diff --git a/orion-viewer/src/main/AndroidManifest.xml b/orion-viewer/src/main/AndroidManifest.xml index 4f016cf11..91167ae25 100644 --- a/orion-viewer/src/main/AndroidManifest.xml +++ b/orion-viewer/src/main/AndroidManifest.xml @@ -20,12 +20,14 @@ --> - + (this, android.R.layout.simple_list_item_single_choice, Action.values()) { + @NonNull @Override public View getView(int position, View convertView, @NonNull ViewGroup parent) { CheckedTextView view = (CheckedTextView)super.getView(position, convertView, parent); @@ -88,64 +83,17 @@ public View getView(int position, View convertView, @NonNull ViewGroup parent) { break; } } - view.setOnItemClickListener(new AdapterView.OnItemClickListener() { - public void onItemClick(AdapterView parent, View view, int position, long id) { - int code = actions[position].getCode(); - Intent result = new Intent(); - result.putExtra("code", code); - result.putExtra("keyCode", keyCode); - result.putExtra("isLong", isLong); - setResult(Activity.RESULT_OK, result); - finish(); - } + view.setOnItemClickListener((parent, view1, position, id) -> { + int code1 = actions[position].getCode(); + Intent result = new Intent(); + result.putExtra("code", code1); + result.putExtra("keyCode", keyCode); + result.putExtra("isLong", isLong); + setResult(Activity.RESULT_OK, result); + finish(); }); -// RadioGroup group = (RadioGroup) findViewById(R.id.actionsGroup); -// Action[] actions = Action.values(); -// for (int i = 0; i < actions.length; i++) { -// Action action = actions[i]; -// RadioButton button = new RadioButton(this); -// button.setText(getResources().getString(action.getName())); -// button.setTag(R.attr.actionId, action.getCode()); -// group.addView(button); -// } -// -// group.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { -// public void onCheckedChanged(RadioGroup group, int checkedId) { -// if (!populating) { -// RadioButton button = (RadioButton) group.findViewById(group.getCheckedRadioButtonId()); -// Integer code = (Integer) button.getTag(R.attr.actionId); -// Intent result = new Intent(); -// result.putExtra("code", code); -// setResult(Activity.RESULT_OK, result); -// finish(); -// } -// } -// }); } - -// @Override -// protected void onResume() { -// super.onResume(); -// populating = true; -// int type = getIntent().getIntExtra("type", 0); -// TextView header = (TextView) findViewById(R.id.actions_header); -// header.setText(type == 0 ? R.string.short_click : type == 1 ? R.string.long_click : R.string.binding_click); -// int code = getIntent().getIntExtra("code", 0); -// RadioGroup group = (RadioGroup) findViewById(R.id.actionsGroup); -// int id = group.getChildAt(0).getId(); -// for (int i = 0; i < group.getChildCount(); i++) { -// RadioButton button = (RadioButton) group.getChildAt(i); -// Integer buttone_code = (Integer) button.getTag(R.attr.actionId); -// if (buttone_code == code) { -// id = group.getChildAt(i).getId(); -// break; -// } -// } -// group.check(id); -// populating = false; -// } - public OrionApplication getOrionContext() { return (OrionApplication) getApplicationContext(); } diff --git a/orion-viewer/src/main/java/universe/constellation/orion/viewer/prefs/GlobalOptions.java b/orion-viewer/src/main/java/universe/constellation/orion/viewer/prefs/GlobalOptions.java index bc20749b3..44b448640 100644 --- a/orion-viewer/src/main/java/universe/constellation/orion/viewer/prefs/GlobalOptions.java +++ b/orion-viewer/src/main/java/universe/constellation/orion/viewer/prefs/GlobalOptions.java @@ -140,38 +140,36 @@ public class GlobalOptions implements Serializable, PageOptions { } } - onSharedPreferenceChangeListener = new SharedPreferences.OnSharedPreferenceChangeListener() { - public void onSharedPreferenceChanged(SharedPreferences preferences, String name) { - log("onSharedPreferenceChanged " + name); - Object oldValue = prefValues.remove(name); - - OrionViewerActivity activity = context.getViewActivity(); - if (activity != null) { - if (FULL_SCREEN.equals(name)) { - OptionActions.FULL_SCREEN.doAction(activity, false, isFullScreen()); - } else if (SHOW_ACTION_BAR.equals(name)) { - OptionActions.SHOW_ACTION_BAR.doAction(activity, false, isActionBarVisible()); - } else if (SHOW_STATUS_BAR.equals(name)) { - OptionActions.SHOW_STATUS_BAR.doAction(activity, false, isStatusBarVisible()); - } else if (SHOW_OFFSET_ON_STATUS_BAR.equals(name)) { - OptionActions.SHOW_OFFSET_ON_STATUS_BAR.doAction(activity, false, isShowOffsetOnStatusBar()); - } else if (SCREEN_OVERLAPPING_HORIZONTAL.equals(name)) { - OptionActions.SCREEN_OVERLAPPING_HORIZONTAL.doAction(activity, getHorizontalOverlapping(), getVerticalOverlapping()); - } else if (SCREEN_OVERLAPPING_VERTICAL.equals(name)) { - OptionActions.SCREEN_OVERLAPPING_VERTICAL.doAction(activity, getHorizontalOverlapping(), getVerticalOverlapping()); - } else if (DEBUG.equals(name)) { - OptionActions.DEBUG.doAction(activity, false, getBooleanProperty(DEBUG, false)); - } else if (APP_LANGUAGE.equals(name)) { - context.setLangCode(getAppLanguage()); - } else if (DRAW_OFF_PAGE.equals(name)) { - activity.getFullScene().setDrawOffPage(isDrawOffPage()); - //TODO ? - activity.getView().invalidate(); - } - + onSharedPreferenceChangeListener = (preferences1, name) -> { + log("onSharedPreferenceChanged " + name); + Object oldValue = prefValues.remove(name); + + OrionViewerActivity activity = context.getViewActivity(); + if (activity != null) { + if (FULL_SCREEN.equals(name)) { + OptionActions.FULL_SCREEN.doAction(activity, false, isFullScreen()); + } else if (SHOW_ACTION_BAR.equals(name)) { + OptionActions.SHOW_ACTION_BAR.doAction(activity, false, isActionBarVisible()); + } else if (SHOW_STATUS_BAR.equals(name)) { + OptionActions.SHOW_STATUS_BAR.doAction(activity, false, isStatusBarVisible()); + } else if (SHOW_OFFSET_ON_STATUS_BAR.equals(name)) { + OptionActions.SHOW_OFFSET_ON_STATUS_BAR.doAction(activity, false, isShowOffsetOnStatusBar()); + } else if (SCREEN_OVERLAPPING_HORIZONTAL.equals(name)) { + OptionActions.SCREEN_OVERLAPPING_HORIZONTAL.doAction(activity, getHorizontalOverlapping(), getVerticalOverlapping()); + } else if (SCREEN_OVERLAPPING_VERTICAL.equals(name)) { + OptionActions.SCREEN_OVERLAPPING_VERTICAL.doAction(activity, getHorizontalOverlapping(), getVerticalOverlapping()); + } else if (DEBUG.equals(name)) { + OptionActions.DEBUG.doAction(activity, false, getBooleanProperty(DEBUG, false)); + } else if (APP_LANGUAGE.equals(name)) { + context.setLangCode(getAppLanguage()); + } else if (DRAW_OFF_PAGE.equals(name)) { + activity.getFullScene().setDrawOffPage(isDrawOffPage()); + //TODO ? + activity.getView().invalidate(); } } + }; prefs.registerOnSharedPreferenceChangeListener(onSharedPreferenceChangeListener); diff --git a/orion-viewer/src/main/java/universe/constellation/orion/viewer/prefs/OrionKeyBinderActivity.java b/orion-viewer/src/main/java/universe/constellation/orion/viewer/prefs/OrionKeyBinderActivity.java index ba1183827..d4402714f 100644 --- a/orion-viewer/src/main/java/universe/constellation/orion/viewer/prefs/OrionKeyBinderActivity.java +++ b/orion-viewer/src/main/java/universe/constellation/orion/viewer/prefs/OrionKeyBinderActivity.java @@ -202,7 +202,7 @@ public int compareTo(KeyCodeAndAction object2) { } } - private class KeyListAdapter extends BaseAdapter { + private static class KeyListAdapter extends BaseAdapter { private final LayoutInflater mInflater; diff --git a/orion-viewer/src/main/java/universe/constellation/orion/viewer/search/SearchTask.java b/orion-viewer/src/main/java/universe/constellation/orion/viewer/search/SearchTask.java index 46df90864..8f553f2a0 100644 --- a/orion-viewer/src/main/java/universe/constellation/orion/viewer/search/SearchTask.java +++ b/orion-viewer/src/main/java/universe/constellation/orion/viewer/search/SearchTask.java @@ -118,12 +118,10 @@ protected void onProgressUpdate(Integer... values) { @Override protected void onPreExecute() { super.onPreExecute(); - mHandler.postDelayed(new Runnable() { - public void run() { - if (!progressDialog.isCancelled()) { - progressDialog.show(); - progressDialog.setProgress(startIndex); - } + mHandler.postDelayed(() -> { + if (!progressDialog.isCancelled()) { + progressDialog.show(); + progressDialog.setProgress(startIndex); } }, SEARCH_PROGRESS_DELAY); } diff --git a/orion-viewer/src/main/java/universe/constellation/orion/viewer/selection/SelectionAutomata.java b/orion-viewer/src/main/java/universe/constellation/orion/viewer/selection/SelectionAutomata.java index ec9985d41..f9bb9b587 100644 --- a/orion-viewer/src/main/java/universe/constellation/orion/viewer/selection/SelectionAutomata.java +++ b/orion-viewer/src/main/java/universe/constellation/orion/viewer/selection/SelectionAutomata.java @@ -29,12 +29,7 @@ public SelectionAutomata(final OrionViewerActivity activity) { super(activity, universe.constellation.orion.viewer.R.layout.text_selector, android.R.style.Theme_Translucent_NoTitleBar); selectionView = dialog.findViewById(R.id.text_selector); - selectionView.setOnTouchListener(new View.OnTouchListener() { - @Override - public boolean onTouch(View v, MotionEvent event) { - return SelectionAutomata.this.onTouch(event); - } - }); + selectionView.setOnTouchListener((v, event) -> SelectionAutomata.this.onTouch(event)); }