Search in sources :

Example 1 with MainThread

use of androidx.annotation.MainThread in project Douya by DreaminginCodeZH.

the class ResourcesFlusher method flushLollipop.

@MainThread
@RequiresApi(Build.VERSION_CODES.LOLLIPOP)
private static void flushLollipop(@NonNull Resources resources) {
    if (!sDrawableCacheFieldInitialized) {
        try {
            // noinspection JavaReflectionMemberAccess
            sDrawableCacheField = Resources.class.getDeclaredField("mDrawableCache");
            sDrawableCacheField.setAccessible(true);
        } catch (NoSuchFieldException e) {
            e.printStackTrace();
        }
        sDrawableCacheFieldInitialized = true;
    }
    if (sDrawableCacheField == null) {
        return;
    }
    Map drawableCache = null;
    try {
        drawableCache = (Map) sDrawableCacheField.get(resources);
    } catch (IllegalAccessException e) {
        e.printStackTrace();
    }
    if (drawableCache == null) {
        return;
    }
    drawableCache.clear();
}
Also used : Resources(android.content.res.Resources) Map(java.util.Map) ArrayMap(android.util.ArrayMap) MainThread(androidx.annotation.MainThread) RequiresApi(androidx.annotation.RequiresApi)

Example 2 with MainThread

use of androidx.annotation.MainThread in project Signal-Android by WhisperSystems.

the class SearchToolbar method display.

@MainThread
public void display(float x, float y) {
    if (getVisibility() != View.VISIBLE) {
        this.x = x;
        this.y = y;
        searchItem.expandActionView();
        if (Build.VERSION.SDK_INT >= 21) {
            Animator animator = ViewAnimationUtils.createCircularReveal(this, (int) x, (int) y, 0, getWidth());
            animator.setDuration(400);
            setVisibility(View.VISIBLE);
            animator.start();
        } else {
            setVisibility(View.VISIBLE);
        }
    }
}
Also used : Animator(android.animation.Animator) MainThread(androidx.annotation.MainThread)

Example 3 with MainThread

use of androidx.annotation.MainThread in project Signal-Android by WhisperSystems.

the class SimpleProgressDialog method show.

@MainThread
@NonNull
public static AlertDialog show(@NonNull Context context) {
    AlertDialog dialog = new AlertDialog.Builder(context).setView(R.layout.progress_dialog).setCancelable(false).create();
    dialog.show();
    dialog.getWindow().setLayout(context.getResources().getDimensionPixelSize(R.dimen.progress_dialog_size), context.getResources().getDimensionPixelSize(R.dimen.progress_dialog_size));
    return dialog;
}
Also used : AlertDialog(androidx.appcompat.app.AlertDialog) MainThread(androidx.annotation.MainThread) NonNull(androidx.annotation.NonNull)

Example 4 with MainThread

use of androidx.annotation.MainThread in project Signal-Android by WhisperSystems.

the class VoiceNotePlaybackPreparer method applyDescriptionsToQueue.

@MainThread
private void applyDescriptionsToQueue(@NonNull List<MediaItem> mediaItems) {
    for (MediaItem mediaItem : mediaItems) {
        MediaItem.PlaybackProperties playbackProperties = mediaItem.playbackProperties;
        if (playbackProperties == null) {
            continue;
        }
        int holderIndex = indexOfPlayerMediaItemByUri(playbackProperties.uri);
        MediaItem next = VoiceNoteMediaItemFactory.buildNextVoiceNoteMediaItem(mediaItem);
        int currentIndex = player.getCurrentWindowIndex();
        if (holderIndex != -1) {
            if (currentIndex != holderIndex) {
                player.removeMediaItem(holderIndex);
                player.addMediaItem(holderIndex, mediaItem);
            }
            if (currentIndex != holderIndex + 1) {
                if (player.getMediaItemCount() > 1) {
                    player.removeMediaItem(holderIndex + 1);
                }
                player.addMediaItem(holderIndex + 1, next);
            }
        } else {
            int insertLocation = indexAfter(mediaItem);
            player.addMediaItem(insertLocation, next);
            player.addMediaItem(insertLocation, mediaItem);
        }
    }
    int itemsCount = player.getMediaItemCount();
    if (itemsCount > 0) {
        int lastIndex = itemsCount - 1;
        MediaItem last = player.getMediaItemAt(lastIndex);
        if (last.playbackProperties != null && Objects.equals(last.playbackProperties.uri, VoiceNoteMediaItemFactory.NEXT_URI)) {
            player.removeMediaItem(lastIndex);
            if (player.getMediaItemCount() > 1) {
                MediaItem end = VoiceNoteMediaItemFactory.buildEndVoiceNoteMediaItem(last);
                player.addMediaItem(lastIndex, end);
            }
        }
    }
}
Also used : MediaItem(com.google.android.exoplayer2.MediaItem) MainThread(androidx.annotation.MainThread)

