android.os.Handler#Callback ( )源码实例Demo

下面列出了android.os.Handler#Callback ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: Nimingban   文件: SnackbarManager.java
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((SnackbarManager.SnackbarRecord)message.obj);
                    return true;
            }
            return false;
        }
    });
}
 
public SubsamplingScaleImageView(Context context, AttributeSet attr) {
    super(context, attr);
    setMinimumDpi(160);
    setDoubleTapZoomDpi(160);
    setGestureDetector(context);
    this.handler = new Handler(new Handler.Callback() {
        public boolean handleMessage(Message message) {
            if (message.what == MESSAGE_LONG_CLICK && onLongClickListener != null) {
                maxTouchCount = 0;
                SubsamplingScaleImageView.super.setOnLongClickListener(onLongClickListener);
                performLongClick();
                SubsamplingScaleImageView.super.setOnLongClickListener(null);
            }
            return true;
        }
    });
    // Handle XML attributes
    if (attr != null) {
        TypedArray typedAttr = getContext().obtainStyledAttributes(attr, styleable.SubsamplingScaleImageView);
        if (typedAttr.hasValue(styleable.SubsamplingScaleImageView_assetName)) {
            String assetName = typedAttr.getString(styleable.SubsamplingScaleImageView_assetName);
            if (assetName != null && assetName.length() > 0) {
                setImageAsset(assetName);
            }
        }
        if (typedAttr.hasValue(styleable.SubsamplingScaleImageView_panEnabled)) {
            setPanEnabled(typedAttr.getBoolean(styleable.SubsamplingScaleImageView_panEnabled, true));
        }
        if (typedAttr.hasValue(styleable.SubsamplingScaleImageView_zoomEnabled)) {
            setZoomEnabled(typedAttr.getBoolean(styleable.SubsamplingScaleImageView_zoomEnabled, true));
        }
        if (typedAttr.hasValue(styleable.SubsamplingScaleImageView_tileBackgroundColor)) {
            setTileBackgroundColor(typedAttr.getColor(styleable.SubsamplingScaleImageView_tileBackgroundColor, Color.argb(0, 0, 0, 0)));
        }
    }
}
 
源代码3 项目: FileDownloader   文件: RemitDatabase.java
public RemitDatabase() {
    this.cachedDatabase = new NoDatabaseImpl();
    this.realDatabase = new SqliteDatabaseImpl();
    this.minInterval = FileDownloadProperties.getImpl().downloadMinProgressTime;

    final HandlerThread thread = new HandlerThread(
            FileDownloadUtils.getThreadPoolName("RemitHandoverToDB"));
    thread.start();
    handler = new Handler(thread.getLooper(), new Handler.Callback() {
        @Override public boolean handleMessage(Message msg) {
            final int id = msg.what;
            if (id == WHAT_CLEAN_LOCK) {
                if (parkThread != null) {
                    LockSupport.unpark(parkThread);
                    parkThread = null;
                }
                return false;
            }

            try {
                handlingId.set(id);

                syncCacheToDB(id);
                freeToDBIdList.add(id);
            } finally {
                handlingId.set(0);
                if (parkThread != null) {
                    LockSupport.unpark(parkThread);
                    parkThread = null;
                }
            }

            return false;
        }
    });
}
 
源代码4 项目: Android-Application-ZJB   文件: WeakHandler.java
public WeakHandler(@Nullable Handler.Callback callback) {
    this.mCallback = callback;
    this.mExec = new ExecHandler(new WeakReference(callback));
}
 
