Search in sources :

Example 1 with Nullable

use of io.reactivex.rxjava3.annotations.Nullable in project Tusky by Vavassor.

the class NotificationsFragment method onCreateView.

@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_timeline_notifications, container, false);
    // from inflater to silence warning
    @NonNull Context context = inflater.getContext();
    SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getActivity());
    boolean showNotificationsFilterSetting = preferences.getBoolean("showNotificationsFilter", true);
    // Clear notifications on filter visibility change to force refresh
    if (showNotificationsFilterSetting != showNotificationsFilter)
        notifications.clear();
    showNotificationsFilter = showNotificationsFilterSetting;
    // Setup the SwipeRefreshLayout.
    swipeRefreshLayout = rootView.findViewById(R.id.swipeRefreshLayout);
    recyclerView = rootView.findViewById(R.id.recyclerView);
    progressBar = rootView.findViewById(R.id.progressBar);
    statusView = rootView.findViewById(R.id.statusView);
    appBarOptions = rootView.findViewById(R.id.appBarOptions);
    swipeRefreshLayout.setOnRefreshListener(this);
    swipeRefreshLayout.setColorSchemeResources(R.color.tusky_blue);
    loadNotificationsFilter();
    // Setup the RecyclerView.
    recyclerView.setHasFixedSize(true);
    layoutManager = new LinearLayoutManager(context);
    recyclerView.setLayoutManager(layoutManager);
    recyclerView.setAccessibilityDelegateCompat(new ListStatusAccessibilityDelegate(recyclerView, this, (pos) -> {
        NotificationViewData notification = notifications.getPairedItemOrNull(pos);
        // We support replies only for now
        if (notification instanceof NotificationViewData.Concrete) {
            return ((NotificationViewData.Concrete) notification).getStatusViewData();
        } else {
            return null;
        }
    }));
    recyclerView.addItemDecoration(new DividerItemDecoration(context, DividerItemDecoration.VERTICAL));
    StatusDisplayOptions statusDisplayOptions = new StatusDisplayOptions(preferences.getBoolean("animateGifAvatars", false), accountManager.getActiveAccount().getMediaPreviewEnabled(), preferences.getBoolean("absoluteTimeView", false), preferences.getBoolean("showBotOverlay", true), preferences.getBoolean("useBlurhash", true), CardViewMode.NONE, preferences.getBoolean("confirmReblogs", true), preferences.getBoolean("confirmFavourites", false), preferences.getBoolean(PrefKeys.WELLBEING_HIDE_STATS_POSTS, false), preferences.getBoolean(PrefKeys.ANIMATE_CUSTOM_EMOJIS, false));
    adapter = new NotificationsAdapter(accountManager.getActiveAccount().getAccountId(), dataSource, statusDisplayOptions, this, this, this);
    alwaysShowSensitiveMedia = accountManager.getActiveAccount().getAlwaysShowSensitiveMedia();
    alwaysOpenSpoiler = accountManager.getActiveAccount().getAlwaysOpenSpoiler();
    recyclerView.setAdapter(adapter);
    topLoading = false;
    bottomLoading = false;
    bottomId = null;
    updateAdapter();
    Button buttonClear = rootView.findViewById(R.id.buttonClear);
    buttonClear.setOnClickListener(v -> confirmClearNotifications());
    buttonFilter = rootView.findViewById(R.id.buttonFilter);
    buttonFilter.setOnClickListener(v -> showFilterMenu());
    if (notifications.isEmpty()) {
        swipeRefreshLayout.setEnabled(false);
        sendFetchNotificationsRequest(null, null, FetchEnd.BOTTOM, -1);
    } else {
        progressBar.setVisibility(View.GONE);
    }
    ((SimpleItemAnimator) recyclerView.getItemAnimator()).setSupportsChangeAnimations(false);
    updateFilterVisibility();
    return rootView;
}
Also used : Context(android.content.Context) DividerItemDecoration(androidx.recyclerview.widget.DividerItemDecoration) Bundle(android.os.Bundle) ProgressBar(android.widget.ProgressBar) NonNull(androidx.annotation.NonNull) AsyncDifferConfig(androidx.recyclerview.widget.AsyncDifferConfig) SimpleItemAnimator(androidx.recyclerview.widget.SimpleItemAnimator) Utils(at.connyduck.sparkbutton.helpers.Utils) AccountActionListener(com.keylesspalace.tusky.interfaces.AccountActionListener) NotificationTypeConverterKt(com.keylesspalace.tusky.util.NotificationTypeConverterKt) AppBarLayout(com.google.android.material.appbar.AppBarLayout) BackgroundMessageView(com.keylesspalace.tusky.view.BackgroundMessageView) Locale(java.util.Locale) FloatingActionButton(com.google.android.material.floatingactionbutton.FloatingActionButton) ActionButtonActivity(com.keylesspalace.tusky.interfaces.ActionButtonActivity) View(android.view.View) Button(android.widget.Button) RecyclerView(androidx.recyclerview.widget.RecyclerView) Function(androidx.arch.core.util.Function) Log(android.util.Log) ViewDataUtils(com.keylesspalace.tusky.util.ViewDataUtils) StatusViewData(com.keylesspalace.tusky.viewdata.StatusViewData) CoordinatorLayout(androidx.coordinatorlayout.widget.CoordinatorLayout) ListUpdateCallback(androidx.recyclerview.widget.ListUpdateCallback) DiffUtil(androidx.recyclerview.widget.DiffUtil) PreferenceChangedEvent(com.keylesspalace.tusky.appstore.PreferenceChangedEvent) StatusActionListener(com.keylesspalace.tusky.interfaces.StatusActionListener) Set(java.util.Set) Function1(kotlin.jvm.functions.Function1) Relationship(com.keylesspalace.tusky.entity.Relationship) ViewGroup(android.view.ViewGroup) ReselectableFragment(com.keylesspalace.tusky.interfaces.ReselectableFragment) Objects(java.util.Objects) FavoriteEvent(com.keylesspalace.tusky.appstore.FavoriteEvent) StatusDisplayOptions(com.keylesspalace.tusky.util.StatusDisplayOptions) AndroidSchedulers(io.reactivex.rxjava3.android.schedulers.AndroidSchedulers) List(java.util.List) Unit(kotlin.Unit) AutoDispose.autoDisposable(autodispose2.AutoDispose.autoDisposable) Nullable(androidx.annotation.Nullable) Pair(androidx.core.util.Pair) Disposable(io.reactivex.rxjava3.disposables.Disposable) CollectionsKt(kotlin.collections.CollectionsKt) AsyncListDiffer(androidx.recyclerview.widget.AsyncListDiffer) ListView(android.widget.ListView) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) StringUtils.isLessThan(com.keylesspalace.tusky.util.StringUtils.isLessThan) AccountEntity(com.keylesspalace.tusky.db.AccountEntity) Context(android.content.Context) BookmarkEvent(com.keylesspalace.tusky.appstore.BookmarkEvent) Notification(com.keylesspalace.tusky.entity.Notification) Single(io.reactivex.rxjava3.core.Single) AlertDialog(androidx.appcompat.app.AlertDialog) Status(com.keylesspalace.tusky.entity.Status) AndroidLifecycleScopeProvider.from(autodispose2.androidx.lifecycle.AndroidLifecycleScopeProvider.from) ReblogEvent(com.keylesspalace.tusky.appstore.ReblogEvent) Poll(com.keylesspalace.tusky.entity.Poll) NotificationViewData(com.keylesspalace.tusky.viewdata.NotificationViewData) PairedList(com.keylesspalace.tusky.util.PairedList) ArrayList(java.util.ArrayList) StatusBaseViewHolder(com.keylesspalace.tusky.adapter.StatusBaseViewHolder) PrefKeys(com.keylesspalace.tusky.settings.PrefKeys) HashSet(java.util.HashSet) Inject(javax.inject.Inject) Lifecycle(androidx.lifecycle.Lifecycle) CompositeDisposable(io.reactivex.rxjava3.disposables.CompositeDisposable) R(com.keylesspalace.tusky.R) CardViewMode(com.keylesspalace.tusky.util.CardViewMode) Observable(io.reactivex.rxjava3.core.Observable) AttachmentViewData(com.keylesspalace.tusky.viewdata.AttachmentViewData) DialogInterface(android.content.DialogInterface) ListStatusAccessibilityDelegate(com.keylesspalace.tusky.util.ListStatusAccessibilityDelegate) EventHub(com.keylesspalace.tusky.appstore.EventHub) BlockEvent(com.keylesspalace.tusky.appstore.BlockEvent) Iterator(java.util.Iterator) LayoutInflater(android.view.LayoutInflater) SwipeRefreshLayout(androidx.swiperefreshlayout.widget.SwipeRefreshLayout) PopupWindow(android.widget.PopupWindow) HttpHeaderLink(com.keylesspalace.tusky.util.HttpHeaderLink) Either(com.keylesspalace.tusky.util.Either) IOException(java.io.IOException) TimeUnit(java.util.concurrent.TimeUnit) ArrayAdapter(android.widget.ArrayAdapter) SparseBooleanArray(android.util.SparseBooleanArray) PinEvent(com.keylesspalace.tusky.appstore.PinEvent) SharedPreferences(android.content.SharedPreferences) NotificationsAdapter(com.keylesspalace.tusky.adapter.NotificationsAdapter) PreferenceManager(androidx.preference.PreferenceManager) ListUtils(com.keylesspalace.tusky.util.ListUtils) AccountManager(com.keylesspalace.tusky.db.AccountManager) EndlessOnScrollListener(com.keylesspalace.tusky.view.EndlessOnScrollListener) Injectable(com.keylesspalace.tusky.di.Injectable) Activity(android.app.Activity) Collections(java.util.Collections) SimpleItemAnimator(androidx.recyclerview.widget.SimpleItemAnimator) SharedPreferences(android.content.SharedPreferences) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) DividerItemDecoration(androidx.recyclerview.widget.DividerItemDecoration) BackgroundMessageView(com.keylesspalace.tusky.view.BackgroundMessageView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) ListView(android.widget.ListView) StatusDisplayOptions(com.keylesspalace.tusky.util.StatusDisplayOptions) NotificationsAdapter(com.keylesspalace.tusky.adapter.NotificationsAdapter) ListStatusAccessibilityDelegate(com.keylesspalace.tusky.util.ListStatusAccessibilityDelegate) FloatingActionButton(com.google.android.material.floatingactionbutton.FloatingActionButton) Button(android.widget.Button) NonNull(androidx.annotation.NonNull) NotificationViewData(com.keylesspalace.tusky.viewdata.NotificationViewData) Nullable(androidx.annotation.Nullable)

