List of usage examples for android.support.v4.app FragmentTransaction commit
public abstract int commit();
From source file:com.chatwing.whitelabel.activities.CommunicationActivity.java
protected void setupMode(CommunicationModeManager newMode, Fragment newFragment) { /*//ww w . j a v a2 s. c o m * Update fragments */ String fragmentTag = getString(R.string.tag_communication_messages); FragmentManager fragmentManager = getSupportFragmentManager(); Fragment oldFragment = fragmentManager.findFragmentByTag(fragmentTag); FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction(); if (oldFragment != null) { fragmentTransaction.remove(oldFragment); } fragmentTransaction.add(R.id.fragment_container, newFragment, fragmentTag); fragmentTransaction.commit(); /* * Deactivate old mode and activate the new one */ if (mCurrentCommunicationMode != null) { mCurrentCommunicationMode.deactivate(); } mCurrentCommunicationMode = newMode; mCurrentCommunicationMode.activate(); /* * Setup drawer layout */ // Set custom shadows that overlay the main content when a drawer opens mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow_left, Gravity.LEFT); mDrawerToggle = mCurrentCommunicationMode.getDrawerToggleListener(); mDrawerToggle.setDrawerIndicatorEnabled(true); getSupportActionBar().setHomeButtonEnabled(true); mDrawerLayout.setDrawerListener(mDrawerToggle); // Don't allow the drawer layout to catch back button and close itself // on back key is pressed. This activity will handle it. mDrawerLayout.setFocusableInTouchMode(false); invalidateOptionsMenu(); }
From source file:cm.aptoide.com.actionbarsherlock.internal.app.ActionBarImpl.java
@Override public void selectTab(Tab tab) { if (getNavigationMode() != NAVIGATION_MODE_TABS) { mSavedTabPosition = tab != null ? tab.getPosition() : INVALID_POSITION; return;/* ww w . j ava 2 s . com*/ } FragmentTransaction trans = null; if (mActivity instanceof FragmentActivity) { trans = ((FragmentActivity) mActivity).getSupportFragmentManager().beginTransaction() .disallowAddToBackStack(); } if (mSelectedTab == tab) { if (mSelectedTab != null) { mSelectedTab.getCallback().onTabReselected(mSelectedTab, trans); mTabScrollView.animateToTab(tab.getPosition()); } } else { mTabScrollView.setTabSelected(tab != null ? tab.getPosition() : Tab.INVALID_POSITION); if (mSelectedTab != null) { mSelectedTab.getCallback().onTabUnselected(mSelectedTab, trans); } mSelectedTab = (TabImpl) tab; if (mSelectedTab != null) { mSelectedTab.getCallback().onTabSelected(mSelectedTab, trans); } } if (trans != null && !trans.isEmpty()) { trans.commit(); } }
From source file:club.xlxk.libs.actionbarsherlock.internal.app.ActionBarImpl.java
@Override public void selectTab(Tab tab) { if (getNavigationMode() != NAVIGATION_MODE_TABS) { mSavedTabPosition = tab != null ? tab.getPosition() : INVALID_POSITION; return;/*from w ww. j a v a2 s.c om*/ } FragmentTransaction trans = null; if (mActivity instanceof SherlockFragmentActivity) { trans = ((SherlockFragmentActivity) mActivity).getSupportFragmentManager().beginTransaction() .disallowAddToBackStack(); } if (mSelectedTab == tab) { if (mSelectedTab != null) { mSelectedTab.getCallback().onTabReselected(mSelectedTab, trans); mTabScrollView.animateToTab(tab.getPosition()); } } else { mTabScrollView.setTabSelected(tab != null ? tab.getPosition() : Tab.INVALID_POSITION); if (mSelectedTab != null) { mSelectedTab.getCallback().onTabUnselected(mSelectedTab, trans); } mSelectedTab = (TabImpl) tab; if (mSelectedTab != null) { mSelectedTab.getCallback().onTabSelected(mSelectedTab, trans); } } if (trans != null && !trans.isEmpty()) { trans.commit(); } }
From source file:ca.mudar.mtlaucasou.BaseMapActivity.java
/** * Toggle display of both fragments, depending on landscape/portrait * layouts. Also toggle the actionbar button icon. {@inheritDoc} *///from w w w . j av a 2 s. c om @Override public boolean onOptionsItemSelected(MenuItem item) { FragmentManager fm = getSupportFragmentManager(); BaseMapFragment fragmentMap = (BaseMapFragment) fm.findFragmentByTag(Const.TAG_FRAGMENT_MAP); Fragment fragmentList = fm.findFragmentByTag(Const.TAG_FRAGMENT_LIST); if (item.getItemId() == R.id.actionbar_toggle_list) { View root = findViewById(R.id.map_root_landscape); boolean isTablet = (root != null); FragmentTransaction ft = fm.beginTransaction(); if ((fragmentMap == null) || (fragmentList == null)) { return false; } if (fragmentList.isVisible()) { /** * List is visible: hide it. */ ft.hide(fragmentList); isHiddenList = true; if (!isTablet) { /** * In portrait layout, we also have to show the hidden map. */ ft.show(fragmentMap); } /** * List is now hidden: Set the actionbar button to view_list. */ item.setIcon(getResources().getDrawable(R.drawable.ic_actionbar_view_list)); item.setTitle(R.string.menu_view_list); } else { /** * List is not visible: show it. */ ft.show(fragmentList); isHiddenList = false; if (!isTablet) { /** * In portrait layout, we also have to hide the visible map. */ ft.hide(fragmentMap); } /** * Map is now hidden: Set the actionbar button to view_map. */ item.setIcon(getResources().getDrawable(R.drawable.ic_actionbar_view_map)); item.setTitle(R.string.menu_view_map); } ft.commit(); return true; } else if (item.getItemId() == R.id.menu_map_mylocation) { /** * Center map on user location. */ fragmentMap.setMapCenterOnLocation(((AppHelper) getApplicationContext()).getLocation()); return true; } else if (item.getItemId() == R.id.menu_map_find_from_name) { /** * Search location by postal code (or address) and center map on * location if found) by Geocode. */ showPostalCodeDialog(); return true; } else { ActivityHelper mActivityHelper = ActivityHelper.createInstance(this); return mActivityHelper.onOptionsItemSelected(item, indexSection) || super.onOptionsItemSelected(item); } }
From source file:ca.mudar.mtlaucasou.BaseMapActivity.java
/** * Default (and restore) of hidden/visible fragments. {@inheritDoc} *//*w w w .j av a 2s . c o m*/ @Override public void onResume() { super.onResume(); if (!ConnectionHelper.hasConnection(this)) { ConnectionHelper.showDialogNoConnection(this); } View root = findViewById(R.id.map_root_landscape); boolean isTablet = (root != null); FragmentManager fm = getSupportFragmentManager(); FragmentTransaction ft = fm.beginTransaction(); Fragment fragmentMap = fm.findFragmentByTag(Const.TAG_FRAGMENT_MAP); Fragment fragmentList = fm.findFragmentByTag(Const.TAG_FRAGMENT_LIST); // TODO Bug: onResume after device (Nook!) shutdown or memory problems. // Temporary solution is the use of ft.show() in the following lines. /** * By default, both fragments are shown. No need to use * FragmentTransaction.show(). */ if (isTablet) { if (isHiddenList) { /** * List was hidden, we'll hide it again. */ ft.show(fragmentMap); ft.hide(fragmentList); // isHiddenList = true; } else { /** * List was not hidden, nothing to do here. */ ft.show(fragmentMap); ft.show(fragmentList); // isHiddenList = false; } } else if (!isTablet) { if (isHiddenList) { /** * List was hidden, we'll hide it again. */ ft.show(fragmentMap); ft.hide(fragmentList); // isHiddenList = true; } else if (!isHiddenList) { /** * List was not hidden. Hide the map since this is a portrait * layout. */ ft.hide(fragmentMap); ft.show(fragmentList); // isHiddenList = false; } } ft.commit(); }
From source file:com.anxpp.blog.MainActivity.java
/** * ?// w w w. j av a2 s. co m * @param uri ? */ public void updateContent(Uri uri) { final Fragment fragment; final String tag; final FragmentManager fm = getSupportFragmentManager(); final FragmentTransaction tr = fm.beginTransaction(); if (!currentUri.equals(uri)) { final Fragment currentFragment = fm.findFragmentByTag(currentContentFragmentTag); if (currentFragment != null) tr.hide(currentFragment); } //about if (AboutFragment.ABOUT_URI.equals(uri)) { tag = AboutFragment.TAG; final Fragment foundFragment = fm.findFragmentByTag(tag); if (foundFragment != null) { fragment = foundFragment; } else { fragment = new AboutFragment(); } } else if (SandboxFragment.SETTINGS_URI.equals(uri)) { tag = SandboxFragment.TAG; final SandboxFragment foundFragment = (SandboxFragment) fm.findFragmentByTag(tag); if (foundFragment != null) { foundFragment.setOnSettingsChangedListener(mSettingsChangedListener); fragment = foundFragment; } else { final SandboxFragment settingsFragment = new SandboxFragment(); settingsFragment.setOnSettingsChangedListener(mSettingsChangedListener); fragment = settingsFragment; } } else if (uri != null) { //... tag = WebViewFragment.TAG; final WebViewFragment webViewFragment; final Fragment foundFragment = fm.findFragmentByTag(tag); if (foundFragment != null) { fragment = foundFragment; webViewFragment = (WebViewFragment) fragment; } else { webViewFragment = new WebViewFragment(); fragment = webViewFragment; } webViewFragment.setUrl(uri.toString()); } else { return; } if (fragment.isAdded()) { tr.show(fragment); } else { tr.replace(R.id.content, fragment, tag); } tr.commit(); currentUri = uri; currentContentFragmentTag = tag; }
From source file:com.cardio3g.MainActivity.java
@Override public void onClick(View view) { if (view == btnBuiltIn) { if (boolBuilt) { boolBuilt = false;//from w ww . j av a 2s . com if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { btnBuiltIn.setBackground(getResources().getDrawable(R.drawable.buttonunselected, null)); btnMuscleIsolation.setBackground(getResources().getDrawable(R.drawable.buttonunselected, null)); btnCustomProgram.setBackground(getResources().getDrawable(R.drawable.buttonunselected, null)); btnSportsTraining.setBackground(getResources().getDrawable(R.drawable.buttonunselected, null)); btnhealthyLiving.setBackground(getResources().getDrawable(R.drawable.buttonunselected, null)); btnPersonalTrainer.setBackground(getResources().getDrawable(R.drawable.buttonunselected, null)); btnVideos.setBackground(getResources().getDrawable(R.drawable.smallbtn, null)); btnVideos.setTextColor(getResources().getColor(android.R.color.white, null)); btnCardio.setBackground(getResources().getDrawable(R.drawable.smallbtn, null)); btnCardio.setTextColor(getResources().getColor(android.R.color.white, null)); btnImages.setBackground(getResources().getDrawable(R.drawable.smallbtn, null)); btnImages.setTextColor(getResources().getColor(android.R.color.white, null)); Fragment f = getSupportFragmentManager().findFragmentById(R.id.frame); android.support.v4.app.FragmentManager fragmentManager = getSupportFragmentManager(); android.support.v4.app.FragmentTransaction fragmentTransaction = fragmentManager .beginTransaction(); fragmentTransaction.setCustomAnimations(R.anim.push_down_in, R.anim.push_down_in); if (f != null) fragmentTransaction.remove(f); fragmentTransaction.commit(); } else { btnBuiltIn.setBackground(getResources().getDrawable(R.drawable.buttonunselected)); btnMuscleIsolation.setBackground(getResources().getDrawable(R.drawable.buttonunselected)); btnCustomProgram.setBackground(getResources().getDrawable(R.drawable.buttonunselected)); btnSportsTraining.setBackground(getResources().getDrawable(R.drawable.buttonunselected)); btnhealthyLiving.setBackground(getResources().getDrawable(R.drawable.buttonunselected)); btnPersonalTrainer.setBackground(getResources().getDrawable(R.drawable.buttonunselected)); btnVideos.setBackground(getResources().getDrawable(R.drawable.smallbtn)); btnVideos.setTextColor(getResources().getColor(android.R.color.white)); btnCardio.setBackground(getResources().getDrawable(R.drawable.smallbtn)); btnCardio.setTextColor(getResources().getColor(android.R.color.white)); btnImages.setBackground(getResources().getDrawable(R.drawable.smallbtn)); btnImages.setTextColor(getResources().getColor(android.R.color.white)); Fragment f = getSupportFragmentManager().findFragmentById(R.id.frame); android.support.v4.app.FragmentManager fragmentManager = getSupportFragmentManager(); android.support.v4.app.FragmentTransaction fragmentTransaction = fragmentManager .beginTransaction(); if (f != null) fragmentTransaction.remove(f); fragmentTransaction.commit(); } } else { boolBuilt = true; removeAllFragments(getSupportFragmentManager()); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { btnBuiltIn.setBackground(getResources().getDrawable(R.drawable.buttonselected, null)); btnMuscleIsolation.setBackground(getResources().getDrawable(R.drawable.buttonunselected, null)); btnCustomProgram.setBackground(getResources().getDrawable(R.drawable.buttonunselected, null)); btnSportsTraining.setBackground(getResources().getDrawable(R.drawable.buttonunselected, null)); btnhealthyLiving.setBackground(getResources().getDrawable(R.drawable.buttonunselected, null)); btnPersonalTrainer.setBackground(getResources().getDrawable(R.drawable.buttonunselected, null)); btnVideos.setBackground(getResources().getDrawable(R.drawable.smallbtn, null)); btnVideos.setTextColor(getResources().getColor(android.R.color.white, null)); btnCardio.setBackground(getResources().getDrawable(R.drawable.smallbtn, null)); btnCardio.setTextColor(getResources().getColor(android.R.color.white, null)); btnImages.setBackground(getResources().getDrawable(R.drawable.smallbtn, null)); btnImages.setTextColor(getResources().getColor(android.R.color.white, null)); android.support.v4.app.FragmentManager fragmentManager = getSupportFragmentManager(); android.support.v4.app.FragmentTransaction fragmentTransaction = fragmentManager .beginTransaction(); fragmentTransaction.setCustomAnimations(R.anim.push_up_in, R.anim.push_up_in); fragmentTransaction.replace(R.id.frame, new BuiltInProgramsFragment()); fragmentTransaction.addToBackStack(null); fragmentTransaction.commit(); } else { btnBuiltIn.setBackground(getResources().getDrawable(R.drawable.buttonselected)); btnMuscleIsolation.setBackground(getResources().getDrawable(R.drawable.buttonunselected)); btnCustomProgram.setBackground(getResources().getDrawable(R.drawable.buttonunselected)); btnSportsTraining.setBackground(getResources().getDrawable(R.drawable.buttonunselected)); btnhealthyLiving.setBackground(getResources().getDrawable(R.drawable.buttonunselected)); btnPersonalTrainer.setBackground(getResources().getDrawable(R.drawable.buttonunselected)); btnVideos.setBackground(getResources().getDrawable(R.drawable.smallbtn)); btnVideos.setTextColor(getResources().getColor(android.R.color.white)); btnCardio.setBackground(getResources().getDrawable(R.drawable.smallbtn)); btnCardio.setTextColor(getResources().getColor(android.R.color.white)); btnImages.setBackground(getResources().getDrawable(R.drawable.smallbtn)); btnImages.setTextColor(getResources().getColor(android.R.color.white)); android.support.v4.app.FragmentManager fragmentManager = getSupportFragmentManager(); android.support.v4.app.FragmentTransaction fragmentTransaction = fragmentManager .beginTransaction(); fragmentTransaction.replace(R.id.frame, new BuiltInProgramsFragment()); fragmentTransaction.addToBackStack(null); fragmentTransaction.commit(); } } } if (view == btnMuscleIsolation) { if (boolMuscle) { boolMuscle = false; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { btnBuiltIn.setBackground(getResources().getDrawable(R.drawable.buttonunselected, null)); btnMuscleIsolation.setBackground(getResources().getDrawable(R.drawable.buttonunselected, null)); btnCustomProgram.setBackground(getResources().getDrawable(R.drawable.buttonunselected, null)); btnSportsTraining.setBackground(getResources().getDrawable(R.drawable.buttonunselected, null)); btnhealthyLiving.setBackground(getResources().getDrawable(R.drawable.buttonunselected, null)); btnPersonalTrainer.setBackground(getResources().getDrawable(R.drawable.buttonunselected, null)); btnVideos.setBackground(getResources().getDrawable(R.drawable.smallbtn, null)); btnVideos.setTextColor(getResources().getColor(android.R.color.white, null)); btnCardio.setBackground(getResources().getDrawable(R.drawable.smallbtn, null)); btnCardio.setTextColor(getResources().getColor(android.R.color.white, null)); btnImages.setBackground(getResources().getDrawable(R.drawable.smallbtn, null)); btnImages.setTextColor(getResources().getColor(android.R.color.white, null)); Fragment f = getSupportFragmentManager().findFragmentById(R.id.frame); android.support.v4.app.FragmentManager fragmentManager = getSupportFragmentManager(); android.support.v4.app.FragmentTransaction fragmentTransaction = fragmentManager .beginTransaction(); fragmentTransaction.setCustomAnimations(R.anim.push_down_in, R.anim.push_down_in); if (f != null) fragmentTransaction.remove(f); fragmentTransaction.commit(); } else { btnBuiltIn.setBackground(getResources().getDrawable(R.drawable.buttonunselected)); btnMuscleIsolation.setBackground(getResources().getDrawable(R.drawable.buttonunselected)); btnCustomProgram.setBackground(getResources().getDrawable(R.drawable.buttonunselected)); btnSportsTraining.setBackground(getResources().getDrawable(R.drawable.buttonunselected)); btnhealthyLiving.setBackground(getResources().getDrawable(R.drawable.buttonunselected)); btnPersonalTrainer.setBackground(getResources().getDrawable(R.drawable.buttonunselected)); btnVideos.setBackground(getResources().getDrawable(R.drawable.smallbtn)); btnVideos.setTextColor(getResources().getColor(android.R.color.white)); btnCardio.setBackground(getResources().getDrawable(R.drawable.smallbtn)); btnCardio.setTextColor(getResources().getColor(android.R.color.white)); btnImages.setBackground(getResources().getDrawable(R.drawable.smallbtn)); btnImages.setTextColor(getResources().getColor(android.R.color.white)); Fragment f = getSupportFragmentManager().findFragmentById(R.id.frame); android.support.v4.app.FragmentManager fragmentManager = getSupportFragmentManager(); android.support.v4.app.FragmentTransaction fragmentTransaction = fragmentManager .beginTransaction(); if (f != null) fragmentTransaction.remove(f); fragmentTransaction.commit(); } } else { boolMuscle = true; removeAllFragments(getSupportFragmentManager()); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { btnBuiltIn.setBackground(getResources().getDrawable(R.drawable.buttonunselected, null)); btnMuscleIsolation.setBackground(getResources().getDrawable(R.drawable.buttonselected, null)); btnCustomProgram.setBackground(getResources().getDrawable(R.drawable.buttonunselected, null)); btnSportsTraining.setBackground(getResources().getDrawable(R.drawable.buttonunselected, null)); btnhealthyLiving.setBackground(getResources().getDrawable(R.drawable.buttonunselected, null)); btnPersonalTrainer.setBackground(getResources().getDrawable(R.drawable.buttonunselected, null)); btnVideos.setBackground(getResources().getDrawable(R.drawable.smallbtn, null)); btnVideos.setTextColor(getResources().getColor(android.R.color.white, null)); btnCardio.setBackground(getResources().getDrawable(R.drawable.smallbtn, null)); btnCardio.setTextColor(getResources().getColor(android.R.color.white, null)); btnImages.setBackground(getResources().getDrawable(R.drawable.smallbtn, null)); btnImages.setTextColor(getResources().getColor(android.R.color.white, null)); android.support.v4.app.FragmentManager fragmentManager = getSupportFragmentManager(); android.support.v4.app.FragmentTransaction fragmentTransaction = fragmentManager .beginTransaction(); fragmentTransaction.setCustomAnimations(R.anim.push_up_in, R.anim.push_up_out); fragmentTransaction.replace(R.id.frame, new MuscleIsolationFragment()); fragmentTransaction.addToBackStack(null); fragmentTransaction.commit(); } else { btnBuiltIn.setBackground(getResources().getDrawable(R.drawable.buttonunselected)); btnMuscleIsolation.setBackground(getResources().getDrawable(R.drawable.buttonselected)); btnCustomProgram.setBackground(getResources().getDrawable(R.drawable.buttonunselected)); btnSportsTraining.setBackground(getResources().getDrawable(R.drawable.buttonunselected)); btnhealthyLiving.setBackground(getResources().getDrawable(R.drawable.buttonunselected)); btnPersonalTrainer.setBackground(getResources().getDrawable(R.drawable.buttonunselected)); btnVideos.setBackground(getResources().getDrawable(R.drawable.smallbtn)); btnVideos.setTextColor(getResources().getColor(android.R.color.white)); btnCardio.setBackground(getResources().getDrawable(R.drawable.smallbtn)); btnCardio.setTextColor(getResources().getColor(android.R.color.white)); btnImages.setBackground(getResources().getDrawable(R.drawable.smallbtn)); btnImages.setTextColor(getResources().getColor(android.R.color.white)); android.support.v4.app.FragmentManager fragmentManager = getSupportFragmentManager(); android.support.v4.app.FragmentTransaction fragmentTransaction = fragmentManager .beginTransaction(); fragmentTransaction.replace(R.id.frame, new MuscleIsolationFragment()); fragmentTransaction.addToBackStack(null); fragmentTransaction.commit(); } } } if (view == btnCustomProgram) { if (boolCustom) { boolCustom = false; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { btnBuiltIn.setBackground(getResources().getDrawable(R.drawable.buttonunselected, null)); btnMuscleIsolation.setBackground(getResources().getDrawable(R.drawable.buttonunselected, null)); btnCustomProgram.setBackground(getResources().getDrawable(R.drawable.buttonunselected, null)); btnSportsTraining.setBackground(getResources().getDrawable(R.drawable.buttonunselected, null)); btnhealthyLiving.setBackground(getResources().getDrawable(R.drawable.buttonunselected, null)); btnPersonalTrainer.setBackground(getResources().getDrawable(R.drawable.buttonunselected, null)); btnVideos.setBackground(getResources().getDrawable(R.drawable.smallbtn, null)); btnVideos.setTextColor(getResources().getColor(android.R.color.white, null)); btnCardio.setBackground(getResources().getDrawable(R.drawable.smallbtn, null)); btnCardio.setTextColor(getResources().getColor(android.R.color.white, null)); btnImages.setBackground(getResources().getDrawable(R.drawable.smallbtn, null)); btnImages.setTextColor(getResources().getColor(android.R.color.white, null)); Fragment f = getSupportFragmentManager().findFragmentById(R.id.frame); android.support.v4.app.FragmentManager fragmentManager = getSupportFragmentManager(); android.support.v4.app.FragmentTransaction fragmentTransaction = fragmentManager .beginTransaction(); fragmentTransaction.setCustomAnimations(R.anim.push_down_in, R.anim.push_down_in); if (f != null) fragmentTransaction.remove(f); fragmentTransaction.commit(); } else { btnBuiltIn.setBackground(getResources().getDrawable(R.drawable.buttonunselected)); btnMuscleIsolation.setBackground(getResources().getDrawable(R.drawable.buttonunselected)); btnCustomProgram.setBackground(getResources().getDrawable(R.drawable.buttonunselected)); btnSportsTraining.setBackground(getResources().getDrawable(R.drawable.buttonunselected)); btnhealthyLiving.setBackground(getResources().getDrawable(R.drawable.buttonunselected)); btnPersonalTrainer.setBackground(getResources().getDrawable(R.drawable.buttonunselected)); btnVideos.setBackground(getResources().getDrawable(R.drawable.smallbtn)); btnVideos.setTextColor(getResources().getColor(android.R.color.white)); btnCardio.setBackground(getResources().getDrawable(R.drawable.smallbtn)); btnCardio.setTextColor(getResources().getColor(android.R.color.white)); btnImages.setBackground(getResources().getDrawable(R.drawable.smallbtn)); btnImages.setTextColor(getResources().getColor(android.R.color.white)); Fragment f = getSupportFragmentManager().findFragmentById(R.id.frame); android.support.v4.app.FragmentManager fragmentManager = getSupportFragmentManager(); android.support.v4.app.FragmentTransaction fragmentTransaction = fragmentManager .beginTransaction(); if (f != null) fragmentTransaction.remove(f); fragmentTransaction.commit(); } } else { boolCustom = true; removeAllFragments(getSupportFragmentManager()); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { btnBuiltIn.setBackground(getResources().getDrawable(R.drawable.buttonunselected, null)); btnMuscleIsolation.setBackground(getResources().getDrawable(R.drawable.buttonunselected, null)); btnCustomProgram.setBackground(getResources().getDrawable(R.drawable.buttonselected, null)); btnSportsTraining.setBackground(getResources().getDrawable(R.drawable.buttonunselected, null)); btnhealthyLiving.setBackground(getResources().getDrawable(R.drawable.buttonunselected, null)); btnPersonalTrainer.setBackground(getResources().getDrawable(R.drawable.buttonunselected, null)); btnVideos.setBackground(getResources().getDrawable(R.drawable.smallbtn, null)); btnVideos.setTextColor(getResources().getColor(android.R.color.white, null)); btnCardio.setBackground(getResources().getDrawable(R.drawable.smallbtn, null)); btnCardio.setTextColor(getResources().getColor(android.R.color.white, null)); btnImages.setBackground(getResources().getDrawable(R.drawable.smallbtn, null)); btnImages.setTextColor(getResources().getColor(android.R.color.white, null)); android.support.v4.app.FragmentManager fragmentManager = getSupportFragmentManager(); android.support.v4.app.FragmentTransaction fragmentTransaction = fragmentManager .beginTransaction(); fragmentTransaction.setCustomAnimations(R.anim.push_up_in, R.anim.push_up_out); fragmentTransaction.replace(R.id.frame, new CustomProgramFragment()); fragmentTransaction.addToBackStack(null); fragmentTransaction.commit(); } else { btnBuiltIn.setBackground(getResources().getDrawable(R.drawable.buttonunselected)); btnMuscleIsolation.setBackground(getResources().getDrawable(R.drawable.buttonunselected)); btnCustomProgram.setBackground(getResources().getDrawable(R.drawable.buttonselected)); btnSportsTraining.setBackground(getResources().getDrawable(R.drawable.buttonunselected)); btnhealthyLiving.setBackground(getResources().getDrawable(R.drawable.buttonunselected)); btnPersonalTrainer.setBackground(getResources().getDrawable(R.drawable.buttonunselected)); btnVideos.setBackground(getResources().getDrawable(R.drawable.smallbtn)); btnVideos.setTextColor(getResources().getColor(android.R.color.white)); btnCardio.setBackground(getResources().getDrawable(R.drawable.smallbtn)); btnCardio.setTextColor(getResources().getColor(android.R.color.white)); btnImages.setBackground(getResources().getDrawable(R.drawable.smallbtn)); btnImages.setTextColor(getResources().getColor(android.R.color.white)); android.support.v4.app.FragmentManager fragmentManager = getSupportFragmentManager(); android.support.v4.app.FragmentTransaction fragmentTransaction = fragmentManager .beginTransaction(); fragmentTransaction.replace(R.id.frame, new CustomProgramFragment()); fragmentTransaction.addToBackStack(null); fragmentTransaction.commit(); } } } if (view == btnSportsTraining) { if (boolSports) { boolSports = false; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { btnBuiltIn.setBackground(getResources().getDrawable(R.drawable.buttonunselected, null)); btnMuscleIsolation.setBackground(getResources().getDrawable(R.drawable.buttonunselected, null)); btnCustomProgram.setBackground(getResources().getDrawable(R.drawable.buttonunselected, null)); btnSportsTraining.setBackground(getResources().getDrawable(R.drawable.buttonunselected, null)); btnhealthyLiving.setBackground(getResources().getDrawable(R.drawable.buttonunselected, null)); btnPersonalTrainer.setBackground(getResources().getDrawable(R.drawable.buttonunselected, null)); btnVideos.setBackground(getResources().getDrawable(R.drawable.smallbtn, null)); btnVideos.setTextColor(getResources().getColor(android.R.color.white, null)); btnCardio.setBackground(getResources().getDrawable(R.drawable.smallbtn, null)); btnCardio.setTextColor(getResources().getColor(android.R.color.white, null)); btnImages.setBackground(getResources().getDrawable(R.drawable.smallbtn, null)); btnImages.setTextColor(getResources().getColor(android.R.color.white, null)); Fragment f = getSupportFragmentManager().findFragmentById(R.id.frame); android.support.v4.app.FragmentManager fragmentManager = getSupportFragmentManager(); android.support.v4.app.FragmentTransaction fragmentTransaction = fragmentManager .beginTransaction(); fragmentTransaction.setCustomAnimations(R.anim.push_down_in, R.anim.push_down_in); if (f != null) fragmentTransaction.remove(f); fragmentTransaction.commit(); } else { btnBuiltIn.setBackground(getResources().getDrawable(R.drawable.buttonunselected)); btnMuscleIsolation.setBackground(getResources().getDrawable(R.drawable.buttonunselected)); btnCustomProgram.setBackground(getResources().getDrawable(R.drawable.buttonunselected)); btnSportsTraining.setBackground(getResources().getDrawable(R.drawable.buttonunselected)); btnhealthyLiving.setBackground(getResources().getDrawable(R.drawable.buttonunselected)); btnPersonalTrainer.setBackground(getResources().getDrawable(R.drawable.buttonunselected)); btnVideos.setBackground(getResources().getDrawable(R.drawable.smallbtn)); btnVideos.setTextColor(getResources().getColor(android.R.color.white)); btnCardio.setBackground(getResources().getDrawable(R.drawable.smallbtn)); btnCardio.setTextColor(getResources().getColor(android.R.color.white)); btnImages.setBackground(getResources().getDrawable(R.drawable.smallbtn)); btnImages.setTextColor(getResources().getColor(android.R.color.white)); Fragment f = getSupportFragmentManager().findFragmentById(R.id.frame); android.support.v4.app.FragmentManager fragmentManager = getSupportFragmentManager(); android.support.v4.app.FragmentTransaction fragmentTransaction = fragmentManager .beginTransaction(); if (f != null) fragmentTransaction.remove(f); fragmentTransaction.commit(); } } else { boolSports = true; removeAllFragments(getSupportFragmentManager()); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { btnBuiltIn.setBackground(getResources().getDrawable(R.drawable.buttonunselected, null)); btnMuscleIsolation.setBackground(getResources().getDrawable(R.drawable.buttonunselected, null)); btnCustomProgram.setBackground(getResources().getDrawable(R.drawable.buttonunselected, null)); btnSportsTraining.setBackground(getResources().getDrawable(R.drawable.buttonselected, null)); btnhealthyLiving.setBackground(getResources().getDrawable(R.drawable.buttonunselected, null)); btnPersonalTrainer.setBackground(getResources().getDrawable(R.drawable.buttonunselected, null)); btnVideos.setBackground(getResources().getDrawable(R.drawable.smallbtn, null)); btnVideos.setTextColor(getResources().getColor(android.R.color.white, null)); btnCardio.setBackground(getResources().getDrawable(R.drawable.smallbtn, null)); btnCardio.setTextColor(getResources().getColor(android.R.color.white, null)); btnImages.setBackground(getResources().getDrawable(R.drawable.smallbtn, null)); btnImages.setTextColor(getResources().getColor(android.R.color.white, null)); android.support.v4.app.FragmentManager fragmentManager = getSupportFragmentManager(); android.support.v4.app.FragmentTransaction fragmentTransaction = fragmentManager .beginTransaction(); fragmentTransaction.setCustomAnimations(R.anim.push_up_in, R.anim.push_up_out); fragmentTransaction.replace(R.id.frame, new SportsTrainingFragment()); fragmentTransaction.addToBackStack(null); fragmentTransaction.commit(); } else { btnBuiltIn.setBackground(getResources().getDrawable(R.drawable.buttonunselected)); btnMuscleIsolation.setBackground(getResources().getDrawable(R.drawable.buttonunselected)); btnCustomProgram.setBackground(getResources().getDrawable(R.drawable.buttonunselected)); btnSportsTraining.setBackground(getResources().getDrawable(R.drawable.buttonselected)); btnhealthyLiving.setBackground(getResources().getDrawable(R.drawable.buttonunselected)); btnPersonalTrainer.setBackground(getResources().getDrawable(R.drawable.buttonunselected)); btnVideos.setBackground(getResources().getDrawable(R.drawable.smallbtn)); btnVideos.setTextColor(getResources().getColor(android.R.color.white)); btnCardio.setBackground(getResources().getDrawable(R.drawable.smallbtn)); btnCardio.setTextColor(getResources().getColor(android.R.color.white)); btnImages.setBackground(getResources().getDrawable(R.drawable.smallbtn)); btnImages.setTextColor(getResources().getColor(android.R.color.white)); android.support.v4.app.FragmentManager fragmentManager = getSupportFragmentManager(); android.support.v4.app.FragmentTransaction fragmentTransaction = fragmentManager .beginTransaction(); //fragmentTransaction.setCustomAnimations(R.anim.push_up_in,R.anim.push_up_out); fragmentTransaction.replace(R.id.frame, new SportsTrainingFragment()); fragmentTransaction.addToBackStack(null); fragmentTransaction.commit(); } } } if (view == btnhealthyLiving) { if (boolHealthy) { boolHealthy = false; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { btnBuiltIn.setBackground(getResources().getDrawable(R.drawable.buttonunselected, null)); btnMuscleIsolation.setBackground(getResources().getDrawable(R.drawable.buttonunselected, null)); btnCustomProgram.setBackground(getResources().getDrawable(R.drawable.buttonunselected, null)); btnSportsTraining.setBackground(getResources().getDrawable(R.drawable.buttonunselected, null)); btnhealthyLiving.setBackground(getResources().getDrawable(R.drawable.buttonunselected, null)); btnPersonalTrainer.setBackground(getResources().getDrawable(R.drawable.buttonunselected, null)); btnVideos.setBackground(getResources().getDrawable(R.drawable.smallbtn, null)); btnVideos.setTextColor(getResources().getColor(android.R.color.white, null)); btnCardio.setBackground(getResources().getDrawable(R.drawable.smallbtn, null)); btnCardio.setTextColor(getResources().getColor(android.R.color.white, null)); btnImages.setBackground(getResources().getDrawable(R.drawable.smallbtn, null)); btnImages.setTextColor(getResources().getColor(android.R.color.white, null)); Fragment f = getSupportFragmentManager().findFragmentById(R.id.frame); android.support.v4.app.FragmentManager fragmentManager = getSupportFragmentManager(); android.support.v4.app.FragmentTransaction fragmentTransaction = fragmentManager .beginTransaction(); fragmentTransaction.setCustomAnimations(R.anim.push_down_in, R.anim.push_down_in); if (f != null) fragmentTransaction.remove(f); fragmentTransaction.commit(); } else { btnBuiltIn.setBackground(getResources().getDrawable(R.drawable.buttonunselected)); btnMuscleIsolation.setBackground(getResources().getDrawable(R.drawable.buttonunselected)); btnCustomProgram.setBackground(getResources().getDrawable(R.drawable.buttonunselected)); btnSportsTraining.setBackground(getResources().getDrawable(R.drawable.buttonunselected)); btnhealthyLiving.setBackground(getResources().getDrawable(R.drawable.buttonunselected)); btnPersonalTrainer.setBackground(getResources().getDrawable(R.drawable.buttonunselected)); btnVideos.setBackground(getResources().getDrawable(R.drawable.smallbtn)); btnVideos.setTextColor(getResources().getColor(android.R.color.white)); btnCardio.setBackground(getResources().getDrawable(R.drawable.smallbtn)); btnCardio.setTextColor(getResources().getColor(android.R.color.white)); btnImages.setBackground(getResources().getDrawable(R.drawable.smallbtn)); btnImages.setTextColor(getResources().getColor(android.R.color.white)); Fragment f = getSupportFragmentManager().findFragmentById(R.id.frame); android.support.v4.app.FragmentManager fragmentManager = getSupportFragmentManager(); android.support.v4.app.FragmentTransaction fragmentTransaction = fragmentManager .beginTransaction(); //fragmentTransaction.setCustomAnimations(R.anim.push_down_in,R.anim.push_down_in); if (f != null) fragmentTransaction.remove(f); fragmentTransaction.commit(); } } else { boolHealthy = true; removeAllFragments(getSupportFragmentManager()); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { btnBuiltIn.setBackground(getResources().getDrawable(R.drawable.buttonunselected, null)); btnMuscleIsolation.setBackground(getResources().getDrawable(R.drawable.buttonunselected, null)); btnCustomProgram.setBackground(getResources().getDrawable(R.drawable.buttonunselected, null)); btnSportsTraining.setBackground(getResources().getDrawable(R.drawable.buttonunselected, null)); btnhealthyLiving.setBackground(getResources().getDrawable(R.drawable.buttonselected, null)); btnPersonalTrainer.setBackground(getResources().getDrawable(R.drawable.buttonunselected, null)); btnVideos.setBackground(getResources().getDrawable(R.drawable.smallbtn, null)); btnVideos.setTextColor(getResources().getColor(android.R.color.white, null)); btnCardio.setBackground(getResources().getDrawable(R.drawable.smallbtn, null)); btnCardio.setTextColor(getResources().getColor(android.R.color.white, null)); btnImages.setBackground(getResources().getDrawable(R.drawable.smallbtn, null)); btnImages.setTextColor(getResources().getColor(android.R.color.white, null)); android.support.v4.app.FragmentManager fragmentManager = getSupportFragmentManager(); android.support.v4.app.FragmentTransaction fragmentTransaction = fragmentManager .beginTransaction(); fragmentTransaction.setCustomAnimations(R.anim.push_up_in, R.anim.push_up_out); fragmentTransaction.replace(R.id.frame, new HealthyLivingFragment()); fragmentTransaction.addToBackStack(null); fragmentTransaction.commit(); } else { btnBuiltIn.setBackground(getResources().getDrawable(R.drawable.buttonunselected)); btnMuscleIsolation.setBackground(getResources().getDrawable(R.drawable.buttonunselected)); btnCustomProgram.setBackground(getResources().getDrawable(R.drawable.buttonunselected)); btnSportsTraining.setBackground(getResources().getDrawable(R.drawable.buttonunselected)); btnhealthyLiving.setBackground(getResources().getDrawable(R.drawable.buttonselected)); btnPersonalTrainer.setBackground(getResources().getDrawable(R.drawable.buttonunselected)); btnVideos.setBackground(getResources().getDrawable(R.drawable.smallbtn)); btnVideos.setTextColor(getResources().getColor(android.R.color.white)); btnCardio.setBackground(getResources().getDrawable(R.drawable.smallbtn)); btnCardio.setTextColor(getResources().getColor(android.R.color.white)); btnImages.setBackground(getResources().getDrawable(R.drawable.smallbtn)); btnImages.setTextColor(getResources().getColor(android.R.color.white)); android.support.v4.app.FragmentManager fragmentManager = getSupportFragmentManager(); android.support.v4.app.FragmentTransaction fragmentTransaction = fragmentManager .beginTransaction(); //fragmentTransaction.setCustomAnimations(R.anim.push_up_in,R.anim.push_up_out); fragmentTransaction.replace(R.id.frame, new HealthyLivingFragment()); fragmentTransaction.addToBackStack(null); fragmentTransaction.commit(); } } } if (view == btnPersonalTrainer) { if (boolPersonal) { boolPersonal = false; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { btnBuiltIn.setBackground(getResources().getDrawable(R.drawable.buttonunselected, null)); btnMuscleIsolation.setBackground(getResources().getDrawable(R.drawable.buttonunselected, null)); btnCustomProgram.setBackground(getResources().getDrawable(R.drawable.buttonunselected, null)); btnSportsTraining.setBackground(getResources().getDrawable(R.drawable.buttonunselected, null)); btnhealthyLiving.setBackground(getResources().getDrawable(R.drawable.buttonunselected, null)); btnPersonalTrainer.setBackground(getResources().getDrawable(R.drawable.buttonunselected, null)); btnVideos.setBackground(getResources().getDrawable(R.drawable.smallbtn, null)); btnVideos.setTextColor(getResources().getColor(android.R.color.white, null)); btnCardio.setBackground(getResources().getDrawable(R.drawable.smallbtn, null)); btnCardio.setTextColor(getResources().getColor(android.R.color.white, null)); btnImages.setBackground(getResources().getDrawable(R.drawable.smallbtn, null)); btnImages.setTextColor(getResources().getColor(android.R.color.white, null)); Fragment f = getSupportFragmentManager().findFragmentById(R.id.frame); android.support.v4.app.FragmentManager fragmentManager = getSupportFragmentManager(); android.support.v4.app.FragmentTransaction fragmentTransaction = fragmentManager .beginTransaction(); fragmentTransaction.setCustomAnimations(R.anim.push_down_in, R.anim.push_down_in); if (f != null) fragmentTransaction.remove(f); fragmentTransaction.commit(); } else { btnBuiltIn.setBackground(getResources().getDrawable(R.drawable.buttonunselected)); btnMuscleIsolation.setBackground(getResources().getDrawable(R.drawable.buttonunselected)); btnCustomProgram.setBackground(getResources().getDrawable(R.drawable.buttonunselected)); btnSportsTraining.setBackground(getResources().getDrawable(R.drawable.buttonunselected)); btnhealthyLiving.setBackground(getResources().getDrawable(R.drawable.buttonunselected)); btnPersonalTrainer.setBackground(getResources().getDrawable(R.drawable.buttonunselected)); btnVideos.setBackground(getResources().getDrawable(R.drawable.smallbtn)); btnVideos.setTextColor(getResources().getColor(android.R.color.white)); btnCardio.setBackground(getResources().getDrawable(R.drawable.smallbtn)); btnCardio.setTextColor(getResources().getColor(android.R.color.white)); btnImages.setBackground(getResources().getDrawable(R.drawable.smallbtn)); btnImages.setTextColor(getResources().getColor(android.R.color.white)); Fragment f = getSupportFragmentManager().findFragmentById(R.id.frame); android.support.v4.app.FragmentManager fragmentManager = getSupportFragmentManager(); android.support.v4.app.FragmentTransaction fragmentTransaction = fragmentManager .beginTransaction(); //fragmentTransaction.setCustomAnimations(R.anim.push_down_in,R.anim.push_down_in); if (f != null) fragmentTransaction.remove(f); fragmentTransaction.commit(); } } else { boolPersonal = true; removeAllFragments(getSupportFragmentManager()); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { btnBuiltIn.setBackground(getResources().getDrawable(R.drawable.buttonunselected, null)); btnMuscleIsolation.setBackground(getResources().getDrawable(R.drawable.buttonunselected, null)); btnCustomProgram.setBackground(getResources().getDrawable(R.drawable.buttonunselected, null)); btnSportsTraining.setBackground(getResources().getDrawable(R.drawable.buttonunselected, null)); btnhealthyLiving.setBackground(getResources().getDrawable(R.drawable.buttonunselected, null)); btnPersonalTrainer.setBackground(getResources().getDrawable(R.drawable.buttonselected, null)); btnVideos.setBackground(getResources().getDrawable(R.drawable.smallbtn, null)); btnVideos.setTextColor(getResources().getColor(android.R.color.white, null)); btnCardio.setBackground(getResources().getDrawable(R.drawable.smallbtn, null)); btnCardio.setTextColor(getResources().getColor(android.R.color.white, null)); btnImages.setBackground(getResources().getDrawable(R.drawable.smallbtn, null)); btnImages.setTextColor(getResources().getColor(android.R.color.white, null)); removeAllFragments(getSupportFragmentManager()); android.support.v4.app.FragmentManager fragmentManager = getSupportFragmentManager(); android.support.v4.app.FragmentTransaction fragmentTransaction = fragmentManager .beginTransaction(); fragmentTransaction.setCustomAnimations(R.anim.push_up_in, R.anim.push_up_out); fragmentTransaction.replace(R.id.frame, new PersonalTrainerFragment()); fragmentTransaction.addToBackStack(null); fragmentTransaction.commit(); } else { btnBuiltIn.setBackground(getResources().getDrawable(R.drawable.buttonunselected)); btnMuscleIsolation.setBackground(getResources().getDrawable(R.drawable.buttonunselected)); btnCustomProgram.setBackground(getResources().getDrawable(R.drawable.buttonunselected)); btnSportsTraining.setBackground(getResources().getDrawable(R.drawable.buttonunselected)); btnhealthyLiving.setBackground(getResources().getDrawable(R.drawable.buttonunselected)); btnPersonalTrainer.setBackground(getResources().getDrawable(R.drawable.buttonselected)); btnVideos.setBackground(getResources().getDrawable(R.drawable.smallbtn)); btnVideos.setTextColor(getResources().getColor(android.R.color.white)); btnCardio.setBackground(getResources().getDrawable(R.drawable.smallbtn)); btnCardio.setTextColor(getResources().getColor(android.R.color.white)); btnImages.setBackground(getResources().getDrawable(R.drawable.smallbtn)); btnImages.setTextColor(getResources().getColor(android.R.color.white)); android.support.v4.app.FragmentManager fragmentManager = getSupportFragmentManager(); android.support.v4.app.FragmentTransaction fragmentTransaction = fragmentManager .beginTransaction(); fragmentTransaction.replace(R.id.frame, new PersonalTrainerFragment()); fragmentTransaction.addToBackStack(null); fragmentTransaction.commit(); } } } if (view == btnVideos) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { btnVideos.setBackground(getResources().getDrawable(R.drawable.smallbtnclickd, null)); btnVideos.setTextColor(getResources().getColor(android.R.color.black, null)); btnBuiltIn.setBackground(getResources().getDrawable(R.drawable.buttonunselected, null)); btnMuscleIsolation.setBackground(getResources().getDrawable(R.drawable.buttonunselected, null)); btnCustomProgram.setBackground(getResources().getDrawable(R.drawable.buttonunselected, null)); btnSportsTraining.setBackground(getResources().getDrawable(R.drawable.buttonunselected, null)); btnhealthyLiving.setBackground(getResources().getDrawable(R.drawable.buttonunselected, null)); btnPersonalTrainer.setBackground(getResources().getDrawable(R.drawable.buttonunselected, null)); btnCardio.setBackground(getResources().getDrawable(R.drawable.smallbtn, null)); btnCardio.setTextColor(getResources().getColor(android.R.color.white, null)); btnImages.setBackground(getResources().getDrawable(R.drawable.smallbtn, null)); btnImages.setTextColor(getResources().getColor(android.R.color.white, null)); Intent intent = new Intent(MainActivity.this, AllImagesVideosActivity.class); intent.putExtra("type", "video"); startActivity(intent); } else { btnVideos.setBackground(getResources().getDrawable(R.drawable.smallbtnclickd)); btnVideos.setTextColor(getResources().getColor(android.R.color.black)); btnBuiltIn.setBackground(getResources().getDrawable(R.drawable.buttonunselected)); btnMuscleIsolation.setBackground(getResources().getDrawable(R.drawable.buttonunselected)); btnCustomProgram.setBackground(getResources().getDrawable(R.drawable.buttonunselected)); btnSportsTraining.setBackground(getResources().getDrawable(R.drawable.buttonunselected)); btnhealthyLiving.setBackground(getResources().getDrawable(R.drawable.buttonunselected)); btnPersonalTrainer.setBackground(getResources().getDrawable(R.drawable.buttonunselected)); btnCardio.setBackground(getResources().getDrawable(R.drawable.smallbtn)); btnCardio.setTextColor(getResources().getColor(android.R.color.white)); btnImages.setBackground(getResources().getDrawable(R.drawable.smallbtn)); btnImages.setTextColor(getResources().getColor(android.R.color.white)); Intent intent = new Intent(MainActivity.this, AllImagesVideosActivity.class); intent.putExtra("type", "video"); startActivity(intent); } } if (view == btnCardio) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { btnCardio.setBackground(getResources().getDrawable(R.drawable.smallbtnclickd, null)); btnCardio.setTextColor(getResources().getColor(android.R.color.black, null)); btnBuiltIn.setBackground(getResources().getDrawable(R.drawable.buttonunselected, null)); btnMuscleIsolation.setBackground(getResources().getDrawable(R.drawable.buttonunselected, null)); btnCustomProgram.setBackground(getResources().getDrawable(R.drawable.buttonunselected, null)); btnSportsTraining.setBackground(getResources().getDrawable(R.drawable.buttonunselected, null)); btnhealthyLiving.setBackground(getResources().getDrawable(R.drawable.buttonunselected, null)); btnPersonalTrainer.setBackground(getResources().getDrawable(R.drawable.buttonunselected, null)); btnVideos.setBackground(getResources().getDrawable(R.drawable.smallbtn, null)); btnVideos.setTextColor(getResources().getColor(android.R.color.white, null)); btnImages.setBackground(getResources().getDrawable(R.drawable.smallbtn, null)); btnImages.setTextColor(getResources().getColor(android.R.color.white, null)); try { startActivity(new Intent(MainActivity.this, Visit3GCardioActivity.class)); finish(); } catch (Exception e) { e.printStackTrace(); } } else { btnCardio.setBackground(getResources().getDrawable(R.drawable.smallbtnclickd)); btnCardio.setTextColor(getResources().getColor(android.R.color.black)); btnBuiltIn.setBackground(getResources().getDrawable(R.drawable.buttonunselected)); btnMuscleIsolation.setBackground(getResources().getDrawable(R.drawable.buttonunselected)); btnCustomProgram.setBackground(getResources().getDrawable(R.drawable.buttonunselected)); btnSportsTraining.setBackground(getResources().getDrawable(R.drawable.buttonunselected)); btnhealthyLiving.setBackground(getResources().getDrawable(R.drawable.buttonunselected)); btnPersonalTrainer.setBackground(getResources().getDrawable(R.drawable.buttonunselected)); btnVideos.setBackground(getResources().getDrawable(R.drawable.smallbtn)); btnVideos.setTextColor(getResources().getColor(android.R.color.white)); btnImages.setBackground(getResources().getDrawable(R.drawable.smallbtn)); btnImages.setTextColor(getResources().getColor(android.R.color.white)); try { startActivity(new Intent(MainActivity.this, Visit3GCardioActivity.class)); finish(); } catch (Exception e) { e.printStackTrace(); } } } if (view == btnImages) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { btnImages.setBackground(getResources().getDrawable(R.drawable.smallbtnclickd, null)); btnImages.setTextColor(getResources().getColor(android.R.color.black, null)); btnBuiltIn.setBackground(getResources().getDrawable(R.drawable.buttonunselected, null)); btnMuscleIsolation.setBackground(getResources().getDrawable(R.drawable.buttonunselected, null)); btnCustomProgram.setBackground(getResources().getDrawable(R.drawable.buttonunselected, null)); btnSportsTraining.setBackground(getResources().getDrawable(R.drawable.buttonunselected, null)); btnhealthyLiving.setBackground(getResources().getDrawable(R.drawable.buttonunselected, null)); btnPersonalTrainer.setBackground(getResources().getDrawable(R.drawable.buttonunselected, null)); btnVideos.setBackground(getResources().getDrawable(R.drawable.smallbtn, null)); btnVideos.setTextColor(getResources().getColor(android.R.color.white, null)); btnCardio.setBackground(getResources().getDrawable(R.drawable.smallbtn, null)); btnCardio.setTextColor(getResources().getColor(android.R.color.white, null)); Intent intent = new Intent(MainActivity.this, AllImagesVideosActivity.class); intent.putExtra("type", "image"); startActivity(intent); } else { btnImages.setBackground(getResources().getDrawable(R.drawable.smallbtnclickd)); btnImages.setTextColor(getResources().getColor(android.R.color.black)); btnBuiltIn.setBackground(getResources().getDrawable(R.drawable.buttonunselected)); btnMuscleIsolation.setBackground(getResources().getDrawable(R.drawable.buttonunselected)); btnCustomProgram.setBackground(getResources().getDrawable(R.drawable.buttonunselected)); btnSportsTraining.setBackground(getResources().getDrawable(R.drawable.buttonunselected)); btnhealthyLiving.setBackground(getResources().getDrawable(R.drawable.buttonunselected)); btnPersonalTrainer.setBackground(getResources().getDrawable(R.drawable.buttonunselected)); btnVideos.setBackground(getResources().getDrawable(R.drawable.smallbtn)); btnVideos.setTextColor(getResources().getColor(android.R.color.white)); btnCardio.setBackground(getResources().getDrawable(R.drawable.smallbtn)); btnCardio.setTextColor(getResources().getColor(android.R.color.white)); Intent intent = new Intent(MainActivity.this, AllImagesVideosActivity.class); intent.putExtra("type", "image"); startActivity(intent); } } }
From source file:cl.ipp.katbag.fragment.Develop.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { menu.clear();/* w w w . j a v a 2s . c o m*/ inflater.inflate(R.menu.develop, menu); menuItemEdit = menu.findItem(R.id.develop_dropdown_menu_edit); menuItemAddWorld = menu.findItem(R.id.develop_dropdown_menu_add_world); menuItemAddDrawing = menu.findItem(R.id.develop_dropdown_menu_add_drawing); menuItemAddMotion = menu.findItem(R.id.develop_dropdown_menu_add_motion); menuItemAddLook = menu.findItem(R.id.develop_dropdown_menu_add_look); menuItemAddSound = menu.findItem(R.id.develop_dropdown_menu_add_sound); menuItemAddControl = menu.findItem(R.id.develop_dropdown_menu_add_control); menuItemAddSensing = menu.findItem(R.id.develop_dropdown_menu_add_sensing); menuItemPlayer = menu.findItem(R.id.develop_dropdown_menu_player); menuItemEdit.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { if (editMode) { editMode = false; menuItemEdit.setIcon(R.drawable.ic_action_edit); } else { editMode = true; menuItemEdit.setIcon(R.drawable.ic_action_accept); } loadListView(); return true; } }); menuItemAddWorld.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { showAlertDialog(OBJECT_WORLD, -1); return true; } }); menuItemAddDrawing.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { showAlertDialog(OBJECT_DRAWING, -1); return true; } }); menuItemAddMotion.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { showAlertDialog(OBJECT_MOTION, -1); return true; } }); menuItemAddLook.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { showAlertDialog(OBJECT_LOOK, -1); return true; } }); menuItemAddSound.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { showAlertDialog(OBJECT_SOUND, -1); return true; } }); menuItemAddControl.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { showAlertDialog(OBJECT_CONTROL, -1); return true; } }); menuItemAddSensing.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { showAlertDialog(OBJECT_SENSING, -1); return true; } }); menuItemPlayer.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { mFragment = new Player(); Bundle bundle = new Bundle(); bundle.putLong("id_app", id_app); bundle.putBoolean("editMode", true); bundle.putString("name_app", Add.name_app_text); mFragment.setArguments(bundle); FragmentTransaction t = getActivity().getSupportFragmentManager().beginTransaction(); t.replace(R.id.fragment_main_container, mFragment); t.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE); t.addToBackStack(mFragment.getClass().getSimpleName()); t.commit(); return true; } }); super.onCreateOptionsMenu(menu, inflater); }
From source file:com.arquitetaweb.restaurantes.MainActivity.java
public void updateContent(Uri uri) { final Fragment fragment; final String tag; final FragmentManager fm = getSupportFragmentManager(); final FragmentTransaction tr = fm.beginTransaction(); if (!currentUri.equals(uri)) { final Fragment currentFragment = fm.findFragmentByTag(currentContentFragmentTag); if (currentFragment != null) tr.hide(currentFragment);//from www . j a va 2 s .co m } if (MainFragment.ABOUT_URI.equals(uri)) { tag = MainFragment.TAG; final Fragment foundFragment = fm.findFragmentByTag(tag); if (foundFragment != null) { fragment = foundFragment; } else { fragment = new MainFragment(); } } else if (CardapioFragment.CARDAPIO_URI.equals(uri)) { tag = CardapioFragment.TAG; final Fragment foundFragment = fm.findFragmentByTag(tag); if (foundFragment != null) { fragment = foundFragment; } else { fragment = new CardapioFragment(); } } else if (ConfigurationsFragment.SETTINGS_URI.equals(uri)) { tag = ConfigurationsFragment.TAG; final ConfigurationsFragment foundFragment = (ConfigurationsFragment) fm.findFragmentByTag(tag); if (foundFragment != null) { fragment = foundFragment; } else { final ConfigurationsFragment settingsFragment = new ConfigurationsFragment(); // botao aki fragment = settingsFragment; } } else if (uri != null) { tag = WebViewFragment.TAG; final WebViewFragment webViewFragment; final Fragment foundFragment = fm.findFragmentByTag(tag); if (foundFragment != null) { fragment = foundFragment; webViewFragment = (WebViewFragment) fragment; } else { webViewFragment = new WebViewFragment(); fragment = webViewFragment; } webViewFragment.setUrl(uri.toString()); } else { return; } if (fragment.isAdded()) { tr.show(fragment); } else { tr.replace(R.id.content, fragment, tag); } tr.commit(); currentUri = uri; currentContentFragmentTag = tag; }
From source file:com.anjalimacwan.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { // Set action bar elevation getSupportActionBar().setElevation(getResources().getDimensionPixelSize(R.dimen.action_bar_elevation)); }/*ww w. jav a 2 s . co m*/ // Show dialog if this is the user's first time running Notepad SharedPreferences prefMain = getPreferences(Context.MODE_PRIVATE); if (prefMain.getInt("first-run", 0) == 0) { // Show welcome dialog if (getSupportFragmentManager().findFragmentByTag("firstrunfragment") == null) { DialogFragment firstRun = new FirstRunDialogFragment(); firstRun.show(getSupportFragmentManager(), "firstrunfragment"); } } else { // Check to see if Android Wear app is installed, and offer to install the Notepad Plugin checkForAndroidWear(); // The following code is only present to support existing users of Notepad on Google Play // and can be removed if using this source code for a different app // Convert old preferences to new ones SharedPreferences pref = getSharedPreferences(getPackageName() + "_preferences", Context.MODE_PRIVATE); if (prefMain.getInt("sort-by", -1) == 0) { SharedPreferences.Editor editor = pref.edit(); SharedPreferences.Editor editorMain = prefMain.edit(); editor.putString("sort_by", "date"); editorMain.putInt("sort-by", -1); editor.apply(); editorMain.apply(); } else if (prefMain.getInt("sort-by", -1) == 1) { SharedPreferences.Editor editor = pref.edit(); SharedPreferences.Editor editorMain = prefMain.edit(); editor.putString("sort_by", "name"); editorMain.putInt("sort-by", -1); editor.apply(); editorMain.apply(); } if (pref.getString("font_size", "null").equals("null")) { SharedPreferences.Editor editor = pref.edit(); editor.putString("font_size", "large"); editor.apply(); } // Rename any saved drafts from 1.3.x File oldDraft = new File(getFilesDir() + File.separator + "draft"); File newDraft = new File(getFilesDir() + File.separator + String.valueOf(System.currentTimeMillis())); if (oldDraft.exists()) oldDraft.renameTo(newDraft); } // Begin a new FragmentTransaction FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); // This fragment shows NoteListFragment as a sidebar (only seen in tablet mode landscape) if (!(getSupportFragmentManager().findFragmentById(R.id.noteList) instanceof NoteListFragment)) transaction.replace(R.id.noteList, new NoteListFragment(), "NoteListFragment"); // This fragment shows NoteListFragment in the main screen area (only seen on phones and tablet mode portrait), // but only if it doesn't already contain NoteViewFragment or NoteEditFragment. // If NoteListFragment is already showing in the sidebar, use WelcomeFragment instead if (!((getSupportFragmentManager().findFragmentById(R.id.noteViewEdit) instanceof NoteEditFragment) || (getSupportFragmentManager().findFragmentById(R.id.noteViewEdit) instanceof NoteViewFragment))) { if ((getSupportFragmentManager().findFragmentById(R.id.noteViewEdit) == null && findViewById(R.id.layoutMain).getTag().equals("main-layout-large")) || ((getSupportFragmentManager() .findFragmentById(R.id.noteViewEdit) instanceof NoteListFragment) && findViewById(R.id.layoutMain).getTag().equals("main-layout-large"))) transaction.replace(R.id.noteViewEdit, new WelcomeFragment(), "NoteListFragment"); else if (findViewById(R.id.layoutMain).getTag().equals("main-layout-normal")) transaction.replace(R.id.noteViewEdit, new NoteListFragment(), "NoteListFragment"); } // Commit fragment transaction transaction.commit(); }