Java Code Examples for android.os.Handler.Callback

The following are Jave code examples for showing how to use Callback of the android.os.Handler class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: ImitateZHRB   File: WeakHandler.java   View Source Code Vote up 7 votes
@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);
}
 
Example 2
Project: cwac-crossport   File: SnackbarManager.java   View Source Code Vote up 6 votes
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;
            }
          });
}
 
Example 3
Project: container   File: HCallbackHook.java   View Source Code Vote up 5 votes
private static Handler.Callback getHCallback() {
	try {
		Handler handler = getH();
		return mirror.android.os.Handler.mCallback.get(handler);
	} catch (Throwable e) {
		e.printStackTrace();
	}
	return null;
}
 
Example 4
Project: FileDownloader-master   File: HybridTestActivity.java   View Source Code Vote up 5 votes
@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;
        }
    });
}
 
Example 5
Project: atlas   File: BundleReleaser.java   View Source Code Vote up 5 votes
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);
}
 
Example 6
Project: container   File: HCallbackHook.java   View Source Code Vote up 5 votes
@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;
}
 
Example 7
Project: GitHub   File: WeakHandler.java   View Source Code Vote up 5 votes
@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);
}
 
Example 8
Project: RNLearn_Project1   File: ForwardingCookieHandler.java   View Source Code Vote up 5 votes
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;
      }
    }
  });
}
 
Example 9
Project: ImitateZHRB   File: WeakHandler.java   View Source Code Vote up 4 votes
ExecHandler(WeakReference<Handler.Callback> callback) {
    mCallback = callback;
}
 
Example 10
Project: ImitateZHRB   File: WeakHandler.java   View Source Code Vote up 4 votes
ExecHandler(Looper looper, WeakReference<Handler.Callback> callback) {
    super(looper);
    mCallback = callback;
}
 
Example 11
Project: GitHub   File: WeakHandler.java   View Source Code Vote up 4 votes
ExecHandler(WeakReference<Handler.Callback> callback) {
    mCallback = callback;
}
 
Example 12
Project: XFrame   File: XHandler.java   View Source Code Vote up 4 votes
ExecHandler(WeakReference<Handler.Callback> callback) {
    mCallback = callback;
}
 
Example 13
Project: AgentWeb   File: AgentWebUIControllerImplBase.java   View Source Code Vote up 4 votes
@Override
public void onForceDownloadAlert(String url, DefaultMsgConfig.DownLoadMsgConfig message, Handler.Callback callback) {
    getDelegate().onForceDownloadAlert(url, message, callback);
}
 
Example 14
Project: AgentWeb   File: DefaultUIController.java   View Source Code Vote up 4 votes
@Override
public void showChooser(WebView view, String url, final String[] ways, final Handler.Callback callback) {
    showChooserInternal(ways, callback);
}
 
Example 15
Project: libRtmp   File: WeakHandler.java   View Source Code Vote up 4 votes
ExecHandler(Looper looper, WeakReference<Handler.Callback> callback) {
    super(looper);
    mCallback = callback;
}
 
Example 16
Project: ImitateZHRB   File: WeakHandler.java   View Source Code Vote up 2 votes
/**
 * 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));
}
 
Example 17
Project: CalendarCheck   File: MilesHandler.java   View Source Code Vote up 2 votes
/**
 * 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
}
 
Example 18
Project: BigDataFortuneTelling   File: WeakHandler.java   View Source Code Vote up 2 votes
/**
 * 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
}
 
Example 19
Project: GitHub   File: WeakHandler.java   View Source Code Vote up 2 votes
/**
 * 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));
}
 
Example 20
Project: XFrame   File: XHandler.java   View Source Code Vote up 2 votes
/**
 * 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));
}