修复了页面中的按钮层级关系

This commit is contained in:
董宏宇
2020-08-12 10:52:38 +08:00
parent cc59125717
commit 6f9b925233
5 changed files with 99 additions and 39 deletions

View File

@@ -12,6 +12,7 @@ import com.mogo.module.v2x.V2XServiceManager
import com.mogo.module.v2x.adapter.V2XEventPagerAdapter
import com.mogo.module.v2x.presenter.EventPanelPresenter
import com.mogo.module.v2x.utils.V2XSQLiteUtils
import com.mogo.module.v2x.view.V2XEventPanelHistoryCountView
import com.mogo.utils.logger.Logger
import kotlinx.android.synthetic.main.module_v2x_event_panel_fragment_event_panel.*
@@ -29,6 +30,8 @@ class V2XEventPanelFragment : MvpFragment<V2XEventPanelFragment, EventPanelPrese
private var mediator: TabLayoutMediator? = null
private var mV2XEventPanelHistoryCountView: V2XEventPanelHistoryCountView? = null
companion object {
private val fragment = V2XEventPanelFragment()
fun getInstance(): V2XEventPanelFragment {
@@ -71,13 +74,15 @@ class V2XEventPanelFragment : MvpFragment<V2XEventPanelFragment, EventPanelPrese
hidePanel()
}
llEventMore.setOnClickListener {
mV2XEventPanelHistoryCountView = V2XEventPanelHistoryCountView(context)
mV2XEventPanelHistoryCountView!!.setOnClickListener {
if (!isPanelShow()) {
showPanel()
} else {
hidePanel()
}
}
V2XServiceManager.getMogoEntranceButtonController().addBottomLayerView(mV2XEventPanelHistoryCountView)
changeEventCount()
}
@@ -110,11 +115,10 @@ class V2XEventPanelFragment : MvpFragment<V2XEventPanelFragment, EventPanelPrese
// 修改未处理消息
fun changeEventCount() {
val historyMessage = V2XSQLiteUtils.getScenarioHistoryUnDisposeData()
if (historyMessage != null && historyMessage.size > 0) {
tvEventCount.visibility = View.VISIBLE
tvEventCount.text = "${historyMessage.size}"
if (historyMessage != null) {
mV2XEventPanelHistoryCountView?.changeMsgCount(historyMessage.size)
} else {
tvEventCount.visibility = View.GONE
mV2XEventPanelHistoryCountView?.changeMsgCount(0)
}
}
}

View File

@@ -0,0 +1,53 @@
package com.mogo.module.v2x.view;
import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import androidx.annotation.Nullable;
import com.mogo.module.v2x.R;
/**
* 事件面板的提示按钮
*
* @author donghongyu
*/
public class V2XEventPanelHistoryCountView extends LinearLayout {
private RelativeLayout mLlEventMore;
private ImageView mBtnShowOrHidePanels;
private TextView mTvEventCount;
public V2XEventPanelHistoryCountView(Context context) {
this(context, null);
}
public V2XEventPanelHistoryCountView(Context context, @Nullable AttributeSet attrs) {
this(context, attrs, 0);
}
public V2XEventPanelHistoryCountView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
LayoutInflater.from(context).inflate(R.layout.view_event_panel_history_count, this);
mLlEventMore = (RelativeLayout) findViewById(R.id.llEventMore);
mBtnShowOrHidePanels = (ImageView) findViewById(R.id.btnShowOrHidePanels);
mTvEventCount = (TextView) findViewById(R.id.tvEventCount);
}
public void changeMsgCount(int count) {
if (mTvEventCount != null) {
if (count > 0) {
mTvEventCount.setVisibility(View.VISIBLE);
} else {
mTvEventCount.setVisibility(View.GONE);
}
mTvEventCount.setText("" + count);
}
}
}