List of usage examples for android.os Looper getMainLooper
public static Looper getMainLooper()
From source file:com.digium.respokesdk.RespokeClient.java
private void didReceiveMessage(final RespokeEndpoint endpoint, final String message, final Date timestamp) { new Handler(Looper.getMainLooper()).post(new Runnable() { @Override//from ww w .ja v a 2 s . c o m public void run() { if (null != listenerReference) { Listener listener = listenerReference.get(); if (null != listener) { listener.onMessage(message, endpoint, null, timestamp, false); } } } }); }
From source file:com.digium.respokesdk.RespokeClient.java
private void didSendMessage(final RespokeEndpoint endpoint, final String message, final Date timestamp) { new Handler(Looper.getMainLooper()).post(new Runnable() { @Override// w ww . j a v a 2 s . com public void run() { if (null != listenerReference) { Listener listener = listenerReference.get(); if (null != listener) { listener.onMessage(message, endpoint, null, timestamp, true); } } } }); }
From source file:com.digium.respokesdk.RespokeClient.java
public void onGroupMessage(final String message, String groupID, String endpointID, RespokeSignalingChannel sender, final Date timestamp) { final RespokeGroup group = groups.get(groupID); if (null != group) { final RespokeEndpoint endpoint = getEndpoint(endpointID, false); // Notify the group of the new message group.didReceiveMessage(message, endpoint, timestamp); // Notify the client listener of the group message new Handler(Looper.getMainLooper()).post(new Runnable() { @Override//w ww .ja va 2 s .com public void run() { if (null != listenerReference) { Listener listener = listenerReference.get(); if (null != listener) { listener.onMessage(message, endpoint, group, timestamp, null); } } } }); } }
From source file:com.codename1.impl.android.AndroidImplementation.java
public void deinitialize() { //activity.getWindowManager().removeView(relativeLayout); super.deinitialize(); if (getActivity() != null) { Runnable r = new Runnable() { public void run() { synchronized (AndroidImplementation.this) { if (!deinitializing) { return; }/*from w ww .j a v a2s . c o m*/ deinitializing = false; } if (nativePeers.size() > 0) { for (int i = 0; i < nativePeers.size(); i++) { ((AndroidImplementation.AndroidPeer) nativePeers.elementAt(i)).deinit(); } } if (relativeLayout != null) { relativeLayout.removeAllViews(); } relativeLayout = null; myView = null; } }; if (Looper.getMainLooper().getThread() == Thread.currentThread()) { deinitializing = true; r.run(); } else { deinitializing = true; getActivity().runOnUiThread(r); } } else { deinitializing = false; } }
From source file:com.digium.respokesdk.RespokeClient.java
public void directConnectionAvailable(final RespokeDirectConnection directConnection, final RespokeEndpoint endpoint) { new Handler(Looper.getMainLooper()).post(new Runnable() { @Override// w w w . ja va 2 s .c o m public void run() { if (null != listenerReference) { Listener listener = listenerReference.get(); if (null != listener) { listener.onIncomingDirectConnection(directConnection, endpoint); } } } }); }
From source file:com.dycody.android.idealnote.ListFragment.java
/** * Merges all the selected notes/*from ww w . jav a 2 s. co m*/ */ public void onEventAsync(NotesMergeEvent notesMergeEvent) { final Note finalMergedNote = NotesHelper.mergeNotes(getSelectedNotes(), notesMergeEvent.keepMergedNotes); new Handler(Looper.getMainLooper()).post(() -> { if (!notesMergeEvent.keepMergedNotes) { ArrayList<String> notesIds = new ArrayList<>(); for (Note selectedNote : getSelectedNotes()) { notesIds.add(String.valueOf(selectedNote.get_id())); } mainActivity.getIntent().putExtra("merged_notes", notesIds); } getSelectedNotes().clear(); if (getActionMode() != null) { getActionMode().finish(); } mainActivity.getIntent().setAction(Constants.ACTION_MERGE); mainActivity.switchToDetail(finalMergedNote); }); }
From source file:com.android.mail.utils.NotificationUtils.java
private static ContactIconInfo getContactIcon(final Context context, String accountName, final String displayName, final String senderAddress, final Folder folder, final ContactFetcher contactFetcher) { if (Looper.myLooper() == Looper.getMainLooper()) { throw new IllegalStateException("getContactIcon should not be called on the main thread."); }/*from w w w .java2s .co m*/ final ContactIconInfo contactIconInfo; if (TextUtils.isEmpty(senderAddress)) { contactIconInfo = new ContactIconInfo(); } else { // Get the ideal size for this icon. final Resources res = context.getResources(); final int idealIconHeight = res.getDimensionPixelSize(android.R.dimen.notification_large_icon_height); final int idealIconWidth = res.getDimensionPixelSize(android.R.dimen.notification_large_icon_width); final int idealWearableBgWidth = res.getDimensionPixelSize(R.dimen.wearable_background_width); final int idealWearableBgHeight = res.getDimensionPixelSize(R.dimen.wearable_background_height); if (contactFetcher != null) { contactIconInfo = contactFetcher.getContactPhoto(context, accountName, senderAddress, idealIconWidth, idealIconHeight, idealWearableBgWidth, idealWearableBgHeight); } else { contactIconInfo = getContactInfo(context, senderAddress, idealIconWidth, idealIconHeight, idealWearableBgWidth, idealWearableBgHeight); } if (contactIconInfo.icon == null) { // Make a colorful tile! final Dimensions dimensions = new Dimensions(idealIconWidth, idealIconHeight, Dimensions.SCALE_ONE); contactIconInfo.icon = new LetterTileProvider(context.getResources()).getLetterTile(dimensions, displayName, senderAddress); } // Only turn the square photo/letter tile into a circle for L and later if (Utils.isRunningLOrLater()) { contactIconInfo.icon = BitmapUtil.frameBitmapInCircle(contactIconInfo.icon); } } if (contactIconInfo.icon == null) { // Use anonymous icon due to lack of sender contactIconInfo.icon = getIcon(context, R.drawable.ic_notification_anonymous_avatar_32dp); } if (contactIconInfo.wearableBg == null) { contactIconInfo.wearableBg = getDefaultWearableBg(context); } return contactIconInfo; }
From source file:com.miz.functions.MizLib.java
public static String getTmdbImageBaseUrl(Context context) { long time = PreferenceManager.getDefaultSharedPreferences(context).getLong(TMDB_BASE_URL_TIME, 0); long currentTime = System.currentTimeMillis(); // We store the TMDb base URL for 24 hours if (((currentTime - time) < DAY && PreferenceManager.getDefaultSharedPreferences(context).contains(TMDB_BASE_URL)) | Looper.getMainLooper().getThread() == Thread.currentThread()) { return PreferenceManager.getDefaultSharedPreferences(context).getString(TMDB_BASE_URL, ""); }//from w ww . j av a2s . c om try { JSONObject configuration = getJSONObject(context, "https://api.themoviedb.org/3/configuration?api_key=" + getTmdbApiKey(context)); String baseUrl = configuration.getJSONObject("images").getString("secure_base_url"); Editor editor = PreferenceManager.getDefaultSharedPreferences(context).edit(); editor.putString(TMDB_BASE_URL, baseUrl); editor.putLong(TMDB_BASE_URL_TIME, System.currentTimeMillis()); editor.commit(); return baseUrl; } catch (JSONException e) { return null; } }
From source file:com.codename1.impl.android.AndroidImplementation.java
public boolean isJSDispatchThread() { if (useJSDispatchThread()) { return jsDispatchThread().isThisIt(); } else {//from w ww.j ava 2 s. c o m return (Looper.getMainLooper().getThread() == Thread.currentThread()); } }