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();
}
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);
}
}
}
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;
}
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);
}
}
}
}
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);
}
});
}
Aggregations