summaryrefslogtreecommitdiff
path: root/Source/Android
diff options
context:
space:
mode:
authorCharles Lombardo <clombardo169@gmail.com>2023-06-10 05:18:37 -0400
committerCharles Lombardo <clombardo169@gmail.com>2023-08-25 14:20:33 -0400
commit6caa4307ac11f57ea4dcf41ea7d16d7029fa3800 (patch)
tree203c0dce96b193982d92e3c5dd663a5c7d3e57a2 /Source/Android
parent29e5c78541bac86a126a1c35895ef8411566c7ed (diff)
Android: Convert ProfileViewHolder to Kotlin
Diffstat (limited to 'Source/Android')
-rw-r--r--Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/input/ui/ProfileViewHolder.java76
-rw-r--r--Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/input/ui/ProfileViewHolder.kt56
2 files changed, 56 insertions, 76 deletions
diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/input/ui/ProfileViewHolder.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/input/ui/ProfileViewHolder.java
deleted file mode 100644
index d4d40c0c65..0000000000
--- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/input/ui/ProfileViewHolder.java
+++ /dev/null
@@ -1,76 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-or-later
-
-package org.dolphinemu.dolphinemu.features.input.ui;
-
-import android.content.Context;
-import android.view.View;
-
-import androidx.annotation.NonNull;
-import androidx.recyclerview.widget.RecyclerView;
-
-import org.dolphinemu.dolphinemu.R;
-import org.dolphinemu.dolphinemu.databinding.ListItemProfileBinding;
-
-public class ProfileViewHolder extends RecyclerView.ViewHolder
-{
- private final ProfileDialogPresenter mPresenter;
- private final ListItemProfileBinding mBinding;
-
- private String mProfileName;
- private boolean mStock;
-
- public ProfileViewHolder(@NonNull ProfileDialogPresenter presenter,
- @NonNull ListItemProfileBinding binding)
- {
- super(binding.getRoot());
-
- mPresenter = presenter;
- mBinding = binding;
-
- binding.buttonLoad.setOnClickListener(view -> loadProfile());
- binding.buttonSave.setOnClickListener(view -> saveProfile());
- binding.buttonDelete.setOnClickListener(view -> deleteProfile());
- }
-
- public void bind(String profileName, boolean stock)
- {
- mProfileName = profileName;
- mStock = stock;
-
- mBinding.textName.setText(profileName);
-
- mBinding.buttonLoad.setVisibility(View.VISIBLE);
- mBinding.buttonSave.setVisibility(stock ? View.GONE : View.VISIBLE);
- mBinding.buttonDelete.setVisibility(stock ? View.GONE : View.VISIBLE);
- }
-
- public void bindAsEmpty(Context context)
- {
- mProfileName = null;
- mStock = false;
-
- mBinding.textName.setText(context.getText(R.string.input_profile_new));
-
- mBinding.buttonLoad.setVisibility(View.GONE);
- mBinding.buttonSave.setVisibility(View.VISIBLE);
- mBinding.buttonDelete.setVisibility(View.GONE);
- }
-
- private void loadProfile()
- {
- mPresenter.loadProfile(mProfileName, mStock);
- }
-
- private void saveProfile()
- {
- if (mProfileName == null)
- mPresenter.saveProfileAndPromptForName();
- else
- mPresenter.saveProfile(mProfileName);
- }
-
- private void deleteProfile()
- {
- mPresenter.deleteProfile(mProfileName);
- }
-}
diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/input/ui/ProfileViewHolder.kt b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/input/ui/ProfileViewHolder.kt
new file mode 100644
index 0000000000..671461c9aa
--- /dev/null
+++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/input/ui/ProfileViewHolder.kt
@@ -0,0 +1,56 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+package org.dolphinemu.dolphinemu.features.input.ui
+
+import android.content.Context
+import android.view.View
+import androidx.recyclerview.widget.RecyclerView
+import org.dolphinemu.dolphinemu.R
+import org.dolphinemu.dolphinemu.databinding.ListItemProfileBinding
+
+class ProfileViewHolder(
+ private val presenter: ProfileDialogPresenter,
+ private val binding: ListItemProfileBinding
+) : RecyclerView.ViewHolder(binding.getRoot()) {
+ private var profileName: String? = null
+ private var stock = false
+
+ init {
+ binding.buttonLoad.setOnClickListener { loadProfile() }
+ binding.buttonSave.setOnClickListener { saveProfile() }
+ binding.buttonDelete.setOnClickListener { deleteProfile() }
+ }
+
+ fun bind(profileName: String, stock: Boolean) {
+ this.profileName = profileName
+ this.stock = stock
+
+ binding.textName.text = profileName
+
+ binding.buttonLoad.visibility = View.VISIBLE
+ binding.buttonSave.visibility = if (stock) View.GONE else View.VISIBLE
+ binding.buttonDelete.visibility = if (stock) View.GONE else View.VISIBLE
+ }
+
+ fun bindAsEmpty(context: Context) {
+ profileName = null
+ stock = false
+
+ binding.textName.text = context.getText(R.string.input_profile_new)
+
+ binding.buttonLoad.visibility = View.GONE
+ binding.buttonSave.visibility = View.VISIBLE
+ binding.buttonDelete.visibility = View.GONE
+ }
+
+ private fun loadProfile() = presenter.loadProfile(profileName!!, stock)
+
+ private fun saveProfile() {
+ if (profileName == null)
+ presenter.saveProfileAndPromptForName()
+ else
+ presenter.saveProfile(profileName!!)
+ }
+
+ private fun deleteProfile() = presenter.deleteProfile(profileName!!)
+}