setting展开时的滚动
This commit is contained in:
parent
b426fda4d3
commit
e2f4c50410
|
|
@ -3,6 +3,7 @@ package com.remax.visualnovel.ui.chat.ui
|
|||
|
||||
import android.content.Context
|
||||
import android.graphics.Color
|
||||
import android.provider.Settings.Global.getString
|
||||
import android.util.AttributeSet
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
|
|
@ -15,9 +16,13 @@ import com.remax.visualnovel.entity.response.ChatBubble
|
|||
import com.remax.visualnovel.entity.response.ChatHistory
|
||||
import com.remax.visualnovel.entity.response.ChatMode
|
||||
import com.remax.visualnovel.entity.response.ChatSound
|
||||
import com.remax.visualnovel.extension.showDoubleBtnDialog
|
||||
import com.remax.visualnovel.ui.chat.ui.expandableSelector.ExpandAiModelSelectView
|
||||
import com.remax.visualnovel.ui.chat.ui.expandableSelector.ExpandBubbleSelectView
|
||||
import com.remax.visualnovel.ui.chat.ui.expandableSelector.ExpandChatModeSelectView
|
||||
import com.remax.visualnovel.ui.chat.ui.expandableSelector.ExpandSoundSelectView
|
||||
import com.remax.visualnovel.ui.chat.ui.expandableSelector.SelectorItem
|
||||
import com.remax.visualnovel.widget.imageviewer.utils.activity
|
||||
import java.util.Date
|
||||
|
||||
class ChatSettingView @JvmOverloads constructor(
|
||||
|
|
@ -44,10 +49,27 @@ class ChatSettingView @JvmOverloads constructor(
|
|||
initBubbleSelectView()
|
||||
initBackgroundSelectView()
|
||||
initHistoryListView()
|
||||
initOtherClickEvent()
|
||||
}
|
||||
|
||||
private fun initOtherClickEvent() {
|
||||
with (mBinding) {
|
||||
llDelete.setOnClickListener {
|
||||
/*activity?.showDoubleBtnDialog(
|
||||
getString(R.string.delete_chat),
|
||||
getString(R.string.delete_chat_hint),
|
||||
isDel = true,
|
||||
topBtnText = getString(R.string.sure),
|
||||
topBtnClick = {
|
||||
// TODO - do delete the chat
|
||||
}
|
||||
)*/
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun scroll2Position(targetSubView: View) {
|
||||
mBinding.scrollView.smoothScrollTo(0, targetSubView.top)
|
||||
mBinding.scrollView.scroll2ChildView(targetSubView)
|
||||
}
|
||||
|
||||
fun initAiModelSelectorView() {
|
||||
|
|
@ -123,11 +145,26 @@ class ChatSettingView @JvmOverloads constructor(
|
|||
)
|
||||
)
|
||||
|
||||
//aiModelSelector.setOnItemSelectedListener()
|
||||
mBinding.chatModelSelector.setTitleIcon(R.mipmap.setting_chat_mode_icon)
|
||||
mBinding.chatModelSelector.setTitleText(R.string.chat_mode)
|
||||
mBinding.chatModelSelector.setItems(items)
|
||||
mBinding.chatModelSelector.selectItem(0)
|
||||
with(mBinding.chatModelSelector) {
|
||||
setTitleIcon(R.mipmap.setting_chat_mode_icon)
|
||||
setTitleText(R.string.chat_mode)
|
||||
setItems(items)
|
||||
selectItem(0)
|
||||
setOnEventListener(object : ExpandChatModeSelectView.IEventListener {
|
||||
override fun onItemSelected(
|
||||
position: Int,
|
||||
item: ChatMode
|
||||
) {
|
||||
|
||||
}
|
||||
|
||||
override fun onExpanded(isExpanded: Boolean) {
|
||||
if (isExpanded)
|
||||
scroll2Position(this@with)
|
||||
}
|
||||
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -223,7 +260,23 @@ class ChatSettingView @JvmOverloads constructor(
|
|||
)
|
||||
)
|
||||
|
||||
mBinding.bubbleSelectView.setItems(items)
|
||||
with(mBinding.bubbleSelectView) {
|
||||
setTitleText(R.string.chat_bubble)
|
||||
setItems(items)
|
||||
setOnEventListener(object : ExpandBubbleSelectView.IEventListener {
|
||||
override fun onItemSelected(
|
||||
position: Int,
|
||||
item: ChatBubble
|
||||
) {
|
||||
|
||||
}
|
||||
|
||||
override fun onExpanded(isExpanded: Boolean) {
|
||||
if (isExpanded)
|
||||
scroll2Position(this@with)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
fun initBackgroundSelectView() {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,26 @@
|
|||
package com.remax.visualnovel.ui.chat.ui
|
||||
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.view.View
|
||||
import android.graphics.Rect
|
||||
import androidx.core.widget.NestedScrollView
|
||||
|
||||
class MyScrollView @JvmOverloads constructor(
|
||||
context: Context,
|
||||
attrs: AttributeSet? = null,
|
||||
defStyleAttr: Int = 0
|
||||
) : NestedScrollView(context, attrs, defStyleAttr) {
|
||||
|
||||
fun scroll2ChildView(child: View) {
|
||||
val tempRect = Rect()
|
||||
child.getDrawingRect(tempRect)
|
||||
offsetDescendantRectToMyCoords(child, tempRect)
|
||||
val scrollDelta: Int = computeScrollDeltaToGetChildRectOnScreen(tempRect)
|
||||
/*if (scrollDelta != 0) {
|
||||
scrollBy(0, scrollDelta)
|
||||
}*/
|
||||
smoothScrollTo(0, tempRect.top)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -34,6 +34,10 @@ class ExpandAiModelSelectView @JvmOverloads constructor(
|
|||
fun onExpanded(isExpanded: Boolean)
|
||||
}
|
||||
|
||||
fun setOnEventListener(listener: IEventListener) {
|
||||
this.mEventListener = listener
|
||||
}
|
||||
|
||||
init {
|
||||
initView(context, attrs)
|
||||
}
|
||||
|
|
@ -205,9 +209,7 @@ class ExpandAiModelSelectView @JvmOverloads constructor(
|
|||
return height
|
||||
}
|
||||
|
||||
fun setOnEventListener(listener: IEventListener) {
|
||||
this.mEventListener = listener
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -25,7 +25,16 @@ class ExpandBubbleSelectView @JvmOverloads constructor(
|
|||
|
||||
private var isExpanded = false
|
||||
private var animationDuration = 300
|
||||
private var itemSelectedListener: OnItemSelectedListener? = null
|
||||
private var mEventListener: IEventListener? = null
|
||||
|
||||
interface IEventListener {
|
||||
fun onItemSelected(position: Int, item: ChatBubble)
|
||||
fun onExpanded(isExpanded: Boolean)
|
||||
}
|
||||
|
||||
fun setOnEventListener(listener: IEventListener) {
|
||||
this.mEventListener = listener
|
||||
}
|
||||
|
||||
init {
|
||||
initView(context, attrs)
|
||||
|
|
@ -63,6 +72,7 @@ class ExpandBubbleSelectView @JvmOverloads constructor(
|
|||
|
||||
fun toggle() {
|
||||
if (isExpanded) collapse() else expand()
|
||||
mEventListener?.onExpanded(isExpanded)
|
||||
}
|
||||
|
||||
fun expand() {
|
||||
|
|
@ -128,11 +138,5 @@ class ExpandBubbleSelectView @JvmOverloads constructor(
|
|||
return height
|
||||
}
|
||||
|
||||
fun setOnItemSelectedListener(listener: OnItemSelectedListener) {
|
||||
this.itemSelectedListener = listener
|
||||
}
|
||||
|
||||
interface OnItemSelectedListener {
|
||||
fun onItemSelected(position: Int, item: SelectorItem)
|
||||
}
|
||||
}
|
||||
|
|
@ -29,7 +29,16 @@ class ExpandChatModeSelectView @JvmOverloads constructor(
|
|||
private var isExpanded = false
|
||||
private var animationDuration = 300
|
||||
private var items: List<ChatMode> = emptyList()
|
||||
private var itemSelectedListener: OnItemSelectedListener? = null
|
||||
|
||||
private var mEventListener: IEventListener? = null
|
||||
interface IEventListener {
|
||||
fun onItemSelected(position: Int, item: ChatMode)
|
||||
fun onExpanded(isExpanded: Boolean)
|
||||
}
|
||||
|
||||
fun setOnEventListener(listener: IEventListener) {
|
||||
this.mEventListener = listener
|
||||
}
|
||||
|
||||
init {
|
||||
initView(context, attrs)
|
||||
|
|
@ -96,7 +105,7 @@ class ExpandChatModeSelectView @JvmOverloads constructor(
|
|||
|
||||
binding.root.setOnClickListener {
|
||||
selectItem(position)
|
||||
itemSelectedListener?.onItemSelected(position, item)
|
||||
mEventListener?.onItemSelected(position, item)
|
||||
}
|
||||
return binding.root
|
||||
}
|
||||
|
|
@ -129,6 +138,7 @@ class ExpandChatModeSelectView @JvmOverloads constructor(
|
|||
|
||||
fun toggle() {
|
||||
if (isExpanded) collapse() else expand()
|
||||
mEventListener?.onExpanded(isExpanded)
|
||||
}
|
||||
|
||||
fun expand() {
|
||||
|
|
@ -194,11 +204,5 @@ class ExpandChatModeSelectView @JvmOverloads constructor(
|
|||
return height
|
||||
}
|
||||
|
||||
fun setOnItemSelectedListener(listener: OnItemSelectedListener) {
|
||||
this.itemSelectedListener = listener
|
||||
}
|
||||
|
||||
interface OnItemSelectedListener {
|
||||
fun onItemSelected(position: Int, item: ChatMode)
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle"
|
||||
>
|
||||
<size
|
||||
android:width="270dp"
|
||||
android:height="300dp"
|
||||
/>
|
||||
<corners android:radius="25dp" />
|
||||
<gradient android:type="linear"
|
||||
android:angle="270"
|
||||
android:startColor="#ffffd4d4"
|
||||
android:endColor="#ffffffff"
|
||||
/>
|
||||
</shape>
|
||||
|
|
@ -44,7 +44,7 @@
|
|||
</com.remax.visualnovel.widget.uitoken.view.UITokenFrameLayout>
|
||||
|
||||
|
||||
<androidx.core.widget.NestedScrollView
|
||||
<com.remax.visualnovel.ui.chat.ui.MyScrollView
|
||||
android:id="@+id/scroll_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
|
|
@ -349,7 +349,7 @@
|
|||
|
||||
</com.remax.visualnovel.widget.uitoken.view.UITokenLinearLayout>
|
||||
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
</com.remax.visualnovel.ui.chat.ui.MyScrollView>
|
||||
|
||||
|
||||
</com.remax.visualnovel.widget.uitoken.view.UITokenRelativeLayout>
|
||||
Loading…
Reference in New Issue