Search in sources :

Example 46 with FragmentActivity

use of androidx.fragment.app.FragmentActivity in project android-oss by kickstarter.

the class BaseBottomSheetDialogFragment method onPause.

@CallSuper
@Override
public void onPause() {
    this.lifecycle.onNext(FragmentEvent.PAUSE);
    super.onPause();
    Timber.d("onPause %s", this.toString());
    if (this.viewModel != null) {
        this.viewModel.onPause();
        final FragmentActivity activity = getActivity();
        if (activity != null) {
            activity.unregisterReceiver(this.optimizelyReadyReceiver);
        }
    }
}
Also used : FragmentActivity(androidx.fragment.app.FragmentActivity) CallSuper(androidx.annotation.CallSuper)

Example 47 with FragmentActivity

use of androidx.fragment.app.FragmentActivity in project android-oss by kickstarter.

the class BaseFragment method onResume.

@CallSuper
@Override
public void onResume() {
    super.onResume();
    Timber.d("onResume %s", this.toString());
    this.lifecycle.onNext(FragmentEvent.RESUME);
    assignViewModel(null);
    if (this.viewModel != null) {
        this.viewModel.onResume(this);
        final FragmentActivity activity = getActivity();
        if (activity != null) {
            activity.registerReceiver(this.optimizelyReadyReceiver, new IntentFilter(ExperimentsClientTypeKt.EXPERIMENTS_CLIENT_READY));
        }
    }
}
Also used : FragmentActivity(androidx.fragment.app.FragmentActivity) IntentFilter(android.content.IntentFilter) CallSuper(androidx.annotation.CallSuper)

Example 48 with FragmentActivity

use of androidx.fragment.app.FragmentActivity in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class DefaultAppPickerFragment method onRadioButtonClicked.

@Override
public void onRadioButtonClicked(RadioButtonPreference selected) {
    final String selectedKey = selected.getKey();
    final CharSequence confirmationMessage = getConfirmationMessage(getCandidate(selectedKey));
    final FragmentActivity activity = getActivity();
    if (TextUtils.isEmpty(confirmationMessage)) {
        super.onRadioButtonClicked(selected);
    } else if (activity != null) {
        final DialogFragment fragment = newConfirmationDialogFragment(selectedKey, confirmationMessage);
        fragment.show(activity.getSupportFragmentManager(), ConfirmationDialogFragment.TAG);
    }
}
Also used : FragmentActivity(androidx.fragment.app.FragmentActivity) InstrumentedDialogFragment(com.android.settings.core.instrumentation.InstrumentedDialogFragment) DialogFragment(androidx.fragment.app.DialogFragment)

Example 49 with FragmentActivity

use of androidx.fragment.app.FragmentActivity in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class PanelFragment method createPanelContent.

private void createPanelContent() {
    final FragmentActivity activity = getActivity();
    if (mLayoutView == null) {
        activity.finish();
    }
    mPanelSlices = mLayoutView.findViewById(R.id.panel_parent_layout);
    mSeeMoreButton = mLayoutView.findViewById(R.id.see_more);
    mDoneButton = mLayoutView.findViewById(R.id.done);
    mTitleView = mLayoutView.findViewById(R.id.panel_title);
    // Make the panel layout gone here, to avoid janky animation when updating from old panel.
    // We will make it visible once the panel is ready to load.
    mPanelSlices.setVisibility(View.GONE);
    final Bundle arguments = getArguments();
    final String panelType = arguments.getString(SettingsPanelActivity.KEY_PANEL_TYPE_ARGUMENT);
    final String callingPackageName = arguments.getString(SettingsPanelActivity.KEY_CALLING_PACKAGE_NAME);
    final String mediaPackageName = arguments.getString(SettingsPanelActivity.KEY_MEDIA_PACKAGE_NAME);
    // TODO (b/124399577) transform interface to take a context and bundle.
    mPanel = FeatureFactory.getFactory(activity).getPanelFeatureProvider().getPanel(activity, panelType, mediaPackageName);
    if (mPanel == null) {
        activity.finish();
    }
    mMetricsProvider = FeatureFactory.getFactory(activity).getMetricsFeatureProvider();
    mPanelSlices.setLayoutManager(new LinearLayoutManager((activity)));
    // Add predraw listener to remove the animation and while we wait for Slices to load.
    mLayoutView.getViewTreeObserver().addOnPreDrawListener(mOnPreDrawListener);
    // Start loading Slices. When finished, the Panel will animate in.
    loadAllSlices();
    mTitleView.setText(mPanel.getTitle());
    mSeeMoreButton.setOnClickListener(getSeeMoreListener());
    mDoneButton.setOnClickListener(getCloseListener());
    // If getSeeMoreIntent() is null, hide the mSeeMoreButton.
    if (mPanel.getSeeMoreIntent() == null) {
        mSeeMoreButton.setVisibility(View.GONE);
    }
    // Log panel opened.
    mMetricsProvider.action(0, /* attribution */
    SettingsEnums.PAGE_VISIBLE, /* opened panel - Action */
    mPanel.getMetricsCategory(), callingPackageName, 0);
}
Also used : FragmentActivity(androidx.fragment.app.FragmentActivity) Bundle(android.os.Bundle) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager)

Example 50 with FragmentActivity

use of androidx.fragment.app.FragmentActivity in project FirebaseUI-Android by firebase.

the class EmailLinkCrossDeviceLinkingFragment method onActivityCreated.

@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    FragmentActivity activity = getActivity();
    if (!(activity instanceof FinishEmailLinkSignInListener)) {
        throw new IllegalStateException("Activity must implement EmailLinkPromptEmailListener");
    }
    mListener = (FinishEmailLinkSignInListener) activity;
}
Also used : FragmentActivity(androidx.fragment.app.FragmentActivity)

Aggregations

FragmentActivity (androidx.fragment.app.FragmentActivity)185 Test (org.junit.Test)71 Intent (android.content.Intent)25 Bundle (android.os.Bundle)19 View (android.view.View)11 Config (org.robolectric.annotation.Config)11 TextView (android.widget.TextView)10 Before (org.junit.Before)10 BroadcastReceiver (android.content.BroadcastReceiver)8 Fragment (androidx.fragment.app.Fragment)8 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)8 Activity (android.app.Activity)7 Resources (android.content.res.Resources)7 FragmentManager (androidx.fragment.app.FragmentManager)7 IntentFilter (android.content.IntentFilter)6 UserHandle (android.os.UserHandle)6 Preference (androidx.preference.Preference)6 SwitchPreference (androidx.preference.SwitchPreference)6 RestrictedSwitchPreference (com.android.settingslib.RestrictedSwitchPreference)6 Tile (com.android.settingslib.drawer.Tile)6