android.os.Handler.Callback Java Examples
The following examples show how to use
android.os.Handler.Callback.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: EpoxyAsyncUtil.java From epoxy with Apache License 2.0 | 6 votes |
/** * Create a Handler with the given Looper * * @param async If true the Handler will calls {@link Message#setAsynchronous(boolean)} for * each {@link Message} that is sent to it or {@link Runnable} that is posted to it. */ public static Handler createHandler(Looper looper, boolean async) { if (!async) { return new Handler(looper); } // Standard way of exposing async handler on older api's from the support library // https://android.googlesource.com/platform/frameworks/support/+/androidx-master-dev/core // /src/main/java/androidx/core/os/HandlerCompat.java#51 if (Build.VERSION.SDK_INT >= 28) { return Handler.createAsync(looper); } if (Build.VERSION.SDK_INT >= 16) { try { //noinspection JavaReflectionMemberAccess return Handler.class.getDeclaredConstructor(Looper.class, Callback.class, boolean.class) .newInstance(looper, null, true); } catch (Throwable ignored) { } } return new Handler(looper); }
Example #2
Source File: GlobalHandlerService.java From sms-ticket with Apache License 2.0 | 6 votes |
@Override public boolean handleMessage(Message msg) { // proces listeners for specified type of message what synchronized (mListenersSpecific) { List<BetterWeakReference<Callback>> whatListofListeners = mListenersSpecific.get(msg.what); if (whatListofListeners != null) { handleListeners(whatListofListeners, msg); if (whatListofListeners.size() == 0) { mListenersSpecific.remove(msg.what); } } } // process universal listeners handleListeners(mListenersUniversal, msg); return true; }
Example #3
Source File: OnekeyShareThemeImpl.java From HHComicViewer with Apache License 2.0 | 5 votes |
private void toast(final String resOrName) { UIHandler.sendEmptyMessage(0, new Callback() { public boolean handleMessage(Message msg) { int resId = R.getStringRes(context, resOrName); if (resId > 0) { Toast.makeText(context, resId, Toast.LENGTH_SHORT).show(); } else { Toast.makeText(context, resOrName, Toast.LENGTH_SHORT).show(); } return false; } }); }
Example #4
Source File: OnekeyShareThemeImpl.java From enjoyshop with Apache License 2.0 | 5 votes |
private void toast(final String resOrName) { UIHandler.sendEmptyMessage(0, new Callback() { public boolean handleMessage(Message msg) { int resId = ResHelper.getStringRes(context, resOrName); if (resId > 0) { Toast.makeText(context, resId, Toast.LENGTH_SHORT).show(); } else { Toast.makeText(context, resOrName, Toast.LENGTH_SHORT).show(); } return false; } }); }
Example #5
Source File: GlobalHandlerService.java From sms-ticket with Apache License 2.0 | 5 votes |
/** * Remove listener for all messages. * * @param listener The listener to remove. */ public synchronized void removeListener(Callback listener) { BetterWeakReference<Callback> r = new BetterWeakReference<Callback>(listener); if (mListenersUniversal.contains(r)) { mListenersUniversal.remove(r); } }
Example #6
Source File: GlobalHandlerService.java From sms-ticket with Apache License 2.0 | 5 votes |
private void handleListeners(List<BetterWeakReference<Callback>> whatListofListeners, Message msg) { synchronized (whatListofListeners) { for (BetterWeakReference<Callback> ComparableWeakReference : whatListofListeners) { if (ComparableWeakReference.get() != null) { ComparableWeakReference.get().handleMessage(msg); } else { whatListofListeners.remove(ComparableWeakReference); } } } }
Example #7
Source File: WXThread.java From ucar-weex-core with Apache License 2.0 | 5 votes |
public static Callback secure(Callback callback){ if(callback == null || callback instanceof SafeCallback){ return callback; } return new SafeCallback(callback); }
Example #8
Source File: OnekeyShareThemeImpl.java From YiZhi with Apache License 2.0 | 5 votes |
private void toast(final String resOrName) { UIHandler.sendEmptyMessage(0, new Callback() { public boolean handleMessage(Message msg) { int resId = ResHelper.getStringRes(context, resOrName); if (resId > 0) { Toast.makeText(context, resId, Toast.LENGTH_SHORT).show(); } else { Toast.makeText(context, resOrName, Toast.LENGTH_SHORT).show(); } return false; } }); }
Example #9
Source File: OnekeyShareThemeImpl.java From Social with Apache License 2.0 | 5 votes |
private void toast(final String resOrName) { UIHandler.sendEmptyMessage(0, new Callback() { public boolean handleMessage(Message msg) { int resId = R.getStringRes(context, resOrName); if (resId > 0) { Toast.makeText(context, resId, Toast.LENGTH_SHORT).show(); } else { Toast.makeText(context, resOrName, Toast.LENGTH_SHORT).show(); } return false; } }); }
Example #10
Source File: OnekeyShareThemeImpl.java From POCenter with MIT License | 5 votes |
private void toast(final String resOrName) { UIHandler.sendEmptyMessage(0, new Callback() { public boolean handleMessage(Message msg) { int resId = ResHelper.getStringRes(context, resOrName); if (resId > 0) { Toast.makeText(context, resId, Toast.LENGTH_SHORT).show(); } else { Toast.makeText(context, resOrName, Toast.LENGTH_SHORT).show(); } return false; } }); }
Example #11
Source File: FriendAdapter.java From POCenter with MIT License | 5 votes |
public void onCancel(Platform plat, int action) { UIHandler.sendEmptyMessage(0, new Callback() { public boolean handleMessage(Message msg) { activity.finish(); return false; } }); }
Example #12
Source File: AndroidConfig.java From darks-logs with Apache License 2.0 | 5 votes |
/** * Register crash handler. It can catch ANR error automatically and use * logger to output message. * * @param callback Call back object.When ANR error happened, it will use * callback to notify developers. If it's null, it won't call * back. */ public void registerCrashHandler(Callback callback) { if (application == null) { return; } AndroidCrashHandler.getInstance().setup(application, callback); }
Example #13
Source File: FriendAdapter.java From YiZhi with Apache License 2.0 | 5 votes |
public void onCancel(Platform plat, int action) { UIHandler.sendEmptyMessage(0, new Callback() { public boolean handleMessage(Message msg) { activity.finish(); return false; } }); }
Example #14
Source File: FriendAdapter.java From Mobike with Apache License 2.0 | 5 votes |
public void onCancel(Platform plat, int action) { UIHandler.sendEmptyMessage(0, new Callback() { public boolean handleMessage(Message msg) { activity.finish(); return false; } }); }
Example #15
Source File: OnekeyShareThemeImpl.java From Mobike with Apache License 2.0 | 5 votes |
private void toast(final String resOrName) { UIHandler.sendEmptyMessage(0, new Callback() { public boolean handleMessage(Message msg) { int resId = R.getStringRes(context, resOrName); if (resId > 0) { Toast.makeText(context, resId, Toast.LENGTH_SHORT).show(); } else { Toast.makeText(context, resOrName, Toast.LENGTH_SHORT).show(); } return false; } }); }
Example #16
Source File: FriendAdapter.java From LQRWeChat with MIT License | 5 votes |
public void onCancel(Platform plat, int action) { UIHandler.sendEmptyMessage(0, new Callback() { public boolean handleMessage(Message msg) { activity.finish(); return false; } }); }
Example #17
Source File: OnekeyShareThemeImpl.java From LQRWeChat with MIT License | 5 votes |
private void toast(final String resOrName) { UIHandler.sendEmptyMessage(0, new Callback() { public boolean handleMessage(Message msg) { int resId = ResHelper.getStringRes(context, resOrName); if (resId > 0) { Toast.makeText(context, resId, Toast.LENGTH_SHORT).show(); } else { Toast.makeText(context, resOrName, Toast.LENGTH_SHORT).show(); } return false; } }); }
Example #18
Source File: WXThread.java From weex-uikit with MIT License | 5 votes |
public static Callback secure(Callback callback){ if(callback == null || callback instanceof SafeCallback){ return callback; } return new SafeCallback(callback); }
Example #19
Source File: FriendAdapter.java From HHComicViewer with Apache License 2.0 | 5 votes |
public void onCancel(Platform plat, int action) { UIHandler.sendEmptyMessage(0, new Callback() { public boolean handleMessage(Message msg) { activity.finish(); return false; } }); }
Example #20
Source File: OnekeyShareThemeImpl.java From fingerpoetry-android with Apache License 2.0 | 5 votes |
private void toast(final String resOrName) { UIHandler.sendEmptyMessage(0, new Callback() { public boolean handleMessage(Message msg) { int resId = R.getStringRes(context, resOrName); if (resId > 0) { Toast.makeText(context, resId, Toast.LENGTH_SHORT).show(); } else { Toast.makeText(context, resOrName, Toast.LENGTH_SHORT).show(); } return false; } }); }
Example #21
Source File: FriendAdapter.java From fingerpoetry-android with Apache License 2.0 | 5 votes |
public void onCancel(Platform plat, int action) { UIHandler.sendEmptyMessage(0, new Callback() { public boolean handleMessage(Message msg) { activity.finish(); return false; } }); }
Example #22
Source File: OnekeyShareThemeImpl.java From BaoKanAndroid with MIT License | 5 votes |
private void toast(final String resOrName) { UIHandler.sendEmptyMessage(0, new Callback() { public boolean handleMessage(Message msg) { int resId = ResHelper.getStringRes(context, resOrName); if (resId > 0) { Toast.makeText(context, resId, Toast.LENGTH_SHORT).show(); } else { Toast.makeText(context, resOrName, Toast.LENGTH_SHORT).show(); } return false; } }); }
Example #23
Source File: UIHandler.java From BigApp_Discuz_Android with Apache License 2.0 | 5 votes |
private static void handleMessage(Message msg) { Object[] objs = (Object[]) msg.obj; Message inner = (Message) objs[0]; Callback callback = (Callback) objs[1]; if (callback != null) { callback.handleMessage(inner); } }
Example #24
Source File: OnekeyShareThemeImpl.java From GithubApp with Apache License 2.0 | 5 votes |
private void toast(final String resOrName) { UIHandler.sendEmptyMessage(0, new Callback() { public boolean handleMessage(Message msg) { int resId = R.getStringRes(context, resOrName); if (resId > 0) { Toast.makeText(context, resId, Toast.LENGTH_SHORT).show(); } else { Toast.makeText(context, resOrName, Toast.LENGTH_SHORT).show(); } return false; } }); }
Example #25
Source File: FriendAdapter.java From GithubApp with Apache License 2.0 | 5 votes |
public void onCancel(Platform plat, int action) { UIHandler.sendEmptyMessage(0, new Callback() { public boolean handleMessage(Message msg) { activity.finish(); return false; } }); }
Example #26
Source File: OnekeyShareThemeImpl.java From MyHearts with Apache License 2.0 | 5 votes |
private void toast(final String resOrName) { UIHandler.sendEmptyMessage(0, new Callback() { public boolean handleMessage(Message msg) { int resId = R.getStringRes(context, resOrName); if (resId > 0) { Toast.makeText(context, resId, Toast.LENGTH_SHORT).show(); } else { Toast.makeText(context, resOrName, Toast.LENGTH_SHORT).show(); } return false; } }); }
Example #27
Source File: FriendAdapter.java From MyHearts with Apache License 2.0 | 5 votes |
public void onCancel(Platform plat, int action) { UIHandler.sendEmptyMessage(0, new Callback() { public boolean handleMessage(Message msg) { activity.finish(); return false; } }); }
Example #28
Source File: UIHandler.java From BigApp_Discuz_Android with Apache License 2.0 | 5 votes |
private static void handleMessage(Message msg) { Object[] objs = (Object[]) msg.obj; Message inner = (Message) objs[0]; Callback callback = (Callback) objs[1]; if (callback != null) { callback.handleMessage(inner); } }
Example #29
Source File: UIHandler.java From BigApp_Discuz_Android with Apache License 2.0 | 5 votes |
private static Message getMessage(int msgWhat, Callback callback) { Message shell = new Message(); Message inner = new Message(); inner.what = msgWhat; shell.obj = new Object[]{inner, callback}; return shell; }
Example #30
Source File: UIHandler.java From BigApp_Discuz_Android with Apache License 2.0 | 5 votes |
/** * 发送消息 * * @param callback * @return */ public static boolean sendMessage(Callback callback, int arg1, int arg2, Object obj, int what, Bundle bundle) { Message message = Message.obtain(); message.arg1 = arg1; message.arg2 = arg2; message.obj = obj; message.what = what; message.setData(bundle); return handler.sendMessage(getShellMessage(message,callback)); }