Commit aac08737f3c223e45069a6b0788f6b47125f8dfb

Authored by YangShuai
1 parent 211608d1

1 修复后台弹窗dialog在部分android10手机上无法显示的问题

2 运动地图页增加终点提示点击好的返回结束页操作
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/frame/view/RunningMapFragmentView.java
1 package com.cnlive.moudle.pedometer.frame.view; 1 package com.cnlive.moudle.pedometer.frame.view;
2 2
  3 +import android.app.Activity;
3 import android.app.Service; 4 import android.app.Service;
4 import android.content.Context; 5 import android.content.Context;
5 import android.graphics.Bitmap; 6 import android.graphics.Bitmap;
@@ -92,7 +93,7 @@ public class RunningMapFragmentView implements MvpView, SensorEventListener { @@ -92,7 +93,7 @@ public class RunningMapFragmentView implements MvpView, SensorEventListener {
92 this.fragment = fragment; 93 this.fragment = fragment;
93 } 94 }
94 95
95 - public Context getContext() { 96 + public Activity getContext() {
96 return fragment == null ? null : fragment.getActivity(); 97 return fragment == null ? null : fragment.getActivity();
97 } 98 }
98 99
@@ -319,12 +320,12 @@ public class RunningMapFragmentView implements MvpView, SensorEventListener { @@ -319,12 +320,12 @@ public class RunningMapFragmentView implements MvpView, SensorEventListener {
319 320
320 } else { 321 } else {
321 //过滤定位精度 322 //过滤定位精度
322 - boolean isNeedZoomInRaduis= PhoneUtil.isNeedZoomInLoacRaduis();  
323 - if (isNeedZoomInRaduis){ 323 + boolean isNeedZoomInRaduis = PhoneUtil.isNeedZoomInLoacRaduis();
  324 + if (isNeedZoomInRaduis) {
324 if (location.getRadius() > Constant.Need_ZOOM_IN_RADUIS) { 325 if (location.getRadius() > Constant.Need_ZOOM_IN_RADUIS) {
325 return; 326 return;
326 } 327 }
327 - }else { 328 + } else {
328 if (location.getRadius() > Constant.LOCA_ACCURACY) { 329 if (location.getRadius() > Constant.LOCA_ACCURACY) {
329 return; 330 return;
330 } 331 }
@@ -431,6 +432,7 @@ public class RunningMapFragmentView implements MvpView, SensorEventListener { @@ -431,6 +432,7 @@ public class RunningMapFragmentView implements MvpView, SensorEventListener {
431 @Override 432 @Override
432 public void onClick(TipDialog dialog) { 433 public void onClick(TipDialog dialog) {
433 dialog.dismiss(); 434 dialog.dismiss();
  435 + getContext().finish();
434 } 436 }
435 }); 437 });
436 endTipDialog.setCancelable(false); 438 endTipDialog.setCancelable(false);
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/ui/widget/SelectDialog.java
@@ -3,10 +3,14 @@ package com.cnlive.moudle.pedometer.ui.widget; @@ -3,10 +3,14 @@ package com.cnlive.moudle.pedometer.ui.widget;
3 import android.app.Dialog; 3 import android.app.Dialog;
4 import android.content.Context; 4 import android.content.Context;
5 import android.os.Bundle; 5 import android.os.Bundle;
  6 +
6 import androidx.annotation.NonNull; 7 import androidx.annotation.NonNull;
  8 +
  9 +import android.util.Log;
7 import android.view.LayoutInflater; 10 import android.view.LayoutInflater;
8 import android.view.View; 11 import android.view.View;
9 import android.view.ViewGroup; 12 import android.view.ViewGroup;
  13 +import android.view.Window;
10 import android.view.WindowManager; 14 import android.view.WindowManager;
11 import android.widget.Button; 15 import android.widget.Button;
12 import android.widget.LinearLayout; 16 import android.widget.LinearLayout;
@@ -61,10 +65,10 @@ public class SelectDialog extends Dialog { @@ -61,10 +65,10 @@ public class SelectDialog extends Dialog {
61 @Override 65 @Override
62 protected void onCreate(Bundle savedInstanceState) { 66 protected void onCreate(Bundle savedInstanceState) {
63 super.onCreate(savedInstanceState); 67 super.onCreate(savedInstanceState);
64 -  
65 -  
66 //显示视图 68 //显示视图
67 this.setContentView(view); 69 this.setContentView(view);
  70 + //android 后台弹窗,只显示灰色蒙层,不显示布局。
  71 + getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
68 } 72 }
69 73
70 private void initView(View rootView) { 74 private void initView(View rootView) {
@@ -87,6 +91,19 @@ public class SelectDialog extends Dialog { @@ -87,6 +91,19 @@ public class SelectDialog extends Dialog {
87 }); 91 });
88 } 92 }
89 93
  94 + @Override
  95 + public void onWindowFocusChanged(boolean hasFocus) {
  96 + super.onWindowFocusChanged(hasFocus);
  97 + Window window = getWindow();
  98 + if (hasFocus && window != null) {
  99 + View decorView = window.getDecorView();
  100 + if (decorView.getHeight() == 0 || decorView.getWidth() == 0) {
  101 + decorView.requestLayout();
  102 + Log.d("TAG", "布局异常,重新布局");
  103 + }
  104 + }
  105 + }
  106 +
90 public interface DialogInterface { 107 public interface DialogInterface {
91 void onClick(SelectDialog dialog); 108 void onClick(SelectDialog dialog);
92 } 109 }
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/ui/widget/TipDialog.java
@@ -3,10 +3,14 @@ package com.cnlive.moudle.pedometer.ui.widget; @@ -3,10 +3,14 @@ package com.cnlive.moudle.pedometer.ui.widget;
3 import android.app.Dialog; 3 import android.app.Dialog;
4 import android.content.Context; 4 import android.content.Context;
5 import android.os.Bundle; 5 import android.os.Bundle;
  6 +
6 import androidx.annotation.NonNull; 7 import androidx.annotation.NonNull;
  8 +
  9 +import android.util.Log;
7 import android.view.LayoutInflater; 10 import android.view.LayoutInflater;
8 import android.view.View; 11 import android.view.View;
9 import android.view.ViewGroup; 12 import android.view.ViewGroup;
  13 +import android.view.Window;
10 import android.view.WindowManager; 14 import android.view.WindowManager;
11 import android.widget.Button; 15 import android.widget.Button;
12 import android.widget.LinearLayout; 16 import android.widget.LinearLayout;
@@ -56,6 +60,9 @@ public class TipDialog extends Dialog { @@ -56,6 +60,9 @@ public class TipDialog extends Dialog {
56 super.onCreate(savedInstanceState); 60 super.onCreate(savedInstanceState);
57 //显示视图 61 //显示视图
58 this.setContentView(view); 62 this.setContentView(view);
  63 + //android 后台弹窗,只显示灰色蒙层,不显示布局。
  64 + getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
  65 +
59 } 66 }
60 67
61 public void setTipMsg(String tipMsg) { 68 public void setTipMsg(String tipMsg) {
@@ -79,6 +86,19 @@ public class TipDialog extends Dialog { @@ -79,6 +86,19 @@ public class TipDialog extends Dialog {
79 void onClick(TipDialog dialog); 86 void onClick(TipDialog dialog);
80 } 87 }
81 88
  89 + @Override
  90 + public void onWindowFocusChanged(boolean hasFocus) {
  91 + super.onWindowFocusChanged(hasFocus);
  92 + Window window = getWindow();
  93 + if (hasFocus && window != null) {
  94 + View decorView = window.getDecorView();
  95 + if (decorView.getHeight() == 0 || decorView.getWidth() == 0) {
  96 + decorView.requestLayout();
  97 + Log.d("TAG", "布局异常,重新布局");
  98 + }
  99 + }
  100 + }
  101 +
82 /** 102 /**
83 * 获取屏幕宽度 103 * 获取屏幕宽度
84 * 104 *
@@ -104,4 +124,5 @@ public class TipDialog extends Dialog { @@ -104,4 +124,5 @@ public class TipDialog extends Dialog {
104 int height = wm.getDefaultDisplay().getHeight(); 124 int height = wm.getDefaultDisplay().getHeight();
105 return height; 125 return height;
106 } 126 }
  127 +
107 } 128 }
moudle_pedometer/src/main/res/layout/fragment_run_race_detail.xml
@@ -37,7 +37,8 @@ @@ -37,7 +37,8 @@
37 android:background="#0D000000" 37 android:background="#0D000000"
38 android:clickable="false" 38 android:clickable="false"
39 android:focusable="false" 39 android:focusable="false"
40 - android:focusableInTouchMode="false"></LinearLayout> 40 + android:focusableInTouchMode="false"
  41 + android:visibility="gone"></LinearLayout>
41 42
42 <ImageView 43 <ImageView
43 android:id="@+id/iv_back" 44 android:id="@+id/iv_back"
moudle_pedometer/src/main/res/layout/fragment_running_map.xml
@@ -18,7 +18,8 @@ @@ -18,7 +18,8 @@
18 android:background="#0D000000" 18 android:background="#0D000000"
19 android:clickable="false" 19 android:clickable="false"
20 android:focusable="false" 20 android:focusable="false"
21 - android:focusableInTouchMode="false"></LinearLayout> 21 + android:focusableInTouchMode="false"
  22 + android:visibility="gone"></LinearLayout>
22 23
23 <FrameLayout 24 <FrameLayout
24 android:id="@+id/fl_back" 25 android:id="@+id/fl_back"
@@ -81,7 +82,7 @@ @@ -81,7 +82,7 @@
81 android:paddingRight="15dp" 82 android:paddingRight="15dp"
82 android:textColor="@color/text_black" 83 android:textColor="@color/text_black"
83 android:textSize="12sp" 84 android:textSize="12sp"
84 - android:visibility="gone"/> 85 + android:visibility="gone" />
85 <!----> 86 <!---->
86 </LinearLayout> 87 </LinearLayout>
87 88
@@ -181,8 +182,8 @@ @@ -181,8 +182,8 @@
181 android:id="@+id/tv_current_diatance" 182 android:id="@+id/tv_current_diatance"
182 android:layout_width="wrap_content" 183 android:layout_width="wrap_content"
183 android:layout_height="wrap_content" 184 android:layout_height="wrap_content"
184 - android:text="--"  
185 android:layout_marginRight="5dp" 185 android:layout_marginRight="5dp"
  186 + android:text="--"
186 android:textColor="@color/black" 187 android:textColor="@color/black"
187 android:textSize="20sp" 188 android:textSize="20sp"
188 android:textStyle="bold" /> 189 android:textStyle="bold" />
@@ -191,8 +192,8 @@ @@ -191,8 +192,8 @@
191 android:layout_width="wrap_content" 192 android:layout_width="wrap_content"
192 android:layout_height="wrap_content" 193 android:layout_height="wrap_content"
193 android:layout_marginTop="10dp" 194 android:layout_marginTop="10dp"
194 - android:text="距离(km)"  
195 android:layout_marginRight="5dp" 195 android:layout_marginRight="5dp"
  196 + android:text="距离(km)"
196 android:textColor="@color/black" 197 android:textColor="@color/black"
197 android:textSize="15sp" /> 198 android:textSize="15sp" />
198 </LinearLayout> 199 </LinearLayout>