Search in sources :

Example 21 with Fragment

use of androidx.fragment.app.Fragment in project StatusBarCompat by niorgai.

the class MainActivity method changeTab.

private void changeTab(int page) {
    if (currentTab == page) {
        return;
    }
    Fragment fragment = fragments.get(page);
    FragmentTransaction ft = MainActivity.this.getSupportFragmentManager().beginTransaction();
    if (!fragment.isAdded()) {
        ft.add(fragmentContentId, fragment);
    }
    ft.hide(fragments.get(currentTab));
    ft.show(fragments.get(page));
    changeButtonStatus(currentTab, false);
    currentTab = page;
    changeButtonStatus(currentTab, true);
    if (!this.isFinishing()) {
        ft.commitAllowingStateLoss();
    }
}
Also used : FragmentTransaction(androidx.fragment.app.FragmentTransaction) DrawerFragment(qiu.statusbarcompat.fragment.DrawerFragment) CommonFragment(qiu.statusbarcompat.fragment.CommonFragment) TranslucentFragment(qiu.statusbarcompat.fragment.TranslucentFragment) CollapsingToolbarFragment(qiu.statusbarcompat.fragment.CollapsingToolbarFragment) Fragment(androidx.fragment.app.Fragment)

Example 22 with Fragment

use of androidx.fragment.app.Fragment in project robolectric by robolectric.

the class ActivityScenarioTest method recreate_retainFragmentHostingActivity.

@Test
public void recreate_retainFragmentHostingActivity() {
    Fragment fragment = new Fragment();
    fragment.setRetainInstance(true);
    ActivityScenario<LifecycleOwnerActivity> activityScenario = ActivityScenario.launch(LifecycleOwnerActivity.class);
    assertThat(activityScenario).isNotNull();
    activityScenario.onActivity(activity -> {
        activity.getSupportFragmentManager().beginTransaction().add(android.R.id.content, fragment).commitNow();
        assertThat(activity.getSupportFragmentManager().findFragmentById(android.R.id.content)).isSameInstanceAs(fragment);
    });
    activityScenario.recreate();
    activityScenario.onActivity(activity -> assertThat(activity.getSupportFragmentManager().findFragmentById(android.R.id.content)).isSameInstanceAs(fragment));
}
Also used : Fragment(androidx.fragment.app.Fragment) Test(org.junit.Test)

Example 23 with Fragment

use of androidx.fragment.app.Fragment in project ETSMobile-Android2 by ApplETS.

the class BottinDetailsFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.bottin_detail_fragment, container, false);
    tv_nom_prenom = (TextView) v.findViewById(R.id.tv_nom_prenom_bottin);
    tv_titre = (TextView) v.findViewById(R.id.tv_titre_bottin);
    tv_service = (TextView) v.findViewById(R.id.tv_service_bottin);
    tv_emplacement = (TextView) v.findViewById(R.id.tv_emplacement_bottin);
    tv_telbureau = (TextView) v.findViewById(R.id.tv_telbureau_bottin);
    tv_courriel = (TextView) v.findViewById(R.id.tv_courriel_bottin);
    btn_ajout_contact = (Button) v.findViewById(R.id.btn_ajout_contact_bottin);
    tv_nom_prenom.setText(prenom + " " + nom);
    tv_titre.setText(titre);
    tv_service.setText(service);
    tv_emplacement.setText(emplacement);
    tv_telbureau.setText(telbureau);
    Linkify.addLinks(tv_telbureau, Patterns.PHONE, "tel:", Linkify.sPhoneNumberMatchFilter, Linkify.sPhoneNumberTransformFilter);
    tv_courriel.setText(courriel);
    Linkify.addLinks(tv_courriel, Linkify.EMAIL_ADDRESSES);
    btn_ajout_contact.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            Bundle args = new Bundle();
            args.putString(BottinDetailsFragment.NOM, nom);
            args.putString(PRENOM, prenom);
            args.putString(TITRE, titre);
            args.putString(SERVICE, service);
            args.putString(EMPLACEMENT, emplacement);
            args.putString(TELBUREAU, telbureau);
            args.putString(COURRIEL, courriel);
            Fragment fragment = ContactAdderFragment.newInstance(args);
            showFragment(fragment);
        }
    });
    return v;
}
Also used : Bundle(android.os.Bundle) OnClickListener(android.view.View.OnClickListener) TextView(android.widget.TextView) View(android.view.View) Fragment(androidx.fragment.app.Fragment)

