List of usage examples for android.app FragmentTransaction hide
public abstract FragmentTransaction hide(Fragment fragment);
From source file:com.zte.permissioncontrol.ui.PermissionControlPageActivity.java
protected void removeUI() { Log.d(TAG, "removeUI()"); // must get a new transaction each time FragmentTransaction transaction = getFragmentManager().beginTransaction(); // set empty view to visible mEmptyView.setVisibility(View.VISIBLE); // remove all the fragment mPermissionsFragment = (PermissionsFragment) getFragmentManager().findFragmentByTag(mPermissionsTag); if (mPermissionsFragment != null) { transaction.hide(mPermissionsFragment); transaction.hide(mAppsFragment); }/*ww w.j a v a 2 s.c o m*/ transaction.commit(); getFragmentManager().executePendingTransactions(); // remove tabs on actionbar mActionBarAdapter.removeAllTab(); }
From source file:com.bt.download.android.gui.activities.MainActivity.java
private FragmentTransaction hideFragments(FragmentTransaction ts) { return ts.hide(search).hide(library).hide(transfers).hide(peers).hide(peersDisabled).hide(about); }
From source file:org.kymjs.kjframe.KJActivity.java
/** * Fragment?/*ww w. ja v a 2 s . c om*/ * * @param resView ?? * @param targetFragment ??Fragment */ public void changeFragment(int resView, KJFragment targetFragment) { if (targetFragment.equals(currentKJFragment)) { return; } FragmentTransaction transaction = getFragmentManager().beginTransaction(); if (!targetFragment.isAdded()) { transaction.add(resView, targetFragment, targetFragment.getClass().getName()); } if (targetFragment.isHidden()) { transaction.show(targetFragment); targetFragment.onChange(); } if (currentKJFragment != null && currentKJFragment.isVisible()) { transaction.hide(currentKJFragment); } currentKJFragment = targetFragment; transaction.commit(); }
From source file:org.kymjs.kjframe.KJActivity.java
/** * Fragment?/*from ww w .j av a 2s . c o m*/ * * @param resView ?? * @param targetFragment ??Fragment * @param isBack ??true */ public void changeFragment(int resView, KJFragment targetFragment, boolean isBack) { if (targetFragment.equals(currentKJFragment)) { return; } FragmentTransaction transaction = getFragmentManager().beginTransaction(); if (!targetFragment.isAdded()) { transaction.add(resView, targetFragment, targetFragment.getClass().getName()); } if (targetFragment.isHidden()) { transaction.show(targetFragment); targetFragment.onChange(); } if (currentKJFragment != null && currentKJFragment.isVisible()) { transaction.hide(currentKJFragment); } if (isBack) { transaction.addToBackStack(null); } currentKJFragment = targetFragment; transaction.commit(); }
From source file:com.tassadar.multirommgr.MainActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (Build.VERSION.SDK_INT == 20) { showDeprecatedLAlert();//from w w w .j a va 2 s .co m return; } setContentView(R.layout.activity_main); // This activity is using different background color, which would cause overdraw // of the whole area, so disable the default background getWindow().setBackgroundDrawable(null); Utils.installHttpCache(this); PreferenceManager.setDefaultValues(this, R.xml.settings, false); m_srLayout = (MultiROMSwipeRefreshLayout) findViewById(R.id.refresh_layout); m_srLayout.setOnRefreshListener(this); m_curFragment = -1; m_fragmentTitles = getResources().getStringArray(R.array.main_fragment_titles); m_drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); m_drawerList = (ListView) findViewById(R.id.left_drawer); String[] fragmentClsNames = new String[MainFragment.MAIN_FRAG_CNT]; for (int i = 0; i < fragmentClsNames.length; ++i) fragmentClsNames[i] = MainFragment.getFragmentClass(i).getName(); m_fragments = new MainFragment[MainFragment.MAIN_FRAG_CNT]; FragmentManager fragmentManager = getFragmentManager(); FragmentTransaction t = fragmentManager.beginTransaction(); for (int i = 0; i < m_fragments.length; ++i) { m_fragments[i] = (MainFragment) fragmentManager.findFragmentByTag(fragmentClsNames[i]); if (m_fragments[i] == null) { m_fragments[i] = MainFragment.newFragment(i); t.add(R.id.content_frame, m_fragments[i], fragmentClsNames[i]); } t.hide(m_fragments[i]); } t.commit(); // Set the adapter for the list view m_drawerList.setAdapter(new ArrayAdapter<String>(this, R.layout.drawer_list_item, m_fragmentTitles)); // Set the list's click listener m_drawerList.setOnItemClickListener(new DrawerItemClickListener()); m_drawerTitle = getText(R.string.app_name); m_drawerToggle = new ActionBarDrawerToggle(this, m_drawerLayout, R.string.drawer_open, R.string.drawer_close) { public void onDrawerClosed(View view) { getSupportActionBar().setTitle(m_title); } public void onDrawerOpened(View drawerView) { getSupportActionBar().setTitle(m_drawerTitle); } }; m_drawerLayout.setDrawerListener(m_drawerToggle); final ActionBar bar = getSupportActionBar(); if (bar != null) { bar.setDisplayHomeAsUpEnabled(true); bar.setHomeButtonEnabled(true); } if (getIntent().hasExtra(INTENT_EXTRA_SHOW_ROM_LIST) && getIntent().getBooleanExtra(INTENT_EXTRA_SHOW_ROM_LIST, false)) { getIntent().removeExtra(INTENT_EXTRA_SHOW_ROM_LIST); selectItem(1); } else if (savedInstanceState != null) { selectItem(savedInstanceState.getInt("curFragment", 0)); } else { selectItem(0); } }
From source file:us.shandian.blacklight.ui.main.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { if (hasSmartBar()) { getWindow().setUiOptions(ActivityInfo.UIOPTION_SPLIT_ACTION_BAR_WHEN_NARROW); }/*w w w . j a v a 2 s.co m*/ Utility.initDarkMode(this); super.onCreate(savedInstanceState); setContentView(R.layout.main); // Tint Utility.enableTint(this); // Detect if the user chose to use right-handed mode boolean rightHanded = Settings.getInstance(this).getBoolean(Settings.RIGHT_HANDED, false); mDrawerGravity = rightHanded ? Gravity.RIGHT : Gravity.LEFT; // Set gravity View nav = findViewById(R.id.nav); DrawerLayout.LayoutParams p = (DrawerLayout.LayoutParams) nav.getLayoutParams(); p.gravity = mDrawerGravity; nav.setLayoutParams(p); // Initialize naviagtion drawer mDrawer = (DrawerLayout) findViewById(R.id.drawer); mToggle = new ActionBarDrawerToggle(this, mDrawer, R.drawable.ic_drawer_l, 0, 0) { @Override public void onDrawerOpened(View drawerView) { super.onDrawerOpened(drawerView); getActionBar().show(); invalidateOptionsMenu(); if (mLastChoice == null) { mLastChoice = (TextView) mMy.getChildAt(0); mLastChoice.getPaint().setFakeBoldText(true); mLastChoice.invalidate(); } ((HomeTimeLineFragment) mFragments[0]).hideFAB(); } @Override public void onDrawerClosed(View drawerView) { invalidateOptionsMenu(); if (mNext == 0) { ((HomeTimeLineFragment) mFragments[0]).showFAB(); } } }; mDrawer.setDrawerListener(mToggle); if (mDrawerGravity == Gravity.LEFT) { mDrawer.setDrawerShadow(R.drawable.drawer_shadow, Gravity.LEFT); } mMy = (ListView) findViewById(R.id.list_my); mAtMe = (ListView) findViewById(R.id.list_at_me); mOther = (ListView) findViewById(R.id.list_other); mMy.setVerticalScrollBarEnabled(false); mMy.setChoiceMode(ListView.CHOICE_MODE_NONE); mAtMe.setVerticalScrollBarEnabled(false); mAtMe.setChoiceMode(ListView.CHOICE_MODE_NONE); mOther.setVerticalScrollBarEnabled(false); mOther.setChoiceMode(ListView.CHOICE_MODE_NONE); mMy.setOnItemClickListener(this); mAtMe.setOnItemClickListener(this); mOther.setOnItemClickListener(this); // My account mName = (TextView) findViewById(R.id.my_name); mName.getPaint().setFakeBoldText(true); mAvatar = (ImageView) findViewById(R.id.my_avatar); mLoginCache = new LoginApiCache(this); mUserCache = new UserApiCache(this); initList(); new InitializerTask().execute(); new GroupsTask().execute(); findViewById(R.id.my_account).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (mUser != null) { Intent i = new Intent(); i.setAction(Intent.ACTION_MAIN); i.setClass(MainActivity.this, UserTimeLineActivity.class); i.putExtra("user", mUser); startActivity(i); } } }); // Initialize ActionBar Style getActionBar().setHomeButtonEnabled(true); // Ignore first spinner event mIgnore = true; // Fragments mFragments[0] = new HomeTimeLineFragment(); mFragments[1] = new CommentTimeLineFragment(); mFragments[2] = new FavListFragment(); mFragments[3] = new DirectMessageUserFragment(); mFragments[4] = new MentionsTimeLineFragment(); mFragments[5] = new CommentMentionsTimeLineFragment(); mFragments[6] = new SearchFragment(); mManager = getFragmentManager(); FragmentTransaction ft = mManager.beginTransaction(); for (Fragment f : mFragments) { ft.add(R.id.container, f); ft.hide(f); } ft.commit(); switchTo(0); }
From source file:org.kymjs.kjframe.KJActivity.java
/** * Fragment?//from www . java 2 s . co m * * @param resView ?? * @param targetFragment ??Fragment * @param isBack ??true */ public void changeFragment(int resView, SupportFragment targetFragment, boolean isBack) { if (targetFragment.equals(currentSupportFragment)) { return; } android.support.v4.app.FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); if (!targetFragment.isAdded()) { transaction.add(resView, targetFragment, targetFragment.getClass().getName()); } if (targetFragment.isHidden()) { transaction.show(targetFragment); targetFragment.onChange(); } if (currentSupportFragment != null && currentSupportFragment.isVisible()) { transaction.hide(currentSupportFragment); } if (isBack) { transaction.addToBackStack(null); } currentSupportFragment = targetFragment; transaction.commit(); }
From source file:us.shandian.blacklight.ui.main.MainActivity.java
private void switchTo(int id) { FragmentTransaction ft = mManager.beginTransaction(); ft.setCustomAnimations(android.R.animator.fade_in, android.R.animator.fade_out, android.R.animator.fade_in, android.R.animator.fade_out); for (int i = 0; i < mFragments.length; i++) { Fragment f = mFragments[i];//from www .ja v a 2 s. c o m if (f != null) { if (i != id) { ft.hide(f); } else { ft.show(f); } } } ft.commit(); mCurrent = id; mNext = id; }
From source file:com.ppgllrd.alfil.MainActivity.java
private void selectCourse(int position) { Log.d("ppgllrd", "selectCourse" + position + " " + drawerSelectedIdx); boolean isSelectable = drawerItems.get(position) instanceof DrawerCourse; if (isSelectable) { final DrawerCourse drawerCourse = (DrawerCourse) drawerItems.get(position); FragmentManager fragmentManager = getFragmentManager(); Log.d("ppgllrd", "Count:" + fragmentManager.getBackStackEntryCount()); if (position != drawerSelectedIdx) { Log.d("ppgllrd", "YES"); drawerSelectedIdx = position; studentsListFragment = new StudentsListFragment(); Bundle args = new Bundle(); args.putParcelable(StudentsListFragment.ARG_GROUP_STUDENTS_COURSE, drawerCourse.getCourse()); studentsListFragment.setArguments(args); FragmentTransaction ft = getFragmentManager().beginTransaction(); ft.replace(R.id.list_Fragment_Placeholder, studentsListFragment, StudentsListFragment.FragmentTag); //ft.addToBackStack(StudentInfoFragment.FragmentTag); ft.commit();//from w w w. j a va 2s.c o m } Log.d("ppgllrd", "YYY"); actionBarTitleController.closeDrawer(); if (studentInfoFragment.isShown()) { FragmentManager fm = getFragmentManager(); if (fm.getBackStackEntryCount() > 0) { fm.popBackStack(); } } FragmentTransaction ft = getFragmentManager().beginTransaction(); ft.show(studentsListFragment); ft.hide(studentInfoFragment); // ft.addToBackStack(StudentInfoFragment.FragmentTag); ft.commit(); } Log.d("ppgllrd", "ZZZ"); }
From source file:com.frostwire.android.gui.activities.MainActivity.java
private void hideFragments() { try {/* www. j a va 2 s . c o m*/ getFragmentManager().executePendingTransactions(); } catch (Throwable t) { LOG.warn(t.getMessage(), t); } FragmentTransaction tx = getFragmentManager().beginTransaction(); tx.hide(search).hide(library).hide(transfers); try { tx.commit(); } catch (IllegalStateException e) { // if not that we can do a lot here, since the root of the problem // is the multiple entry points to MainActivity, just let it run // a possible inconsistent (but probably right) version. // in the future with a higher API, commitNow should be considered LOG.warn("Error running commit in fragment transaction, using weaker option", e); try { tx.commitAllowingStateLoss(); } catch (IllegalStateException e2) { // \_()_/ LOG.warn( "Error running commit in fragment transaction, weaker option also failed (commit already called - mCommited=true)", e2); } } }