-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
befffb9
commit 0c38a02
Showing
6 changed files
with
218 additions
and
178 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
57 changes: 57 additions & 0 deletions
57
ss-smart-filter/src/main/java/com/ss/smartfilterlib/BaseSelection.kt
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package com.ss.smartfilterlib | ||
|
||
import RadioGroupCallback | ||
import android.content.Context | ||
import android.graphics.Typeface | ||
import android.util.AttributeSet | ||
import android.widget.CheckedTextView | ||
import androidx.recyclerview.widget.RecyclerView | ||
import com.ss.smartfilterlib.singlechoice.radiogroup.data.RadioGroupData | ||
import com.ss.smartfilterlib.singlechoice.util.Constant | ||
import com.ss.smartfilterlib.singlechoice.util.PaddingAttributes | ||
import com.ss.smartfilterlib.singlechoice.util.TextAttributes | ||
|
||
/** | ||
* created by Mala Ruparel ON 08/05/24 | ||
*/ | ||
abstract class BaseClass<T> : RecyclerView { | ||
|
||
|
||
protected var primaryTextColor: Int = Constant.PRIMARY_TEXT_COLOR | ||
protected var orientation: Int = SmartOrientation.VERTICAL | ||
protected var checkSelector: Int = 0 | ||
protected var paddingAttributes: PaddingAttributes = PaddingAttributes() | ||
protected var textAttributes: TextAttributes = TextAttributes() | ||
protected var onMultiSelectionClicked: ((List<RadioGroupData>) -> Unit)? = null | ||
protected var onSingleSelectionClicked: RadioGroupCallback? = null | ||
protected var dataFromXml: Int = 0 | ||
protected var data: List<T> = emptyList() | ||
protected val selectedItemsPositions = mutableListOf<Int>() | ||
constructor(context: Context) : super(context) | ||
constructor(context: Context, attrs: AttributeSet?) : super(context, attrs) | ||
constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : super(context, attrs, defStyleAttr) | ||
|
||
// Common methods | ||
protected abstract fun initAttributes(attrs: AttributeSet?) | ||
protected abstract fun initializeView() | ||
|
||
protected fun applyTextAttributes(textView: CheckedTextView) { | ||
textAttributes.let { attributes -> | ||
textView.apply { | ||
textSize = attributes.textSize | ||
typeface = Typeface.create(Typeface.DEFAULT, attributes.fontFamily) | ||
} | ||
} | ||
} | ||
protected fun applyPaddingAttributes(textView: CheckedTextView) { | ||
paddingAttributes.let { attributes -> | ||
textView.setPadding( | ||
attributes.paddingStart, | ||
attributes.paddingTop, | ||
attributes.paddingEnd, | ||
attributes.paddingBottom | ||
) | ||
} | ||
} | ||
protected fun setData(data: RadioGroupData) = data.name | ||
} |
This file contains 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
Oops, something went wrong.