|
@@ -1,16 +1,17 @@
|
|
package com.shanp.youqi.im.dialog
|
|
package com.shanp.youqi.im.dialog
|
|
|
|
|
|
-import android.os.Bundle
|
|
|
|
-import android.view.View
|
|
|
|
import android.widget.FrameLayout
|
|
import android.widget.FrameLayout
|
|
import com.alibaba.android.arouter.facade.annotation.Route
|
|
import com.alibaba.android.arouter.facade.annotation.Route
|
|
import com.alibaba.android.arouter.launcher.ARouter
|
|
import com.alibaba.android.arouter.launcher.ARouter
|
|
import com.blankj.utilcode.util.FragmentUtils
|
|
import com.blankj.utilcode.util.FragmentUtils
|
|
|
|
+import com.blankj.utilcode.util.KeyboardUtils
|
|
import com.shanp.youqi.common.app.Route.RouterUrl
|
|
import com.shanp.youqi.common.app.Route.RouterUrl
|
|
import com.shanp.youqi.common.base.BaseDialogFragment
|
|
import com.shanp.youqi.common.base.BaseDialogFragment
|
|
import com.shanp.youqi.common.base.BaseViewHolder
|
|
import com.shanp.youqi.common.base.BaseViewHolder
|
|
|
|
+import com.shanp.youqi.common.utils.ViewHideShowUtils
|
|
import com.shanp.youqi.im.R
|
|
import com.shanp.youqi.im.R
|
|
import com.shanp.youqi.im.fragment.MessageListOnlyUserFragment
|
|
import com.shanp.youqi.im.fragment.MessageListOnlyUserFragment
|
|
|
|
+import com.shanp.youqi.im.fragment.UChatConversationOnlyTextFragment
|
|
import me.jessyan.autosize.utils.AutoSizeUtils
|
|
import me.jessyan.autosize.utils.AutoSizeUtils
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -23,8 +24,10 @@ class MessageListDialog : BaseDialogFragment() {
|
|
|
|
|
|
private var upHeight = 0
|
|
private var upHeight = 0
|
|
private var downHeight = 0
|
|
private var downHeight = 0
|
|
|
|
+ private var currentHeight = 0
|
|
|
|
|
|
- lateinit var flContainer: FrameLayout
|
|
|
|
|
|
+ private lateinit var flContainer: FrameLayout
|
|
|
|
+ private var conversationFragment: UChatConversationOnlyTextFragment? = null
|
|
|
|
|
|
init {
|
|
init {
|
|
setAnimStyle(R.style.dialogstyle)
|
|
setAnimStyle(R.style.dialogstyle)
|
|
@@ -32,26 +35,46 @@ class MessageListDialog : BaseDialogFragment() {
|
|
setDimAmount(0.0f)
|
|
setDimAmount(0.0f)
|
|
setWidthFull(true)
|
|
setWidthFull(true)
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
override fun convert(holder: BaseViewHolder, dialog: BaseDialogFragment?) {
|
|
override fun convert(holder: BaseViewHolder, dialog: BaseDialogFragment?) {
|
|
ARouter.getInstance().inject(this)
|
|
ARouter.getInstance().inject(this)
|
|
upHeight = AutoSizeUtils.dp2px(mContext, 317.5f)
|
|
upHeight = AutoSizeUtils.dp2px(mContext, 317.5f)
|
|
downHeight = AutoSizeUtils.dp2px(mContext, 402f)
|
|
downHeight = AutoSizeUtils.dp2px(mContext, 402f)
|
|
|
|
+ currentHeight = downHeight
|
|
flContainer = holder.getView(R.id.fl_container_message_list)
|
|
flContainer = holder.getView(R.id.fl_container_message_list)
|
|
FragmentUtils.add(childFragmentManager, MessageListOnlyUserFragment(), R.id.fl_container_message_list)
|
|
FragmentUtils.add(childFragmentManager, MessageListOnlyUserFragment(), R.id.fl_container_message_list)
|
|
- }
|
|
|
|
-
|
|
|
|
- fun showHide(show: Boolean) {
|
|
|
|
- if (show) {
|
|
|
|
- flContainer.visibility = View.VISIBLE
|
|
|
|
- } else {
|
|
|
|
- flContainer.postDelayed({
|
|
|
|
- if (flContainer != null) {
|
|
|
|
- flContainer.visibility = View.INVISIBLE
|
|
|
|
|
|
+ activity?.window?.let {
|
|
|
|
+ KeyboardUtils.registerSoftInputChangedListener(it) { height ->
|
|
|
|
+ conversationFragment?.let {
|
|
|
|
+ if (height > 0) {
|
|
|
|
+ if (currentHeight != upHeight) {
|
|
|
|
+ currentHeight = upHeight
|
|
|
|
+ ViewHideShowUtils.performAnim(flContainer, downHeight, upHeight, 300) {
|
|
|
|
+ it?.rcvToBottom()
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ if (currentHeight != downHeight) {
|
|
|
|
+ currentHeight = downHeight
|
|
|
|
+ ViewHideShowUtils.performAnim(flContainer, upHeight, downHeight, 300) {
|
|
|
|
+ it?.rcvToBottom()
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- }, 310)
|
|
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
override fun getLayoutId(): Int = R.layout.im_dialog_message_list_layout
|
|
override fun getLayoutId(): Int = R.layout.im_dialog_message_list_layout
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ fun addConversation(targetId: String, targetUserName: String, targetHeadImg: String) {
|
|
|
|
+ conversationFragment = UChatConversationOnlyTextFragment()
|
|
|
|
+ conversationFragment?.let {
|
|
|
|
+ it.setParam(targetId, targetUserName, targetHeadImg, true)
|
|
|
|
+ FragmentUtils.add(childFragmentManager, it, R.id.fl_container_message_list,true,
|
|
|
|
+ R.anim.dialog_enter_r_l, R.anim.dialog_exit_l_r, R.anim.dialog_enter_r_l, R.anim.dialog_exit_l_r)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|