From c6bc25a189392cf6465328afe0302581a49eff37 Mon Sep 17 00:00:00 2001 From: mahdihijazi Date: Sun, 17 Dec 2017 16:52:19 +0100 Subject: [PATCH 1/2] Enable Java 8 features in Dolphin --- Source/Android/app/build.gradle | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Source/Android/app/build.gradle b/Source/Android/app/build.gradle index 3dc43ee8b0..857eef27f6 100644 --- a/Source/Android/app/build.gradle +++ b/Source/Android/app/build.gradle @@ -4,6 +4,11 @@ android { compileSdkVersion 26 buildToolsVersion '26.0.2' + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + lintOptions { // This is important as it will run lint but not abort on error // Lint has some overly obnoxious "errors" that should really be warnings From e61e4d4b3c7ab24f78edc32078a4b1682d7e5c04 Mon Sep 17 00:00:00 2001 From: mahdihijazi Date: Sun, 17 Dec 2017 17:45:24 +0100 Subject: [PATCH 2/2] Replace all Anonymouse class with lambdas or method refernce where applicable --- .../dolphinemu/dolphinemu/NativeLibrary.java | 9 +- .../activities/EmulationActivity.java | 163 ++++++------------ .../dolphinemu/adapters/FileAdapter.java | 12 +- .../dolphinemu/dialogs/GameDetailsDialog.java | 20 +-- .../fragments/EmulationFragment.java | 21 +-- .../dolphinemu/model/GameDatabase.java | 38 ++-- .../dolphinemu/ui/main/MainActivity.java | 9 +- .../dolphinemu/ui/main/MainPresenter.java | 10 +- .../dolphinemu/ui/main/TvMainActivity.java | 44 +++-- .../ui/platform/PlatformGamesPresenter.java | 10 +- .../ui/settings/SettingsAdapter.java | 36 ++-- .../dolphinemu/utils/Java_GCAdapter.java | 9 +- .../dolphinemu/utils/PermissionsHandler.java | 18 +- 13 files changed, 130 insertions(+), 269 deletions(-) diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/NativeLibrary.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/NativeLibrary.java index 3cbbf3299a..b2d4ed8d39 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/NativeLibrary.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/NativeLibrary.java @@ -384,14 +384,7 @@ public final class NativeLibrary final EmulationActivity emulationActivity = sEmulationActivity.get(); if (emulationActivity != null) { - emulationActivity.runOnUiThread(new Runnable() - { - @Override - public void run() - { - Toast.makeText(emulationActivity, "Panic Alert: " + alert, Toast.LENGTH_LONG).show(); - } - }); + emulationActivity.runOnUiThread(() -> Toast.makeText(emulationActivity, "Panic Alert: " + alert, Toast.LENGTH_LONG).show()); } else { diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/activities/EmulationActivity.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/activities/EmulationActivity.java index 7fede2a7d4..56873cab76 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/activities/EmulationActivity.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/activities/EmulationActivity.java @@ -175,24 +175,13 @@ public final class EmulationActivity extends AppCompatActivity // Get a handle to the Window containing the UI. mDecorView = getWindow().getDecorView(); - mDecorView.setOnSystemUiVisibilityChangeListener - (new View.OnSystemUiVisibilityChangeListener() { - @Override - public void onSystemUiVisibilityChange(int visibility) { - if ((visibility & View.SYSTEM_UI_FLAG_FULLSCREEN) == 0) - { - // Go back to immersive fullscreen mode in 3s - Handler handler = new Handler(getMainLooper()); - handler.postDelayed(new Runnable() - { - @Override - public void run() - { - enableFullscreenImmersive(); - } - }, - 3000 /* 3s */); - } + mDecorView.setOnSystemUiVisibilityChangeListener(visibility -> + { + if ((visibility & View.SYSTEM_UI_FLAG_FULLSCREEN) == 0) + { + // Go back to immersive fullscreen mode in 3s + Handler handler = new Handler(getMainLooper()); + handler.postDelayed(this::enableFullscreenImmersive, 3000 /* 3s */); } }); // Set these options now so that the SurfaceView the game renders into is the right size. @@ -251,14 +240,7 @@ public final class EmulationActivity extends AppCompatActivity Animations.fadeViewOut(mImageView) .setStartDelay(2000) - .withEndAction(new Runnable() - { - @Override - public void run() - { - mImageView.setVisibility(View.GONE); - } - }); + .withEndAction(() -> mImageView.setVisibility(View.GONE)); } else { @@ -328,35 +310,27 @@ public final class EmulationActivity extends AppCompatActivity } } - public void exitWithAnimation() - { - runOnUiThread(new Runnable() + public void exitWithAnimation() { + runOnUiThread(() -> { - @Override - public void run() - { - Picasso.with(EmulationActivity.this) - .invalidate(mScreenPath); + Picasso.with(EmulationActivity.this) + .invalidate(mScreenPath); - Picasso.with(EmulationActivity.this) - .load(mScreenPath) - .noFade() - .noPlaceholder() - .into(mImageView, new Callback() - { - @Override - public void onSuccess() - { - showScreenshot(); - } + Picasso.with(EmulationActivity.this) + .load(mScreenPath) + .noFade() + .noPlaceholder() + .into(mImageView, new Callback() { + @Override + public void onSuccess() { + showScreenshot(); + } - @Override - public void onError() - { - finish(); - } - }); - } + @Override + public void onError() { + finish(); + } + }); }); } @@ -575,60 +549,31 @@ public final class EmulationActivity extends AppCompatActivity enabledButtons[i] = mPreferences.getBoolean("buttonToggleGc" + i, true); } builder.setMultiChoiceItems(R.array.gcpadButtons, enabledButtons, - new DialogInterface.OnMultiChoiceClickListener() { - @Override - public void onClick(DialogInterface dialog, int indexSelected, boolean isChecked) { - editor.putBoolean("buttonToggleGc" + indexSelected, isChecked); - } - }); + (dialog, indexSelected, isChecked) -> editor.putBoolean("buttonToggleGc" + indexSelected, isChecked)); } else if (mPreferences.getInt("wiiController", 3) == 4) { for (int i = 0; i < enabledButtons.length; i++) { enabledButtons[i] = mPreferences.getBoolean("buttonToggleClassic" + i, true); } builder.setMultiChoiceItems(R.array.classicButtons, enabledButtons, - new DialogInterface.OnMultiChoiceClickListener() { - @Override - public void onClick(DialogInterface dialog, int indexSelected, boolean isChecked) { - editor.putBoolean("buttonToggleClassic" + indexSelected, isChecked); - } - }); + (dialog, indexSelected, isChecked) -> editor.putBoolean("buttonToggleClassic" + indexSelected, isChecked)); } else { for (int i = 0; i < enabledButtons.length; i++) { enabledButtons[i] = mPreferences.getBoolean("buttonToggleWii" + i, true); } if (mPreferences.getInt("wiiController", 3) == 3) { builder.setMultiChoiceItems(R.array.nunchukButtons, enabledButtons, - new DialogInterface.OnMultiChoiceClickListener() { - @Override - public void onClick(DialogInterface dialog, int indexSelected, boolean isChecked) { - editor.putBoolean("buttonToggleWii" + indexSelected, isChecked); - } - }); + (dialog, indexSelected, isChecked) -> editor.putBoolean("buttonToggleWii" + indexSelected, isChecked)); } else { builder.setMultiChoiceItems(R.array.wiimoteButtons, enabledButtons, - new DialogInterface.OnMultiChoiceClickListener() { - @Override - public void onClick(DialogInterface dialog, int indexSelected, boolean isChecked) { - editor.putBoolean("buttonToggleWii" + indexSelected, isChecked); - } - }); + (dialog, indexSelected, isChecked) -> editor.putBoolean("buttonToggleWii" + indexSelected, isChecked)); } } - builder.setNeutralButton(getString(R.string.emulation_toggle_all), new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialogInterface, int i) - { - mEmulationFragment.toggleInputOverlayVisibility(); - } - }); - builder.setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialogInterface, int i) - { - editor.apply(); + builder.setNeutralButton(getString(R.string.emulation_toggle_all), (dialogInterface, i) -> mEmulationFragment.toggleInputOverlayVisibility()); + builder.setPositiveButton(getString(R.string.ok), (dialogInterface, i) -> + { + editor.apply(); - mEmulationFragment.refreshInputOverlay(); - } + mEmulationFragment.refreshInputOverlay(); }); AlertDialog alertDialog = builder.create(); @@ -665,15 +610,13 @@ public final class EmulationActivity extends AppCompatActivity AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(R.string.emulation_control_scale); builder.setView(view); - builder.setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialogInterface, int i) { - SharedPreferences.Editor editor = mPreferences.edit(); - editor.putInt("controlScale", seekbar.getProgress()); - editor.apply(); + builder.setPositiveButton(getString(R.string.ok), (dialogInterface, i) -> + { + SharedPreferences.Editor editor = mPreferences.edit(); + editor.putInt("controlScale", seekbar.getProgress()); + editor.apply(); - mEmulationFragment.refreshInputOverlay(); - } + mEmulationFragment.refreshInputOverlay(); }); AlertDialog alertDialog = builder.create(); @@ -685,24 +628,20 @@ public final class EmulationActivity extends AppCompatActivity AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(R.string.emulation_choose_controller); builder.setSingleChoiceItems(R.array.controllersEntries, mPreferences.getInt("wiiController", 3), - new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int indexSelected) { - editor.putInt("wiiController", indexSelected); + (dialog, indexSelected) -> + { + editor.putInt("wiiController", indexSelected); - NativeLibrary.SetConfig("WiimoteNew.ini", "Wiimote1", "Extension", - getResources().getStringArray(R.array.controllersValues)[indexSelected]); - } + NativeLibrary.SetConfig("WiimoteNew.ini", "Wiimote1", "Extension", + getResources().getStringArray(R.array.controllersValues)[indexSelected]); }); - builder.setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialogInterface, int i) { - editor.apply(); + builder.setPositiveButton(getString(R.string.ok), (dialogInterface, i) -> + { + editor.apply(); - mEmulationFragment.refreshInputOverlay(); + mEmulationFragment.refreshInputOverlay(); - Toast.makeText(getApplication(), R.string.emulation_controller_changed, Toast.LENGTH_SHORT).show(); - } + Toast.makeText(getApplication(), R.string.emulation_controller_changed, Toast.LENGTH_SHORT).show(); }); AlertDialog alertDialog = builder.create(); diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/adapters/FileAdapter.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/adapters/FileAdapter.java index 9b15dd5d2f..3e1048ffa5 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/adapters/FileAdapter.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/adapters/FileAdapter.java @@ -132,15 +132,11 @@ public final class FileAdapter extends RecyclerView.Adapter impl // Delay the loading of the new directory to give a little bit of time for UI feedback // to happen. Hacky, but good enough for now; this is necessary because we're modifying // the RecyclerView's contents, rather than constructing a new one. - view.getHandler().postDelayed(new Runnable() + view.getHandler().postDelayed(() -> { - @Override - public void run() - { - mFileList = fileList; - notifyDataSetChanged(); - mListener.updateSubtitle(path); - } + mFileList = fileList; + notifyDataSetChanged(); + mListener.updateSubtitle(path); }, 200); } } diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/dialogs/GameDetailsDialog.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/dialogs/GameDetailsDialog.java index 10c04778d0..b3dc13de22 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/dialogs/GameDetailsDialog.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/dialogs/GameDetailsDialog.java @@ -68,19 +68,15 @@ public final class GameDetailsDialog extends DialogFragment textCountry.setText(country); textDate.setText(getArguments().getString(ARG_GAME_DATE)); - buttonLaunch.setOnClickListener(new View.OnClickListener() + buttonLaunch.setOnClickListener(view -> { - @Override - public void onClick(View view) - { - // Start the emulation activity and send the path of the clicked ROM to it. - EmulationActivity.launch(getActivity(), - getArguments().getString(ARG_GAME_PATH), - getArguments().getString(ARG_GAME_TITLE), - getArguments().getString(ARG_GAME_SCREENSHOT_PATH), - -1, - imageGameScreen); - } + // Start the emulation activity and send the path of the clicked ROM to it. + EmulationActivity.launch(getActivity(), + getArguments().getString(ARG_GAME_PATH), + getArguments().getString(ARG_GAME_TITLE), + getArguments().getString(ARG_GAME_SCREENSHOT_PATH), + -1, + imageGameScreen); }); // Fill in the view contents. diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/fragments/EmulationFragment.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/fragments/EmulationFragment.java index 263cd597c1..68b7ddad4d 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/fragments/EmulationFragment.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/fragments/EmulationFragment.java @@ -96,14 +96,7 @@ public final class EmulationFragment extends Fragment implements SurfaceHolder.C Button doneButton = contents.findViewById(R.id.done_control_config); if (doneButton != null) { - doneButton.setOnClickListener(new View.OnClickListener() - { - @Override - public void onClick(View v) - { - stopConfiguringControls(); - } - }); + doneButton.setOnClickListener(v -> stopConfiguringControls()); } // The new Surface created here will get passed to the native code via onSurfaceChanged. @@ -327,15 +320,11 @@ public final class EmulationFragment extends Fragment implements SurfaceHolder.C { Log.debug("[EmulationFragment] Starting emulation thread."); - mEmulationThread = new Thread(new Runnable() + mEmulationThread = new Thread(() -> { - @Override - public void run() - { - NativeLibrary.SurfaceChanged(mSurface); - NativeLibrary.Run(mGamePath); - }}, - "NativeEmulation"); + NativeLibrary.SurfaceChanged(mSurface); + NativeLibrary.Run(mGamePath); + }, "NativeEmulation"); mEmulationThread.start(); } diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/model/GameDatabase.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/model/GameDatabase.java index 231665094f..41181f4183 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/model/GameDatabase.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/model/GameDatabase.java @@ -262,32 +262,28 @@ public final class GameDatabase extends SQLiteOpenHelper public Observable getGamesForPlatform(final Platform platform) { - return Observable.create(new Observable.OnSubscribe() + return Observable.create(subscriber -> { - @Override - public void call(Subscriber subscriber) - { - Log.info("[GameDatabase] Reading games list..."); + Log.info("[GameDatabase] Reading games list..."); - String[] whereArgs = new String[]{Integer.toString(platform.toInt())}; + String[] whereArgs = new String[]{Integer.toString(platform.toInt())}; - SQLiteDatabase database = getReadableDatabase(); - Cursor resultCursor = database.query( - TABLE_NAME_GAMES, - null, - KEY_GAME_PLATFORM + " = ?", - whereArgs, - null, - null, - KEY_GAME_TITLE + " ASC" - ); + SQLiteDatabase database = getReadableDatabase(); + Cursor resultCursor = database.query( + TABLE_NAME_GAMES, + null, + KEY_GAME_PLATFORM + " = ?", + whereArgs, + null, + null, + KEY_GAME_TITLE + " ASC" + ); - // Pass the result cursor to the consumer. - subscriber.onNext(resultCursor); + // Pass the result cursor to the consumer. + subscriber.onNext(resultCursor); - // Tell the consumer we're done; it will unsubscribe implicitly. - subscriber.onCompleted(); - } + // Tell the consumer we're done; it will unsubscribe implicitly. + subscriber.onCompleted(); }); } diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/main/MainActivity.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/main/MainActivity.java index 7c9fa225b1..38c478480c 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/main/MainActivity.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/main/MainActivity.java @@ -52,14 +52,7 @@ public final class MainActivity extends AppCompatActivity implements MainView mTabLayout.setupWithViewPager(mViewPager); // Set up the FAB. - mFab.setOnClickListener(new View.OnClickListener() - { - @Override - public void onClick(View view) - { - mPresenter.onFabClick(); - } - }); + mFab.setOnClickListener(view -> mPresenter.onFabClick()); mPresenter.onCreate(); diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/main/MainPresenter.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/main/MainPresenter.java index de9796243b..57ee61baef 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/main/MainPresenter.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/main/MainPresenter.java @@ -96,14 +96,6 @@ public final class MainPresenter databaseHelper.getGamesForPlatform(platform) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) - .subscribe(new Action1() - { - @Override - public void call(Cursor games) - { - mView.showGames(platform, games); - } - } - ); + .subscribe(games -> mView.showGames(platform, games)); } } diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/main/TvMainActivity.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/main/TvMainActivity.java index 383b30aeba..6e4dfa6063 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/main/TvMainActivity.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/main/TvMainActivity.java @@ -71,31 +71,27 @@ public final class TvMainActivity extends FragmentActivity implements MainView buildRowsAdapter(); mBrowseFragment.setOnItemViewClickedListener( - new OnItemViewClickedListener() - { - @Override - public void onItemClicked(Presenter.ViewHolder itemViewHolder, Object item, RowPresenter.ViewHolder rowViewHolder, Row row) - { - // Special case: user clicked on a settings row item. - if (item instanceof TvSettingsItem) - { - TvSettingsItem settingsItem = (TvSettingsItem) item; - mPresenter.handleOptionSelection(settingsItem.getItemId()); - } - else - { - TvGameViewHolder holder = (TvGameViewHolder) itemViewHolder; + (itemViewHolder, item, rowViewHolder, row) -> + { + // Special case: user clicked on a settings row item. + if (item instanceof TvSettingsItem) + { + TvSettingsItem settingsItem = (TvSettingsItem) item; + mPresenter.handleOptionSelection(settingsItem.getItemId()); + } + else + { + TvGameViewHolder holder = (TvGameViewHolder) itemViewHolder; - // Start the emulation activity and send the path of the clicked ISO to it. - EmulationActivity.launch(TvMainActivity.this, - holder.path, - holder.title, - holder.screenshotPath, - -1, - holder.imageScreenshot); - } - } - }); + // Start the emulation activity and send the path of the clicked ISO to it. + EmulationActivity.launch(TvMainActivity.this, + holder.path, + holder.title, + holder.screenshotPath, + -1, + holder.imageScreenshot); + } + }); } /** * MainView diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/platform/PlatformGamesPresenter.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/platform/PlatformGamesPresenter.java index 3320943643..4c6782dd5f 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/platform/PlatformGamesPresenter.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/platform/PlatformGamesPresenter.java @@ -47,15 +47,11 @@ public final class PlatformGamesPresenter databaseHelper.getGamesForPlatform(mPlatform) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) - .subscribe(new Action1() + .subscribe(games -> { - @Override - public void call(Cursor games) - { - Log.debug("[PlatformGamesPresenter] " + mPlatform + ": Load finished, swapping cursor..."); + Log.debug("[PlatformGamesPresenter] " + mPlatform + ": Load finished, swapping cursor..."); - mView.showGames(games); - } + mView.showGames(games); }); } } diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/settings/SettingsAdapter.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/settings/SettingsAdapter.java index 930abb1fb1..f27210111a 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/settings/SettingsAdapter.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/settings/SettingsAdapter.java @@ -201,34 +201,26 @@ public final class SettingsAdapter extends RecyclerView.Adapter { - @Override - public void onClick(DialogInterface dialogInterface, int i) - { - item.setValue(""); + item.setValue(""); - SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(mContext); - SharedPreferences.Editor editor = sharedPreferences.edit(); - editor.remove(item.getKey()); - editor.apply(); - } + SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(mContext); + SharedPreferences.Editor editor = sharedPreferences.edit(); + editor.remove(item.getKey()); + editor.apply(); }); - dialog.setOnDismissListener(new AlertDialog.OnDismissListener() + dialog.setOnDismissListener(dialog1 -> { - @Override - public void onDismiss(DialogInterface dialog) + StringSetting setting = new StringSetting(item.getKey(), item.getSection(), item.getFile(), item.getValue()); + notifyItemChanged(position); + + if (setting != null) { - StringSetting setting = new StringSetting(item.getKey(), item.getSection(), item.getFile(), item.getValue()); - notifyItemChanged(position); - - if (setting != null) - { - mView.putSetting(setting); - } - - mView.onSettingChanged(); + mView.putSetting(setting); } + + mView.onSettingChanged(); }); dialog.setCanceledOnTouchOutside(false); dialog.show(); diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/utils/Java_GCAdapter.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/utils/Java_GCAdapter.java index 91e2a9ca46..e12180be7a 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/utils/Java_GCAdapter.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/utils/Java_GCAdapter.java @@ -137,14 +137,7 @@ public class Java_GCAdapter { final Activity emulationActivity = NativeLibrary.sEmulationActivity.get(); if (emulationActivity != null) { - emulationActivity.runOnUiThread(new Runnable() - { - @Override - public void run() - { - Toast.makeText(emulationActivity, "GameCube Adapter couldn't be opened. Please re-plug the device.", Toast.LENGTH_LONG).show(); - } - }); + emulationActivity.runOnUiThread(() -> Toast.makeText(emulationActivity, "GameCube Adapter couldn't be opened. Please re-plug the device.", Toast.LENGTH_LONG).show()); } else { diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/utils/PermissionsHandler.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/utils/PermissionsHandler.java index ceca9e4195..e569df112a 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/utils/PermissionsHandler.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/utils/PermissionsHandler.java @@ -27,13 +27,8 @@ public class PermissionsHandler { if (hasWritePermission != PackageManager.PERMISSION_GRANTED) { if (activity.shouldShowRequestPermissionRationale(WRITE_EXTERNAL_STORAGE)) { showMessageOKCancel(activity, activity.getString(R.string.write_permission_needed), - new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - activity.requestPermissions(new String[] {WRITE_EXTERNAL_STORAGE}, - REQUEST_CODE_WRITE_PERMISSION); - } - }); + (dialog, which) -> activity.requestPermissions(new String[] {WRITE_EXTERNAL_STORAGE}, + REQUEST_CODE_WRITE_PERMISSION)); return false; } @@ -58,13 +53,8 @@ public class PermissionsHandler { new AlertDialog.Builder(activity) .setMessage(message) .setPositiveButton(android.R.string.ok, okListener) - .setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialogInterface, int i) { - Toast.makeText(activity, R.string.write_permission_needed, Toast.LENGTH_SHORT) - .show(); - } - }) + .setNegativeButton(android.R.string.cancel, (dialogInterface, i) -> + Toast.makeText(activity, R.string.write_permission_needed, Toast.LENGTH_SHORT).show()) .create() .show(); }