Example 5 with MainThread

use of androidx.annotation.MainThread in project mobile-center-sdk-android by Microsoft.

the class DefaultChannel method sendLogs.

/**
 * Send logs.
 *
 * @param groupState   The group state.
 * @param currentState The current state.
 * @param batch        The log batch.
 * @param batchId      The batch ID.
 */
@MainThread
private void sendLogs(final GroupState groupState, final int currentState, List<Log> batch, final String batchId) {
    /* Send logs. */
    LogContainer logContainer = new LogContainer();
    logContainer.setLogs(batch);
    groupState.mIngestion.sendAsync(mAppSecret, mInstallId, logContainer, new ServiceCallback() {

        @Override
        public void onCallSucceeded(HttpResponse httpResponse) {
            mAppCenterHandler.post(new Runnable() {

                @Override
                public void run() {
                    handleSendingSuccess(groupState, batchId);
                }
            });
        }

        @Override
        public void onCallFailed(final Exception e) {
            mAppCenterHandler.post(new Runnable() {

                @Override
                public void run() {
                    handleSendingFailure(groupState, batchId, e);
                }
            });
        }
    });
    /* Check for more pending logs. */
    mAppCenterHandler.post(new Runnable() {

        @Override
        public void run() {
            checkPendingLogsAfterPost(groupState, currentState);
        }
    });
}
Also used : ServiceCallback(com.microsoft.appcenter.http.ServiceCallback) HttpResponse(com.microsoft.appcenter.http.HttpResponse) LogContainer(com.microsoft.appcenter.ingestion.models.LogContainer) IOException(java.io.IOException) CancellationException(com.microsoft.appcenter.CancellationException) MainThread(androidx.annotation.MainThread)

Aggregations

MainThread (androidx.annotation.MainThread)26 Animator (android.animation.Animator)4 IMedia (org.videolan.libvlc.interfaces.IMedia)3 Uri (android.net.Uri)2 ArrayMap (android.util.ArrayMap)2 AlphaAnimation (android.view.animation.AlphaAnimation)2 Animation (android.view.animation.Animation)2 AnimationSet (android.view.animation.AnimationSet)2 OvershootInterpolator (android.view.animation.OvershootInterpolator)2 TranslateAnimation (android.view.animation.TranslateAnimation)2 TextView (android.widget.TextView)2 NonNull (androidx.annotation.NonNull)2 RequiresApi (androidx.annotation.RequiresApi)2 AlertDialog (androidx.appcompat.app.AlertDialog)2 DefaultLifecycleObserver (androidx.lifecycle.DefaultLifecycleObserver)2 LifecycleOwner (androidx.lifecycle.LifecycleOwner)2 ProcessLifecycleOwner (androidx.lifecycle.ProcessLifecycleOwner)2 MediaItem (com.google.android.exoplayer2.MediaItem)2 AnimationCompleteListener (org.thoughtcrime.securesms.animation.AnimationCompleteListener)2 CallParticipant (org.thoughtcrime.securesms.events.CallParticipant)2