public SubsamplingScaleImageViewDragClose(Context context, AttributeSet attr) {
    super(context, attr);
    density = getResources().getDisplayMetrics().density;
    setMinimumDpi(160);
    setDoubleTapZoomDpi(160);
    setMinimumTileDpi(320);
    setGestureDetector(context);
    mTouchslop = ViewConfiguration.get(context).getScaledPagingTouchSlop();
    this.handler = new Handler(new Handler.Callback() {
        @Override
        public boolean handleMessage(Message message) {
            if (message.what == MESSAGE_LONG_CLICK && onLongClickListener != null) {
                maxTouchCount = 0;
                SubsamplingScaleImageViewDragClose.super.setOnLongClickListener(onLongClickListener);
                performLongClick();
                SubsamplingScaleImageViewDragClose.super.setOnLongClickListener(null);
            }
            return true;
        }
    });
    // Handle XML attributes
    if (attr != null) {
        TypedArray typedAttr = getContext().obtainStyledAttributes(attr, R.styleable.SubsamplingScaleImageView);
        if (typedAttr.hasValue(R.styleable.SubsamplingScaleImageView_assetName)) {
            String assetName = typedAttr.getString(R.styleable.SubsamplingScaleImageView_assetName);
            if (assetName != null && assetName.length() > 0) {
                setImage(ImageSource.asset(assetName).tilingEnabled());
            }
        }
        if (typedAttr.hasValue(R.styleable.SubsamplingScaleImageView_src)) {
            int resId = typedAttr.getResourceId(R.styleable.SubsamplingScaleImageView_src, 0);
            if (resId > 0) {
                setImage(ImageSource.resource(resId).tilingEnabled());
            }
        }
        if (typedAttr.hasValue(R.styleable.SubsamplingScaleImageView_panEnabled)) {
            setPanEnabled(typedAttr.getBoolean(R.styleable.SubsamplingScaleImageView_panEnabled, true));
        }
        if (typedAttr.hasValue(R.styleable.SubsamplingScaleImageView_zoomEnabled)) {
            setZoomEnabled(typedAttr.getBoolean(R.styleable.SubsamplingScaleImageView_zoomEnabled, true));
        }
        if (typedAttr.hasValue(R.styleable.SubsamplingScaleImageView_quickScaleEnabled)) {
            setQuickScaleEnabled(typedAttr.getBoolean(R.styleable.SubsamplingScaleImageView_quickScaleEnabled, true));
        }
        if (typedAttr.hasValue(R.styleable.SubsamplingScaleImageView_tileBackgroundColor)) {
            setTileBackgroundColor(typedAttr.getColor(R.styleable.SubsamplingScaleImageView_tileBackgroundColor,
                Color.argb(0, 0, 0, 0)));
        }
        typedAttr.recycle();
    }

    quickScaleThreshold =
        TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 20, context.getResources().getDisplayMetrics());
}
 
源代码6 项目: RtmpPublisher   文件: Muxer.java
Muxer() {
    final Handler uiHandler = new Handler(Looper.getMainLooper());
    HandlerThread handlerThread = new HandlerThread("Muxer");
    handlerThread.start();
    handler = new Handler(handlerThread.getLooper(), new Handler.Callback() {
        @Override
        public boolean handleMessage(Message msg) {
            switch (msg.what) {
                case MSG_OPEN:
                    rtmpMuxer.open((String) msg.obj, msg.arg1, msg.arg2);
                    if (listener != null) {
                        uiHandler.post(new Runnable() {
                            @Override
                            public void run() {
                                if (isConnected()) {
                                    listener.onStarted();
                                    disconnected = false;
                                    closed = false;
                                } else {
                                    listener.onFailedToConnect();
                                }
                            }
                        });
                    }
                    break;
                case MSG_CLOSE:
                    rtmpMuxer.close();
                    if (listener != null) {
                        uiHandler.post(new Runnable() {
                            @Override
                            public void run() {
                                listener.onStopped();
                                closed = true;
                            }
                        });
                    }
                    break;
                case MSG_SEND_VIDEO: {
                    if (isConnected()) {
                        rtmpMuxer.writeVideo((byte[]) msg.obj, 0, msg.arg1, msg.arg2);
                    } else {
                        if (listener != null) {
                            uiHandler.post(new Runnable() {
                                @Override
                                public void run() {
                                    if (closed || disconnected) return;
                                    listener.onDisconnected();
                                    disconnected = true;
                                }
                            });
                        }
                    }
                    break;
                }
                case MSG_SEND_AUDIO: {
                    if (isConnected()) {
                        rtmpMuxer.writeAudio((byte[]) msg.obj, 0, msg.arg1, msg.arg2);
                    } else {
                        if (listener != null) {
                            uiHandler.post(new Runnable() {
                                @Override
                                public void run() {
                                    if (closed || disconnected) return;
                                    listener.onDisconnected();
                                    disconnected = true;
                                }
                            });
                        }
                    }
                    break;
                }
            }
            return false;
        }
    });
}
 
