refactor
This commit is contained in:
parent
86efd2a62b
commit
2919953707
|
@ -69,7 +69,6 @@ class ColumnViewHolder(
|
|||
|
||||
lateinit var listLayoutManager : LinearLayoutManager
|
||||
|
||||
|
||||
private lateinit var llColumnHeader : View
|
||||
private lateinit var tvColumnIndex : TextView
|
||||
private lateinit var tvColumnStatus : TextView
|
||||
|
@ -254,6 +253,7 @@ class ColumnViewHolder(
|
|||
}
|
||||
|
||||
val viewRoot : View = inflate(activity, parent)
|
||||
|
||||
init {
|
||||
|
||||
viewRoot.scan { v ->
|
||||
|
@ -279,8 +279,6 @@ class ColumnViewHolder(
|
|||
// animator.supportsChangeAnimations = false
|
||||
// }
|
||||
|
||||
|
||||
|
||||
btnListAdd.setOnClickListener(this)
|
||||
|
||||
etListName.setOnEditorActionListener { _, actionId, _ ->
|
||||
|
@ -562,27 +560,27 @@ class ColumnViewHolder(
|
|||
|
||||
|
||||
|
||||
cbDontCloseColumn.isCheckedEx = column.dont_close
|
||||
cbWithAttachment.isCheckedEx = column.with_attachment
|
||||
cbWithHighlight.isCheckedEx = column.with_highlight
|
||||
cbDontShowBoost.isCheckedEx = column.dont_show_boost
|
||||
cbDontShowFollow.isCheckedEx = column.dont_show_follow
|
||||
cbDontShowFavourite.isCheckedEx = column.dont_show_favourite
|
||||
cbDontShowReply.isCheckedEx = column.dont_show_reply
|
||||
cbDontShowReaction.isCheckedEx = column.dont_show_reaction
|
||||
cbDontShowVote.isCheckedEx = column.dont_show_vote
|
||||
cbDontShowNormalToot.isCheckedEx = column.dont_show_normal_toot
|
||||
cbInstanceLocal.isCheckedEx = column.instance_local
|
||||
cbDontStreaming.isCheckedEx = column.dont_streaming
|
||||
cbDontAutoRefresh.isCheckedEx = column.dont_auto_refresh
|
||||
cbHideMediaDefault.isCheckedEx = column.hide_media_default
|
||||
cbSystemNotificationNotRelated.isCheckedEx = column.system_notification_not_related
|
||||
cbEnableSpeech.isCheckedEx = column.enable_speech
|
||||
cbOldApi.isCheckedEx = column.use_old_api
|
||||
cbDontCloseColumn.isCheckedNoAnime = column.dont_close
|
||||
cbWithAttachment.isCheckedNoAnime = column.with_attachment
|
||||
cbWithHighlight.isCheckedNoAnime = column.with_highlight
|
||||
cbDontShowBoost.isCheckedNoAnime = column.dont_show_boost
|
||||
cbDontShowFollow.isCheckedNoAnime = column.dont_show_follow
|
||||
cbDontShowFavourite.isCheckedNoAnime = column.dont_show_favourite
|
||||
cbDontShowReply.isCheckedNoAnime = column.dont_show_reply
|
||||
cbDontShowReaction.isCheckedNoAnime = column.dont_show_reaction
|
||||
cbDontShowVote.isCheckedNoAnime = column.dont_show_vote
|
||||
cbDontShowNormalToot.isCheckedNoAnime = column.dont_show_normal_toot
|
||||
cbInstanceLocal.isCheckedNoAnime = column.instance_local
|
||||
cbDontStreaming.isCheckedNoAnime = column.dont_streaming
|
||||
cbDontAutoRefresh.isCheckedNoAnime = column.dont_auto_refresh
|
||||
cbHideMediaDefault.isCheckedNoAnime = column.hide_media_default
|
||||
cbSystemNotificationNotRelated.isCheckedNoAnime = column.system_notification_not_related
|
||||
cbEnableSpeech.isCheckedNoAnime = column.enable_speech
|
||||
cbOldApi.isCheckedNoAnime = column.use_old_api
|
||||
|
||||
etRegexFilter.setText(column.regex_text)
|
||||
etSearch.setText(column.search_query)
|
||||
cbResolve.isCheckedEx = column.search_resolve
|
||||
cbResolve.isCheckedNoAnime = column.search_resolve
|
||||
|
||||
vg(cbWithAttachment, bAllowFilter)
|
||||
vg(cbWithHighlight, bAllowFilter)
|
||||
|
@ -994,7 +992,7 @@ class ColumnViewHolder(
|
|||
if(column.isSearchColumn) {
|
||||
etSearch.hideKeyboard()
|
||||
etSearch.setText(column.search_query)
|
||||
cbResolve.isCheckedEx = column.search_resolve
|
||||
cbResolve.isCheckedNoAnime = column.search_resolve
|
||||
}
|
||||
refreshLayout.isRefreshing = false
|
||||
column.startLoading()
|
||||
|
@ -1561,7 +1559,6 @@ class ColumnViewHolder(
|
|||
)
|
||||
}
|
||||
|
||||
|
||||
private fun inflate(activity : ActMain, parent : ViewGroup) = with(activity.UI {}) {
|
||||
val b = Benchmark(log, "Item-Inflate", 40L)
|
||||
var label : TextView? = null
|
||||
|
@ -1646,7 +1643,8 @@ class ColumnViewHolder(
|
|||
}
|
||||
|
||||
btnColumnSetting = imageButton {
|
||||
background = ContextCompat.getDrawable(context,R.drawable.btn_bg_transparent)
|
||||
background =
|
||||
ContextCompat.getDrawable(context, R.drawable.btn_bg_transparent)
|
||||
contentDescription = context.getString(R.string.setting)
|
||||
setImageResource(R.drawable.ic_tune)
|
||||
padding = dip(8)
|
||||
|
@ -1657,7 +1655,8 @@ class ColumnViewHolder(
|
|||
}
|
||||
|
||||
btnColumnReload = imageButton {
|
||||
background = ContextCompat.getDrawable(context,R.drawable.btn_bg_transparent)
|
||||
background =
|
||||
ContextCompat.getDrawable(context, R.drawable.btn_bg_transparent)
|
||||
contentDescription = context.getString(R.string.reload)
|
||||
setImageResource(R.drawable.ic_refresh)
|
||||
padding = dip(8)
|
||||
|
@ -1670,7 +1669,8 @@ class ColumnViewHolder(
|
|||
}
|
||||
|
||||
btnColumnClose = imageButton {
|
||||
background = ContextCompat.getDrawable(context,R.drawable.btn_bg_transparent)
|
||||
background =
|
||||
ContextCompat.getDrawable(context, R.drawable.btn_bg_transparent)
|
||||
contentDescription = context.getString(R.string.close_column)
|
||||
setImageResource(R.drawable.ic_close)
|
||||
padding = dip(8)
|
||||
|
@ -1692,7 +1692,8 @@ class ColumnViewHolder(
|
|||
llColumnSettingInside = verticalLayout {
|
||||
lparams(matchParent, wrapContent)
|
||||
|
||||
backgroundColor = getAttributeColor(context,R.attr.colorColumnSettingBackground)
|
||||
backgroundColor =
|
||||
getAttributeColor(context, R.attr.colorColumnSettingBackground)
|
||||
startPadding = dip(12)
|
||||
endPadding = dip(12)
|
||||
topPadding = dip(3)
|
||||
|
@ -1702,7 +1703,8 @@ class ColumnViewHolder(
|
|||
lparams(matchParent, wrapContent)
|
||||
|
||||
label = textView {
|
||||
textColor= getAttributeColor(context,R.attr.colorColumnHeaderPageNumber)
|
||||
textColor =
|
||||
getAttributeColor(context, R.attr.colorColumnHeaderPageNumber)
|
||||
text = context.getString(R.string.hashtag_extra_any)
|
||||
}.lparams(matchParent, wrapContent)
|
||||
|
||||
|
@ -1716,7 +1718,8 @@ class ColumnViewHolder(
|
|||
label?.labelFor = etHashtagExtraAny.id
|
||||
|
||||
label = textView {
|
||||
textColor= getAttributeColor(context,R.attr.colorColumnHeaderPageNumber)
|
||||
textColor =
|
||||
getAttributeColor(context, R.attr.colorColumnHeaderPageNumber)
|
||||
text = context.getString(R.string.hashtag_extra_all)
|
||||
}.lparams(matchParent, wrapContent)
|
||||
|
||||
|
@ -1730,7 +1733,8 @@ class ColumnViewHolder(
|
|||
label?.labelFor = etHashtagExtraAll.id
|
||||
|
||||
label = textView {
|
||||
textColor= getAttributeColor(context,R.attr.colorColumnHeaderPageNumber)
|
||||
textColor =
|
||||
getAttributeColor(context, R.attr.colorColumnHeaderPageNumber)
|
||||
text = context.getString(R.string.hashtag_extra_none)
|
||||
}.lparams(matchParent, wrapContent)
|
||||
|
||||
|
@ -1744,7 +1748,6 @@ class ColumnViewHolder(
|
|||
label?.labelFor = etHashtagExtraNone.id
|
||||
} // end of hashtag extra
|
||||
|
||||
|
||||
cbDontCloseColumn = checkBox {
|
||||
text = context.getString(R.string.dont_close_column)
|
||||
}.lparams(matchParent, wrapContent)
|
||||
|
@ -1838,7 +1841,8 @@ class ColumnViewHolder(
|
|||
lparams(matchParent, wrapContent)
|
||||
|
||||
label = textView {
|
||||
textColor= getAttributeColor(context,R.attr.colorColumnHeaderPageNumber)
|
||||
textColor =
|
||||
getAttributeColor(context, R.attr.colorColumnHeaderPageNumber)
|
||||
text = context.getString(R.string.regex_filter)
|
||||
}.lparams(wrapContent, wrapContent)
|
||||
|
||||
|
@ -1849,7 +1853,6 @@ class ColumnViewHolder(
|
|||
startMargin = dip(4)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
etRegexFilter = editText {
|
||||
id = View.generateViewId()
|
||||
|
@ -1858,7 +1861,6 @@ class ColumnViewHolder(
|
|||
setHorizontallyScrolling(true)
|
||||
isHorizontalScrollBarEnabled = true
|
||||
|
||||
|
||||
}.lparams(matchParent, wrapContent)
|
||||
label?.labelFor = etRegexFilter.id
|
||||
|
||||
|
@ -1903,7 +1905,12 @@ class ColumnViewHolder(
|
|||
backgroundResource = R.drawable.btn_bg_transparent
|
||||
contentDescription = context.getString(R.string.clear)
|
||||
imageResource = R.drawable.ic_close
|
||||
imageTintList = ColorStateList.valueOf(getAttributeColor(context,R.attr.colorVectorDrawable))
|
||||
imageTintList = ColorStateList.valueOf(
|
||||
getAttributeColor(
|
||||
context,
|
||||
R.attr.colorVectorDrawable
|
||||
)
|
||||
)
|
||||
}.lparams(dip(40), dip(40)) {
|
||||
startMargin = dip(4)
|
||||
}
|
||||
|
@ -1912,7 +1919,12 @@ class ColumnViewHolder(
|
|||
backgroundResource = R.drawable.btn_bg_transparent
|
||||
contentDescription = context.getString(R.string.search)
|
||||
imageResource = R.drawable.ic_search
|
||||
imageTintList = ColorStateList.valueOf(getAttributeColor(context,R.attr.colorVectorDrawable))
|
||||
imageTintList = ColorStateList.valueOf(
|
||||
getAttributeColor(
|
||||
context,
|
||||
R.attr.colorVectorDrawable
|
||||
)
|
||||
)
|
||||
}.lparams(dip(40), dip(40)) {
|
||||
startMargin = dip(4)
|
||||
}
|
||||
|
@ -1949,7 +1961,12 @@ class ColumnViewHolder(
|
|||
backgroundResource = R.drawable.btn_bg_transparent
|
||||
contentDescription = context.getString(R.string.add)
|
||||
imageResource = R.drawable.ic_add
|
||||
imageTintList = ColorStateList.valueOf(getAttributeColor(context,R.attr.colorVectorDrawable))
|
||||
imageTintList = ColorStateList.valueOf(
|
||||
getAttributeColor(
|
||||
context,
|
||||
R.attr.colorVectorDrawable
|
||||
)
|
||||
)
|
||||
}.lparams(dip(40), dip(40)) {
|
||||
startMargin = dip(4)
|
||||
}
|
||||
|
|
|
@ -18,7 +18,6 @@ inline fun ViewManager.myTextView(init: MyTextView.() -> Unit) : MyTextView {
|
|||
return ankoView({ MyTextView(it) }, theme = 0, init = init)
|
||||
}
|
||||
|
||||
|
||||
inline fun ViewManager.trendTagHistoryView(init : TagHistoryView.() -> Unit) : TagHistoryView {
|
||||
return ankoView({ TagHistoryView(it) }, theme = 0, init = init)
|
||||
}
|
||||
|
@ -27,7 +26,6 @@ inline fun ViewManager.blurhashView(init: BlurhashView.() -> Unit): BlurhashView
|
|||
return ankoView({ BlurhashView(it) }, theme = 0, init = init)
|
||||
}
|
||||
|
||||
|
||||
inline fun ViewManager.maxHeightScrollView(init : MaxHeightScrollView.() -> Unit) : MaxHeightScrollView {
|
||||
return ankoView({ MaxHeightScrollView(it) }, theme = 0, init = init)
|
||||
}
|
||||
|
@ -37,6 +35,8 @@ inline fun ViewManager.swipyRefreshLayout(init: SwipyRefreshLayout.() -> Unit):
|
|||
}
|
||||
|
||||
inline fun ViewManager.recyclerView(init : RecyclerView.() -> Unit) : RecyclerView {
|
||||
return ankoView({ RecyclerView(ContextThemeWrapper(it, R.style.recycler_view_with_scroll_bar)) }, theme = 0, init = init)
|
||||
return ankoView({
|
||||
RecyclerView(ContextThemeWrapper(it, R.style.recycler_view_with_scroll_bar))
|
||||
}, theme = 0, init = init)
|
||||
}
|
||||
|
||||
|
|
|
@ -25,13 +25,15 @@ class ScrollPosition {
|
|||
constructor(holder : ColumnViewHolder) {
|
||||
val layoutManager = holder.listLayoutManager
|
||||
val findPosition = layoutManager.findFirstVisibleItemPosition()
|
||||
if(findPosition == androidx.recyclerview.widget.RecyclerView.NO_POSITION) {
|
||||
if(findPosition == RecyclerView.NO_POSITION) {
|
||||
adapterIndex = 0
|
||||
offset = 0
|
||||
} else {
|
||||
adapterIndex = findPosition
|
||||
val firstItemView = layoutManager.findViewByPosition(findPosition)
|
||||
offset = (firstItemView?.top ?: 0) - (((firstItemView?.layoutParams as? ViewGroup.MarginLayoutParams)?.topMargin)?:0)
|
||||
offset = (firstItemView?.top
|
||||
?: 0) - (((firstItemView?.layoutParams as? ViewGroup.MarginLayoutParams)?.topMargin)
|
||||
?: 0)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -67,7 +67,6 @@ fun vg(v : View, visible : Boolean) : Boolean {
|
|||
return visible
|
||||
}
|
||||
|
||||
|
||||
fun ViewGroup.generateLayoutParamsEx() : ViewGroup.LayoutParams? =
|
||||
try {
|
||||
val parser = resources.getLayout(R.layout.generate_params)
|
||||
|
@ -82,9 +81,8 @@ fun ViewGroup.generateLayoutParamsEx():ViewGroup.LayoutParams?=
|
|||
null
|
||||
}
|
||||
|
||||
|
||||
// isChecked with skipping animation
|
||||
var CompoundButton.isCheckedEx :Boolean
|
||||
var CompoundButton.isCheckedNoAnime : Boolean
|
||||
get() = isChecked
|
||||
set(value) {
|
||||
isChecked = value
|
||||
|
|
|
@ -68,7 +68,8 @@
|
|||
<item name="colorRippleEffect">@color/Dark_colorRippleEffect</item>
|
||||
<item name="colorButtonSelected">@color/Dark_colorButtonSelected</item>
|
||||
<item name="colorReplyBackground">@color/Dark_colorReplyBackground</item>
|
||||
<item name="colorColumnListDeleteBackground">@color/Dark_colorColumnListDeleteBackground</item>
|
||||
<item name="colorColumnListDeleteBackground">@color/Dark_colorColumnListDeleteBackground
|
||||
</item>
|
||||
<item name="colorColumnListDeleteText">@color/Dark_colorColumnListDeleteText</item>
|
||||
<item name="colorColumnListDragHandleBackground">
|
||||
@color/Dark_colorColumnListDragHandleBackground
|
||||
|
@ -150,6 +151,7 @@
|
|||
<item name="android:paddingStart">12dp</item>
|
||||
|
||||
</style>
|
||||
|
||||
<style name="setting_row_label">
|
||||
<item name="android:layout_width">match_parent</item>
|
||||
<item name="android:layout_height">wrap_content</item>
|
||||
|
@ -238,5 +240,4 @@
|
|||
|
||||
</style>
|
||||
|
||||
|
||||
</resources>
|
||||
|
|
Loading…
Reference in New Issue