Search in sources :

Example 21 with FragmentActivity

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

the class UserReviewListResource method attachTo.

public static UserReviewListResource attachTo(String userIdOrUid, Fragment fragment, String tag, int requestCode) {
    FragmentActivity activity = fragment.getActivity();
    UserReviewListResource instance = FragmentUtils.findByTag(activity, tag);
    if (instance == null) {
        instance = newInstance(userIdOrUid);
        FragmentUtils.add(instance, activity, tag);
    }
    instance.setTarget(fragment, requestCode);
    return instance;
}
Also used : FragmentActivity(androidx.fragment.app.FragmentActivity)

Example 22 with FragmentActivity

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

the class ItemReviewListResource method attachTo.

public static ItemReviewListResource attachTo(CollectableItem.Type itemType, long itemId, Fragment fragment, String tag, int requestCode) {
    FragmentActivity activity = fragment.getActivity();
    ItemReviewListResource instance = FragmentUtils.findByTag(activity, tag);
    if (instance == null) {
        instance = newInstance(itemType, itemId);
        FragmentUtils.add(instance, activity, tag);
    }
    instance.setTarget(fragment, requestCode);
    return instance;
}
Also used : FragmentActivity(androidx.fragment.app.FragmentActivity)

Example 23 with FragmentActivity

use of androidx.fragment.app.FragmentActivity in project Gadgetbridge by Freeyourgadget.

the class LiveActivityFragment method startActivityPulse.

private ScheduledExecutorService startActivityPulse() {
    ScheduledExecutorService service = Executors.newSingleThreadScheduledExecutor();
    service.scheduleAtFixedRate(new Runnable() {

        @Override
        public void run() {
            FragmentActivity activity = LiveActivityFragment.this.getActivity();
            if (activity != null && !activity.isFinishing() && !activity.isDestroyed()) {
                activity.runOnUiThread(new Runnable() {

                    @Override
                    public void run() {
                        pulse();
                    }
                });
            }
        }
    }, 0, getPulseIntervalMillis(), TimeUnit.MILLISECONDS);
    return service;
}
Also used : FragmentActivity(androidx.fragment.app.FragmentActivity) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService)

Example 24 with FragmentActivity

use of androidx.fragment.app.FragmentActivity in project Signal-Android by WhisperSystems.

the class StoragePreferenceFragment method onCreate.

@Override
public void onCreate(@Nullable Bundle paramBundle) {
    super.onCreate(paramBundle);
    findPreference("pref_storage_clear_message_history").setOnPreferenceClickListener(new ClearMessageHistoryClickListener());
    trimLength = findPreference(SettingsValues.THREAD_TRIM_LENGTH);
    trimLength.setOnPreferenceClickListener(p -> {
        updateToolbarTitle(R.string.preferences__conversation_length_limit);
        pushFragment(BaseSettingsFragment.create(new ConversationLengthLimitConfiguration()));
        return true;
    });
    keepMessages = findPreference(SettingsValues.KEEP_MESSAGES_DURATION);
    keepMessages.setOnPreferenceClickListener(p -> {
        updateToolbarTitle(R.string.preferences__keep_messages);
        pushFragment(BaseSettingsFragment.create(new KeepMessagesConfiguration()));
        return true;
    });
    StoragePreferenceCategory storageCategory = (StoragePreferenceCategory) findPreference("pref_storage_category");
    FragmentActivity activity = requireActivity();
    ApplicationPreferencesViewModel viewModel = ApplicationPreferencesViewModel.getApplicationPreferencesViewModel(activity);
    storageCategory.setOnFreeUpSpace(() -> activity.startActivity(MediaOverviewActivity.forAll(activity)));
    viewModel.getStorageBreakdown().observe(activity, storageCategory::setStorage);
}
Also used : FragmentActivity(androidx.fragment.app.FragmentActivity) StoragePreferenceCategory(org.thoughtcrime.securesms.preferences.widgets.StoragePreferenceCategory)

Example 25 with FragmentActivity

use of androidx.fragment.app.FragmentActivity in project Signal-Android by WhisperSystems.

the class RegistrationCompleteFragment method onViewCreated.

@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    FragmentActivity activity = requireActivity();
    RegistrationViewModel viewModel = new ViewModelProvider(activity).get(RegistrationViewModel.class);
    if (SignalStore.storageService().needsAccountRestore()) {
        Log.i(TAG, "Performing pin restore");
        activity.startActivity(new Intent(activity, PinRestoreActivity.class));
    } else if (!viewModel.isReregister()) {
        boolean needsProfile = Recipient.self().getProfileName().isEmpty() || !AvatarHelper.hasAvatar(activity, Recipient.self().getId());
        boolean needsPin = !SignalStore.kbsValues().hasPin();
        Log.i(TAG, "Pin restore flow not required." + " profile name: " + Recipient.self().getProfileName().isEmpty() + " profile avatar: " + !AvatarHelper.hasAvatar(activity, Recipient.self().getId()) + " needsPin:" + needsPin);
        Intent startIntent = MainActivity.clearTop(activity);
        if (needsPin) {
            startIntent = chainIntents(CreateKbsPinActivity.getIntentForPinCreate(requireContext()), startIntent);
        }
        if (needsProfile) {
            startIntent = chainIntents(EditProfileActivity.getIntentForUserProfile(activity), startIntent);
        }
        if (!needsProfile && !needsPin) {
            ApplicationDependencies.getJobManager().startChain(new ProfileUploadJob()).then(Arrays.asList(new MultiDeviceProfileKeyUpdateJob(), new MultiDeviceProfileContentUpdateJob())).enqueue();
            RegistrationUtil.maybeMarkRegistrationComplete(requireContext());
        }
        activity.startActivity(startIntent);
    }
    activity.finish();
    ActivityNavigator.applyPopAnimationsToPendingTransition(activity);
}
Also used : FragmentActivity(androidx.fragment.app.FragmentActivity) Intent(android.content.Intent) MultiDeviceProfileKeyUpdateJob(org.thoughtcrime.securesms.jobs.MultiDeviceProfileKeyUpdateJob) ProfileUploadJob(org.thoughtcrime.securesms.jobs.ProfileUploadJob) MultiDeviceProfileContentUpdateJob(org.thoughtcrime.securesms.jobs.MultiDeviceProfileContentUpdateJob) RegistrationViewModel(org.thoughtcrime.securesms.registration.viewmodel.RegistrationViewModel) ViewModelProvider(androidx.lifecycle.ViewModelProvider) PinRestoreActivity(org.thoughtcrime.securesms.pin.PinRestoreActivity)

Aggregations

FragmentActivity (androidx.fragment.app.FragmentActivity)181 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 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)8 Resources (android.content.res.Resources)7 Fragment (androidx.fragment.app.Fragment)7 FragmentManager (androidx.fragment.app.FragmentManager)7 Activity (android.app.Activity)6 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