Commit cde055503e47a996ddba1f6fd8b034607e612c13
1 parent
c754427c
1.修复倒计时显示异常
Showing
7 changed files
with
45 additions
and
34 deletions
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/commonInfo/CommonInfo.java
| ... | ... | @@ -232,29 +232,26 @@ public class CommonInfo { |
| 232 | 232 | */ |
| 233 | 233 | public static String getUserIcon(Context context) { |
| 234 | 234 | return MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).getString("RunUserNickIcon", ""); |
| 235 | - public static String getUserNickName(Context context) { | |
| 236 | - return MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).getString("RunUserNickName", ""); | |
| 237 | 235 | |
| 238 | 236 | } |
| 239 | 237 | |
| 240 | 238 | /** |
| 241 | - * 设置用户头像 | |
| 239 | + * 是否第一次显示倒计时动画 | |
| 242 | 240 | * |
| 243 | 241 | * @param context |
| 242 | + * @param isAllow | |
| 244 | 243 | */ |
| 245 | - public static void setUserFaceUrl(Context context, String faceUrl) { | |
| 246 | - MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).putString("RunUserFaceUrl", faceUrl); | |
| 247 | - | |
| 244 | + public static void setIsFirstShowTimeTip(Context context, boolean isAllow) { | |
| 245 | + MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).putBoolean("IsFirstShowTimeTip", isAllow); | |
| 248 | 246 | } |
| 249 | 247 | |
| 250 | 248 | /** |
| 251 | - * 获取用户头像 | |
| 249 | + * 是否第一次显示倒计时动画 | |
| 252 | 250 | * |
| 253 | 251 | * @param context |
| 254 | 252 | */ |
| 255 | - public static String getUserFaceUrl(Context context) { | |
| 256 | - return MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).getString("RunUserFaceUrl", ""); | |
| 257 | - | |
| 253 | + public static boolean getIsFirstShowTimeTip(Context context) { | |
| 254 | + return MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).getBoolean("IsFirstShowTimeTip", true); | |
| 258 | 255 | } |
| 259 | 256 | |
| 260 | 257 | |
| ... | ... | @@ -269,9 +266,18 @@ public class CommonInfo { |
| 269 | 266 | MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).removeKey("streetId"); |
| 270 | 267 | MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).removeKey("FirstStepSendTraceTip"); |
| 271 | 268 | MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).removeKey("FenceId"); |
| 272 | - | |
| 273 | - | |
| 269 | + MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).removeKey("IsFirstShowTimeTip"); | |
| 274 | 270 | } |
| 275 | 271 | |
| 276 | - | |
| 272 | + /*重置赛事 | |
| 273 | + * @param context | |
| 274 | + */ | |
| 275 | + public static void resetRace(Context context) { | |
| 276 | + MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).removeKey("writeUserStep"); | |
| 277 | + MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).removeKey("runStepService"); | |
| 278 | + MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).removeKey("KeepAliveService"); | |
| 279 | + MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).removeKey("RunBaiduTraceService"); | |
| 280 | + MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).removeKey("FirstStepSendTraceTip"); | |
| 281 | + MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).removeKey("IsFirstShowTimeTip"); | |
| 282 | + } | |
| 277 | 283 | } | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/frame/view/RunMainFragmentView.java
| ... | ... | @@ -117,7 +117,6 @@ public class RunMainFragmentView implements MvpView { |
| 117 | 117 | */ |
| 118 | 118 | public void initView() { |
| 119 | 119 | uid = CommonInfo.getUserId(getContext()); |
| 120 | - UserStepEntity userStepEntity = StepUtil.getUserStepData(getContext(), uid); | |
| 121 | 120 | initLocationClient(); |
| 122 | 121 | fragment.binding.llRunMainRoot.setVisibility(View.GONE); |
| 123 | 122 | ButtonAnimUtil.startAnimation(fragment.binding.llStartTimeTip, false); |
| ... | ... | @@ -177,12 +176,14 @@ public class RunMainFragmentView implements MvpView { |
| 177 | 176 | |
| 178 | 177 | } |
| 179 | 178 | }); |
| 180 | - | |
| 179 | + boolean isFirstShowTime = CommonInfo.getIsFirstShowTimeTip(getContext()); | |
| 181 | 180 | //当前用户已经在运动 |
| 182 | - if (userStepEntity == null) { | |
| 181 | + if (isFirstShowTime) { | |
| 183 | 182 | //依次倒计时 |
| 184 | 183 | handler.postDelayed(runnable, 1000); |
| 184 | + CommonInfo.setIsFirstShowTimeTip(getContext(), false); | |
| 185 | 185 | } else { |
| 186 | + UserStepEntity userStepEntity = StepUtil.getUserStepData(getContext(), uid); | |
| 186 | 187 | //隐藏计时界面 |
| 187 | 188 | fragment.binding.llStartTimeTip.setVisibility(View.GONE); |
| 188 | 189 | fragment.binding.llRunMainRoot.setVisibility(View.VISIBLE); | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/frame/view/RunRaceDetailFragmentView.java
| ... | ... | @@ -403,6 +403,8 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener { |
| 403 | 403 | StepUtil.clearRunData(getContext(), CommonInfo.getUserId(getContext())); |
| 404 | 404 | //停止服务 |
| 405 | 405 | stopStepService(); |
| 406 | + //清除数据 | |
| 407 | + CommonInfo.resetRace(getContext()); | |
| 406 | 408 | //更改当前按钮 |
| 407 | 409 | fragment.binding.tvRunNow.setText("立即开始"); |
| 408 | 410 | fragment.binding.rlScrollViewStartBtn.setTag("1"); | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/frame/view/RunningFinishFragmentView.java
| ... | ... | @@ -27,7 +27,7 @@ public class RunningFinishFragmentView implements MvpView { |
| 27 | 27 | |
| 28 | 28 | public void initView(RunningFinishBean runningFinishBean) { |
| 29 | 29 | //设置用户头像 |
| 30 | - String faceUrl = CommonInfo.getUserFaceUrl(getContext()); | |
| 30 | + String faceUrl = CommonInfo.getUserIcon(getContext()); | |
| 31 | 31 | if (!TextUtils.isEmpty(faceUrl)) { |
| 32 | 32 | Glide.with(getContext()).load(faceUrl).into(fragment.binding.includeFinishUserInfo.qmIvIcon); |
| 33 | 33 | } | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/sql/dao/DaoMaster.java
| ... | ... | @@ -21,14 +21,14 @@ public class DaoMaster extends AbstractDaoMaster { |
| 21 | 21 | |
| 22 | 22 | /** Creates underlying database table using DAOs. */ |
| 23 | 23 | public static void createAllTables(Database db, boolean ifNotExists) { |
| 24 | - UserStepEntityDao.createTable(db, ifNotExists); | |
| 25 | 24 | CollUserStepEntityDao.createTable(db, ifNotExists); |
| 25 | + UserStepEntityDao.createTable(db, ifNotExists); | |
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | /** Drops underlying database table using DAOs. */ |
| 29 | 29 | public static void dropAllTables(Database db, boolean ifExists) { |
| 30 | - UserStepEntityDao.dropTable(db, ifExists); | |
| 31 | 30 | CollUserStepEntityDao.dropTable(db, ifExists); |
| 31 | + UserStepEntityDao.dropTable(db, ifExists); | |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | /** |
| ... | ... | @@ -47,8 +47,8 @@ public class DaoMaster extends AbstractDaoMaster { |
| 47 | 47 | |
| 48 | 48 | public DaoMaster(Database db) { |
| 49 | 49 | super(db, SCHEMA_VERSION); |
| 50 | - registerDaoClass(UserStepEntityDao.class); | |
| 51 | 50 | registerDaoClass(CollUserStepEntityDao.class); |
| 51 | + registerDaoClass(UserStepEntityDao.class); | |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | public DaoSession newSession() { | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/sql/dao/DaoSession.java
| ... | ... | @@ -8,11 +8,11 @@ import org.greenrobot.greendao.database.Database; |
| 8 | 8 | import org.greenrobot.greendao.identityscope.IdentityScopeType; |
| 9 | 9 | import org.greenrobot.greendao.internal.DaoConfig; |
| 10 | 10 | |
| 11 | -import com.cnlive.moudle.pedometer.sql.entity.UserStepEntity; | |
| 12 | 11 | import com.cnlive.moudle.pedometer.sql.entity.CollUserStepEntity; |
| 12 | +import com.cnlive.moudle.pedometer.sql.entity.UserStepEntity; | |
| 13 | 13 | |
| 14 | -import com.cnlive.moudle.pedometer.sql.dao.UserStepEntityDao; | |
| 15 | 14 | import com.cnlive.moudle.pedometer.sql.dao.CollUserStepEntityDao; |
| 15 | +import com.cnlive.moudle.pedometer.sql.dao.UserStepEntityDao; | |
| 16 | 16 | |
| 17 | 17 | // THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. |
| 18 | 18 | |
| ... | ... | @@ -23,40 +23,40 @@ import com.cnlive.moudle.pedometer.sql.dao.CollUserStepEntityDao; |
| 23 | 23 | */ |
| 24 | 24 | public class DaoSession extends AbstractDaoSession { |
| 25 | 25 | |
| 26 | - private final DaoConfig userStepEntityDaoConfig; | |
| 27 | 26 | private final DaoConfig collUserStepEntityDaoConfig; |
| 27 | + private final DaoConfig userStepEntityDaoConfig; | |
| 28 | 28 | |
| 29 | - private final UserStepEntityDao userStepEntityDao; | |
| 30 | 29 | private final CollUserStepEntityDao collUserStepEntityDao; |
| 30 | + private final UserStepEntityDao userStepEntityDao; | |
| 31 | 31 | |
| 32 | 32 | public DaoSession(Database db, IdentityScopeType type, Map<Class<? extends AbstractDao<?, ?>>, DaoConfig> |
| 33 | 33 | daoConfigMap) { |
| 34 | 34 | super(db); |
| 35 | 35 | |
| 36 | - userStepEntityDaoConfig = daoConfigMap.get(UserStepEntityDao.class).clone(); | |
| 37 | - userStepEntityDaoConfig.initIdentityScope(type); | |
| 38 | - | |
| 39 | 36 | collUserStepEntityDaoConfig = daoConfigMap.get(CollUserStepEntityDao.class).clone(); |
| 40 | 37 | collUserStepEntityDaoConfig.initIdentityScope(type); |
| 41 | 38 | |
| 42 | - userStepEntityDao = new UserStepEntityDao(userStepEntityDaoConfig, this); | |
| 39 | + userStepEntityDaoConfig = daoConfigMap.get(UserStepEntityDao.class).clone(); | |
| 40 | + userStepEntityDaoConfig.initIdentityScope(type); | |
| 41 | + | |
| 43 | 42 | collUserStepEntityDao = new CollUserStepEntityDao(collUserStepEntityDaoConfig, this); |
| 43 | + userStepEntityDao = new UserStepEntityDao(userStepEntityDaoConfig, this); | |
| 44 | 44 | |
| 45 | - registerDao(UserStepEntity.class, userStepEntityDao); | |
| 46 | 45 | registerDao(CollUserStepEntity.class, collUserStepEntityDao); |
| 46 | + registerDao(UserStepEntity.class, userStepEntityDao); | |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | public void clear() { |
| 50 | - userStepEntityDaoConfig.clearIdentityScope(); | |
| 51 | 50 | collUserStepEntityDaoConfig.clearIdentityScope(); |
| 52 | - } | |
| 53 | - | |
| 54 | - public UserStepEntityDao getUserStepEntityDao() { | |
| 55 | - return userStepEntityDao; | |
| 51 | + userStepEntityDaoConfig.clearIdentityScope(); | |
| 56 | 52 | } |
| 57 | 53 | |
| 58 | 54 | public CollUserStepEntityDao getCollUserStepEntityDao() { |
| 59 | 55 | return collUserStepEntityDao; |
| 60 | 56 | } |
| 61 | 57 | |
| 58 | + public UserStepEntityDao getUserStepEntityDao() { | |
| 59 | + return userStepEntityDao; | |
| 60 | + } | |
| 61 | + | |
| 62 | 62 | } | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/ui/activity/RunLineActivity.java