@UiThread
private void onLoadMessageFromDatabaseFinished() {
if (callback == null) {
throw new IllegalStateException("unexpected call when callback is already detached");
}
callback.onMessageDataLoadFinished(localMessage);
boolean messageIncomplete =
!localMessage.isSet(Flag.X_DOWNLOADED_FULL) && !localMessage.isSet(Flag.X_DOWNLOADED_PARTIAL);
if (messageIncomplete) {
startDownloadingMessageBody(false);
return;
}
if (QMail.isOpenPgpProviderConfigured()) {
startOrResumeCryptoOperation();
return;
}
startOrResumeDecodeMessage();
}
java类android.support.annotation.UiThread的实例源码
MessageLoaderHelper.java 文件源码
项目:q-mail
阅读 36
收藏 0
点赞 0
评论 0
Utils.java 文件源码
项目:GitHub
阅读 36
收藏 0
点赞 0
评论 0
@UiThread // Implicit synchronization for use of shared resource VALUE.
public static Drawable getTintedDrawable(Context context,
@DrawableRes int id, @AttrRes int tintAttrId) {
boolean attributeFound = context.getTheme().resolveAttribute(tintAttrId, VALUE, true);
if (!attributeFound) {
throw new Resources.NotFoundException("Required tint color attribute with name "
+ context.getResources().getResourceEntryName(tintAttrId)
+ " and attribute ID "
+ tintAttrId
+ " was not found.");
}
Drawable drawable = ContextCompat.getDrawable(context, id);
drawable = DrawableCompat.wrap(drawable.mutate());
int color = ContextCompat.getColor(context, VALUE.resourceId);
DrawableCompat.setTint(drawable, color);
return drawable;
}
GamePlayActivity.java 文件源码
项目:play-billing-codelab
阅读 34
收藏 0
点赞 0
评论 0
/**
* Show an alert dialog to the user
* @param messageId String id to display inside the alert dialog
* @param optionalParam Optional attribute for the string
*/
@UiThread
void alert(@StringRes int messageId, @Nullable Object optionalParam) {
if (Looper.getMainLooper().getThread() != Thread.currentThread()) {
throw new RuntimeException("Dialog could be shown only from the main thread");
}
AlertDialog.Builder bld = new AlertDialog.Builder(this);
bld.setNeutralButton("OK", null);
if (optionalParam == null) {
bld.setMessage(messageId);
} else {
bld.setMessage(getResources().getString(messageId, optionalParam));
}
bld.create().show();
}
Pager.java 文件源码
项目:Elements
阅读 35
收藏 0
点赞 0
评论 0
@UiThread
/* package */ Page openPage(int number, boolean clearContent) {
log("openPage: called for position "+number+" clearing "+clearContent);
int objectsBefore = 0;
for (int i = 0; i < number; i++) {
objectsBefore += pages.get(i).getElementsCount();
}
if (number >= pages.size()) {
// Need to create a new one.
currentPage = new Page(number, objectsBefore);
pages.add(number, currentPage);
} else if (clearContent) {
// We want an already present, but with cleared content.
clearPage(number);
currentPage = new Page(number, objectsBefore);
pages.set(number, currentPage);
} else {
// We just want the current page. it'll be erased as soon as stuff comes.
currentPage = pages.get(number);
}
return currentPage;
}
ChromeStrictMode.java 文件源码
项目:chromium-for-android-56-debug-video
阅读 44
收藏 0
点赞 0
评论 0
/**
* Always process the violation on the UI thread. This ensures other crash reports are not
* corrupted. Since each individual user has a very small chance of uploading each violation,
* and we have a hard cap of 3 per session, this will not affect performance too much.
*
* @param violationInfo The violation info from the StrictMode violation in question.
*/
@UiThread
private static void reportStrictModeViolation(Object violationInfo) {
try {
Field crashInfoField = violationInfo.getClass().getField("crashInfo");
ApplicationErrorReport.CrashInfo crashInfo =
(ApplicationErrorReport.CrashInfo) crashInfoField.get(violationInfo);
String stackTrace = crashInfo.stackTrace;
if (stackTrace == null) {
Log.d(TAG, "StrictMode violation stack trace was null.");
} else {
Log.d(TAG, "Upload stack trace: " + stackTrace);
JavaExceptionReporter.reportStackTrace(stackTrace);
}
} catch (Exception e) {
// Ignore all exceptions.
Log.d(TAG, "Could not handle observed StrictMode violation.", e);
}
}
NativeApiObject.java 文件源码
项目:android-api
阅读 43
收藏 0
点赞 0
评论 0
@UiThread
protected void destroyNativeHandle(Callable<Integer> destroyHandleCallable) {
new NativeHandleFuture(destroyHandleCallable)
.then(new Ready<Integer>() {
@Override
public void ready(Integer result) {
if (m_nativeHandle == null)
throw new RuntimeException();
if (!m_tasks.isEmpty())
throw new RuntimeException();
m_nativeHandle = null;
}
});
}
AnimHelper.java 文件源码
项目:mvvm-template
阅读 41
收藏 0
点赞 0
评论 0
@UiThread public static void dismissDialog(@NonNull DialogFragment dialogFragment, int duration, AnimatorListenerAdapter listenerAdapter) {
Dialog dialog = dialogFragment.getDialog();
if (dialog != null) {
if (dialog.getWindow() != null) {
View view = dialog.getWindow().getDecorView();
if (view != null) {
int centerX = view.getWidth() / 2;
int centerY = view.getHeight() / 2;
float radius = (float) Math.sqrt(view.getWidth() * view.getWidth() / 4 + view.getHeight() * view.getHeight() / 4);
view.post(() -> {
if (ViewCompat.isAttachedToWindow(view)) {
Animator animator = ViewAnimationUtils.createCircularReveal(view, centerX, centerY, radius, 0);
animator.setDuration(duration);
animator.addListener(listenerAdapter);
animator.start();
} else {
listenerAdapter.onAnimationEnd(null);
}
});
}
}
} else {
listenerAdapter.onAnimationEnd(null);
}
}
EegeoNativeMapView.java 文件源码
项目:android-api
阅读 32
收藏 0
点赞 0
评论 0
@UiThread
public void surfaceCreated(final SurfaceHolder holder) {
runOnNativeThread(new Runnable() {
@WorkerThread
@Override
public void run() {
m_surfaceHolder = holder;
Surface surface = m_surfaceHolder.getSurface();
if (surface.isValid()) {
nativeSetSurface(m_jniApiRunnerPtr, surface);
notifySurfaceCreated();
}
}
});
}
EegeoMap.java 文件源码
项目:android-api
阅读 30
收藏 0
点赞 0
评论 0
/**
* Stops any running camera animation.
*/
@UiThread
public void stopAnimation() {
m_nativeRunner.runOnNativeThread(new Runnable() {
@Override
public void run() {
CameraApiJniCalls.tryStopTransition(m_eegeoMapApiPtr);
}
});
}
BlueSphere.java 文件源码
项目:android-api
阅读 32
收藏 0
点赞 0
评论 0
@UiThread
private void updateIndoors() {
final String indoorMap = m_indoorMapId;
final int floorId = m_indoorFloorId;
submit(new Runnable() {
@WorkerThread
public void run() {
m_bluesphereApi.setIndoorMap(BlueSphere.m_allowHandleAccess, indoorMap, floorId);
}
});
}
ScreenFilterMonitorImpl.java 文件源码
项目:Nird2
阅读 45
收藏 0
点赞 0
评论 0
@Override
@UiThread
public Set<String> getApps() {
if (!serviceStarted) {
apps.addAll(getInstalledScreenFilterApps());
}
TreeSet<String> buf = new TreeSet<>();
if (apps.isEmpty()) {
return buf;
}
buf.addAll(apps);
buf.removeAll(shownApps);
return buf;
}
CameraView.java 文件源码
项目:Nird2
阅读 41
收藏 0
点赞 0
评论 0
@UiThread
private void surfaceCreatedUi(SurfaceHolder holder) {
LOG.info("Surface created");
if (surface != null && surface != holder.getSurface()) {
LOG.info("Releasing old surface");
surface.release();
}
surface = holder.getSurface();
// Start the preview when the camera and the surface are both ready
if (camera != null && !previewStarted) startPreview(holder);
}
MvpNullObjectBasePresenter.java 文件源码
项目:Watermark
阅读 37
收藏 0
点赞 0
评论 0
@UiThread
@NonNull protected V getView() {
if (!viewAttachedAtLeastOnce){
throw new IllegalStateException("No view has ever been attached to this presenter!");
}
if (view != null) {
V realView = view.get();
if (realView != null) {
return realView;
}
}
return nullView;
}
Utils.java 文件源码
项目:GitHub
阅读 46
收藏 0
点赞 0
评论 0
@UiThread // Implicit synchronization for use of shared resource VALUE.
public static float getFloat(Context context, @DimenRes int id) {
TypedValue value = VALUE;
context.getResources().getValue(id, value, true);
if (value.type == TypedValue.TYPE_FLOAT) {
return value.getFloat();
}
throw new Resources.NotFoundException("Resource ID #0x" + Integer.toHexString(id)
+ " type #0x" + Integer.toHexString(value.type) + " is not valid");
}
Pager.java 文件源码
项目:Elements
阅读 39
收藏 0
点赞 0
评论 0
/**
* Remove the specified element from this page, if present.
* @param element element to be removed
*/
@UiThread
public void removeElement(Element element) {
int position = this.elements.indexOf(element);
if (position != -1) {
removeElement(position);
}
}
Polygon.java 文件源码
项目:android-api
阅读 34
收藏 0
点赞 0
评论 0
@UiThread
private void updateNativeStyleAttributes() {
final int fillColorARGB = m_fillColorARGB;
submit(new Runnable() {
@WorkerThread
public void run() {
m_polygonApi.setStyleAttributes(
getNativeHandle(),
Polygon.m_allowHandleAccess,
fillColorARGB);
}
});
}
HomeActivity.java 文件源码
项目:pokequest
阅读 41
收藏 0
点赞 0
评论 0
@UiThread
private void onLoadPokemonError() {
new AlertDialog.Builder(this)
.setTitle(R.string.loading_error)
.setMessage(R.string.loading_pokemon_list_error_msg)
.setPositiveButton(R.string.retry, (dialog, which) -> loadPokemons())
.setNegativeButton(R.string.cancel, null)
.setIcon(android.R.drawable.ic_dialog_alert)
.show();
}
RTLRowTest.java 文件源码
项目:ChipsLayoutManager
阅读 30
收藏 0
点赞 0
评论 0
@UiThread
@Override
protected ChipsLayoutManager getLayoutManager() {
ChipsLayoutManager layoutManager = super.getLayoutManager();
if (activityTestRule.getActivity() != null) {
View recyclerView = activityTestRule.getActivity().findViewById(R.id.rvTest);
ViewCompat.setLayoutDirection(recyclerView, ViewCompat.LAYOUT_DIRECTION_RTL);
}
return layoutManager;
}
MvpBasePresenter.java 文件源码
项目:FriendBook
阅读 34
收藏 0
点赞 0
评论 0
@UiThread
@Override
public void destroy() {
if (isViewAttached()) {
detachView();
}
}
AndroidNotificationManagerImpl.java 文件源码
项目:Nird2
阅读 36
收藏 0
点赞 0
评论 0
@UiThread
private void clearGroupMessageNotification() {
groupCounts.clear();
groupTotal = 0;
Object o = appContext.getSystemService(NOTIFICATION_SERVICE);
NotificationManager nm = (NotificationManager) o;
nm.cancel(GROUP_MESSAGE_NOTIFICATION_ID);
}
AndroidNotificationManagerImpl.java 文件源码
项目:Nird2
阅读 39
收藏 0
点赞 0
评论 0
@UiThread
private void clearForumPostNotification() {
forumCounts.clear();
forumTotal = 0;
Object o = appContext.getSystemService(NOTIFICATION_SERVICE);
NotificationManager nm = (NotificationManager) o;
nm.cancel(FORUM_POST_NOTIFICATION_ID);
}
ScreenFilterMonitorImpl.java 文件源码
项目:Nird2
阅读 46
收藏 0
点赞 0
评论 0
@Override
@UiThread
public Set<String> getApps() {
if (!serviceStarted) {
apps.addAll(getInstalledScreenFilterApps());
}
TreeSet<String> buf = new TreeSet<>();
if (apps.isEmpty()) {
return buf;
}
buf.addAll(apps);
buf.removeAll(shownApps);
return buf;
}
GenericMultipleLayoutAdapter.java 文件源码
项目:gmlrva
阅读 30
收藏 0
点赞 0
评论 0
/**
* Procedure meant to remove a list of Generic Layout Implementation items on this adapter's data set.
* @param items the list of Generic Layout Implementation items to be removed.
* See {@link IGenericRecyclerViewLayout} for more information.
*/
@UiThread
public void remove(@NonNull final List<IGenericRecyclerViewLayout> items) {
final List<IGenericRecyclerViewLayout> newList
= new ArrayList<>(mPendingUpdates.isEmpty() ? mDataSet : mPendingUpdates.peekLast());
if (!newList.isEmpty() && !items.isEmpty()) {
newList.removeAll(items);
updateList(newList);
}
}
CameraView.java 文件源码
项目:Nird2
阅读 45
收藏 0
点赞 0
评论 0
@UiThread
private void startPreview(SurfaceHolder holder) {
LOG.info("Starting preview");
try {
camera.setPreviewDisplay(holder);
camera.startPreview();
previewStarted = true;
startConsumer();
} catch (IOException | RuntimeException e) {
LOG.log(WARNING, "Error starting camera preview", e);
}
}
RouteView.java 文件源码
项目:android-api
阅读 32
收藏 0
点赞 0
评论 0
/**
* Sets the width of this RouteView's polylines.
*
* @param width The width of the polyline in screen pixels.
*/
@UiThread
public void setWidth(float width) {
m_width = width;
for (Polyline polyline: m_polylines) {
polyline.setWidth(m_width);
}
}
Polygon.java 文件源码
项目:android-api
阅读 36
收藏 0
点赞 0
评论 0
/**
* This constructor is for internal SDK use only -- use EegeoMap.addPolygon to create a polygon
*
* @eegeo.internal
*/
@UiThread
public Polygon(@NonNull final PolygonApi polygonApi,
@NonNull final PolygonOptions polygonOptions) {
super(polygonApi.getNativeRunner(), polygonApi.getUiRunner(),
new Callable<Integer>() {
@WorkerThread
@Override
public Integer call() throws Exception {
return polygonApi.create(polygonOptions, m_allowHandleAccess);
}
});
m_polygonApi = polygonApi;
m_indoorMapId = polygonOptions.getIndoorMapId();
m_indoorFloorId = polygonOptions.getIndoorFloorId();
m_elevation = polygonOptions.getElevation();
m_elevationMode = polygonOptions.getElevationMode();
m_points = polygonOptions.getPoints();
m_holes = polygonOptions.getHoles();
m_fillColorARGB = polygonOptions.getFillColor();
submit(new Runnable() {
@WorkerThread
@Override
public void run() {
polygonApi.register(Polygon.this, m_allowHandleAccess);
}
});
}
CameraView.java 文件源码
项目:Nird2
阅读 47
收藏 0
点赞 0
评论 0
@UiThread
public void stop() {
if (camera == null) return;
stopPreview();
try {
LOG.info("Releasing camera");
camera.release();
} catch (RuntimeException e) {
LOG.log(WARNING, "Error releasing camera", e);
}
camera = null;
}
GamePlayActivity.java 文件源码
项目:play-billing-codelab
阅读 32
收藏 0
点赞 0
评论 0
/**
* Update UI to reflect model
*/
@UiThread
private void updateUi() {
Log.d(TAG, "Updating the UI. Thread: " + Thread.currentThread().getName());
// Update gas gauge to reflect tank status
mGasImageView.setImageResource(mViewController.getTankResId());
}
ShowQrCodeFragment.java 文件源码
项目:Nird2
阅读 35
收藏 0
点赞 0
评论 0
@UiThread
private void generateBitmapQR(final Payload payload) {
// Get narrowest screen dimension
Context context = getContext();
if (context == null) return;
final DisplayMetrics dm = context.getResources().getDisplayMetrics();
new AsyncTask<Void, Void, Bitmap>() {
@Override
protected Bitmap doInBackground(Void... params) {
byte[] encoded = payloadEncoder.encode(payload);
if (LOG.isLoggable(INFO))
LOG.info("Local payload is " + encoded.length + " bytes");
String input = Base64.encodeToString(encoded, 0);
return QrCodeUtils.createQrCode(dm, input);
}
@Override
protected void onPostExecute(@Nullable Bitmap bitmap) {
if (bitmap != null && !isDetached()) {
qrCode.setImageBitmap(bitmap);
// Simple fade-in animation
AlphaAnimation anim = new AlphaAnimation(0.0f, 1.0f);
anim.setDuration(200);
qrCode.startAnimation(anim);
}
}
}.execute();
}
GenericMultipleLayoutAdapter.java 文件源码
项目:gmlrva
阅读 28
收藏 0
点赞 0
评论 0
/**
* Procedure meant to insert a Generic Layout Implementation item on this adapter's data set.
* @param item a Generic Layout Implementation item to be inserted.
* See {@link IGenericRecyclerViewLayout} for more information.
*/
@UiThread
public void add(@NonNull final IGenericRecyclerViewLayout item) {
final List<IGenericRecyclerViewLayout> newList
= new ArrayList<>(mPendingUpdates.isEmpty() ? mDataSet : mPendingUpdates.peekLast());
newList.add(item);
updateList(newList);
}