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

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);
}
}
}

View File

@@ -95,7 +95,7 @@
<TextView
android:id="@+id/tvFaultHelpDistance"
android:layout_width="wrap_content"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/dp_30"
android:gravity="center_vertical"
@@ -104,6 +104,7 @@
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="@+id/ivFaultHelpEventCall"
app:layout_constraintEnd_toStartOf="@+id/ivFaultHelpEventCall"
app:layout_constraintStart_toEndOf="@+id/tvFaultHelpEventTime"
app:layout_constraintTop_toTopOf="@+id/ivFaultHelpEventCall"
tools:text="300M" />

View File

@@ -5,39 +5,6 @@
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:id="@+id/llEventMore"
android:layout_width="@dimen/dp_132"
android:layout_height="@dimen/dp_132"
android:background="@drawable/v2x_drawable_event_more_bkg"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:translationZ="1dp">
<ImageView
android:id="@+id/btnShowOrHidePanels"
android:layout_width="@dimen/dp_52"
android:layout_height="@dimen/dp_52"
android:layout_centerInParent="true"
android:src="@drawable/icon_event_panel_more" />
<TextView
android:id="@+id/tvEventCount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_marginTop="@dimen/dp_12"
android:layout_marginEnd="@dimen/dp_12"
android:background="@drawable/v2x_drawable_event_message_bkg"
android:paddingStart="@dimen/dp_10"
android:paddingEnd="@dimen/dp_10"
android:textColor="#FFFFFF"
android:textSize="@dimen/dp_28"
android:visibility="gone"
tools:text="9"
tools:visibility="visible" />
</RelativeLayout>
<com.mogo.module.v2x.view.RoundConstraintLayout
android:id="@+id/clPanelContainer"
android:layout_width="match_parent"

View File

@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/llEventMore"
android:layout_width="@dimen/dp_132"
android:layout_height="@dimen/dp_132"
android:background="@drawable/v2x_drawable_event_more_bkg"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:translationZ="1dp">
<ImageView
android:id="@+id/btnShowOrHidePanels"
android:layout_width="@dimen/dp_52"
android:layout_height="@dimen/dp_52"
android:layout_centerInParent="true"
android:src="@drawable/icon_event_panel_more" />
<TextView
android:id="@+id/tvEventCount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_marginTop="@dimen/dp_12"
android:layout_marginEnd="@dimen/dp_12"
android:background="@drawable/v2x_drawable_event_message_bkg"
android:paddingStart="@dimen/dp_10"
android:paddingEnd="@dimen/dp_10"
android:textColor="#FFFFFF"
android:textSize="@dimen/dp_28"
android:visibility="gone"
tools:text="9"
tools:visibility="visible" />
</RelativeLayout>