Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Merge pull request #9154 from Ebola16/RR
Android: ConfirmRunnable to RunRunnable with optional confirmation
- Loading branch information
Showing
6 changed files
with
110 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
82 changes: 0 additions & 82 deletions
82
.../org/dolphinemu/dolphinemu/features/settings/ui/viewholder/ConfirmRunnableViewHolder.java
This file was deleted.
Oops, something went wrong.
88 changes: 88 additions & 0 deletions
88
...java/org/dolphinemu/dolphinemu/features/settings/ui/viewholder/RunRunnableViewHolder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| package org.dolphinemu.dolphinemu.features.settings.ui.viewholder; | ||
|
|
||
| import android.content.Context; | ||
| import android.view.View; | ||
| import android.widget.TextView; | ||
| import android.widget.Toast; | ||
|
|
||
| import androidx.appcompat.app.AlertDialog; | ||
|
|
||
| import org.dolphinemu.dolphinemu.R; | ||
| import org.dolphinemu.dolphinemu.features.settings.model.view.RunRunnable; | ||
| import org.dolphinemu.dolphinemu.features.settings.model.view.SettingsItem; | ||
| import org.dolphinemu.dolphinemu.features.settings.ui.SettingsAdapter; | ||
|
|
||
| public final class RunRunnableViewHolder extends SettingViewHolder | ||
| { | ||
| private RunRunnable mItem; | ||
|
|
||
| private final Context mContext; | ||
|
|
||
| private TextView mTextSettingName; | ||
| private TextView mTextSettingDescription; | ||
|
|
||
| public RunRunnableViewHolder(View itemView, SettingsAdapter adapter, Context context) | ||
| { | ||
| super(itemView, adapter); | ||
|
|
||
| mContext = context; | ||
| } | ||
|
|
||
| @Override | ||
| protected void findViews(View root) | ||
| { | ||
| mTextSettingName = root.findViewById(R.id.text_setting_name); | ||
| mTextSettingDescription = root.findViewById(R.id.text_setting_description); | ||
| } | ||
|
|
||
| @Override | ||
| public void bind(SettingsItem item) | ||
| { | ||
| mItem = (RunRunnable) item; | ||
|
|
||
| mTextSettingName.setText(item.getNameId()); | ||
|
|
||
| if (item.getDescriptionId() > 0) | ||
| { | ||
| mTextSettingDescription.setText(item.getDescriptionId()); | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| public void onClick(View clicked) | ||
| { | ||
| int alertTextID = mItem.getAlertText(); | ||
|
|
||
| if (alertTextID > 0) | ||
| { | ||
| AlertDialog.Builder builder = new AlertDialog.Builder(mContext, R.style.DolphinDialogBase) | ||
| .setTitle(mContext.getString(mItem.getNameId())) | ||
| .setMessage(mContext.getString(alertTextID)); | ||
|
|
||
| builder | ||
| .setPositiveButton(R.string.ok, (dialog, whichButton) -> | ||
| { | ||
| runRunnable(); | ||
| dialog.dismiss(); | ||
| }) | ||
| .setNegativeButton(R.string.cancel, (dialog, whichButton) -> dialog.dismiss()); | ||
|
|
||
| builder.show(); | ||
| } | ||
| else | ||
| { | ||
| runRunnable(); | ||
| } | ||
| } | ||
|
|
||
| private void runRunnable() | ||
| { | ||
| mItem.getRunnable().run(); | ||
|
|
||
| if (mItem.getToastTextAfterRun() > 0) | ||
| { | ||
| Toast.makeText(mContext, mContext.getString(mItem.getToastTextAfterRun()), Toast.LENGTH_SHORT) | ||
| .show(); | ||
| } | ||
| } | ||
| } |