2018-01-04 19:52:25 +01:00
|
|
|
package jp.juggler.subwaytooter
|
|
|
|
|
|
|
|
import android.annotation.SuppressLint
|
2018-11-17 13:51:01 +01:00
|
|
|
import android.content.Context
|
2019-01-17 20:40:51 +01:00
|
|
|
import android.content.res.ColorStateList
|
2018-01-04 19:52:25 +01:00
|
|
|
import android.graphics.Bitmap
|
2018-11-20 10:32:30 +01:00
|
|
|
import android.graphics.Color
|
2018-01-04 19:52:25 +01:00
|
|
|
import android.os.AsyncTask
|
2018-08-04 21:56:53 +02:00
|
|
|
import android.text.SpannableStringBuilder
|
2018-11-20 10:32:30 +01:00
|
|
|
import android.text.TextUtils
|
2018-11-17 13:51:01 +01:00
|
|
|
import android.view.GestureDetector
|
|
|
|
import android.view.MotionEvent
|
2018-01-04 19:52:25 +01:00
|
|
|
import android.view.View
|
2018-12-12 15:21:38 +01:00
|
|
|
import android.view.ViewGroup
|
2018-12-01 00:02:18 +01:00
|
|
|
import android.view.animation.AlphaAnimation
|
|
|
|
import android.view.animation.Animation
|
2018-01-04 19:52:25 +01:00
|
|
|
import android.view.inputmethod.EditorInfo
|
2018-08-04 21:56:53 +02:00
|
|
|
import android.widget.*
|
2019-02-25 09:00:36 +01:00
|
|
|
import androidx.core.content.ContextCompat
|
|
|
|
import androidx.recyclerview.widget.LinearLayoutManager
|
|
|
|
import androidx.recyclerview.widget.RecyclerView
|
|
|
|
import com.omadahealth.github.swipyrefreshlayout.library.SwipyRefreshLayout
|
|
|
|
import com.omadahealth.github.swipyrefreshlayout.library.SwipyRefreshLayoutDirection
|
2018-01-04 19:52:25 +01:00
|
|
|
import jp.juggler.subwaytooter.action.Action_List
|
|
|
|
import jp.juggler.subwaytooter.action.Action_Notification
|
|
|
|
import jp.juggler.subwaytooter.table.AcctColor
|
2018-12-01 00:02:18 +01:00
|
|
|
import jp.juggler.subwaytooter.util.ScrollPosition
|
2018-01-17 18:39:16 +01:00
|
|
|
import jp.juggler.subwaytooter.view.ListDivider
|
2018-12-01 00:02:18 +01:00
|
|
|
import jp.juggler.util.*
|
2019-02-25 09:00:36 +01:00
|
|
|
import org.jetbrains.anko.backgroundDrawable
|
2018-11-18 03:38:52 +01:00
|
|
|
import org.jetbrains.anko.textColor
|
2018-01-19 10:27:35 +01:00
|
|
|
import java.io.Closeable
|
2018-01-17 18:39:16 +01:00
|
|
|
import java.lang.reflect.Field
|
2018-08-04 21:56:53 +02:00
|
|
|
import java.util.regex.Pattern
|
2018-01-04 19:52:25 +01:00
|
|
|
|
2019-01-09 09:08:51 +01:00
|
|
|
@SuppressLint("ClickableViewAccessibility")
|
2018-01-17 18:39:16 +01:00
|
|
|
class ColumnViewHolder(
|
|
|
|
val activity : ActMain,
|
2018-11-15 23:08:11 +01:00
|
|
|
val viewRoot : View
|
2018-01-17 18:39:16 +01:00
|
|
|
) : View.OnClickListener,
|
|
|
|
SwipyRefreshLayout.OnRefreshListener,
|
2018-07-05 14:38:48 +02:00
|
|
|
CompoundButton.OnCheckedChangeListener, View.OnLongClickListener {
|
2018-01-04 19:52:25 +01:00
|
|
|
|
|
|
|
companion object {
|
|
|
|
private val log = LogCategory("ColumnViewHolder")
|
|
|
|
|
2018-01-19 10:27:35 +01:00
|
|
|
val fieldRecycler : Field by lazy {
|
2019-02-25 09:00:36 +01:00
|
|
|
val field = RecyclerView::class.java.getDeclaredField("mRecycler")
|
2018-01-17 18:39:16 +01:00
|
|
|
field.isAccessible = true
|
|
|
|
field
|
|
|
|
}
|
|
|
|
|
2018-01-19 10:27:35 +01:00
|
|
|
val fieldState : Field by lazy {
|
2019-02-25 09:00:36 +01:00
|
|
|
val field = RecyclerView::class.java.getDeclaredField("mState")
|
2018-01-17 18:39:16 +01:00
|
|
|
field.isAccessible = true
|
|
|
|
field
|
|
|
|
}
|
|
|
|
|
|
|
|
val heightSpec = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED)
|
|
|
|
|
2018-11-20 10:32:30 +01:00
|
|
|
// var lastRefreshError : String = ""
|
|
|
|
// var lastRefreshErrorShown : Long = 0L
|
2018-01-04 19:52:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
var column : Column? = null
|
|
|
|
private var status_adapter : ItemListAdapter? = null
|
|
|
|
private var page_idx : Int = 0
|
|
|
|
|
|
|
|
private val tvLoading : TextView
|
2019-02-25 09:00:36 +01:00
|
|
|
val listView : RecyclerView
|
2018-01-04 19:52:25 +01:00
|
|
|
val refreshLayout : SwipyRefreshLayout
|
2019-02-25 09:00:36 +01:00
|
|
|
lateinit var listLayoutManager : LinearLayoutManager
|
2018-01-19 10:27:35 +01:00
|
|
|
|
2018-01-04 19:52:25 +01:00
|
|
|
private val llColumnHeader : View
|
|
|
|
private val tvColumnIndex : TextView
|
2018-04-20 15:22:21 +02:00
|
|
|
private val tvColumnStatus : TextView
|
2018-01-04 19:52:25 +01:00
|
|
|
private val tvColumnContext : TextView
|
|
|
|
private val ivColumnIcon : ImageView
|
|
|
|
private val tvColumnName : TextView
|
|
|
|
|
|
|
|
private val llColumnSetting : View
|
|
|
|
|
2019-02-03 15:12:03 +01:00
|
|
|
private val btnSearch : ImageButton
|
|
|
|
private val btnSearchClear : ImageButton
|
2018-01-04 19:52:25 +01:00
|
|
|
private val etSearch : EditText
|
|
|
|
private val cbResolve : CheckBox
|
|
|
|
private val etRegexFilter : EditText
|
|
|
|
private val tvRegexFilterError : TextView
|
|
|
|
|
|
|
|
private val btnColumnSetting : ImageButton
|
|
|
|
private val btnColumnReload : ImageButton
|
|
|
|
private val btnColumnClose : ImageButton
|
|
|
|
|
|
|
|
private val flColumnBackground : View
|
|
|
|
private val ivColumnBackgroundImage : ImageView
|
|
|
|
private val llSearch : View
|
|
|
|
private val cbDontCloseColumn : CheckBox
|
|
|
|
private val cbWithAttachment : CheckBox
|
|
|
|
private val cbWithHighlight : CheckBox
|
|
|
|
private val cbDontShowBoost : CheckBox
|
|
|
|
private val cbDontShowFollow : CheckBox
|
|
|
|
private val cbDontShowFavourite : CheckBox
|
|
|
|
private val cbDontShowReply : CheckBox
|
2018-08-21 12:19:02 +02:00
|
|
|
private val cbDontShowReaction : CheckBox
|
|
|
|
private val cbDontShowVote : CheckBox
|
2018-02-10 01:36:27 +01:00
|
|
|
private val cbDontShowNormalToot : CheckBox
|
2018-03-25 15:27:58 +02:00
|
|
|
private val cbInstanceLocal : CheckBox
|
2018-01-04 19:52:25 +01:00
|
|
|
private val cbDontStreaming : CheckBox
|
|
|
|
private val cbDontAutoRefresh : CheckBox
|
|
|
|
private val cbHideMediaDefault : CheckBox
|
2018-02-06 21:41:30 +01:00
|
|
|
private val cbSystemNotificationNotRelated : CheckBox
|
2018-01-04 19:52:25 +01:00
|
|
|
private val cbEnableSpeech : CheckBox
|
2018-10-10 22:43:10 +02:00
|
|
|
private val cbOldApi : CheckBox
|
2018-01-04 19:52:25 +01:00
|
|
|
private val llRegexFilter : View
|
|
|
|
private val btnDeleteNotification : Button
|
|
|
|
|
2019-01-08 05:30:18 +01:00
|
|
|
private val svQuickFilter : HorizontalScrollView
|
|
|
|
private val btnQuickFilterAll : Button
|
|
|
|
private val btnQuickFilterMention : ImageButton
|
|
|
|
private val btnQuickFilterFavourite : ImageButton
|
|
|
|
private val btnQuickFilterBoost : ImageButton
|
|
|
|
private val btnQuickFilterFollow : ImageButton
|
|
|
|
private val btnQuickFilterReaction : ImageButton
|
|
|
|
private val btnQuickFilterVote : ImageButton
|
|
|
|
|
2018-11-20 10:32:30 +01:00
|
|
|
private val llRefreshError : FrameLayout
|
|
|
|
private val ivRefreshError : ImageView
|
|
|
|
private val tvRefreshError : TextView
|
|
|
|
|
2018-01-04 19:52:25 +01:00
|
|
|
private val llListList : View
|
|
|
|
private val etListName : EditText
|
|
|
|
private val btnListAdd : View
|
|
|
|
|
2019-02-03 08:54:52 +01:00
|
|
|
private val llHashtagExtra : LinearLayout
|
|
|
|
private val etHashtagExtraAny : EditText
|
|
|
|
private val etHashtagExtraAll : EditText
|
|
|
|
private val etHashtagExtraNone : EditText
|
2019-02-03 05:29:50 +01:00
|
|
|
|
2018-01-04 19:52:25 +01:00
|
|
|
private val isPageDestroyed : Boolean
|
|
|
|
get() = column == null || activity.isFinishing
|
|
|
|
|
2019-02-03 08:54:52 +01:00
|
|
|
private var binding_busy : Boolean = false
|
2018-01-04 19:52:25 +01:00
|
|
|
|
|
|
|
private var last_image_uri : String? = null
|
|
|
|
private var last_image_bitmap : Bitmap? = null
|
2018-01-10 16:47:35 +01:00
|
|
|
private var last_image_task : AsyncTask<Void, Void, Bitmap?>? = null
|
2018-01-04 19:52:25 +01:00
|
|
|
|
2018-06-30 13:18:17 +02:00
|
|
|
private fun checkRegexFilterError(src : String) : String? {
|
|
|
|
try {
|
|
|
|
if(src.isEmpty()) {
|
|
|
|
return null
|
2018-01-04 19:52:25 +01:00
|
|
|
}
|
2018-06-30 13:18:17 +02:00
|
|
|
val m = Pattern.compile(src).matcher("")
|
|
|
|
if(m.find()) {
|
|
|
|
// 空文字列にマッチする正規表現はエラー扱いにする
|
|
|
|
// そうしないとCWの警告テキストにマッチしてしまう
|
|
|
|
return activity.getString(R.string.regex_filter_matches_empty_string)
|
|
|
|
}
|
|
|
|
return null
|
|
|
|
} catch(ex : Throwable) {
|
|
|
|
val message = ex.message
|
|
|
|
return if(message != null && message.isNotEmpty()) {
|
|
|
|
message
|
|
|
|
} else {
|
|
|
|
ex.withCaption(activity.resources, R.string.regex_error)
|
2018-01-04 19:52:25 +01:00
|
|
|
}
|
|
|
|
}
|
2018-06-30 13:18:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
private fun isRegexValid() : Boolean {
|
|
|
|
val s = etRegexFilter.text.toString()
|
|
|
|
val error = checkRegexFilterError(s)
|
|
|
|
tvRegexFilterError.text = error ?: ""
|
|
|
|
return error == null
|
|
|
|
}
|
2018-01-04 19:52:25 +01:00
|
|
|
|
|
|
|
val isColumnSettingShown : Boolean
|
|
|
|
get() = llColumnSetting.visibility == View.VISIBLE
|
|
|
|
|
2018-01-17 18:39:16 +01:00
|
|
|
// val headerView : HeaderViewHolderBase?
|
|
|
|
// get() = status_adapter?.header
|
2018-01-04 19:52:25 +01:00
|
|
|
|
|
|
|
val scrollPosition : ScrollPosition
|
2018-01-17 18:39:16 +01:00
|
|
|
get() = ScrollPosition(this)
|
2018-01-04 19:52:25 +01:00
|
|
|
|
2018-11-17 13:51:01 +01:00
|
|
|
inner class ErrorFlickListener(
|
2018-11-18 03:38:52 +01:00
|
|
|
context : Context
|
|
|
|
) : View.OnTouchListener, GestureDetector.OnGestureListener {
|
2018-11-17 13:51:01 +01:00
|
|
|
|
|
|
|
private val gd = GestureDetector(context, this)
|
|
|
|
private val density = context.resources.displayMetrics.density
|
2018-11-18 03:38:52 +01:00
|
|
|
|
|
|
|
@SuppressLint("ClickableViewAccessibility")
|
2018-11-17 13:51:01 +01:00
|
|
|
override fun onTouch(v : View?, event : MotionEvent?) : Boolean {
|
|
|
|
return gd.onTouchEvent(event)
|
|
|
|
}
|
|
|
|
|
|
|
|
override fun onShowPress(e : MotionEvent?) {
|
|
|
|
}
|
|
|
|
|
|
|
|
override fun onLongPress(e : MotionEvent?) {
|
|
|
|
}
|
2018-11-18 03:38:52 +01:00
|
|
|
|
2018-11-17 13:51:01 +01:00
|
|
|
override fun onSingleTapUp(e : MotionEvent?) : Boolean {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
|
|
|
override fun onDown(e : MotionEvent?) : Boolean {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
|
|
|
override fun onScroll(
|
|
|
|
e1 : MotionEvent?,
|
|
|
|
e2 : MotionEvent?,
|
|
|
|
distanceX : Float,
|
|
|
|
distanceY : Float
|
|
|
|
) : Boolean {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
|
|
|
override fun onFling(
|
|
|
|
e1 : MotionEvent?,
|
|
|
|
e2 : MotionEvent?,
|
|
|
|
velocityX : Float,
|
|
|
|
velocityY : Float
|
|
|
|
) : Boolean {
|
|
|
|
|
2018-11-18 03:38:52 +01:00
|
|
|
val vx = velocityX.abs()
|
|
|
|
val vy = velocityY.abs()
|
|
|
|
if(vy < vx * 1.5f) {
|
2018-11-17 13:51:01 +01:00
|
|
|
// フリック方向が上下ではない
|
|
|
|
log.d("fling? not vertical view. $vx $vy")
|
2018-11-18 03:38:52 +01:00
|
|
|
} else {
|
|
|
|
|
2018-11-17 13:51:01 +01:00
|
|
|
val vydp = vy / density
|
|
|
|
val limit = 1024f
|
|
|
|
log.d("fling? $vydp/$limit")
|
2018-11-18 03:38:52 +01:00
|
|
|
if(vydp >= limit) {
|
|
|
|
|
2018-11-17 13:51:01 +01:00
|
|
|
val column = column
|
2018-11-18 03:38:52 +01:00
|
|
|
if(column != null && column.lastTask == null) {
|
2018-11-17 13:51:01 +01:00
|
|
|
column.startLoading()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@SuppressLint("ClickableViewAccessibility")
|
2018-11-18 03:38:52 +01:00
|
|
|
private fun initLoadingTextView() {
|
2018-11-17 13:51:01 +01:00
|
|
|
tvLoading.setOnTouchListener(ErrorFlickListener(activity))
|
|
|
|
}
|
2018-11-18 03:38:52 +01:00
|
|
|
|
2018-01-04 19:52:25 +01:00
|
|
|
init {
|
2018-11-18 03:38:52 +01:00
|
|
|
|
2018-08-22 03:05:54 +02:00
|
|
|
viewRoot.scan { v ->
|
|
|
|
try {
|
|
|
|
if(v is Button) {
|
|
|
|
// ボタンは触らない
|
|
|
|
} else if(v is TextView) {
|
|
|
|
v.typeface = ActMain.timeline_font
|
2018-01-04 19:52:25 +01:00
|
|
|
}
|
2018-08-22 03:05:54 +02:00
|
|
|
} catch(ex : Throwable) {
|
|
|
|
log.trace(ex)
|
2018-01-04 19:52:25 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-01-21 13:46:36 +01:00
|
|
|
flColumnBackground = viewRoot.findViewById(R.id.flColumnBackground)
|
|
|
|
ivColumnBackgroundImage = viewRoot.findViewById(R.id.ivColumnBackgroundImage)
|
|
|
|
llColumnHeader = viewRoot.findViewById(R.id.llColumnHeader)
|
2018-01-04 19:52:25 +01:00
|
|
|
|
2018-01-21 13:46:36 +01:00
|
|
|
tvColumnIndex = viewRoot.findViewById(R.id.tvColumnIndex)
|
2018-04-20 15:22:21 +02:00
|
|
|
tvColumnStatus = viewRoot.findViewById(R.id.tvColumnStatus)
|
2018-01-04 19:52:25 +01:00
|
|
|
|
2018-01-21 13:46:36 +01:00
|
|
|
tvColumnName = viewRoot.findViewById(R.id.tvColumnName)
|
|
|
|
tvColumnContext = viewRoot.findViewById(R.id.tvColumnContext)
|
|
|
|
ivColumnIcon = viewRoot.findViewById(R.id.ivColumnIcon)
|
2018-01-04 19:52:25 +01:00
|
|
|
|
2018-01-21 13:46:36 +01:00
|
|
|
btnColumnSetting = viewRoot.findViewById(R.id.btnColumnSetting)
|
|
|
|
btnColumnReload = viewRoot.findViewById(R.id.btnColumnReload)
|
|
|
|
btnColumnClose = viewRoot.findViewById(R.id.btnColumnClose)
|
2018-01-04 19:52:25 +01:00
|
|
|
|
2018-01-21 13:46:36 +01:00
|
|
|
tvLoading = viewRoot.findViewById(R.id.tvLoading)
|
|
|
|
listView = viewRoot.findViewById(R.id.listView)
|
2018-01-19 10:27:35 +01:00
|
|
|
|
|
|
|
if(Pref.bpShareViewPool(activity.pref)) {
|
2018-10-10 22:43:10 +02:00
|
|
|
listView.setRecycledViewPool(activity.viewPool)
|
2018-01-18 08:53:32 +01:00
|
|
|
}
|
2018-01-20 07:51:14 +01:00
|
|
|
listView.itemAnimator = null
|
2018-01-21 13:46:36 +01:00
|
|
|
//
|
|
|
|
// val animator = listView.itemAnimator
|
|
|
|
// if( animator is DefaultItemAnimator){
|
|
|
|
// animator.supportsChangeAnimations = false
|
|
|
|
// }
|
2018-01-04 19:52:25 +01:00
|
|
|
|
2018-01-21 13:46:36 +01:00
|
|
|
btnSearch = viewRoot.findViewById(R.id.btnSearch)
|
2019-02-03 15:12:03 +01:00
|
|
|
btnSearchClear = viewRoot.findViewById(R.id.btnSearchClear)
|
2018-01-21 13:46:36 +01:00
|
|
|
etSearch = viewRoot.findViewById(R.id.etSearch)
|
|
|
|
cbResolve = viewRoot.findViewById(R.id.cbResolve)
|
2018-01-04 19:52:25 +01:00
|
|
|
|
2018-01-21 13:46:36 +01:00
|
|
|
llSearch = viewRoot.findViewById(R.id.llSearch)
|
|
|
|
llListList = viewRoot.findViewById(R.id.llListList)
|
2018-01-04 19:52:25 +01:00
|
|
|
|
2018-01-21 13:46:36 +01:00
|
|
|
btnListAdd = viewRoot.findViewById(R.id.btnListAdd)
|
|
|
|
etListName = viewRoot.findViewById(R.id.etListName)
|
2018-01-04 19:52:25 +01:00
|
|
|
btnListAdd.setOnClickListener(this)
|
|
|
|
|
|
|
|
etListName.setOnEditorActionListener { _, actionId, _ ->
|
|
|
|
var handled = false
|
|
|
|
if(actionId == EditorInfo.IME_ACTION_SEND) {
|
|
|
|
btnListAdd.performClick()
|
|
|
|
handled = true
|
|
|
|
}
|
|
|
|
handled
|
|
|
|
}
|
|
|
|
|
2018-01-21 13:46:36 +01:00
|
|
|
llColumnSetting = viewRoot.findViewById(R.id.llColumnSetting)
|
|
|
|
|
|
|
|
cbDontCloseColumn = viewRoot.findViewById(R.id.cbDontCloseColumn)
|
|
|
|
cbWithAttachment = viewRoot.findViewById(R.id.cbWithAttachment)
|
|
|
|
cbWithHighlight = viewRoot.findViewById(R.id.cbWithHighlight)
|
|
|
|
cbDontShowBoost = viewRoot.findViewById(R.id.cbDontShowBoost)
|
|
|
|
cbDontShowFollow = viewRoot.findViewById(R.id.cbDontShowFollow)
|
|
|
|
cbDontShowFavourite = viewRoot.findViewById(R.id.cbDontShowFavourite)
|
|
|
|
cbDontShowReply = viewRoot.findViewById(R.id.cbDontShowReply)
|
2018-08-21 12:19:02 +02:00
|
|
|
cbDontShowReaction = viewRoot.findViewById(R.id.cbDontShowReaction)
|
|
|
|
cbDontShowVote = viewRoot.findViewById(R.id.cbDontShowVote)
|
2018-02-10 01:36:27 +01:00
|
|
|
cbDontShowNormalToot = viewRoot.findViewById(R.id.cbDontShowNormalToot)
|
2018-04-20 15:22:21 +02:00
|
|
|
cbInstanceLocal = viewRoot.findViewById(R.id.cbInstanceLocal)
|
2018-01-21 13:46:36 +01:00
|
|
|
cbDontStreaming = viewRoot.findViewById(R.id.cbDontStreaming)
|
|
|
|
cbDontAutoRefresh = viewRoot.findViewById(R.id.cbDontAutoRefresh)
|
|
|
|
cbHideMediaDefault = viewRoot.findViewById(R.id.cbHideMediaDefault)
|
2018-02-06 21:41:30 +01:00
|
|
|
cbSystemNotificationNotRelated = viewRoot.findViewById(R.id.cbSystemNotificationNotRelated)
|
2018-01-21 13:46:36 +01:00
|
|
|
cbEnableSpeech = viewRoot.findViewById(R.id.cbEnableSpeech)
|
2018-10-10 22:43:10 +02:00
|
|
|
cbOldApi = viewRoot.findViewById(R.id.cbOldApi)
|
2018-01-21 13:46:36 +01:00
|
|
|
etRegexFilter = viewRoot.findViewById(R.id.etRegexFilter)
|
|
|
|
llRegexFilter = viewRoot.findViewById(R.id.llRegexFilter)
|
|
|
|
tvRegexFilterError = viewRoot.findViewById(R.id.tvRegexFilterError)
|
|
|
|
|
|
|
|
btnDeleteNotification = viewRoot.findViewById(R.id.btnDeleteNotification)
|
2018-01-04 19:52:25 +01:00
|
|
|
|
2019-01-08 05:30:18 +01:00
|
|
|
svQuickFilter = viewRoot.findViewById(R.id.svQuickFilter)
|
|
|
|
btnQuickFilterAll = viewRoot.findViewById(R.id.btnQuickFilterAll)
|
|
|
|
btnQuickFilterMention = viewRoot.findViewById(R.id.btnQuickFilterMention)
|
|
|
|
btnQuickFilterFavourite = viewRoot.findViewById(R.id.btnQuickFilterFavourite)
|
|
|
|
btnQuickFilterBoost = viewRoot.findViewById(R.id.btnQuickFilterBoost)
|
|
|
|
btnQuickFilterFollow = viewRoot.findViewById(R.id.btnQuickFilterFollow)
|
|
|
|
btnQuickFilterReaction = viewRoot.findViewById(R.id.btnQuickFilterReaction)
|
|
|
|
btnQuickFilterVote = viewRoot.findViewById(R.id.btnQuickFilterVote)
|
2019-01-09 09:08:51 +01:00
|
|
|
val llColumnSettingInside : LinearLayout = viewRoot.findViewById(R.id.llColumnSettingInside)
|
2019-01-08 05:30:18 +01:00
|
|
|
|
2019-02-03 08:54:52 +01:00
|
|
|
llHashtagExtra = viewRoot.findViewById(R.id.llHashtagExtra)
|
|
|
|
etHashtagExtraAny = viewRoot.findViewById(R.id.etHashtagExtraAny)
|
|
|
|
etHashtagExtraAll = viewRoot.findViewById(R.id.etHashtagExtraAll)
|
|
|
|
etHashtagExtraNone = viewRoot.findViewById(R.id.etHashtagExtraNone)
|
2019-02-03 05:29:50 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
2019-01-08 05:30:18 +01:00
|
|
|
btnQuickFilterAll.setOnClickListener(this)
|
|
|
|
btnQuickFilterMention.setOnClickListener(this)
|
|
|
|
btnQuickFilterFavourite.setOnClickListener(this)
|
|
|
|
btnQuickFilterBoost.setOnClickListener(this)
|
|
|
|
btnQuickFilterFollow.setOnClickListener(this)
|
|
|
|
btnQuickFilterReaction.setOnClickListener(this)
|
|
|
|
btnQuickFilterVote.setOnClickListener(this)
|
|
|
|
|
|
|
|
|
2018-01-04 19:52:25 +01:00
|
|
|
llColumnHeader.setOnClickListener(this)
|
|
|
|
btnColumnSetting.setOnClickListener(this)
|
|
|
|
btnColumnReload.setOnClickListener(this)
|
|
|
|
btnColumnClose.setOnClickListener(this)
|
2018-07-05 14:38:48 +02:00
|
|
|
btnColumnClose.setOnLongClickListener(this)
|
2018-01-04 19:52:25 +01:00
|
|
|
btnDeleteNotification.setOnClickListener(this)
|
|
|
|
|
2018-01-21 13:46:36 +01:00
|
|
|
viewRoot.findViewById<View>(R.id.btnColor).setOnClickListener(this)
|
2018-01-04 19:52:25 +01:00
|
|
|
|
2018-01-21 13:46:36 +01:00
|
|
|
this.refreshLayout = viewRoot.findViewById(R.id.swipyRefreshLayout)
|
2018-01-04 19:52:25 +01:00
|
|
|
refreshLayout.setOnRefreshListener(this)
|
|
|
|
refreshLayout.setDistanceToTriggerSync((0.5f + 20f * activity.density).toInt())
|
|
|
|
|
2018-11-20 10:32:30 +01:00
|
|
|
llRefreshError = viewRoot.findViewById(R.id.llRefreshError)
|
|
|
|
ivRefreshError = viewRoot.findViewById(R.id.ivRefreshError)
|
|
|
|
tvRefreshError = viewRoot.findViewById(R.id.tvRefreshError)
|
|
|
|
llRefreshError.setOnClickListener(this)
|
|
|
|
|
|
|
|
|
2018-01-04 19:52:25 +01:00
|
|
|
cbDontCloseColumn.setOnCheckedChangeListener(this)
|
|
|
|
cbWithAttachment.setOnCheckedChangeListener(this)
|
|
|
|
cbWithHighlight.setOnCheckedChangeListener(this)
|
|
|
|
cbDontShowBoost.setOnCheckedChangeListener(this)
|
|
|
|
cbDontShowFollow.setOnCheckedChangeListener(this)
|
|
|
|
cbDontShowFavourite.setOnCheckedChangeListener(this)
|
|
|
|
cbDontShowReply.setOnCheckedChangeListener(this)
|
2018-08-21 12:19:02 +02:00
|
|
|
cbDontShowReaction.setOnCheckedChangeListener(this)
|
|
|
|
cbDontShowVote.setOnCheckedChangeListener(this)
|
2018-02-10 01:36:27 +01:00
|
|
|
cbDontShowNormalToot.setOnCheckedChangeListener(this)
|
2018-03-25 15:27:58 +02:00
|
|
|
cbInstanceLocal.setOnCheckedChangeListener(this)
|
2018-01-04 19:52:25 +01:00
|
|
|
cbDontStreaming.setOnCheckedChangeListener(this)
|
|
|
|
cbDontAutoRefresh.setOnCheckedChangeListener(this)
|
|
|
|
cbHideMediaDefault.setOnCheckedChangeListener(this)
|
2018-02-06 21:41:30 +01:00
|
|
|
cbSystemNotificationNotRelated.setOnCheckedChangeListener(this)
|
2018-01-04 19:52:25 +01:00
|
|
|
cbEnableSpeech.setOnCheckedChangeListener(this)
|
2018-10-10 22:43:10 +02:00
|
|
|
cbOldApi.setOnCheckedChangeListener(this)
|
2018-01-04 19:52:25 +01:00
|
|
|
|
2019-01-11 10:47:30 +01:00
|
|
|
if(Pref.bpMoveNotificationsQuickFilter(activity.pref)) {
|
2019-01-09 09:08:51 +01:00
|
|
|
(svQuickFilter.parent as? ViewGroup)?.removeView(svQuickFilter)
|
2019-01-11 10:47:30 +01:00
|
|
|
llColumnSettingInside.addView(svQuickFilter, 0)
|
2019-01-09 09:08:51 +01:00
|
|
|
|
2019-01-11 10:47:30 +01:00
|
|
|
svQuickFilter.setOnTouchListener { v, event ->
|
2019-01-09 09:08:51 +01:00
|
|
|
val action = event.action
|
2019-01-11 10:47:30 +01:00
|
|
|
if(action == MotionEvent.ACTION_DOWN) {
|
|
|
|
val sv = v as? HorizontalScrollView
|
|
|
|
if(sv != null && sv.getChildAt(0).width > sv.width) {
|
|
|
|
sv.requestDisallowInterceptTouchEvent(true)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
v.onTouchEvent(event)
|
2019-01-09 09:08:51 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-11 10:47:30 +01:00
|
|
|
if(! activity.header_text_size_sp.isNaN()) {
|
|
|
|
tvColumnName.textSize = activity.header_text_size_sp
|
|
|
|
|
|
|
|
val acctSize = activity.header_text_size_sp * 0.857f
|
|
|
|
tvColumnContext.textSize = acctSize
|
|
|
|
tvColumnStatus.textSize = acctSize
|
|
|
|
tvColumnIndex.textSize = acctSize
|
|
|
|
}
|
|
|
|
|
2018-11-17 13:51:01 +01:00
|
|
|
initLoadingTextView()
|
|
|
|
|
2019-01-11 10:47:30 +01:00
|
|
|
var pad = 0
|
|
|
|
var wh = ActMain.headerIconSize + pad * 2
|
|
|
|
ivColumnIcon.layoutParams.width = wh
|
|
|
|
ivColumnIcon.layoutParams.height = wh
|
|
|
|
ivColumnIcon.setPaddingRelative(pad, pad, pad, pad)
|
|
|
|
|
|
|
|
pad = (ActMain.headerIconSize * 0.125f + 0.5f).toInt()
|
|
|
|
wh = ActMain.headerIconSize + pad * 2
|
|
|
|
btnColumnSetting.layoutParams.width = wh
|
|
|
|
btnColumnSetting.layoutParams.height = wh
|
|
|
|
btnColumnSetting.setPaddingRelative(pad, pad, pad, pad)
|
|
|
|
btnColumnReload.layoutParams.width = wh
|
|
|
|
btnColumnReload.layoutParams.height = wh
|
|
|
|
btnColumnReload.setPaddingRelative(pad, pad, pad, pad)
|
|
|
|
btnColumnClose.layoutParams.width = wh
|
|
|
|
btnColumnClose.layoutParams.height = wh
|
|
|
|
btnColumnClose.setPaddingRelative(pad, pad, pad, pad)
|
|
|
|
|
2018-01-04 19:52:25 +01:00
|
|
|
btnSearch.setOnClickListener(this)
|
2019-02-03 15:12:03 +01:00
|
|
|
btnSearchClear.setOnClickListener(this)
|
2018-01-04 19:52:25 +01:00
|
|
|
etSearch.setOnEditorActionListener(TextView.OnEditorActionListener { _, actionId, _ ->
|
2019-02-03 08:54:52 +01:00
|
|
|
if(! binding_busy) {
|
2018-01-04 19:52:25 +01:00
|
|
|
if(actionId == EditorInfo.IME_ACTION_SEARCH) {
|
|
|
|
btnSearch.performClick()
|
|
|
|
return@OnEditorActionListener true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
false
|
|
|
|
})
|
2018-12-12 15:21:38 +01:00
|
|
|
|
2019-02-03 05:29:50 +01:00
|
|
|
// 入力の追跡
|
2019-02-03 08:54:52 +01:00
|
|
|
etRegexFilter.addTextChangedListener(CustomTextWatcher {
|
|
|
|
if(binding_busy || isPageDestroyed) return@CustomTextWatcher
|
|
|
|
if(! isRegexValid()) return@CustomTextWatcher
|
2019-02-03 05:29:50 +01:00
|
|
|
column?.regex_text = etRegexFilter.text.toString()
|
2018-01-04 19:52:25 +01:00
|
|
|
activity.app_state.saveColumnList()
|
2019-02-03 05:29:50 +01:00
|
|
|
activity.handler.removeCallbacks(proc_start_filter)
|
|
|
|
activity.handler.postDelayed(proc_start_filter, 666L)
|
|
|
|
})
|
|
|
|
|
2019-02-03 08:54:52 +01:00
|
|
|
etHashtagExtraAny.addTextChangedListener(CustomTextWatcher {
|
|
|
|
if(binding_busy || isPageDestroyed) return@CustomTextWatcher
|
2019-02-03 05:29:50 +01:00
|
|
|
column?.hashtag_any = etHashtagExtraAny.text.toString()
|
|
|
|
activity.app_state.saveColumnList()
|
|
|
|
activity.handler.removeCallbacks(proc_start_filter)
|
|
|
|
activity.handler.postDelayed(proc_start_filter, 666L)
|
|
|
|
})
|
|
|
|
|
2019-02-03 08:54:52 +01:00
|
|
|
etHashtagExtraAll.addTextChangedListener(CustomTextWatcher {
|
|
|
|
if(binding_busy || isPageDestroyed) return@CustomTextWatcher
|
2019-02-03 05:29:50 +01:00
|
|
|
column?.hashtag_all = etHashtagExtraAll.text.toString()
|
|
|
|
activity.app_state.saveColumnList()
|
|
|
|
activity.handler.removeCallbacks(proc_start_filter)
|
|
|
|
activity.handler.postDelayed(proc_start_filter, 666L)
|
|
|
|
})
|
|
|
|
|
2019-02-03 08:54:52 +01:00
|
|
|
etHashtagExtraNone.addTextChangedListener(CustomTextWatcher {
|
|
|
|
if(binding_busy || isPageDestroyed) return@CustomTextWatcher
|
2019-02-03 05:29:50 +01:00
|
|
|
column?.hashtag_none = etHashtagExtraNone.text.toString()
|
|
|
|
activity.app_state.saveColumnList()
|
|
|
|
activity.handler.removeCallbacks(proc_start_filter)
|
|
|
|
activity.handler.postDelayed(proc_start_filter, 666L)
|
|
|
|
})
|
|
|
|
}
|
2019-02-03 08:54:52 +01:00
|
|
|
|
|
|
|
private val proc_start_filter : Runnable = Runnable {
|
|
|
|
if(binding_busy || isPageDestroyed) return@Runnable
|
|
|
|
column?.startLoading()
|
2018-01-04 19:52:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
private val proc_restoreScrollPosition = object : Runnable {
|
|
|
|
override fun run() {
|
|
|
|
activity.handler.removeCallbacks(this)
|
|
|
|
|
|
|
|
if(isPageDestroyed) {
|
|
|
|
log.d("restoreScrollPosition [%d], page is destroyed.")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2018-01-10 16:47:35 +01:00
|
|
|
val column = this@ColumnViewHolder.column
|
2018-01-04 19:52:25 +01:00
|
|
|
if(column == null) {
|
|
|
|
log.d("restoreScrollPosition [%d], column==null", page_idx)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2018-01-10 16:47:35 +01:00
|
|
|
if(column.is_dispose.get()) {
|
2018-01-04 19:52:25 +01:00
|
|
|
log.d("restoreScrollPosition [%d], column is disposed", page_idx)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2018-01-10 16:47:35 +01:00
|
|
|
if(column.hasMultipleViewHolder()) {
|
2018-01-19 10:27:35 +01:00
|
|
|
log.d(
|
|
|
|
"restoreScrollPosition [%d] %s , column has multiple view holder. retry later.",
|
|
|
|
page_idx,
|
|
|
|
column.getColumnName(true)
|
|
|
|
)
|
2018-01-04 19:52:25 +01:00
|
|
|
|
|
|
|
// タブレットモードでカラムを追加/削除した際に発生する。
|
|
|
|
// このタイミングでスクロール位置を復元してもうまくいかないので延期する
|
|
|
|
activity.handler.postDelayed(this, 100L)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2018-08-18 12:58:14 +02:00
|
|
|
//復元後にもここを通るがこれは正常である
|
|
|
|
val sp = column.scroll_save
|
2018-10-10 22:43:10 +02:00
|
|
|
if(sp == null) {
|
|
|
|
// val lvi = column.last_viewing_item_id
|
|
|
|
// if( lvi != null ){
|
|
|
|
// column.last_viewing_item_id = null
|
|
|
|
// val listIndex = column.findListIndexByTimelineId(lvi)
|
|
|
|
// if( listIndex != null){
|
|
|
|
// log.d(
|
|
|
|
// "restoreScrollPosition [$page_idx] %s , restore from last_viewing_item_id %d"
|
|
|
|
// , column.getColumnName( true )
|
|
|
|
// ,listIndex
|
|
|
|
// )
|
|
|
|
// ScrollPosition(column.toAdapterIndex(listIndex),0).restore(this@ColumnViewHolder)
|
|
|
|
// return
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
|
2018-08-18 12:58:14 +02:00
|
|
|
log.d(
|
|
|
|
"restoreScrollPosition [$page_idx] %s , column has no saved scroll position."
|
2018-10-10 22:43:10 +02:00
|
|
|
, column.getColumnName(true)
|
2018-08-18 12:58:14 +02:00
|
|
|
)
|
|
|
|
return
|
|
|
|
}
|
2018-01-04 19:52:25 +01:00
|
|
|
|
2018-01-17 18:39:16 +01:00
|
|
|
column.scroll_save = null
|
2018-01-04 19:52:25 +01:00
|
|
|
|
|
|
|
if(listView.visibility != View.VISIBLE) {
|
2018-01-19 10:27:35 +01:00
|
|
|
log.d(
|
2018-08-18 12:58:14 +02:00
|
|
|
"restoreScrollPosition [$page_idx] %s , listView is not visible. saved position %s,%s is dropped."
|
2018-10-10 22:43:10 +02:00
|
|
|
, column.getColumnName(true)
|
|
|
|
, sp.adapterIndex
|
|
|
|
, sp.offset
|
2018-01-04 19:52:25 +01:00
|
|
|
)
|
|
|
|
} else {
|
2018-01-19 10:27:35 +01:00
|
|
|
log.d(
|
2018-08-18 12:58:14 +02:00
|
|
|
"restoreScrollPosition [%d] %s , listView is visible. resume %s,%s"
|
2018-10-10 22:43:10 +02:00
|
|
|
, page_idx
|
|
|
|
, column.getColumnName(true)
|
|
|
|
, sp.adapterIndex
|
|
|
|
, sp.offset
|
2018-01-04 19:52:25 +01:00
|
|
|
)
|
2018-01-17 18:39:16 +01:00
|
|
|
sp.restore(this@ColumnViewHolder)
|
2018-01-04 19:52:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fun onPageDestroy(page_idx : Int) {
|
|
|
|
// タブレットモードの場合、onPageCreateより前に呼ばれる
|
2018-01-10 16:47:35 +01:00
|
|
|
val column = this@ColumnViewHolder.column
|
2018-01-04 19:52:25 +01:00
|
|
|
if(column != null) {
|
|
|
|
log.d("onPageDestroy [%d] %s", page_idx, tvColumnName.text)
|
|
|
|
saveScrollPosition()
|
|
|
|
listView.adapter = null
|
2018-01-10 16:47:35 +01:00
|
|
|
column.removeColumnViewHolder(this)
|
|
|
|
this@ColumnViewHolder.column = null
|
2018-01-04 19:52:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
closeBitmaps()
|
|
|
|
|
|
|
|
activity.closeListItemPopup()
|
|
|
|
}
|
|
|
|
|
|
|
|
fun onPageCreate(column : Column, page_idx : Int, page_count : Int) {
|
2019-02-03 08:54:52 +01:00
|
|
|
binding_busy = true
|
2018-01-04 19:52:25 +01:00
|
|
|
try {
|
|
|
|
this.column = column
|
|
|
|
this.page_idx = page_idx
|
|
|
|
|
|
|
|
log.d("onPageCreate [%d] %s", page_idx, column.getColumnName(true))
|
|
|
|
|
2018-01-19 10:27:35 +01:00
|
|
|
val bSimpleList =
|
|
|
|
column.column_type != Column.TYPE_CONVERSATION && Pref.bpSimpleList(activity.pref)
|
2018-01-04 19:52:25 +01:00
|
|
|
|
|
|
|
tvColumnIndex.text = activity.getString(R.string.column_index, page_idx + 1, page_count)
|
2018-04-20 15:22:21 +02:00
|
|
|
tvColumnStatus.text = "?"
|
2019-01-17 20:40:51 +01:00
|
|
|
ivColumnIcon.setImageResource(column.getIconId(column.column_type))
|
2018-01-04 19:52:25 +01:00
|
|
|
|
|
|
|
listView.adapter = null
|
2018-08-15 15:27:04 +02:00
|
|
|
if(listView.itemDecorationCount == 0) {
|
|
|
|
listView.addItemDecoration(ListDivider(activity))
|
|
|
|
}
|
|
|
|
|
2018-01-17 18:39:16 +01:00
|
|
|
val status_adapter = ItemListAdapter(activity, column, this, bSimpleList)
|
2018-01-04 19:52:25 +01:00
|
|
|
this.status_adapter = status_adapter
|
|
|
|
|
2019-06-04 03:49:48 +02:00
|
|
|
val isNotificationColumn = column.isNotificationColumn
|
2018-01-04 19:52:25 +01:00
|
|
|
|
|
|
|
// 添付メディアや正規表現のフィルタ
|
|
|
|
val bAllowFilter = column.canStatusFilter()
|
|
|
|
|
|
|
|
llColumnSetting.visibility = View.GONE
|
|
|
|
|
|
|
|
cbDontCloseColumn.isChecked = column.dont_close
|
|
|
|
cbWithAttachment.isChecked = column.with_attachment
|
|
|
|
cbWithHighlight.isChecked = column.with_highlight
|
|
|
|
cbDontShowBoost.isChecked = column.dont_show_boost
|
|
|
|
cbDontShowFollow.isChecked = column.dont_show_follow
|
|
|
|
cbDontShowFavourite.isChecked = column.dont_show_favourite
|
|
|
|
cbDontShowReply.isChecked = column.dont_show_reply
|
2018-08-21 12:19:02 +02:00
|
|
|
cbDontShowReaction.isChecked = column.dont_show_reaction
|
|
|
|
cbDontShowVote.isChecked = column.dont_show_vote
|
2018-02-10 01:36:27 +01:00
|
|
|
cbDontShowNormalToot.isChecked = column.dont_show_normal_toot
|
2018-03-25 15:27:58 +02:00
|
|
|
cbInstanceLocal.isChecked = column.instance_local
|
2018-01-04 19:52:25 +01:00
|
|
|
cbDontStreaming.isChecked = column.dont_streaming
|
|
|
|
cbDontAutoRefresh.isChecked = column.dont_auto_refresh
|
|
|
|
cbHideMediaDefault.isChecked = column.hide_media_default
|
2018-02-06 21:41:30 +01:00
|
|
|
cbSystemNotificationNotRelated.isChecked = column.system_notification_not_related
|
2018-01-04 19:52:25 +01:00
|
|
|
cbEnableSpeech.isChecked = column.enable_speech
|
2018-10-10 22:43:10 +02:00
|
|
|
cbOldApi.isChecked = column.use_old_api
|
2018-01-04 19:52:25 +01:00
|
|
|
|
2018-01-17 18:39:16 +01:00
|
|
|
etRegexFilter.setText(column.regex_text)
|
2018-01-04 19:52:25 +01:00
|
|
|
etSearch.setText(column.search_query)
|
|
|
|
cbResolve.isChecked = column.search_resolve
|
|
|
|
|
|
|
|
vg(cbWithAttachment, bAllowFilter)
|
|
|
|
vg(cbWithHighlight, bAllowFilter)
|
|
|
|
vg(etRegexFilter, bAllowFilter)
|
|
|
|
vg(llRegexFilter, bAllowFilter)
|
|
|
|
|
|
|
|
vg(cbDontShowBoost, column.canFilterBoost())
|
|
|
|
vg(cbDontShowReply, column.canFilterReply())
|
2018-02-10 01:36:27 +01:00
|
|
|
vg(cbDontShowNormalToot, column.canFilterNormalToot())
|
2018-08-21 12:19:02 +02:00
|
|
|
vg(cbDontShowReaction, isNotificationColumn && column.isMisskey)
|
2019-03-13 18:34:56 +01:00
|
|
|
vg(cbDontShowVote, isNotificationColumn )
|
2019-01-08 05:30:18 +01:00
|
|
|
vg(cbDontShowFavourite, isNotificationColumn && ! column.isMisskey)
|
2018-01-04 19:52:25 +01:00
|
|
|
vg(cbDontShowFollow, isNotificationColumn)
|
|
|
|
|
2018-03-25 15:27:58 +02:00
|
|
|
vg(cbInstanceLocal, column.column_type == Column.TYPE_HASHTAG)
|
|
|
|
|
|
|
|
|
2018-01-04 19:52:25 +01:00
|
|
|
vg(cbDontStreaming, column.canStreaming())
|
|
|
|
vg(cbDontAutoRefresh, column.canAutoRefresh())
|
|
|
|
vg(cbHideMediaDefault, column.canNSFWDefault())
|
2019-06-04 03:49:48 +02:00
|
|
|
vg(cbSystemNotificationNotRelated, column.isNotificationColumn)
|
2018-01-04 19:52:25 +01:00
|
|
|
vg(cbEnableSpeech, column.canSpeech())
|
2018-10-10 22:43:10 +02:00
|
|
|
vg(cbOldApi, column.column_type == Column.TYPE_DIRECT_MESSAGES)
|
|
|
|
|
2018-01-04 19:52:25 +01:00
|
|
|
|
2019-06-04 03:49:48 +02:00
|
|
|
vg(btnDeleteNotification, column.isNotificationColumn)
|
2019-02-03 15:12:03 +01:00
|
|
|
|
|
|
|
if( vg(llSearch, column.isSearchColumn) ){
|
|
|
|
vg(btnSearchClear,Pref.bpShowSearchClear(activity.pref))
|
|
|
|
}
|
|
|
|
|
2018-01-04 19:52:25 +01:00
|
|
|
vg(llListList, column.column_type == Column.TYPE_LIST_LIST)
|
|
|
|
vg(cbResolve, column.column_type == Column.TYPE_SEARCH)
|
|
|
|
|
2019-07-09 13:56:22 +02:00
|
|
|
vg(llHashtagExtra, column.hasHashtagExtra())
|
2019-02-03 05:29:50 +01:00
|
|
|
etHashtagExtraAny.setText(column.hashtag_any)
|
|
|
|
etHashtagExtraAll.setText(column.hashtag_all)
|
|
|
|
etHashtagExtraNone.setText(column.hashtag_none)
|
|
|
|
|
2018-01-04 19:52:25 +01:00
|
|
|
// tvRegexFilterErrorの表示を更新
|
|
|
|
if(bAllowFilter) {
|
2018-06-30 13:18:17 +02:00
|
|
|
isRegexValid()
|
2018-01-04 19:52:25 +01:00
|
|
|
}
|
|
|
|
|
2018-08-25 02:29:24 +02:00
|
|
|
val canRefreshTop = column.canRefreshTopBySwipe()
|
|
|
|
val canRefreshBottom = column.canRefreshBottomBySwipe()
|
|
|
|
|
|
|
|
refreshLayout.isEnabled = canRefreshTop || canRefreshBottom
|
2018-10-10 22:43:10 +02:00
|
|
|
refreshLayout.direction = if(canRefreshTop && canRefreshBottom) {
|
2018-08-25 02:29:24 +02:00
|
|
|
SwipyRefreshLayoutDirection.BOTH
|
2018-10-10 22:43:10 +02:00
|
|
|
} else if(canRefreshTop) {
|
2018-08-25 02:29:24 +02:00
|
|
|
SwipyRefreshLayoutDirection.TOP
|
2018-10-10 22:43:10 +02:00
|
|
|
} else {
|
2018-08-25 02:29:24 +02:00
|
|
|
SwipyRefreshLayoutDirection.BOTTOM
|
2018-01-04 19:52:25 +01:00
|
|
|
}
|
|
|
|
|
2018-11-20 10:32:30 +01:00
|
|
|
bRefreshErrorWillShown = false
|
|
|
|
llRefreshError.clearAnimation()
|
|
|
|
llRefreshError.visibility = View.GONE
|
|
|
|
|
2018-01-04 19:52:25 +01:00
|
|
|
//
|
2019-02-25 09:00:36 +01:00
|
|
|
listLayoutManager = LinearLayoutManager(activity)
|
2018-01-17 18:39:16 +01:00
|
|
|
listView.layoutManager = listLayoutManager
|
2018-01-04 19:52:25 +01:00
|
|
|
listView.adapter = status_adapter
|
2018-01-17 18:39:16 +01:00
|
|
|
|
|
|
|
//XXX FastScrollerのサポートを諦める。ライブラリはいくつかあるんだけど、設定でON/OFFできなかったり頭文字バブルを無効にできなかったり
|
|
|
|
// listView.isFastScrollEnabled = ! Pref.bpDisableFastScroller(Pref.pref(activity))
|
2018-01-04 19:52:25 +01:00
|
|
|
|
|
|
|
column.addColumnViewHolder(this)
|
|
|
|
|
|
|
|
showColumnColor()
|
|
|
|
|
2018-01-21 13:46:36 +01:00
|
|
|
showContent(reason = "onPageCreate", reset = true)
|
2018-01-04 19:52:25 +01:00
|
|
|
} finally {
|
2019-02-03 08:54:52 +01:00
|
|
|
binding_busy = false
|
2018-01-04 19:52:25 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-01 00:02:18 +01:00
|
|
|
private val procShowColumnStatus : Runnable = Runnable {
|
2018-04-21 01:16:44 +02:00
|
|
|
|
2018-11-15 23:08:11 +01:00
|
|
|
val column = this.column
|
2018-11-18 03:38:52 +01:00
|
|
|
if(column == null || column.is_dispose.get()) return@Runnable
|
2018-04-21 01:16:44 +02:00
|
|
|
|
2018-11-15 23:08:11 +01:00
|
|
|
val sb = SpannableStringBuilder()
|
2018-04-20 15:22:21 +02:00
|
|
|
try {
|
2018-11-15 23:08:11 +01:00
|
|
|
|
|
|
|
val task = column.lastTask
|
|
|
|
if(task != null) {
|
|
|
|
sb.append(
|
|
|
|
when(task.ctType) {
|
|
|
|
ColumnTaskType.LOADING -> 'L'
|
|
|
|
ColumnTaskType.REFRESH_TOP -> 'T'
|
|
|
|
ColumnTaskType.REFRESH_BOTTOM -> 'B'
|
|
|
|
ColumnTaskType.GAP -> 'G'
|
2018-04-21 01:16:44 +02:00
|
|
|
}
|
2018-11-15 23:08:11 +01:00
|
|
|
)
|
|
|
|
sb.append(
|
|
|
|
when {
|
|
|
|
task.isCancelled -> "~"
|
|
|
|
task.ctClosed.get() -> "!"
|
|
|
|
task.ctStarted.get() -> ""
|
|
|
|
else -> "?"
|
2018-04-21 01:16:44 +02:00
|
|
|
}
|
2018-11-15 23:08:11 +01:00
|
|
|
)
|
|
|
|
}
|
|
|
|
when(column.getStreamingStatus()) {
|
|
|
|
StreamingIndicatorState.NONE -> {
|
|
|
|
}
|
|
|
|
|
|
|
|
StreamingIndicatorState.REGISTERED -> {
|
|
|
|
sb.appendColorShadeIcon(activity, R.drawable.ic_pulse, "Streaming")
|
|
|
|
sb.append("?")
|
|
|
|
}
|
|
|
|
|
|
|
|
StreamingIndicatorState.LISTENING -> {
|
|
|
|
sb.appendColorShadeIcon(activity, R.drawable.ic_pulse, "Streaming")
|
2018-04-20 15:22:21 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} finally {
|
|
|
|
log.d("showColumnStatus ${sb}")
|
|
|
|
tvColumnStatus.text = sb
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-11-15 23:08:11 +01:00
|
|
|
fun showColumnStatus() {
|
|
|
|
activity.handler.removeCallbacks(procShowColumnStatus)
|
2018-11-18 03:38:52 +01:00
|
|
|
activity.handler.postDelayed(procShowColumnStatus, 50L)
|
2018-11-15 23:08:11 +01:00
|
|
|
}
|
|
|
|
|
2018-01-04 19:52:25 +01:00
|
|
|
fun showColumnColor() {
|
|
|
|
val column = this.column
|
2018-11-18 03:38:52 +01:00
|
|
|
if(column == null || column.is_dispose.get()) return
|
2018-11-20 10:32:30 +01:00
|
|
|
|
2018-11-18 15:29:35 +01:00
|
|
|
// カラムヘッダ背景
|
2018-11-19 23:46:14 +01:00
|
|
|
column.setHeaderBackground(llColumnHeader)
|
2018-11-20 10:32:30 +01:00
|
|
|
|
2018-11-18 15:29:35 +01:00
|
|
|
// カラムヘッダ文字色(A)
|
2018-11-19 23:46:14 +01:00
|
|
|
var c = column.getHeaderNameColor()
|
2019-01-17 20:40:51 +01:00
|
|
|
val csl = ColorStateList.valueOf(c)
|
2018-11-20 10:32:30 +01:00
|
|
|
tvColumnName.textColor = c
|
2019-01-17 20:40:51 +01:00
|
|
|
ivColumnIcon.imageTintList = csl
|
|
|
|
btnColumnSetting.imageTintList = csl
|
|
|
|
btnColumnReload.imageTintList = csl
|
|
|
|
btnColumnClose.imageTintList = csl
|
2018-11-18 15:29:35 +01:00
|
|
|
|
|
|
|
// カラムヘッダ文字色(B)
|
2018-11-19 23:46:14 +01:00
|
|
|
c = column.getHeaderPageNumberColor()
|
2018-11-20 10:32:30 +01:00
|
|
|
tvColumnIndex.textColor = c
|
|
|
|
tvColumnStatus.textColor = c
|
2018-11-18 15:29:35 +01:00
|
|
|
|
|
|
|
// カラム内部の背景色
|
2019-01-18 16:33:53 +01:00
|
|
|
flColumnBackground.setBackgroundColor(
|
|
|
|
column.column_bg_color.notZero()
|
|
|
|
?: Column.defaultColorContentBg
|
|
|
|
)
|
2018-11-18 03:38:52 +01:00
|
|
|
|
2018-11-18 15:29:35 +01:00
|
|
|
// カラム内部の背景画像
|
2018-11-18 03:38:52 +01:00
|
|
|
ivColumnBackgroundImage.alpha = column.column_bg_image_alpha
|
|
|
|
loadBackgroundImage(ivColumnBackgroundImage, column.column_bg_image)
|
2018-11-20 10:32:30 +01:00
|
|
|
|
2018-11-18 15:29:35 +01:00
|
|
|
// エラー表示
|
2018-11-19 23:46:14 +01:00
|
|
|
tvLoading.textColor = column.getContentColor()
|
2018-11-18 03:38:52 +01:00
|
|
|
|
|
|
|
status_adapter?.findHeaderViewHolder(listView)?.showColor()
|
2019-01-18 10:28:04 +01:00
|
|
|
|
|
|
|
// カラム色を変更したらクイックフィルタの色も変わる場合がある
|
|
|
|
showQuickFilter()
|
2018-01-04 19:52:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
private fun closeBitmaps() {
|
|
|
|
try {
|
|
|
|
ivColumnBackgroundImage.visibility = View.GONE
|
|
|
|
ivColumnBackgroundImage.setImageDrawable(null)
|
|
|
|
|
2018-01-10 16:47:35 +01:00
|
|
|
last_image_bitmap?.recycle()
|
|
|
|
last_image_bitmap = null
|
2018-01-04 19:52:25 +01:00
|
|
|
|
2018-01-17 18:39:16 +01:00
|
|
|
last_image_task?.cancel(true)
|
2018-01-10 16:47:35 +01:00
|
|
|
last_image_task = null
|
2018-01-04 19:52:25 +01:00
|
|
|
|
|
|
|
last_image_uri = null
|
|
|
|
|
|
|
|
} catch(ex : Throwable) {
|
|
|
|
log.trace(ex)
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@SuppressLint("StaticFieldLeak")
|
|
|
|
private fun loadBackgroundImage(iv : ImageView, url : String?) {
|
|
|
|
try {
|
2019-02-23 10:45:54 +01:00
|
|
|
if(url == null || url.isEmpty() || Pref.bpDontShowColumnBackgroundImage(activity.pref) ) {
|
2018-01-04 19:52:25 +01:00
|
|
|
// 指定がないなら閉じる
|
|
|
|
closeBitmaps()
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
if(url == last_image_uri) {
|
|
|
|
// 今表示してるのと同じ
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// 直前の処理をキャンセルする。Bitmapも破棄する
|
|
|
|
closeBitmaps()
|
|
|
|
|
|
|
|
// ロード開始
|
|
|
|
last_image_uri = url
|
|
|
|
val screen_w = iv.resources.displayMetrics.widthPixels
|
|
|
|
val screen_h = iv.resources.displayMetrics.heightPixels
|
|
|
|
|
|
|
|
// 非同期処理を開始
|
2018-01-10 16:47:35 +01:00
|
|
|
val task = object : AsyncTask<Void, Void, Bitmap?>() {
|
2018-01-04 19:52:25 +01:00
|
|
|
override fun doInBackground(vararg params : Void) : Bitmap? {
|
2018-01-21 13:46:36 +01:00
|
|
|
return try {
|
|
|
|
createResizedBitmap(
|
2018-11-30 05:42:20 +01:00
|
|
|
activity, url.toUri(),
|
|
|
|
if(screen_w > screen_h)
|
|
|
|
screen_w
|
|
|
|
else
|
|
|
|
screen_h
|
2018-01-21 13:46:36 +01:00
|
|
|
)
|
2018-01-04 19:52:25 +01:00
|
|
|
} catch(ex : Throwable) {
|
|
|
|
log.trace(ex)
|
2018-01-21 13:46:36 +01:00
|
|
|
null
|
2018-01-04 19:52:25 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-01-10 16:47:35 +01:00
|
|
|
override fun onCancelled(bitmap : Bitmap?) {
|
2018-01-04 19:52:25 +01:00
|
|
|
onPostExecute(bitmap)
|
|
|
|
}
|
|
|
|
|
|
|
|
override fun onPostExecute(bitmap : Bitmap?) {
|
|
|
|
if(bitmap != null) {
|
|
|
|
if(isCancelled || url != last_image_uri) {
|
|
|
|
bitmap.recycle()
|
|
|
|
} else {
|
|
|
|
last_image_bitmap = bitmap
|
|
|
|
iv.setImageBitmap(last_image_bitmap)
|
|
|
|
iv.visibility = View.VISIBLE
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-01-10 16:47:35 +01:00
|
|
|
last_image_task = task
|
|
|
|
task.executeOnExecutor(App1.task_executor)
|
2018-01-04 19:52:25 +01:00
|
|
|
|
|
|
|
} catch(ex : Throwable) {
|
|
|
|
log.trace(ex)
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
fun closeColumnSetting() {
|
|
|
|
llColumnSetting.visibility = View.GONE
|
|
|
|
}
|
|
|
|
|
|
|
|
fun onListListUpdated() {
|
|
|
|
etListName.setText("")
|
|
|
|
}
|
|
|
|
|
|
|
|
override fun onRefresh(direction : SwipyRefreshLayoutDirection) {
|
2018-01-10 16:47:35 +01:00
|
|
|
val column = this.column ?: return
|
2018-01-04 19:52:25 +01:00
|
|
|
|
|
|
|
// カラムを追加/削除したときに ColumnからColumnViewHolderへの参照が外れることがある
|
|
|
|
// リロードやリフレッシュ操作で直るようにする
|
2018-01-17 18:39:16 +01:00
|
|
|
column.addColumnViewHolder(this)
|
2018-01-04 19:52:25 +01:00
|
|
|
|
2018-01-17 18:39:16 +01:00
|
|
|
if(direction == SwipyRefreshLayoutDirection.TOP && column.canReloadWhenRefreshTop()) {
|
2018-01-04 19:52:25 +01:00
|
|
|
refreshLayout.isRefreshing = false
|
2018-01-10 16:47:35 +01:00
|
|
|
activity.handler.post {
|
|
|
|
this@ColumnViewHolder.column?.startLoading()
|
|
|
|
}
|
2018-01-04 19:52:25 +01:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2018-10-10 22:43:10 +02:00
|
|
|
column.startRefresh(false, direction == SwipyRefreshLayoutDirection.BOTTOM)
|
2018-01-04 19:52:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
override fun onCheckedChanged(view : CompoundButton, isChecked : Boolean) {
|
2018-01-10 16:47:35 +01:00
|
|
|
val column = this@ColumnViewHolder.column
|
|
|
|
|
2019-02-03 08:54:52 +01:00
|
|
|
if(binding_busy || column == null || status_adapter == null) return
|
2018-01-04 19:52:25 +01:00
|
|
|
|
|
|
|
// カラムを追加/削除したときに ColumnからColumnViewHolderへの参照が外れることがある
|
|
|
|
// リロードやリフレッシュ操作で直るようにする
|
2018-01-17 18:39:16 +01:00
|
|
|
column.addColumnViewHolder(this)
|
2018-01-04 19:52:25 +01:00
|
|
|
|
|
|
|
when(view.id) {
|
|
|
|
|
|
|
|
R.id.cbDontCloseColumn -> {
|
2018-01-17 18:39:16 +01:00
|
|
|
column.dont_close = isChecked
|
2018-01-04 19:52:25 +01:00
|
|
|
showColumnCloseButton()
|
|
|
|
activity.app_state.saveColumnList()
|
|
|
|
}
|
|
|
|
|
|
|
|
R.id.cbWithAttachment -> {
|
2018-01-17 18:39:16 +01:00
|
|
|
column.with_attachment = isChecked
|
2018-01-04 19:52:25 +01:00
|
|
|
activity.app_state.saveColumnList()
|
2018-01-17 18:39:16 +01:00
|
|
|
column.startLoading()
|
2018-01-04 19:52:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
R.id.cbWithHighlight -> {
|
2018-01-17 18:39:16 +01:00
|
|
|
column.with_highlight = isChecked
|
2018-01-04 19:52:25 +01:00
|
|
|
activity.app_state.saveColumnList()
|
2018-01-17 18:39:16 +01:00
|
|
|
column.startLoading()
|
2018-01-04 19:52:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
R.id.cbDontShowBoost -> {
|
2018-01-17 18:39:16 +01:00
|
|
|
column.dont_show_boost = isChecked
|
2018-01-04 19:52:25 +01:00
|
|
|
activity.app_state.saveColumnList()
|
2018-01-17 18:39:16 +01:00
|
|
|
column.startLoading()
|
2018-01-04 19:52:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
R.id.cbDontShowReply -> {
|
2018-01-17 18:39:16 +01:00
|
|
|
column.dont_show_reply = isChecked
|
2018-01-04 19:52:25 +01:00
|
|
|
activity.app_state.saveColumnList()
|
2018-02-10 01:36:27 +01:00
|
|
|
column.startLoading()
|
|
|
|
}
|
2018-10-10 22:43:10 +02:00
|
|
|
|
2018-08-21 12:19:02 +02:00
|
|
|
R.id.cbDontShowReaction -> {
|
|
|
|
column.dont_show_reaction = isChecked
|
|
|
|
activity.app_state.saveColumnList()
|
|
|
|
column.startLoading()
|
|
|
|
}
|
2018-10-10 22:43:10 +02:00
|
|
|
|
2018-08-21 12:19:02 +02:00
|
|
|
R.id.cbDontShowVote -> {
|
|
|
|
column.dont_show_vote = isChecked
|
|
|
|
activity.app_state.saveColumnList()
|
|
|
|
column.startLoading()
|
|
|
|
}
|
2018-10-10 22:43:10 +02:00
|
|
|
|
2018-02-10 01:36:27 +01:00
|
|
|
R.id.cbDontShowNormalToot -> {
|
|
|
|
column.dont_show_normal_toot = isChecked
|
|
|
|
activity.app_state.saveColumnList()
|
2018-01-17 18:39:16 +01:00
|
|
|
column.startLoading()
|
2018-01-04 19:52:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
R.id.cbDontShowFavourite -> {
|
2018-01-17 18:39:16 +01:00
|
|
|
column.dont_show_favourite = isChecked
|
2018-01-04 19:52:25 +01:00
|
|
|
activity.app_state.saveColumnList()
|
2018-01-17 18:39:16 +01:00
|
|
|
column.startLoading()
|
2018-01-04 19:52:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
R.id.cbDontShowFollow -> {
|
2018-01-17 18:39:16 +01:00
|
|
|
column.dont_show_follow = isChecked
|
2018-01-04 19:52:25 +01:00
|
|
|
activity.app_state.saveColumnList()
|
2018-01-17 18:39:16 +01:00
|
|
|
column.startLoading()
|
2018-01-04 19:52:25 +01:00
|
|
|
}
|
|
|
|
|
2018-03-25 15:27:58 +02:00
|
|
|
R.id.cbInstanceLocal -> {
|
|
|
|
column.instance_local = isChecked
|
|
|
|
activity.app_state.saveColumnList()
|
|
|
|
column.startLoading()
|
|
|
|
}
|
|
|
|
|
2018-01-04 19:52:25 +01:00
|
|
|
R.id.cbDontStreaming -> {
|
2018-01-17 18:39:16 +01:00
|
|
|
column.dont_streaming = isChecked
|
2018-01-04 19:52:25 +01:00
|
|
|
activity.app_state.saveColumnList()
|
|
|
|
if(isChecked) {
|
2018-01-17 18:39:16 +01:00
|
|
|
column.stopStreaming()
|
2018-01-04 19:52:25 +01:00
|
|
|
} else {
|
2018-01-17 18:39:16 +01:00
|
|
|
column.onStart(activity)
|
2018-01-04 19:52:25 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
R.id.cbDontAutoRefresh -> {
|
2018-01-17 18:39:16 +01:00
|
|
|
column.dont_auto_refresh = isChecked
|
2018-01-04 19:52:25 +01:00
|
|
|
activity.app_state.saveColumnList()
|
|
|
|
}
|
|
|
|
|
|
|
|
R.id.cbHideMediaDefault -> {
|
2018-01-17 18:39:16 +01:00
|
|
|
column.hide_media_default = isChecked
|
2018-01-04 19:52:25 +01:00
|
|
|
activity.app_state.saveColumnList()
|
2018-01-21 13:46:36 +01:00
|
|
|
column.fireShowContent(reason = "HideMediaDefault in ColumnSetting", reset = true)
|
2018-01-04 19:52:25 +01:00
|
|
|
}
|
2018-04-20 15:22:21 +02:00
|
|
|
|
2018-02-06 21:41:30 +01:00
|
|
|
R.id.cbSystemNotificationNotRelated -> {
|
|
|
|
column.system_notification_not_related = isChecked
|
|
|
|
activity.app_state.saveColumnList()
|
|
|
|
}
|
2018-04-20 15:22:21 +02:00
|
|
|
|
2018-01-04 19:52:25 +01:00
|
|
|
R.id.cbEnableSpeech -> {
|
2018-01-17 18:39:16 +01:00
|
|
|
column.enable_speech = isChecked
|
2018-01-04 19:52:25 +01:00
|
|
|
activity.app_state.saveColumnList()
|
|
|
|
}
|
2018-10-10 22:43:10 +02:00
|
|
|
|
|
|
|
R.id.cbOldApi -> {
|
|
|
|
column.use_old_api = isChecked
|
|
|
|
activity.app_state.saveColumnList()
|
|
|
|
column.startLoading()
|
|
|
|
}
|
2018-01-04 19:52:25 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
override fun onClick(v : View) {
|
|
|
|
val column = this.column
|
2018-01-10 16:47:35 +01:00
|
|
|
val status_adapter = this.status_adapter
|
2019-02-03 08:54:52 +01:00
|
|
|
if(binding_busy || column == null || status_adapter == null) return
|
2018-01-04 19:52:25 +01:00
|
|
|
|
|
|
|
// カラムを追加/削除したときに ColumnからColumnViewHolderへの参照が外れることがある
|
|
|
|
// リロードやリフレッシュ操作で直るようにする
|
|
|
|
column.addColumnViewHolder(this)
|
|
|
|
|
|
|
|
when(v.id) {
|
2018-10-10 22:43:10 +02:00
|
|
|
R.id.btnColumnClose -> activity.closeColumn(column)
|
2018-01-04 19:52:25 +01:00
|
|
|
|
|
|
|
R.id.btnColumnReload -> {
|
|
|
|
App1.custom_emoji_cache.clearErrorCache()
|
|
|
|
|
|
|
|
if(column.isSearchColumn) {
|
2018-01-21 13:46:36 +01:00
|
|
|
etSearch.hideKeyboard()
|
2018-01-04 19:52:25 +01:00
|
|
|
etSearch.setText(column.search_query)
|
|
|
|
cbResolve.isChecked = column.search_resolve
|
|
|
|
}
|
|
|
|
refreshLayout.isRefreshing = false
|
|
|
|
column.startLoading()
|
|
|
|
}
|
|
|
|
|
|
|
|
R.id.btnSearch -> {
|
2018-01-21 13:46:36 +01:00
|
|
|
etSearch.hideKeyboard()
|
2018-01-04 19:52:25 +01:00
|
|
|
column.search_query = etSearch.text.toString().trim { it <= ' ' }
|
|
|
|
column.search_resolve = cbResolve.isChecked
|
|
|
|
activity.app_state.saveColumnList()
|
|
|
|
column.startLoading()
|
|
|
|
}
|
|
|
|
|
2019-02-03 15:12:03 +01:00
|
|
|
R.id.btnSearchClear -> {
|
|
|
|
etSearch.setText("")
|
|
|
|
column.search_query = ""
|
|
|
|
column.search_resolve = cbResolve.isChecked
|
|
|
|
activity.app_state.saveColumnList()
|
|
|
|
column.startLoading()
|
|
|
|
}
|
|
|
|
|
2018-07-10 08:44:34 +02:00
|
|
|
R.id.llColumnHeader -> scrollToTop2()
|
2018-01-04 19:52:25 +01:00
|
|
|
|
2018-01-19 10:27:35 +01:00
|
|
|
R.id.btnColumnSetting -> llColumnSetting.visibility =
|
|
|
|
if(llColumnSetting.visibility == View.VISIBLE) View.GONE else View.VISIBLE
|
2018-01-04 19:52:25 +01:00
|
|
|
|
2018-01-19 10:27:35 +01:00
|
|
|
R.id.btnDeleteNotification -> Action_Notification.deleteAll(
|
|
|
|
activity,
|
|
|
|
column.access_info,
|
|
|
|
false
|
|
|
|
)
|
2018-01-04 19:52:25 +01:00
|
|
|
|
|
|
|
R.id.btnColor -> {
|
|
|
|
val idx = activity.app_state.column_list.indexOf(column)
|
|
|
|
ActColumnCustomize.open(activity, idx, ActMain.REQUEST_CODE_COLUMN_COLOR)
|
|
|
|
}
|
|
|
|
|
|
|
|
R.id.btnListAdd -> {
|
|
|
|
val tv = etListName.text.toString().trim { it <= ' ' }
|
|
|
|
if(tv.isEmpty()) {
|
2018-01-21 13:46:36 +01:00
|
|
|
showToast(activity, true, R.string.list_name_empty)
|
2018-01-04 19:52:25 +01:00
|
|
|
return
|
|
|
|
}
|
|
|
|
Action_List.create(activity, column.access_info, tv, null)
|
|
|
|
}
|
2018-11-20 10:32:30 +01:00
|
|
|
|
|
|
|
R.id.llRefreshError -> {
|
|
|
|
column.mRefreshLoadingErrorPopupState = 1 - column.mRefreshLoadingErrorPopupState
|
|
|
|
showRefreshError()
|
|
|
|
}
|
2019-01-08 05:30:18 +01:00
|
|
|
|
|
|
|
R.id.btnQuickFilterAll -> clickQuickFilter(Column.QUICK_FILTER_ALL)
|
|
|
|
R.id.btnQuickFilterMention -> clickQuickFilter(Column.QUICK_FILTER_MENTION)
|
|
|
|
R.id.btnQuickFilterFavourite -> clickQuickFilter(Column.QUICK_FILTER_FAVOURITE)
|
|
|
|
R.id.btnQuickFilterBoost -> clickQuickFilter(Column.QUICK_FILTER_BOOST)
|
|
|
|
R.id.btnQuickFilterFollow -> clickQuickFilter(Column.QUICK_FILTER_FOLLOW)
|
|
|
|
R.id.btnQuickFilterReaction -> clickQuickFilter(Column.QUICK_FILTER_REACTION)
|
|
|
|
R.id.btnQuickFilterVote -> clickQuickFilter(Column.QUICK_FILTER_VOTE)
|
|
|
|
|
2018-01-04 19:52:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2018-07-05 14:38:48 +02:00
|
|
|
override fun onLongClick(v : View) : Boolean {
|
2018-07-08 19:00:47 +02:00
|
|
|
return when(v.id) {
|
|
|
|
R.id.btnColumnClose -> {
|
2018-07-05 14:38:48 +02:00
|
|
|
val idx = activity.app_state.column_list.indexOf(column)
|
2018-07-08 19:00:47 +02:00
|
|
|
activity.closeColumnAll(idx)
|
2018-07-05 14:38:48 +02:00
|
|
|
true
|
|
|
|
}
|
2018-07-08 19:00:47 +02:00
|
|
|
|
|
|
|
else -> false
|
2018-07-05 14:38:48 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-01-04 19:52:25 +01:00
|
|
|
private fun showError(message : String) {
|
2018-11-20 10:32:30 +01:00
|
|
|
hideRefreshError()
|
2018-01-04 19:52:25 +01:00
|
|
|
tvLoading.visibility = View.VISIBLE
|
|
|
|
tvLoading.text = message
|
|
|
|
|
|
|
|
refreshLayout.isRefreshing = false
|
|
|
|
refreshLayout.visibility = View.GONE
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
private fun showColumnCloseButton() {
|
2018-01-21 13:46:36 +01:00
|
|
|
val dont_close = column?.dont_close ?: return
|
2018-01-19 10:27:35 +01:00
|
|
|
btnColumnClose.isEnabled = ! dont_close
|
|
|
|
btnColumnClose.alpha = if(dont_close) 0.3f else 1f
|
2018-01-04 19:52:25 +01:00
|
|
|
}
|
|
|
|
|
2018-01-20 07:51:14 +01:00
|
|
|
// 相対時刻を更新する
|
|
|
|
fun updateRelativeTime() = rebindAdapterItems()
|
|
|
|
|
|
|
|
fun rebindAdapterItems() {
|
2018-01-21 13:46:36 +01:00
|
|
|
for(childIndex in 0 until listView.childCount) {
|
2018-01-20 07:51:14 +01:00
|
|
|
val adapterIndex = listView.getChildAdapterPosition(listView.getChildAt(childIndex))
|
2019-02-15 02:51:22 +01:00
|
|
|
if(adapterIndex == androidx.recyclerview.widget.RecyclerView.NO_POSITION) continue
|
2018-01-21 13:46:36 +01:00
|
|
|
status_adapter?.notifyItemChanged(adapterIndex)
|
2018-01-20 07:51:14 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-01 00:02:18 +01:00
|
|
|
private val procShowColumnHeader : Runnable = Runnable {
|
2018-11-18 03:38:52 +01:00
|
|
|
|
2018-11-15 23:08:11 +01:00
|
|
|
val column = this.column
|
2018-11-18 03:38:52 +01:00
|
|
|
if(column == null || column.is_dispose.get()) return@Runnable
|
2018-01-04 19:52:25 +01:00
|
|
|
|
|
|
|
val acct = column.access_info.acct
|
|
|
|
val ac = AcctColor.load(acct)
|
|
|
|
|
|
|
|
val nickname = ac.nickname
|
2018-11-18 03:38:52 +01:00
|
|
|
tvColumnContext.text = if(nickname != null && nickname.isNotEmpty())
|
|
|
|
nickname
|
|
|
|
else
|
|
|
|
acct
|
2018-01-04 19:52:25 +01:00
|
|
|
|
2018-01-17 18:39:16 +01:00
|
|
|
|
2018-01-19 10:27:35 +01:00
|
|
|
tvColumnContext.setTextColor(
|
2019-01-18 16:33:53 +01:00
|
|
|
ac.color_fg.notZero()
|
|
|
|
?: getAttributeColor(activity, R.attr.colorTimeSmall)
|
2018-01-19 10:27:35 +01:00
|
|
|
)
|
2018-01-04 19:52:25 +01:00
|
|
|
|
2019-01-18 16:33:53 +01:00
|
|
|
tvColumnContext.setBackgroundColor(ac.color_bg)
|
2018-01-04 19:52:25 +01:00
|
|
|
tvColumnContext.setPaddingRelative(activity.acct_pad_lr, 0, activity.acct_pad_lr, 0)
|
|
|
|
|
|
|
|
tvColumnName.text = column.getColumnName(false)
|
|
|
|
|
|
|
|
showColumnCloseButton()
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2018-11-15 23:08:11 +01:00
|
|
|
// カラムヘッダなど、負荷が低い部分の表示更新
|
|
|
|
fun showColumnHeader() {
|
|
|
|
activity.handler.removeCallbacks(procShowColumnHeader)
|
2018-11-18 03:38:52 +01:00
|
|
|
activity.handler.postDelayed(procShowColumnHeader, 50L)
|
2018-11-15 23:08:11 +01:00
|
|
|
}
|
|
|
|
|
2018-01-20 07:51:14 +01:00
|
|
|
internal fun showContent(
|
2018-01-21 13:46:36 +01:00
|
|
|
reason : String,
|
|
|
|
changeList : List<AdapterChange>? = null,
|
2018-01-20 07:51:14 +01:00
|
|
|
reset : Boolean = false
|
2018-01-21 13:46:36 +01:00
|
|
|
) {
|
2018-01-04 19:52:25 +01:00
|
|
|
// クラッシュレポートにadapterとリストデータの状態不整合が多かったので、
|
|
|
|
// とりあえずリストデータ変更の通知だけは最優先で行っておく
|
|
|
|
try {
|
2018-01-21 13:46:36 +01:00
|
|
|
status_adapter?.notifyChange(reason, changeList, reset)
|
2018-01-04 19:52:25 +01:00
|
|
|
} catch(ex : Throwable) {
|
|
|
|
log.trace(ex)
|
|
|
|
}
|
|
|
|
|
|
|
|
showColumnHeader()
|
2018-04-20 15:22:21 +02:00
|
|
|
showColumnStatus()
|
2018-01-04 19:52:25 +01:00
|
|
|
|
|
|
|
val column = this.column
|
|
|
|
if(column == null || column.is_dispose.get()) {
|
|
|
|
showError("column was disposed.")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
if(! column.bFirstInitialized) {
|
|
|
|
showError("initializing")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
if(column.bInitialLoading) {
|
|
|
|
var message : String? = column.task_progress
|
|
|
|
if(message == null) message = "loading?"
|
|
|
|
showError(message)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
val initialLoadingError = column.mInitialLoadingError
|
2018-01-17 18:39:16 +01:00
|
|
|
if(initialLoadingError.isNotEmpty()) {
|
2018-01-04 19:52:25 +01:00
|
|
|
showError(initialLoadingError)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
val status_adapter = this.status_adapter
|
|
|
|
|
2018-01-17 18:39:16 +01:00
|
|
|
if(status_adapter == null || status_adapter.itemCount == 0) {
|
2018-01-04 19:52:25 +01:00
|
|
|
showError(activity.getString(R.string.list_empty))
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
tvLoading.visibility = View.GONE
|
|
|
|
|
|
|
|
refreshLayout.visibility = View.VISIBLE
|
|
|
|
|
2018-01-19 10:27:35 +01:00
|
|
|
status_adapter.findHeaderViewHolder(listView)?.bindData(column)
|
2018-01-04 19:52:25 +01:00
|
|
|
|
2018-11-20 10:32:30 +01:00
|
|
|
if(column.bRefreshLoading) {
|
|
|
|
hideRefreshError()
|
|
|
|
} else {
|
2018-01-04 19:52:25 +01:00
|
|
|
refreshLayout.isRefreshing = false
|
2018-11-20 10:32:30 +01:00
|
|
|
showRefreshError()
|
2018-01-04 19:52:25 +01:00
|
|
|
}
|
|
|
|
proc_restoreScrollPosition.run()
|
|
|
|
}
|
|
|
|
|
2018-11-20 10:32:30 +01:00
|
|
|
private var bRefreshErrorWillShown = false
|
|
|
|
|
|
|
|
private fun hideRefreshError() {
|
|
|
|
if(! bRefreshErrorWillShown) return
|
|
|
|
bRefreshErrorWillShown = false
|
|
|
|
if(llRefreshError.visibility == View.GONE) return
|
|
|
|
val aa = AlphaAnimation(1f, 0f)
|
|
|
|
aa.duration = 666L
|
|
|
|
aa.setAnimationListener(object : Animation.AnimationListener {
|
|
|
|
override fun onAnimationRepeat(animation : Animation?) {
|
|
|
|
}
|
|
|
|
|
|
|
|
override fun onAnimationStart(animation : Animation?) {
|
|
|
|
}
|
|
|
|
|
|
|
|
override fun onAnimationEnd(animation : Animation?) {
|
|
|
|
if(! bRefreshErrorWillShown) llRefreshError.visibility = View.GONE
|
|
|
|
}
|
|
|
|
})
|
|
|
|
llRefreshError.clearAnimation()
|
|
|
|
llRefreshError.startAnimation(aa)
|
|
|
|
}
|
|
|
|
|
|
|
|
private fun showRefreshError() {
|
|
|
|
val column = column
|
|
|
|
if(column == null) {
|
|
|
|
hideRefreshError()
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
val refreshError = column.mRefreshLoadingError
|
|
|
|
// val refreshErrorTime = column.mRefreshLoadingErrorTime
|
|
|
|
if(refreshError.isEmpty()) {
|
|
|
|
hideRefreshError()
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
tvRefreshError.text = refreshError
|
|
|
|
when(column.mRefreshLoadingErrorPopupState) {
|
|
|
|
// initially expanded
|
|
|
|
0 -> {
|
|
|
|
tvRefreshError.setSingleLine(false)
|
|
|
|
tvRefreshError.ellipsize = null
|
|
|
|
}
|
|
|
|
|
|
|
|
// tap to minimize
|
|
|
|
1 -> {
|
|
|
|
tvRefreshError.setSingleLine(true)
|
|
|
|
tvRefreshError.ellipsize = TextUtils.TruncateAt.END
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(! bRefreshErrorWillShown) {
|
|
|
|
bRefreshErrorWillShown = true
|
|
|
|
if(llRefreshError.visibility == View.GONE) {
|
|
|
|
llRefreshError.visibility = View.VISIBLE
|
|
|
|
val aa = AlphaAnimation(0f, 1f)
|
|
|
|
aa.duration = 666L
|
|
|
|
llRefreshError.clearAnimation()
|
|
|
|
llRefreshError.startAnimation(aa)
|
|
|
|
}
|
|
|
|
}
|
2018-08-04 20:07:55 +02:00
|
|
|
}
|
|
|
|
|
2018-10-10 22:43:10 +02:00
|
|
|
fun saveScrollPosition() : Boolean {
|
2018-01-04 19:52:25 +01:00
|
|
|
val column = this.column
|
|
|
|
when {
|
|
|
|
column == null -> log.d("saveScrollPosition [%d] , column==null", page_idx)
|
2018-01-21 13:46:36 +01:00
|
|
|
|
2018-01-19 10:27:35 +01:00
|
|
|
column.is_dispose.get() -> log.d(
|
|
|
|
"saveScrollPosition [%d] , column is disposed",
|
|
|
|
page_idx
|
|
|
|
)
|
2018-01-04 19:52:25 +01:00
|
|
|
|
|
|
|
listView.visibility != View.VISIBLE -> {
|
2018-12-12 15:21:38 +01:00
|
|
|
val scroll_save = ScrollPosition()
|
2018-01-04 19:52:25 +01:00
|
|
|
column.scroll_save = scroll_save
|
2018-01-19 10:27:35 +01:00
|
|
|
log.d(
|
|
|
|
"saveScrollPosition [%d] %s , listView is not visible, save %s,%s"
|
2018-01-04 19:52:25 +01:00
|
|
|
, page_idx
|
|
|
|
, column.getColumnName(true)
|
2018-01-19 10:27:35 +01:00
|
|
|
, scroll_save.adapterIndex
|
|
|
|
, scroll_save.offset
|
2018-01-04 19:52:25 +01:00
|
|
|
)
|
2018-08-24 15:45:27 +02:00
|
|
|
return true
|
2018-01-04 19:52:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
else -> {
|
2018-01-17 18:39:16 +01:00
|
|
|
val scroll_save = ScrollPosition(this)
|
2018-01-04 19:52:25 +01:00
|
|
|
column.scroll_save = scroll_save
|
2018-01-19 10:27:35 +01:00
|
|
|
log.d(
|
|
|
|
"saveScrollPosition [%d] %s , listView is visible, save %s,%s"
|
2018-01-04 19:52:25 +01:00
|
|
|
, page_idx
|
|
|
|
, column.getColumnName(true)
|
2018-01-19 10:27:35 +01:00
|
|
|
, scroll_save.adapterIndex
|
|
|
|
, scroll_save.offset
|
2018-01-04 19:52:25 +01:00
|
|
|
)
|
2018-08-24 15:45:27 +02:00
|
|
|
return true
|
2018-01-04 19:52:25 +01:00
|
|
|
}
|
|
|
|
}
|
2018-08-24 15:45:27 +02:00
|
|
|
return false
|
2018-01-04 19:52:25 +01:00
|
|
|
}
|
|
|
|
|
2018-01-21 13:46:36 +01:00
|
|
|
fun setScrollPosition(sp : ScrollPosition, deltaDp : Float = 0f) {
|
2018-01-04 19:52:25 +01:00
|
|
|
val last_adapter = listView.adapter
|
|
|
|
if(column == null || last_adapter == null) return
|
|
|
|
|
2018-01-17 18:39:16 +01:00
|
|
|
sp.restore(this)
|
2018-01-04 19:52:25 +01:00
|
|
|
|
2018-12-12 15:21:38 +01:00
|
|
|
// 復元した後に意図的に少し上下にずらしたい
|
2018-01-19 10:27:35 +01:00
|
|
|
val dy = (deltaDp * activity.density + 0.5f).toInt()
|
2018-01-17 18:39:16 +01:00
|
|
|
if(dy != 0) listView.postDelayed(Runnable {
|
2018-01-04 19:52:25 +01:00
|
|
|
if(column == null || listView.adapter !== last_adapter) return@Runnable
|
2018-01-17 18:39:16 +01:00
|
|
|
|
|
|
|
try {
|
2019-02-15 02:51:22 +01:00
|
|
|
val recycler = fieldRecycler.get(listView) as androidx.recyclerview.widget.RecyclerView.Recycler
|
|
|
|
val state = fieldState.get(listView) as androidx.recyclerview.widget.RecyclerView.State
|
2018-01-19 10:27:35 +01:00
|
|
|
listLayoutManager.scrollVerticallyBy(dy, recycler, state)
|
|
|
|
} catch(ex : Throwable) {
|
2018-01-17 18:39:16 +01:00
|
|
|
log.trace(ex)
|
2019-02-15 02:51:22 +01:00
|
|
|
log.e("can't access field in class %s", androidx.recyclerview.widget.RecyclerView::class.java.simpleName)
|
2018-01-17 18:39:16 +01:00
|
|
|
}
|
2018-01-04 19:52:25 +01:00
|
|
|
}, 20L)
|
|
|
|
}
|
|
|
|
|
2019-02-15 02:51:22 +01:00
|
|
|
internal inner class AdapterItemHeightWorkarea internal constructor(val adapter : ItemListAdapter) :
|
2018-01-21 13:46:36 +01:00
|
|
|
Closeable {
|
2018-01-19 10:27:35 +01:00
|
|
|
|
|
|
|
private val item_width : Int
|
|
|
|
private val widthSpec : Int
|
|
|
|
private var lastViewType : Int = - 1
|
2019-02-15 02:51:22 +01:00
|
|
|
private var lastViewHolder : androidx.recyclerview.widget.RecyclerView.ViewHolder? = null
|
2018-01-21 13:46:36 +01:00
|
|
|
|
2018-01-19 10:27:35 +01:00
|
|
|
init {
|
|
|
|
this.item_width = listView.width - listView.paddingLeft - listView.paddingRight
|
|
|
|
this.widthSpec = View.MeasureSpec.makeMeasureSpec(item_width, View.MeasureSpec.EXACTLY)
|
|
|
|
}
|
|
|
|
|
|
|
|
override fun close() {
|
|
|
|
val childViewHolder = lastViewHolder
|
|
|
|
if(childViewHolder != null) {
|
|
|
|
adapter.onViewRecycled(childViewHolder)
|
|
|
|
lastViewHolder = null
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-12 15:21:38 +01:00
|
|
|
// この関数はAdapterViewの項目の(marginを含む)高さを返す
|
2018-01-19 10:27:35 +01:00
|
|
|
fun getAdapterItemHeight(adapterIndex : Int) : Int {
|
|
|
|
|
2019-01-08 03:02:02 +01:00
|
|
|
fun View.getTotalHeight() : Int {
|
2018-12-12 15:21:38 +01:00
|
|
|
measure(widthSpec, heightSpec)
|
|
|
|
val lp = layoutParams as? ViewGroup.MarginLayoutParams
|
2019-01-08 03:02:02 +01:00
|
|
|
return measuredHeight + (lp?.topMargin ?: 0) + (lp?.bottomMargin ?: 0)
|
2018-01-19 10:27:35 +01:00
|
|
|
}
|
|
|
|
|
2019-01-08 03:02:02 +01:00
|
|
|
listView.findViewHolderForAdapterPosition(adapterIndex)?.itemView?.let {
|
2018-12-12 15:21:38 +01:00
|
|
|
return it.getTotalHeight()
|
|
|
|
}
|
2018-01-21 13:46:36 +01:00
|
|
|
|
2018-01-19 10:27:35 +01:00
|
|
|
log.d("getAdapterItemHeight idx=$adapterIndex createView")
|
|
|
|
|
|
|
|
val viewType = adapter.getItemViewType(adapterIndex)
|
|
|
|
|
2018-12-12 15:21:38 +01:00
|
|
|
var childViewHolder = lastViewHolder
|
2018-01-19 10:27:35 +01:00
|
|
|
if(childViewHolder == null || lastViewType != viewType) {
|
|
|
|
if(childViewHolder != null) {
|
|
|
|
adapter.onViewRecycled(childViewHolder)
|
|
|
|
}
|
|
|
|
childViewHolder = adapter.onCreateViewHolder(listView, viewType)
|
|
|
|
lastViewHolder = childViewHolder
|
|
|
|
lastViewType = viewType
|
|
|
|
}
|
|
|
|
adapter.onBindViewHolder(childViewHolder, adapterIndex)
|
2018-12-12 15:21:38 +01:00
|
|
|
return childViewHolder.itemView.getTotalHeight()
|
2018-01-17 18:39:16 +01:00
|
|
|
}
|
2018-01-19 10:27:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// 特定の要素が特定の位置に来るようにスクロール位置を調整する
|
|
|
|
fun setListItemTop(listIndex : Int, yArg : Int) {
|
|
|
|
var adapterIndex = column?.toAdapterIndex(listIndex) ?: return
|
|
|
|
|
2018-01-17 18:39:16 +01:00
|
|
|
val adapter = status_adapter
|
2018-01-21 13:46:36 +01:00
|
|
|
if(adapter == null) {
|
2018-01-19 10:27:35 +01:00
|
|
|
log.e("setListItemTop: missing status adapter")
|
|
|
|
return
|
2018-01-17 18:39:16 +01:00
|
|
|
}
|
2018-01-19 10:27:35 +01:00
|
|
|
|
|
|
|
var y = yArg
|
|
|
|
AdapterItemHeightWorkarea(adapter).use { workarea ->
|
|
|
|
while(y > 0 && adapterIndex > 0) {
|
|
|
|
-- adapterIndex
|
|
|
|
y -= workarea.getAdapterItemHeight(adapterIndex)
|
|
|
|
y -= ListDivider.height
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(adapterIndex == 0 && y > 0) y = 0
|
|
|
|
listLayoutManager.scrollToPositionWithOffset(adapterIndex, y)
|
|
|
|
}
|
|
|
|
|
2018-12-12 15:21:38 +01:00
|
|
|
// この関数は scrollToPositionWithOffset 用のオフセットを返す
|
|
|
|
fun getListItemOffset(listIndex : Int) : Int {
|
2018-01-21 13:46:36 +01:00
|
|
|
|
2018-01-19 10:27:35 +01:00
|
|
|
val adapterIndex = column?.toAdapterIndex(listIndex)
|
|
|
|
?: return 0
|
|
|
|
|
|
|
|
val childView = listLayoutManager.findViewByPosition(adapterIndex)
|
|
|
|
?: throw IndexOutOfBoundsException("findViewByPosition($adapterIndex) returns null.")
|
|
|
|
|
2018-12-12 15:21:38 +01:00
|
|
|
// スクロールとともにtopは減少する
|
|
|
|
// しかしtopMarginがあるので最大値は4である
|
|
|
|
// この関数は scrollToPositionWithOffset 用のオフセットを返すので top - topMargin を返す
|
2019-01-08 03:02:02 +01:00
|
|
|
return childView.top - ((childView.layoutParams as? ViewGroup.MarginLayoutParams)?.topMargin
|
|
|
|
?: 0)
|
2018-01-19 10:27:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
fun findFirstVisibleListItem() : Int {
|
2018-01-21 13:46:36 +01:00
|
|
|
|
2018-01-19 10:27:35 +01:00
|
|
|
val adapterIndex = listLayoutManager.findFirstVisibleItemPosition()
|
2018-01-21 13:46:36 +01:00
|
|
|
|
2019-02-15 02:51:22 +01:00
|
|
|
if(adapterIndex == androidx.recyclerview.widget.RecyclerView.NO_POSITION)
|
2018-01-19 10:27:35 +01:00
|
|
|
throw IndexOutOfBoundsException()
|
2018-01-21 13:46:36 +01:00
|
|
|
|
2018-01-19 10:27:35 +01:00
|
|
|
return column?.toListIndex(adapterIndex)
|
|
|
|
?: throw IndexOutOfBoundsException()
|
|
|
|
|
2018-01-17 18:39:16 +01:00
|
|
|
}
|
2018-01-20 07:51:14 +01:00
|
|
|
|
|
|
|
fun scrollToTop() {
|
2019-02-25 09:00:36 +01:00
|
|
|
try {
|
|
|
|
listView.stopScroll()
|
|
|
|
} catch(ex : Throwable) {
|
|
|
|
log.e(ex,"stopScroll failed.")
|
|
|
|
}
|
2018-01-20 07:51:14 +01:00
|
|
|
try {
|
|
|
|
listLayoutManager.scrollToPositionWithOffset(0, 0)
|
2019-02-25 09:00:36 +01:00
|
|
|
} catch(ex : Throwable) {
|
|
|
|
log.e(ex,"scrollToPositionWithOffset failed.")
|
2018-01-20 07:51:14 +01:00
|
|
|
}
|
|
|
|
}
|
2018-08-04 21:56:53 +02:00
|
|
|
|
2018-07-10 08:44:34 +02:00
|
|
|
fun scrollToTop2() {
|
|
|
|
val status_adapter = this.status_adapter
|
2019-02-03 08:54:52 +01:00
|
|
|
if(binding_busy || status_adapter == null) return
|
2018-07-10 08:44:34 +02:00
|
|
|
if(status_adapter.itemCount > 0) {
|
|
|
|
scrollToTop()
|
|
|
|
}
|
|
|
|
}
|
2019-01-08 05:30:18 +01:00
|
|
|
|
|
|
|
private fun clickQuickFilter(filter : Int) {
|
|
|
|
column?.quick_filter = filter
|
|
|
|
showQuickFilter()
|
|
|
|
activity.app_state.saveColumnList()
|
|
|
|
column?.startLoading()
|
|
|
|
}
|
|
|
|
|
|
|
|
private fun showQuickFilter() {
|
|
|
|
val column = this.column ?: return
|
|
|
|
|
2019-06-04 03:49:48 +02:00
|
|
|
val isNotificationColumn = column.isNotificationColumn
|
2019-01-08 05:30:18 +01:00
|
|
|
vg(svQuickFilter, isNotificationColumn)
|
|
|
|
if(! isNotificationColumn) return
|
|
|
|
|
|
|
|
vg(btnQuickFilterReaction, column.isMisskey)
|
2019-01-11 10:47:30 +01:00
|
|
|
vg(btnQuickFilterFavourite, ! column.isMisskey)
|
|
|
|
|
2019-01-09 09:08:51 +01:00
|
|
|
val insideColumnSetting = Pref.bpMoveNotificationsQuickFilter(activity.pref)
|
2019-01-08 05:30:18 +01:00
|
|
|
|
2019-01-11 10:47:30 +01:00
|
|
|
val showQuickFilterButton : (btn : View, iconId : Int, selected : Boolean) -> Unit
|
|
|
|
|
|
|
|
if(insideColumnSetting) {
|
2019-01-09 09:08:51 +01:00
|
|
|
svQuickFilter.setBackgroundColor(0)
|
2019-01-11 10:47:30 +01:00
|
|
|
|
|
|
|
val colorFg = getAttributeColor(activity, R.attr.colorContentText)
|
2019-01-09 09:08:51 +01:00
|
|
|
val colorBgSelected = colorFg.applyAlphaMultiplier(0.25f)
|
2019-01-18 16:33:53 +01:00
|
|
|
val colorFgList = ColorStateList.valueOf(colorFg)
|
2019-01-11 10:47:30 +01:00
|
|
|
showQuickFilterButton = { btn, iconId, selected ->
|
2019-01-20 22:04:57 +01:00
|
|
|
btn.backgroundDrawable = if(selected) {
|
|
|
|
getAdaptiveRippleDrawable(
|
|
|
|
colorBgSelected,
|
|
|
|
colorFg
|
|
|
|
)
|
|
|
|
} else {
|
|
|
|
ContextCompat.getDrawable(activity, R.drawable.btn_bg_transparent)
|
|
|
|
}
|
|
|
|
|
2019-01-09 09:08:51 +01:00
|
|
|
when(btn) {
|
|
|
|
is TextView -> btn.textColor = colorFg
|
2019-01-18 16:33:53 +01:00
|
|
|
|
2019-01-17 20:40:51 +01:00
|
|
|
is ImageButton -> {
|
|
|
|
btn.setImageResource(iconId)
|
|
|
|
btn.imageTintList = colorFgList
|
|
|
|
}
|
2019-01-09 09:08:51 +01:00
|
|
|
}
|
|
|
|
}
|
2019-01-11 10:47:30 +01:00
|
|
|
} else {
|
2019-01-09 09:08:51 +01:00
|
|
|
val colorBg = column.getHeaderBackgroundColor()
|
|
|
|
val colorFg = column.getHeaderNameColor()
|
2019-01-18 16:33:53 +01:00
|
|
|
val colorFgList = ColorStateList.valueOf(colorFg)
|
2019-01-09 09:08:51 +01:00
|
|
|
val colorBgSelected = Color.rgb(
|
|
|
|
(Color.red(colorBg) * 3 + Color.red(colorFg)) / 4,
|
|
|
|
(Color.green(colorBg) * 3 + Color.green(colorFg)) / 4,
|
|
|
|
(Color.blue(colorBg) * 3 + Color.blue(colorFg)) / 4
|
2019-01-08 05:30:18 +01:00
|
|
|
)
|
2019-01-09 09:08:51 +01:00
|
|
|
svQuickFilter.setBackgroundColor(colorBg)
|
|
|
|
|
2019-01-11 10:47:30 +01:00
|
|
|
showQuickFilterButton = { btn, iconId, selected ->
|
2019-02-03 08:54:52 +01:00
|
|
|
|
|
|
|
btn.backgroundDrawable = getAdaptiveRippleDrawable(
|
2019-01-20 22:04:57 +01:00
|
|
|
if(selected) colorBgSelected else colorBg,
|
|
|
|
colorFg
|
2019-01-09 09:08:51 +01:00
|
|
|
)
|
2019-02-03 08:54:52 +01:00
|
|
|
|
2019-01-09 09:08:51 +01:00
|
|
|
when(btn) {
|
|
|
|
is TextView -> btn.textColor = colorFg
|
2019-01-18 16:33:53 +01:00
|
|
|
|
|
|
|
is ImageButton -> {
|
2019-01-17 20:40:51 +01:00
|
|
|
btn.setImageResource(iconId)
|
|
|
|
btn.imageTintList = colorFgList
|
|
|
|
}
|
2019-01-09 09:08:51 +01:00
|
|
|
}
|
2019-01-08 05:30:18 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
showQuickFilterButton(
|
|
|
|
btnQuickFilterAll,
|
|
|
|
0,
|
|
|
|
column.quick_filter == Column.QUICK_FILTER_ALL
|
|
|
|
)
|
|
|
|
|
|
|
|
showQuickFilterButton(
|
|
|
|
btnQuickFilterMention,
|
2019-01-16 13:33:07 +01:00
|
|
|
R.drawable.ic_reply,
|
2019-01-08 05:30:18 +01:00
|
|
|
column.quick_filter == Column.QUICK_FILTER_MENTION
|
|
|
|
)
|
|
|
|
|
|
|
|
showQuickFilterButton(
|
|
|
|
btnQuickFilterFavourite,
|
2019-01-16 13:33:07 +01:00
|
|
|
R.drawable.ic_star,
|
2019-01-08 05:30:18 +01:00
|
|
|
column.quick_filter == Column.QUICK_FILTER_FAVOURITE
|
|
|
|
)
|
|
|
|
|
|
|
|
showQuickFilterButton(
|
|
|
|
btnQuickFilterBoost,
|
2019-01-16 13:33:07 +01:00
|
|
|
R.drawable.ic_repeat,
|
2019-01-08 05:30:18 +01:00
|
|
|
column.quick_filter == Column.QUICK_FILTER_BOOST
|
|
|
|
)
|
|
|
|
|
|
|
|
showQuickFilterButton(
|
|
|
|
btnQuickFilterFollow,
|
|
|
|
R.drawable.ic_follow_plus,
|
|
|
|
column.quick_filter == Column.QUICK_FILTER_FOLLOW
|
|
|
|
)
|
|
|
|
|
|
|
|
showQuickFilterButton(
|
|
|
|
btnQuickFilterReaction,
|
|
|
|
R.drawable.ic_add,
|
|
|
|
column.quick_filter == Column.QUICK_FILTER_REACTION
|
|
|
|
)
|
|
|
|
|
|
|
|
showQuickFilterButton(
|
|
|
|
btnQuickFilterVote,
|
|
|
|
R.drawable.ic_vote,
|
|
|
|
column.quick_filter == Column.QUICK_FILTER_VOTE
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2018-01-04 19:52:25 +01:00
|
|
|
}
|