Example 2 with Nullable

use of io.reactivex.rxjava3.annotations.Nullable in project Signal-Android by WhisperSystems.

the class BaseRegistrationLockFragment method onViewCreated.

@Override
@CallSuper
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    setDebugLogSubmitMultiTapView(view.findViewById(R.id.kbs_lock_pin_title));
    pinEntry = view.findViewById(R.id.kbs_lock_pin_input);
    pinButton = view.findViewById(R.id.kbs_lock_pin_confirm);
    errorLabel = view.findViewById(R.id.kbs_lock_pin_input_label);
    keyboardToggle = view.findViewById(R.id.kbs_lock_keyboard_toggle);
    forgotPin = view.findViewById(R.id.kbs_lock_forgot_pin);
    RegistrationLockFragmentArgs args = RegistrationLockFragmentArgs.fromBundle(requireArguments());
    timeRemaining = args.getTimeRemaining();
    forgotPin.setVisibility(View.GONE);
    forgotPin.setOnClickListener(v -> handleForgottenPin(timeRemaining));
    pinEntry.setImeOptions(EditorInfo.IME_ACTION_DONE);
    pinEntry.setOnEditorActionListener((v, actionId, event) -> {
        if (actionId == EditorInfo.IME_ACTION_DONE) {
            ViewUtil.hideKeyboard(requireContext(), v);
            handlePinEntry();
            return true;
        }
        return false;
    });
    enableAndFocusPinEntry();
    pinButton.setOnClickListener((v) -> {
        ViewUtil.hideKeyboard(requireContext(), pinEntry);
        handlePinEntry();
    });
    keyboardToggle.setOnClickListener((v) -> {
        PinKeyboardType keyboardType = getPinEntryKeyboardType();
        updateKeyboard(keyboardType.getOther());
        keyboardToggle.setText(resolveKeyboardToggleText(keyboardType));
    });
    PinKeyboardType keyboardType = getPinEntryKeyboardType().getOther();
    keyboardToggle.setText(resolveKeyboardToggleText(keyboardType));
    disposables.bindTo(getViewLifecycleOwner().getLifecycle());
    viewModel = getViewModel();
    viewModel.getLockedTimeRemaining().observe(getViewLifecycleOwner(), t -> timeRemaining = t);
    TokenData keyBackupCurrentToken = viewModel.getKeyBackupCurrentToken();
    if (keyBackupCurrentToken != null) {
        int triesRemaining = keyBackupCurrentToken.getTriesRemaining();
        if (triesRemaining <= 3) {
            int daysRemaining = getLockoutDays(timeRemaining);
            new MaterialAlertDialogBuilder(requireContext()).setTitle(R.string.RegistrationLockFragment__not_many_tries_left).setMessage(getTriesRemainingDialogMessage(triesRemaining, daysRemaining)).setPositiveButton(android.R.string.ok, null).setNeutralButton(R.string.PinRestoreEntryFragment_contact_support, (dialog, which) -> sendEmailToSupport()).show();
        }
        if (triesRemaining < 5) {
            errorLabel.setText(requireContext().getResources().getQuantityString(R.plurals.RegistrationLockFragment__d_attempts_remaining, triesRemaining, triesRemaining));
        }
    }
}
Also used : CircularProgressButtonUtil.setSpinning(org.thoughtcrime.securesms.util.CircularProgressButtonUtil.setSpinning) Bundle(android.os.Bundle) NonNull(androidx.annotation.NonNull) LifecycleDisposable(org.thoughtcrime.securesms.util.LifecycleDisposable) MaterialAlertDialogBuilder(com.google.android.material.dialog.MaterialAlertDialogBuilder) ViewUtil(org.thoughtcrime.securesms.util.ViewUtil) R(org.thoughtcrime.securesms.R) Toast(android.widget.Toast) View(android.view.View) ServiceUtil(org.thoughtcrime.securesms.util.ServiceUtil) CircularProgressButton(com.dd.CircularProgressButton) CircularProgressButtonUtil.cancelSpinning(org.thoughtcrime.securesms.util.CircularProgressButtonUtil.cancelSpinning) PinKeyboardType(org.thoughtcrime.securesms.lock.v2.PinKeyboardType) RegistrationViewDelegate.setDebugLogSubmitMultiTapView(org.thoughtcrime.securesms.registration.fragments.RegistrationViewDelegate.setDebugLogSubmitMultiTapView) InputType(android.text.InputType) BaseRegistrationViewModel(org.thoughtcrime.securesms.registration.viewmodel.BaseRegistrationViewModel) CallSuper(androidx.annotation.CallSuper) TokenData(org.thoughtcrime.securesms.pin.TokenData) TimeUnit(java.util.concurrent.TimeUnit) Log(org.signal.core.util.logging.Log) AndroidSchedulers(io.reactivex.rxjava3.android.schedulers.AndroidSchedulers) StringRes(androidx.annotation.StringRes) TextView(android.widget.TextView) Nullable(androidx.annotation.Nullable) Disposable(io.reactivex.rxjava3.disposables.Disposable) LoggingFragment(org.thoughtcrime.securesms.LoggingFragment) EditorInfo(android.view.inputmethod.EditorInfo) EditText(android.widget.EditText) Resources(android.content.res.Resources) PinKeyboardType(org.thoughtcrime.securesms.lock.v2.PinKeyboardType) TokenData(org.thoughtcrime.securesms.pin.TokenData) MaterialAlertDialogBuilder(com.google.android.material.dialog.MaterialAlertDialogBuilder) CallSuper(androidx.annotation.CallSuper)

