本文整理匯總了Java中android.support.annotation.UiThread類的典型用法代碼示例。如果您正苦於以下問題:Java UiThread類的具體用法?Java UiThread怎麽用?Java UiThread使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
UiThread類屬於android.support.annotation包,在下文中一共展示了UiThread類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onLoadMessageFromDatabaseFinished
import android.support.annotation.UiThread; //導入依賴的package包/類
@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();
}
示例2: getTintedDrawable
import android.support.annotation.UiThread; //導入依賴的package包/類
@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;
}
示例3: alert
import android.support.annotation.UiThread; //導入依賴的package包/類
/**
* 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();
}
示例4: log
import android.support.annotation.UiThread; //導入依賴的package包/類
@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;
}
示例5: reportStrictModeViolation
import android.support.annotation.UiThread; //導入依賴的package包/類
/**
* 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);
}
}
示例6: destroyNativeHandle
import android.support.annotation.UiThread; //導入依賴的package包/類
@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;
}
});
}
示例7: dismissDialog
import android.support.annotation.UiThread; //導入依賴的package包/類
@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);
}
}
示例8: surfaceCreated
import android.support.annotation.UiThread; //導入依賴的package包/類
@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();
}
}
});
}
示例9: stopAnimation
import android.support.annotation.UiThread; //導入依賴的package包/類
/**
* Stops any running camera animation.
*/
@UiThread
public void stopAnimation() {
m_nativeRunner.runOnNativeThread(new Runnable() {
@Override
public void run() {
CameraApiJniCalls.tryStopTransition(m_eegeoMapApiPtr);
}
});
}
示例10: updateIndoors
import android.support.annotation.UiThread; //導入依賴的package包/類
@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);
}
});
}
示例11: getApps
import android.support.annotation.UiThread; //導入依賴的package包/類
@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;
}
示例12: surfaceCreatedUi
import android.support.annotation.UiThread; //導入依賴的package包/類
@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);
}
示例13: getView
import android.support.annotation.UiThread; //導入依賴的package包/類
@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;
}
示例14: getFloat
import android.support.annotation.UiThread; //導入依賴的package包/類
@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");
}
示例15: removeElement
import android.support.annotation.UiThread; //導入依賴的package包/類
/**
* 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);
}
}