Browse Source

Refactored drawer variable to be inline with correct naming

master
Anthony Restaino 10 years ago
parent
commit
179a4c2420
  1. 62
      src/acr/browser/lightning/BrowserActivity.java

62
src/acr/browser/lightning/BrowserActivity.java

@ -67,8 +67,8 @@ import java.util.*;
public class BrowserActivity extends Activity implements BrowserController { public class BrowserActivity extends Activity implements BrowserController {
private DrawerLayout mDrawerLayout; private DrawerLayout mDrawerLayout;
private ListView mDrawerList; private ListView mDrawerListLeft;
private RelativeLayout mDrawer; private RelativeLayout mDrawerLeft;
private LinearLayout mDrawerRight; private LinearLayout mDrawerRight;
private ListView mDrawerListRight; private ListView mDrawerListRight;
private RelativeLayout mNewTab; private RelativeLayout mNewTab;
@ -157,11 +157,11 @@ public class BrowserActivity extends Activity implements BrowserController {
mProgressBar = (ProgressBar) findViewById(R.id.activity_bar); mProgressBar = (ProgressBar) findViewById(R.id.activity_bar);
mProgressBar.setVisibility(View.GONE); mProgressBar.setVisibility(View.GONE);
mNewTab = (RelativeLayout) findViewById(R.id.new_tab_button); mNewTab = (RelativeLayout) findViewById(R.id.new_tab_button);
mDrawer = (RelativeLayout) findViewById(R.id.left_drawer); mDrawerLeft = (RelativeLayout) findViewById(R.id.left_drawer);
mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
mDrawerList = (ListView) findViewById(R.id.left_drawer_list); mDrawerListLeft = (ListView) findViewById(R.id.left_drawer_list);
mDrawerList.setDivider(null); mDrawerListLeft.setDivider(null);
mDrawerList.setDividerHeight(0); mDrawerListLeft.setDividerHeight(0);
mDrawerRight = (LinearLayout) findViewById(R.id.right_drawer); mDrawerRight = (LinearLayout) findViewById(R.id.right_drawer);
mDrawerListRight = (ListView) findViewById(R.id.right_drawer_list); mDrawerListRight = (ListView) findViewById(R.id.right_drawer_list);
mDrawerListRight.setDivider(null); mDrawerListRight.setDivider(null);
@ -181,9 +181,9 @@ public class BrowserActivity extends Activity implements BrowserController {
mHomepage = mPreferences.getString(PreferenceConstants.HOMEPAGE, Constants.HOMEPAGE); mHomepage = mPreferences.getString(PreferenceConstants.HOMEPAGE, Constants.HOMEPAGE);
mTitleAdapter = new LightningViewAdapter(this, R.layout.tab_list_item, mWebViews); mTitleAdapter = new LightningViewAdapter(this, R.layout.tab_list_item, mWebViews);
mDrawerList.setAdapter(mTitleAdapter); mDrawerListLeft.setAdapter(mTitleAdapter);
mDrawerList.setOnItemClickListener(new DrawerItemClickListener()); mDrawerListLeft.setOnItemClickListener(new DrawerItemClickListener());
mDrawerList.setOnItemLongClickListener(new DrawerItemLongClickListener()); mDrawerListLeft.setOnItemLongClickListener(new DrawerItemLongClickListener());
mBookmarkList = mBookmarkManager.getBookmarks(true); mBookmarkList = mBookmarkManager.getBookmarks(true);
mBookmarkAdapter = new BookmarkViewAdapter(this, R.layout.bookmark_list_item, mBookmarkList); mBookmarkAdapter = new BookmarkViewAdapter(this, R.layout.bookmark_list_item, mBookmarkList);
@ -215,7 +215,7 @@ public class BrowserActivity extends Activity implements BrowserController {
if (mCurrentView.canGoBack()) { if (mCurrentView.canGoBack()) {
mCurrentView.goBack(); mCurrentView.goBack();
} else { } else {
deleteTab(mDrawerList.getCheckedItemPosition()); deleteTab(mDrawerListLeft.getCheckedItemPosition());
} }
} }
} }
@ -366,23 +366,23 @@ public class BrowserActivity extends Activity implements BrowserController {
@Override @Override
public void onDrawerClosed(View view) { public void onDrawerClosed(View view) {
super.onDrawerClosed(view); super.onDrawerClosed(view);
if (view.equals(mDrawer)) { if (view.equals(mDrawerLeft)) {
mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED, mDrawerRight); mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED, mDrawerRight);
} else if (view.equals(mDrawerRight)) { } else if (view.equals(mDrawerRight)) {
mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED, mDrawer); mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED, mDrawerLeft);
} }
} }
@Override @Override
public void onDrawerOpened(View drawerView) { public void onDrawerOpened(View drawerView) {
super.onDrawerOpened(drawerView); super.onDrawerOpened(drawerView);
if (drawerView.equals(mDrawer)) { if (drawerView.equals(mDrawerLeft)) {
mDrawerLayout.closeDrawer(mDrawerRight); mDrawerLayout.closeDrawer(mDrawerRight);
mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED, mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED,
mDrawerRight); mDrawerRight);
} else if (drawerView.equals(mDrawerRight)) { } else if (drawerView.equals(mDrawerRight)) {
mDrawerLayout.closeDrawer(mDrawer); mDrawerLayout.closeDrawer(mDrawerLeft);
mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED, mDrawer); mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED, mDrawerLeft);
} }
} }
@ -496,19 +496,19 @@ public class BrowserActivity extends Activity implements BrowserController {
int width = getResources().getDisplayMetrics().widthPixels * 3 / 4; int width = getResources().getDisplayMetrics().widthPixels * 3 / 4;
int maxWidth = Utils.convertToDensityPixels(mContext, 300); int maxWidth = Utils.convertToDensityPixels(mContext, 300);
if (width > maxWidth) { if (width > maxWidth) {
DrawerLayout.LayoutParams params = (android.support.v4.widget.DrawerLayout.LayoutParams) mDrawer DrawerLayout.LayoutParams params = (android.support.v4.widget.DrawerLayout.LayoutParams) mDrawerLeft
.getLayoutParams(); .getLayoutParams();
params.width = maxWidth; params.width = maxWidth;
mDrawer.setLayoutParams(params); mDrawerLeft.setLayoutParams(params);
DrawerLayout.LayoutParams paramsRight = (android.support.v4.widget.DrawerLayout.LayoutParams) mDrawerRight DrawerLayout.LayoutParams paramsRight = (android.support.v4.widget.DrawerLayout.LayoutParams) mDrawerRight
.getLayoutParams(); .getLayoutParams();
paramsRight.width = maxWidth; paramsRight.width = maxWidth;
mDrawerRight.setLayoutParams(paramsRight); mDrawerRight.setLayoutParams(paramsRight);
} else { } else {
DrawerLayout.LayoutParams params = (android.support.v4.widget.DrawerLayout.LayoutParams) mDrawer DrawerLayout.LayoutParams params = (android.support.v4.widget.DrawerLayout.LayoutParams) mDrawerLeft
.getLayoutParams(); .getLayoutParams();
params.width = width; params.width = width;
mDrawer.setLayoutParams(params); mDrawerLeft.setLayoutParams(params);
DrawerLayout.LayoutParams paramsRight = (android.support.v4.widget.DrawerLayout.LayoutParams) mDrawerRight DrawerLayout.LayoutParams paramsRight = (android.support.v4.widget.DrawerLayout.LayoutParams) mDrawerRight
.getLayoutParams(); .getLayoutParams();
paramsRight.width = width; paramsRight.width = width;
@ -651,9 +651,9 @@ public class BrowserActivity extends Activity implements BrowserController {
if (mDrawerToggle.onOptionsItemSelected(item)) { if (mDrawerToggle.onOptionsItemSelected(item)) {
if (mDrawerLayout.isDrawerOpen(mDrawerRight)) { if (mDrawerLayout.isDrawerOpen(mDrawerRight)) {
mDrawerLayout.closeDrawer(mDrawerRight); mDrawerLayout.closeDrawer(mDrawerRight);
mDrawerLayout.openDrawer(mDrawer); mDrawerLayout.openDrawer(mDrawerLeft);
} else if (mDrawerLayout.isDrawerOpen(mDrawer)) { } else if (mDrawerLayout.isDrawerOpen(mDrawerLeft)) {
mDrawerLayout.closeDrawer(mDrawer); mDrawerLayout.closeDrawer(mDrawerLeft);
} }
mDrawerToggle.syncState(); mDrawerToggle.syncState();
return true; return true;
@ -1030,7 +1030,7 @@ public class BrowserActivity extends Activity implements BrowserController {
mActionBar.setIcon(icon); mActionBar.setIcon(icon);
mTitleAdapter.notifyDataSetChanged(); mTitleAdapter.notifyDataSetChanged();
if (show) { if (show) {
mDrawerList.setItemChecked(mWebViews.size() - 1, true); mDrawerListLeft.setItemChecked(mWebViews.size() - 1, true);
showTab(startingTab); showTab(startingTab);
} }
} }
@ -1040,7 +1040,7 @@ public class BrowserActivity extends Activity implements BrowserController {
return; return;
} }
int current = mDrawerList.getCheckedItemPosition(); int current = mDrawerListLeft.getCheckedItemPosition();
LightningView reference = mWebViews.get(position); LightningView reference = mWebViews.get(position);
if (reference == null) { if (reference == null) {
return; return;
@ -1052,14 +1052,14 @@ public class BrowserActivity extends Activity implements BrowserController {
if (current > position) { if (current > position) {
mIdList.remove(position); mIdList.remove(position);
mWebViews.remove(position); mWebViews.remove(position);
mDrawerList.setItemChecked(current - 1, true); mDrawerListLeft.setItemChecked(current - 1, true);
reference.onDestroy(); reference.onDestroy();
} else if (mWebViews.size() > position + 1) { } else if (mWebViews.size() > position + 1) {
mIdList.remove(position); mIdList.remove(position);
if (current == position) { if (current == position) {
showTab(mWebViews.get(position + 1)); showTab(mWebViews.get(position + 1));
mWebViews.remove(position); mWebViews.remove(position);
mDrawerList.setItemChecked(position, true); mDrawerListLeft.setItemChecked(position, true);
} else { } else {
mWebViews.remove(position); mWebViews.remove(position);
} }
@ -1070,7 +1070,7 @@ public class BrowserActivity extends Activity implements BrowserController {
if (current == position) { if (current == position) {
showTab(mWebViews.get(position - 1)); showTab(mWebViews.get(position - 1));
mWebViews.remove(position); mWebViews.remove(position);
mDrawerList.setItemChecked(position - 1, true); mDrawerListLeft.setItemChecked(position - 1, true);
} else { } else {
mWebViews.remove(position); mWebViews.remove(position);
} }
@ -1188,8 +1188,8 @@ public class BrowserActivity extends Activity implements BrowserController {
if (!mActionBar.isShowing()) { if (!mActionBar.isShowing()) {
mActionBar.show(); mActionBar.show();
} }
if (mDrawerLayout.isDrawerOpen(mDrawer)) { if (mDrawerLayout.isDrawerOpen(mDrawerLeft)) {
mDrawerLayout.closeDrawer(mDrawer); mDrawerLayout.closeDrawer(mDrawerLeft);
} else if (mDrawerLayout.isDrawerOpen(mDrawerRight)) { } else if (mDrawerLayout.isDrawerOpen(mDrawerRight)) {
mDrawerLayout.closeDrawer(mDrawerRight); mDrawerLayout.closeDrawer(mDrawerRight);
} else { } else {
@ -1202,7 +1202,7 @@ public class BrowserActivity extends Activity implements BrowserController {
mCurrentView.goBack(); mCurrentView.goBack();
} }
} else { } else {
deleteTab(mDrawerList.getCheckedItemPosition()); deleteTab(mDrawerListLeft.getCheckedItemPosition());
} }
} else { } else {
Log.e(Constants.TAG, "So madness. Much confusion. Why happen."); Log.e(Constants.TAG, "So madness. Much confusion. Why happen.");
@ -1796,7 +1796,7 @@ public class BrowserActivity extends Activity implements BrowserController {
* helper function that opens the bookmark drawer * helper function that opens the bookmark drawer
*/ */
private void openBookmarks() { private void openBookmarks() {
if (mDrawerLayout.isDrawerOpen(mDrawer)) { if (mDrawerLayout.isDrawerOpen(mDrawerLeft)) {
mDrawerLayout.closeDrawers(); mDrawerLayout.closeDrawers();
} }
mDrawerToggle.syncState(); mDrawerToggle.syncState();

Loading…
Cancel
Save