Example 3 with Nullable

use of io.reactivex.rxjava3.annotations.Nullable in project RxJava by ReactiveX.

the class FlowableObserveOnTest method asycFusedPollThrows.

@Test
public void asycFusedPollThrows() {
    new Flowable<Integer>() {

        @Override
        protected void subscribeActual(Subscriber<? super Integer> subscriber) {
            subscriber.onSubscribe(new BooleanSubscription());
            @SuppressWarnings("unchecked") BaseObserveOnSubscriber<Integer> oo = (BaseObserveOnSubscriber<Integer>) subscriber;
            oo.sourceMode = QueueFuseable.ASYNC;
            oo.requested.lazySet(1);
            oo.queue = new SimpleQueue<Integer>() {

                @Override
                public boolean offer(Integer value) {
                    return false;
                }

                @Override
                public boolean offer(Integer v1, Integer v2) {
                    return false;
                }

                @Nullable
                @Override
                public Integer poll() throws Exception {
                    throw new TestException();
                }

                @Override
                public boolean isEmpty() {
                    return false;
                }

                @Override
                public void clear() {
                }
            };
            oo.clear();
            oo.trySchedule();
        }
    }.observeOn(Schedulers.single()).test(0L).awaitDone(5, TimeUnit.SECONDS).assertFailure(TestException.class);
}
Also used : BaseObserveOnSubscriber(io.reactivex.rxjava3.internal.operators.flowable.FlowableObserveOn.BaseObserveOnSubscriber) BooleanSubscription(io.reactivex.rxjava3.internal.subscriptions.BooleanSubscription) BaseObserveOnSubscriber(io.reactivex.rxjava3.internal.operators.flowable.FlowableObserveOn.BaseObserveOnSubscriber) Nullable(io.reactivex.rxjava3.annotations.Nullable) Test(org.junit.Test)

