This file contains hidden or 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
class UniversalAdapter<T, VH : RecyclerView.ViewHolder>( | |
private val onCreateViewHolder: (ViewGroup?, Int) -> VH, | |
private val onBindViewHolder: (VH, Int, T) -> Unit, | |
private val onViewType: ((Int) -> Int)? = null) : RecyclerView.Adapter<VH>(), | |
Universal<T> { | |
var items = mutableListOf<T>() | |
private set | |
override fun onCreateViewHolder(parent: ViewGroup?, viewType: Int): VH = |
This file contains hidden or 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
override fun setupView(view: View?) { | |
safeWith(arguments) { arguments -> | |
safeWitCouple(zoo, arguments.getParcelable(ZOO), poo, arguments.getParcelable(POO)) { zoo, poo, fromIntent -> | |
[email protected] = zoo as World.Zoo | |
[email protected] = poo as World.Poo | |
if (fromIntent) { | |
arguments.remove(ZOO) | |
arguments.remove(POO) | |
} |
This file contains hidden or 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
class FooPresenter(private val dataSource: DataSource?) : BasePresenter<FooPresenter.View> { | |
fun push(data: Bar){ | |
dataSource?.push("someKey", data) | |
} | |
fun peek() : Bar { | |
return dataSource?.peek<Bar>("someKey") | |
} | |
} |
This file contains hidden or 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
class FooFragment : BaseFragment<FooPresenter.View, FooPresenter>() { | |
companion object { | |
fun newInstance(data: Bar): FooFragment { | |
val fragment = FooFragment() | |
val bundle = Bundle() | |
bundle.putParcelable("bar", data) | |
fragment.arguments = bundle | |
return fragment | |
} | |
} |
This file contains hidden or 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
interface DataSourceBase | |
class DataSource { | |
companion object { | |
private var sInstance: DataSource? = null | |
private var LOCK = Any() | |
fun getInstance(): DataSource? { | |
synchronized(LOCK) { | |
if (sInstance == null) { |
NewerOlder