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