mirror of
https://github.com/AngelAuraMC/Amethyst-Android.git
synced 2026-05-24 09:54:43 -04:00
Custom controls: can move or not
This commit is contained in:
@@ -11,6 +11,7 @@ public class ControlView extends Button implements OnTouchListener
|
||||
private GestureDetector mGestureDetector;
|
||||
private View.OnClickListener mClickListener;
|
||||
private ControlButton mProperties;
|
||||
private boolean mCanMove = false;
|
||||
|
||||
public ControlView(Context ctx, ControlButton properties) {
|
||||
super(ctx);
|
||||
@@ -44,6 +45,8 @@ public class ControlView extends Button implements OnTouchListener
|
||||
if (mGestureDetector.onTouchEvent(event)) {
|
||||
mClickListener.onClick(view);
|
||||
return true;
|
||||
} else if (!mCanMove) {
|
||||
return false;
|
||||
}
|
||||
|
||||
switch (event.getActionMasked()) {
|
||||
@@ -70,4 +73,8 @@ public class ControlView extends Button implements OnTouchListener
|
||||
|
||||
mClickListener = l;
|
||||
}
|
||||
|
||||
public void setCanMove(boolean z) {
|
||||
mCanMove = z;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package net.kdt.pojavlaunch.value.customcontrols;
|
||||
import android.widget.*;
|
||||
import android.content.*;
|
||||
import android.util.*;
|
||||
import android.view.*;
|
||||
|
||||
public class ControlsLayout extends FrameLayout
|
||||
{
|
||||
@@ -18,4 +19,13 @@ public class ControlsLayout extends FrameLayout
|
||||
addView(new ControlView(getContext(), button));
|
||||
}
|
||||
}
|
||||
|
||||
public void setCanMove(boolean z) {
|
||||
for (int i = 0; i < getChildCount(); i++) {
|
||||
View v = getChildAt(i);
|
||||
if (v instanceof ControlView) {
|
||||
((ControlView) v).setCanMove(z);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user