Search in sources :

Example 66 with FragmentActivity

use of androidx.fragment.app.FragmentActivity in project android by nextcloud.

the class ActivityInjector method onActivityCreated.

@Override
public final void onActivityCreated(Activity activity, Bundle savedInstanceState) {
    if (activity instanceof Injectable) {
        AndroidInjection.inject(activity);
    }
    if (activity instanceof FragmentActivity) {
        final FragmentManager fm = ((FragmentActivity) activity).getSupportFragmentManager();
        fm.registerFragmentLifecycleCallbacks(new FragmentInjector(), true);
    }
}
Also used : FragmentManager(androidx.fragment.app.FragmentManager) FragmentActivity(androidx.fragment.app.FragmentActivity)

Example 67 with FragmentActivity

use of androidx.fragment.app.FragmentActivity in project collect by opendatakit.

the class ServerPreferencesAdderTest method whenAPreferenceHasAnIncorrectType_returnsFalse_andShowsToastError.

@Test
public void whenAPreferenceHasAnIncorrectType_returnsFalse_andShowsToastError() {
    FragmentActivity activity = Robolectric.setupActivity(FragmentActivity.class);
    PreferenceFragmentCompat fragment = mock(PreferenceFragmentCompat.class);
    doThrow(ClassCastException.class).when(fragment).addPreferencesFromResource(R.xml.odk_server_preferences);
    when(fragment.getActivity()).thenReturn(activity);
    ServerPreferencesAdder loader = new ServerPreferencesAdder(fragment);
    boolean result = loader.add();
    assertFalse(result);
    String toastText = ShadowToast.getTextOfLatestToast();
    assertEquals(toastText, getString(R.string.corrupt_imported_preferences_error));
}
Also used : FragmentActivity(androidx.fragment.app.FragmentActivity) PreferenceFragmentCompat(androidx.preference.PreferenceFragmentCompat) Test(org.junit.Test)

Example 68 with FragmentActivity

use of androidx.fragment.app.FragmentActivity in project EhViewer by seven332.

the class SceneFragment method onDestroyView.

@Override
public void onDestroyView() {
    super.onDestroyView();
    // Notify
    FragmentActivity activity = getActivity();
    if (activity instanceof StageActivity) {
        ((StageActivity) activity).onSceneViewDestroyed(this);
    }
}
Also used : FragmentActivity(androidx.fragment.app.FragmentActivity)

Example 69 with FragmentActivity

use of androidx.fragment.app.FragmentActivity in project EhViewer by seven332.

the class SceneFragment method onDestroy.

@Override
public void onDestroy() {
    super.onDestroy();
    FragmentActivity activity = getActivity();
    if (activity instanceof StageActivity) {
        ((StageActivity) activity).onSceneDestroyed(this);
    }
}
Also used : FragmentActivity(androidx.fragment.app.FragmentActivity)

Example 70 with FragmentActivity

use of androidx.fragment.app.FragmentActivity in project iterable-android-sdk by Iterable.

the class IterableInAppHTMLNotificationTest method testDoNotCrashOnResizeAfterDismiss.

@Test
public void testDoNotCrashOnResizeAfterDismiss() {
    ActivityController<FragmentActivity> controller = Robolectric.buildActivity(FragmentActivity.class).create().start().resume();
    FragmentActivity activity = controller.get();
    IterableInAppDisplayer.showIterableFragmentNotificationHTML(activity, "", "", null, 0.0, new Rect(), true, new IterableInAppMessage.InAppBgColor(null, 0.0f), false, IterableInAppLocation.IN_APP);
    IterableInAppFragmentHTMLNotification notification = IterableInAppFragmentHTMLNotification.getInstance();
    notification.dismiss();
    notification.resize(500.0f);
}
Also used : FragmentActivity(androidx.fragment.app.FragmentActivity) Rect(android.graphics.Rect) Test(org.junit.Test)

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