Java Code Examples for android.support.v4.app.Fragment#getTag()
The following examples show how to use
android.support.v4.app.Fragment#getTag() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PagePresenter.java From java-n-IDE-for-Android with Apache License 2.0 | 6 votes |
@Override public void removePage(int position) { if (position >= mPageAdapter.getCount() || position < 0) { return; } Fragment existingFragment = mPageAdapter.getExistingFragment(position); if (existingFragment == null) { if (DLog.DEBUG) DLog.d(TAG, "removePage: " + "null page " + position); return; } //delete in database String filePath = existingFragment.getTag(); mFileManager.removeTabFile(filePath); //remove page mPageAdapter.remove(position); invalidateTab(); Toast.makeText(mContext, mContext.getString(R.string.closed) + " " + new File(filePath).getName(), Toast.LENGTH_SHORT).show(); }
Example 2
Source File: DappBrowserFragment.java From alpha-wallet-android with MIT License | 6 votes |
@Override public void onAttachFragment(Fragment fragment) { if (getContext() != null && fragment.getTag() != null) { switch (fragment.getTag()) { case DAPP_HOME: ((DappHomeFragment) fragment).setCallbacks(this, this); break; case DISCOVER_DAPPS: ((DiscoverDappsFragment) fragment).setCallbacks(this); break; case MY_DAPPS: ((MyDappsFragment) fragment).setCallbacks(this); break; case HISTORY: ((BrowserHistoryFragment) fragment).setCallbacks(this, this); break; case DAPP_BROWSER: break; default: //no init break; } } }
Example 3
Source File: RxLoaderBackendNestedFragmentCompat.java From rxloader with Apache License 2.0 | 6 votes |
private String getStateId() { if (stateId != null) { return stateId; } Fragment parentFragment = getParentFragment(); stateId = parentFragment.getTag(); if (stateId == null) { int id = parentFragment.getId(); if (id > 0) { stateId = Integer.toString(id); } } if (stateId == null) { throw new IllegalStateException("Fragment dose not have a valid id"); } return stateId; }
Example 4
Source File: LancetHook.java From Trojan with Apache License 2.0 | 5 votes |
private static String getSupportFragInfo(Fragment fragment) { StringBuilder info = new StringBuilder(); String className = fragment.getClass().getName(); info.append(className); if (fragment.getTag() != null) { info.append(":"); info.append(fragment.getTag()); } return info.toString(); }
Example 5
Source File: SwipeAdapter.java From Rey-MusicPlayer with Apache License 2.0 | 5 votes |
@Override public Object instantiateItem(ViewGroup container, int position) { Object obj = super.instantiateItem(container, position); if (obj instanceof Fragment) { Fragment f = (Fragment) obj; String tag = f.getTag(); mFragmentTags.put(position, tag); } return obj; }
Example 6
Source File: SectionsPagerAdapterCurrencyList.java From CryptoBuddy with GNU Affero General Public License v3.0 | 5 votes |
@Override public Object instantiateItem(ViewGroup container, int position) { Object object = super.instantiateItem(container, position); if (object instanceof Fragment) { Fragment fragment = (Fragment) object; String tag = fragment.getTag(); mFragmentTags.put(position, tag); } return object; }
Example 7
Source File: MainNavigationActivity.java From beaconloc with Apache License 2.0 | 5 votes |
@OnClick(R.id.fab) void navAction() { Fragment currentFragment = getFragmentInstance(R.id.content_frame); if (currentFragment != null) { String tag = currentFragment.getTag(); switch (tag) { case Constants.TAG_FRAGMENT_SCAN_LIST: case Constants.TAG_FRAGMENT_SCAN_RADAR: ((ScanFragment) currentFragment).scanStartStopAction(); break; case Constants.TAG_FRAGMENT_TRACKED_BEACON_LIST: } } }
Example 8
Source File: MainNavigationActivity.java From beaconloc with Apache License 2.0 | 5 votes |
public void swappingFloatingIcon() { Fragment currentFragment = getFragmentInstance(R.id.content_frame); String tag = currentFragment.getTag(); switch (tag) { case Constants.TAG_FRAGMENT_SCAN_LIST: case Constants.TAG_FRAGMENT_SCAN_RADAR: swappingFabUp(); break; default: hideFab(); } }
Example 9
Source File: FragmentIdHelper.java From android-task with Apache License 2.0 | 5 votes |
public static String getFragmentId(Fragment fragment) { String index = getIndex(fragment); int id = fragment.getId(); String tag = fragment.getTag(); if (tag == null) { tag = "null"; } return index + '/' + id + '/' + tag; }
Example 10
Source File: FragmentStack.java From fragmentstack with Apache License 2.0 | 5 votes |
public void saveState(Bundle outState) { executePendingTransactions(); final int stackSize = stack.size(); String[] stackTags = new String[stackSize]; int i = 0; for (Fragment f : stack) { stackTags[i++] = f.getTag(); } outState.putStringArray(STATE_STACK, stackTags); }
Example 11
Source File: MainActivity.java From YTPlayer with GNU General Public License v3.0 | 4 votes |
@Override public void onBackPressed() { Fragment fragment = getSupportFragmentManager().findFragmentById(R.id.fragment_container); if (getSupportFragmentManager().getBackStackEntryCount() > 0) { getSupportFragmentManager().popBackStack(); return; } if (fragment instanceof PopularFragment) { loadFragment(SearchFrag); return; } if (fragment instanceof SFragment) { loadFragment(SearchFrag); return; } if (fragment instanceof DiscoverFragment) { loadFragment(SearchFrag); return; } if (fragment instanceof LocalSearchFragment) { loadFragment(localMusicFrag); return; } if (fragment instanceof OPlaylistFragment && fragment.getTag() != null && fragment.getTag().equals("localMusic")) { loadFragment(localMusicFrag); return; } if (fragment instanceof OPlaylistFragment && loadedFavFrag) { loadedFavFrag = false; loadFragment(libraryFrag); return; } if (fragment instanceof OPlaylistFragment) { loadFragment(PlaylistFrag); return; } if (fragment instanceof PlaylistFragment) { loadFragment(libraryFrag); return; } if (fragment instanceof LocalMusicFragment) { loadFragment(libraryFrag); return; } if (doubleBackToExitPressedOnce) { super.onBackPressed(); return; } this.doubleBackToExitPressedOnce = true; Toast.makeText(this, "Press back once more to exit.", Toast.LENGTH_SHORT).show(); new Handler().postDelayed(new Runnable() { @Override public void run() { doubleBackToExitPressedOnce = false; } }, 2000); }
Example 12
Source File: ViewPagerMainMenuAdapter.java From mangosta-android with Apache License 2.0 | 4 votes |
@Override public Object instantiateItem(ViewGroup container, int position) { Fragment createdFragment = (Fragment) super.instantiateItem(container, position); mFragmentListTags[position] = createdFragment.getTag(); return createdFragment; }
Example 13
Source File: FragmentCompatSupportLib.java From weex with Apache License 2.0 | 4 votes |
@Nullable @Override public String getTag(Fragment fragment) { return fragment.getTag(); }
Example 14
Source File: FragmentCompatSupportLib.java From stetho with MIT License | 4 votes |
@Nullable @Override public String getTag(Fragment fragment) { return fragment.getTag(); }
Example 15
Source File: MainActivity.java From Woodmin with Apache License 2.0 | 4 votes |
@Override public void onNavigationDrawerItemSelected(int position) { FragmentManager fragmentManager = getSupportFragmentManager(); List<Fragment> allFragments = fragmentManager.getFragments(); switch (position) { case 0: fragmentManager.beginTransaction() .replace(R.id.container, ResumeFragment.newInstance(position),"section") .commit(); /* mTitle = getString(R.string.app_name); if (allFragments != null && allFragments.size() > 0) { for (Fragment frag : allFragments) { if (frag!= null && frag.getTag()!= null && frag.getTag().equals("section")){ fragmentManager.beginTransaction().remove(frag).commit(); } } } */ break; case 1: fragmentManager.beginTransaction() .replace(R.id.container, OrdersFragment.newInstance(position),"section") .commit(); break; case 2: fragmentManager.beginTransaction() .replace(R.id.container, ProductsFragment.newInstance(position),"section") .commit(); break; case 3: fragmentManager.beginTransaction() .replace(R.id.container, CustomersFragment.newInstance(position),"section") .commit(); break; case 4: mTitle = getString(R.string.title_section5); if (allFragments != null && allFragments.size() > 0) { for (Fragment frag : allFragments) { if (frag!= null && frag.getTag()!= null && frag.getTag().equals("section")){ fragmentManager.beginTransaction().remove(frag).commit(); } } } //Clear database getApplicationContext().getContentResolver().delete(WoodminContract.CustomerEntry.CONTENT_URI, null, null); getApplicationContext().getContentResolver().delete(WoodminContract.ProductEntry.CONTENT_URI, null, null); getApplicationContext().getContentResolver().delete(WoodminContract.ShopEntry.CONTENT_URI, null, null); getApplicationContext().getContentResolver().delete(WoodminContract.OrdersEntry.CONTENT_URI, null, null); //Remove Sync WoodminSyncAdapter.disablePeriodSync(getApplicationContext()); WoodminSyncAdapter.removeAccount(getApplicationContext()); //Remove Preferences Utility.setPreferredServer(getApplicationContext(), null); Utility.setPreferredLastSync(getApplicationContext(), 0L); Utility.setPreferredUserSecret(getApplicationContext(), null, null); Utility.setPreferredShoppingCard(getApplicationContext(), null); Intent main = new Intent(getApplicationContext(), LoginActivity.class); startActivity(main); finish(); break; } }
Example 16
Source File: MainActivity.java From Woodmin with Apache License 2.0 | 4 votes |
@Override public void onNavigationDrawerItemSelected(int position) { FragmentManager fragmentManager = getSupportFragmentManager(); List<Fragment> allFragments = fragmentManager.getFragments(); switch (position) { case 0: fragmentManager.beginTransaction() .replace(R.id.container, ResumeFragment.newInstance(position),"section") .commit(); /* mTitle = getString(R.string.app_name); if (allFragments != null && allFragments.size() > 0) { for (Fragment frag : allFragments) { if (frag!= null && frag.getTag()!= null && frag.getTag().equals("section")){ fragmentManager.beginTransaction().remove(frag).commit(); } } } */ break; case 1: fragmentManager.beginTransaction() .replace(R.id.container, OrdersFragment.newInstance(position),"section") .commit(); break; case 2: fragmentManager.beginTransaction() .replace(R.id.container, ProductsFragment.newInstance(position),"section") .commit(); break; case 3: fragmentManager.beginTransaction() .replace(R.id.container, CustomersFragment.newInstance(position),"section") .commit(); break; case 4: mTitle = getString(R.string.title_section5); if (allFragments != null && allFragments.size() > 0) { for (Fragment frag : allFragments) { if (frag!= null && frag.getTag()!= null && frag.getTag().equals("section")){ fragmentManager.beginTransaction().remove(frag).commit(); } } } //Clear database getApplicationContext().getContentResolver().delete(WoodminContract.CustomerEntry.CONTENT_URI, null, null); getApplicationContext().getContentResolver().delete(WoodminContract.ProductEntry.CONTENT_URI, null, null); getApplicationContext().getContentResolver().delete(WoodminContract.ShopEntry.CONTENT_URI, null, null); getApplicationContext().getContentResolver().delete(WoodminContract.OrdersEntry.CONTENT_URI, null, null); //Remove Sync WoodminSyncAdapter.disablePeriodSync(getApplicationContext()); WoodminSyncAdapter.removeAccount(getApplicationContext()); //Remove Preferences Utility.setPreferredServer(getApplicationContext(), null); Utility.setPreferredLastSync(getApplicationContext(), 0L); Utility.setPreferredUserSecret(getApplicationContext(), null, null); Utility.setPreferredShoppingCard(getApplicationContext(), null); Intent main = new Intent(getApplicationContext(), LoginActivity.class); startActivity(main); finish(); break; } }