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

Commit

Permalink
Inherit from UDialog instead of listening to WorldClick events
Browse files Browse the repository at this point in the history
  • Loading branch information
keianhzo committed Nov 14, 2019
1 parent 20c8ac2 commit d0cd20b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@
import android.widget.Button;

import org.mozilla.vrbrowser.R;
import org.mozilla.vrbrowser.ui.widgets.dialogs.UIDialog;

public class NoInternetWidget extends UIWidget implements WidgetManagerDelegate.WorldClickListener {

private Button mAcceptButton;
public class NoInternetWidget extends UIDialog {

public NoInternetWidget(Context aContext) {
super(aContext);
Expand All @@ -33,7 +32,7 @@ public NoInternetWidget(Context aContext, AttributeSet aAttrs, int aDefStyle) {
private void initialize(Context aContext) {
inflate(aContext, R.layout.no_internet, this);

mAcceptButton = findViewById(R.id.acceptButton);
Button mAcceptButton = findViewById(R.id.acceptButton);
mAcceptButton.setOnClickListener(view -> {
view.requestFocusFromTouch();
hide(REMOVE_WIDGET);
Expand All @@ -58,7 +57,6 @@ protected void initializeWidgetPlacement(WidgetPlacement aPlacement) {
public void show(int aShowFlags) {
super.show(aShowFlags);

mWidgetManager.addWorldClickListener(this);
mWidgetManager.pushWorldBrightness(this, WidgetManagerDelegate.DEFAULT_DIM_BRIGHTNESS);
}

Expand All @@ -67,14 +65,6 @@ public void hide(int aHideFlags) {
super.hide(aHideFlags);

mWidgetManager.popWorldBrightness(this);
mWidgetManager.removeWorldClickListener(this);
}

// WidgetManagerDelegate.WorldClickListener

@Override
public void onWorldClick() {
onDismiss();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import org.mozilla.vrbrowser.ui.widgets.UIWidget;
import org.mozilla.vrbrowser.ui.widgets.WidgetManagerDelegate;
import org.mozilla.vrbrowser.utils.ViewUtils;

public abstract class UIDialog extends UIWidget implements WidgetManagerDelegate.FocusChangeListener {
public UIDialog(Context aContext) {
Expand Down Expand Up @@ -42,7 +43,7 @@ public boolean isDialog() {

@Override
public void onGlobalFocusChanged(View oldFocus, View newFocus) {
if (oldFocus == this && isVisible()) {
if (!ViewUtils.isEqualOrChildrenOf(this, newFocus) && isVisible()) {
onDismiss();
}
}
Expand Down

0 comments on commit d0cd20b

Please sign in to comment.