Commit 14d23495ac763e132d33cfa0de5795070e434ce5
Merge branch 'master' of bj.gitlab.cnlive.com:cnlive-team/ModulePedometer
| ... | ... | @@ -3,9 +3,6 @@ |
| 3 | 3 | <component name="GradleSettings"> |
| 4 | 4 | <option name="linkedExternalProjectsSettings"> |
| 5 | 5 | <GradleProjectSettings> |
| 6 | - <compositeConfiguration> | |
| 7 | - <compositeBuild compositeDefinitionSource="SCRIPT" /> | |
| 8 | - </compositeConfiguration> | |
| 9 | 6 | <option name="distributionType" value="DEFAULT_WRAPPED" /> |
| 10 | 7 | <option name="externalProjectPath" value="$PROJECT_DIR$" /> |
| 11 | 8 | <option name="modules"> | ... | ... |
| ... | ... | @@ -9,10 +9,10 @@ android { |
| 9 | 9 | compileSdkVersion 28 |
| 10 | 10 | defaultConfig { |
| 11 | 11 | applicationId "com.cnlive.strike" |
| 12 | - minSdkVersion 16 | |
| 13 | - targetSdkVersion 27 | |
| 14 | - versionCode 1 | |
| 15 | - versionName "1.0" | |
| 12 | + minSdkVersion rootProject.ext.minSdkVersion | |
| 13 | + targetSdkVersion rootProject.ext.targetSdkVersion | |
| 14 | + versionCode rootProject.ext.versionCode | |
| 15 | + versionName rootProject.ext.versionName | |
| 16 | 16 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" |
| 17 | 17 | multiDexEnabled true |
| 18 | 18 | javaCompileOptions { | ... | ... |
| ... | ... | @@ -13,9 +13,7 @@ |
| 13 | 13 | android:roundIcon="@mipmap/ic_launcher_round" |
| 14 | 14 | android:supportsRtl="true" |
| 15 | 15 | android:theme="@style/AppTheme"> |
| 16 | - <activity | |
| 17 | - android:name=".MainActivity" | |
| 18 | - android:theme="@style/Theme.AppCompat.Light.NoActionBar"> | |
| 16 | + <activity android:name=".MainActivity"> | |
| 19 | 17 | <intent-filter> |
| 20 | 18 | <action android:name="android.intent.action.MAIN" /> |
| 21 | 19 | ... | ... |
| ... | ... | @@ -9,6 +9,7 @@ import com.cnlive.moudle.collectionTrace.ui.activity.CollRunRaceDetailActivity; |
| 9 | 9 | import com.cnlive.moudle.collectionTrace.ui.activity.CollRunningFinishActivity; |
| 10 | 10 | import com.cnlive.moudle.collectionTrace.ui.activity.RaceListActivity; |
| 11 | 11 | import com.cnlive.moudle.collectionTrace.ui.activity.RaceNameListActivity; |
| 12 | +import com.cnlive.moudle.pedometer.model.Constant; | |
| 12 | 13 | import com.cnlive.moudle.pedometer.ui.activity.MyRecordActivity; |
| 13 | 14 | import com.cnlive.moudle.pedometer.ui.activity.RunLineActivity; |
| 14 | 15 | import com.cnlive.moudle.pedometer.ui.activity.SelfRecordActivity; |
| ... | ... | @@ -20,7 +21,10 @@ public class MainActivity extends AppCompatActivity { |
| 20 | 21 | protected void onCreate(Bundle savedInstanceState) { |
| 21 | 22 | super.onCreate(savedInstanceState); |
| 22 | 23 | setContentView(R.layout.activity_main); |
| 24 | + | |
| 23 | 25 | String uid = "358916"; |
| 26 | +// String uid = "358689"; | |
| 27 | + | |
| 24 | 28 | findViewById(R.id.recordd).setOnClickListener(new View.OnClickListener() { |
| 25 | 29 | @Override |
| 26 | 30 | public void onClick(View v) { | ... | ... |
| ... | ... | @@ -6,6 +6,7 @@ import com.alibaba.android.arouter.launcher.ARouter; |
| 6 | 6 | import com.baidu.mapapi.CoordType; |
| 7 | 7 | import com.baidu.mapapi.SDKInitializer; |
| 8 | 8 | import com.cnlive.libs.base.application.AppConfig; |
| 9 | +import com.cnlive.moudle.pedometer.model.Constant; | |
| 9 | 10 | |
| 10 | 11 | public class MyApp extends Application { |
| 11 | 12 | @Override |
| ... | ... | @@ -15,6 +16,11 @@ public class MyApp extends Application { |
| 15 | 16 | AppConfig.init(getApplicationContext(), BuildConfig.APP_ID, BuildConfig.APP_KEY, BuildConfig.APP_SCERET, |
| 16 | 17 | 0, BuildConfig.DEBUG, "", "", |
| 17 | 18 | userId, "", "", "", "", "", "", "", BuildConfig.BAIDU_MAP_APP_KEY); |
| 19 | + if (AppConfig.isDebug()) { | |
| 20 | + Constant.SERVICE_ID = 213511; | |
| 21 | + } else { | |
| 22 | + Constant.SERVICE_ID = 214690; | |
| 23 | + } | |
| 18 | 24 | initARouter(); |
| 19 | 25 | //在使用SDK各组件之前初始化context信息,传入ApplicationContext |
| 20 | 26 | SDKInitializer.initialize(getApplicationContext()); | ... | ... |
| ... | ... | @@ -7,7 +7,6 @@ import com.alibaba.android.arouter.facade.annotation.Route; |
| 7 | 7 | import com.baidu.mapapi.CoordType; |
| 8 | 8 | import com.baidu.mapapi.SDKInitializer; |
| 9 | 9 | import com.example.moudle_baidumap.R; |
| 10 | -@Route(path = "/moudle_baidumap/BaiduMapMainActivity") | |
| 11 | 10 | public class BaiduMapMainActivity extends AppCompatActivity { |
| 12 | 11 | |
| 13 | 12 | @Override | ... | ... |
| ... | ... | @@ -5,6 +5,19 @@ import android.content.Context; |
| 5 | 5 | import com.cnlive.moudle.pedometer.utils.MySpHelper; |
| 6 | 6 | |
| 7 | 7 | public class CollCommonInfo { |
| 8 | + private static final String KEY_USER_ID = "collUserId";//用户ID | |
| 9 | + private static final String KEY_STEP_START_TIME = "collStepStartTime";//服务启动时间 | |
| 10 | + private static final String KEY_WRITE_USER_STEP = "collWriteUserStep";//是否向数据库写入数据 | |
| 11 | + private static final String KEY_IS_RUN_STEP_SERVICE = "collRunStepService";//是否运行计步服务 | |
| 12 | + private static final String KEY_IS_RUN_KEEP_ALIVE_SERVICE = "collKeepAliveService";//是否运行保活服务 | |
| 13 | + private static final String KEY_STREET_ID = "collStreetId";//赛事ID | |
| 14 | + private static final String KEY_IS_RUN_BAIDU_TRACE_SERVICE = "collRunBaiduTraceService";//是否运行百度鹰眼服务 | |
| 15 | + private static final String KEY_IS_FIRST_STEP_SEND_TRACE_TIP = "collFirstStepSendTraceTip";//是否第一次启动鹰眼服务 | |
| 16 | + private static final String KEY_USER_NICK_NAME = "collRunUserNickName";//用户昵称 | |
| 17 | + private static final String KEY_USER_NICK_ICON = "collRunUserNickIcon";//用户头像 | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 8 | 21 | |
| 9 | 22 | /** |
| 10 | 23 | * 设置计步时间 |
| ... | ... | @@ -12,7 +25,7 @@ public class CollCommonInfo { |
| 12 | 25 | * @param context |
| 13 | 26 | */ |
| 14 | 27 | public static void setStepStartTime(Context context, long currentTime) { |
| 15 | - MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).putLong("CollstepStartTime", currentTime); | |
| 28 | + MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).putLong(KEY_STEP_START_TIME, currentTime); | |
| 16 | 29 | } |
| 17 | 30 | |
| 18 | 31 | /** |
| ... | ... | @@ -21,7 +34,7 @@ public class CollCommonInfo { |
| 21 | 34 | * @param context |
| 22 | 35 | */ |
| 23 | 36 | public static long getStepStartTime(Context context) { |
| 24 | - return MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).getLong("CollstepStartTime", 0); | |
| 37 | + return MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).getLong(KEY_STEP_START_TIME, 0); | |
| 25 | 38 | } |
| 26 | 39 | |
| 27 | 40 | /** |
| ... | ... | @@ -30,7 +43,7 @@ public class CollCommonInfo { |
| 30 | 43 | * @param context |
| 31 | 44 | */ |
| 32 | 45 | public static void setIsWriteUserStep(Context context, boolean isAllow) { |
| 33 | - MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).putBoolean("CollwriteUserStep:", isAllow); | |
| 46 | + MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).putBoolean(KEY_WRITE_USER_STEP, isAllow); | |
| 34 | 47 | } |
| 35 | 48 | |
| 36 | 49 | /** |
| ... | ... | @@ -39,7 +52,7 @@ public class CollCommonInfo { |
| 39 | 52 | * @param context |
| 40 | 53 | */ |
| 41 | 54 | public static boolean getIsWriteUserStep(Context context) { |
| 42 | - return MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).getBoolean("CollwriteUserStep", true); | |
| 55 | + return MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).getBoolean(KEY_WRITE_USER_STEP, true); | |
| 43 | 56 | } |
| 44 | 57 | |
| 45 | 58 | /** |
| ... | ... | @@ -47,14 +60,14 @@ public class CollCommonInfo { |
| 47 | 60 | * @param uid |
| 48 | 61 | */ |
| 49 | 62 | public static void setUserId(Context context, String uid) { |
| 50 | - MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).putString("ColluserId", uid); | |
| 63 | + MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).putString(KEY_USER_ID, uid); | |
| 51 | 64 | } |
| 52 | 65 | |
| 53 | 66 | /** |
| 54 | 67 | * @param context |
| 55 | 68 | */ |
| 56 | 69 | public static String getUserId(Context context) { |
| 57 | - return MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).getString("ColluserId", ""); | |
| 70 | + return MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).getString(KEY_USER_ID, ""); | |
| 58 | 71 | } |
| 59 | 72 | |
| 60 | 73 | /** |
| ... | ... | @@ -64,7 +77,7 @@ public class CollCommonInfo { |
| 64 | 77 | * @param isAllow |
| 65 | 78 | */ |
| 66 | 79 | public static void setIsRunStepService(Context context, boolean isAllow) { |
| 67 | - MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).putBoolean("CollrunStepService", isAllow); | |
| 80 | + MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).putBoolean(KEY_IS_RUN_STEP_SERVICE, isAllow); | |
| 68 | 81 | |
| 69 | 82 | } |
| 70 | 83 | |
| ... | ... | @@ -75,7 +88,7 @@ public class CollCommonInfo { |
| 75 | 88 | * @param isAllow |
| 76 | 89 | */ |
| 77 | 90 | public static void setIsRunKeepAliveService(Context context, boolean isAllow) { |
| 78 | - MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).putBoolean("CollKeepAliveService", isAllow); | |
| 91 | + MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).putBoolean(KEY_IS_RUN_KEEP_ALIVE_SERVICE, isAllow); | |
| 79 | 92 | |
| 80 | 93 | } |
| 81 | 94 | |
| ... | ... | @@ -85,7 +98,7 @@ public class CollCommonInfo { |
| 85 | 98 | * @param context |
| 86 | 99 | */ |
| 87 | 100 | public static boolean getIsRunKeepAliveService(Context context) { |
| 88 | - return MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).getBoolean("CollKeepAliveService", false); | |
| 101 | + return MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).getBoolean(KEY_IS_RUN_KEEP_ALIVE_SERVICE, false); | |
| 89 | 102 | } |
| 90 | 103 | |
| 91 | 104 | /** |
| ... | ... | @@ -94,7 +107,7 @@ public class CollCommonInfo { |
| 94 | 107 | * @param context |
| 95 | 108 | */ |
| 96 | 109 | public static boolean getIsRunStepService(Context context) { |
| 97 | - return MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).getBoolean("CollrunStepService", false); | |
| 110 | + return MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).getBoolean(KEY_IS_RUN_STEP_SERVICE, false); | |
| 98 | 111 | } |
| 99 | 112 | |
| 100 | 113 | /** |
| ... | ... | @@ -104,7 +117,7 @@ public class CollCommonInfo { |
| 104 | 117 | * @param streetId |
| 105 | 118 | */ |
| 106 | 119 | public static void setStreetId(Context context, String streetId) { |
| 107 | - MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).putString("CollstreetId", streetId); | |
| 120 | + MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).putString(KEY_STREET_ID, streetId); | |
| 108 | 121 | } |
| 109 | 122 | |
| 110 | 123 | /** |
| ... | ... | @@ -113,7 +126,7 @@ public class CollCommonInfo { |
| 113 | 126 | * @param context |
| 114 | 127 | */ |
| 115 | 128 | public static String getStreetId(Context context) { |
| 116 | - return MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).getString("CollstreetId", ""); | |
| 129 | + return MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).getString(KEY_STREET_ID, ""); | |
| 117 | 130 | } |
| 118 | 131 | |
| 119 | 132 | /** |
| ... | ... | @@ -123,7 +136,7 @@ public class CollCommonInfo { |
| 123 | 136 | * @param isRun |
| 124 | 137 | */ |
| 125 | 138 | public static void setTsRunBaiduTraceService(Context context, boolean isRun) { |
| 126 | - MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).putBoolean("CollRunBaiduTraceService", isRun); | |
| 139 | + MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).putBoolean(KEY_IS_RUN_BAIDU_TRACE_SERVICE, isRun); | |
| 127 | 140 | } |
| 128 | 141 | |
| 129 | 142 | /** |
| ... | ... | @@ -132,7 +145,7 @@ public class CollCommonInfo { |
| 132 | 145 | * @param context |
| 133 | 146 | */ |
| 134 | 147 | public static boolean getIsRunBaiduTraceService(Context context) { |
| 135 | - return MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).getBoolean("CollRunBaiduTraceService", true); | |
| 148 | + return MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).getBoolean(KEY_IS_RUN_BAIDU_TRACE_SERVICE, true); | |
| 136 | 149 | } |
| 137 | 150 | |
| 138 | 151 | /** |
| ... | ... | @@ -142,7 +155,7 @@ public class CollCommonInfo { |
| 142 | 155 | * @param isAllow |
| 143 | 156 | */ |
| 144 | 157 | public static void setIsFirstStepSendTraceTip(Context context, boolean isAllow) { |
| 145 | - MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).putBoolean("CollFirstStepSendTraceTip", isAllow); | |
| 158 | + MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).putBoolean(KEY_IS_FIRST_STEP_SEND_TRACE_TIP, isAllow); | |
| 146 | 159 | } |
| 147 | 160 | |
| 148 | 161 | /** |
| ... | ... | @@ -152,7 +165,7 @@ public class CollCommonInfo { |
| 152 | 165 | * @param context |
| 153 | 166 | */ |
| 154 | 167 | public static boolean getIsFirstStepSendTraceTip(Context context) { |
| 155 | - return MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).getBoolean("CollFirstStepSendTraceTip", true); | |
| 168 | + return MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).getBoolean(KEY_IS_FIRST_STEP_SEND_TRACE_TIP, true); | |
| 156 | 169 | } |
| 157 | 170 | |
| 158 | 171 | /** |
| ... | ... | @@ -162,7 +175,7 @@ public class CollCommonInfo { |
| 162 | 175 | * @param nickName |
| 163 | 176 | */ |
| 164 | 177 | public static void setUserNickName(Context context, String nickName) { |
| 165 | - MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).putString("CollRunUserNickName", nickName); | |
| 178 | + MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).putString(KEY_USER_NICK_NAME, nickName); | |
| 166 | 179 | |
| 167 | 180 | } |
| 168 | 181 | |
| ... | ... | @@ -172,7 +185,7 @@ public class CollCommonInfo { |
| 172 | 185 | * @param context |
| 173 | 186 | */ |
| 174 | 187 | public static String getUserNickName(Context context) { |
| 175 | - return MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).getString("CollRunUserNickName", ""); | |
| 188 | + return MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).getString(KEY_USER_NICK_NAME, ""); | |
| 176 | 189 | |
| 177 | 190 | } |
| 178 | 191 | |
| ... | ... | @@ -183,7 +196,7 @@ public class CollCommonInfo { |
| 183 | 196 | * @param userIcon |
| 184 | 197 | */ |
| 185 | 198 | public static void setUserIcon(Context context, String userIcon) { |
| 186 | - MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).putString("CollRunUserNickIcon", userIcon); | |
| 199 | + MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).putString(KEY_USER_NICK_ICON, userIcon); | |
| 187 | 200 | |
| 188 | 201 | } |
| 189 | 202 | |
| ... | ... | @@ -193,7 +206,7 @@ public class CollCommonInfo { |
| 193 | 206 | * @param context |
| 194 | 207 | */ |
| 195 | 208 | public static String getUserIcon(Context context) { |
| 196 | - return MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).getString("CollRunUserNickIcon", ""); | |
| 209 | + return MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).getString(KEY_USER_NICK_ICON, ""); | |
| 197 | 210 | |
| 198 | 211 | } |
| 199 | 212 | |
| ... | ... | @@ -202,13 +215,13 @@ public class CollCommonInfo { |
| 202 | 215 | * @param context |
| 203 | 216 | */ |
| 204 | 217 | public static void reset(Context context) { |
| 205 | - MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).removeKey("CollwriteUserStep"); | |
| 206 | - MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).removeKey("CollstepStartTime"); | |
| 207 | - MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).removeKey("CollrunStepService"); | |
| 208 | - MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).removeKey("CollstepStartTime"); | |
| 209 | - MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).removeKey("CollKeepAliveService"); | |
| 210 | - MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).removeKey("CollRunBaiduTraceService"); | |
| 211 | - MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).removeKey("CollFirstStepSendTraceTip"); | |
| 218 | + MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).removeKey(KEY_WRITE_USER_STEP); | |
| 219 | + MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).removeKey(KEY_STEP_START_TIME); | |
| 220 | + MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).removeKey(KEY_IS_RUN_STEP_SERVICE); | |
| 221 | + MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).removeKey(KEY_STEP_START_TIME); | |
| 222 | + MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).removeKey(KEY_IS_RUN_KEEP_ALIVE_SERVICE); | |
| 223 | + MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).removeKey(KEY_IS_RUN_BAIDU_TRACE_SERVICE); | |
| 224 | + MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).removeKey(KEY_IS_FIRST_STEP_SEND_TRACE_TIP); | |
| 212 | 225 | } |
| 213 | 226 | |
| 214 | 227 | ... | ... |
| ... | ... | @@ -66,12 +66,12 @@ public class CollRunningFinishFragmetPresenter extends MvpBasePresenter<CollRunn |
| 66 | 66 | endPoint = GsonUtil.GsonToBean(userStepEntity.getCollEndPointData(), CollectPoint.class); |
| 67 | 67 | } |
| 68 | 68 | if (null != startPoint) { |
| 69 | - collectPoints.add(0, startPoint); | |
| 69 | +// collectPoints.add(0, startPoint); | |
| 70 | 70 | //起点 |
| 71 | 71 | paramsMap.put("startLocation", startPoint.getPointName()); |
| 72 | 72 | } |
| 73 | 73 | if (null != endPoint) { |
| 74 | - collectPoints.add(endPoint); | |
| 74 | +// collectPoints.add(endPoint); | |
| 75 | 75 | // 终点 |
| 76 | 76 | paramsMap.put("endLocation", endPoint.getPointName()); |
| 77 | 77 | ... | ... |
| ... | ... | @@ -42,6 +42,7 @@ import com.cnlive.moudle.collectionTrace.ui.fragment.CollRunningMapFragment; |
| 42 | 42 | import com.cnlive.moudle.collectionTrace.commonInfo.CollCommonInfo; |
| 43 | 43 | import com.cnlive.moudle.pedometer.commonInfo.CommonInfo; |
| 44 | 44 | import com.cnlive.moudle.pedometer.model.Constant; |
| 45 | +import com.cnlive.moudle.pedometer.model.MessageEvent; | |
| 45 | 46 | import com.cnlive.moudle.pedometer.net.bean.RunRaceDetailInfo; |
| 46 | 47 | import com.cnlive.moudle.pedometer.service.StepService; |
| 47 | 48 | import com.cnlive.moudle.pedometer.sql.entity.CollUserStepEntity; |
| ... | ... | @@ -55,6 +56,8 @@ import com.cnlive.moudle.pedometer.utils.TimeUtil; |
| 55 | 56 | import com.example.moudle_pedometer.R; |
| 56 | 57 | import com.hannesdorfmann.mosby3.mvp.MvpView; |
| 57 | 58 | |
| 59 | +import org.greenrobot.eventbus.EventBus; | |
| 60 | + | |
| 58 | 61 | import java.util.ArrayList; |
| 59 | 62 | import java.util.List; |
| 60 | 63 | |
| ... | ... | @@ -309,8 +312,8 @@ public class CollRunningMapFragmentView implements MvpView, SensorEventListener |
| 309 | 312 | private int updataCanTakePointCount() { |
| 310 | 313 | //获取用户可打点的数量 |
| 311 | 314 | int canTakePointCount = CollStepUtil.getCollImportPointSize(getContext(), CollCommonInfo.getUserId(getContext())); |
| 312 | - if (canTakePointCount < 98) { | |
| 313 | - canTakePointCount = 98 - canTakePointCount; | |
| 315 | + if (canTakePointCount < Constant.TAKE_POINT_MAX_SIZE) { | |
| 316 | + canTakePointCount = Constant.TAKE_POINT_MAX_SIZE - canTakePointCount; | |
| 314 | 317 | } else { |
| 315 | 318 | canTakePointCount = 0; |
| 316 | 319 | } |
| ... | ... | @@ -788,6 +791,8 @@ public class CollRunningMapFragmentView implements MvpView, SensorEventListener |
| 788 | 791 | if (mMapView != null) { |
| 789 | 792 | mMapView.onResume(); |
| 790 | 793 | } |
| 794 | + //保持最新的步数 | |
| 795 | + EventBus.getDefault().post(new MessageEvent(Constant.COLL_SERVICE_STEP_COUNT_ONRESUME, "")); | |
| 791 | 796 | } |
| 792 | 797 | |
| 793 | 798 | public void onPause() { | ... | ... |
| ... | ... | @@ -407,15 +407,18 @@ public class StartTraceFragmentView implements MvpView, SensorEventListener { |
| 407 | 407 | } |
| 408 | 408 | if (isFirstLoc) { |
| 409 | 409 | isFirstLoc = false; |
| 410 | - if (location.getRadius() > Constant.LOCA_ACCURACY) { | |
| 411 | - Toast.makeText(getContext(), "当前定位精度为:" + location.getRadius() + "米,请您移动至空旷地带!", Toast.LENGTH_SHORT).show(); | |
| 412 | - } | |
| 413 | - } else { | |
| 414 | - //过滤定位精度 | |
| 415 | - if (location.getRadius() > Constant.LOCA_ACCURACY) { | |
| 416 | - return; | |
| 417 | - } | |
| 410 | + Toast.makeText(getContext(), "当前定位精度为:" + location.getRadius() + "米,请您移动至空旷地带!", Toast.LENGTH_SHORT).show(); | |
| 411 | + | |
| 418 | 412 | } |
| 413 | +// if (location.getRadius() > Constant.LOCA_ACCURACY) { | |
| 414 | +// Toast.makeText(getContext(), "当前定位精度为:" + location.getRadius() + "米,请您移动至空旷地带!", Toast.LENGTH_SHORT).show(); | |
| 415 | +// } | |
| 416 | +// } else { | |
| 417 | + //过滤定位精度 | |
| 418 | + if (location.getRadius() > Constant.LOCA_ACCURACY) { | |
| 419 | + return; | |
| 420 | + } | |
| 421 | +// } | |
| 419 | 422 | followMyLocation = new MyLocationData.Builder() |
| 420 | 423 | .accuracy(location.getRadius()) |
| 421 | 424 | // 此处设置开发者获取到的方向信息,顺时针0-360 | ... | ... |
| ... | ... | @@ -47,6 +47,7 @@ public class CollKeepLiveService extends Service implements MediaPlayer.OnComple |
| 47 | 47 | private final String TAG = "CollKeepLiveService"; |
| 48 | 48 | private Handler handler; |
| 49 | 49 | private Runnable runnable; |
| 50 | + private boolean isRegisterReceiver = false; | |
| 50 | 51 | |
| 51 | 52 | public CollKeepLiveService() { |
| 52 | 53 | } |
| ... | ... | @@ -96,12 +97,16 @@ public class CollKeepLiveService extends Service implements MediaPlayer.OnComple |
| 96 | 97 | IntentFilter intentFilter = new IntentFilter(); |
| 97 | 98 | intentFilter.addAction(Intent.ACTION_SCREEN_OFF); |
| 98 | 99 | intentFilter.addAction(Intent.ACTION_SCREEN_ON); |
| 100 | + intentFilter.addAction(Intent.ACTION_TIME_CHANGED); | |
| 101 | + intentFilter.addAction(Intent.ACTION_TIME_TICK); | |
| 102 | + intentFilter.addAction(Intent.ACTION_TIMEZONE_CHANGED); | |
| 99 | 103 | // intentFilter.addAction(Intent.ACTION_BATTERY_CHANGED); |
| 100 | 104 | // intentFilter.addAction(Intent.ACTION_TIME_CHANGED); |
| 101 | 105 | // intentFilter.addAction(Intent.ACTION_POWER_CONNECTED); |
| 102 | 106 | // intentFilter.addAction(Intent.ACTION_POWER_DISCONNECTED); |
| 103 | 107 | intentFilter.addAction("com.cnlive.moudle.collectionTrace.receivers.CollServiceReceiver"); |
| 104 | 108 | registerReceiver(myReceiver, intentFilter); |
| 109 | + isRegisterReceiver = true; | |
| 105 | 110 | } |
| 106 | 111 | |
| 107 | 112 | /** |
| ... | ... | @@ -212,7 +217,7 @@ public class CollKeepLiveService extends Service implements MediaPlayer.OnComple |
| 212 | 217 | public void onDestroy() { |
| 213 | 218 | super.onDestroy(); |
| 214 | 219 | try { |
| 215 | - if (myReceiver != null) { | |
| 220 | + if (myReceiver != null && isRegisterReceiver) { | |
| 216 | 221 | unregisterReceiver(myReceiver); |
| 217 | 222 | } |
| 218 | 223 | } catch (Exception e) { |
| ... | ... | @@ -228,7 +233,7 @@ public class CollKeepLiveService extends Service implements MediaPlayer.OnComple |
| 228 | 233 | //发送重启广播 |
| 229 | 234 | sendRestartBroadCast(); |
| 230 | 235 | } |
| 231 | - | |
| 236 | + isRegisterReceiver = false; | |
| 232 | 237 | |
| 233 | 238 | } |
| 234 | 239 | ... | ... |
| ... | ... | @@ -229,7 +229,8 @@ public class CollStepService extends Service implements SensorEventListener { |
| 229 | 229 | if (mClient != null) { |
| 230 | 230 | retryIndex = 0; |
| 231 | 231 | mClient.startGather(traceListener); |
| 232 | - Toast.makeText(getApplicationContext(), "开启轨迹服务", Toast.LENGTH_LONG).show(); | |
| 232 | + Log.e(TAG, "开启轨迹服务" ); | |
| 233 | +// Toast.makeText(getApplicationContext(), "开启轨迹服务", Toast.LENGTH_LONG).show(); | |
| 233 | 234 | boolean isFirstSendNotification = CollCommonInfo.getIsFirstStepSendTraceTip(getApplicationContext()); |
| 234 | 235 | if (isFirstSendNotification) { |
| 235 | 236 | CollCommonInfo.setIsFirstStepSendTraceTip(getApplicationContext(), false); |
| ... | ... | @@ -273,7 +274,8 @@ public class CollStepService extends Service implements SensorEventListener { |
| 273 | 274 | if (StatusCodes.SUCCESS == errorNo || StatusCodes.CACHE_TRACK_NOT_UPLOAD == errorNo) { |
| 274 | 275 | if (mClient != null) { |
| 275 | 276 | mClient.stopTrace(mTrace, traceListener); |
| 276 | - Toast.makeText(getApplicationContext(), "停止轨迹服务", Toast.LENGTH_LONG).show(); | |
| 277 | + Log.e(TAG, "停止轨迹服务" ); | |
| 278 | +// Toast.makeText(getApplicationContext(), "停止轨迹服务", Toast.LENGTH_LONG).show(); | |
| 277 | 279 | } |
| 278 | 280 | } |
| 279 | 281 | } |
| ... | ... | @@ -293,7 +295,8 @@ public class CollStepService extends Service implements SensorEventListener { |
| 293 | 295 | Log.e(TAG, "onStartGatherCallback: " + message + "," + errorNo); |
| 294 | 296 | if (StatusCodes.SUCCESS == errorNo || StatusCodes.GATHER_STARTED == errorNo) { |
| 295 | 297 | retryIndex = 0; |
| 296 | - Toast.makeText(getApplicationContext(), "开始采集", Toast.LENGTH_LONG).show(); | |
| 298 | + Log.e(TAG, "开始采集" ); | |
| 299 | +// Toast.makeText(getApplicationContext(), "开始采集", Toast.LENGTH_LONG).show(); | |
| 297 | 300 | } else { |
| 298 | 301 | //重新开启采集 |
| 299 | 302 | if (retryIndex < 4) { |
| ... | ... | @@ -320,7 +323,8 @@ public class CollStepService extends Service implements SensorEventListener { |
| 320 | 323 | @Override |
| 321 | 324 | public void onStopGatherCallback(int errorNo, String message) { |
| 322 | 325 | if (StatusCodes.SUCCESS == errorNo || StatusCodes.GATHER_STOPPED == errorNo) { |
| 323 | - Toast.makeText(getApplicationContext(), "停止采集", Toast.LENGTH_LONG).show(); | |
| 326 | + Log.e(TAG, "停止采集" ); | |
| 327 | +// Toast.makeText(getApplicationContext(), "停止采集", Toast.LENGTH_LONG).show(); | |
| 324 | 328 | if (mClient != null) { |
| 325 | 329 | mClient.stopTrace(mTrace, traceListener); |
| 326 | 330 | } |
| ... | ... | @@ -494,6 +498,12 @@ public class CollStepService extends Service implements SensorEventListener { |
| 494 | 498 | // else if (messageEvent.getMessageType() == Constant.SERVICE_STEP_COUNT_CONTINUE) { |
| 495 | 499 | // pauseFlag = false; |
| 496 | 500 | // } |
| 501 | + | |
| 502 | + //更新锁屏步数 | |
| 503 | + if (messageEvent.getMessageType() == Constant.COLL_SERVICE_STEP_COUNT_ONRESUME) { | |
| 504 | + updateNotification(); | |
| 505 | + } | |
| 506 | + | |
| 497 | 507 | } |
| 498 | 508 | |
| 499 | 509 | /** |
| ... | ... | @@ -559,6 +569,7 @@ public class CollStepService extends Service implements SensorEventListener { |
| 559 | 569 | } |
| 560 | 570 | |
| 561 | 571 | private void updateNotification() { |
| 572 | + save(); | |
| 562 | 573 | // Log.e(TAG, "updateNotification: 当前步数:" + CURRENT_STEP); |
| 563 | 574 | EventBus.getDefault().post(new MessageEvent(Constant.COLL_SERVICE_STEP_COUNT_UPDATE, CURRENT_STEP)); |
| 564 | 575 | updateSpeedStepFlag = false; |
| ... | ... | @@ -669,12 +680,12 @@ public class CollStepService extends Service implements SensorEventListener { |
| 669 | 680 | } else if (Intent.ACTION_DATE_CHANGED.equals(action)) {//日期变化步数重置为0 |
| 670 | 681 | // Logger.d("重置步数" + StepDcretor.CURRENT_STEP); |
| 671 | 682 | save(); |
| 672 | - isNewDay(); | |
| 683 | +// isNewDay(); | |
| 673 | 684 | } else if (Intent.ACTION_TIME_CHANGED.equals(action)) { |
| 674 | 685 | //时间变化步数重置为0 |
| 675 | 686 | // isCall(); |
| 676 | 687 | save(); |
| 677 | - isNewDay(); | |
| 688 | +// isNewDay(); | |
| 678 | 689 | } else if (Intent.ACTION_TIME_TICK.equals(action)) {//日期变化步数重置为0 |
| 679 | 690 | // isCall(); |
| 680 | 691 | // Logger.d("重置步数" + StepDcretor.CURRENT_STEP); | ... | ... |
| ... | ... | @@ -37,8 +37,6 @@ public class RaceListActivity extends AppCompatActivity { |
| 37 | 37 | CommonInfo.setUserId(this,getIntent().getStringExtra("userId")); |
| 38 | 38 | CommonInfo.setUserNickName(this,getIntent().getStringExtra("userName")); |
| 39 | 39 | CommonInfo.setUserIcon(this,getIntent().getStringExtra("userIcon")); |
| 40 | - }else { | |
| 41 | - CommonInfo.setUserId(this, "10513196"); | |
| 42 | 40 | } |
| 43 | 41 | getSupportFragmentManager().beginTransaction().replace(R.id.race_container,new RaceListFragment()).commit(); |
| 44 | 42 | } | ... | ... |
| ... | ... | @@ -186,7 +186,7 @@ public class CollRunningMapFragment extends QMUIFragment<CollRunningMapFragmentV |
| 186 | 186 | if (mVibrator != null) { |
| 187 | 187 | //设置震动周期,数组表示时间:等待+执行,单位是毫秒,下面操作代表:等待100,执行100,等待100,执行1000, |
| 188 | 188 | //后面的数字如果为-1代表不重复,之执行一次,其他代表会重复,0代表从数组的第0个位置开始 |
| 189 | - mVibrator.vibrate(new long[]{100, 1000, 100, 1000}, -1); | |
| 189 | + mVibrator.vibrate(new long[]{Constant.VIBRATOR_DELAY_TIME, Constant.VIBRATOR_RUN_TIME, Constant.VIBRATOR_DELAY_TIME, Constant.VIBRATOR_RUN_TIME}, Constant.VIBRATOR_REPEAT_TIME); | |
| 190 | 190 | } |
| 191 | 191 | if (tipDialog != null) { |
| 192 | 192 | tipDialog.show(); | ... | ... |
| ... | ... | @@ -7,6 +7,8 @@ import android.support.annotation.Nullable; |
| 7 | 7 | import android.view.View; |
| 8 | 8 | |
| 9 | 9 | import com.cnlive.libs.base.ui.QMUIFragment; |
| 10 | +import com.cnlive.libs.base.util.StatusBarUtil; | |
| 11 | +import com.cnlive.libs.base.util.StatusBarUtil2; | |
| 10 | 12 | import com.cnlive.moudle.collectionTrace.frame.presenter.StartTraceFragmentPresenter; |
| 11 | 13 | import com.cnlive.moudle.collectionTrace.frame.view.StartTraceFragmentView; |
| 12 | 14 | import com.cnlive.moudle.collectionTrace.ui.activity.CollPedometerMainActivity; |
| ... | ... | @@ -55,6 +57,8 @@ public class StartTraceFragment extends QMUIFragment<StartTraceFragmentView, Sta |
| 55 | 57 | @Override |
| 56 | 58 | public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { |
| 57 | 59 | super.onViewCreated(view, savedInstanceState); |
| 60 | + StatusBarUtil.setStatusBarWrite(getActivity()); | |
| 61 | + StatusBarUtil2.setColor(getActivity(), getResources().getColor(R.color.white), 0); | |
| 58 | 62 | EventBus.getDefault().register(this); |
| 59 | 63 | mSensorManager = (SensorManager) getActivity().getSystemService(SENSOR_SERVICE);//获取传感器管理服务 |
| 60 | 64 | if (null != getArguments()) { | ... | ... |
| ... | ... | @@ -6,6 +6,7 @@ import android.util.Log; |
| 6 | 6 | |
| 7 | 7 | import com.baidu.mapapi.model.LatLng; |
| 8 | 8 | import com.cnlive.moudle.collectionTrace.model.CollectPoint; |
| 9 | +import com.cnlive.moudle.pedometer.model.Constant; | |
| 9 | 10 | import com.cnlive.moudle.pedometer.sql.dao.CollUserStepEntityDao; |
| 10 | 11 | import com.cnlive.moudle.pedometer.sql.dao.UserStepEntityDao; |
| 11 | 12 | import com.cnlive.moudle.pedometer.sql.db.DbCore; |
| ... | ... | @@ -190,10 +191,10 @@ public class CollStepUtil { |
| 190 | 191 | } |
| 191 | 192 | } |
| 192 | 193 | } |
| 193 | - return 98; | |
| 194 | + return Constant.TAKE_POINT_MAX_SIZE; | |
| 194 | 195 | } catch (Exception e) { |
| 195 | 196 | Log.e(TAG, "getCollImportPointSize: " + e.getMessage()); |
| 196 | - return 98; | |
| 197 | + return Constant.TAKE_POINT_MAX_SIZE; | |
| 197 | 198 | } |
| 198 | 199 | |
| 199 | 200 | } | ... | ... |
| ... | ... | @@ -6,24 +6,19 @@ import com.cnlive.moudle.pedometer.utils.MySpHelper; |
| 6 | 6 | import com.cnlive.moudle.pedometer.utils.TimeUtil; |
| 7 | 7 | |
| 8 | 8 | public class CommonInfo { |
| 9 | - | |
| 10 | -// /** | |
| 11 | -// * 设置计步时间 | |
| 12 | -// * | |
| 13 | -// * @param context | |
| 14 | -// */ | |
| 15 | -// public static void setStepStartTime(Context context, long currentTime) { | |
| 16 | -// MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).putLong("stepStartTime", currentTime); | |
| 17 | -// } | |
| 18 | -// | |
| 19 | -// /** | |
| 20 | -// * 获取计步时间 | |
| 21 | -// * | |
| 22 | -// * @param context | |
| 23 | -// */ | |
| 24 | -// public static long getStepStartTime(Context context) { | |
| 25 | -// return MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).getLong("stepStartTime", 0); | |
| 26 | -// } | |
| 9 | + private static final String KEY_USER_ID = "runUserId";//用户ID | |
| 10 | + private static final String KEY_WRITE_USER_STEP = "runWriteUserStep";//是否允许写入步数 | |
| 11 | + private static final String KEY_RUN_WRITE_USER_STEP = "runStepService";//是否运行计步服务 | |
| 12 | + private static final String KEY_KEEP_ALIVE_SERVICE = "runKeepAliveService";//是否运行保活服务 | |
| 13 | + private static final String KEY_EVENT_ID = "runStreetId";//赛事id | |
| 14 | + private static final String KEY_RUN_BAIDU_TRACE_SERVICE = "runBaiduTraceService";//是否运行百度服务 | |
| 15 | + private static final String KEY_FIRST_STEP_SEND_TIP = "runFirstStepSendTraceTip";//是否是第一次启动鹰眼服务 | |
| 16 | + private static final String KEY_FENCE_ID = "runFenceId";//围栏ID | |
| 17 | + private static final String KEY_USER_NICK_NAME = "runUserNickName";//用户昵称 | |
| 18 | + private static final String KEY_USER_NICK_ICON = "runUserNickIcon";//用户头像 | |
| 19 | + private static final String KEY_USER_PHONE = "runUserPhone";//用户电话 | |
| 20 | + private static final String KEY_IS_FIRST_SHOW_TIME_TIP = "runIsFirstShowTimeTip";//是否是第一次显示倒计时 | |
| 21 | + private static final String KEY_IS_PAUSE_STATE = "runIsPauseState";//是否点击暂停按钮 | |
| 27 | 22 | |
| 28 | 23 | |
| 29 | 24 | /** |
| ... | ... | @@ -32,7 +27,7 @@ public class CommonInfo { |
| 32 | 27 | * @param context |
| 33 | 28 | */ |
| 34 | 29 | public static void setIsWriteUserStep(Context context, boolean isAllow) { |
| 35 | - MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).putBoolean("writeUserStep:", isAllow); | |
| 30 | + MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).putBoolean(KEY_WRITE_USER_STEP, isAllow); | |
| 36 | 31 | } |
| 37 | 32 | |
| 38 | 33 | /** |
| ... | ... | @@ -41,7 +36,7 @@ public class CommonInfo { |
| 41 | 36 | * @param context |
| 42 | 37 | */ |
| 43 | 38 | public static boolean getIsWriteUserStep(Context context) { |
| 44 | - return MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).getBoolean("writeUserStep", true); | |
| 39 | + return MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).getBoolean(KEY_WRITE_USER_STEP, true); | |
| 45 | 40 | } |
| 46 | 41 | |
| 47 | 42 | /** |
| ... | ... | @@ -49,14 +44,14 @@ public class CommonInfo { |
| 49 | 44 | * @param uid |
| 50 | 45 | */ |
| 51 | 46 | public static void setUserId(Context context, String uid) { |
| 52 | - MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).putString("userId", uid); | |
| 47 | + MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).putString(KEY_USER_ID, uid); | |
| 53 | 48 | } |
| 54 | 49 | |
| 55 | 50 | /** |
| 56 | 51 | * @param context |
| 57 | 52 | */ |
| 58 | 53 | public static String getUserId(Context context) { |
| 59 | - return MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).getString("userId", ""); | |
| 54 | + return MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).getString(KEY_USER_ID, ""); | |
| 60 | 55 | } |
| 61 | 56 | |
| 62 | 57 | /** |
| ... | ... | @@ -66,7 +61,7 @@ public class CommonInfo { |
| 66 | 61 | * @param isAllow |
| 67 | 62 | */ |
| 68 | 63 | public static void setIsRunStepService(Context context, boolean isAllow) { |
| 69 | - MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).putBoolean("runStepService", isAllow); | |
| 64 | + MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).putBoolean(KEY_RUN_WRITE_USER_STEP, isAllow); | |
| 70 | 65 | |
| 71 | 66 | } |
| 72 | 67 | |
| ... | ... | @@ -77,7 +72,7 @@ public class CommonInfo { |
| 77 | 72 | * @param isAllow |
| 78 | 73 | */ |
| 79 | 74 | public static void setIsRunKeepAliveService(Context context, boolean isAllow) { |
| 80 | - MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).putBoolean("KeepAliveService", isAllow); | |
| 75 | + MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).putBoolean(KEY_KEEP_ALIVE_SERVICE, isAllow); | |
| 81 | 76 | |
| 82 | 77 | } |
| 83 | 78 | |
| ... | ... | @@ -87,7 +82,7 @@ public class CommonInfo { |
| 87 | 82 | * @param context |
| 88 | 83 | */ |
| 89 | 84 | public static boolean getIsRunKeepAliveService(Context context) { |
| 90 | - return MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).getBoolean("KeepAliveService", false); | |
| 85 | + return MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).getBoolean(KEY_KEEP_ALIVE_SERVICE, false); | |
| 91 | 86 | } |
| 92 | 87 | |
| 93 | 88 | /** |
| ... | ... | @@ -96,7 +91,7 @@ public class CommonInfo { |
| 96 | 91 | * @param context |
| 97 | 92 | */ |
| 98 | 93 | public static boolean getIsRunStepService(Context context) { |
| 99 | - return MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).getBoolean("runStepService", false); | |
| 94 | + return MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).getBoolean(KEY_RUN_WRITE_USER_STEP, false); | |
| 100 | 95 | } |
| 101 | 96 | |
| 102 | 97 | /** |
| ... | ... | @@ -106,7 +101,7 @@ public class CommonInfo { |
| 106 | 101 | * @param streetId |
| 107 | 102 | */ |
| 108 | 103 | public static void setStreetId(Context context, String streetId) { |
| 109 | - MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).putString("streetId", streetId); | |
| 104 | + MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).putString(KEY_EVENT_ID, streetId); | |
| 110 | 105 | } |
| 111 | 106 | |
| 112 | 107 | /** |
| ... | ... | @@ -115,7 +110,7 @@ public class CommonInfo { |
| 115 | 110 | * @param context |
| 116 | 111 | */ |
| 117 | 112 | public static String getStreetId(Context context) { |
| 118 | - return MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).getString("streetId", ""); | |
| 113 | + return MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).getString(KEY_EVENT_ID, ""); | |
| 119 | 114 | } |
| 120 | 115 | |
| 121 | 116 | /** |
| ... | ... | @@ -125,7 +120,7 @@ public class CommonInfo { |
| 125 | 120 | * @param isRun |
| 126 | 121 | */ |
| 127 | 122 | public static void setTsRunBaiduTraceService(Context context, boolean isRun) { |
| 128 | - MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).putBoolean("RunBaiduTraceService", isRun); | |
| 123 | + MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).putBoolean(KEY_RUN_BAIDU_TRACE_SERVICE, isRun); | |
| 129 | 124 | } |
| 130 | 125 | |
| 131 | 126 | /** |
| ... | ... | @@ -134,7 +129,7 @@ public class CommonInfo { |
| 134 | 129 | * @param context |
| 135 | 130 | */ |
| 136 | 131 | public static boolean getIsRunBaiduTraceService(Context context) { |
| 137 | - return MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).getBoolean("RunBaiduTraceService", true); | |
| 132 | + return MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).getBoolean(KEY_RUN_BAIDU_TRACE_SERVICE, true); | |
| 138 | 133 | } |
| 139 | 134 | |
| 140 | 135 | /** |
| ... | ... | @@ -144,7 +139,7 @@ public class CommonInfo { |
| 144 | 139 | * @param isAllow |
| 145 | 140 | */ |
| 146 | 141 | public static void setIsFirstStepSendTraceTip(Context context, boolean isAllow) { |
| 147 | - MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).putBoolean("FirstStepSendTraceTip", isAllow); | |
| 142 | + MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).putBoolean(KEY_FIRST_STEP_SEND_TIP, isAllow); | |
| 148 | 143 | } |
| 149 | 144 | |
| 150 | 145 | /** |
| ... | ... | @@ -154,7 +149,7 @@ public class CommonInfo { |
| 154 | 149 | * @param context |
| 155 | 150 | */ |
| 156 | 151 | public static boolean getIsFirstStepSendTraceTip(Context context) { |
| 157 | - return MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).getBoolean("FirstStepSendTraceTip", true); | |
| 152 | + return MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).getBoolean(KEY_FIRST_STEP_SEND_TIP, true); | |
| 158 | 153 | } |
| 159 | 154 | |
| 160 | 155 | /** |
| ... | ... | @@ -164,7 +159,7 @@ public class CommonInfo { |
| 164 | 159 | * @param id |
| 165 | 160 | */ |
| 166 | 161 | public static void setFenceId(Context context, int id) { |
| 167 | - MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).putInt("FenceId", id); | |
| 162 | + MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).putInt(KEY_FENCE_ID, id); | |
| 168 | 163 | } |
| 169 | 164 | |
| 170 | 165 | /** |
| ... | ... | @@ -173,7 +168,7 @@ public class CommonInfo { |
| 173 | 168 | * @param context |
| 174 | 169 | */ |
| 175 | 170 | public static int getFenceId(Context context) { |
| 176 | - return MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).getInt("FenceId", -1); | |
| 171 | + return MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).getInt(KEY_FENCE_ID, -1); | |
| 177 | 172 | } |
| 178 | 173 | |
| 179 | 174 | /** |
| ... | ... | @@ -183,7 +178,7 @@ public class CommonInfo { |
| 183 | 178 | * @param nickName |
| 184 | 179 | */ |
| 185 | 180 | public static void setUserNickName(Context context, String nickName) { |
| 186 | - MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).putString("RunUserNickName", nickName); | |
| 181 | + MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).putString(KEY_USER_NICK_NAME, nickName); | |
| 187 | 182 | |
| 188 | 183 | } |
| 189 | 184 | |
| ... | ... | @@ -193,7 +188,7 @@ public class CommonInfo { |
| 193 | 188 | * @param context |
| 194 | 189 | */ |
| 195 | 190 | public static String getUserNickName(Context context) { |
| 196 | - return MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).getString("RunUserNickName", ""); | |
| 191 | + return MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).getString(KEY_USER_NICK_NAME, ""); | |
| 197 | 192 | |
| 198 | 193 | } |
| 199 | 194 | |
| ... | ... | @@ -204,7 +199,7 @@ public class CommonInfo { |
| 204 | 199 | * @param userIcon |
| 205 | 200 | */ |
| 206 | 201 | public static void setUserIcon(Context context, String userIcon) { |
| 207 | - MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).putString("RunUserNickIcon", userIcon); | |
| 202 | + MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).putString(KEY_USER_NICK_ICON, userIcon); | |
| 208 | 203 | |
| 209 | 204 | } |
| 210 | 205 | |
| ... | ... | @@ -214,7 +209,7 @@ public class CommonInfo { |
| 214 | 209 | * @param context |
| 215 | 210 | */ |
| 216 | 211 | public static String getUserIcon(Context context) { |
| 217 | - return MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).getString("RunUserNickIcon", ""); | |
| 212 | + return MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).getString(KEY_USER_NICK_ICON, ""); | |
| 218 | 213 | |
| 219 | 214 | } |
| 220 | 215 | |
| ... | ... | @@ -225,7 +220,7 @@ public class CommonInfo { |
| 225 | 220 | * @param userIcon |
| 226 | 221 | */ |
| 227 | 222 | public static void setUserPhone(Context context, String userIcon) { |
| 228 | - MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).putString("RunUserPhone", userIcon); | |
| 223 | + MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).putString(KEY_USER_PHONE, userIcon); | |
| 229 | 224 | |
| 230 | 225 | } |
| 231 | 226 | |
| ... | ... | @@ -235,7 +230,7 @@ public class CommonInfo { |
| 235 | 230 | * @param context |
| 236 | 231 | */ |
| 237 | 232 | public static String getUserPhone(Context context) { |
| 238 | - return MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).getString("RunUserPhone", ""); | |
| 233 | + return MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).getString(KEY_USER_PHONE, ""); | |
| 239 | 234 | |
| 240 | 235 | } |
| 241 | 236 | |
| ... | ... | @@ -247,7 +242,7 @@ public class CommonInfo { |
| 247 | 242 | * @param isAllow |
| 248 | 243 | */ |
| 249 | 244 | public static void setIsFirstShowTimeTip(Context context, boolean isAllow) { |
| 250 | - MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).putBoolean("IsFirstShowTimeTip", isAllow); | |
| 245 | + MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).putBoolean(KEY_IS_FIRST_SHOW_TIME_TIP, isAllow); | |
| 251 | 246 | } |
| 252 | 247 | |
| 253 | 248 | /** |
| ... | ... | @@ -256,7 +251,7 @@ public class CommonInfo { |
| 256 | 251 | * @param context |
| 257 | 252 | */ |
| 258 | 253 | public static boolean getIsFirstShowTimeTip(Context context) { |
| 259 | - return MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).getBoolean("IsFirstShowTimeTip", true); | |
| 254 | + return MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).getBoolean(KEY_IS_FIRST_SHOW_TIME_TIP, true); | |
| 260 | 255 | } |
| 261 | 256 | |
| 262 | 257 | /** |
| ... | ... | @@ -266,7 +261,7 @@ public class CommonInfo { |
| 266 | 261 | * @param isAllow |
| 267 | 262 | */ |
| 268 | 263 | public static void setIsPauseState(Context context, boolean isAllow) { |
| 269 | - MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).putBoolean("runIsPauseState", isAllow); | |
| 264 | + MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).putBoolean(KEY_IS_PAUSE_STATE, isAllow); | |
| 270 | 265 | } |
| 271 | 266 | |
| 272 | 267 | /** |
| ... | ... | @@ -275,68 +270,23 @@ public class CommonInfo { |
| 275 | 270 | * @param context |
| 276 | 271 | */ |
| 277 | 272 | public static boolean getIsPause(Context context) { |
| 278 | - return MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).getBoolean("runIsPauseState", false); | |
| 273 | + return MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).getBoolean(KEY_IS_PAUSE_STATE, false); | |
| 279 | 274 | } |
| 280 | 275 | |
| 281 | - | |
| 282 | -// /** | |
| 283 | -// * 设置赛事标题 | |
| 284 | -// * | |
| 285 | -// * @param context | |
| 286 | -// * @param streetTitle | |
| 287 | -// */ | |
| 288 | -// public static void setStreetTitle(Context context, String streetTitle) { | |
| 289 | -// MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).putString("runStreetTitle", streetTitle); | |
| 290 | -// | |
| 291 | -// } | |
| 292 | -// | |
| 293 | -// /** | |
| 294 | -// * 获取赛事标题 | |
| 295 | -// * | |
| 296 | -// * @param context | |
| 297 | -// */ | |
| 298 | -// public static String getStreetTitle(Context context) { | |
| 299 | -// return MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).getString("runStreetTitle", ""); | |
| 300 | -// | |
| 301 | -// } | |
| 302 | - | |
| 303 | - // /** | |
| 304 | -// * 设置起点经纬度 | |
| 305 | -// * | |
| 306 | -// * @param context | |
| 307 | -// * @param startLatLng | |
| 308 | -// */ | |
| 309 | -// public static void setStartLatLng(Context context, String startLatLng) { | |
| 310 | -// MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).putString("runStartLatLng", startLatLng); | |
| 311 | -// | |
| 312 | -// } | |
| 313 | -// | |
| 314 | -// /** | |
| 315 | -// * 设置终点经纬度 | |
| 316 | -// * | |
| 317 | -// * @param context | |
| 318 | -// * @param endLatLng | |
| 319 | -// */ | |
| 320 | -// public static void setEndLatLng(Context context, String endLatLng) { | |
| 321 | -// MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).putString("runEndLatLng", endLatLng); | |
| 322 | -// | |
| 323 | -// } | |
| 324 | 276 | /*重置 |
| 325 | 277 | * @param context |
| 326 | 278 | */ |
| 327 | 279 | public static void reset(Context context) { |
| 328 | 280 | |
| 329 | - MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).removeKey("IsFirstShowTimeTip"); | |
| 330 | - MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).removeKey("writeUserStep"); | |
| 331 | - MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).removeKey("runStepService"); | |
| 332 | - MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).removeKey("KeepAliveService"); | |
| 333 | - MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).removeKey("RunBaiduTraceService"); | |
| 334 | - MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).removeKey("streetId"); | |
| 335 | - MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).removeKey("FirstStepSendTraceTip"); | |
| 336 | - MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).removeKey("FenceId"); | |
| 337 | - MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).removeKey("IsFirstShowTimeTip"); | |
| 338 | - MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).removeKey("runIsPauseState"); | |
| 339 | - MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).removeKey("runStreetTitle"); | |
| 281 | + MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).removeKey(KEY_WRITE_USER_STEP); | |
| 282 | + MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).removeKey(KEY_RUN_WRITE_USER_STEP); | |
| 283 | + MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).removeKey(KEY_KEEP_ALIVE_SERVICE); | |
| 284 | + MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).removeKey(KEY_RUN_BAIDU_TRACE_SERVICE); | |
| 285 | + MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).removeKey(KEY_EVENT_ID); | |
| 286 | + MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).removeKey(KEY_FIRST_STEP_SEND_TIP); | |
| 287 | + MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).removeKey(KEY_FENCE_ID); | |
| 288 | + MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).removeKey(KEY_IS_FIRST_SHOW_TIME_TIP); | |
| 289 | + MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).removeKey(KEY_IS_PAUSE_STATE); | |
| 340 | 290 | |
| 341 | 291 | |
| 342 | 292 | } |
| ... | ... | @@ -345,14 +295,13 @@ public class CommonInfo { |
| 345 | 295 | * @param context |
| 346 | 296 | */ |
| 347 | 297 | public static void resetRace(Context context) { |
| 348 | - MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).removeKey("IsFirstShowTimeTip"); | |
| 349 | - MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).removeKey("writeUserStep"); | |
| 350 | - MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).removeKey("runStepService"); | |
| 351 | - MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).removeKey("KeepAliveService"); | |
| 352 | - MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).removeKey("RunBaiduTraceService"); | |
| 353 | - MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).removeKey("FirstStepSendTraceTip"); | |
| 354 | - MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).removeKey("IsFirstShowTimeTip"); | |
| 355 | - MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).removeKey("runIsPauseState"); | |
| 298 | + MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).removeKey(KEY_WRITE_USER_STEP); | |
| 299 | + MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).removeKey(KEY_RUN_WRITE_USER_STEP); | |
| 300 | + MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).removeKey(KEY_KEEP_ALIVE_SERVICE); | |
| 301 | + MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).removeKey(KEY_RUN_BAIDU_TRACE_SERVICE); | |
| 302 | + MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).removeKey(KEY_FIRST_STEP_SEND_TIP); | |
| 303 | + MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).removeKey(KEY_IS_FIRST_SHOW_TIME_TIP); | |
| 304 | + MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).removeKey(KEY_IS_PAUSE_STATE); | |
| 356 | 305 | |
| 357 | 306 | } |
| 358 | 307 | } | ... | ... |
| ... | ... | @@ -74,7 +74,7 @@ public class ALLScoreDetailFragmentPresenter extends MvpBasePresenter<ALLScoreDe |
| 74 | 74 | else { |
| 75 | 75 | MyMapUtil.drawHistoryTrack(context, getView().baiduMap, resultPoints, SortType.asc, R.color.red, R.drawable.icon_start, R.drawable.icon_end); |
| 76 | 76 | //设置地图自动缩放 |
| 77 | - MyMapUtil.setMapAutoZoom(getView().baiduMap, resultPoints, -2f); | |
| 77 | + MyMapUtil.setMapAutoZoom(getView().baiduMap, resultPoints, -0.8f); | |
| 78 | 78 | } |
| 79 | 79 | } |
| 80 | 80 | |
| ... | ... | @@ -97,7 +97,7 @@ public class ALLScoreDetailFragmentPresenter extends MvpBasePresenter<ALLScoreDe |
| 97 | 97 | MyMapUtil.drawHistoryTrack(context, getView().baiduMap, resultPoints, SortType.asc, R.color.red, 0, R.drawable.icon_end); |
| 98 | 98 | //设置地图自动缩放 |
| 99 | 99 | allResultList.addAll(resultPoints); |
| 100 | - MyMapUtil.setMapAutoZoom(getView().baiduMap, allResultList, -2f); | |
| 100 | + MyMapUtil.setMapAutoZoom(getView().baiduMap, allResultList, -0.8f); | |
| 101 | 101 | } |
| 102 | 102 | } |
| 103 | 103 | }); | ... | ... |
| ... | ... | @@ -55,7 +55,13 @@ public class RegistrationInfoPresenter extends MvpBasePresenter<RegistrationInfo |
| 55 | 55 | }).<BaseInfo>event().setFailureCallback(new FailureCallback() { |
| 56 | 56 | @Override |
| 57 | 57 | public void onFailure(int code, String message) { |
| 58 | - Toast.makeText(context, "报名失败", Toast.LENGTH_LONG).show(); | |
| 58 | +// if (408 == code) { | |
| 59 | +// if (getView() != null) { | |
| 60 | +// getView().toResult(); | |
| 61 | +// } | |
| 62 | +// } else { | |
| 63 | + Toast.makeText(context, "报名失败", Toast.LENGTH_LONG).show(); | |
| 64 | +// } | |
| 59 | 65 | } |
| 60 | 66 | }).setSuccessCallback(new SuccessCallback<BaseInfo>() { |
| 61 | 67 | @Override | ... | ... |
| ... | ... | @@ -7,6 +7,7 @@ import android.util.Log; |
| 7 | 7 | import android.widget.Toast; |
| 8 | 8 | |
| 9 | 9 | import com.baidu.mapapi.model.LatLng; |
| 10 | +import com.baidu.mapapi.utils.DistanceUtil; | |
| 10 | 11 | import com.baidu.trace.LBSTraceClient; |
| 11 | 12 | import com.baidu.trace.model.SortType; |
| 12 | 13 | import com.cnlive.libs.base.logic.Logic; |
| ... | ... | @@ -211,7 +212,7 @@ public class RunningFinishFragmetPresenter extends MvpBasePresenter<RunningFinis |
| 211 | 212 | //判断用户是否点击暂停按钮 |
| 212 | 213 | if (userStepEntity.getPauseCount() == 0) { |
| 213 | 214 | MyMapUtil.drawHistoryTrack(context, getView().baiduMap, resultPoints, SortType.asc, R.color.red, R.drawable.icon_start, R.drawable.icon_end); |
| 214 | - MyMapUtil.setMapAutoZoom(getView().baiduMap, resultPoints, -2f); | |
| 215 | + MyMapUtil.setMapAutoZoom(getView().baiduMap, resultPoints, -1.5f); | |
| 215 | 216 | |
| 216 | 217 | //没有点击暂停 |
| 217 | 218 | //先判断是否到达终点 |
| ... | ... | @@ -270,9 +271,41 @@ public class RunningFinishFragmetPresenter extends MvpBasePresenter<RunningFinis |
| 270 | 271 | * @param context |
| 271 | 272 | */ |
| 272 | 273 | public void checkUserIsFinish(List<LatLng> resultPoints, UserStepEntity userStepEntity, RunningFinishBean runningFinishBean, Activity context) { |
| 274 | + boolean isArrive = false; | |
| 275 | + FailedEntity failedEntity = null; | |
| 276 | + if (!TextUtils.isEmpty(runningFinishBean.getFailUUID())) { | |
| 277 | + StepUtil.getTempSaveFailByUUID(context, CommonInfo.getUserId(context), runningFinishBean.getFailUUID()); | |
| 278 | + } | |
| 273 | 279 | if (!userStepEntity.getIsArriveEndPoint()) { |
| 274 | 280 | runningFinishBean.setIsFinish("0"); |
| 281 | + isArrive = false; | |
| 282 | + if (null != failedEntity) { | |
| 283 | + failedEntity.setIsArriveEndPoint(false); | |
| 284 | + StepUtil.updateFailData(context, failedEntity); | |
| 285 | + } | |
| 286 | + //在判断一次历史轨迹 | |
| 287 | + if (null != resultPoints && resultPoints.size() > 1) { | |
| 288 | + if (!TextUtils.isEmpty(userStepEntity.getEndLatLng())) { | |
| 289 | + LatLng endLat = GsonUtil.GsonToBean(userStepEntity.getEndLatLng(), LatLng.class); | |
| 290 | + if (null != endLat) { | |
| 291 | + for (int i = 0; i < resultPoints.size(); i++) { | |
| 292 | + double distance = DistanceUtil.getDistance(endLat, resultPoints.get(i)); | |
| 293 | + if (distance < Constant.LOCA_END_POINT_ACCURACY) { | |
| 294 | + isArrive = true; | |
| 295 | + if (null != failedEntity) { | |
| 296 | + failedEntity.setIsArriveEndPoint(true); | |
| 297 | + StepUtil.updateFailData(context, failedEntity); | |
| 298 | + } | |
| 299 | + break; | |
| 300 | + } | |
| 301 | + } | |
| 302 | + } | |
| 303 | + } | |
| 304 | + } | |
| 275 | 305 | } else { |
| 306 | + isArrive = true; | |
| 307 | + } | |
| 308 | + if (isArrive) { | |
| 276 | 309 | if (importPoints != null) { |
| 277 | 310 | //判断是否完成 |
| 278 | 311 | boolean isFinish = MyMapUtil.checkIsFinishTrace(importPoints, resultPoints, Constant.PASS_RATE); |
| ... | ... | @@ -284,6 +317,11 @@ public class RunningFinishFragmetPresenter extends MvpBasePresenter<RunningFinis |
| 284 | 317 | runningFinishBean.setIsFinish("0"); |
| 285 | 318 | } |
| 286 | 319 | } |
| 320 | + } else { | |
| 321 | + runningFinishBean.setIsFinish("0"); | |
| 322 | + } | |
| 323 | + if (null != getView()) { | |
| 324 | + getView().updataIsFinish(runningFinishBean); | |
| 287 | 325 | } |
| 288 | 326 | } |
| 289 | 327 | ... | ... |
| ... | ... | @@ -72,8 +72,8 @@ public class RunningMapFragmentPresenter extends MvpBasePresenter<RunningMapFrag |
| 72 | 72 | /** |
| 73 | 73 | * 轨迹点集合 |
| 74 | 74 | */ |
| 75 | - private String imports = "[{\"latitude\":39.93395837223,\"latitudeE6\":3.993395837223E7,\"longitude\":116.30855458458,\"longitudeE6\":1.1630855458457999E8},{\"latitude\":39.93396326228,\"latitudeE6\":3.993396326228E7,\"longitude\":116.30861833018,\"longitudeE6\":1.1630861833017999E8},{\"latitude\":39.934156956749995,\"latitudeE6\":3.993415695675E7,\"longitude\":116.30869672329999,\"longitudeE6\":1.163086967233E8},{\"latitude\":39.934220163784,\"latitudeE6\":3.9934220163784E7,\"longitude\":116.3087100148,\"longitudeE6\":1.163087100148E8},{\"latitude\":39.934285263072,\"latitudeE6\":3.9934285263072E7,\"longitude\":116.30866498582,\"longitudeE6\":1.1630866498582E8},{\"latitude\":39.934351994321,\"latitudeE6\":3.9934351994320996E7,\"longitude\":116.30865820422,\"longitudeE6\":1.1630865820422E8},{\"latitude\":39.934393506188,\"latitudeE6\":3.9934393506188005E7,\"longitude\":116.3087268324,\"longitudeE6\":1.163087268324E8},{\"latitude\":39.934515310648,\"latitudeE6\":3.9934515310648E7,\"longitude\":116.30877023341,\"longitudeE6\":1.1630877023341E8},{\"latitude\":39.934576888398,\"latitudeE6\":3.9934576888398E7,\"longitude\":116.30876860572,\"longitudeE6\":1.1630876860572E8},{\"latitude\":39.934641987882,\"latitudeE6\":3.9934641987882E7,\"longitude\":116.30872520428,\"longitudeE6\":1.1630872520427999E8},{\"latitude\":39.934720386354,\"latitudeE6\":3.9934720386354E7,\"longitude\":116.30874175083,\"longitudeE6\":1.1630874175083E8},{\"latitude\":39.934703845843,\"latitudeE6\":3.9934703845843E7,\"longitude\":116.30880197017,\"longitudeE6\":1.1630880197016999E8},{\"latitude\":39.934719055573,\"latitudeE6\":3.9934719055573E7,\"longitude\":116.30896553874,\"longitudeE6\":1.1630896553874E8},{\"latitude\":39.93482461107,\"latitudeE6\":3.993482461107E7,\"longitude\":116.30924466304002,\"longitudeE6\":1.1630924466304001E8},{\"latitude\":39.934804821527,\"latitudeE6\":3.9934804821527004E7,\"longitude\":116.30935804892,\"longitudeE6\":1.1630935804892E8},{\"latitude\":39.934856643274,\"latitudeE6\":3.9934856643274E7,\"longitude\":116.30943996874,\"longitudeE6\":1.1630943996874E8},{\"latitude\":39.934844987999,\"latitudeE6\":3.9934844987999E7,\"longitude\":116.30952026112,\"longitudeE6\":1.1630952026112E8},{\"latitude\":39.934722121282,\"latitudeE6\":3.9934722121282004E7,\"longitude\":116.30967542086,\"longitudeE6\":1.1630967542086E8},{\"latitude\":39.934828721701,\"latitudeE6\":3.9934828721701E7,\"longitude\":116.30960516489,\"longitudeE6\":1.1630960516489E8},{\"latitude\":39.934408798988,\"latitudeE6\":3.9934408798988E7,\"longitude\":116.30961357453,\"longitudeE6\":1.1630961357453E8},{\"latitude\":39.934345321571,\"latitudeE6\":3.9934345321571E7,\"longitude\":116.30960842073,\"longitudeE6\":1.1630960842073E8},{\"latitude\":39.93436159016,\"latitudeE6\":3.9934361590160005E7,\"longitude\":116.30954331882,\"longitudeE6\":1.1630954331882E8},{\"latitude\":39.934295133241,\"latitudeE6\":3.9934295133241E7,\"longitude\":116.30957668364,\"longitudeE6\":1.1630957668364E8},{\"latitude\":39.934188525341,\"latitudeE6\":3.9934188525341E7,\"longitude\":116.30958183769,\"longitudeE6\":1.1630958183769001E8},{\"latitude\":39.933976660469,\"latitudeE6\":3.9933976660469E7,\"longitude\":116.30954494693,\"longitudeE6\":1.1630954494693E8},{\"latitude\":39.933993190121,\"latitudeE6\":3.9933993190121E7,\"longitude\":116.30939114375,\"longitudeE6\":1.1630939114375001E8},{\"latitude\":39.933938115564,\"latitudeE6\":3.9933938115563996E7,\"longitude\":116.30932956832,\"longitudeE6\":1.1630932956831999E8},{\"latitude\":39.933916130555,\"latitudeE6\":3.9933916130555E7,\"longitude\":116.30922269279,\"longitudeE6\":1.1630922269279E8},{\"latitude\":39.933836097011,\"latitudeE6\":3.9933836097011E7,\"longitude\":116.30914077307,\"longitudeE6\":1.1630914077307E8}]\n"; | |
| 76 | - private HashMap<Integer, Boolean> importHash; | |
| 75 | +// private String imports = "[{\"latitude\":39.93395837223,\"latitudeE6\":3.993395837223E7,\"longitude\":116.30855458458,\"longitudeE6\":1.1630855458457999E8},{\"latitude\":39.93396326228,\"latitudeE6\":3.993396326228E7,\"longitude\":116.30861833018,\"longitudeE6\":1.1630861833017999E8},{\"latitude\":39.934156956749995,\"latitudeE6\":3.993415695675E7,\"longitude\":116.30869672329999,\"longitudeE6\":1.163086967233E8},{\"latitude\":39.934220163784,\"latitudeE6\":3.9934220163784E7,\"longitude\":116.3087100148,\"longitudeE6\":1.163087100148E8},{\"latitude\":39.934285263072,\"latitudeE6\":3.9934285263072E7,\"longitude\":116.30866498582,\"longitudeE6\":1.1630866498582E8},{\"latitude\":39.934351994321,\"latitudeE6\":3.9934351994320996E7,\"longitude\":116.30865820422,\"longitudeE6\":1.1630865820422E8},{\"latitude\":39.934393506188,\"latitudeE6\":3.9934393506188005E7,\"longitude\":116.3087268324,\"longitudeE6\":1.163087268324E8},{\"latitude\":39.934515310648,\"latitudeE6\":3.9934515310648E7,\"longitude\":116.30877023341,\"longitudeE6\":1.1630877023341E8},{\"latitude\":39.934576888398,\"latitudeE6\":3.9934576888398E7,\"longitude\":116.30876860572,\"longitudeE6\":1.1630876860572E8},{\"latitude\":39.934641987882,\"latitudeE6\":3.9934641987882E7,\"longitude\":116.30872520428,\"longitudeE6\":1.1630872520427999E8},{\"latitude\":39.934720386354,\"latitudeE6\":3.9934720386354E7,\"longitude\":116.30874175083,\"longitudeE6\":1.1630874175083E8},{\"latitude\":39.934703845843,\"latitudeE6\":3.9934703845843E7,\"longitude\":116.30880197017,\"longitudeE6\":1.1630880197016999E8},{\"latitude\":39.934719055573,\"latitudeE6\":3.9934719055573E7,\"longitude\":116.30896553874,\"longitudeE6\":1.1630896553874E8},{\"latitude\":39.93482461107,\"latitudeE6\":3.993482461107E7,\"longitude\":116.30924466304002,\"longitudeE6\":1.1630924466304001E8},{\"latitude\":39.934804821527,\"latitudeE6\":3.9934804821527004E7,\"longitude\":116.30935804892,\"longitudeE6\":1.1630935804892E8},{\"latitude\":39.934856643274,\"latitudeE6\":3.9934856643274E7,\"longitude\":116.30943996874,\"longitudeE6\":1.1630943996874E8},{\"latitude\":39.934844987999,\"latitudeE6\":3.9934844987999E7,\"longitude\":116.30952026112,\"longitudeE6\":1.1630952026112E8},{\"latitude\":39.934722121282,\"latitudeE6\":3.9934722121282004E7,\"longitude\":116.30967542086,\"longitudeE6\":1.1630967542086E8},{\"latitude\":39.934828721701,\"latitudeE6\":3.9934828721701E7,\"longitude\":116.30960516489,\"longitudeE6\":1.1630960516489E8},{\"latitude\":39.934408798988,\"latitudeE6\":3.9934408798988E7,\"longitude\":116.30961357453,\"longitudeE6\":1.1630961357453E8},{\"latitude\":39.934345321571,\"latitudeE6\":3.9934345321571E7,\"longitude\":116.30960842073,\"longitudeE6\":1.1630960842073E8},{\"latitude\":39.93436159016,\"latitudeE6\":3.9934361590160005E7,\"longitude\":116.30954331882,\"longitudeE6\":1.1630954331882E8},{\"latitude\":39.934295133241,\"latitudeE6\":3.9934295133241E7,\"longitude\":116.30957668364,\"longitudeE6\":1.1630957668364E8},{\"latitude\":39.934188525341,\"latitudeE6\":3.9934188525341E7,\"longitude\":116.30958183769,\"longitudeE6\":1.1630958183769001E8},{\"latitude\":39.933976660469,\"latitudeE6\":3.9933976660469E7,\"longitude\":116.30954494693,\"longitudeE6\":1.1630954494693E8},{\"latitude\":39.933993190121,\"latitudeE6\":3.9933993190121E7,\"longitude\":116.30939114375,\"longitudeE6\":1.1630939114375001E8},{\"latitude\":39.933938115564,\"latitudeE6\":3.9933938115563996E7,\"longitude\":116.30932956832,\"longitudeE6\":1.1630932956831999E8},{\"latitude\":39.933916130555,\"latitudeE6\":3.9933916130555E7,\"longitude\":116.30922269279,\"longitudeE6\":1.1630922269279E8},{\"latitude\":39.933836097011,\"latitudeE6\":3.9933836097011E7,\"longitude\":116.30914077307,\"longitudeE6\":1.1630914077307E8}]\n"; | |
| 76 | + private List<LatLng> importPoints; | |
| 77 | 77 | |
| 78 | 78 | /** |
| 79 | 79 | * 查询运营人员踩得轨迹 |
| ... | ... | @@ -319,7 +319,10 @@ public class RunningMapFragmentPresenter extends MvpBasePresenter<RunningMapFrag |
| 319 | 319 | //获取当前的实体名称 |
| 320 | 320 | String entityName = CommonInfo.getUserId(context); |
| 321 | 321 | //打的重要点 |
| 322 | - List<LatLng> importPoints = GsonUtil.jsonToList(imports, LatLng.class); | |
| 322 | + importPoints = null; | |
| 323 | + if (!TextUtils.isEmpty(userStepEntity.getImportPoint())) { | |
| 324 | + importPoints = GsonUtil.jsonToList(userStepEntity.getImportPoint(), LatLng.class); | |
| 325 | + } | |
| 323 | 326 | MyMapUtil.queryHistoryTrace(context, StepService.mClient, entityName, startTime, endTime, new MyMapUtil.CallBack() { |
| 324 | 327 | @Override |
| 325 | 328 | public void success(List<LatLng> resultPoints) { |
| ... | ... | @@ -371,7 +374,7 @@ public class RunningMapFragmentPresenter extends MvpBasePresenter<RunningMapFrag |
| 371 | 374 | } |
| 372 | 375 | } |
| 373 | 376 | //开始划线 |
| 374 | - MyMapUtil.drawHistoryTrack(context, getView().baiduMap, resultPoints, SortType.asc, R.color.red, 0, R.drawable.icon_end); | |
| 377 | + MyMapUtil.drawHistoryTrack(context, getView().baiduMap, resultPoints, SortType.asc, R.color.red, 0, R.drawable.icon_end); | |
| 375 | 378 | |
| 376 | 379 | } |
| 377 | 380 | } | ... | ... |
| ... | ... | @@ -16,6 +16,7 @@ import com.cnlive.libs.base.logic.callback.SuccessCallback; |
| 16 | 16 | import com.cnlive.moudle.pedometer.commonInfo.CommonInfo; |
| 17 | 17 | import com.cnlive.moudle.pedometer.frame.view.UploadFailDetailFragmentView; |
| 18 | 18 | import com.cnlive.moudle.pedometer.model.Constant; |
| 19 | +import com.cnlive.moudle.pedometer.model.MessageEvent; | |
| 19 | 20 | import com.cnlive.moudle.pedometer.model.RunningFinishBean; |
| 20 | 21 | import com.cnlive.moudle.pedometer.net.ApiServiceRunLin; |
| 21 | 22 | import com.cnlive.moudle.pedometer.net.SubscriptionRequest; |
| ... | ... | @@ -31,6 +32,8 @@ import com.cnlive.moudle.pedometer.utils.StepUtil; |
| 31 | 32 | import com.example.moudle_pedometer.R; |
| 32 | 33 | import com.hannesdorfmann.mosby3.mvp.MvpBasePresenter; |
| 33 | 34 | |
| 35 | +import org.greenrobot.eventbus.EventBus; | |
| 36 | + | |
| 34 | 37 | import java.util.HashMap; |
| 35 | 38 | import java.util.List; |
| 36 | 39 | import java.util.Map; |
| ... | ... | @@ -90,7 +93,7 @@ public class UploadFailDetailFragmentPresenter extends MvpBasePresenter<UploadFa |
| 90 | 93 | if (!failedEntity.getIsPause()) { |
| 91 | 94 | MyMapUtil.drawHistoryTrack(context, getView().baiduMap, resultPoints, SortType.asc, R.color.red, R.drawable.icon_start, R.drawable.icon_end); |
| 92 | 95 | //设置地图自动缩放 |
| 93 | - MyMapUtil.setMapAutoZoom(getView().baiduMap, resultPoints, -2f); | |
| 96 | + MyMapUtil.setMapAutoZoom(getView().baiduMap, resultPoints, -0.8f); | |
| 94 | 97 | } else { |
| 95 | 98 | MyMapUtil.drawHistoryTrack(context, getView().baiduMap, resultPoints, SortType.asc, R.color.red, R.drawable.icon_start, 0); |
| 96 | 99 | |
| ... | ... | @@ -144,7 +147,7 @@ public class UploadFailDetailFragmentPresenter extends MvpBasePresenter<UploadFa |
| 144 | 147 | allResultPoints.addAll(resultPoints); |
| 145 | 148 | } |
| 146 | 149 | //设置地图自动缩放 |
| 147 | - MyMapUtil.setMapAutoZoom(getView().baiduMap, allResultPoints, -2f); | |
| 150 | + MyMapUtil.setMapAutoZoom(getView().baiduMap, allResultPoints, -0.8f); | |
| 148 | 151 | //判断用户是否完成 |
| 149 | 152 | if (!failedEntity.getIsArriveEndPoint()) { |
| 150 | 153 | //没有完成 |
| ... | ... | @@ -329,6 +332,8 @@ public class UploadFailDetailFragmentPresenter extends MvpBasePresenter<UploadFa |
| 329 | 332 | if (getView() == null) { |
| 330 | 333 | return; |
| 331 | 334 | } |
| 335 | + //更新我的记录列表 | |
| 336 | + EventBus.getDefault().post(new MessageEvent(Constant.UPDATE_MYSELF_RECORD_LIST, "")); | |
| 332 | 337 | QMUITipDialogUtil.dismessDialog(); |
| 333 | 338 | QMUITipDialogUtil.successDialog(context, "上传成功", 1); |
| 334 | 339 | //删除暂存数据 | ... | ... |
| ... | ... | @@ -89,7 +89,7 @@ public class ALLScoreDetailFragmentView implements MvpView { |
| 89 | 89 | }); |
| 90 | 90 | } |
| 91 | 91 | |
| 92 | - public void initMap() { | |
| 92 | + public void initMap(MapCallBack mapCallBack) { | |
| 93 | 93 | this.mMapView = fragment.binding.mapView; |
| 94 | 94 | if (baiduMap == null) { |
| 95 | 95 | baiduMap = mMapView.getMap(); |
| ... | ... | @@ -104,5 +104,17 @@ public class ALLScoreDetailFragmentView implements MvpView { |
| 104 | 104 | mUiSettings.setEnlargeCenterWithDoubleClickEnable(true); |
| 105 | 105 | //隐藏自带的指南针,改用自定义指南针 杨帅 |
| 106 | 106 | mUiSettings.setCompassEnabled(false); |
| 107 | + baiduMap.setOnMapLoadedCallback(new BaiduMap.OnMapLoadedCallback() { | |
| 108 | + @Override | |
| 109 | + public void onMapLoaded() { | |
| 110 | + if (null != mapCallBack) { | |
| 111 | + mapCallBack.onMapLoadFinish(); | |
| 112 | + } | |
| 113 | + } | |
| 114 | + }); | |
| 115 | + } | |
| 116 | + | |
| 117 | + public interface MapCallBack { | |
| 118 | + void onMapLoadFinish(); | |
| 107 | 119 | } |
| 108 | 120 | } | ... | ... |
| ... | ... | @@ -5,16 +5,21 @@ import android.view.View; |
| 5 | 5 | |
| 6 | 6 | import com.cnlive.moudle.pedometer.commonInfo.CommonInfo; |
| 7 | 7 | import com.cnlive.moudle.pedometer.frame.presenter.LineUpAgainPresenter; |
| 8 | +import com.cnlive.moudle.pedometer.model.Constant; | |
| 9 | +import com.cnlive.moudle.pedometer.model.MessageEvent; | |
| 8 | 10 | import com.cnlive.moudle.pedometer.sql.entity.FailedEntity; |
| 9 | 11 | import com.cnlive.moudle.pedometer.ui.activity.UploadFailDetailActivity; |
| 10 | 12 | import com.cnlive.moudle.pedometer.ui.adapter.LineUpAgainAdapter; |
| 11 | 13 | import com.cnlive.moudle.pedometer.ui.fragment.LineUpAgainFragment; |
| 14 | +import com.cnlive.moudle.pedometer.ui.widget.SelectDialog; | |
| 12 | 15 | import com.cnlive.moudle.pedometer.utils.StepUtil; |
| 13 | 16 | import com.example.moudle_pedometer.R; |
| 14 | 17 | import com.hannesdorfmann.mosby3.mvp.MvpView; |
| 15 | 18 | import com.scwang.smartrefresh.layout.footer.ClassicsFooter; |
| 16 | 19 | import com.scwang.smartrefresh.layout.header.ClassicsHeader; |
| 17 | 20 | |
| 21 | +import org.greenrobot.eventbus.EventBus; | |
| 22 | + | |
| 18 | 23 | import java.util.ArrayList; |
| 19 | 24 | import java.util.List; |
| 20 | 25 | |
| ... | ... | @@ -51,6 +56,39 @@ public class LineUpAgainView implements MvpView { |
| 51 | 56 | UploadFailDetailActivity.startActivity(fragment.getActivity(), bean); |
| 52 | 57 | } |
| 53 | 58 | }); |
| 59 | + //设置点击删除按钮点击事件 | |
| 60 | + againAdapter.setOnDeleteClickListener(new LineUpAgainAdapter.OnDeleteClickListener() { | |
| 61 | + @Override | |
| 62 | + public void onDeleteClickListener(int position) { | |
| 63 | + SelectDialog selectDialog = new SelectDialog(fragment.getActivity(), "确认删除该条记录?", "取消", new SelectDialog.DialogInterface() { | |
| 64 | + @Override | |
| 65 | + public void onClick(SelectDialog dialog) { | |
| 66 | + dialog.dismiss(); | |
| 67 | + } | |
| 68 | + }, "删除", new SelectDialog.DialogInterface() { | |
| 69 | + @Override | |
| 70 | + public void onClick(SelectDialog dialog) { | |
| 71 | + dialog.dismiss(); | |
| 72 | + if (null != failedEntities && null != failedEntities.get(position) && null != againAdapter) { | |
| 73 | + StepUtil.deleteTempSaveFailData(fragment.getActivity(), failedEntities.get(position)); | |
| 74 | + //先删除数据库,再更新列表 | |
| 75 | + againAdapter.updateDeleteList(position); | |
| 76 | + } | |
| 77 | + if (null != againAdapter) { | |
| 78 | + if (againAdapter.getListSize() < 1) { | |
| 79 | + if (null == fragment.getActivity()) { | |
| 80 | + return; | |
| 81 | + } | |
| 82 | + fragment.binding.llNoFailTip.setVisibility(View.VISIBLE); | |
| 83 | + } | |
| 84 | + } | |
| 85 | + } | |
| 86 | + }); | |
| 87 | + selectDialog.setCancelable(false); | |
| 88 | + selectDialog.setCanceledOnTouchOutside(false); | |
| 89 | + selectDialog.show(); | |
| 90 | + } | |
| 91 | + }); | |
| 54 | 92 | //设置重新上传按钮点击事件 |
| 55 | 93 | againAdapter.setOnRestartUploadClickListener(new LineUpAgainAdapter.OnRestartUploadClickListener() { |
| 56 | 94 | @Override |
| ... | ... | @@ -61,6 +99,8 @@ public class LineUpAgainView implements MvpView { |
| 61 | 99 | fragment.getPresenter().queryHistoryTraceNoMap(fragment.getActivity(), failedEntity, new LineUpAgainPresenter.onResultListener() { |
| 62 | 100 | @Override |
| 63 | 101 | public void onSuccess() { |
| 102 | + //更新我的记录列表 | |
| 103 | + EventBus.getDefault().post(new MessageEvent(Constant.UPDATE_MYSELF_RECORD_LIST, "")); | |
| 64 | 104 | //刷新列表 |
| 65 | 105 | List<FailedEntity> failedEntities = StepUtil.getFailListData(fragment.getActivity(), CommonInfo.getUserId(fragment.getActivity())); |
| 66 | 106 | if (failedEntities == null || failedEntities.size() < 1) { | ... | ... |
| ... | ... | @@ -23,6 +23,7 @@ import com.baidu.mapapi.search.route.RoutePlanSearch; |
| 23 | 23 | import com.baidu.mapapi.utils.DistanceUtil; |
| 24 | 24 | import com.baidu.trace.LBSTraceClient; |
| 25 | 25 | import com.baidu.trace.model.SortType; |
| 26 | +import com.cnlive.libs.base.application.AppConfig; | |
| 26 | 27 | import com.cnlive.libs.base.util.StatusBarUtil2; |
| 27 | 28 | import com.cnlive.moudle.pedometer.commonInfo.CommonInfo; |
| 28 | 29 | import com.cnlive.moudle.pedometer.model.Constant; |
| ... | ... | @@ -363,9 +364,10 @@ public class OnGoingFragmentView implements MvpView { |
| 363 | 364 | fragment.binding.includeRank.tvCatAllRank.setOnClickListener(new View.OnClickListener() { |
| 364 | 365 | @Override |
| 365 | 366 | public void onClick(View view) { |
| 367 | + String baseWebUrl = AppConfig.isDebug() ? "http://wjjh5test.cnlive.com/cnSportListOver.html" : "http://wjjh5.cnlive.com/cnSportListOver.html"; | |
| 366 | 368 | ARouter.getInstance().build("/web/WebViewColorActivity") |
| 367 | - .withString("url", "http://wjjh5test.cnlive.com/cnSportList.html" + "?sid=" + CommonInfo.getUserId(fragment.getActivity()) + "&eventId=" + CommonInfo.getStreetId(fragment.getActivity())) | |
| 368 | - .withString("title", "排行榜") | |
| 369 | + .withString("url", baseWebUrl + "?sid=" + CommonInfo.getUserId(fragment.getActivity()) + "&eventId=" + fragment.eventId) | |
| 370 | + .withString("title", "总排行榜") | |
| 369 | 371 | .navigation(fragment.getActivity()); |
| 370 | 372 | } |
| 371 | 373 | }); | ... | ... |
| 1 | 1 | package com.cnlive.moudle.pedometer.frame.view; |
| 2 | 2 | |
| 3 | 3 | import android.app.Activity; |
| 4 | +import android.app.Service; | |
| 4 | 5 | import android.content.Context; |
| 5 | 6 | import android.content.Intent; |
| 6 | 7 | import android.os.Handler; |
| 7 | 8 | import android.os.SystemClock; |
| 9 | +import android.os.Vibrator; | |
| 8 | 10 | import android.support.v4.content.ContextCompat; |
| 9 | 11 | import android.text.TextUtils; |
| 10 | 12 | import android.util.Log; |
| ... | ... | @@ -39,6 +41,7 @@ import com.cnlive.moudle.pedometer.ui.fragment.RunMainFragment; |
| 39 | 41 | import com.cnlive.moudle.pedometer.ui.widget.SelectDialog; |
| 40 | 42 | import com.cnlive.moudle.pedometer.ui.widget.TipDialog; |
| 41 | 43 | import com.cnlive.moudle.pedometer.utils.ButtonAnimUtil; |
| 44 | +import com.cnlive.moudle.pedometer.utils.ChineseToSpeechUtil; | |
| 42 | 45 | import com.cnlive.moudle.pedometer.utils.GsonUtil; |
| 43 | 46 | import com.cnlive.moudle.pedometer.utils.MyMapUtil; |
| 44 | 47 | import com.cnlive.moudle.pedometer.utils.MySpHelper; |
| ... | ... | @@ -72,6 +75,9 @@ public class RunMainFragmentView implements MvpView { |
| 72 | 75 | private String employTime = ""; |
| 73 | 76 | private LatLng endLatLng;//终点坐标 |
| 74 | 77 | private TipDialog tipDialog; |
| 78 | + //创建震动服务对象 | |
| 79 | + private Vibrator mVibrator; | |
| 80 | + private boolean isfirstEndTip = true; | |
| 75 | 81 | |
| 76 | 82 | public RunMainFragmentView(RunMainFragment fragment) { |
| 77 | 83 | this.fragment = fragment; |
| ... | ... | @@ -125,31 +131,45 @@ public class RunMainFragmentView implements MvpView { |
| 125 | 131 | * 初始化相关视图 |
| 126 | 132 | */ |
| 127 | 133 | public void initView(RunRaceDetailInfo runRaceDetailInfo) { |
| 134 | + //获取手机震动服务 | |
| 135 | + mVibrator = (Vibrator) getContext().getSystemService(Service.VIBRATOR_SERVICE); | |
| 128 | 136 | uid = CommonInfo.getUserId(getContext()); |
| 129 | 137 | userStepEntity = StepUtil.getUserStepData(getContext(), uid); |
| 130 | 138 | //设置数据 |
| 131 | 139 | if (userStepEntity != null) { |
| 132 | 140 | //设置赛事标题 |
| 133 | - if (TextUtils.isEmpty(userStepEntity.getStreetTitle())) { | |
| 134 | - StepUtil.setStreetTitle(getContext(), CommonInfo.getUserId(getContext()), runRaceDetailInfo.getTitle()); | |
| 141 | + if (TextUtils.isEmpty(userStepEntity.getStreetTitle()) || null == userStepEntity.getStreetTitle()) { | |
| 142 | + userStepEntity = StepUtil.getUserStepData(getContext(), uid); | |
| 143 | + if (null != userStepEntity) { | |
| 144 | + StepUtil.setStreetTitle(getContext(), CommonInfo.getUserId(getContext()), runRaceDetailInfo.getTitle()); | |
| 145 | + } | |
| 135 | 146 | } |
| 136 | 147 | //设置实体名字 |
| 137 | - if (TextUtils.isEmpty(userStepEntity.getQueryEntityName())) { | |
| 148 | + if (TextUtils.isEmpty(userStepEntity.getQueryEntityName()) || null == userStepEntity.getQueryEntityName()) { | |
| 138 | 149 | long startTime = Long.parseLong(runRaceDetailInfo.getStartTime()); |
| 139 | 150 | long endTime = Long.parseLong(runRaceDetailInfo.getEndTime()); |
| 140 | - StepUtil.setQueryTraceTime(getContext(), CommonInfo.getUserId(getContext()), startTime, endTime, runRaceDetailInfo.getEntityName()); | |
| 151 | + userStepEntity = StepUtil.getUserStepData(getContext(), uid); | |
| 152 | + if (null != userStepEntity) { | |
| 153 | + StepUtil.setQueryTraceTime(getContext(), CommonInfo.getUserId(getContext()), startTime, endTime, runRaceDetailInfo.getEntityName()); | |
| 154 | + } | |
| 141 | 155 | } |
| 142 | 156 | //设置开始时间和赛事id |
| 143 | - if (TextUtils.isEmpty(userStepEntity.getStreetId())) { | |
| 144 | - StepUtil.setStepStartData(getContext(), uid, TimeUtil.getNowTimeStamp(), CommonInfo.getStreetId(getContext())); | |
| 157 | + if (TextUtils.isEmpty(userStepEntity.getStreetId()) || null == userStepEntity.getStreetId()) { | |
| 158 | + userStepEntity = StepUtil.getUserStepData(getContext(), uid); | |
| 159 | + if (null != userStepEntity) { | |
| 160 | + StepUtil.setStepStartData(getContext(), uid, TimeUtil.getNowTimeStamp(), CommonInfo.getStreetId(getContext())); | |
| 161 | + } | |
| 145 | 162 | } |
| 146 | 163 | //设置终点经纬度 |
| 147 | - if (TextUtils.isEmpty(userStepEntity.getEndLatLng())) { | |
| 164 | + if (TextUtils.isEmpty(userStepEntity.getEndLatLng()) || null == userStepEntity.getEndLatLng()) { | |
| 148 | 165 | if (null != runRaceDetailInfo.getEndLatLng()) { |
| 149 | - //设置终点坐标 | |
| 150 | - userStepEntity.setEndLatLng(runRaceDetailInfo.getEndLatLng()); | |
| 151 | - //更新数据 | |
| 152 | - StepUtil.updateStepData(getContext(), userStepEntity); | |
| 166 | + userStepEntity = StepUtil.getUserStepData(getContext(), uid); | |
| 167 | + if (null != userStepEntity) { | |
| 168 | + //设置终点坐标 | |
| 169 | + userStepEntity.setEndLatLng(runRaceDetailInfo.getEndLatLng()); | |
| 170 | + //更新数据 | |
| 171 | + StepUtil.updateStepData(getContext(), userStepEntity); | |
| 172 | + } | |
| 153 | 173 | } |
| 154 | 174 | } |
| 155 | 175 | //设置终点经纬度 |
| ... | ... | @@ -157,7 +177,7 @@ public class RunMainFragmentView implements MvpView { |
| 157 | 177 | endLatLng = GsonUtil.GsonToBean(userStepEntity.getEndLatLng(), LatLng.class); |
| 158 | 178 | } |
| 159 | 179 | //设置步数 |
| 160 | - if (!TextUtils.isEmpty(userStepEntity.getStepCount())){ | |
| 180 | + if (!TextUtils.isEmpty(userStepEntity.getStepCount())) { | |
| 161 | 181 | //设置行走步数 |
| 162 | 182 | fragment.binding.tvStepCount.setText(userStepEntity.getStepCount()); |
| 163 | 183 | //设置行走公里 |
| ... | ... | @@ -413,13 +433,17 @@ public class RunMainFragmentView implements MvpView { |
| 413 | 433 | runningFinishBean.setStreetTitle(userStepEntity.getStreetTitle()); |
| 414 | 434 | //设置用时 |
| 415 | 435 | runningFinishBean.setEmployTime(employTime); |
| 416 | - | |
| 436 | + //刷新一遍数据 | |
| 437 | + userStepEntity = StepUtil.getUserStepData(getContext(), uid); | |
| 417 | 438 | //先将失败数据保存起来 |
| 418 | 439 | if (runningFinishBean != null && userStepEntity != null) { |
| 419 | 440 | setFailData(getContext(), userStepEntity, runningFinishBean); |
| 420 | 441 | } |
| 421 | 442 | FailedEntity failedEntity = StepUtil.getTempSaveFailData(getContext(), CommonInfo.getUserId(getContext()), userStepEntity.getStartTimeStamp()); |
| 422 | 443 | if (failedEntity != null) { |
| 444 | + if (null != failedEntity.getUuid()) { | |
| 445 | + runningFinishBean.setFailUUID(failedEntity.getUuid()); | |
| 446 | + } | |
| 423 | 447 | RunningFinishActivity.startActivity(fragment.getActivity(), runningFinishBean); |
| 424 | 448 | fragment.getActivity().finish(); |
| 425 | 449 | } |
| ... | ... | @@ -539,6 +563,7 @@ public class RunMainFragmentView implements MvpView { |
| 539 | 563 | if (getContext() == null) { |
| 540 | 564 | return; |
| 541 | 565 | } |
| 566 | + | |
| 542 | 567 | fragment.getActivity().finish(); |
| 543 | 568 | } |
| 544 | 569 | }); |
| ... | ... | @@ -770,8 +795,20 @@ public class RunMainFragmentView implements MvpView { |
| 770 | 795 | //更新数据 |
| 771 | 796 | StepUtil.updateStepData(getContext(), userStepEntity); |
| 772 | 797 | } |
| 798 | + if (!isfirstEndTip) { | |
| 799 | + return; | |
| 800 | + } | |
| 801 | + if (isfirstEndTip) { | |
| 802 | + isfirstEndTip = false; | |
| 803 | + } | |
| 773 | 804 | //进行提示 |
| 774 | 805 | if (null == tipDialog) { |
| 806 | + ChineseToSpeechUtil.speech(getContext(), "您已到达终点附近,可以结束运动了!"); | |
| 807 | + if (mVibrator != null) { | |
| 808 | + //设置震动周期,数组表示时间:等待+执行,单位是毫秒,下面操作代表:等待100,执行100,等待100,执行1000, | |
| 809 | + //后面的数字如果为-1代表不重复,之执行一次,其他代表会重复,0代表从数组的第0个位置开始 | |
| 810 | + mVibrator.vibrate(new long[]{Constant.VIBRATOR_DELAY_TIME, Constant.VIBRATOR_RUN_TIME, Constant.VIBRATOR_DELAY_TIME, Constant.VIBRATOR_RUN_TIME}, Constant.VIBRATOR_REPEAT_TIME); | |
| 811 | + } | |
| 775 | 812 | tipDialog = new TipDialog(getContext(), getContext().getResources().getString(R.string.run_race_arrive_end_tip), "好的", R.color.green_round, new TipDialog.DialogInterface() { |
| 776 | 813 | @Override |
| 777 | 814 | public void onClick(TipDialog dialog) { |
| ... | ... | @@ -800,6 +837,7 @@ public class RunMainFragmentView implements MvpView { |
| 800 | 837 | CommonInfo.setIsWriteUserStep(getContext(), false); |
| 801 | 838 | if (StepService.mClient != null) { |
| 802 | 839 | StepService.mClient.stopGather(StepService.traceListener); |
| 840 | +// StepService.CURRENT_STEP = 0; | |
| 803 | 841 | } |
| 804 | 842 | fragment.getActivity().stopService(new Intent(fragment.getActivity(), StepService.class)); |
| 805 | 843 | } |
| ... | ... | @@ -810,6 +848,11 @@ public class RunMainFragmentView implements MvpView { |
| 810 | 848 | } |
| 811 | 849 | } |
| 812 | 850 | |
| 851 | + public void onResume() { | |
| 852 | + //保持最新的步数 | |
| 853 | + EventBus.getDefault().post(new MessageEvent(Constant.SERVICE_STEP_COUNT_ONRESUME, "")); | |
| 854 | + } | |
| 855 | + | |
| 813 | 856 | /** |
| 814 | 857 | * 暂存失败数据 |
| 815 | 858 | * |
| ... | ... | @@ -885,6 +928,10 @@ public class RunMainFragmentView implements MvpView { |
| 885 | 928 | StepUtil.setFailData(context, failedEntity); |
| 886 | 929 | |
| 887 | 930 | } |
| 931 | + | |
| 932 | + public void onStop() { | |
| 933 | + ChineseToSpeechUtil.destroy(); | |
| 934 | + } | |
| 888 | 935 | } |
| 889 | 936 | |
| 890 | 937 | ... | ... |
| ... | ... | @@ -111,6 +111,7 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener { |
| 111 | 111 | private final float INIT_MAP_OVERLOOK = -40f;//地图倾斜角度 |
| 112 | 112 | private final float DEFAULT_MAP_AUTO_ZOOM = -0.8f;//根据点位,自动缩放的比例 |
| 113 | 113 | private List<LatLng> queryResultPoints;//查询到的历史轨迹 |
| 114 | + private List<String> joinFaceIcon;//参与活动人数 | |
| 114 | 115 | |
| 115 | 116 | public RunRaceDetailFragmentView(RunRaceDetailFragment fragment) { |
| 116 | 117 | this.fragment = fragment; |
| ... | ... | @@ -183,15 +184,15 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener { |
| 183 | 184 | StatusBarUtil2.setColor(fragment.getActivity(), getContext().getResources().getColor(R.color.run_main_bg), 0); |
| 184 | 185 | |
| 185 | 186 | } |
| 186 | - } else { | |
| 187 | + } else if (slideOffset!=0){ | |
| 187 | 188 | if (fragment.binding.flTop.getVisibility() == View.VISIBLE) { |
| 188 | 189 | QMUIStatusBarHelper.setStatusBarLightMode(fragment.getActivity()); |
| 189 | 190 | StatusBarUtil2.setColor(fragment.getActivity(), getContext().getResources().getColor(R.color.white), 0); |
| 190 | - fragment.binding.flTop.setVisibility(View.GONE); | |
| 191 | + fragment.binding.flTop.setVisibility(View.INVISIBLE); | |
| 191 | 192 | } |
| 192 | 193 | } |
| 193 | 194 | //设置卡片缩放特效 |
| 194 | - if (slideOffset >= 0 && slideOffset <= 1) { | |
| 195 | + if (slideOffset >= 0 && slideOffset <= 0.6) { | |
| 195 | 196 | int leakWidth = (int) (ScreenUtil.dip2px(getContext(), 15) / 0.6); |
| 196 | 197 | LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); |
| 197 | 198 | int current = (int) (leakWidth * slideOffset); |
| ... | ... | @@ -245,14 +246,14 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener { |
| 245 | 246 | } else if (previousState == SlidingUpPanelLayout.PanelState.EXPANDED && newState == SlidingUpPanelLayout.PanelState.DRAGGING) { |
| 246 | 247 | QMUIStatusBarHelper.setStatusBarLightMode(fragment.getActivity()); |
| 247 | 248 | StatusBarUtil2.setColor(fragment.getActivity(), getContext().getResources().getColor(R.color.white), 0); |
| 248 | - if (fragment.binding.flTop.getVisibility() != View.GONE) { | |
| 249 | - fragment.binding.flTop.setVisibility(View.GONE); | |
| 249 | + if (fragment.binding.flTop.getVisibility() != View.INVISIBLE) { | |
| 250 | + fragment.binding.flTop.setVisibility(View.INVISIBLE); | |
| 250 | 251 | } |
| 251 | 252 | } else if (previousState == SlidingUpPanelLayout.PanelState.DRAGGING && newState == SlidingUpPanelLayout.PanelState.ANCHORED) { |
| 252 | 253 | QMUIStatusBarHelper.setStatusBarLightMode(fragment.getActivity()); |
| 253 | 254 | StatusBarUtil2.setColor(fragment.getActivity(), getContext().getResources().getColor(R.color.white), 0); |
| 254 | - if (fragment.binding.flTop.getVisibility() != View.GONE) { | |
| 255 | - fragment.binding.flTop.setVisibility(View.GONE); | |
| 255 | + if (fragment.binding.flTop.getVisibility() != View.INVISIBLE) { | |
| 256 | + fragment.binding.flTop.setVisibility(View.INVISIBLE); | |
| 256 | 257 | } |
| 257 | 258 | } |
| 258 | 259 | //设置地图缩放 |
| ... | ... | @@ -376,7 +377,7 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener { |
| 376 | 377 | //设置参加人数 |
| 377 | 378 | fragment.binding.includeStreet.tvSignPerson.setText(runRaceDetailInfo.getSignupNum() + ""); |
| 378 | 379 | //设置报名完成的头像 |
| 379 | - List<String> joinFaceIcon = runRaceDetailInfo.getFaceUrl(); | |
| 380 | + joinFaceIcon = runRaceDetailInfo.getFaceUrl(); | |
| 380 | 381 | if (joinFaceIcon != null && joinFaceIcon.size() > 0) { |
| 381 | 382 | fragment.binding.includeStreet.fiveJoinPerson.setVisibility(View.VISIBLE); |
| 382 | 383 | //设置头像数据 |
| ... | ... | @@ -544,7 +545,7 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener { |
| 544 | 545 | } |
| 545 | 546 | |
| 546 | 547 | } else { |
| 547 | - QMUITipDialogUtil.textDialog(getContext(), "正在获取轨迹请稍后...", 1); | |
| 548 | + QMUITipDialogUtil.textDialog(getContext(), "正在获取赛事,请稍后...", 1); | |
| 548 | 549 | } |
| 549 | 550 | } |
| 550 | 551 | //继续运动 |
| ... | ... | @@ -640,6 +641,10 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener { |
| 640 | 641 | } |
| 641 | 642 | |
| 642 | 643 | private void checkBaiduServiceState() { |
| 644 | + CommonInfo.setIsRunKeepAliveService(getContext(), true); | |
| 645 | + CommonInfo.setIsRunStepService(getContext(), true); | |
| 646 | + CommonInfo.setTsRunBaiduTraceService(getContext(), true); | |
| 647 | + CommonInfo.setIsWriteUserStep(getContext(), true); | |
| 643 | 648 | boolean isRunBaidu = CommonInfo.getIsRunBaiduTraceService(getContext()); |
| 644 | 649 | if (isRunBaidu) { |
| 645 | 650 | //判断百度服务是否运行 |
| ... | ... | @@ -1010,7 +1015,7 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener { |
| 1010 | 1015 | //获取用户暂停的时间戳 |
| 1011 | 1016 | long userPauseTime = userStepEntity.getChronometerBase(); |
| 1012 | 1017 | //判断时间是否小于9小时 |
| 1013 | - Log.e(TAG, "checkStartBtnState: " + currnetTime + ",userPauseTime:" + userPauseTime); | |
| 1018 | +// Log.e(TAG, "checkStartBtnState: " + currnetTime + ",userPauseTime:" + userPauseTime); | |
| 1014 | 1019 | if ((currnetTime - userPauseTime) <= (9 * 60 * 60 * 1000)) { |
| 1015 | 1020 | Log.e(TAG, "小于9小时"); |
| 1016 | 1021 | fragment.binding.tvRunNow.setText("继续运动"); |
| ... | ... | @@ -1258,6 +1263,49 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener { |
| 1258 | 1263 | if (getContext() == null) { |
| 1259 | 1264 | return; |
| 1260 | 1265 | } |
| 1266 | + //更新用户头像 | |
| 1267 | + if (null != joinFaceIcon) { | |
| 1268 | + //获取用户头像 | |
| 1269 | + if (TextUtils.isEmpty(CommonInfo.getUserIcon(getContext()))) { | |
| 1270 | + //添加默认头像 | |
| 1271 | + joinFaceIcon.add(0, "http://wjj.ys1.cnliveimg.com/769/img/2018/0416/head_c.png"); | |
| 1272 | + } else { | |
| 1273 | + //添加用户本身头像 | |
| 1274 | + joinFaceIcon.add(0, CommonInfo.getUserIcon(getContext())); | |
| 1275 | + | |
| 1276 | + } | |
| 1277 | + } | |
| 1278 | + //没有一个用户头像 | |
| 1279 | + else { | |
| 1280 | + joinFaceIcon = new ArrayList<>(); | |
| 1281 | + //获取用户头像 | |
| 1282 | + if (TextUtils.isEmpty(CommonInfo.getUserIcon(getContext()))) { | |
| 1283 | + //添加默认头像 | |
| 1284 | + joinFaceIcon.add("http://wjj.ys1.cnliveimg.com/769/img/2018/0416/head_c.png"); | |
| 1285 | + } else { | |
| 1286 | + //添加用户本身头像 | |
| 1287 | + joinFaceIcon.add(CommonInfo.getUserIcon(getContext())); | |
| 1288 | + | |
| 1289 | + } | |
| 1290 | + } | |
| 1291 | + | |
| 1292 | + //开始更新头像 | |
| 1293 | + if (null != joinFaceIcon) { | |
| 1294 | + fragment.binding.includeStreet.fiveJoinPerson.setVisibility(View.VISIBLE); | |
| 1295 | + //设置头像数据 | |
| 1296 | + fragment.binding.includeStreet.fiveJoinPerson.initIconData(joinFaceIcon); | |
| 1297 | + } | |
| 1298 | + //更新参与人数 | |
| 1299 | + if (!TextUtils.isEmpty(fragment.binding.includeStreet.tvSignPerson.getText().toString())) { | |
| 1300 | + if ("--".equals(fragment.binding.includeStreet.tvSignPerson.getText().toString())) { | |
| 1301 | + fragment.binding.includeStreet.tvSignPerson.setText("1"); | |
| 1302 | + } | |
| 1303 | + if (null != runRaceDetailInfo) { | |
| 1304 | + fragment.binding.includeStreet.tvSignPerson.setText((runRaceDetailInfo.getSignupNum() + 1) + ""); | |
| 1305 | + } | |
| 1306 | + } else { | |
| 1307 | + fragment.binding.includeStreet.tvSignPerson.setText("1"); | |
| 1308 | + } | |
| 1261 | 1309 | fragment.binding.rlScrollViewStartBtn.setTag("1"); |
| 1262 | 1310 | fragment.binding.tvRunNow.setText("现在开始"); |
| 1263 | 1311 | fragment.binding.tvGoTip.setVisibility(View.VISIBLE); | ... | ... |
| ... | ... | @@ -14,8 +14,10 @@ import com.baidu.trace.model.SortType; |
| 14 | 14 | import com.bumptech.glide.Glide; |
| 15 | 15 | import com.cnlive.moudle.pedometer.commonInfo.CommonInfo; |
| 16 | 16 | import com.cnlive.moudle.pedometer.model.RunningFinishBean; |
| 17 | +import com.cnlive.moudle.pedometer.sql.entity.UserStepEntity; | |
| 17 | 18 | import com.cnlive.moudle.pedometer.ui.fragment.RunningFinishFragment; |
| 18 | 19 | import com.cnlive.moudle.pedometer.ui.fragment.RunningMapFragment; |
| 20 | +import com.cnlive.moudle.pedometer.ui.widget.SelectDialog; | |
| 19 | 21 | import com.cnlive.moudle.pedometer.utils.MyMapUtil; |
| 20 | 22 | import com.cnlive.moudle.pedometer.utils.QMUITipDialogUtil; |
| 21 | 23 | import com.cnlive.moudle.pedometer.utils.StepUtil; |
| ... | ... | @@ -32,6 +34,7 @@ public class RunningFinishFragmentView implements MvpView { |
| 32 | 34 | public BaiduMap baiduMap; |
| 33 | 35 | private MapView mMapView; |
| 34 | 36 | private UiSettings mUiSettings; |
| 37 | + | |
| 35 | 38 | public RunningFinishFragmentView(RunningFinishFragment fragment) { |
| 36 | 39 | this.fragment = fragment; |
| 37 | 40 | } |
| ... | ... | @@ -80,7 +83,30 @@ public class RunningFinishFragmentView implements MvpView { |
| 80 | 83 | if (fragment.getActivity() == null) { |
| 81 | 84 | return; |
| 82 | 85 | } |
| 83 | - fragment.getActivity().finish(); | |
| 86 | + UserStepEntity userStepEntity = StepUtil.getUserStepData(getContext(), CommonInfo.getUserId(getContext())); | |
| 87 | + if (null != userStepEntity) { | |
| 88 | + SelectDialog selectDialog = new SelectDialog(getContext(), "上传数据失败,您可在重新上传页面查看失败数据,是否确认返回?", "取消", new SelectDialog.DialogInterface() { | |
| 89 | + @Override | |
| 90 | + public void onClick(SelectDialog dialog) { | |
| 91 | + dialog.dismiss(); | |
| 92 | + } | |
| 93 | + }, "返回", new SelectDialog.DialogInterface() { | |
| 94 | + @Override | |
| 95 | + public void onClick(SelectDialog dialog) { | |
| 96 | + dialog.dismiss(); | |
| 97 | + StepUtil.clearRunData(getContext(), CommonInfo.getUserId(getContext())); | |
| 98 | + CommonInfo.reset(getContext()); | |
| 99 | + fragment.getActivity().finish(); | |
| 100 | + } | |
| 101 | + }); | |
| 102 | + selectDialog.setCanceledOnTouchOutside(false); | |
| 103 | + selectDialog.setCancelable(false); | |
| 104 | + if (!selectDialog.isShowing()) { | |
| 105 | + selectDialog.show(); | |
| 106 | + } | |
| 107 | + } else { | |
| 108 | + fragment.getActivity().finish(); | |
| 109 | + } | |
| 84 | 110 | } |
| 85 | 111 | }); |
| 86 | 112 | //完成按钮 | ... | ... |
| 1 | 1 | package com.cnlive.moudle.pedometer.frame.view; |
| 2 | 2 | |
| 3 | +import android.app.Service; | |
| 3 | 4 | import android.content.Context; |
| 4 | 5 | import android.graphics.Bitmap; |
| 5 | 6 | import android.graphics.BitmapFactory; |
| ... | ... | @@ -9,6 +10,7 @@ import android.hardware.SensorEventListener; |
| 9 | 10 | import android.hardware.SensorManager; |
| 10 | 11 | import android.os.Handler; |
| 11 | 12 | import android.os.SystemClock; |
| 13 | +import android.os.Vibrator; | |
| 12 | 14 | import android.text.TextUtils; |
| 13 | 15 | import android.util.Log; |
| 14 | 16 | import android.view.MotionEvent; |
| ... | ... | @@ -38,18 +40,23 @@ import com.baidu.mapapi.utils.DistanceUtil; |
| 38 | 40 | import com.baidu.trace.model.SortType; |
| 39 | 41 | import com.cnlive.moudle.pedometer.commonInfo.CommonInfo; |
| 40 | 42 | import com.cnlive.moudle.pedometer.model.Constant; |
| 43 | +import com.cnlive.moudle.pedometer.model.MessageEvent; | |
| 41 | 44 | import com.cnlive.moudle.pedometer.model.RunningMapBean; |
| 45 | +import com.cnlive.moudle.pedometer.service.StepService; | |
| 42 | 46 | import com.cnlive.moudle.pedometer.sql.entity.UserStepEntity; |
| 43 | 47 | import com.cnlive.moudle.pedometer.ui.fragment.RunningMapFragment; |
| 44 | 48 | import com.cnlive.moudle.pedometer.ui.widget.TipDialog; |
| 45 | 49 | import com.cnlive.moudle.pedometer.utils.BitmapUtil; |
| 46 | 50 | import com.cnlive.moudle.pedometer.utils.ButtonAnimUtil; |
| 51 | +import com.cnlive.moudle.pedometer.utils.ChineseToSpeechUtil; | |
| 47 | 52 | import com.cnlive.moudle.pedometer.utils.GsonUtil; |
| 48 | 53 | import com.cnlive.moudle.pedometer.utils.MyMapUtil; |
| 49 | 54 | import com.cnlive.moudle.pedometer.utils.StepUtil; |
| 50 | 55 | import com.example.moudle_pedometer.R; |
| 51 | 56 | import com.hannesdorfmann.mosby3.mvp.MvpView; |
| 52 | 57 | |
| 58 | +import org.greenrobot.eventbus.EventBus; | |
| 59 | + | |
| 53 | 60 | import java.util.ArrayList; |
| 54 | 61 | import java.util.HashMap; |
| 55 | 62 | import java.util.List; |
| ... | ... | @@ -83,6 +90,9 @@ public class RunningMapFragmentView implements MvpView, SensorEventListener { |
| 83 | 90 | private LatLng endLatLng;//终点坐标 |
| 84 | 91 | private UserStepEntity userStepEntity; |
| 85 | 92 | private TipDialog tipDialog; |
| 93 | + //创建震动服务对象 | |
| 94 | + private Vibrator mVibrator; | |
| 95 | + private boolean isfirstEndTip = true;//是否是第一次提示到达终点 | |
| 86 | 96 | |
| 87 | 97 | public RunningMapFragmentView(RunningMapFragment fragment) { |
| 88 | 98 | this.fragment = fragment; |
| ... | ... | @@ -96,6 +106,8 @@ public class RunningMapFragmentView implements MvpView, SensorEventListener { |
| 96 | 106 | if (getContext() == null) { |
| 97 | 107 | return; |
| 98 | 108 | } |
| 109 | + //获取手机震动服务 | |
| 110 | + mVibrator = (Vibrator) getContext().getSystemService(Service.VIBRATOR_SERVICE); | |
| 99 | 111 | userStepEntity = StepUtil.getUserStepData(getContext(), CommonInfo.getUserId(getContext())); |
| 100 | 112 | currentPoints = new ArrayList<>(); |
| 101 | 113 | initMap(); |
| ... | ... | @@ -341,8 +353,22 @@ public class RunningMapFragmentView implements MvpView, SensorEventListener { |
| 341 | 353 | //更新数据 |
| 342 | 354 | StepUtil.updateStepData(getContext(), userStepEntity); |
| 343 | 355 | } |
| 356 | + | |
| 357 | + if (!isfirstEndTip) { | |
| 358 | + return; | |
| 359 | + } | |
| 360 | + if (isfirstEndTip) { | |
| 361 | + isfirstEndTip = false; | |
| 362 | + } | |
| 344 | 363 | //进行提示 |
| 345 | 364 | if (null == tipDialog) { |
| 365 | + ChineseToSpeechUtil.speech(getContext(), "您已到达终点附近,可以结束运动了!"); | |
| 366 | + if (mVibrator != null) { | |
| 367 | + //设置震动周期,数组表示时间:等待+执行,单位是毫秒,下面操作代表:等待100,执行100,等待100,执行1000, | |
| 368 | + //后面的数字如果为-1代表不重复,之执行一次,其他代表会重复,0代表从数组的第0个位置开始 | |
| 369 | + mVibrator.vibrate(new long[]{Constant.VIBRATOR_DELAY_TIME, Constant.VIBRATOR_RUN_TIME, Constant.VIBRATOR_DELAY_TIME, Constant.VIBRATOR_RUN_TIME}, Constant.VIBRATOR_REPEAT_TIME); | |
| 370 | + } | |
| 371 | + | |
| 346 | 372 | tipDialog = new TipDialog(getContext(), getContext().getResources().getString(R.string.run_race_arrive_end_tip), "好的", R.color.green_round, new TipDialog.DialogInterface() { |
| 347 | 373 | @Override |
| 348 | 374 | public void onClick(TipDialog dialog) { |
| ... | ... | @@ -492,6 +518,10 @@ public class RunningMapFragmentView implements MvpView, SensorEventListener { |
| 492 | 518 | |
| 493 | 519 | } |
| 494 | 520 | |
| 521 | + public void onStop() { | |
| 522 | + ChineseToSpeechUtil.destroy(); | |
| 523 | + } | |
| 524 | + | |
| 495 | 525 | /** |
| 496 | 526 | * 设置从历史轨迹中查询到的最新点 |
| 497 | 527 | * |
| ... | ... | @@ -512,6 +542,7 @@ public class RunningMapFragmentView implements MvpView, SensorEventListener { |
| 512 | 542 | if (mMapView != null) { |
| 513 | 543 | mMapView.onResume(); |
| 514 | 544 | } |
| 545 | + EventBus.getDefault().post(new MessageEvent(Constant.SERVICE_STEP_COUNT_ONRESUME, "")); | |
| 515 | 546 | } |
| 516 | 547 | |
| 517 | 548 | public void onPause() { | ... | ... |
| 1 | 1 | package com.cnlive.moudle.pedometer.model; |
| 2 | 2 | |
| 3 | 3 | public class Constant { |
| 4 | - public static final long SERVICE_ID = 213511;//公司账号 | |
| 5 | -// public static final long SERVICE_ID = 213553; | |
| 6 | - | |
| 7 | - public static final int TAG = 1; | |
| 8 | - public static final int GATHER_INTERVAL = 2;//位置采集周期 | |
| 9 | - public static final int PACK_INTERVAL = 10;//位置采集周期 | |
| 10 | - | |
| 4 | + /*********************************用户标志位**************************************************/ | |
| 11 | 5 | public static final int SERVICE_STEP_COUNT_UPDATE = 0;//步数更新 |
| 12 | 6 | public static final int SERVICE_STEP_COUNT_PAUSE = 1;//步数暂停 |
| 13 | 7 | public static final int SERVICE_STEP_COUNT_CONTINUE = 2;//继续计步 |
| ... | ... | @@ -15,9 +9,8 @@ public class Constant { |
| 15 | 9 | public static final int FRAGMENT_RUN_CHRONOMETER = 4;//同步计时器 |
| 16 | 10 | public static final int EXIT_RANGE = 5;//超出范围 |
| 17 | 11 | public static final int ENTER_RANGE = 6;//进入范围 |
| 18 | - | |
| 19 | - | |
| 20 | - /*****************************************运营工具****************************************************/ | |
| 12 | + public static final int UPDATE_MYSELF_RECORD_LIST = 16;//更新我的记录页面 | |
| 13 | + /*****************************************运营工具标志位****************************************************/ | |
| 21 | 14 | public static final int COLL_SERVICE_STEP_COUNT_RESET_SPEED = 3;//重置速度 |
| 22 | 15 | public static final int COLL_SERVICE_STEP_COUNT_UPDATE = 0;//步数更新 |
| 23 | 16 | public static final int COLL_START_TRACE_GATHER_SUCCESS = 7;//启动轨迹服务成功(运营) |
| ... | ... | @@ -27,11 +20,26 @@ public class Constant { |
| 27 | 20 | public static final int REGISTRATION_SUCCESS = 11;//用户报名成功 |
| 28 | 21 | public static final int UPDATA_COLL_BIND_TRACE_LIST = 12;//更新已绑定列表 |
| 29 | 22 | public static final int DELECT_COLL_BIND_TRACE_LIST = 13;//删除已绑定列表 |
| 23 | + public static final int SERVICE_STEP_COUNT_ONRESUME = 14;//用户从后台回到前台,更新步数 | |
| 24 | + public static final int COLL_SERVICE_STEP_COUNT_ONRESUME = 15;//运营从后台回到前台,更新步数 | |
| 25 | + | |
| 26 | + | |
| 27 | + /*************************************用户其他值,非标志位************************************************************/ | |
| 28 | + public static long SERVICE_ID = 0;//公司账号 | |
| 29 | + // public static final long SERVICE_ID = 213553; | |
| 30 | + public static final int TAG = 1; | |
| 31 | + public static final int GATHER_INTERVAL = 2;//位置采集周期 | |
| 32 | + public static final int PACK_INTERVAL = 10;//位置采集周期 | |
| 33 | + public static final int VIBRATOR_DELAY_TIME = 100;//震动等待时间(ms) | |
| 34 | + public static final int VIBRATOR_RUN_TIME = 1000;//震动执行时间(ms) | |
| 35 | + public static final int VIBRATOR_REPEAT_TIME = -1;//震动重复次数(-1代表不重复,之执行一次,其他代表会重复,0代表从数组的第0个位置开始) | |
| 36 | + /*****************************************运营工具其他值,非标志位****************************************************/ | |
| 30 | 37 | public static final double PASS_RATE = 0.7;//通过率70% |
| 31 | 38 | public static final int CHECK_ACCURACY = 50;//判断用户是否完成的精度范围 |
| 32 | 39 | public static final int LOCA_ACCURACY = 20;//定位过滤精度 |
| 33 | 40 | public static final int LOCA_END_POINT_ACCURACY = 20;//终点位置比较精度 |
| 34 | 41 | public static final int LOCA_START_POINT_ACCURACY = 20;//起点位置比较精度 |
| 35 | - public static final int FENCE_OFFSET = 70;//围栏偏离距离 | |
| 36 | - public static final int FENCE_DENOISE = 70;//围栏去噪精度 | |
| 42 | + public static final int FENCE_OFFSET = 50;//围栏偏离距离 | |
| 43 | + public static final int FENCE_DENOISE = 20;//围栏去噪精度 | |
| 44 | + public static final int TAKE_POINT_MAX_SIZE = 100;//最大打点数量 | |
| 37 | 45 | } | ... | ... |
| ... | ... | @@ -27,6 +27,15 @@ public class RunningFinishBean implements Serializable { |
| 27 | 27 | private boolean isPause; |
| 28 | 28 | private String userPauseTime; |
| 29 | 29 | private String userContinueTime; |
| 30 | + private String failUUID; | |
| 31 | + | |
| 32 | + public String getFailUUID() { | |
| 33 | + return failUUID; | |
| 34 | + } | |
| 35 | + | |
| 36 | + public void setFailUUID(String failUUID) { | |
| 37 | + this.failUUID = failUUID; | |
| 38 | + } | |
| 30 | 39 | |
| 31 | 40 | public boolean isPause() { |
| 32 | 41 | return isPause; | ... | ... |
| ... | ... | @@ -21,7 +21,7 @@ import com.cnlive.moudle.pedometer.utils.ServiceUtils; |
| 21 | 21 | public class ServiceReceiver extends BroadcastReceiver { |
| 22 | 22 | //唤醒锁 |
| 23 | 23 | private PowerManager.WakeLock wakeLock = null; |
| 24 | - private final String TAG = "CollServiceReceiver"; | |
| 24 | + private final String TAG = "ServiceReceiver"; | |
| 25 | 25 | |
| 26 | 26 | public ServiceReceiver() { |
| 27 | 27 | |
| ... | ... | @@ -39,7 +39,7 @@ public class ServiceReceiver extends BroadcastReceiver { |
| 39 | 39 | //todo 这里判断要保活的服务 |
| 40 | 40 | boolean isRunStepService = CommonInfo.getIsRunStepService(context); |
| 41 | 41 | if (isRunStepService) { |
| 42 | - if (!ServiceUtils.isServiceRunning(context, "com.cnlive.moudle.pedometer.service.CollStepService")) { | |
| 42 | + if (!ServiceUtils.isServiceRunning(context, "com.cnlive.moudle.pedometer.service.StepService")) { | |
| 43 | 43 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { |
| 44 | 44 | context.startForegroundService(new Intent(context, StepService.class)); |
| 45 | 45 | } else { |
| ... | ... | @@ -65,7 +65,7 @@ public class ServiceReceiver extends BroadcastReceiver { |
| 65 | 65 | //todo 保活 |
| 66 | 66 | boolean isRunKeepAliveService = CommonInfo.getIsRunKeepAliveService(context); |
| 67 | 67 | if (isRunKeepAliveService) { |
| 68 | - if (!ServiceUtils.isServiceRunning(context, "com.cnlive.moudle.pedometer.service.CollKeepLiveService")) { | |
| 68 | + if (!ServiceUtils.isServiceRunning(context, "com.cnlive.moudle.pedometer.service.KeepLiveService")) { | |
| 69 | 69 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { |
| 70 | 70 | context.startForegroundService(new Intent(context, KeepLiveService.class)); |
| 71 | 71 | } else { | ... | ... |
| ... | ... | @@ -49,6 +49,7 @@ public class KeepLiveService extends Service implements MediaPlayer.OnCompletion |
| 49 | 49 | private final String TAG = "KeepLiveService"; |
| 50 | 50 | private Handler handler; |
| 51 | 51 | private Runnable runnable; |
| 52 | + private boolean isRegisterReceiver = false; | |
| 52 | 53 | |
| 53 | 54 | public KeepLiveService() { |
| 54 | 55 | } |
| ... | ... | @@ -106,13 +107,16 @@ public class KeepLiveService extends Service implements MediaPlayer.OnCompletion |
| 106 | 107 | IntentFilter intentFilter = new IntentFilter(); |
| 107 | 108 | intentFilter.addAction(Intent.ACTION_SCREEN_OFF); |
| 108 | 109 | intentFilter.addAction(Intent.ACTION_SCREEN_ON); |
| 109 | -// intentFilter.addAction(Intent.ACTION_BATTERY_CHANGED); | |
| 110 | + intentFilter.addAction(Intent.ACTION_TIME_CHANGED); | |
| 111 | + intentFilter.addAction(Intent.ACTION_TIME_TICK); | |
| 112 | + intentFilter.addAction(Intent.ACTION_TIMEZONE_CHANGED); | |
| 110 | 113 | // intentFilter.addAction(Intent.ACTION_TIME_CHANGED); |
| 111 | 114 | // intentFilter.addAction(Intent.ACTION_POWER_CONNECTED); |
| 112 | 115 | // intentFilter.addAction(Intent.ACTION_POWER_DISCONNECTED); |
| 113 | 116 | intentFilter.addAction("com.cnlive.strike.receiver.ServiceReceiver"); |
| 114 | 117 | intentFilter.addAction("close.KeepService"); |
| 115 | 118 | registerReceiver(myReceiver, intentFilter); |
| 119 | + isRegisterReceiver=true; | |
| 116 | 120 | } |
| 117 | 121 | |
| 118 | 122 | /** |
| ... | ... | @@ -157,7 +161,7 @@ public class KeepLiveService extends Service implements MediaPlayer.OnCompletion |
| 157 | 161 | } |
| 158 | 162 | showHideForegroundNotification(); |
| 159 | 163 | // startService(new Intent(getApplicationContext(), HideKeepTipService.class)); |
| 160 | - Log.e(TAG, "启动HideKeepTipService"); | |
| 164 | +// Log.e(TAG, "启动HideKeepTipService"); | |
| 161 | 165 | startPlaySong(); |
| 162 | 166 | } |
| 163 | 167 | return START_STICKY; |
| ... | ... | @@ -236,7 +240,7 @@ public class KeepLiveService extends Service implements MediaPlayer.OnCompletion |
| 236 | 240 | public void onDestroy() { |
| 237 | 241 | super.onDestroy(); |
| 238 | 242 | try { |
| 239 | - if (myReceiver != null) { | |
| 243 | + if (myReceiver != null&&isRegisterReceiver) { | |
| 240 | 244 | unregisterReceiver(myReceiver); |
| 241 | 245 | } |
| 242 | 246 | } catch (Exception e) { | ... | ... |
| ... | ... | @@ -112,7 +112,7 @@ public class StepService extends Service implements SensorEventListener { |
| 112 | 112 | /** |
| 113 | 113 | * 计步传感器类型 Sensor.TYPE_STEP_COUNTER或者Sensor.TYPE_STEP_DETECTOR |
| 114 | 114 | */ |
| 115 | - private static int stepSensorType = -1; | |
| 115 | + private int stepSensorType = -1; | |
| 116 | 116 | /** |
| 117 | 117 | * 每次第一次启动记步服务时是否从系统中获取了已有的步数记录 |
| 118 | 118 | */ |
| ... | ... | @@ -247,7 +247,8 @@ public class StepService extends Service implements SensorEventListener { |
| 247 | 247 | if (mClient != null) { |
| 248 | 248 | retryIndex = 0; |
| 249 | 249 | mClient.startGather(traceListener); |
| 250 | - Toast.makeText(getApplicationContext(), "开启轨迹服务", Toast.LENGTH_LONG).show(); | |
| 250 | + Log.e(TAG, "开启轨迹服务"); | |
| 251 | +// Toast.makeText(getApplicationContext(), "开启轨迹服务", Toast.LENGTH_LONG).show(); | |
| 251 | 252 | boolean isFirstSendNotification = CommonInfo.getIsFirstStepSendTraceTip(getApplicationContext()); |
| 252 | 253 | if (isFirstSendNotification) { |
| 253 | 254 | CommonInfo.setIsFirstStepSendTraceTip(getApplicationContext(), false); |
| ... | ... | @@ -292,7 +293,8 @@ public class StepService extends Service implements SensorEventListener { |
| 292 | 293 | if (StatusCodes.SUCCESS == errorNo || StatusCodes.CACHE_TRACK_NOT_UPLOAD == errorNo) { |
| 293 | 294 | if (mClient != null) { |
| 294 | 295 | mClient.stopTrace(mTrace, traceListener); |
| 295 | - Toast.makeText(getApplicationContext(), "停止轨迹服务", Toast.LENGTH_LONG).show(); | |
| 296 | + Log.e(TAG, "停止轨迹服务"); | |
| 297 | +// Toast.makeText(getApplicationContext(), "停止轨迹服务", Toast.LENGTH_LONG).show(); | |
| 296 | 298 | |
| 297 | 299 | } |
| 298 | 300 | } |
| ... | ... | @@ -312,7 +314,8 @@ public class StepService extends Service implements SensorEventListener { |
| 312 | 314 | public void onStartGatherCallback(int errorNo, String message) { |
| 313 | 315 | if (StatusCodes.SUCCESS == errorNo || StatusCodes.GATHER_STARTED == errorNo) { |
| 314 | 316 | retryIndex = 0; |
| 315 | - Toast.makeText(getApplicationContext(), "开始采集", Toast.LENGTH_LONG).show(); | |
| 317 | + Log.e(TAG, "开始采集"); | |
| 318 | +// Toast.makeText(getApplicationContext(), "开始采集", Toast.LENGTH_LONG).show(); | |
| 316 | 319 | } else { |
| 317 | 320 | //重新开启采集 |
| 318 | 321 | if (retryIndex < 4) { |
| ... | ... | @@ -337,7 +340,8 @@ public class StepService extends Service implements SensorEventListener { |
| 337 | 340 | @Override |
| 338 | 341 | public void onStopGatherCallback(int errorNo, String message) { |
| 339 | 342 | if (StatusCodes.SUCCESS == errorNo || StatusCodes.GATHER_STOPPED == errorNo) { |
| 340 | - Toast.makeText(getApplicationContext(), "停止采集", Toast.LENGTH_LONG).show(); | |
| 343 | + Log.e(TAG, "停止采集"); | |
| 344 | +// Toast.makeText(getApplicationContext(), "停止采集", Toast.LENGTH_LONG).show(); | |
| 341 | 345 | if (mClient != null) { |
| 342 | 346 | mClient.stopTrace(mTrace, traceListener); |
| 343 | 347 | } |
| ... | ... | @@ -361,18 +365,18 @@ public class StepService extends Service implements SensorEventListener { |
| 361 | 365 | public void onPushCallback(byte messageType, PushMessage pushMessage) { |
| 362 | 366 | Log.e(TAG, "onPushCallback: "); |
| 363 | 367 | |
| 364 | - if (messageType < 0x03 || messageType > 0x04) { | |
| 365 | - return; | |
| 366 | - } | |
| 368 | +// if (messageType < 0x03 || messageType > 0x04) { | |
| 369 | +// return; | |
| 370 | +// } | |
| 367 | 371 | FenceAlarmPushInfo alarmPushInfo = pushMessage.getFenceAlarmPushInfo(); |
| 368 | 372 | if (null == alarmPushInfo) { |
| 369 | 373 | return; |
| 370 | 374 | } |
| 371 | 375 | UserStepEntity userStepEntity = StepUtil.getUserStepData(getApplicationContext(), CommonInfo.getUserId(getApplicationContext())); |
| 372 | - if (null == userStepEntity) { | |
| 376 | + if (null == userStepEntity || TextUtils.isEmpty(userStepEntity.getFenceId())) { | |
| 373 | 377 | return; |
| 374 | 378 | } |
| 375 | - if (alarmPushInfo.getFenceId() == userStepEntity.getFenceId()) { | |
| 379 | + if (alarmPushInfo.getFenceId() == Long.parseLong(userStepEntity.getFenceId())) { | |
| 376 | 380 | //超出范围 |
| 377 | 381 | if (alarmPushInfo.getMonitoredAction() == MonitoredAction.exit) { |
| 378 | 382 | EventBus.getDefault().post(new MessageEvent(Constant.EXIT_RANGE, "")); |
| ... | ... | @@ -381,7 +385,7 @@ public class StepService extends Service implements SensorEventListener { |
| 381 | 385 | else if (alarmPushInfo.getMonitoredAction() == MonitoredAction.enter) { |
| 382 | 386 | EventBus.getDefault().post(new MessageEvent(Constant.ENTER_RANGE, "")); |
| 383 | 387 | } |
| 384 | - Toast.makeText(getApplicationContext(), "onPushCallback:" + alarmPushInfo.getMonitoredAction(), Toast.LENGTH_SHORT).show(); | |
| 388 | +// Toast.makeText(getApplicationContext(), "onPushCallback:" + alarmPushInfo.getMonitoredAction(), Toast.LENGTH_SHORT).show(); | |
| 385 | 389 | } |
| 386 | 390 | } |
| 387 | 391 | |
| ... | ... | @@ -398,15 +402,18 @@ public class StepService extends Service implements SensorEventListener { |
| 398 | 402 | } |
| 399 | 403 | |
| 400 | 404 | public void startQueryFence() { |
| 401 | - UserStepEntity userStepEntity = StepUtil.getUserStepData(getApplicationContext(), CommonInfo.getUserId(getApplicationContext())); | |
| 405 | + final UserStepEntity userStepEntity = StepUtil.getUserStepData(getApplicationContext(), CommonInfo.getUserId(getApplicationContext())); | |
| 402 | 406 | // 初始化围栏监听器 |
| 403 | 407 | OnFenceListener onFenceListener = new OnFenceListener() { |
| 404 | 408 | // 创建围栏回调 |
| 405 | 409 | @Override |
| 406 | 410 | public void onCreateFenceCallback(CreateFenceResponse createFenceResponse) { |
| 407 | - if ("成功".equals(createFenceResponse.getMessage())) { | |
| 411 | + if (null == createFenceResponse) { | |
| 412 | + return; | |
| 413 | + } | |
| 414 | + if (0 == createFenceResponse.getStatus()) { | |
| 408 | 415 | // Toast.makeText(context, "创建围栏回调成功", Toast.LENGTH_SHORT).show(); |
| 409 | - Log.e(TAG, "onCreateFenceCallback: " + createFenceResponse.getFenceId()); | |
| 416 | +// Log.e(TAG, "onCreateFenceCallback: " + createFenceResponse.getFenceId()); | |
| 410 | 417 | // 查询围栏监控者状态 |
| 411 | 418 | List<Long> list = new ArrayList<>(); |
| 412 | 419 | list.add(createFenceResponse.getFenceId()); |
| ... | ... | @@ -438,31 +445,32 @@ public class StepService extends Service implements SensorEventListener { |
| 438 | 445 | // 监控状态回调 |
| 439 | 446 | @Override |
| 440 | 447 | public void onMonitoredStatusCallback(MonitoredStatusResponse monitoredStatusResponse) { |
| 441 | - if (monitoredStatusResponse.getMonitoredStatusInfos() != null) { | |
| 442 | - Toast.makeText(getApplicationContext(), "围栏列表回调成功:个数:" + monitoredStatusResponse.getMonitoredStatusInfos().size(), Toast.LENGTH_SHORT).show(); | |
| 448 | + if (monitoredStatusResponse.getMonitoredStatusInfos() == null || null == monitoredStatusResponse) { | |
| 449 | + return; | |
| 450 | +// Toast.makeText(getApplicationContext(), "围栏列表回调成功:个数:" + monitoredStatusResponse.getMonitoredStatusInfos().size(), Toast.LENGTH_SHORT).show(); | |
| 443 | 451 | } //查询监控对象状态响应结果 |
| 444 | 452 | List<MonitoredStatusInfo> monitoredStatusInfos = monitoredStatusResponse.getMonitoredStatusInfos(); |
| 445 | - if (monitoredStatusInfos == null) { | |
| 453 | + if (monitoredStatusInfos == null || TextUtils.isEmpty(userStepEntity.getFenceId())) { | |
| 446 | 454 | return; |
| 447 | 455 | } |
| 448 | 456 | for (MonitoredStatusInfo monitoredStatusInfo : monitoredStatusInfos) { |
| 449 | - if (monitoredStatusInfo.getFenceId() == userStepEntity.getFenceId()) { | |
| 457 | + if (monitoredStatusInfo.getFenceId() == Long.parseLong(userStepEntity.getFenceId())) { | |
| 450 | 458 | MonitoredStatus status = monitoredStatusInfo.getMonitoredStatus();//获取状态 |
| 451 | 459 | switch (status) { |
| 452 | 460 | case in: |
| 453 | 461 | //监控的设备在围栏内 |
| 454 | - Toast.makeText(getApplicationContext(), "监控的设备在围栏内", Toast.LENGTH_SHORT).show(); | |
| 462 | +// Toast.makeText(getApplicationContext(), "监控的设备在围栏内", Toast.LENGTH_SHORT).show(); | |
| 455 | 463 | Log.e(TAG, "监控的设备在围栏内: "); |
| 456 | 464 | break; |
| 457 | 465 | case out: |
| 458 | 466 | //监控的设备在围栏外 |
| 459 | - Toast.makeText(getApplicationContext(), "监控的设备在围栏外", Toast.LENGTH_SHORT).show(); | |
| 467 | +// Toast.makeText(getApplicationContext(), "监控的设备在围栏外", Toast.LENGTH_SHORT).show(); | |
| 460 | 468 | Log.e(TAG, "监控的设备在围栏外: "); |
| 461 | 469 | |
| 462 | 470 | break; |
| 463 | 471 | case unknown: |
| 464 | 472 | //监控的设备状态未知 |
| 465 | - Toast.makeText(getApplicationContext(), "监控的设备状态未知", Toast.LENGTH_SHORT).show(); | |
| 473 | +// Toast.makeText(getApplicationContext(), "监控的设备状态未知", Toast.LENGTH_SHORT).show(); | |
| 466 | 474 | Log.e(TAG, "监控的设备状态未知: "); |
| 467 | 475 | |
| 468 | 476 | break; |
| ... | ... | @@ -498,9 +506,9 @@ public class StepService extends Service implements SensorEventListener { |
| 498 | 506 | Log.e(TAG, "onListMonitoredPersonCallback: "); |
| 499 | 507 | } |
| 500 | 508 | }; |
| 501 | - if (userStepEntity != null) { | |
| 509 | + if (userStepEntity != null &&!TextUtils.isEmpty(userStepEntity.getFenceId())) { | |
| 502 | 510 | List<Long> fenids = new ArrayList<>(); |
| 503 | - fenids.add(userStepEntity.getFenceId()); | |
| 511 | + fenids.add(Long.parseLong(userStepEntity.getFenceId())); | |
| 504 | 512 | MonitoredStatusRequest request1 = MonitoredStatusRequest.buildServerRequest(Constant.TAG, |
| 505 | 513 | Constant.SERVICE_ID, userId, fenids); |
| 506 | 514 | if (mClient != null) { |
| ... | ... | @@ -525,11 +533,13 @@ public class StepService extends Service implements SensorEventListener { |
| 525 | 533 | } |
| 526 | 534 | //设置围栏ID |
| 527 | 535 | UserStepEntity userStepEntity = StepUtil.getUserStepData(getApplicationContext(), CommonInfo.getUserId(getApplicationContext())); |
| 528 | - if (userStepEntity == null) { | |
| 529 | - int fenceId = CommonInfo.getFenceId(getApplicationContext()); | |
| 530 | - Log.e(TAG, "onStartTraceCallback: 保存的围栏id" + fenceId); | |
| 531 | - //设置围栏id | |
| 532 | - StepUtil.setFenceId(getApplicationContext(), CommonInfo.getUserId(getApplicationContext()), fenceId); | |
| 536 | + if (userStepEntity != null) { | |
| 537 | + if (TextUtils.isEmpty(userStepEntity.getFenceId())) { | |
| 538 | + int fenceId = CommonInfo.getFenceId(getApplicationContext()); | |
| 539 | +// Log.e(TAG, "onStartTraceCallback: 保存的围栏id" + fenceId); | |
| 540 | + //设置围栏id | |
| 541 | + StepUtil.setFenceId(getApplicationContext(), CommonInfo.getUserId(getApplicationContext()), fenceId + ""); | |
| 542 | + } | |
| 533 | 543 | } |
| 534 | 544 | entityName = userId; |
| 535 | 545 | initTodayData(userId); |
| ... | ... | @@ -642,11 +652,11 @@ public class StepService extends Service implements SensorEventListener { |
| 642 | 652 | handler.removeCallbacks(speedRunnable); |
| 643 | 653 | } |
| 644 | 654 | // Log.e("杀死", "MyTestService"); |
| 645 | - lastStep = 0; | |
| 646 | - hasStepCount = 0; | |
| 647 | - hasRecord = false; | |
| 648 | - CURRENT_STEP = 0; | |
| 649 | - previousStepCount = 0; | |
| 655 | +// lastStep = 0; | |
| 656 | +// hasStepCount = 0; | |
| 657 | +// hasRecord = false; | |
| 658 | +// CURRENT_STEP = 0; | |
| 659 | +// previousStepCount = 0; | |
| 650 | 660 | if (sensorManager != null) { |
| 651 | 661 | sensorManager.unregisterListener(StepService.this); |
| 652 | 662 | sensorManager = null; |
| ... | ... | @@ -666,6 +676,10 @@ public class StepService extends Service implements SensorEventListener { |
| 666 | 676 | else if (messageEvent.getMessageType() == Constant.SERVICE_STEP_COUNT_CONTINUE) { |
| 667 | 677 | pauseFlag = false; |
| 668 | 678 | } |
| 679 | + //更新锁屏步数 | |
| 680 | + else if (messageEvent.getMessageType() == Constant.SERVICE_STEP_COUNT_ONRESUME) { | |
| 681 | + updateNotification(); | |
| 682 | + } | |
| 669 | 683 | } |
| 670 | 684 | |
| 671 | 685 | /** |
| ... | ... | @@ -731,6 +745,7 @@ public class StepService extends Service implements SensorEventListener { |
| 731 | 745 | } |
| 732 | 746 | |
| 733 | 747 | private void updateNotification() { |
| 748 | + save(); | |
| 734 | 749 | // Log.e(TAG, "updateNotification: 当前步数:" + CURRENT_STEP); |
| 735 | 750 | EventBus.getDefault().post(new MessageEvent(Constant.SERVICE_STEP_COUNT_UPDATE, CURRENT_STEP)); |
| 736 | 751 | updateSpeedStepFlag = false; |
| ... | ... | @@ -1046,12 +1061,12 @@ public class StepService extends Service implements SensorEventListener { |
| 1046 | 1061 | //获取APP打开到现在的总步数=本次系统回调的总步数-APP打开之前已有的步数 |
| 1047 | 1062 | // Log.e(TAG, "tempStep: " + tempStep + ",hasStepCount:" + hasStepCount); |
| 1048 | 1063 | int thisStepCount = tempStep - hasStepCount; |
| 1049 | -// Log.e(TAG, "onSensorChanged: thisStepCount" + thisStepCount); | |
| 1064 | + Log.e(TAG, "onSensorChanged: thisStepCount" + thisStepCount); | |
| 1050 | 1065 | //本次有效步数=(APP打开后所记录的总步数-上一次APP打开后所记录的总步数) |
| 1051 | 1066 | int thisStep = thisStepCount - previousStepCount; |
| 1052 | 1067 | //记录最后一次APP打开到现在的总步数 |
| 1053 | 1068 | previousStepCount = thisStepCount; |
| 1054 | -// Log.e(TAG, "本次有效步数: thisStep" + thisStep + ",previousStepCount:" + previousStepCount); | |
| 1069 | + Log.e(TAG, "本次有效步数: thisStep" + thisStep + ",previousStepCount:" + previousStepCount); | |
| 1055 | 1070 | //当用户点击暂停了 |
| 1056 | 1071 | if (pauseFlag) { |
| 1057 | 1072 | thisStep = 0; |
| ... | ... | @@ -1063,7 +1078,7 @@ public class StepService extends Service implements SensorEventListener { |
| 1063 | 1078 | } |
| 1064 | 1079 | //总步数=现有的步数+本次有效步数 |
| 1065 | 1080 | CURRENT_STEP += (thisStep); |
| 1066 | -// Log.e(TAG, "onSensorChanged: 加了以后" + CURRENT_STEP); | |
| 1081 | + Log.e(TAG, "onSensorChanged: 加了以后" + CURRENT_STEP); | |
| 1067 | 1082 | lastStep = tempStep; |
| 1068 | 1083 | } |
| 1069 | 1084 | } | ... | ... |
| ... | ... | @@ -42,7 +42,7 @@ public class UserStepEntityDao extends AbstractDao<UserStepEntity, String> { |
| 42 | 42 | public final static Property QueryTraceEndTime = new Property(15, long.class, "queryTraceEndTime", false, "QUERY_TRACE_END_TIME"); |
| 43 | 43 | public final static Property QueryEntityName = new Property(16, String.class, "queryEntityName", false, "QUERY_ENTITY_NAME"); |
| 44 | 44 | public final static Property ContinueTime = new Property(17, long.class, "continueTime", false, "CONTINUE_TIME"); |
| 45 | - public final static Property FenceId = new Property(18, long.class, "fenceId", false, "FENCE_ID"); | |
| 45 | + public final static Property FenceId = new Property(18, String.class, "fenceId", false, "FENCE_ID"); | |
| 46 | 46 | public final static Property ImportPoint = new Property(19, String.class, "importPoint", false, "IMPORT_POINT"); |
| 47 | 47 | public final static Property StreetTitle = new Property(20, String.class, "streetTitle", false, "STREET_TITLE"); |
| 48 | 48 | public final static Property EndLatLng = new Property(21, String.class, "endLatLng", false, "END_LAT_LNG"); |
| ... | ... | @@ -80,7 +80,7 @@ public class UserStepEntityDao extends AbstractDao<UserStepEntity, String> { |
| 80 | 80 | "\"QUERY_TRACE_END_TIME\" INTEGER NOT NULL ," + // 15: queryTraceEndTime |
| 81 | 81 | "\"QUERY_ENTITY_NAME\" TEXT," + // 16: queryEntityName |
| 82 | 82 | "\"CONTINUE_TIME\" INTEGER NOT NULL ," + // 17: continueTime |
| 83 | - "\"FENCE_ID\" INTEGER NOT NULL ," + // 18: fenceId | |
| 83 | + "\"FENCE_ID\" TEXT," + // 18: fenceId | |
| 84 | 84 | "\"IMPORT_POINT\" TEXT," + // 19: importPoint |
| 85 | 85 | "\"STREET_TITLE\" TEXT," + // 20: streetTitle |
| 86 | 86 | "\"END_LAT_LNG\" TEXT," + // 21: endLatLng |
| ... | ... | @@ -146,7 +146,11 @@ public class UserStepEntityDao extends AbstractDao<UserStepEntity, String> { |
| 146 | 146 | stmt.bindString(17, queryEntityName); |
| 147 | 147 | } |
| 148 | 148 | stmt.bindLong(18, entity.getContinueTime()); |
| 149 | - stmt.bindLong(19, entity.getFenceId()); | |
| 149 | + | |
| 150 | + String fenceId = entity.getFenceId(); | |
| 151 | + if (fenceId != null) { | |
| 152 | + stmt.bindString(19, fenceId); | |
| 153 | + } | |
| 150 | 154 | |
| 151 | 155 | String importPoint = entity.getImportPoint(); |
| 152 | 156 | if (importPoint != null) { |
| ... | ... | @@ -218,7 +222,11 @@ public class UserStepEntityDao extends AbstractDao<UserStepEntity, String> { |
| 218 | 222 | stmt.bindString(17, queryEntityName); |
| 219 | 223 | } |
| 220 | 224 | stmt.bindLong(18, entity.getContinueTime()); |
| 221 | - stmt.bindLong(19, entity.getFenceId()); | |
| 225 | + | |
| 226 | + String fenceId = entity.getFenceId(); | |
| 227 | + if (fenceId != null) { | |
| 228 | + stmt.bindString(19, fenceId); | |
| 229 | + } | |
| 222 | 230 | |
| 223 | 231 | String importPoint = entity.getImportPoint(); |
| 224 | 232 | if (importPoint != null) { |
| ... | ... | @@ -263,7 +271,7 @@ public class UserStepEntityDao extends AbstractDao<UserStepEntity, String> { |
| 263 | 271 | cursor.getLong(offset + 15), // queryTraceEndTime |
| 264 | 272 | cursor.isNull(offset + 16) ? null : cursor.getString(offset + 16), // queryEntityName |
| 265 | 273 | cursor.getLong(offset + 17), // continueTime |
| 266 | - cursor.getLong(offset + 18), // fenceId | |
| 274 | + cursor.isNull(offset + 18) ? null : cursor.getString(offset + 18), // fenceId | |
| 267 | 275 | cursor.isNull(offset + 19) ? null : cursor.getString(offset + 19), // importPoint |
| 268 | 276 | cursor.isNull(offset + 20) ? null : cursor.getString(offset + 20), // streetTitle |
| 269 | 277 | cursor.isNull(offset + 21) ? null : cursor.getString(offset + 21), // endLatLng |
| ... | ... | @@ -292,7 +300,7 @@ public class UserStepEntityDao extends AbstractDao<UserStepEntity, String> { |
| 292 | 300 | entity.setQueryTraceEndTime(cursor.getLong(offset + 15)); |
| 293 | 301 | entity.setQueryEntityName(cursor.isNull(offset + 16) ? null : cursor.getString(offset + 16)); |
| 294 | 302 | entity.setContinueTime(cursor.getLong(offset + 17)); |
| 295 | - entity.setFenceId(cursor.getLong(offset + 18)); | |
| 303 | + entity.setFenceId(cursor.isNull(offset + 18) ? null : cursor.getString(offset + 18)); | |
| 296 | 304 | entity.setImportPoint(cursor.isNull(offset + 19) ? null : cursor.getString(offset + 19)); |
| 297 | 305 | entity.setStreetTitle(cursor.isNull(offset + 20) ? null : cursor.getString(offset + 20)); |
| 298 | 306 | entity.setEndLatLng(cursor.isNull(offset + 21) ? null : cursor.getString(offset + 21)); | ... | ... |
| ... | ... | @@ -27,15 +27,15 @@ public class UserStepEntity { |
| 27 | 27 | private long queryTraceEndTime;//从服务器获取的结束时间呢 |
| 28 | 28 | private String queryEntityName;//从服务器获取的运营人员的实体名称 |
| 29 | 29 | private long continueTime;//继续运动时间 |
| 30 | - private long fenceId;//围栏id | |
| 30 | + private String fenceId;//围栏id | |
| 31 | 31 | private String importPoint;//关键点 |
| 32 | 32 | private String streetTitle;//赛事标题 |
| 33 | 33 | private String endLatLng;//终点坐标 |
| 34 | 34 | private boolean isArriveEndPoint;//是否到达终点 |
| 35 | - @Generated(hash = 434792384) | |
| 35 | + @Generated(hash = 640124145) | |
| 36 | 36 | public UserStepEntity(String userId, String date, String stepCount, long recordTime, double caloriesCount, String serverTraceData, String startPoint, String endPoint, |
| 37 | 37 | long startTimeStamp, long finishTimeStamp, String streetId, int pauseCount, long userPauseTimeStamp, long chronometerBase, long queryTraceStartTime, long queryTraceEndTime, |
| 38 | - String queryEntityName, long continueTime, long fenceId, String importPoint, String streetTitle, String endLatLng, boolean isArriveEndPoint) { | |
| 38 | + String queryEntityName, long continueTime, String fenceId, String importPoint, String streetTitle, String endLatLng, boolean isArriveEndPoint) { | |
| 39 | 39 | this.userId = userId; |
| 40 | 40 | this.date = date; |
| 41 | 41 | this.stepCount = stepCount; |
| ... | ... | @@ -210,13 +210,6 @@ public class UserStepEntity { |
| 210 | 210 | this.continueTime = continueTime; |
| 211 | 211 | } |
| 212 | 212 | |
| 213 | - public long getFenceId() { | |
| 214 | - return this.fenceId; | |
| 215 | - } | |
| 216 | - | |
| 217 | - public void setFenceId(long fenceId) { | |
| 218 | - this.fenceId = fenceId; | |
| 219 | - } | |
| 220 | 213 | |
| 221 | 214 | public String getImportPoint() { |
| 222 | 215 | return this.importPoint; |
| ... | ... | @@ -250,5 +243,14 @@ public class UserStepEntity { |
| 250 | 243 | this.endLatLng = endLatLng; |
| 251 | 244 | } |
| 252 | 245 | |
| 246 | + public String getFenceId() { | |
| 247 | + return this.fenceId; | |
| 248 | + } | |
| 249 | + | |
| 250 | + public void setFenceId(String fenceId) { | |
| 251 | + this.fenceId = fenceId; | |
| 252 | + } | |
| 253 | + | |
| 254 | + | |
| 253 | 255 | |
| 254 | 256 | } | ... | ... |
| ... | ... | @@ -39,8 +39,6 @@ public class RunLineActivity extends AppCompatActivity { |
| 39 | 39 | CommonInfo.setUserNickName(this,getIntent().getStringExtra("userName")); |
| 40 | 40 | CommonInfo.setUserIcon(this,getIntent().getStringExtra("userIcon")); |
| 41 | 41 | CommonInfo.setUserPhone(this,getIntent().getStringExtra("userPhone")); |
| 42 | - }else { | |
| 43 | - CommonInfo.setUserId(this, "10513196"); | |
| 44 | 42 | } |
| 45 | 43 | getSupportFragmentManager().beginTransaction().replace(R.id.run_line_container, new RunLineFragment()).commit(); |
| 46 | 44 | } | ... | ... |
| ... | ... | @@ -29,6 +29,7 @@ import com.cnlive.moudle.pedometer.ui.fragment.RunMainFragment; |
| 29 | 29 | import com.cnlive.moudle.pedometer.ui.fragment.RunRaceDetailFragment; |
| 30 | 30 | import com.cnlive.moudle.pedometer.ui.fragment.RunningMapFragment; |
| 31 | 31 | import com.cnlive.moudle.pedometer.ui.widget.FivePersonIconView; |
| 32 | +import com.cnlive.moudle.pedometer.utils.CheckUtil; | |
| 32 | 33 | import com.cnlive.moudle.pedometer.utils.MyMapUtil; |
| 33 | 34 | import com.cnlive.moudle.pedometer.utils.NotificationUtil; |
| 34 | 35 | import com.cnlive.moudle.pedometer.utils.StepUtil; |
| ... | ... | @@ -94,7 +95,7 @@ public class RunRaceDetailActivity extends QMUIFragmentActivity { |
| 94 | 95 | @Override |
| 95 | 96 | protected void onResume() { |
| 96 | 97 | super.onResume(); |
| 97 | - if (eventId != null) { | |
| 98 | + if (!TextUtils.isEmpty(eventId)) { | |
| 98 | 99 | CommonInfo.setStreetId(this, eventId); |
| 99 | 100 | Log.e("设置全局eventId", "onResume: " + eventId); |
| 100 | 101 | } |
| ... | ... | @@ -107,7 +108,12 @@ public class RunRaceDetailActivity extends QMUIFragmentActivity { |
| 107 | 108 | Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS); |
| 108 | 109 | startActivityForResult(intent, 10); |
| 109 | 110 | } else { |
| 110 | - getPermissionsWithTip(); | |
| 111 | + boolean isSetBattery = CheckUtil.isIgnoringBatteryOptimizationss(RunRaceDetailActivity.this); | |
| 112 | + if (!isSetBattery) { | |
| 113 | + isSetBattery = CheckUtil.isIgnoringBatteryOptimizationss(RunRaceDetailActivity.this); | |
| 114 | + } else { | |
| 115 | + getPermissionsWithTip(); | |
| 116 | + } | |
| 111 | 117 | } |
| 112 | 118 | } |
| 113 | 119 | ... | ... |
| ... | ... | @@ -29,6 +29,26 @@ public class LineUpAgainAdapter extends RecyclerView.Adapter<LineUpAgainAdapter. |
| 29 | 29 | private Context context; |
| 30 | 30 | private OnClickListener onClickListener; |
| 31 | 31 | private OnRestartUploadClickListener onRestartUploadClickListener; |
| 32 | + private OnDeleteClickListener onDeleteClickListener; | |
| 33 | + | |
| 34 | + public int getListSize() { | |
| 35 | + if (null == list) { | |
| 36 | + return 0; | |
| 37 | + } else { | |
| 38 | + return list.size(); | |
| 39 | + } | |
| 40 | + } | |
| 41 | + | |
| 42 | + public void updateDeleteList(int position) { | |
| 43 | + if (null != list) { | |
| 44 | + list.remove(position); | |
| 45 | + notifyDataSetChanged(); | |
| 46 | + } | |
| 47 | + } | |
| 48 | + | |
| 49 | + public void setOnDeleteClickListener(OnDeleteClickListener onDeleteClickListener) { | |
| 50 | + this.onDeleteClickListener = onDeleteClickListener; | |
| 51 | + } | |
| 32 | 52 | |
| 33 | 53 | public void setOnRestartUploadClickListener(OnRestartUploadClickListener onRestartUploadClickListener) { |
| 34 | 54 | this.onRestartUploadClickListener = onRestartUploadClickListener; |
| ... | ... | @@ -79,6 +99,14 @@ public class LineUpAgainAdapter extends RecyclerView.Adapter<LineUpAgainAdapter. |
| 79 | 99 | myHolder.up_record_speed.setText(list.get(i).getSpeed()); |
| 80 | 100 | //设置步数 |
| 81 | 101 | myHolder.up_record_step.setText(list.get(i).getStep()); |
| 102 | + myHolder.tv_delete.setOnClickListener(new View.OnClickListener() { | |
| 103 | + @Override | |
| 104 | + public void onClick(View view) { | |
| 105 | + if (null != onDeleteClickListener) { | |
| 106 | + onDeleteClickListener.onDeleteClickListener(i); | |
| 107 | + } | |
| 108 | + } | |
| 109 | + }); | |
| 82 | 110 | } |
| 83 | 111 | |
| 84 | 112 | } |
| ... | ... | @@ -99,6 +127,7 @@ public class LineUpAgainAdapter extends RecyclerView.Adapter<LineUpAgainAdapter. |
| 99 | 127 | TextView up_record_speed; |
| 100 | 128 | TextView up_record_step; |
| 101 | 129 | TextView again_up; |
| 130 | + TextView tv_delete; | |
| 102 | 131 | RelativeLayout ry_re; |
| 103 | 132 | |
| 104 | 133 | public MyHolder(@NonNull View itemView) { |
| ... | ... | @@ -112,6 +141,7 @@ public class LineUpAgainAdapter extends RecyclerView.Adapter<LineUpAgainAdapter. |
| 112 | 141 | up_record_speed = itemView.findViewById(R.id.up_record_speed); |
| 113 | 142 | up_record_step = itemView.findViewById(R.id.up_record_step); |
| 114 | 143 | again_up = itemView.findViewById(R.id.again_up); |
| 144 | + tv_delete = itemView.findViewById(R.id.tv_delete); | |
| 115 | 145 | ry_re = itemView.findViewById(R.id.ry_re); |
| 116 | 146 | } |
| 117 | 147 | } |
| ... | ... | @@ -121,6 +151,10 @@ public class LineUpAgainAdapter extends RecyclerView.Adapter<LineUpAgainAdapter. |
| 121 | 151 | void onClickListener(FailedEntity bean, int position); |
| 122 | 152 | } |
| 123 | 153 | |
| 154 | + public interface OnDeleteClickListener { | |
| 155 | + void onDeleteClickListener(int position); | |
| 156 | + } | |
| 157 | + | |
| 124 | 158 | public interface OnRestartUploadClickListener { |
| 125 | 159 | void onRestartUploadClickListener(FailedEntity failedEntity); |
| 126 | 160 | } | ... | ... |
| ... | ... | @@ -95,10 +95,17 @@ public class MyRecordAdapter extends RecyclerView.Adapter<MyRecordAdapter.MyView |
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | private void toRaking(String eventId){ |
| 98 | - String baseWebUrl = AppConfig.isDebug() ? "http://wjjh5test.cnlive.com/cnSportListOver.html" : "http://wjjh5.cnlive.com/cnSportListOver.html"; | |
| 98 | + String baseWebUrl,title; | |
| 99 | + if(state.equals("0")){ | |
| 100 | + title = "排行榜"; | |
| 101 | + baseWebUrl = AppConfig.isDebug() ? "http://wjjh5test.cnlive.com/cnSportList.html" : "http://wjjh5.cnlive.com/cnSportList.html"; | |
| 102 | + }else { | |
| 103 | + title = "总排行榜"; | |
| 104 | + baseWebUrl = AppConfig.isDebug() ? "http://wjjh5test.cnlive.com/cnSportListOver.html" : "http://wjjh5.cnlive.com/cnSportListOver.html"; | |
| 105 | + } | |
| 99 | 106 | ARouter.getInstance().build("/web/WebViewColorActivity") |
| 100 | 107 | .withString("url", baseWebUrl +"?sid="+CommonInfo.getUserId(context)+"&eventId="+eventId) |
| 101 | - .withString("title","总排行榜") | |
| 108 | + .withString("title",title) | |
| 102 | 109 | .navigation(context); |
| 103 | 110 | } |
| 104 | 111 | ... | ... |
| ... | ... | @@ -52,11 +52,16 @@ public class ALLScoreDetailFragment extends QMUIFragment<ALLScoreDetailFragmentV |
| 52 | 52 | runningFinishBean = (RunningFinishBean) getArguments().getSerializable("runningFinishBean"); |
| 53 | 53 | if (runningFinishBean != null) { |
| 54 | 54 | if (getMvpView() != null) { |
| 55 | - getMvpView().initMap(); | |
| 56 | - getMvpView().initView(runningFinishBean); | |
| 57 | - if (getPresenter() != null) { | |
| 58 | - getPresenter().queryHistoryTrace(getActivity(), runningFinishBean); | |
| 59 | - } | |
| 55 | + getMvpView().initMap(new ALLScoreDetailFragmentView.MapCallBack() { | |
| 56 | + @Override | |
| 57 | + public void onMapLoadFinish() { | |
| 58 | + getMvpView().initView(runningFinishBean); | |
| 59 | + if (getPresenter() != null) { | |
| 60 | + getPresenter().queryHistoryTrace(getActivity(), runningFinishBean); | |
| 61 | + } | |
| 62 | + } | |
| 63 | + }); | |
| 64 | + | |
| 60 | 65 | } |
| 61 | 66 | } |
| 62 | 67 | } | ... | ... |
| ... | ... | @@ -11,11 +11,18 @@ import com.cnlive.libs.base.frame.fragment.MvpBindingFragment; |
| 11 | 11 | import com.cnlive.moudle.pedometer.commonInfo.CommonInfo; |
| 12 | 12 | import com.cnlive.moudle.pedometer.frame.presenter.LineUpAgainPresenter; |
| 13 | 13 | import com.cnlive.moudle.pedometer.frame.view.LineUpAgainView; |
| 14 | +import com.cnlive.moudle.pedometer.model.Constant; | |
| 15 | +import com.cnlive.moudle.pedometer.model.MessageEvent; | |
| 14 | 16 | import com.cnlive.moudle.pedometer.sql.entity.FailedEntity; |
| 17 | +import com.cnlive.moudle.pedometer.utils.ChineseToSpeechUtil; | |
| 15 | 18 | import com.cnlive.moudle.pedometer.utils.StepUtil; |
| 16 | 19 | import com.example.moudle_pedometer.R; |
| 17 | 20 | import com.example.moudle_pedometer.databinding.FragmentLineUpAgainBinding; |
| 18 | 21 | |
| 22 | +import org.greenrobot.eventbus.EventBus; | |
| 23 | +import org.greenrobot.eventbus.Subscribe; | |
| 24 | +import org.greenrobot.eventbus.ThreadMode; | |
| 25 | + | |
| 19 | 26 | import java.util.List; |
| 20 | 27 | |
| 21 | 28 | /** |
| ... | ... | @@ -37,6 +44,7 @@ public class LineUpAgainFragment extends MvpBindingFragment<LineUpAgainView, Lin |
| 37 | 44 | @Override |
| 38 | 45 | public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { |
| 39 | 46 | super.onViewCreated(view, savedInstanceState); |
| 47 | + | |
| 40 | 48 | List<FailedEntity> failedEntities = StepUtil.getFailListData(getActivity(), CommonInfo.getUserId(getActivity())); |
| 41 | 49 | if (getMvpView() != null) { |
| 42 | 50 | getMvpView().initView(); |
| ... | ... | @@ -63,4 +71,8 @@ public class LineUpAgainFragment extends MvpBindingFragment<LineUpAgainView, Lin |
| 63 | 71 | } |
| 64 | 72 | } |
| 65 | 73 | } |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 66 | 78 | } | ... | ... |
| ... | ... | @@ -15,7 +15,7 @@ import com.example.moudle_pedometer.databinding.FragmentRunRaceDetailBinding; |
| 15 | 15 | import com.qmuiteam.qmui.util.QMUIStatusBarHelper; |
| 16 | 16 | |
| 17 | 17 | public class OnGoingFragment extends QMUIFragment<OnGoingFragmentView, OnGoingFragmentPresenter, FragmentRunRaceDetailBinding> { |
| 18 | - private String eventId; | |
| 18 | + public String eventId; | |
| 19 | 19 | |
| 20 | 20 | public static OnGoingFragment newInstance(String eventId) { |
| 21 | 21 | OnGoingFragment fragment = new OnGoingFragment(); | ... | ... |
| ... | ... | @@ -127,6 +127,14 @@ public class RunMainFragment extends QMUIFragment<RunMainFragmentView, RunMainFr |
| 127 | 127 | } |
| 128 | 128 | |
| 129 | 129 | @Override |
| 130 | + public void onResume() { | |
| 131 | + super.onResume(); | |
| 132 | + if (getMvpView() != null) { | |
| 133 | + getMvpView().onResume(); | |
| 134 | + } | |
| 135 | + } | |
| 136 | + | |
| 137 | + @Override | |
| 130 | 138 | public void onDestroy() { |
| 131 | 139 | |
| 132 | 140 | super.onDestroy(); |
| ... | ... | @@ -186,7 +194,7 @@ public class RunMainFragment extends QMUIFragment<RunMainFragmentView, RunMainFr |
| 186 | 194 | if (mVibrator != null) { |
| 187 | 195 | //设置震动周期,数组表示时间:等待+执行,单位是毫秒,下面操作代表:等待100,执行100,等待100,执行1000, |
| 188 | 196 | //后面的数字如果为-1代表不重复,之执行一次,其他代表会重复,0代表从数组的第0个位置开始 |
| 189 | - mVibrator.vibrate(new long[]{100, 1000, 100, 1000}, -1); | |
| 197 | + mVibrator.vibrate(new long[]{Constant.VIBRATOR_DELAY_TIME, Constant.VIBRATOR_RUN_TIME, Constant.VIBRATOR_DELAY_TIME, Constant.VIBRATOR_RUN_TIME}, Constant.VIBRATOR_REPEAT_TIME); | |
| 190 | 198 | } |
| 191 | 199 | if (tipDialog != null) { |
| 192 | 200 | tipDialog.setTipMsg("您已偏离路径轨迹\n请您计时回归路径!"); |
| ... | ... | @@ -199,7 +207,7 @@ public class RunMainFragment extends QMUIFragment<RunMainFragmentView, RunMainFr |
| 199 | 207 | if (mVibrator != null) { |
| 200 | 208 | //设置震动周期,数组表示时间:等待+执行,单位是毫秒,下面操作代表:等待100,执行100,等待100,执行1000, |
| 201 | 209 | //后面的数字如果为-1代表不重复,之执行一次,其他代表会重复,0代表从数组的第0个位置开始 |
| 202 | - mVibrator.vibrate(new long[]{100, 1000, 100, 1000}, -1); | |
| 210 | + mVibrator.vibrate(new long[]{Constant.VIBRATOR_DELAY_TIME, Constant.VIBRATOR_RUN_TIME, Constant.VIBRATOR_DELAY_TIME, Constant.VIBRATOR_RUN_TIME}, Constant.VIBRATOR_REPEAT_TIME); | |
| 203 | 211 | } |
| 204 | 212 | if (tipDialog != null) { |
| 205 | 213 | tipDialog.setTipMsg("您已回归轨迹\n继续参与运动吧"); |
| ... | ... | @@ -208,6 +216,14 @@ public class RunMainFragment extends QMUIFragment<RunMainFragmentView, RunMainFr |
| 208 | 216 | } |
| 209 | 217 | } |
| 210 | 218 | |
| 219 | + @Override | |
| 220 | + public void onStop() { | |
| 221 | + super.onStop(); | |
| 222 | + if (null != getMvpView()) { | |
| 223 | + getMvpView().onStop(); | |
| 224 | + } | |
| 225 | + } | |
| 226 | + | |
| 211 | 227 | /** |
| 212 | 228 | * 屏蔽边缘返回 |
| 213 | 229 | * 杨帅 | ... | ... |
| ... | ... | @@ -150,6 +150,7 @@ public class RunningMapFragment extends QMUIFragment<RunningMapFragmentView, Run |
| 150 | 150 | if (getMvpView() != null) { |
| 151 | 151 | //取消注册传感器监听 |
| 152 | 152 | mSensorManager.unregisterListener(getMvpView()); |
| 153 | + getMvpView().onStop(); | |
| 153 | 154 | } |
| 154 | 155 | ChineseToSpeechUtil.destroy(); |
| 155 | 156 | |
| ... | ... | @@ -196,7 +197,7 @@ public class RunningMapFragment extends QMUIFragment<RunningMapFragmentView, Run |
| 196 | 197 | if (mVibrator != null) { |
| 197 | 198 | //设置震动周期,数组表示时间:等待+执行,单位是毫秒,下面操作代表:等待100,执行100,等待100,执行1000, |
| 198 | 199 | //后面的数字如果为-1代表不重复,之执行一次,其他代表会重复,0代表从数组的第0个位置开始 |
| 199 | - mVibrator.vibrate(new long[]{100, 1000, 100, 1000}, -1); | |
| 200 | + mVibrator.vibrate(new long[]{Constant.VIBRATOR_DELAY_TIME, Constant.VIBRATOR_RUN_TIME, Constant.VIBRATOR_DELAY_TIME, Constant.VIBRATOR_RUN_TIME}, Constant.VIBRATOR_REPEAT_TIME); | |
| 200 | 201 | } |
| 201 | 202 | if (tipDialog != null) { |
| 202 | 203 | tipDialog.setTipMsg("您已偏离路径轨迹\n请您计时回归路径!"); |
| ... | ... | @@ -209,7 +210,7 @@ public class RunningMapFragment extends QMUIFragment<RunningMapFragmentView, Run |
| 209 | 210 | if (mVibrator != null) { |
| 210 | 211 | //设置震动周期,数组表示时间:等待+执行,单位是毫秒,下面操作代表:等待100,执行100,等待100,执行1000, |
| 211 | 212 | //后面的数字如果为-1代表不重复,之执行一次,其他代表会重复,0代表从数组的第0个位置开始 |
| 212 | - mVibrator.vibrate(new long[]{100, 1000, 100, 1000}, -1); | |
| 213 | + mVibrator.vibrate(new long[]{Constant.VIBRATOR_DELAY_TIME, Constant.VIBRATOR_RUN_TIME, Constant.VIBRATOR_DELAY_TIME, Constant.VIBRATOR_RUN_TIME}, Constant.VIBRATOR_REPEAT_TIME); | |
| 213 | 214 | } |
| 214 | 215 | if (tipDialog != null) { |
| 215 | 216 | tipDialog.setTipMsg("您已回归轨迹\n继续参与运动吧"); | ... | ... |
| ... | ... | @@ -11,6 +11,8 @@ import com.cnlive.libs.base.frame.fragment.MvpBindingFragment; |
| 11 | 11 | import com.cnlive.moudle.pedometer.commonInfo.CommonInfo; |
| 12 | 12 | import com.cnlive.moudle.pedometer.frame.presenter.SelfRecordPresenter; |
| 13 | 13 | import com.cnlive.moudle.pedometer.frame.view.SelfRecordView; |
| 14 | +import com.cnlive.moudle.pedometer.model.Constant; | |
| 15 | +import com.cnlive.moudle.pedometer.model.MessageEvent; | |
| 14 | 16 | import com.cnlive.moudle.pedometer.sql.entity.FailedEntity; |
| 15 | 17 | import com.cnlive.moudle.pedometer.utils.StepUtil; |
| 16 | 18 | import com.example.moudle_pedometer.R; |
| ... | ... | @@ -19,6 +21,10 @@ import com.scwang.smartrefresh.layout.api.RefreshLayout; |
| 19 | 21 | import com.scwang.smartrefresh.layout.listener.OnLoadMoreListener; |
| 20 | 22 | import com.scwang.smartrefresh.layout.listener.OnRefreshListener; |
| 21 | 23 | |
| 24 | +import org.greenrobot.eventbus.EventBus; | |
| 25 | +import org.greenrobot.eventbus.Subscribe; | |
| 26 | +import org.greenrobot.eventbus.ThreadMode; | |
| 27 | + | |
| 22 | 28 | import java.util.List; |
| 23 | 29 | |
| 24 | 30 | import q.rorbin.badgeview.QBadgeView; |
| ... | ... | @@ -42,6 +48,9 @@ public class SelfRecordFragment extends MvpBindingFragment<SelfRecordView, SelfR |
| 42 | 48 | @Override |
| 43 | 49 | public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { |
| 44 | 50 | super.onViewCreated(view, savedInstanceState); |
| 51 | + if (!EventBus.getDefault().isRegistered(this)) { | |
| 52 | + EventBus.getDefault().register(this); | |
| 53 | + } | |
| 45 | 54 | if (getMvpView() != null) getMvpView().initView(); |
| 46 | 55 | getData(completeStatus); |
| 47 | 56 | |
| ... | ... | @@ -69,7 +78,7 @@ public class SelfRecordFragment extends MvpBindingFragment<SelfRecordView, SelfR |
| 69 | 78 | |
| 70 | 79 | |
| 71 | 80 | private void getData(int completeStatu) { |
| 72 | - if(completeStatu != completeStatus) currentPage = 1; | |
| 81 | + if (completeStatu != completeStatus) currentPage = 1; | |
| 73 | 82 | this.completeStatus = completeStatu; |
| 74 | 83 | getPresenter().getData(getActivity(), CommonInfo.getUserId(getActivity()), completeStatus, currentPage, pageSize); |
| 75 | 84 | if (completeStatus == 1) { |
| ... | ... | @@ -114,4 +123,22 @@ public class SelfRecordFragment extends MvpBindingFragment<SelfRecordView, SelfR |
| 114 | 123 | qBadgeView.setBadgeNumber(failedEntities.size()); |
| 115 | 124 | } |
| 116 | 125 | } |
| 126 | + | |
| 127 | + @Subscribe(threadMode = ThreadMode.MAIN) | |
| 128 | + public void Event(MessageEvent messageEvent) { | |
| 129 | + //刷新我的记录页面 | |
| 130 | + if (messageEvent.getMessageType() == Constant.UPDATE_MYSELF_RECORD_LIST) { | |
| 131 | + if (getMvpView() != null) { | |
| 132 | + getData(completeStatus); | |
| 133 | + } | |
| 134 | + } | |
| 135 | + } | |
| 136 | + | |
| 137 | + @Override | |
| 138 | + public void onDestroy() { | |
| 139 | + super.onDestroy(); | |
| 140 | + if (EventBus.getDefault().isRegistered(this)) { | |
| 141 | + EventBus.getDefault().unregister(this); | |
| 142 | + } | |
| 143 | + } | |
| 117 | 144 | } | ... | ... |
| ... | ... | @@ -8,25 +8,39 @@ import android.net.Uri; |
| 8 | 8 | import android.os.PowerManager; |
| 9 | 9 | import android.provider.Settings; |
| 10 | 10 | |
| 11 | +import com.cnlive.libs.base.util.AlertUtil; | |
| 12 | + | |
| 11 | 13 | import static android.content.Context.POWER_SERVICE; |
| 12 | 14 | |
| 13 | 15 | public class CheckUtil { |
| 14 | 16 | |
| 17 | + /** | |
| 18 | + * 锤子手机不能检测电池白名单,会崩溃 | |
| 19 | + * | |
| 20 | + * @param context | |
| 21 | + * @return | |
| 22 | + */ | |
| 15 | 23 | public static boolean isIgnoringBatteryOptimizationss(Activity context) { |
| 16 | - PowerManager powerManager = (PowerManager) context.getSystemService(POWER_SERVICE); | |
| 17 | - if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) { | |
| 18 | - boolean hasIgnored = powerManager.isIgnoringBatteryOptimizations(context.getPackageName()); | |
| 19 | - if (!hasIgnored) { | |
| 20 | - Intent intent = new Intent(Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS); | |
| 21 | - intent.setData(Uri.parse("package:" + context.getPackageName())); | |
| 22 | - PackageManager pm = context.getPackageManager(); | |
| 23 | - if (intent.resolveActivity(pm) != null) { | |
| 24 | - context.startActivity(intent); | |
| 24 | + String carrier = android.os.Build.MANUFACTURER; | |
| 25 | + if (!"smartisan".equals(carrier)) { | |
| 26 | + PowerManager powerManager = (PowerManager) context.getSystemService(POWER_SERVICE); | |
| 27 | + if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) { | |
| 28 | + boolean hasIgnored = powerManager.isIgnoringBatteryOptimizations(context.getPackageName()); | |
| 29 | + if (!hasIgnored) { | |
| 30 | + Intent intent = new Intent(Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS); | |
| 31 | + intent.setData(Uri.parse("package:" + context.getPackageName())); | |
| 32 | + PackageManager pm = context.getPackageManager(); | |
| 33 | + if (intent.resolveActivity(pm) != null) { | |
| 34 | + context.startActivity(intent); | |
| 35 | + } | |
| 36 | + AlertUtil.showDeftToast(context, "请选择允许加入电池优化白名单,否则将会影响您的正常使用!"); | |
| 37 | + return false; | |
| 38 | + } else { | |
| 39 | + return true; | |
| 25 | 40 | } |
| 26 | - return false; | |
| 27 | - } else { | |
| 28 | - return true; | |
| 29 | 41 | } |
| 42 | + } else { | |
| 43 | + return true; | |
| 30 | 44 | } |
| 31 | 45 | return false; |
| 32 | 46 | } | ... | ... |
| ... | ... | @@ -68,7 +68,7 @@ public class MyMapUtil { |
| 68 | 68 | return null; |
| 69 | 69 | } |
| 70 | 70 | try { |
| 71 | - Bitmap pointBitmap = BitmapUtil.getBitmapFromDp(context, BitmapFactory.decodeResource(context.getResources(), startIconRes), 17, 30); | |
| 71 | + Bitmap pointBitmap = BitmapUtil.getBitmapFromDp(context, BitmapFactory.decodeResource(context.getResources(), startIconRes), 25, 25); | |
| 72 | 72 | OverlayOptions startOptions = null; |
| 73 | 73 | if (pointBitmap != null) { |
| 74 | 74 | startOptions = new MarkerOptions() |
| ... | ... | @@ -211,24 +211,26 @@ public class MyMapUtil { |
| 211 | 211 | public static boolean checkIsFinishTrace(List<LatLng> importPoints, List<LatLng> trackPoints, double passRate) { |
| 212 | 212 | HashMap<Integer, Boolean> importHash = new HashMap<>(); |
| 213 | 213 | for (int i = 0; i < importPoints.size(); i++) { |
| 214 | - if (i % 3 != 0) { | |
| 215 | - importPoints.remove(i); | |
| 216 | - } | |
| 217 | - } | |
| 218 | - for (int i = 0; i < importPoints.size(); i++) { | |
| 219 | 214 | importHash.put(i, false); |
| 220 | 215 | } |
| 221 | 216 | //开始比较数据 |
| 222 | 217 | int index = 0; |
| 218 | + boolean isContinue = false; | |
| 223 | 219 | for (int i = 0; i < importPoints.size(); i++) { |
| 220 | + isContinue = false; | |
| 224 | 221 | LatLng importLatLng = importPoints.get(i); |
| 225 | 222 | for (int j = index; j < trackPoints.size(); j++) { |
| 226 | 223 | double distance = DistanceUtil.getDistance(importLatLng, trackPoints.get(j)); |
| 227 | 224 | if (distance < Constant.CHECK_ACCURACY) { |
| 228 | 225 | importHash.put(i, true); |
| 229 | 226 | index = j; |
| 227 | + isContinue = true; | |
| 228 | + break; | |
| 230 | 229 | } |
| 231 | 230 | } |
| 231 | + if (isContinue) { | |
| 232 | + continue; | |
| 233 | + } | |
| 232 | 234 | } |
| 233 | 235 | //输出 |
| 234 | 236 | int result = 0; |
| ... | ... | @@ -374,16 +376,20 @@ public class MyMapUtil { |
| 374 | 376 | * @return true 表示开启 |
| 375 | 377 | */ |
| 376 | 378 | public static final boolean isOPenGps(final Context context) { |
| 377 | - LocationManager locationManager | |
| 378 | - = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE); | |
| 379 | - // 通过GPS卫星定位,定位级别可以精确到街(通过24颗卫星定位,在室外和空旷的地方定位准确、速度快) | |
| 380 | - boolean gps = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER); | |
| 381 | - // 通过WLAN或移动网络(3G/2G)确定的位置(也称作AGPS,辅助GPS定位。主要用于在室内或遮盖物(建筑群或茂密的深林等)密集的地方定位) | |
| 382 | - boolean network = locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER); | |
| 383 | - if (gps || network) { | |
| 379 | + try { | |
| 380 | + LocationManager locationManager | |
| 381 | + = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE); | |
| 382 | + // 通过GPS卫星定位,定位级别可以精确到街(通过24颗卫星定位,在室外和空旷的地方定位准确、速度快) | |
| 383 | + boolean gps = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER); | |
| 384 | + // 通过WLAN或移动网络(3G/2G)确定的位置(也称作AGPS,辅助GPS定位。主要用于在室内或遮盖物(建筑群或茂密的深林等)密集的地方定位) | |
| 385 | + boolean network = locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER); | |
| 386 | + if (gps) { | |
| 387 | + return true; | |
| 388 | + } | |
| 389 | + } catch (Exception e) { | |
| 390 | + //异常就返回true | |
| 384 | 391 | return true; |
| 385 | 392 | } |
| 386 | - | |
| 387 | 393 | return false; |
| 388 | 394 | } |
| 389 | 395 | ... | ... |
| ... | ... | @@ -7,6 +7,8 @@ import android.provider.Settings; |
| 7 | 7 | import android.support.v4.app.NotificationManagerCompat; |
| 8 | 8 | import android.widget.Toast; |
| 9 | 9 | |
| 10 | +import com.cnlive.libs.base.util.AlertUtil; | |
| 11 | + | |
| 10 | 12 | import static android.app.Notification.EXTRA_CHANNEL_ID; |
| 11 | 13 | import static android.provider.Settings.EXTRA_APP_PACKAGE; |
| 12 | 14 | ... | ... |
| ... | ... | @@ -35,6 +35,7 @@ public class StepUtil { |
| 35 | 35 | return UUID.randomUUID().toString().replace("-", ""); |
| 36 | 36 | } |
| 37 | 37 | |
| 38 | + | |
| 38 | 39 | public static void initDataBase(Context context, String uid) { |
| 39 | 40 | try { |
| 40 | 41 | if (null == getUserStepData(context, uid)) { |
| ... | ... | @@ -50,6 +51,50 @@ public class StepUtil { |
| 50 | 51 | } |
| 51 | 52 | |
| 52 | 53 | /** |
| 54 | + * 更新删除临时保存数据 | |
| 55 | + * | |
| 56 | + * @param context | |
| 57 | + * @param entity | |
| 58 | + */ | |
| 59 | + public static void updateFailData(Context context, FailedEntity entity) { | |
| 60 | + try { | |
| 61 | + DbCore.init(context, dbName); | |
| 62 | + if (entity != null && !TextUtils.isEmpty(entity.getUuid())) { | |
| 63 | + DbCore.getDaoSession().getFailedEntityDao().update(entity); | |
| 64 | + } | |
| 65 | + } catch (Exception e) { | |
| 66 | + Log.e(TAG, "deleteTempSaveFailData: " + e.toString()); | |
| 67 | + } | |
| 68 | + | |
| 69 | + } | |
| 70 | + | |
| 71 | + /** | |
| 72 | + * 获取暂存的失败数据 | |
| 73 | + * | |
| 74 | + * @param context | |
| 75 | + * @param uid | |
| 76 | + * @return | |
| 77 | + */ | |
| 78 | + public static FailedEntity getTempSaveFailByUUID(Context context, String uid, String UUID) { | |
| 79 | + try { | |
| 80 | + DbCore.init(context, dbName); | |
| 81 | + List<FailedEntity> list = DbCore.getDaoSession().getFailedEntityDao().queryBuilder().where(FailedEntityDao.Properties.Uid.eq(uid), FailedEntityDao.Properties.Uuid.eq(UUID)).list(); | |
| 82 | + if (list != null && list.size() > 0) { | |
| 83 | + if (list.get(0) == null) { | |
| 84 | + return null; | |
| 85 | + } else { | |
| 86 | + return list.get(0); | |
| 87 | + } | |
| 88 | + } | |
| 89 | + return null; | |
| 90 | + } catch (Exception e) { | |
| 91 | + Log.e(TAG, "getTempSaveFailByUUID: " + e.toString()); | |
| 92 | + return null; | |
| 93 | + } | |
| 94 | + | |
| 95 | + } | |
| 96 | + | |
| 97 | + /** | |
| 53 | 98 | * 删除临时保存数据 |
| 54 | 99 | * |
| 55 | 100 | * @param context |
| ... | ... | @@ -95,11 +140,11 @@ public class StepUtil { |
| 95 | 140 | |
| 96 | 141 | } |
| 97 | 142 | |
| 98 | - //获取上传失败列表 | |
| 143 | + //获取上传失败列表,按时间倒序 | |
| 99 | 144 | public static List<FailedEntity> getFailListData(Context context, String uid) { |
| 100 | 145 | try { |
| 101 | 146 | DbCore.init(context, dbName); |
| 102 | - List<FailedEntity> list = DbCore.getDaoSession().getFailedEntityDao().queryBuilder().where(FailedEntityDao.Properties.Uid.eq(uid)).list(); | |
| 147 | + List<FailedEntity> list = DbCore.getDaoSession().getFailedEntityDao().queryBuilder().where(FailedEntityDao.Properties.Uid.eq(uid)).orderDesc(FailedEntityDao.Properties.CreatTimeStamp).list(); | |
| 103 | 148 | return list; |
| 104 | 149 | } catch (Exception e) { |
| 105 | 150 | Log.e(TAG, "getFailListData: " + e.toString()); |
| ... | ... | @@ -170,7 +215,7 @@ public class StepUtil { |
| 170 | 215 | * @param uid |
| 171 | 216 | * @param fenceId |
| 172 | 217 | */ |
| 173 | - public static void setFenceId(Context context, String uid, long fenceId) { | |
| 218 | + public static void setFenceId(Context context, String uid, String fenceId) { | |
| 174 | 219 | try { |
| 175 | 220 | if (getUserStepData(context, uid) != null) { |
| 176 | 221 | UserStepEntity entity = getUserStepData(context, uid); |
| ... | ... | @@ -258,8 +303,8 @@ public class StepUtil { |
| 258 | 303 | */ |
| 259 | 304 | public static void updateStepData(Context context, UserStepEntity userStepEntity) { |
| 260 | 305 | try { |
| 306 | + DbCore.init(context, dbName); | |
| 261 | 307 | if (userStepEntity != null) { |
| 262 | - DbCore.init(context, dbName); | |
| 263 | 308 | DbCore.getDaoSession().getUserStepEntityDao().update(userStepEntity); |
| 264 | 309 | } |
| 265 | 310 | } catch (Exception e) { | ... | ... |
3.67 KB
3.49 KB
765 Bytes
14.1 KB
14.5 KB
14 KB
14.4 KB
2.73 KB
2.03 KB
915 Bytes
1.38 KB
1.62 KB
702 Bytes
2.85 KB
1.4 KB
14.5 KB
1.15 KB
974 Bytes
469 Bytes
2.97 KB
1.22 KB
414 Bytes
931 Bytes
7.73 KB
1.7 KB
252 Bytes
114 Bytes
414 Bytes
306 Bytes
440 Bytes
444 Bytes
1.38 KB
208 KB
975 Bytes
8.58 KB
818 Bytes
322 Bytes
758 Bytes
903 Bytes
1.8 KB
2.02 KB
773 Bytes
1.86 KB
652 Bytes
1014 Bytes
863 Bytes
37.1 KB
6.33 KB
2.84 KB
2.39 KB
5.84 KB
5.44 KB
5.18 KB
968 Bytes
15.7 KB
16.6 KB
15.8 KB
16.3 KB
3.11 KB
2.44 KB
1.07 KB
1.89 KB
1.99 KB
855 Bytes
3.58 KB
1.21 KB
16.6 KB
1.36 KB
705 Bytes
1.08 KB
517 Bytes
3.73 KB
1.31 KB
705 Bytes
459 Bytes
831 Bytes
7.52 KB
2.04 KB
152 Bytes
555 Bytes
130 Bytes
212 Bytes
1.38 KB
272 KB
1.07 KB
9.28 KB
917 Bytes
370 Bytes
793 Bytes
1.01 KB
1.9 KB
2.15 KB
777 Bytes
1.97 KB
747 Bytes
1.19 KB
979 Bytes
468 Bytes
119 KB
9.53 KB
2.34 KB
2.16 KB
3.96 KB
11.2 KB
10.6 KB
1.79 KB
30.6 KB
31.9 KB
31.9 KB
30.5 KB
31.4 KB
6.3 KB
4.66 KB
1.85 KB
3.54 KB
3.79 KB
1.49 KB
6.98 KB
3.51 KB
32 KB
2.61 KB
1.17 KB
2.09 KB
1002 Bytes
7.3 KB
2.81 KB
1.17 KB
776 Bytes
1.92 KB
23.2 KB
3.71 KB
427 Bytes
854 Bytes
207 Bytes
501 Bytes
384 Bytes
723 Bytes
636 Bytes
3.01 KB
633 KB
2.04 KB
23.4 KB
1.8 KB
725 Bytes
1.39 KB
1.84 KB
3.74 KB
4.42 KB
1.51 KB
3.91 KB
1.29 KB
2.33 KB
1.85 KB
877 Bytes
175 KB
18.7 KB
7.72 KB
6.58 KB
17.1 KB
| ... | ... | @@ -26,9 +26,9 @@ |
| 26 | 26 | android:layout_centerVertical="true" |
| 27 | 27 | android:layout_marginLeft="10dp" |
| 28 | 28 | android:layout_toRightOf="@id/back_btn" |
| 29 | - android:drawableRight="@drawable/sport_dropdown" | |
| 30 | 29 | android:drawablePadding="7dp" |
| 31 | 30 | android:text="@string/beijing" |
| 31 | + android:visibility="gone" | |
| 32 | 32 | android:textColor="#333333" |
| 33 | 33 | android:textSize="15sp" /> |
| 34 | 34 | ... | ... |
| ... | ... | @@ -4,10 +4,12 @@ |
| 4 | 4 | <LinearLayout |
| 5 | 5 | android:layout_width="match_parent" |
| 6 | 6 | android:layout_height="match_parent" |
| 7 | + android:background="@color/run_main_bg" | |
| 7 | 8 | android:orientation="vertical"> |
| 8 | 9 | |
| 9 | 10 | <FrameLayout |
| 10 | 11 | android:layout_width="match_parent" |
| 12 | + android:background="@color/run_main_bg" | |
| 11 | 13 | android:layout_height="match_parent"> |
| 12 | 14 | |
| 13 | 15 | <LinearLayout | ... | ... |
| ... | ... | @@ -71,7 +71,7 @@ |
| 71 | 71 | android:id="@+id/scrollView" |
| 72 | 72 | android:layout_width="match_parent" |
| 73 | 73 | android:layout_height="match_parent" |
| 74 | - android:layout_marginTop="40dp" | |
| 74 | + android:paddingTop="40dp" | |
| 75 | 75 | android:scrollbars="none"> |
| 76 | 76 | |
| 77 | 77 | <LinearLayout |
| ... | ... | @@ -151,7 +151,7 @@ |
| 151 | 151 | android:layout_gravity="top" |
| 152 | 152 | android:background="@color/run_main_bg" |
| 153 | 153 | android:gravity="center" |
| 154 | - android:visibility="gone"> | |
| 154 | + android:visibility="invisible"> | |
| 155 | 155 | |
| 156 | 156 | <LinearLayout |
| 157 | 157 | android:id="@+id/ll_top_back" | ... | ... |
| ... | ... | @@ -4,42 +4,43 @@ |
| 4 | 4 | <data> |
| 5 | 5 | |
| 6 | 6 | </data> |
| 7 | + | |
| 7 | 8 | <RelativeLayout |
| 8 | 9 | android:id="@+id/ry_re" |
| 9 | 10 | android:layout_width="match_parent" |
| 10 | 11 | android:layout_height="wrap_content" |
| 11 | - android:background="@drawable/background" | |
| 12 | - android:layout_marginTop="5dp" | |
| 13 | 12 | android:layout_marginLeft="5dp" |
| 13 | + android:layout_marginTop="5dp" | |
| 14 | 14 | android:layout_marginRight="5dp" |
| 15 | + android:background="@drawable/background" | |
| 15 | 16 | android:padding="15dp"> |
| 16 | 17 | |
| 17 | 18 | <TextView |
| 18 | 19 | android:id="@+id/up_day" |
| 19 | 20 | android:layout_width="wrap_content" |
| 20 | 21 | android:layout_height="wrap_content" |
| 22 | + android:text="5月1日" | |
| 21 | 23 | android:textColor="#333333" |
| 22 | - android:textSize="14sp" | |
| 23 | - android:text="5月1日" /> | |
| 24 | + android:textSize="14sp" /> | |
| 24 | 25 | |
| 25 | 26 | <TextView |
| 26 | 27 | android:id="@+id/up_record_time" |
| 27 | 28 | android:layout_width="wrap_content" |
| 28 | 29 | android:layout_height="wrap_content" |
| 29 | - android:layout_toRightOf="@id/up_day" | |
| 30 | 30 | android:layout_marginLeft="15dp" |
| 31 | + android:layout_toRightOf="@id/up_day" | |
| 32 | + android:text="15:30" | |
| 31 | 33 | android:textColor="#999999" |
| 32 | - android:textSize="14sp" | |
| 33 | - android:text="15:30" /> | |
| 34 | + android:textSize="14sp" /> | |
| 34 | 35 | |
| 35 | 36 | <TextView |
| 36 | 37 | android:layout_width="wrap_content" |
| 37 | 38 | android:layout_height="wrap_content" |
| 39 | + android:layout_alignParentRight="true" | |
| 38 | 40 | android:layout_marginRight="10dp" |
| 39 | - android:textColor="#FE4E4E" | |
| 40 | - android:textSize="12sp" | |
| 41 | 41 | android:text="@string/up_fail" |
| 42 | - android:layout_alignParentRight="true"/> | |
| 42 | + android:textColor="#FE4E4E" | |
| 43 | + android:textSize="12sp" /> | |
| 43 | 44 | |
| 44 | 45 | <LinearLayout |
| 45 | 46 | android:id="@+id/ly" |
| ... | ... | @@ -52,10 +53,10 @@ |
| 52 | 53 | android:id="@+id/up_item_img" |
| 53 | 54 | android:layout_width="80dp" |
| 54 | 55 | android:layout_height="80dp" |
| 55 | - android:scaleType="fitXY" | |
| 56 | - android:visibility="gone" | |
| 57 | 56 | android:layout_gravity="center_vertical" |
| 58 | - android:src="@drawable/defaults" /> | |
| 57 | + android:scaleType="fitXY" | |
| 58 | + android:src="@drawable/defaults" | |
| 59 | + android:visibility="gone" /> | |
| 59 | 60 | |
| 60 | 61 | <RelativeLayout |
| 61 | 62 | android:layout_width="match_parent" |
| ... | ... | @@ -67,31 +68,31 @@ |
| 67 | 68 | android:layout_width="wrap_content" |
| 68 | 69 | android:layout_height="wrap_content" |
| 69 | 70 | android:singleLine="true" |
| 70 | - android:textSize="12sp" | |
| 71 | - android:textColor="#333333"/> | |
| 71 | + android:textColor="#333333" | |
| 72 | + android:textSize="12sp" /> | |
| 72 | 73 | |
| 73 | 74 | <LinearLayout |
| 74 | 75 | android:layout_width="wrap_content" |
| 75 | 76 | android:layout_height="wrap_content" |
| 76 | 77 | android:layout_centerVertical="true" |
| 77 | 78 | android:orientation="horizontal"> |
| 79 | + | |
| 78 | 80 | <TextView |
| 79 | 81 | android:id="@+id/up_kilometer_num" |
| 80 | 82 | android:layout_width="wrap_content" |
| 81 | 83 | android:layout_height="wrap_content" |
| 82 | - android:textColor="#333333" | |
| 83 | - android:textSize="30sp" | |
| 84 | 84 | android:layout_centerVertical="true" |
| 85 | - /> | |
| 85 | + android:textColor="#333333" | |
| 86 | + android:textSize="30sp" /> | |
| 86 | 87 | |
| 87 | 88 | <TextView |
| 88 | 89 | android:layout_width="wrap_content" |
| 89 | 90 | android:layout_height="wrap_content" |
| 90 | 91 | android:layout_centerVertical="true" |
| 92 | + android:layout_marginLeft="5dp" | |
| 91 | 93 | android:text="@string/kilometer" |
| 92 | 94 | android:textColor="#333333" |
| 93 | - android:textSize="12sp" | |
| 94 | - android:layout_marginLeft="5dp"/> | |
| 95 | + android:textSize="12sp" /> | |
| 95 | 96 | </LinearLayout> |
| 96 | 97 | |
| 97 | 98 | |
| ... | ... | @@ -107,7 +108,7 @@ |
| 107 | 108 | android:drawableRight="@drawable/time_cost" |
| 108 | 109 | android:drawablePadding="5dp" |
| 109 | 110 | android:textColor="#333333" |
| 110 | - android:textSize="13sp"/> | |
| 111 | + android:textSize="13sp" /> | |
| 111 | 112 | |
| 112 | 113 | <TextView |
| 113 | 114 | android:id="@+id/up_record_speed" |
| ... | ... | @@ -117,7 +118,7 @@ |
| 117 | 118 | android:drawableRight="@drawable/speed" |
| 118 | 119 | android:drawablePadding="5dp" |
| 119 | 120 | android:textColor="#333333" |
| 120 | - android:textSize="13sp"/> | |
| 121 | + android:textSize="13sp" /> | |
| 121 | 122 | |
| 122 | 123 | <TextView |
| 123 | 124 | android:id="@+id/up_record_step" |
| ... | ... | @@ -125,7 +126,7 @@ |
| 125 | 126 | android:layout_height="wrap_content" |
| 126 | 127 | android:layout_marginLeft="20dp" |
| 127 | 128 | android:drawableRight="@drawable/step" |
| 128 | - android:drawablePadding="5dp"/> | |
| 129 | + android:drawablePadding="5dp" /> | |
| 129 | 130 | </LinearLayout> |
| 130 | 131 | </RelativeLayout> |
| 131 | 132 | </LinearLayout> |
| ... | ... | @@ -134,26 +135,45 @@ |
| 134 | 135 | android:id="@+id/view" |
| 135 | 136 | android:layout_width="match_parent" |
| 136 | 137 | android:layout_height="1dp" |
| 137 | - android:background="@color/line" | |
| 138 | 138 | android:layout_below="@id/ly" |
| 139 | - /> | |
| 139 | + android:background="@color/line" /> | |
| 140 | 140 | |
| 141 | - <TextView | |
| 142 | - android:id="@+id/again_up" | |
| 143 | - android:layout_width="wrap_content" | |
| 141 | + <LinearLayout | |
| 142 | + android:layout_width="match_parent" | |
| 144 | 143 | android:layout_height="wrap_content" |
| 145 | - android:layout_alignParentRight="true" | |
| 146 | 144 | android:layout_below="@id/view" |
| 147 | 145 | android:layout_marginTop="10dp" |
| 148 | 146 | android:layout_marginRight="5dp" |
| 149 | - android:background="@drawable/green_raduis_bg" | |
| 150 | - android:text="@string/again_up" | |
| 151 | - android:textColor="#36C28D" | |
| 152 | - android:textSize="12sp" | |
| 153 | - android:paddingTop="7dp" | |
| 154 | - android:paddingBottom="7dp" | |
| 155 | - android:paddingRight="10dp" | |
| 156 | - android:paddingLeft="10dp" | |
| 157 | - /> | |
| 147 | + android:gravity="center|right"> | |
| 148 | + | |
| 149 | + <TextView | |
| 150 | + android:id="@+id/again_up" | |
| 151 | + android:layout_width="wrap_content" | |
| 152 | + android:layout_height="wrap_content" | |
| 153 | + android:layout_alignParentRight="true" | |
| 154 | + android:layout_marginRight="15dp" | |
| 155 | + android:background="@drawable/green_raduis_bg" | |
| 156 | + android:paddingLeft="10dp" | |
| 157 | + android:paddingTop="7dp" | |
| 158 | + android:paddingRight="10dp" | |
| 159 | + android:paddingBottom="7dp" | |
| 160 | + android:text="@string/again_up" | |
| 161 | + android:textColor="#36C28D" | |
| 162 | + android:textSize="12sp" /> | |
| 163 | + | |
| 164 | + <TextView | |
| 165 | + android:id="@+id/tv_delete" | |
| 166 | + android:layout_width="wrap_content" | |
| 167 | + android:layout_height="wrap_content" | |
| 168 | + android:layout_alignParentRight="true" | |
| 169 | + android:background="@drawable/green_raduis_bg" | |
| 170 | + android:paddingLeft="10dp" | |
| 171 | + android:paddingTop="7dp" | |
| 172 | + android:paddingRight="10dp" | |
| 173 | + android:paddingBottom="7dp" | |
| 174 | + android:text="@string/delete" | |
| 175 | + android:textColor="#36C28D" | |
| 176 | + android:textSize="12sp" /> | |
| 177 | + </LinearLayout> | |
| 158 | 178 | </RelativeLayout> |
| 159 | 179 | </layout> | ... | ... |
| ... | ... | @@ -68,7 +68,7 @@ |
| 68 | 68 | <string name="loc_gps_accuracy_mid">GPS信号质量中等</string> |
| 69 | 69 | <string name="loc_gps_accuracy_good">GPS信号质量好</string> |
| 70 | 70 | <string name="layout_street_active_type">活动类型</string> |
| 71 | - <string name="open_gps_tip">请开启GPS饼将其设置为高精度模式!</string> | |
| 71 | + <string name="open_gps_tip">请开启GPS,将其设置为高精度模式!</string> | |
| 72 | 72 | <!----> |
| 73 | 73 | <!--网络请求--> |
| 74 | 74 | <string name="retry">重试</string> |
| ... | ... | @@ -78,10 +78,11 @@ |
| 78 | 78 | <string name="finish">完成</string> |
| 79 | 79 | <string name="no_finish">未完成</string> |
| 80 | 80 | <string name="again_up">重新上传</string> |
| 81 | + <string name="delete">删 除</string> | |
| 81 | 82 | <string name="myrecord">我的记录</string> |
| 82 | 83 | <string name="up_fail">上传失败</string> |
| 83 | 84 | <string name="enter_range_tip">您已回归轨迹继续参与运动吧</string> |
| 84 | - <string name="exit_range_tip">您已偏离路径轨迹请您计时回归路径</string> | |
| 85 | + <string name="exit_range_tip">您已偏离路径轨迹请您及时回归路径</string> | |
| 85 | 86 | <string name="more_than_pause_count_tip">您已超过最大暂停次数,无法继续比赛</string> |
| 86 | 87 | <string name="run_pause_tip">固定赛事只可暂停一次\n是否确定使用?</string> |
| 87 | 88 | <string name="add_path">添加轨迹</string> | ... | ... |