Java Code Examples for android.os.Handler#Callback

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: SnackbarManager.java    From Nimingban with Apache License 2.0 5 votes vote down vote up
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;
        }
    });
}
 
Example 2
Source File: RemitDatabase.java    From FileDownloader with Apache License 2.0 5 votes vote down vote up
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;
        }
    });
}
 
Example 3
Source File: SubsamplingScaleImageView.java    From IndiaSatelliteWeather with GNU General Public License v2.0 5 votes vote down vote up
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)));
        }
    }
}
 
Example 4
Source File: ZulipApp.java    From zulip-android with Apache License 2.0 4 votes vote down vote up
@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;
        }
    });
}
 
Example 5
Source File: SubsamplingScaleImageView.java    From pdfview-android with Apache License 2.0 4 votes vote down vote up
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());
}
 
Example 6
Source File: MediaPlayerExtendedView.java    From Spectaculum with Apache License 2.0 4 votes vote down vote up
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();
}
 
Example 7
Source File: RxScaleImageView.java    From RxTools-master with Apache License 2.0 4 votes vote down vote up
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());
}
 
Example 8
Source File: ScaleImageView.java    From light-novel-library_Wenku8_Android with GNU General Public License v2.0 4 votes vote down vote up
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)));
        }
    }
}
 
Example 9
Source File: SubsamplingScaleImageView.java    From imsdk-android with MIT License 4 votes vote down vote up
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());
}
 
Example 10
Source File: AgentWebUIControllerImplBase.java    From AgentWeb with Apache License 2.0 4 votes vote down vote up
@Override
public void onForceDownloadAlert(String url, Handler.Callback callback) {
	getDelegate().onForceDownloadAlert(url, callback);
}
 
Example 11
Source File: Muxer.java    From RtmpPublisher with Apache License 2.0 4 votes vote down vote up
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;
        }
    });
}
 
Example 12
Source File: SubsamplingScaleImageViewDragClose.java    From imsdk-android with MIT License 4 votes vote down vote up
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());
}
 
Example 13
Source File: WeakHandler.java    From Android-Application-ZJB with Apache License 2.0 4 votes vote down vote up
public WeakHandler(@Nullable Handler.Callback callback) {
    this.mCallback = callback;
    this.mExec = new ExecHandler(new WeakReference(callback));
}
 
Example 14
Source File: ThreadUtils.java    From xdroid with Apache License 2.0 2 votes vote down vote up
/**
 * 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);
}
 
Example 15
Source File: WeakHandler.java    From HomeApplianceMall with MIT License 2 votes vote down vote up
/**
 * 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 16
Source File: WeakHandler.java    From LRecyclerView with Apache License 2.0 2 votes vote down vote up
/**
 * 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
}
 
Example 17
Source File: WeakHandler.java    From HomeApplianceMall with MIT License 2 votes vote down vote up
/**
 * 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
}
 
Example 18
Source File: WeakHandler.java    From FriendCircle with GNU General Public License v3.0 2 votes vote down vote up
/**
 * 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
Source File: WeakHandler.java    From Pas with Apache License 2.0 2 votes vote down vote up
/**
 * 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
Source File: AbsAgentWebUIController.java    From AgentWeb with Apache License 2.0 votes vote down vote up
public abstract void onSelectItemsPrompt(WebView view, String url, String[] ways, Handler.Callback callback);