> viewHolder) {
mClassHashMap.put(viewType, viewHolder);
}
}
diff --git a/adapter/src/main/java/com/android/jmaxime/interfaces/IAdapterChanged.java b/adapter/src/main/java/com/android/jmaxime/interfaces/IAdapterChanged.java
new file mode 100644
index 0000000..2957ebc
--- /dev/null
+++ b/adapter/src/main/java/com/android/jmaxime/interfaces/IAdapterChanged.java
@@ -0,0 +1,12 @@
+package com.android.jmaxime.interfaces;
+
+/**
+ * @author Maxime Jallu
+ * @since 29/09/2017
+ *
+ * Use this Class for :
+ * {DOCUMENTATION}
+ */
+public interface IAdapterChanged {
+ void onItemCountChange(int count);
+}
diff --git a/adapter/src/main/java/com/android/jmaxime/interfaces/IBaseCommunication.java b/adapter/src/main/java/com/android/jmaxime/interfaces/IBaseCommunication.java
new file mode 100644
index 0000000..f15f7ec
--- /dev/null
+++ b/adapter/src/main/java/com/android/jmaxime/interfaces/IBaseCommunication.java
@@ -0,0 +1,13 @@
+package com.android.jmaxime.interfaces;
+
+
+public interface IBaseCommunication {
+
+ default void onDeleteClicked(int position, T item) {
+ /*nothing*/
+ }
+
+ default void onEditClicked(int position, T item) {
+ /*nothing*/
+ }
+}
diff --git a/adapter/src/main/java/com/android/jmaxime/interfaces/IViewType.java b/adapter/src/main/java/com/android/jmaxime/interfaces/IViewType.java
new file mode 100644
index 0000000..b20fba8
--- /dev/null
+++ b/adapter/src/main/java/com/android/jmaxime/interfaces/IViewType.java
@@ -0,0 +1,12 @@
+package com.android.jmaxime.interfaces;
+
+/**
+ * @author Maxime Jallu
+ * @since 29/09/2017
+ *
+ * Use this Class for :
+ * {DOCUMENTATION}
+ */
+public interface IViewType {
+ int getItemViewType();
+}
diff --git a/adapter/src/main/java/com/android/jmaxime/interfaces/ViewCheckableCallback.java b/adapter/src/main/java/com/android/jmaxime/interfaces/ViewCheckableCallback.java
new file mode 100644
index 0000000..d182bfc
--- /dev/null
+++ b/adapter/src/main/java/com/android/jmaxime/interfaces/ViewCheckableCallback.java
@@ -0,0 +1,19 @@
+package com.android.jmaxime.interfaces;
+
+import android.annotation.SuppressLint;
+
+/**
+ * @author Maxime Jallu
+ * @since 29/09/2017
+ *
+ * Use this Class for :
+ * {DOCUMENTATION}
+ */
+@SuppressLint("NewApi")
+public interface ViewCheckableCallback extends IBaseCommunication {
+ boolean isChecked(T item);
+ default boolean isCheckable(T item) {
+ return true;
+ }
+ void put(String key, boolean value);
+}
diff --git a/adapter/src/main/java/com/android/jmaxime/viewholder/KRecyclerViewHolder.kt b/adapter/src/main/java/com/android/jmaxime/viewholder/KRecyclerViewHolder.kt
deleted file mode 100644
index 03c30d8..0000000
--- a/adapter/src/main/java/com/android/jmaxime/viewholder/KRecyclerViewHolder.kt
+++ /dev/null
@@ -1,103 +0,0 @@
-package com.android.jmaxime.adapter
-
-import android.content.Context
-import android.graphics.drawable.Drawable
-import android.support.annotation.*
-import android.support.v4.content.ContextCompat
-import android.support.v7.widget.RecyclerView
-import android.util.Log
-import android.view.View
-import android.widget.ImageView
-import butterknife.ButterKnife
-import com.android.jmaxime.interfaces.IBaseCommunication
-import com.squareup.picasso.Picasso
-
-/**
- * @author Maxime Jallu
- * *
- * @link ArrayRecyclerAdapter
- * * Tools this class:
- * *
- * * getContext()
- * * getColor(@ColorRes res)
- * * getDrawable(@DrawableRes res)
- * *
- * @since 30/06/2016
- * *
- * * Create for CubeInStore - Android (Decathlon)
- * *
- * * Use this Class for :
- * * make it easier ViewHolder com.android.jmaxime.adapter recyclerView, define T type of item
- * * Must to use in RecyclerAdapter
- */
-abstract class KRecyclerViewHolder constructor(itemView: View) : RecyclerView.ViewHolder(itemView) {
-
- var item: T? = null
- var isBound: Boolean = false
- private var mCommunication: IBaseCommunication? = null
-
- init {
- ButterKnife.bind(this, itemView)
- }
-
- abstract fun bind(item: T)
-
- protected val context: Context get() = itemView.context
-
- protected fun getString(@StringRes stringRes: Int): String {
- return context.getString(stringRes)
- }
-
- protected fun getString(@StringRes stringRes: Int, string: String): String {
- return context.resources.getString(stringRes, string)
- }
-
- protected fun getQuantityString(@PluralsRes pluralRes: Int, quantity: Int): String {
- return context.resources.getQuantityString(pluralRes, quantity, quantity)
- }
-
- protected fun getQuantityStringFormat(@PluralsRes pluralRes: Int, quantity: Int): String {
- return context.resources.getQuantityString(pluralRes, quantity, quantity)
- }
-
- protected fun getColor(@ColorRes colorResId: Int): Int {
- return ContextCompat.getColor(context, colorResId)
- }
-
- protected fun getDrawable(@DrawableRes drawableResId: Int): Drawable {
- return ContextCompat.getDrawable(context, drawableResId)
- }
-
- fun showPicture(picture: ImageView, url: String) {
- Picasso.with(picture.context)
- .load(url)
- .placeholder(R.drawable.ic_image_black_24dp)
- .error(R.drawable.ic_image_black_24dp)
- .fit()
- .centerInside()
- .into(picture)
- }
-
- protected fun onClickRemoveItem() {
- getDispatcher>()?.onDeleteClicked(adapterPosition, item!!)
- }
-
- protected fun onClickEditItem() {
- getDispatcher>()?.onEditClicked(adapterPosition, item!!)
- }
-
- protected fun > getDispatcher(): I? {
- var i: I? = null
- try {
- i = mCommunication as I?
- } catch (e: ClassCastException) {
- Log.e("ViewHolderFactory", "getInterfaceCallback: ", e)
- }
-
- return i
- }
-
- fun setCommunication(interfaceCallback: IBaseCommunication?) {
- mCommunication = interfaceCallback
- }
-}
diff --git a/adapter/src/main/java/com/android/jmaxime/viewholder/JRecyclerViewHolder.java b/adapter/src/main/java/com/android/jmaxime/viewholder/RecyclerViewHolder.java
similarity index 94%
rename from adapter/src/main/java/com/android/jmaxime/viewholder/JRecyclerViewHolder.java
rename to adapter/src/main/java/com/android/jmaxime/viewholder/RecyclerViewHolder.java
index cff531d..d506b78 100644
--- a/adapter/src/main/java/com/android/jmaxime/viewholder/JRecyclerViewHolder.java
+++ b/adapter/src/main/java/com/android/jmaxime/viewholder/RecyclerViewHolder.java
@@ -34,10 +34,10 @@
* Create for CubeInStore - Android (Decathlon)
*
* Use this Class for :
- * make it easier ViewHolder com.android.jmaxime.adapter recyclerView, define T type of item
+ * make it easier ViewHolder adapter recyclerView, define T type of item
* Must to use in ArrayRecyclerAdapter
*/
-public abstract class JRecyclerViewHolder extends RecyclerView.ViewHolder {
+public abstract class RecyclerViewHolder extends RecyclerView.ViewHolder {
private T mItem;
private boolean isBound;
@@ -52,7 +52,7 @@ public abstract class JRecyclerViewHolder extends RecyclerView.ViewHolder {
* @param itemView the Views holder
*/
@SuppressLint("NewApi")
- public JRecyclerViewHolder(View itemView) {
+ public RecyclerViewHolder(View itemView) {
super(itemView);
ButterKnife.bind(this, itemView);
}
@@ -136,3 +136,4 @@ public void setCommunication(IBaseCommunication interfaceCallback) {
mCommunication = interfaceCallback;
}
}
+
diff --git a/adapter/src/main/kotlin/com/android/jmaxime/adapters/ArrayRecyclerAdapter.kt b/adapter/src/main/kotlin/com/android/jmaxime/adapters/ArrayRecyclerAdapter.kt
deleted file mode 100644
index 2455df2..0000000
--- a/adapter/src/main/kotlin/com/android/jmaxime/adapters/ArrayRecyclerAdapter.kt
+++ /dev/null
@@ -1,51 +0,0 @@
-package com.android.jmaxime.adapter
-
-import android.support.v7.widget.RecyclerView
-
-/**
- * @author Maxime Jallu
- * @since 30/06/2016
- *
- * Create for CubeInStore - Android
- *
- * Use this Class for :
- * Crée un adapteur de recycler view de base
- * @param Type d'item de la liste
- * @param Type de ViewHolder doit extends de RecyclerViewHolder
- **/
-abstract class ArrayRecyclerAdapter>(TList: List) : RecyclerView.Adapter() {
-
- var tList: List? = null
- private set
-
- init {
- tList = TList
- }
-
- override fun onBindViewHolder(holder: U, position: Int) {
- holder.bind(getItem(position))
- }
-
- override fun getItemCount(): Int {
- return tList!!.size
- }
-
- /**
- * Get Item
- * @param position position founded
- * @return instance to position
- */
- fun getItem(position: Int): T {
- return tList!![position]
- }
-
- /**
- * Set new list items and notifyDataSetChanged()
- * @link notifyDataSetChanged
- * @param list new instance items list for bind views
- */
- fun updateItems(list: List) {
- tList = list
- notifyDataSetChanged()
- }
-}
diff --git a/adapter/src/main/kotlin/com/android/jmaxime/adapters/DividerItemDecoration.kt b/adapter/src/main/kotlin/com/android/jmaxime/adapters/DividerItemDecoration.kt
deleted file mode 100644
index 47cb619..0000000
--- a/adapter/src/main/kotlin/com/android/jmaxime/adapters/DividerItemDecoration.kt
+++ /dev/null
@@ -1,99 +0,0 @@
-package com.android.jmaxime.adapter
-
-import android.content.Context
-import android.content.res.TypedArray
-import android.graphics.Canvas
-import android.graphics.Rect
-import android.graphics.drawable.Drawable
-import android.support.v7.widget.LinearLayoutManager
-import android.support.v7.widget.RecyclerView
-import android.view.View
-
-/**
- * @author Maxime Jallu
- * @since 30/09/2016
- *
- *
- * Create for - Android
- *
- *
- * Use this Class for :
- * ... {DOCUMENTATION}
- */
-class DividerItemDecoration(context: Context, orientation: Int) : RecyclerView.ItemDecoration() {
-
- private val mDivider: Drawable?
-
- private var mOrientation: Int = 0
-
- init {
- val a = context.obtainStyledAttributes(ATTRS)
- mDivider = a.getDrawable(0)
- a.recycle()
- setOrientation(orientation)
- }
-
- fun setOrientation(orientation: Int) {
- if (orientation != HORIZONTAL_LIST && orientation != VERTICAL_LIST) {
- throw IllegalArgumentException("invalid orientation")
- }
- mOrientation = orientation
- }
-
- override fun onDraw(c: Canvas?, parent: RecyclerView?) {
- if (mOrientation == VERTICAL_LIST) {
- drawVertical(c, parent)
- } else {
- drawHorizontal(c, parent)
- }
- }
-
- fun drawVertical(c: Canvas?, parent: RecyclerView?) {
- val left = parent!!.paddingLeft
- val right = parent.width - parent.paddingRight
-
- val childCount = parent.childCount
- for (i in 0..childCount - 1) {
- val child = parent.getChildAt(i)
- val params = child
- .layoutParams as RecyclerView.LayoutParams
- val top = child.bottom + params.bottomMargin
- val bottom = top + mDivider!!.intrinsicHeight
- mDivider.setBounds(left, top, right, bottom)
- mDivider.draw(c!!)
- }
- }
-
- fun drawHorizontal(c: Canvas?, parent: RecyclerView?) {
- val top = parent!!.paddingTop
- val bottom = parent.height - parent.paddingBottom
-
- val childCount = parent.childCount
- for (i in 0..childCount - 1) {
- val child = parent.getChildAt(i)
- val params = child
- .layoutParams as RecyclerView.LayoutParams
- val left = child.right + params.rightMargin
- val right = left + mDivider!!.intrinsicHeight
- mDivider.setBounds(left, top, right, bottom)
- mDivider.draw(c!!)
- }
- }
-
- override fun getItemOffsets(outRect: Rect, view: View, parent: RecyclerView, state: RecyclerView.State?) {
- if (mOrientation == VERTICAL_LIST) {
- outRect.set(0, 0, 0, mDivider!!.intrinsicHeight)
- } else {
- outRect.set(0, 0, mDivider!!.intrinsicWidth, 0)
- }
- }
-
- companion object {
-
- private val ATTRS = intArrayOf(android.R.attr.listDivider)
-
- val HORIZONTAL_LIST = LinearLayoutManager.HORIZONTAL
-
- val VERTICAL_LIST = LinearLayoutManager.VERTICAL
- }
-}
diff --git a/adapter/src/main/kotlin/com/android/jmaxime/adapters/RecyclerAdapter.kt b/adapter/src/main/kotlin/com/android/jmaxime/adapters/RecyclerAdapter.kt
deleted file mode 100644
index 403e274..0000000
--- a/adapter/src/main/kotlin/com/android/jmaxime/adapters/RecyclerAdapter.kt
+++ /dev/null
@@ -1,187 +0,0 @@
-package com.android.jmaxime.adapter
-
-import android.support.v7.widget.RecyclerView
-import android.view.ViewGroup
-import com.android.jmaxime.factory.ViewHolderFactory
-import com.android.jmaxime.interfaces.IAdapterChanged
-import com.android.jmaxime.interfaces.IBaseCommunication
-import com.android.jmaxime.interfaces.IViewType
-import java.security.AccessControlException
-import java.util.*
-
-/**
- * @author Maxime Jallu
- * @since 03/05/2017
- * Use this Class for :
- * ... {DOCUMENTATION}
- */
-class RecyclerAdapter : RecyclerView.Adapter> {
-
- private var mTList: MutableList? = null
- private var mFactory: ViewHolderFactory? = null
- private var mAdapterChanged: IAdapterChanged? = null
-
- constructor() {
- mTList = ArrayList()
- }
-
- constructor(factory: ViewHolderFactory) : this(ArrayList(), factory, null) {}
-
- constructor(viewHolderType: Class>) : this(ArrayList(), viewHolderType, null) {}
-
- constructor(viewHolderType: Class>, callback: IBaseCommunication?) : this(ArrayList(), viewHolderType, callback) {}
-
- @JvmOverloads constructor(TList: MutableList, viewHolderType: Class>, callback: IBaseCommunication? = null) : this(TList, ViewHolderFactory(viewHolderType), callback) {}
-
- constructor(TList: MutableList, factory: ViewHolderFactory, callback: IBaseCommunication?) {
- mTList = TList
- mFactory = factory
- mFactory!!.communication = callback
- }
-
- fun setFactory(factory: ViewHolderFactory) {
- mFactory = factory
- }
-
- override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): KRecyclerViewHolder? {
- if (mFactory == null) {
- throw AccessControlException("mFactory is not instancied. thanks use setFactory() method.")
- }
-
- return mFactory!!.createVH(parent, viewType)
- }
-
-
- override fun onBindViewHolder(holder: KRecyclerViewHolder, position: Int) {
- holder.item = getItem(position)
- holder.isBound = false
- holder.bind(holder.item!!)
- holder.isBound = true
- }
-
- override fun getItemCount(): Int {
- return if (mTList != null) mTList!!.size else 0
- }
-
- /**
- * Get Item
- *
- * @param position position founded
- * @return instance to position
- */
- fun getItem(position: Int): T? {
- return mTList!![position]
- }
-
- override fun getItemViewType(position: Int): Int {
- return if (getItem(position) != null && getItem(position) is IViewType) {
- (getItem(position) as IViewType).getItemViewType()
- } else super.getItemViewType(position)
- }
-
- fun putViewType(viewType: Int, viewHolder: Class>) {
- mFactory!!.putViewType(viewType, viewHolder)
- }
-
- operator fun contains(obj: T): Boolean {
- return mTList!!.contains(obj)
- }
-
- protected fun callChangedListener() {
- mAdapterChanged?.onItemCountChange(itemCount)
- }
-
- fun setOnAdapterChangedListener(adapterChanged: IAdapterChanged?) {
- mAdapterChanged = adapterChanged
- }
-
- fun setCommunication(communication: IBaseCommunication?) {
- mFactory!!.communication = communication
- notifyDataSetChanged()
- }
-
- /**
- * Inserts the specified element at the specified position in this list (optional operation).
- * Shifts the element currently at that position (if any) and any subsequent elements to the right (adds one to their indices).
- *
- * @param item element to be inserted
- */
- fun addItem(item: T) {
- if (mTList != null) {
- mTList!!.add(item)
- notifyItemInserted(mTList!!.size)
- }
- }
-
- /**
- * Inserts the specified element at the specified position in this list (optional operation).
- * Shifts the element currently at that position (if any) and any subsequent elements to the right (adds one to their indices).
- *
- * @param item element to be inserted
- * @param position index at which the specified element is to be inserted
- */
- fun addItem(item: T, position: Int) {
- if (mTList != null) {
- val pos = Math.min(position, mTList!!.size)
- mTList!!.add(pos, item)
- notifyItemInserted(pos)
- }
- }
-
- /**
- * Inserts the specified element at the specified position in this list (optional operation).
- * Shifts the element currently at that position (if any) and any subsequent elements to the right (adds one to their indices).
- *
- * @param collection elements to be inserted
- */
- fun addAll(collection: List) {
- if (mTList != null) {
- mTList!!.addAll(collection)
- val start = Math.max(0, mTList!!.size - collection.size - 1)
- notifyItemRangeInserted(start, collection.size)
- }
- }
-
- /**
- * Inserts the specified element at the specified position in this list (optional operation).
- * Shifts the element currently at that position (if any) and any subsequent elements to the right (adds one to their indices).
- *
- * @param item the element to be removed
- */
- fun removeItem(item: T) {
- removeItem(tList!!.indexOf(item))
- }
-
- /**
- * Inserts the specified element at the specified position in this list (optional operation).
- * Shifts the element currently at that position (if any) and any subsequent elements to the right (adds one to their indices).
- *
- * @param position the index of the element to be removed
- */
- fun removeItem(position: Int) {
- if (mTList != null && position > -1 && position < mTList!!.size) {
- mTList!!.removeAt(position)
- notifyItemRemoved(position)
- }
- }
-
- /**
- * Set new list items and notifyDataSetChanged()
- *
- * @param list new instance items list for bind views
- * @link notifyDataSetChanged
- */
- fun updateItems(list: MutableList) {
- mTList = list
- notifyDataSetChanged()
- }
-
- /**
- * @return instance items list
- */
- val tList: List?
- get() = mTList
-
- val isEmpty: Boolean
- get() = mTList == null || mTList!!.isEmpty()
-}
diff --git a/adapter/src/main/kotlin/com/android/jmaxime/interfaces/IAdapterChanged.kt b/adapter/src/main/kotlin/com/android/jmaxime/interfaces/IAdapterChanged.kt
deleted file mode 100644
index fd447d7..0000000
--- a/adapter/src/main/kotlin/com/android/jmaxime/interfaces/IAdapterChanged.kt
+++ /dev/null
@@ -1,12 +0,0 @@
-package com.android.jmaxime.interfaces
-
-/**
- * @author Maxime Jallu
- * @since 13/09/2017
- *
- * Use this Class for :
- * {DOCUMENTATION}
- */
-interface IAdapterChanged {
- fun onItemCountChange(count: Int)
-}
\ No newline at end of file
diff --git a/adapter/src/main/kotlin/com/android/jmaxime/interfaces/IBaseCommunication.kt b/adapter/src/main/kotlin/com/android/jmaxime/interfaces/IBaseCommunication.kt
deleted file mode 100644
index fa70d10..0000000
--- a/adapter/src/main/kotlin/com/android/jmaxime/interfaces/IBaseCommunication.kt
+++ /dev/null
@@ -1,18 +0,0 @@
-package com.android.jmaxime.interfaces
-
-/**
- * @author Maxime Jallu
- * @since 10/05/2017
- * Use this Class for :
- * ... {DOCUMENTATION}
- */
-interface IBaseCommunication {
-
- fun onDeleteClicked(position: Int, item : T) {
- /*nothing*/
- }
-
- fun onEditClicked(position: Int, item: T) {
- /*nothing*/
- }
-}
diff --git a/adapter/src/main/kotlin/com/android/jmaxime/interfaces/IViewType.kt b/adapter/src/main/kotlin/com/android/jmaxime/interfaces/IViewType.kt
deleted file mode 100644
index 6847bc0..0000000
--- a/adapter/src/main/kotlin/com/android/jmaxime/interfaces/IViewType.kt
+++ /dev/null
@@ -1,12 +0,0 @@
-package com.android.jmaxime.interfaces
-
-/**
- * @author Maxime Jallu
- * @since 13/09/2017
- *
- * Use this Class for :
- * {DOCUMENTATION}
- */
-interface IViewType {
- fun getItemViewType(): Int
-}
\ No newline at end of file
diff --git a/adapter/src/main/kotlin/com/android/jmaxime/interfaces/ViewCheckableCallback.kt b/adapter/src/main/kotlin/com/android/jmaxime/interfaces/ViewCheckableCallback.kt
deleted file mode 100644
index 2c699bd..0000000
--- a/adapter/src/main/kotlin/com/android/jmaxime/interfaces/ViewCheckableCallback.kt
+++ /dev/null
@@ -1,19 +0,0 @@
-package com.android.jmaxime.interfaces
-
-import android.annotation.SuppressLint
-
-/**
- * @author Maxime Jallu
- * @since 26/09/2017
- *
- * Use this Class for :
- * {DOCUMENTATION}
- */
-interface ViewCheckableCallback : IBaseCommunication {
- abstract fun isChecked(item: T): Boolean
- @SuppressLint("NewApi")
- fun isCheckable(item: T): Boolean {
- return true
- }
- fun put(key: String, value: Boolean)
-}
\ No newline at end of file