/** * Asserts that code executes on the main thread. */ public static void assertBackgroundThread() { if (imp != null && DispatchQueue.isMainQueue()) { imp.assertFailed("Expected background thread but was 'main'"); } }
/** * Asserts that code executes on the main thread. */ public static void assertMainThread() { if (imp != null && !DispatchQueue.isMainQueue()) { imp.assertFailed(StringUtils.format("Expected 'main' thread but was '%s'", Thread.currentThread().getName())); } }
if (!DispatchQueue.isMainQueue()) { extra = new StringBuilder() .append('[')
public static void launchMessageCenterErrorActivity(final Context context) { if (!isMainQueue()) { mainQueue().dispatchAsync(new DispatchTask() { @Override protected void execute() { launchMessageCenterErrorActivity(context); } }); return; } if (context != null) { Intent intent = MessageCenterInteraction.generateMessageCenterErrorIntent(context); if (!(context instanceof Activity)) { intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_MULTIPLE_TASK); } context.startActivity(intent); } }
public static void showToast(final Context context, final String message, final int duration) { if (!DispatchQueue.isMainQueue()) { DispatchQueue.mainQueue().dispatchAsync(new DispatchTask() { @Override protected void execute() { showToast(context, message, duration); } }); return; } try { Toast.makeText(context, message, duration).show(); } catch (Exception e) { ApptentiveLog.e(e, "Exception while trying to display toast message"); logException(e); } }
if (!isMainQueue()) { mainQueue().dispatchAsync(new DispatchTask() { @Override