androidx.annotation.AnyThread Java Examples
The following examples show how to use
androidx.annotation.AnyThread.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AsyncEpoxyDiffer.java From epoxy with Apache License 2.0 | 6 votes |
/** * Marks the generation as done, and updates the list if the generation is the most recent. * * @return True if the given generation is the most recent, in which case the given list was * set. False if the generation is old and the list was ignored. */ @AnyThread private synchronized boolean tryLatchList(@Nullable List<? extends EpoxyModel<?>> newList, int runGeneration) { if (generationTracker.finishGeneration(runGeneration)) { list = newList; if (newList == null) { readOnlyList = Collections.emptyList(); } else { readOnlyList = Collections.unmodifiableList(newList); } return true; } return false; }
Example #2
Source File: LiveRecipientCache.java From mollyim-android with GNU General Public License v3.0 | 6 votes |
@AnyThread synchronized @NonNull LiveRecipient getLive(@NonNull RecipientId id) { if (id.isUnknown()) return unknown; LiveRecipient live = recipients.get(id); if (live == null) { final LiveRecipient newLive = new LiveRecipient(context, new MutableLiveData<>(), new Recipient(id)); recipients.put(id, newLive); MissingRecipientException prettyStackTraceError = new MissingRecipientException(newLive.getId()); SignalExecutors.BOUNDED.execute(() -> { try { newLive.resolve(); } catch (MissingRecipientException e) { throw prettyStackTraceError; } }); live = newLive; } return live; }
Example #3
Source File: AuthStateManager.java From AppAuth-Android with Apache License 2.0 | 6 votes |
@AnyThread @NonNull private AuthState readState() { mPrefsLock.lock(); try { String currentState = mPrefs.getString(KEY_STATE, null); if (currentState == null) { return new AuthState(); } try { return AuthState.jsonDeserialize(currentState); } catch (JSONException ex) { Log.w(TAG, "Failed to deserialize stored auth state - discarding"); return new AuthState(); } } finally { mPrefsLock.unlock(); } }
Example #4
Source File: AuthStateManager.java From AppAuth-Android with Apache License 2.0 | 6 votes |
@AnyThread private void writeState(@Nullable AuthState state) { mPrefsLock.lock(); try { SharedPreferences.Editor editor = mPrefs.edit(); if (state == null) { editor.remove(KEY_STATE); } else { editor.putString(KEY_STATE, state.jsonSerializeString()); } if (!editor.commit()) { throw new IllegalStateException("Failed to write state to shared prefs"); } } finally { mPrefsLock.unlock(); } }
Example #5
Source File: DeferredReleaserConcurrentImpl.java From fresco with MIT License | 6 votes |
@AnyThread @Override public void scheduleDeferredRelease(Releasable releasable) { if (!isOnUiThread()) { releasable.release(); return; } boolean shouldSchedule; synchronized (mLock) { if (mPendingReleasables.contains(releasable)) { return; } mPendingReleasables.add(releasable); shouldSchedule = mPendingReleasables.size() == 1; } // Posting to the UI queue is an O(n) operation, so we only do it once. // The one runnable does all the releases. if (shouldSchedule) { mUiHandler.post(releaseRunnable); } }
Example #6
Source File: SubsamplingScaleImageView.java From PdfViewPager with Apache License 2.0 | 6 votes |
@SuppressWarnings("SuspiciousNameCombination") @AnyThread private void fileSRect(Rect sRect, Rect target) { if (getRequiredRotation() == 0) { target.set(sRect); } else if (getRequiredRotation() == 90) { target.set(sRect.top, sHeight - sRect.right, sRect.bottom, sHeight - sRect.left); } else if (getRequiredRotation() == 180) { target.set( sWidth - sRect.right, sHeight - sRect.bottom, sWidth - sRect.left, sHeight - sRect.top); } else { target.set(sWidth - sRect.bottom, sRect.left, sWidth - sRect.top, sRect.right); } }
Example #7
Source File: AuthStateManager.java From Android-Example with Apache License 2.0 | 6 votes |
@AnyThread @NonNull private AuthState readState() { mPrefsLock.lock(); try { String currentState = mPrefs.getString(KEY_STATE, null); if (currentState == null) { return new AuthState(); } try { return AuthState.jsonDeserialize(currentState); } catch (JSONException ex) { Log.w(TAG, "Failed to deserialize stored auth state - discarding"); return new AuthState(); } } finally { mPrefsLock.unlock(); } }
Example #8
Source File: AuthStateManager.java From Android-Example with Apache License 2.0 | 6 votes |
@AnyThread private void writeState(@Nullable AuthState state) { mPrefsLock.lock(); try { SharedPreferences.Editor editor = mPrefs.edit(); if (state == null) { editor.remove(KEY_STATE); } else { editor.putString(KEY_STATE, state.jsonSerializeString()); } if (!editor.commit()) { throw new IllegalStateException("Failed to write state to shared prefs"); } } finally { mPrefsLock.unlock(); } }
Example #9
Source File: AuthStateManager.java From Android-Example with Apache License 2.0 | 5 votes |
@AnyThread @NonNull public AuthState updateAfterRegistration( RegistrationResponse response, AuthorizationException ex) { AuthState current = getCurrent(); if (ex != null) { return current; } current.update(response); return replace(current); }
Example #10
Source File: AuthStateManager.java From AppAuth-Android with Apache License 2.0 | 5 votes |
@AnyThread public static AuthStateManager getInstance(@NonNull Context context) { AuthStateManager manager = INSTANCE_REF.get().get(); if (manager == null) { manager = new AuthStateManager(context.getApplicationContext()); INSTANCE_REF.set(new WeakReference<>(manager)); } return manager; }
Example #11
Source File: AsyncEpoxyDiffer.java From epoxy with Apache License 2.0 | 5 votes |
/** * Set the current list without performing any diffing. Cancels any diff in progress. * <p> * This can be used if you notified a change to the adapter manually and need this list to be * synced. */ @AnyThread public synchronized boolean forceListOverride(@Nullable List<EpoxyModel<?>> newList) { // We need to make sure that generation changes and list updates are synchronized final boolean interruptedDiff = cancelDiff(); int generation = generationTracker.incrementAndGetNextScheduled(); tryLatchList(newList, generation); return interruptedDiff; }
Example #12
Source File: AuthStateManager.java From AppAuth-Android with Apache License 2.0 | 5 votes |
@AnyThread @NonNull public AuthState replace(@NonNull AuthState state) { writeState(state); mCurrentAuthState.set(state); return state; }
Example #13
Source File: AuthStateManager.java From AppAuth-Android with Apache License 2.0 | 5 votes |
@AnyThread @NonNull public AuthState updateAfterAuthorization( @Nullable AuthorizationResponse response, @Nullable AuthorizationException ex) { AuthState current = getCurrent(); current.update(response, ex); return replace(current); }
Example #14
Source File: AuthStateManager.java From AppAuth-Android with Apache License 2.0 | 5 votes |
@AnyThread @NonNull public AuthState updateAfterTokenResponse( @Nullable TokenResponse response, @Nullable AuthorizationException ex) { AuthState current = getCurrent(); current.update(response, ex); return replace(current); }
Example #15
Source File: ConversationAdapter.java From mollyim-android with GNU General Public License v3.0 | 5 votes |
/** * Marks a record as no-longer-needed. Will be removed from the adapter the next time the database * changes. */ @AnyThread void releaseFastRecord(long id) { synchronized (releasedFastRecords) { releasedFastRecords.add(id); } }
Example #16
Source File: AuthStateManager.java From Android-Example with Apache License 2.0 | 5 votes |
@AnyThread @NonNull public AuthState replace(@NonNull AuthState state) { writeState(state); mCurrentAuthState.set(state); return state; }
Example #17
Source File: SubsamplingScaleImageView.java From EasyPhotos with Apache License 2.0 | 5 votes |
/** * Converts source rectangle from tile, which treats the image file as if it were in the correct orientation already, * to the rectangle of the image that needs to be loaded. */ @SuppressWarnings("SuspiciousNameCombination") @AnyThread private void fileSRect(Rect sRect, Rect target) { if (getRequiredRotation() == 0) { target.set(sRect); } else if (getRequiredRotation() == 90) { target.set(sRect.top, sHeight - sRect.right, sRect.bottom, sHeight - sRect.left); } else if (getRequiredRotation() == 180) { target.set(sWidth - sRect.right, sHeight - sRect.bottom, sWidth - sRect.left, sHeight - sRect.top); } else { target.set(sWidth - sRect.bottom, sRect.left, sWidth - sRect.top, sRect.right); } }
Example #18
Source File: AuthStateManager.java From Android-Example with Apache License 2.0 | 5 votes |
@AnyThread @NonNull public AuthState updateAfterTokenResponse( @Nullable TokenResponse response, @Nullable AuthorizationException ex) { AuthState current = getCurrent(); current.update(response, ex); return replace(current); }
Example #19
Source File: AuthStateManager.java From Android-Example with Apache License 2.0 | 5 votes |
@AnyThread @NonNull public AuthState getCurrent() { if (mCurrentAuthState.get() != null) { return mCurrentAuthState.get(); } AuthState state = readState(); if (mCurrentAuthState.compareAndSet(null, state)) { return state; } else { return mCurrentAuthState.get(); } }
Example #20
Source File: AuthStateManager.java From AppAuth-Android with Apache License 2.0 | 5 votes |
@AnyThread @NonNull public AuthState getCurrent() { if (mCurrentAuthState.get() != null) { return mCurrentAuthState.get(); } AuthState state = readState(); if (mCurrentAuthState.compareAndSet(null, state)) { return state; } else { return mCurrentAuthState.get(); } }
Example #21
Source File: SubsamplingScaleImageView.java From PictureSelector with Apache License 2.0 | 5 votes |
/** * Debug logger */ @AnyThread private void debug(String message, Object... args) { if (debug) { Log.d(TAG, String.format(message, args)); } }
Example #22
Source File: AuthStateManager.java From Android-Example with Apache License 2.0 | 5 votes |
@AnyThread public static AuthStateManager getInstance(@NonNull Context context) { AuthStateManager manager = INSTANCE_REF.get().get(); if (manager == null) { manager = new AuthStateManager(context.getApplicationContext()); INSTANCE_REF.set(new WeakReference<>(manager)); } return manager; }
Example #23
Source File: AuthStateManager.java From Android-Example with Apache License 2.0 | 5 votes |
@AnyThread @NonNull public AuthState updateAfterAuthorization( @Nullable AuthorizationResponse response, @Nullable AuthorizationException ex) { AuthState current = getCurrent(); current.update(response, ex); return replace(current); }
Example #24
Source File: ViewportManager.java From litho with Apache License 2.0 | 5 votes |
@AnyThread void removeViewportChangedListener(@Nullable ViewportChanged viewportChangedListener) { if (viewportChangedListener == null) { return; } synchronized (this) { if (mViewportChangedListeners.isEmpty()) { return; } mViewportChangedListeners.remove(viewportChangedListener); } }
Example #25
Source File: ViewportManager.java From litho with Apache License 2.0 | 5 votes |
@AnyThread void addViewportChangedListener(@Nullable ViewportChanged viewportChangedListener) { if (viewportChangedListener == null) { return; } synchronized (this) { mViewportChangedListeners.add(viewportChangedListener); } }
Example #26
Source File: AuthStateManager.java From AppAuth-Android with Apache License 2.0 | 5 votes |
@AnyThread @NonNull public AuthState updateAfterRegistration( RegistrationResponse response, AuthorizationException ex) { AuthState current = getCurrent(); if (ex != null) { return current; } current.update(response); return replace(current); }
Example #27
Source File: SubsamplingScaleImageView.java From Matisse-Kotlin with Apache License 2.0 | 5 votes |
/** * Debug logger */ @AnyThread private void debug(String message, Object... args) { if (debug) { Log.d(TAG, String.format(message, args)); } }
Example #28
Source File: SubsamplingScaleImageView.java From Matisse-Kotlin with Apache License 2.0 | 5 votes |
/** * Determines the rotation to be applied to tiles, based on EXIF orientation or chosen setting. */ @AnyThread private int getRequiredRotation() { if (orientation == ORIENTATION_USE_EXIF) { return sOrientation; } else { return orientation; } }
Example #29
Source File: SubsamplingScaleImageView.java From Matisse-Kotlin with Apache License 2.0 | 5 votes |
/** * Converts source rectangle from tile, which treats the image file as if it were in the correct orientation already, * to the rectangle of the image that needs to be loaded. */ @SuppressWarnings("SuspiciousNameCombination") @AnyThread private void fileSRect(Rect sRect, Rect target) { if (getRequiredRotation() == 0) { target.set(sRect); } else if (getRequiredRotation() == 90) { target.set(sRect.top, sHeight - sRect.right, sRect.bottom, sHeight - sRect.left); } else if (getRequiredRotation() == 180) { target.set(sWidth - sRect.right, sHeight - sRect.bottom, sWidth - sRect.left, sHeight - sRect.top); } else { target.set(sWidth - sRect.bottom, sRect.left, sWidth - sRect.top, sRect.right); } }
Example #30
Source File: NavUtil.java From EdXposedManager with GNU General Public License v3.0 | 5 votes |
@AnyThread public static void showMessage(final @NonNull Context context, final CharSequence message) { XposedApp.runOnUiThread(() -> new MaterialDialog.Builder(context) .content(message) .positiveText(R.string.ok) .show()); }