use of android.support.v4.app.FragmentManager in project AndroidUtilCode by Blankj.
the class FragmentUtils method removeAllFragments.
/**
* 移除所有fragment
*/
public static void removeAllFragments(@NonNull FragmentManager fragmentManager) {
List<Fragment> fragments = getFragments(fragmentManager);
if (fragments.isEmpty())
return;
for (int i = fragments.size() - 1; i >= 0; --i) {
Fragment fragment = fragments.get(i);
if (fragment != null) {
removeAllFragments(fragment.getChildFragmentManager());
removeFragment(fragment);
}
}
}
use of android.support.v4.app.FragmentManager in project AndroidUtilCode by Blankj.
the class FragmentUtils method addFragments.
/**
* 新增多个fragment
*
* @param fragmentManager fragment管理器
* @param fragments fragments
* @param containerId 布局Id
* @param showIndex 要显示的fragment索引
* @return 要显示的fragment
*/
public static Fragment addFragments(@NonNull FragmentManager fragmentManager, @NonNull List<Fragment> fragments, @IdRes int containerId, int showIndex, @NonNull List<SharedElement>... lists) {
for (int i = 0, size = fragments.size(); i < size; ++i) {
Fragment fragment = fragments.get(i);
List<SharedElement> list = lists[i];
if (fragment != null) {
if (list != null) {
putArgs(fragment, new Args(containerId, showIndex != i, false));
return operateFragment(fragmentManager, null, fragment, TYPE_ADD_FRAGMENT, list.toArray(new SharedElement[0]));
}
}
}
return fragments.get(showIndex);
}
use of android.support.v4.app.FragmentManager in project Douya by DreaminginCodeZH.
the class ScalpelHelperFragment method attachTo.
/**
* @deprecated Use {@link #attachTo(Fragment)} instead.
*/
public static ScalpelHelperFragment attachTo(FragmentActivity activity) {
FragmentManager fragmentManager = activity.getSupportFragmentManager();
ScalpelHelperFragment fragment = (ScalpelHelperFragment) fragmentManager.findFragmentByTag(FRAGMENT_TAG);
if (fragment == null) {
fragment = new ScalpelHelperFragment();
fragmentManager.beginTransaction().add(fragment, FRAGMENT_TAG).commit();
}
return fragment;
}
use of android.support.v4.app.FragmentManager in project Aegis by Decad3nce.
the class AegisActivity method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
final SharedPreferences preferences = getSharedPreferences(PREFERENCES_AEGIS, MODE_PRIVATE);
mVersion = preferences.getString(PREFERENCES_AEGIS_VERSION, "35");
FragmentManager fragmentManager = getFragmentManager();
setContentView(R.layout.drawer_layout);
final ActionBar bar = getActionBar();
bar.setDisplayShowHomeEnabled(true);
bar.setHomeButtonEnabled(true);
bar.setDisplayHomeAsUpEnabled(true);
Fragment fragment = new SMSAlarmFragment();
fragmentManager.beginTransaction().replace(R.id.content_frame, fragment).commit();
mTitle = mDrawerTitle = getTitle();
mMenuTitles = getMenuTitles();
mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
mDrawerList = (ListView) findViewById(R.id.left_drawer);
mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.drawable.ic_drawer, R.string.drawer_open, R.string.drawer_close) {
public void onDrawerClosed(View view) {
((BaseAdapter) mDrawerList.getAdapter()).notifyDataSetChanged();
invalidateOptionsMenu();
getActionBar().setTitle(mTitle);
}
public void onDrawerOpened(View drawerView) {
getActionBar().setTitle("Menu");
((BaseAdapter) mDrawerList.getAdapter()).notifyDataSetChanged();
Utils.hideItem(R.id.alarm_menu_settings, thisMenu);
Utils.hideItem(R.id.lock_menu_settings, thisMenu);
Utils.hideItem(R.id.locate_menu_settings, thisMenu);
Utils.hideItem(R.id.wipe_menu_settings, thisMenu);
Utils.hideItem(R.id.data_menu_settings, thisMenu);
Utils.showItem(R.id.action_help, thisMenu);
}
};
mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START);
mDrawerList.setAdapter(new DrawerLayoutAdapter(this, R.layout.drawer_list_item, new ArrayList(Arrays.asList(mMenuTitles))));
mDrawerList.setOnItemClickListener(new DrawerItemClickListener());
mDrawerLayout.setDrawerListener(mDrawerToggle);
int versionCode = 0;
try {
PackageInfo packageInfo = getPackageManager().getPackageInfo(getPackageName(), 0);
versionCode = packageInfo.versionCode;
} catch (PackageManager.NameNotFoundException e) {
//shwat
}
if (savedInstanceState == null) {
if (versionCode > Integer.parseInt(mVersion)) {
mVersion = String.valueOf(versionCode);
WebView webView = new WebView(this);
webView.loadUrl("file:///android_asset/changelog.html");
AlertDialog.Builder dialog = new AlertDialog.Builder(this);
dialog.setView(webView);
dialog.setPositiveButton("Dismiss", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
SharedPreferences.Editor editor = preferences.edit();
// value to store
editor.putString(PREFERENCES_AEGIS_VERSION, mVersion);
editor.commit();
dialog.dismiss();
}
});
dialog.show();
} else {
selectItem(0);
}
} else {
selectItem(mIndex);
}
}
use of android.support.v4.app.FragmentManager in project ActionBarSherlock by JakeWharton.
the class LoaderCursorSupport method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
FragmentManager fm = getSupportFragmentManager();
// Create the list fragment and add it as our sole content.
if (fm.findFragmentById(android.R.id.content) == null) {
CursorLoaderListFragment list = new CursorLoaderListFragment();
fm.beginTransaction().add(android.R.id.content, list).commit();
}
}
Aggregations