源代码7 项目: AgentWeb   文件: AgentWebUIControllerImplBase.java
@Override
public void onForceDownloadAlert(String url, Handler.Callback callback) {
	getDelegate().onForceDownloadAlert(url, callback);
}
 
源代码8 项目: imsdk-android   文件: SubsamplingScaleImageView.java
public SubsamplingScaleImageView(Context context, AttributeSet attr) {
    super(context, attr);
    density = getResources().getDisplayMetrics().density;
    setMinimumDpi(160);
    setDoubleTapZoomDpi(160);
    setMinimumTileDpi(320);
    setGestureDetector(context);
    this.handler = new Handler(new Handler.Callback() {
        public boolean handleMessage(Message message) {
            if (message.what == MESSAGE_LONG_CLICK && onLongClickListener != null) {
                maxTouchCount = 0;
                SubsamplingScaleImageView.super.setOnLongClickListener(onLongClickListener);
                performLongClick();
                SubsamplingScaleImageView.super.setOnLongClickListener(null);
            }
            return true;
        }
    });
    // Handle XML attributes
    if (attr != null) {
        TypedArray typedAttr = getContext().obtainStyledAttributes(attr, R.styleable.SubsamplingScaleImageView);
        if (typedAttr.hasValue(R.styleable.SubsamplingScaleImageView_assetName)) {
            String assetName = typedAttr.getString(R.styleable.SubsamplingScaleImageView_assetName);
            if (assetName != null && assetName.length() > 0) {
                setImage(ImageSource.asset(assetName).tilingEnabled());
            }
        }
        if (typedAttr.hasValue(R.styleable.SubsamplingScaleImageView_src)) {
            int resId = typedAttr.getResourceId(R.styleable.SubsamplingScaleImageView_src, 0);
            if (resId > 0) {
                setImage(ImageSource.resource(resId).tilingEnabled());
            }
        }
        if (typedAttr.hasValue(R.styleable.SubsamplingScaleImageView_panEnabled)) {
            setPanEnabled(typedAttr.getBoolean(R.styleable.SubsamplingScaleImageView_panEnabled, true));
        }
        if (typedAttr.hasValue(R.styleable.SubsamplingScaleImageView_zoomEnabled)) {
            setZoomEnabled(typedAttr.getBoolean(R.styleable.SubsamplingScaleImageView_zoomEnabled, true));
        }
        if (typedAttr.hasValue(R.styleable.SubsamplingScaleImageView_quickScaleEnabled)) {
            setQuickScaleEnabled(typedAttr.getBoolean(R.styleable.SubsamplingScaleImageView_quickScaleEnabled, true));
        }
        if (typedAttr.hasValue(R.styleable.SubsamplingScaleImageView_tileBackgroundColor)) {
            setTileBackgroundColor(typedAttr.getColor(R.styleable.SubsamplingScaleImageView_tileBackgroundColor, Color.argb(0, 0, 0, 0)));
        }
        typedAttr.recycle();
    }

    quickScaleThreshold = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 20, context.getResources().getDisplayMetrics());
}
 