Example 4 with Nullable

use of io.reactivex.rxjava3.annotations.Nullable in project fdroidclient by f-droid.

the class InstalledAppProviderService method getPathToInstalledApk.

@Nullable
public static File getPathToInstalledApk(PackageInfo packageInfo) {
    File apk = new File(packageInfo.applicationInfo.publicSourceDir);
    if (apk.isDirectory()) {
        FilenameFilter filter = (dir, name) -> name.endsWith(".apk");
        File[] files = apk.listFiles(filter);
        if (files == null) {
            String msg = packageInfo.packageName + " sourceDir has no APKs: " + apk.getAbsolutePath();
            Utils.debugLog(TAG, msg);
            ACRA.getErrorReporter().handleException(new IllegalArgumentException(msg), false);
            return null;
        }
        apk = files[0];
    }
    return apk;
}
Also used : Context(android.content.Context) PrivilegedInstaller(org.fdroid.fdroid.installer.PrivilegedInstaller) FilenameFilter(java.io.FilenameFilter) PackageManager(android.content.pm.PackageManager) NonNull(androidx.annotation.NonNull) Uri(android.net.Uri) Intent(android.content.Intent) RemoteException(android.os.RemoteException) PackageInfo(android.content.pm.PackageInfo) IBinder(android.os.IBinder) Process(android.os.Process) Utils(org.fdroid.fdroid.Utils) TreeSet(java.util.TreeSet) Schedulers(io.reactivex.rxjava3.schedulers.Schedulers) ACRA(org.acra.ACRA) InstalledAppTable(org.fdroid.fdroid.data.Schema.InstalledAppTable) JobIntentService(androidx.core.app.JobIntentService) CompositeDisposable(io.reactivex.rxjava3.disposables.CompositeDisposable) Map(java.util.Map) PublishSubject(io.reactivex.rxjava3.subjects.PublishSubject) ServiceConnection(android.content.ServiceConnection) Build(android.os.Build) Log(android.util.Log) ComponentName(android.content.ComponentName) IPrivilegedService(org.fdroid.fdroid.privileged.IPrivilegedService) AppUpdateStatusManager(org.fdroid.fdroid.AppUpdateStatusManager) File(java.io.File) TimeUnit(java.util.concurrent.TimeUnit) List(java.util.List) Nullable(androidx.annotation.Nullable) ContentValues(android.content.ContentValues) Comparator(java.util.Comparator) FilenameFilter(java.io.FilenameFilter) File(java.io.File) Nullable(androidx.annotation.Nullable)

