From 6cebfeea9668b27e95b54358900ba39e6836a979 Mon Sep 17 00:00:00 2001 From: Zhanty Date: Wed, 17 Jul 2019 18:38:45 +0800 Subject: [PATCH] optimize KoltinEx,MultiTypeAdapter --- .../adapter/recycler/MultiTypeAdapter.java | 6 +++- .../java/com/android/base/kotlin/MenuEx.kt | 2 +- .../com/android/base/kotlin/RecyclerViewEx.kt | 29 ------------------- 3 files changed, 6 insertions(+), 31 deletions(-) delete mode 100644 lib_base/src/main/java/com/android/base/kotlin/RecyclerViewEx.kt diff --git a/lib_base/src/main/java/com/android/base/adapter/recycler/MultiTypeAdapter.java b/lib_base/src/main/java/com/android/base/adapter/recycler/MultiTypeAdapter.java index d29f4d7..7571c1a 100644 --- a/lib_base/src/main/java/com/android/base/adapter/recycler/MultiTypeAdapter.java +++ b/lib_base/src/main/java/com/android/base/adapter/recycler/MultiTypeAdapter.java @@ -15,7 +15,7 @@ import me.drakeet.multitype.TypePool; */ public class MultiTypeAdapter extends me.drakeet.multitype.MultiTypeAdapter implements DataManager { - protected final Context mContext; + private final Context mContext; private RecyclerDataManagerImpl mRecyclerDataManager; @@ -163,4 +163,8 @@ public class MultiTypeAdapter extends me.drakeet.multitype.MultiTypeAdapter impl mRecyclerDataManager.setDataSource(objects, true); } + public Context getContext() { + return mContext; + } + } \ No newline at end of file diff --git a/lib_base/src/main/java/com/android/base/kotlin/MenuEx.kt b/lib_base/src/main/java/com/android/base/kotlin/MenuEx.kt index 6ce25af..2601519 100644 --- a/lib_base/src/main/java/com/android/base/kotlin/MenuEx.kt +++ b/lib_base/src/main/java/com/android/base/kotlin/MenuEx.kt @@ -31,7 +31,7 @@ fun MenuItem.alwaysShow(): MenuItem { return this } -fun MenuItem.setSimpleClickListener(onClick: (MenuItem) -> Unit): MenuItem { +fun MenuItem.onMenuItemClick(onClick: (MenuItem) -> Unit): MenuItem { setOnMenuItemClickListener { onClick(it) true diff --git a/lib_base/src/main/java/com/android/base/kotlin/RecyclerViewEx.kt b/lib_base/src/main/java/com/android/base/kotlin/RecyclerViewEx.kt deleted file mode 100644 index fcfcfb1..0000000 --- a/lib_base/src/main/java/com/android/base/kotlin/RecyclerViewEx.kt +++ /dev/null @@ -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 -} \ No newline at end of file