源代码9 项目: zulip-android   文件: ZulipApp.java
@Override
public void onCreate() {
    super.onCreate();
    if (!BuildConfig.DEBUG)
        Fabric.with(this, new Crashlytics());
    ZulipApp.setInstance(this);
    // This used to be from HumbugActivity.getPreferences, so we keep that
    // file name.
    this.settings = getSharedPreferences("HumbugActivity", Context.MODE_PRIVATE);
    //check for auto theme is enabled or not
    if (getSettings().getBoolean(Constants.AUTO_NIGHT_THEME, false)) {
        AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_AUTO);
    }
    max_message_id = settings.getInt("max_message_id", -1);
    eventQueueId = settings.getString("eventQueueId", null);
    lastEventId = settings.getInt("lastEventId", -1);
    pointer = settings.getInt("pointer", -1);


    this.api_key = settings.getString(API_KEY, null);

    if (api_key != null) {
        afterLogin();
    }

    // create unread message queue
    unreadMessageHandler = new Handler(new Handler.Callback() {
        @Override
        public boolean handleMessage(android.os.Message message) {
            if (message.what == 0) {
                AsyncUnreadMessagesUpdate task = new AsyncUnreadMessagesUpdate(ZulipApp.this);
                task.execute();
            }

            // documentation doesn't say what this value does for
            // Handler.Callback,
            // and Handler.handleMessage returns void
            // so this just returns true.
            return true;
        }
    });
}
 
public ScaleImageView(Context context, AttributeSet attr) {
    super(context, attr);
    setMinimumDpi(160);
    setDoubleTapZoomDpi(160);
    setGestureDetector(context);
    this.handler = new Handler(new Handler.Callback() {
        public boolean handleMessage(Message message) {
            if (message.what == MESSAGE_LONG_CLICK && onLongClickListener != null) {
                maxTouchCount = 0;
                ScaleImageView.super.setOnLongClickListener(onLongClickListener);
                performLongClick();
                ScaleImageView.super.setOnLongClickListener(null);
            }
            return true;
        }
    });
    // Handle XML attributes
    if (attr != null) {
        TypedArray typedAttr = getContext().obtainStyledAttributes(attr, styleable.SubsamplingScaleImageView);
        if (typedAttr.hasValue(styleable.SubsamplingScaleImageView_assetName)) {
            String assetName = typedAttr.getString(styleable.SubsamplingScaleImageView_assetName);
            if (assetName != null && assetName.length() > 0) {
                setImageAsset(assetName);
            }
        }
        if (typedAttr.hasValue(styleable.SubsamplingScaleImageView_src)) {
            int resId = typedAttr.getResourceId(styleable.SubsamplingScaleImageView_src, 0);
            if (resId > 0) {
                setImageResource(resId);
            }
        }
        if (typedAttr.hasValue(styleable.SubsamplingScaleImageView_panEnabled)) {
            setPanEnabled(typedAttr.getBoolean(styleable.SubsamplingScaleImageView_panEnabled, true));
        }
        if (typedAttr.hasValue(styleable.SubsamplingScaleImageView_zoomEnabled)) {
            setZoomEnabled(typedAttr.getBoolean(styleable.SubsamplingScaleImageView_zoomEnabled, true));
        }
        if (typedAttr.hasValue(styleable.SubsamplingScaleImageView_tileBackgroundColor)) {
            setTileBackgroundColor(typedAttr.getColor(styleable.SubsamplingScaleImageView_tileBackgroundColor, Color.argb(0, 0, 0, 0)));
        }
    }
}
 
