Skip to content
This repository was archived by the owner on Jul 22, 2024. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 4 additions & 10 deletions app/src/common/shared/org/mozilla/vrbrowser/ui/views/UIButton.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
import android.content.res.TypedArray;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Handler;
import android.util.AttributeSet;
import android.view.MotionEvent;

import androidx.annotation.IdRes;
import androidx.appcompat.widget.AppCompatImageButton;

import org.mozilla.gecko.util.ThreadUtils;
import org.mozilla.vrbrowser.R;
import org.mozilla.vrbrowser.ui.widgets.TooltipWidget;
import org.mozilla.vrbrowser.ui.widgets.UIWidget;
Expand All @@ -44,7 +44,6 @@ private enum State {
private int mTooltipDelay;
private float mTooltipDensity;
private ViewUtils.TooltipPosition mTooltipPosition;
private Handler mHandler;

public UIButton(Context context, AttributeSet attrs) {
this(context, attrs, R.attr.imageButtonStyle);
Expand Down Expand Up @@ -74,7 +73,6 @@ public UIButton(Context context, AttributeSet attrs, int defStyleAttr) {
mBackground = getBackground();

mState = State.NORMAL;
mHandler = getHandler();
}

@TargetApi(Build.VERSION_CODES.O)
Expand Down Expand Up @@ -103,15 +101,11 @@ public void setTooltip(String text) {
public boolean onHoverEvent(MotionEvent event) {
if (getTooltip() != null) {
if (event.getAction() == MotionEvent.ACTION_HOVER_ENTER) {
if (mHandler != null) {
mHandler.postDelayed(mShowTooltipRunnable, mTooltipDelay);
}
ThreadUtils.postDelayedToUiThread(mShowTooltipRunnable, mTooltipDelay);

} else if (event.getAction() == MotionEvent.ACTION_HOVER_EXIT) {
if (mHandler != null) {
mHandler.removeCallbacks(mShowTooltipRunnable);
mHandler.post(mHideTooltipRunnable);
}
ThreadUtils.removeCallbacksFromUiThread(mShowTooltipRunnable);
ThreadUtils.postToUiThread(mHideTooltipRunnable);
}
}

Expand Down