本文整理汇总了Java中android.os.Handler.Callback方法的典型用法代码示例。如果您正苦于以下问题:Java Handler.Callback方法的具体用法?Java Handler.Callback怎么用?Java Handler.Callback使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.os.Handler
的用法示例。
在下文中一共展示了Handler.Callback方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handleMessage
import android.os.Handler; //导入方法依赖的package包/类
@Override
public void handleMessage(@NonNull Message msg) {
if (mCallback == null) {
return;
}
final Handler.Callback callback = mCallback.get();
if (callback == null) { // Already disposed
return;
}
callback.handleMessage(msg);
}
示例2: SnackbarManager
import android.os.Handler; //导入方法依赖的package包/类
private SnackbarManager() {
mLock = new Object();
mHandler = new Handler(Looper.getMainLooper(), new Handler.Callback() {
@Override
public boolean handleMessage(Message message) {
switch (message.what) {
case MSG_TIMEOUT:
handleTimeout((SnackbarRecord) message.obj);
return true;
}
return false;
}
});
}
示例3: getHCallback
import android.os.Handler; //导入方法依赖的package包/类
private static Handler.Callback getHCallback() {
try {
Handler handler = getH();
return mirror.android.os.Handler.mCallback.get(handler);
} catch (Throwable e) {
e.printStackTrace();
}
return null;
}
示例4: onCreate
import android.os.Handler; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_hybrid_test);
uiHandler = new Handler(new Handler.Callback() {
@Override
public boolean handleMessage(Message msg) {
if (msg.what == WHAT_NEED_AUTO_2_BOTTOM) {
needAuto2Bottom = true;
}
return false;
}
});
assignViews();
scrollView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_DOWN) {
uiHandler.removeMessages(WHAT_NEED_AUTO_2_BOTTOM);
needAuto2Bottom = false;
}
if (event.getAction() == MotionEvent.ACTION_UP ||
event.getAction() == MotionEvent.ACTION_CANCEL) {
uiHandler.removeMessages(WHAT_NEED_AUTO_2_BOTTOM);
uiHandler.sendEmptyMessageDelayed(WHAT_NEED_AUTO_2_BOTTOM, 1000);
}
return false;
}
});
}
示例5: BundleReleaser
import android.os.Handler; //导入方法依赖的package包/类
public BundleReleaser(final File reversionDir,boolean hasReleased) {
if(Boolean.FALSE.booleanValue()){
String.valueOf(PreVerifier.class);
}
this.hasReleased = hasReleased;
this.reversionDir = reversionDir;
if(!reversionDir.getAbsolutePath().startsWith(KernalConstants.baseContext.getFilesDir().getAbsolutePath())){
externalStorage = true;
}
if (!(Looper.getMainLooper() == Looper.myLooper())) {
if (Looper.myLooper() == null)
Looper.prepare();
}
handler = new Handler(new Handler.Callback() {
@Override
public boolean handleMessage(Message msg) {
try {
return handleMsg(msg);
} catch (IOException e) {
e.printStackTrace();
}
return false;
}
});
this.service = Executors.newFixedThreadPool(3);
}
示例6: isEnvBad
import android.os.Handler; //导入方法依赖的package包/类
@Override
public boolean isEnvBad() {
Handler.Callback callback = getHCallback();
boolean envBad = callback != this;
if (callback != null && envBad) {
VLog.d(TAG, "HCallback has bad, other callback = " + callback);
}
return envBad;
}
示例7: CookieSaver
import android.os.Handler; //导入方法依赖的package包/类
public CookieSaver() {
mHandler = new Handler(Looper.getMainLooper(), new Handler.Callback() {
@Override
public boolean handleMessage(Message msg) {
if (msg.what == MSG_PERSIST_COOKIES) {
persistCookies();
return true;
} else {
return false;
}
}
});
}
示例8: ExecHandler
import android.os.Handler; //导入方法依赖的package包/类
ExecHandler(WeakReference<Handler.Callback> callback) {
mCallback = callback;
}
示例9: onForceDownloadAlert
import android.os.Handler; //导入方法依赖的package包/类
@Override
public void onForceDownloadAlert(String url, DefaultMsgConfig.DownLoadMsgConfig message, Handler.Callback callback) {
getDelegate().onForceDownloadAlert(url, message, callback);
}
示例10: showChooser
import android.os.Handler; //导入方法依赖的package包/类
@Override
public void showChooser(WebView view, String url, final String[] ways, final Handler.Callback callback) {
showChooserInternal(ways, callback);
}
示例11: ExecHandler
import android.os.Handler; //导入方法依赖的package包/类
ExecHandler(Looper looper, WeakReference<Handler.Callback> callback) {
super(looper);
mCallback = callback;
}
示例12: WeakHandler
import android.os.Handler; //导入方法依赖的package包/类
/**
* Use the provided {@link Looper} instead of the default one and take a callback
* interface in which to handle messages.
*
* @param looper The looper, must not be null.
* @param callback The callback interface in which to handle messages, or null.
*/
public WeakHandler(@NonNull Looper looper, @NonNull Handler.Callback callback) {
mCallback = callback;
mExec = new ExecHandler(looper, new WeakReference<>(callback));
}
示例13: MilesHandler
import android.os.Handler; //导入方法依赖的package包/类
/**
* Constructor associates this handler with the {@link Looper} for the
* current thread and takes a callback interface in which you can handle
* messages.
* <p>
* If this thread does not have a looper, this handler won't be able to receive messages
* so an exception is thrown.
*
* @param callback The callback interface in which to handle messages, or null.
*/
public MilesHandler(@Nullable Handler.Callback callback) {
mCallback = callback; // Hard referencing body
mExec = new ExecHandler(new WeakReference<>(callback)); // Weak referencing inside ExecHandler
}
示例14: WeakHandler
import android.os.Handler; //导入方法依赖的package包/类
/**
* Constructor associates this handler with the {@link Looper} for the
* current thread and takes a callback interface in which you can handle
* messages.
* <p/>
* If this thread does not have a looper, this handler won't be able to receive messages
* so an exception is thrown.
*
* @param callback The callback interface in which to handle messages, or null.
*/
public WeakHandler(Handler.Callback callback) {
mCallback = callback; // Hard referencing body
mExec = new ExecHandler(new WeakReference<>(callback)); // Weak referencing inside ExecHandler
}
示例15: XHandler
import android.os.Handler; //导入方法依赖的package包/类
/**
* Use the provided {@link Looper} instead of the default one and take a callback
* interface in which to handle messages.
*
* @param looper The looper, must not be null.
* @param callback The callback interface in which to handle messages, or null.
*/
public XHandler(@NonNull Looper looper, @NonNull Handler.Callback callback) {
mCallback = callback;
mExec = new ExecHandler(looper, new WeakReference<>(callback));
}