源代码11 项目: RxTools-master   文件: RxScaleImageView.java
public RxScaleImageView(Context context, AttributeSet attr) {
    super(context, attr);
    density = getResources().getDisplayMetrics().density;
    setMinimumDpi(160);
    setDoubleTapZoomDpi(160);
    setGestureDetector(context);
    this.handler = new Handler(new Handler.Callback() {
        public boolean handleMessage(Message message) {
            if (message.what == MESSAGE_LONG_CLICK && onLongClickListener != null) {
                maxTouchCount = 0;
                RxScaleImageView.super.setOnLongClickListener(onLongClickListener);
                performLongClick();
                RxScaleImageView.super.setOnLongClickListener(null);
            }
            return true;
        }
    });
    // Handle XML attributes
    if (attr != null) {
        TypedArray typedAttr = getContext().obtainStyledAttributes(attr, R.styleable.RxScaleImageView);
        if (typedAttr.hasValue(R.styleable.RxScaleImageView_assetName)) {
            String assetName = typedAttr.getString(R.styleable.RxScaleImageView_assetName);
            if (assetName != null && assetName.length() > 0) {
                setImage(ImageSource.asset(assetName).tilingEnabled());
            }
        }
        if (typedAttr.hasValue(R.styleable.RxScaleImageView_src)) {
            int resId = typedAttr.getResourceId(R.styleable.RxScaleImageView_src, 0);
            if (resId > 0) {
                setImage(ImageSource.resource(resId).tilingEnabled());
            }
        }
        if (typedAttr.hasValue(R.styleable.RxScaleImageView_panEnabled)) {
            setPanEnabled(typedAttr.getBoolean(R.styleable.RxScaleImageView_panEnabled, true));
        }
        if (typedAttr.hasValue(R.styleable.RxScaleImageView_zoomEnabled)) {
            setZoomEnabled(typedAttr.getBoolean(R.styleable.RxScaleImageView_zoomEnabled, true));
        }
        if (typedAttr.hasValue(R.styleable.RxScaleImageView_quickScaleEnabled)) {
            setQuickScaleEnabled(typedAttr.getBoolean(R.styleable.RxScaleImageView_quickScaleEnabled, true));
        }
        if (typedAttr.hasValue(R.styleable.RxScaleImageView_tileBackgroundColor)) {
            setTileBackgroundColor(typedAttr.getColor(R.styleable.RxScaleImageView_tileBackgroundColor, Color.argb(0, 0, 0, 0)));
        }
        typedAttr.recycle();
    }

    quickScaleThreshold = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 20, context.getResources().getDisplayMetrics());
}
 
源代码12 项目: Spectaculum   文件: MediaPlayerExtendedView.java
private void openVideo() {
    if (mSource == null || mInputSurfaceHolder == null) {
        // not ready for playback yet, will be called again later
        return;
    }

    release();

    mPlayer = new MediaPlayer();
    mPlayer.setSurface(getInputHolder().getSurface());
    mPlayer.setOnPreparedListener(mPreparedListener);
    mPlayer.setOnVideoSizeChangedListener(mSizeChangedListener);
    mPlayer.setOnSeekListener(mSeekListener);
    mPlayer.setOnSeekCompleteListener(mSeekCompleteListener);
    mPlayer.setOnCompletionListener(mCompletionListener);
    mPlayer.setOnErrorListener(mErrorListener);
    mPlayer.setOnInfoListener(mInfoListener);

    // Create a handler for the error message in case an exceptions happens in the following thread
    final Handler exceptionHandler = new Handler(new Handler.Callback() {
        @Override
        public boolean handleMessage(Message msg) {
            mCurrentState = STATE_ERROR;
            mTargetState = STATE_ERROR;
            mErrorListener.onError(mPlayer, MediaPlayer.MEDIA_ERROR_UNKNOWN, 0);
            return true;
        }
    });

    // Set the data source asynchronously as this might take a while, e.g. is data has to be
    // requested from the network/internet.
    // IMPORTANT:
    // We use a Thread instead of an AsyncTask for performance reasons, because threads started
    // in an AsyncTask perform much worse, no matter the priority the Thread gets (unless the
    // AsyncTask's priority is elevated before creating the Thread).
    // See comment in MediaPlayer#prepareAsync for detailed explanation.
    new Thread(new Runnable() {
        @Override
        public void run() {
            try {
                mPlayer.setDataSource(mSource);

                // Async prepare spawns another thread inside this thread which really isn't
                // necessary; we call this method anyway because of the events it triggers
                // when it fails, and to stay in sync which the Android VideoView that does
                // the same.
                mPlayer.prepareAsync();
                mCurrentState = STATE_PREPARING;

                Log.d(TAG, "video opened");
            } catch (IOException e) {
                Log.e(TAG, "video open failed", e);

                // Send message to the handler that an error occurred
                // (we don't need a message id as the handler only handles this single message)
                exceptionHandler.sendEmptyMessage(0);
            }
        }
    }).start();
}
 
