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();
}
}
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));
}
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;
}
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);
}
}
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);
}
Aggregations