Example 5 with Nullable

use of io.reactivex.rxjava3.annotations.Nullable in project RxJava by ReactiveX.

the class FlowableObserveOnTest method nonFusedPollThrows.

@Test
public void nonFusedPollThrows() {
    new Flowable<Integer>() {

        @Override
        protected void subscribeActual(Subscriber<? super Integer> subscriber) {
            subscriber.onSubscribe(new BooleanSubscription());
            @SuppressWarnings("unchecked") BaseObserveOnSubscriber<Integer> oo = (BaseObserveOnSubscriber<Integer>) subscriber;
            oo.sourceMode = QueueFuseable.SYNC;
            oo.requested.lazySet(1);
            oo.queue = new SimpleQueue<Integer>() {

                @Override
                public boolean offer(Integer value) {
                    return false;
                }

                @Override
                public boolean offer(Integer v1, Integer v2) {
                    return false;
                }

                @Nullable
                @Override
                public Integer poll() throws Exception {
                    throw new TestException();
                }

                @Override
                public boolean isEmpty() {
                    return false;
                }

                @Override
                public void clear() {
                }
            };
            oo.clear();
            oo.trySchedule();
        }
    }.observeOn(Schedulers.single()).test(0L).awaitDone(5, TimeUnit.SECONDS).assertFailure(TestException.class);
}
Also used : BaseObserveOnSubscriber(io.reactivex.rxjava3.internal.operators.flowable.FlowableObserveOn.BaseObserveOnSubscriber) BooleanSubscription(io.reactivex.rxjava3.internal.subscriptions.BooleanSubscription) BaseObserveOnSubscriber(io.reactivex.rxjava3.internal.operators.flowable.FlowableObserveOn.BaseObserveOnSubscriber) Nullable(io.reactivex.rxjava3.annotations.Nullable) Test(org.junit.Test)

Aggregations

NonNull (androidx.annotation.NonNull)4 Nullable (androidx.annotation.Nullable)4 TimeUnit (java.util.concurrent.TimeUnit)4 Bundle (android.os.Bundle)3 View (android.view.View)3 AndroidSchedulers (io.reactivex.rxjava3.android.schedulers.AndroidSchedulers)3 Disposable (io.reactivex.rxjava3.disposables.Disposable)3 Context (android.content.Context)2 Resources (android.content.res.Resources)2 InputType (android.text.InputType)2 Log (android.util.Log)2 EditorInfo (android.view.inputmethod.EditorInfo)2 EditText (android.widget.EditText)2 TextView (android.widget.TextView)2 Toast (android.widget.Toast)2 CallSuper (androidx.annotation.CallSuper)2 CompositeDisposable (io.reactivex.rxjava3.disposables.CompositeDisposable)2 List (java.util.List)2 Activity (android.app.Activity)1 ComponentName (android.content.ComponentName)1