public SubsamplingScaleImageView(Context context, AttributeSet attr) {
    super(context, attr);
    density = getResources().getDisplayMetrics().density;
    setMinimumDpi(160);
    setDoubleTapZoomDpi(160);
    setMinimumTileDpi(320);
    setGestureDetector(context);
    this.handler = new Handler(new Handler.Callback() {
        public boolean handleMessage(Message message) {
            if (message.what == MESSAGE_LONG_CLICK && onLongClickListener != null) {
                maxTouchCount = 0;
                SubsamplingScaleImageView.super.setOnLongClickListener(onLongClickListener);
                performLongClick();
                SubsamplingScaleImageView.super.setOnLongClickListener(null);
            }
            return true;
        }
    });
    // Handle XML attributes
    if (attr != null) {
        TypedArray typedAttr = getContext().obtainStyledAttributes(attr, R.styleable.SubsamplingScaleImageView);
        if (typedAttr.hasValue(R.styleable.SubsamplingScaleImageView_assetName)) {
            String assetName = typedAttr.getString(R.styleable.SubsamplingScaleImageView_assetName);
            if (assetName != null && assetName.length() > 0) {
                setImage(ImageSource.asset(assetName).tilingEnabled());
            }
        }
        if (typedAttr.hasValue(R.styleable.SubsamplingScaleImageView_src)) {
            int resId = typedAttr.getResourceId(R.styleable.SubsamplingScaleImageView_src, 0);
            if (resId > 0) {
                setImage(ImageSource.resource(resId).tilingEnabled());
            }
        }
        if (typedAttr.hasValue(R.styleable.SubsamplingScaleImageView_panEnabled)) {
            setPanEnabled(typedAttr.getBoolean(R.styleable.SubsamplingScaleImageView_panEnabled, true));
        }
        if (typedAttr.hasValue(R.styleable.SubsamplingScaleImageView_zoomEnabled)) {
            setZoomEnabled(typedAttr.getBoolean(R.styleable.SubsamplingScaleImageView_zoomEnabled, true));
        }
        if (typedAttr.hasValue(R.styleable.SubsamplingScaleImageView_quickScaleEnabled)) {
            setQuickScaleEnabled(typedAttr.getBoolean(R.styleable.SubsamplingScaleImageView_quickScaleEnabled, true));
        }
        if (typedAttr.hasValue(R.styleable.SubsamplingScaleImageView_tileBackgroundColor)) {
            setTileBackgroundColor(typedAttr.getColor(R.styleable.SubsamplingScaleImageView_tileBackgroundColor, Color.argb(0, 0, 0, 0)));
        }

        typedAttr.recycle();
    }

    quickScaleThreshold = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 20, context.getResources().getDisplayMetrics());
}
 
源代码14 项目: xdroid   文件: ThreadUtils.java
/**
 * Creates new {@link Handler} with the same {@link Looper} as the original handler.
 *
 * @param original original handler, can not be null
 * @param callback message handling callback, may be null
 * @return new instance
 */
public static Handler newHandler(Handler original, Handler.Callback callback) {
    return new Handler(original.getLooper(), callback);
}
 
源代码15 项目: Pas   文件: WeakHandler.java
/**
 * 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));
}
 
源代码16 项目: HomeApplianceMall   文件: WeakHandler.java
/**
 * 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));
}
 
源代码17 项目: LRecyclerView   文件: WeakHandler.java
/**
 * Constructor associates this handler with the {@link Looper} for the
 * current thread and takes a callback interface in which you can handle
 * messages.
 *
 * 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(@Nullable Handler.Callback callback) {
    mCallback = callback; // Hard referencing body
    mExec = new ExecHandler(this); // Weak referencing inside ExecHandler
}
 
源代码18 项目: HomeApplianceMall   文件: WeakHandler.java
/**
 * Constructor associates this handler with the {@link Looper} for the
 * current thread and takes a callback interface in which you can handle
 * messages.
 *
 * 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(@Nullable Handler.Callback callback) {
    mCallback = callback; // Hard referencing body
    mExec = new ExecHandler(new WeakReference<>(callback)); // Weak referencing inside ExecHandler
}
 
源代码19 项目: FriendCircle   文件: WeakHandler.java
/**
 * 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
}
 
源代码20 项目: AgentWeb   文件: AbsAgentWebUIController.java
public abstract void onSelectItemsPrompt(WebView view, String url, String[] ways, Handler.Callback callback);