Example 24 with Fragment

use of androidx.fragment.app.Fragment in project Douya by DreaminginCodeZH.

the class ItemIntroductionActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // Calls ensureSubDecor().
    findViewById(android.R.id.content);
    if (savedInstanceState == null) {
        Intent intent = getIntent();
        CollectableItem item = intent.getParcelableExtra(EXTRA_ITEM);
        Fragment fragment;
        switch(item.getType()) {
            case APP:
                // TODO
                throw new UnsupportedOperationException();
            case BOOK:
                fragment = BookIntroductionFragment.newInstance((Book) item);
                break;
            case EVENT:
                // TODO
                throw new UnsupportedOperationException();
            case GAME:
                fragment = GameIntroductionFragment.newInstance((Game) item);
                break;
            case MOVIE:
            case TV:
                fragment = MovieIntroductionFragment.newInstance((Movie) item);
                break;
            case MUSIC:
                fragment = MusicIntroductionFragment.newInstance((Music) item);
                break;
            default:
                throw new IllegalArgumentException();
        }
        FragmentUtils.add(fragment, this, android.R.id.content);
    }
}
Also used : Movie(me.zhanghai.android.douya.network.api.info.frodo.Movie) CollectableItem(me.zhanghai.android.douya.network.api.info.frodo.CollectableItem) Game(me.zhanghai.android.douya.network.api.info.frodo.Game) Book(me.zhanghai.android.douya.network.api.info.frodo.Book) Music(me.zhanghai.android.douya.network.api.info.frodo.Music) Intent(android.content.Intent) Fragment(androidx.fragment.app.Fragment)

Example 25 with Fragment

use of androidx.fragment.app.Fragment in project Douya by DreaminginCodeZH.

the class SimpleDialogFragment method onActivityCreated.

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    Fragment parentFragment = getParentFragment();
    if (parentFragment == null) {
        Activity activity = getActivity();
        if (activity instanceof ListenerProvider) {
            mListener = ((ListenerProvider) activity).getDialogListener();
        }
    } else {
        if (parentFragment instanceof ListenerProvider) {
            mListener = ((ListenerProvider) parentFragment).getDialogListener();
        }
    }
    mRequestCode = getArguments().getInt(ARGUMENT_REQUEST_CODE);
}
Also used : FragmentActivity(androidx.fragment.app.FragmentActivity) Activity(android.app.Activity) AppCompatDialogFragment(androidx.appcompat.app.AppCompatDialogFragment) Fragment(androidx.fragment.app.Fragment)

Aggregations

Fragment (androidx.fragment.app.Fragment)262 FragmentTransaction (androidx.fragment.app.FragmentTransaction)57 Bundle (android.os.Bundle)49 FragmentManager (androidx.fragment.app.FragmentManager)42 DialogFragment (androidx.fragment.app.DialogFragment)24 FileFragment (com.owncloud.android.ui.fragment.FileFragment)23 Intent (android.content.Intent)22 View (android.view.View)22 FileDetailFragment (com.owncloud.android.ui.fragment.FileDetailFragment)20 OCFileListFragment (com.owncloud.android.ui.fragment.OCFileListFragment)20 SortingOrderDialogFragment (com.owncloud.android.ui.dialog.SortingOrderDialogFragment)19 GalleryFragment (com.owncloud.android.ui.fragment.GalleryFragment)18 TaskRetainerFragment (com.owncloud.android.ui.fragment.TaskRetainerFragment)18 UnifiedSearchFragment (com.owncloud.android.ui.fragment.UnifiedSearchFragment)18 PreviewImageFragment (com.owncloud.android.ui.preview.PreviewImageFragment)18 PreviewMediaFragment (com.owncloud.android.ui.preview.PreviewMediaFragment)18 PreviewTextFileFragment (com.owncloud.android.ui.preview.PreviewTextFileFragment)18 PreviewTextFragment (com.owncloud.android.ui.preview.PreviewTextFragment)18 PreviewTextStringFragment (com.owncloud.android.ui.preview.PreviewTextStringFragment)18 PreviewPdfFragment (com.owncloud.android.ui.preview.pdf.PreviewPdfFragment)18