Search in sources :

Example 91 with FragmentManager

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);
        }
    }
}
Also used : Fragment(android.support.v4.app.Fragment)

Example 92 with FragmentManager

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);
}
Also used : Fragment(android.support.v4.app.Fragment)

Example 93 with FragmentManager

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;
}
Also used : FragmentManager(android.support.v4.app.FragmentManager)

Example 94 with FragmentManager

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);
    }
}
Also used : PackageInfo(android.content.pm.PackageInfo) ActionBarDrawerToggle(android.support.v4.app.ActionBarDrawerToggle) ArrayList(java.util.ArrayList) WebView(android.webkit.WebView) PackageManager(android.content.pm.PackageManager) WebView(android.webkit.WebView)

Example 95 with FragmentManager

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();
    }
}
Also used : FragmentManager(android.support.v4.app.FragmentManager)

Aggregations

FragmentManager (android.support.v4.app.FragmentManager)293 FragmentTransaction (android.support.v4.app.FragmentTransaction)106 Fragment (android.support.v4.app.Fragment)99 View (android.view.View)53 TextView (android.widget.TextView)35 Bundle (android.os.Bundle)31 OnClickListener (android.view.View.OnClickListener)24 DialogFragment (android.support.v4.app.DialogFragment)23 Intent (android.content.Intent)20 ImageView (android.widget.ImageView)16 ScrollView (android.widget.ScrollView)14 ListFragment (android.support.v4.app.ListFragment)12 Button (android.widget.Button)11 ArrayList (java.util.ArrayList)9 FrontPageFragment (ingage.ingage20.fragments.FrontPageFragment)8 SearchResultFragment (ingage.ingage20.fragments.SearchResultFragment)8 ViewPager (android.support.v4.view.ViewPager)7 ActionBar (android.support.v7.app.ActionBar)7 RecyclerView (android.support.v7.widget.RecyclerView)7 CategoriesPageFragment (ingage.ingage20.fragments.CategoriesPageFragment)7