Search in sources :

Example 51 with Fragment

use of android.app.Fragment in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class ActionListViewSettings method onDestroyView.

@Override
public void onDestroyView() {
    super.onDestroyView();
    if (mAdditionalFragmentAttached) {
        FragmentManager fragmentManager = getFragmentManager();
        Fragment fragment = fragmentManager.findFragmentById(R.id.fragment_container);
        if (fragment != null && !fragmentManager.isDestroyed()) {
            fragmentManager.beginTransaction().remove(fragment).commit();
        }
    }
}
Also used : FragmentManager(android.app.FragmentManager) ListFragment(android.app.ListFragment) DialogFragment(android.app.DialogFragment) Fragment(android.app.Fragment)

Example 52 with Fragment

use of android.app.Fragment in project android_frameworks_base by ResurrectionRemix.

the class BiDiTestActivity method onListItemClick.

private void onListItemClick(ListView lv, View v, int position, long id) {
    // Show the test
    Map<String, Object> map = (Map<String, Object>) lv.getItemAtPosition(position);
    int fragmentId = (Integer) map.get(KEY_FRAGMENT_ID);
    Fragment fragment = getFragmentManager().findFragmentById(fragmentId);
    if (fragment == null) {
        try {
            // Create an instance of the test
            Class<? extends Fragment> clazz = (Class<? extends Fragment>) map.get(KEY_CLASS);
            fragment = clazz.newInstance();
            // Replace the old test fragment with the new one
            FragmentTransaction ft = getFragmentManager().beginTransaction();
            ft.replace(R.id.testframe, fragment);
            ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
            ft.commit();
        } catch (InstantiationException e) {
        } catch (IllegalAccessException e) {
        }
    }
}
Also used : FragmentTransaction(android.app.FragmentTransaction) HashMap(java.util.HashMap) Map(java.util.Map) Fragment(android.app.Fragment)

Example 53 with Fragment

use of android.app.Fragment in project android_frameworks_base by ResurrectionRemix.

the class SharedLibraryMain method ensureVersion.

/**
     * Check that the library's version is at least the given minimum version,
     * displaying a dialog to have the user install an update if that is not true.
     * The dialog is displayed as a DialogFragment in your activity if a newer
     * version is needed.  If a newer version is needed, false is returned.
     */
public static boolean ensureVersion(final Activity activity, int minVersion) {
    final FragmentManager fm = activity.getFragmentManager();
    final String dialogTag = LIBRARY_PACKAGE + ":version";
    Fragment curDialog = fm.findFragmentByTag(dialogTag);
    if (getVersion(activity) >= minVersion) {
        // we had shown is removed before returning.
        if (curDialog != null) {
            fm.beginTransaction().remove(curDialog).commitAllowingStateLoss();
        }
        return true;
    }
    // If we don't already have a version dialog displayed, display it now.
    if (curDialog == null) {
        curDialog = new VersionDialog();
        fm.beginTransaction().add(curDialog, dialogTag).commitAllowingStateLoss();
    }
    // Tell the caller that the current version is not sufficient.
    return false;
}
Also used : FragmentManager(android.app.FragmentManager) Fragment(android.app.Fragment)

Example 54 with Fragment

use of android.app.Fragment in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class SubActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    ActionBar actionBar = getActionBar();
    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);
    }
    String fragmentExtra = getIntent().getStringExtra(EXTRA_FRAGMENT_CLASS);
    if (fragmentExtra != null && !fragmentExtra.isEmpty()) {
        try {
            Class<?> fragmentClass = Class.forName(fragmentExtra);
            Fragment fragment = (Fragment) fragmentClass.newInstance();
            getFragmentManager().beginTransaction().replace(android.R.id.content, fragment).commit();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    String title = getIntent().getStringExtra(EXTRA_TITLE);
    if (title != null && !title.isEmpty()) {
        setTitle(title);
    }
}
Also used : Fragment(android.app.Fragment) ActionBar(android.app.ActionBar)

Example 55 with Fragment

use of android.app.Fragment in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class InputMethodAndLanguageSettings method updateUserDictionaryPreference.

private void updateUserDictionaryPreference(Preference userDictionaryPreference) {
    if (userDictionaryPreference == null) {
        return;
    }
    final Activity activity = getActivity();
    final TreeSet<String> localeSet = UserDictionaryList.getUserDictionaryLocalesSet(activity);
    if (null == localeSet) {
        // The locale list is null if and only if the user dictionary service is
        // not present or disabled. In this case we need to remove the preference.
        getPreferenceScreen().removePreference(userDictionaryPreference);
    } else {
        userDictionaryPreference.setOnPreferenceClickListener(new OnPreferenceClickListener() {

            @Override
            public boolean onPreferenceClick(Preference arg0) {
                // Redirect to UserDictionarySettings if the user needs only one
                // language.
                final Bundle extras = new Bundle();
                final Class<? extends Fragment> targetFragment;
                if (localeSet.size() <= 1) {
                    if (!localeSet.isEmpty()) {
                        // If the size of localeList is 0, we don't set the locale
                        // parameter in the extras. This will be interpreted by the
                        // UserDictionarySettings class as meaning
                        // "the current locale". Note that with the current code for
                        // UserDictionaryList#getUserDictionaryLocalesSet()
                        // the locale list always has at least one element, since it
                        // always includes the current locale explicitly.
                        // @see UserDictionaryList.getUserDictionaryLocalesSet().
                        extras.putString("locale", localeSet.first());
                    }
                    targetFragment = UserDictionarySettings.class;
                } else {
                    targetFragment = UserDictionaryList.class;
                }
                startFragment(InputMethodAndLanguageSettings.this, targetFragment.getCanonicalName(), -1, -1, extras);
                return true;
            }
        });
    }
}
Also used : OnPreferenceClickListener(android.support.v7.preference.Preference.OnPreferenceClickListener) UserDictionarySettings(com.android.settings.UserDictionarySettings) ListPreference(android.support.v7.preference.ListPreference) Preference(android.support.v7.preference.Preference) SwitchPreference(android.support.v14.preference.SwitchPreference) Bundle(android.os.Bundle) SettingsActivity(com.android.settings.SettingsActivity) KeyboardLayoutPickerActivity(com.android.settings.Settings.KeyboardLayoutPickerActivity) Activity(android.app.Activity) SettingsPreferenceFragment(com.android.settings.SettingsPreferenceFragment) Fragment(android.app.Fragment)

Aggregations

Fragment (android.app.Fragment)209 FragmentTransaction (android.app.FragmentTransaction)82 FragmentManager (android.app.FragmentManager)51 DialogFragment (android.app.DialogFragment)44 Bundle (android.os.Bundle)22 Intent (android.content.Intent)13 View (android.view.View)13 PreferenceFragment (android.support.v14.preference.PreferenceFragment)12 TextView (android.widget.TextView)8 BizFragment (org.aisen.weibo.sina.ui.fragment.base.BizFragment)8 Uri (android.net.Uri)6 ABaseFragment (org.aisen.android.ui.fragment.ABaseFragment)6 Activity (android.app.Activity)5 PreferenceFragment (android.preference.PreferenceFragment)4 HashMap (java.util.HashMap)4 Map (java.util.Map)4 ViewGroup (android.view.ViewGroup)3 FrameLayout (android.widget.FrameLayout)3 ContactVcardViewerFragment (com.xabber.android.ui.fragment.ContactVcardViewerFragment)3 Method (java.lang.reflect.Method)3