mirror of
https://github.com/yuzu-emu/yuzu.git
synced 2024-08-24 05:07:29 +02:00
android: Convert SettingViewHolder to Kotlin
This commit is contained in:
parent
d472f41580
commit
c42eb92557
@ -1,49 +0,0 @@
|
|||||||
package org.yuzu.yuzu_emu.features.settings.ui.viewholder;
|
|
||||||
|
|
||||||
import android.view.View;
|
|
||||||
|
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
|
||||||
|
|
||||||
import org.yuzu.yuzu_emu.features.settings.model.view.SettingsItem;
|
|
||||||
import org.yuzu.yuzu_emu.features.settings.ui.SettingsAdapter;
|
|
||||||
|
|
||||||
public abstract class SettingViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
|
|
||||||
private SettingsAdapter mAdapter;
|
|
||||||
|
|
||||||
public SettingViewHolder(View itemView, SettingsAdapter adapter) {
|
|
||||||
super(itemView);
|
|
||||||
|
|
||||||
mAdapter = adapter;
|
|
||||||
|
|
||||||
itemView.setOnClickListener(this);
|
|
||||||
|
|
||||||
findViews(itemView);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected SettingsAdapter getAdapter() {
|
|
||||||
return mAdapter;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets handles to all this ViewHolder's child views using their XML-defined identifiers.
|
|
||||||
*
|
|
||||||
* @param root The newly inflated top-level view.
|
|
||||||
*/
|
|
||||||
protected abstract void findViews(View root);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called by the adapter to set this ViewHolder's child views to display the list item
|
|
||||||
* it must now represent.
|
|
||||||
*
|
|
||||||
* @param item The list item that should be represented by this ViewHolder.
|
|
||||||
*/
|
|
||||||
public abstract void bind(SettingsItem item);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called when this ViewHolder's view is clicked on. Implementations should usually pass
|
|
||||||
* this event up to the adapter.
|
|
||||||
*
|
|
||||||
* @param clicked The view that was clicked on.
|
|
||||||
*/
|
|
||||||
public abstract void onClick(View clicked);
|
|
||||||
}
|
|
@ -0,0 +1,38 @@
|
|||||||
|
package org.yuzu.yuzu_emu.features.settings.ui.viewholder
|
||||||
|
|
||||||
|
import android.view.View
|
||||||
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
|
import org.yuzu.yuzu_emu.features.settings.model.view.SettingsItem
|
||||||
|
import org.yuzu.yuzu_emu.features.settings.ui.SettingsAdapter
|
||||||
|
|
||||||
|
abstract class SettingViewHolder(itemView: View, protected val adapter: SettingsAdapter) :
|
||||||
|
RecyclerView.ViewHolder(itemView), View.OnClickListener {
|
||||||
|
|
||||||
|
init {
|
||||||
|
itemView.setOnClickListener(this)
|
||||||
|
findViews(itemView)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets handles to all this ViewHolder's child views using their XML-defined identifiers.
|
||||||
|
*
|
||||||
|
* @param root The newly inflated top-level view.
|
||||||
|
*/
|
||||||
|
protected abstract fun findViews(root: View)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called by the adapter to set this ViewHolder's child views to display the list item
|
||||||
|
* it must now represent.
|
||||||
|
*
|
||||||
|
* @param item The list item that should be represented by this ViewHolder.
|
||||||
|
*/
|
||||||
|
abstract fun bind(item: SettingsItem)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when this ViewHolder's view is clicked on. Implementations should usually pass
|
||||||
|
* this event up to the adapter.
|
||||||
|
*
|
||||||
|
* @param clicked The view that was clicked on.
|
||||||
|
*/
|
||||||
|
abstract override fun onClick(clicked: View)
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user