List of usage examples for android.support.v4.app FragmentManager findFragmentByTag
public abstract Fragment findFragmentByTag(String tag);
From source file:com.heneryh.aquanotes.ui.SearchActivity.java
/** * Build and add "vendors" tab./*from w w w .j a v a 2 s . c om*/ */ private void setupVendorsTab() { // TODO: this is very inefficient and messy, clean it up FrameLayout fragmentContainer = new FrameLayout(this); fragmentContainer.setId(R.id.fragment_controllers); fragmentContainer.setLayoutParams( new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT)); ((ViewGroup) findViewById(android.R.id.tabcontent)).addView(fragmentContainer); final FragmentManager fm = getSupportFragmentManager(); mVendorsFragment = (DbMaintControllersFragment) fm.findFragmentByTag("vendors"); if (mVendorsFragment == null) { mVendorsFragment = new DbMaintControllersFragment(); mVendorsFragment.setArguments(getVendorsFragmentArguments()); fm.beginTransaction().add(R.id.fragment_controllers, mVendorsFragment, "vendors").commit(); } else { mVendorsFragment.reloadFromArguments(getVendorsFragmentArguments()); } // Vendors content comes from reused activity mTabHost.addTab(mTabHost.newTabSpec(TAG_VENDORS).setIndicator(buildIndicator(R.string.db_maint_controllers)) .setContent(R.id.fragment_controllers)); }
From source file:com.github.jobs.ui.fragment.SOUserPickerFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); setHasOptionsMenu(true);//ww w. jav a 2 s.c om FragmentManager fm = getFragmentManager(); mSOUserFetcherReceiver = (SOUserFetcherReceiver) fm.findFragmentByTag(ReceiverFragment.TAG); if (mSOUserFetcherReceiver == null) { mSOUserFetcherReceiver = new SOUserFetcherReceiver(); fm.beginTransaction().add(mSOUserFetcherReceiver, ReceiverFragment.TAG).commitAllowingStateLoss(); } mUserSearch = (EditText) getView().findViewById(R.id.edit_user_search); mUserSearch.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_SEARCH) { executeSearch(mUserSearch.getText().toString().trim()); return true; } return false; } }); ListView userList = (ListView) getView().findViewById(R.id.users_list); mAdapter = new SOUsersAdapter(getActivity()); if (savedInstanceState != null && savedInstanceState.containsKey(KEY_USERS)) { ArrayList<Parcelable> items = savedInstanceState.getParcelableArrayList(KEY_USERS); ArrayList<SOUser> users = new ArrayList<SOUser>(); for (Parcelable item : items) { users.add((SOUser) item); } mAdapter.updateItems(users); } userList.setOnItemClickListener(this); userList.setAdapter(mAdapter); String search = getActivity().getIntent().getStringExtra(SOUserPickerActivity.EXTRA_SEARCH); if (search == null) { if (savedInstanceState != null && savedInstanceState.containsKey(KEY_SEARCH)) { search = savedInstanceState.getString(KEY_SEARCH); mUserSearch.setText(search); mUserSearch.setSelection(search.length()); } else { search = ""; } } mUserSearch.setText(search); mUserSearch.setSelection(search.length()); if (savedInstanceState == null) { // this will execute search only the first time the activity is open executeSearch(search); } }
From source file:com.nomprenom2.view.NameParamsFragment.java
/** * processe fragment item remove/*from w w w .j a v a2 s . com*/ * @param frag_name */ public void onFragmentInteraction(String frag_name) { FragmentManager mngr = getFragmentManager(); FragmentTransaction tr = mngr.beginTransaction(); Fragment fr = mngr.findFragmentByTag(frag_name); if (fr != null) { tr.remove(fr); regions.remove(frag_name); } tr.commit(); }
From source file:com.digi.android.wva.FaultCodeActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.fault_code_activity); ActionBar ab = getSupportActionBar(); ab.setDisplayHomeAsUpEnabled(true);// w w w .j a v a 2 s .c o m ab.setTitle("Fault Code Browser"); // Figure out if the layout has space for two fragments. twoColumns = (findViewById(R.id.faultCodeDetailFragment) != null); FragmentManager fm = getSupportFragmentManager(); // FaultCodeBrowsingFragment uses setRetainInstance, so that a single fragment instance // can persist between configuration changes (e.g. screen rotation) if (fm.findFragmentByTag(BROWSE_FRAG_TAG) == null) { // Fresh instance of the activity FragmentTransaction transaction = fm.beginTransaction(); transaction.replace(R.id.faultCodeFragment, new FaultCodeBrowsingFragment(), BROWSE_FRAG_TAG); transaction.commit(); } }
From source file:com.fastbootmobile.encore.app.PlaylistActivity.java
@Override @TargetApi(Build.VERSION_CODES.LOLLIPOP) protected void onCreate(Bundle savedInstance) { super.onCreate(savedInstance); setContentView(R.layout.activity_playlist); FragmentManager fm = getSupportFragmentManager(); mActiveFragment = (PlaylistViewFragment) fm.findFragmentByTag(TAG_FRAGMENT); if (savedInstance == null) { mInitialIntent = getIntent().getExtras(); } else {//from w w w .j a v a 2 s .com mInitialIntent = savedInstance.getBundle(EXTRA_RESTORE_INTENT); } if (mActiveFragment == null) { mActiveFragment = new PlaylistViewFragment(); fm.beginTransaction().add(R.id.playlist_container, mActiveFragment, TAG_FRAGMENT).commit(); mActiveFragment.setArguments(mInitialIntent); } // Remove the activity title as we don't want it here mToolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(mToolbar); final ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setHomeButtonEnabled(true); actionBar.setTitle(""); } mIsEntering = true; if (Utils.hasLollipop()) { setEnterSharedElementCallback(new SharedElementCallback() { @Override public void onMapSharedElements(List<String> names, Map<String, View> sharedElements) { View imageHeader = mActiveFragment.getHeroImageView(); if (imageHeader != null) { sharedElements.put("itemImage", imageHeader); } View albumName = mActiveFragment.findViewById(R.id.tvAlbumName); if (albumName != null) { final int cx = albumName.getMeasuredWidth() / 4; final int cy = albumName.getMeasuredHeight() / 2; final int duration = getResources().getInteger(android.R.integer.config_mediumAnimTime); final int radius = Utils.getEnclosingCircleRadius(albumName, cx, cy); if (albumName.isAttachedToWindow()) { if (mIsEntering) { albumName.setVisibility(View.INVISIBLE); Utils.animateCircleReveal(albumName, cx, cy, 0, radius, duration, 300); } else { albumName.setVisibility(View.VISIBLE); Utils.animateCircleReveal(albumName, cx, cy, radius, 0, duration, 0); } } } } }); } getWindow().getDecorView() .setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN); }
From source file:com.ibuildapp.ZopimChatPlugin.ZopimChat.java
private void resumeChat() { FragmentManager manager = getSupportFragmentManager(); if (manager.findFragmentByTag(ZopimChatLogFragment.class.getName()) == null) { FragmentTransaction transaction = manager.beginTransaction(); transaction.add(R.id.chat_fragment_container, new ZopimChatLogFragment(), ZopimChatLogFragment.class.getName()); transaction.commit();//w ww .j a v a2 s . co m } overDrawRightButton(); }
From source file:com.nextgis.ngm_clink_monitoring.dialogs.DistanceExceededDialog.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setRetainInstance(true);/* w w w.j av a2s .c o m*/ if (null != savedInstanceState) { mObjectLayerName = savedInstanceState.getString(FoclConstants.OBJECT_LAYER_NAME); mDistance = savedInstanceState.getFloat(FoclConstants.DISTANCE); } GISApplication app = (GISApplication) getActivity().getApplication(); mGpsEventSource = app.getGpsEventSource(); if (null != mGpsEventSource) { mGpsEventSource.addListener(this); } FragmentManager fm = getActivity().getSupportFragmentManager(); CreateObjectFragment createObjectFragment = (CreateObjectFragment) fm .findFragmentByTag(FoclConstants.FRAGMENT_CREATE_OBJECT); if (null != createObjectFragment) { mOnRepeatClickedListener = createObjectFragment; mOnNewPointClickedListener = createObjectFragment; } }
From source file:com.grayfox.android.app.activity.MainActivity.java
public void setupFragment(Fragment fragment) { FragmentManager fragmentManager = getSupportFragmentManager(); Fragment currentFragment = fragmentManager.findFragmentByTag(FRAGMENT_TAG); if (currentFragment == null || !currentFragment.getClass().equals(fragment.getClass())) { fragmentManager.beginTransaction().replace(R.id.content_frame, fragment, FRAGMENT_TAG).commit(); }//from w w w . j av a 2s.c o m }
From source file:com.audacity.booster.fragments.DetectorFragment.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // If there already exists fragments doing work, reattach to them FragmentManager fm = getFragmentManager(); DetectorTaskFragment taskFragment = (DetectorTaskFragment) fm.findFragmentByTag(DetectorTaskFragment.TAG); if (taskFragment != null) { taskFragment.setTargetFragment(this, DetectorTaskFragment.TASK_REQUEST_CODE); }/*from w w w. ja v a2s . c o m*/ Fragment dialogFragment = fm.findFragmentByTag(NativeDetectionDialogFragment.TAG); if (dialogFragment != null) { dialogFragment.setTargetFragment(this, NativeDetectionDialogFragment.TASK_REQUEST_CODE); } }
From source file:at.ac.uniklu.mobile.sportal.ExamListActivity.java
@Override public void refreshFragments() { FragmentManager fm = getSupportFragmentManager(); for (String tag : mFragmentRefreshRegistry) { Fragment f = fm.findFragmentByTag(tag); if (f != null) ((FragmentRefreshable) f).refresh(); }/*from www. j a va 2s . c o m*/ mFragmentRefreshRegistry.clear(); }