diff --git a/lib_base/src/main/java/com/android/base/adapter/recycler/ItemViewBinder.kt b/lib_base/src/main/java/com/android/base/adapter/recycler/ItemViewBinder.kt index 3b85ca3..d67b5b1 100644 --- a/lib_base/src/main/java/com/android/base/adapter/recycler/ItemViewBinder.kt +++ b/lib_base/src/main/java/com/android/base/adapter/recycler/ItemViewBinder.kt @@ -26,9 +26,13 @@ abstract class SimpleItemViewBinder : ItemViewBinder() { inflater.inflate(layout, parent, false) } else layout as View - return KtViewHolder(itemView) + return KtViewHolder(itemView).apply { + onViewHolderCreated(this) + } } + protected open fun onViewHolderCreated(viewHolder: KtViewHolder) = Unit + /**provide a layout id or a View*/ abstract fun provideLayout(inflater: LayoutInflater, parent: ViewGroup): Any diff --git a/lib_base/src/main/java/com/android/base/kotlin/Collections.kt b/lib_base/src/main/java/com/android/base/kotlin/Collections.kt new file mode 100644 index 0000000..8f33905 --- /dev/null +++ b/lib_base/src/main/java/com/android/base/kotlin/Collections.kt @@ -0,0 +1,7 @@ +package com.android.base.kotlin + +import com.android.base.utils.common.CollectionUtils + +fun List?.toArrayList(): ArrayList { + return CollectionUtils.toArrayList(this) +} \ No newline at end of file diff --git a/lib_base/src/main/java/com/android/base/kotlin/SizeEx.kt b/lib_base/src/main/java/com/android/base/kotlin/SizeEx.kt index b99dc04..a555455 100644 --- a/lib_base/src/main/java/com/android/base/kotlin/SizeEx.kt +++ b/lib_base/src/main/java/com/android/base/kotlin/SizeEx.kt @@ -1,27 +1,8 @@ package com.android.base.kotlin -import android.content.Context -import android.support.v4.app.Fragment -import android.support.v7.widget.RecyclerView -import android.view.View import com.android.base.utils.android.UnitConverter -fun Context.dip(value: Int): Int = UnitConverter.dpToPx(value) -fun Context.dip(value: Float): Float = UnitConverter.dpToPx(value) -fun Context.sp(value: Int): Int = UnitConverter.spToPx(value) -fun Context.sp(value: Float): Float = UnitConverter.spToPx(value) - -fun Fragment.dip(value: Int): Int = UnitConverter.dpToPx(value) -fun Fragment.dip(value: Float): Float = UnitConverter.dpToPx(value) -fun Fragment.sp(value: Int): Int = UnitConverter.spToPx(value) -fun Fragment.sp(value: Float): Float = UnitConverter.spToPx(value) - -fun View.dip(value: Int): Int = context.dip(value) -fun View.dip(value: Float): Float = context.dip(value) -fun View.sp(value: Int): Int = context.sp(value) -fun View.sp(value: Float): Float = context.sp(value) - -fun RecyclerView.ViewHolder.dip(value: Int): Int = itemView.dip(value) -fun RecyclerView.ViewHolder.dip(value: Float): Float = itemView.dip(value) -fun RecyclerView.ViewHolder.sp(value: Int): Int = itemView.dip(value) -fun RecyclerView.ViewHolder.sp(value: Float): Float = itemView.dip(value) \ No newline at end of file +fun dip(value: Int): Int = UnitConverter.dpToPx(value) +fun dip(value: Float): Float = UnitConverter.dpToPx(value) +fun sp(value: Int): Int = UnitConverter.spToPx(value) +fun sp(value: Float): Float = UnitConverter.spToPx(value) \ No newline at end of file diff --git a/lib_base/src/main/java/com/android/base/utils/common/CollectionUtils.java b/lib_base/src/main/java/com/android/base/utils/common/CollectionUtils.java index 1332c74..e285ca4 100644 --- a/lib_base/src/main/java/com/android/base/utils/common/CollectionUtils.java +++ b/lib_base/src/main/java/com/android/base/utils/common/CollectionUtils.java @@ -1,7 +1,6 @@ package com.android.base.utils.common; import java.util.ArrayList; -import java.util.Collections; import java.util.List; @@ -21,11 +20,4 @@ public class CollectionUtils { return new ArrayList<>(list); } - public static List emptyIfNull(List list) { - if (list == null) { - return Collections.emptyList(); - } - return list; - } - }