Skip to content

Commit

Permalink
Corrected contains code to instanceof
Browse files Browse the repository at this point in the history
  • Loading branch information
EmmanuelMess committed Sep 8, 2017
1 parent 6f668f1 commit 7b5271e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 27 deletions.
19 changes: 8 additions & 11 deletions app/src/main/java/com/amaze/filemanager/fragments/TabFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ public void updatepaths(int pos) {

tabHandler.clear();
for (Fragment fragment : fragments) {
if (fragment.getClass().getName().contains("MainFragment")) {
if (fragment instanceof MainFragment) {
MainFragment m = (MainFragment) fragment;
items.add(parsePathForName(m.getCurrentPath(), m.openMode));
if (i - 1 == MainActivity.currentTab && i == pos) {
Expand Down Expand Up @@ -286,16 +286,13 @@ public void onPageSelected(int p1) {
Log.d(getClass().getSimpleName(), "Page Selected: " + MainActivity.currentTab);

Fragment fragment = fragments.get(p1);
if (fragment != null) {
String name = fragments.get(p1).getClass().getName();
if (name != null && name.contains("Main")) {
MainFragment ma = ((MainFragment) fragments.get(p1));
if (ma.getCurrentPath() != null) {
mainActivity.updateDrawer(ma.getCurrentPath());
mainActivity.getAppbar().getBottomBar().updatePath(ma.getCurrentPath(),
ma.results, MainActivityHelper.SEARCH_TEXT, ma.openMode,
ma.folder_count, ma.file_count, ma);
}
if (fragment != null && fragment instanceof MainFragment) {
MainFragment ma = (MainFragment) fragment;
if (ma.getCurrentPath() != null) {
mainActivity.updateDrawer(ma.getCurrentPath());
mainActivity.getAppbar().getBottomBar().updatePath(ma.getCurrentPath(),
ma.results, MainActivityHelper.SEARCH_TEXT, ma.openMode,
ma.folder_count, ma.file_count, ma);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -952,15 +952,8 @@ public boolean onPrepareOptionsMenu(Menu menu) {
MenuItem s = menu.findItem(R.id.view);
MenuItem search = menu.findItem(R.id.search);
MenuItem paste = menu.findItem(R.id.paste);
String fragmentName;
Fragment fragment;
try {
fragment = getSupportFragmentManager().findFragmentById(R.id.content_frame);
fragmentName = fragment.getClass().getName();
} catch (Exception e) {
return true;
}
if (fragmentName.contains("TabFragment")) {
Fragment fragment = getSupportFragmentManager().findFragmentById(R.id.content_frame);
if (fragment instanceof TabFragment) {
appbar.setTitle("Amaze");
if (useGridView) {
s.setTitle(getResources().getString(R.string.gridview));
Expand Down Expand Up @@ -991,8 +984,8 @@ public boolean onPrepareOptionsMenu(Menu menu) {
menu.findItem(R.id.extract).setVisible(false);
invalidatePasteButton(menu.findItem(R.id.paste));
findViewById(R.id.buttonbarframe).setVisibility(View.VISIBLE);
} else if (fragmentName.contains("AppsListFragment") || fragmentName.contains("ProcessViewerFragment") ||
fragmentName.contains(FTPServerFragment.class.getName())) {
} else if (fragment instanceof AppsListFragment || fragment instanceof ProcessViewerFragment
|| fragment instanceof FTPServerFragment) {
appBarLayout.setExpanded(true);
menu.findItem(R.id.sethome).setVisible(false);
if (indicator_layout != null) indicator_layout.setVisibility(View.GONE);
Expand All @@ -1001,15 +994,16 @@ public boolean onPrepareOptionsMenu(Menu menu) {
menu.findItem(R.id.home).setVisible(false);
menu.findItem(R.id.history).setVisible(false);
menu.findItem(R.id.extract).setVisible(false);
if (fragmentName.contains("ProcessViewerFragment")) menu.findItem(R.id.sort).setVisible(false);
else {
if (fragment instanceof ProcessViewerFragment) {
menu.findItem(R.id.sort).setVisible(false);
} else {
menu.findItem(R.id.dsort).setVisible(false);
menu.findItem(R.id.sortby).setVisible(false);
}
menu.findItem(R.id.hiddenitems).setVisible(false);
menu.findItem(R.id.view).setVisible(false);
menu.findItem(R.id.paste).setVisible(false);
} else if (fragmentName.contains("ZipExplorerFragment")) {
} else if (fragment instanceof ZipExplorerFragment) {
menu.findItem(R.id.sethome).setVisible(false);
if (indicator_layout != null) indicator_layout.setVisibility(View.GONE);
getAppbar().getBottomBar().resetClickListener();
Expand Down Expand Up @@ -1091,8 +1085,9 @@ public void onClick(View v) {
break;
case R.id.sort:
Fragment fragment = getFragmentAtFrame();
if (fragment.getClass().getName().contains("AppsListFragment"))
if (fragment instanceof AppsListFragment) {
GeneralDialogCreation.showSortDialog((AppsListFragment) fragment, getAppTheme());
}
break;
case R.id.sortby:
if (ma != null)
Expand Down Expand Up @@ -1182,8 +1177,9 @@ public void run() {
break;
case R.id.extract:
Fragment fragment1 = getSupportFragmentManager().findFragmentById(R.id.content_frame);
if (fragment1.getClass().getName().contains("ZipExplorerFragment"))
if (fragment1 instanceof ZipExplorerFragment) {
mainActivityHelper.extractFile(((ZipExplorerFragment) fragment1).f);
}
break;
case R.id.search:
getAppbar().getSearchView().revealSearchView();
Expand Down

0 comments on commit 7b5271e

Please sign in to comment.