Skip to content

Commit

Permalink
hide items if model is not set or not supported
Browse files Browse the repository at this point in the history
  • Loading branch information
KillerInk committed Apr 22, 2018
1 parent 5b30518 commit cfe083c
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -120,21 +120,23 @@ protected void onResume() {
@Override
protected void onPause() {
Log.d(TAG,"onPause");
removeSurfaceView();
super.onPause();
if (avIndexManager != null) {
unregisterReceiver(avIndexManager);
avIndexManager.onPause(getApplicationContext());
}

CameraInstance.GET().closeCamera();
removeSurfaceView();
layoutHolder.removeAllViews();
}

@Override
protected void onDestroy() {
super.onDestroy();
stopBackgroundThread();
Preferences.CLEAR();
avIndexManager = null;
ShutterController.GetInstance().bindActivityInterface(null);
}

Expand Down Expand Up @@ -281,6 +283,7 @@ private void addSurfaceView() {

private void removeSurfaceView()
{
m_surfaceHolder.removeCallback(this);
surfaceView = null;
surfaceViewHolder.removeAllViews();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,9 @@ protected void updateImage() {

}

@Override
public void onIsSupportedChanged() {
if(view != null)
view.setVisibility(View.VISIBLE);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,27 @@ public abstract class AbstractController<V extends View, M extends Model> imple
protected M model;

@Override
public void bindView(V v) {
public synchronized void bindView(V v) {
this.view = v;
onIsSupportedChanged();
}

@Override
public void bindModel(M model) {
public synchronized void bindModel(M model) {
this.model = model;
if (model != null)
model.setListner(this);
onIsSupportedChanged();
}

@Override
public void onIsSupportedChanged() {
if (model != null){
if (view != null)
view.setVisibility(model.isSupported() ? View.VISIBLE : View.INVISIBLE);
view.post(()->view.setVisibility(model.isSupported() ? View.VISIBLE : View.INVISIBLE));
}
else if (view != null)
view.setVisibility(View.GONE);
view.post(()->view.setVisibility(View.GONE));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,5 @@ protected void updateImage() {
else
view.setImageResource(R.drawable.lnr_off);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,14 @@ public class ExposureModeModel extends AbstractModel<ExposureModeModel.ExposureM

public ExposureModeModel(CameraInstance camera) {
super(camera);
value = ExposureModes.aperture;
if (camera.getSceneMode().equals(CameraEx.ParametersModifier.SCENE_MODE_APERTURE_PRIORITY))
value = ExposureModes.aperture;
else if (camera.getSceneMode().equals(CameraEx.ParametersModifier.SCENE_MODE_MANUAL_EXPOSURE))
value = ExposureModes.manual;
else if (camera.getSceneMode().equals(CameraEx.ParametersModifier.SCENE_MODE_SHUTTER_PRIORITY))
value = ExposureModes.shutter;
else
value = ExposureModes.other;
}

public enum ExposureModes { manual, aperture, shutter, other }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,9 @@ public void setValue(int i) {
camera.setImageStabilisation("onetime");
fireOnValueChanged();
}

@Override
public boolean isSupported() {
return true;
}
}

0 comments on commit cfe083c

Please sign in to comment.