Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

Commit

Permalink
Fixes tooltips (#1622)
Browse files Browse the repository at this point in the history
  • Loading branch information
keianhzo authored and bluemarvin committed Aug 21, 2019
1 parent f8d7486 commit 3c3c7dc
Showing 1 changed file with 4 additions and 10 deletions.
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

0 comments on commit 3c3c7dc

Please sign in to comment.