optimize KoltinEx,MultiTypeAdapter

androidx
Zhanty 5 years ago
parent 29cd0754d3
commit 6cebfeea96
  1. 6
      lib_base/src/main/java/com/android/base/adapter/recycler/MultiTypeAdapter.java
  2. 2
      lib_base/src/main/java/com/android/base/kotlin/MenuEx.kt
  3. 29
      lib_base/src/main/java/com/android/base/kotlin/RecyclerViewEx.kt

@ -15,7 +15,7 @@ import me.drakeet.multitype.TypePool;
*/ */
public class MultiTypeAdapter extends me.drakeet.multitype.MultiTypeAdapter implements DataManager<Object> { public class MultiTypeAdapter extends me.drakeet.multitype.MultiTypeAdapter implements DataManager<Object> {
protected final Context mContext; private final Context mContext;
private RecyclerDataManagerImpl<Object> mRecyclerDataManager; private RecyclerDataManagerImpl<Object> mRecyclerDataManager;
@ -163,4 +163,8 @@ public class MultiTypeAdapter extends me.drakeet.multitype.MultiTypeAdapter impl
mRecyclerDataManager.setDataSource(objects, true); mRecyclerDataManager.setDataSource(objects, true);
} }
public Context getContext() {
return mContext;
}
} }

@ -31,7 +31,7 @@ fun MenuItem.alwaysShow(): MenuItem {
return this return this
} }
fun MenuItem.setSimpleClickListener(onClick: (MenuItem) -> Unit): MenuItem { fun MenuItem.onMenuItemClick(onClick: (MenuItem) -> Unit): MenuItem {
setOnMenuItemClickListener { setOnMenuItemClickListener {
onClick(it) onClick(it)
true true

@ -1,29 +0,0 @@
package com.android.base.kotlin
import android.support.v7.widget.GridLayoutManager
import android.support.v7.widget.LinearLayoutManager
import android.support.v7.widget.RecyclerView
fun RecyclerView.verticalLinearLayoutManager(): LinearLayoutManager {
val linearLayoutManager = LinearLayoutManager(context)
layoutManager = linearLayoutManager
return linearLayoutManager
}
fun RecyclerView.horizontalLinearlLayoutManager(): LinearLayoutManager {
val linearLayoutManager = LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false)
layoutManager = linearLayoutManager
return linearLayoutManager
}
fun RecyclerView.verticalLinearLayoutManager(span: Int): GridLayoutManager {
val gridLayoutManager = GridLayoutManager(context, span)
layoutManager = gridLayoutManager
return gridLayoutManager
}
fun RecyclerView.horizontalLinearlLayoutManager(span: Int): GridLayoutManager {
val gridLayoutManager = GridLayoutManager(context, span, GridLayoutManager.HORIZONTAL, false)
layoutManager = gridLayoutManager
return gridLayoutManager
}
Loading…
Cancel
Save