Commit 5520a4b27df178a212e405aeaad6b3bbda41cd3d

Authored by Dinh Chu
1 parent 13594f58ae
Exists in master and in 1 other branch development

update

Showing 17 changed files with 401 additions and 88 deletions Side-by-side Diff

1 1 <?xml version="1.0" encoding="UTF-8"?>
2 2 <project version="4">
3   - <component name="EntryPointsManager">
4   - <entry_points version="2.0" />
5   - </component>
6 3 <component name="NullableNotNullManager">
7 4 <option name="myDefaultNullable" value="android.support.annotation.Nullable" />
8 5 <option name="myDefaultNotNull" value="android.support.annotation.NonNull" />
... ... @@ -27,17 +24,7 @@
27 24 </value>
28 25 </option>
29 26 </component>
30   - <component name="ProjectLevelVcsManager" settingsEditedManually="false">
31   - <OptionsSetting value="true" id="Add" />
32   - <OptionsSetting value="true" id="Remove" />
33   - <OptionsSetting value="true" id="Checkout" />
34   - <OptionsSetting value="true" id="Update" />
35   - <OptionsSetting value="true" id="Status" />
36   - <OptionsSetting value="true" id="Edit" />
37   - <ConfirmationsSetting value="0" id="Add" />
38   - <ConfirmationsSetting value="0" id="Remove" />
39   - </component>
40   - <component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
  27 + <component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
41 28 <output url="file://$PROJECT_DIR$/build/classes" />
42 29 </component>
43 30 <component name="ProjectType">
... ... @@ -4,7 +4,7 @@
4 4 <modules>
5 5 <module fileurl="file://$PROJECT_DIR$/app/app.iml" filepath="$PROJECT_DIR$/app/app.iml" />
6 6 <module fileurl="file://$PROJECT_DIR$/lifelog_android.iml" filepath="$PROJECT_DIR$/lifelog_android.iml" />
7   - <module fileurl="file://$PROJECT_DIR$/lifelogpedometer.iml" filepath="$PROJECT_DIR$/lifelogpedometer.iml" />
  7 + <module fileurl="file://D:\Project\Git\lifelog_android\lifelogpedometer.iml" filepath="D:\Project\Git\lifelog_android\lifelogpedometer.iml" />
8 8 </modules>
9 9 </component>
10 10 </project>
... ... @@ -2,7 +2,7 @@
2 2  
3 3 android {
4 4 compileSdkVersion 25
5   - buildToolsVersion "25.0.3"
  5 + buildToolsVersion '26.0.2'
6 6 defaultConfig {
7 7 applicationId "com.dinhcv.lifelogpedometer"
8 8 minSdkVersion 19
... ... @@ -13,6 +13,9 @@
13 13 // Enabling multidex support.
14 14 multiDexEnabled true
15 15 }
  16 +
  17 + flavorDimensions "default"
  18 +
16 19 buildTypes {
17 20 release {
18 21 minifyEnabled false
app/src/main/java/com/dinhcv/lifelogpedometer/activity/HistoryContentFragment.java
... ... @@ -17,6 +17,7 @@
17 17 import com.dinhcv.lifelogpedometer.R;
18 18 import com.dinhcv.lifelogpedometer.interfaces.LLAPIManagerListener;
19 19 import com.dinhcv.lifelogpedometer.model.structure.history.HistoryInfo;
  20 +import com.dinhcv.lifelogpedometer.portal.ApiServices;
20 21 import com.dinhcv.lifelogpedometer.portal.LLAPIManager;
21 22 import com.dinhcv.lifelogpedometer.utils.Const;
22 23 import com.dinhcv.lifelogpedometer.utils.DayAxisValueFormatter;
... ... @@ -228,7 +229,7 @@
228 229 Date fromDate = Utils.getFromDate(mAnaDate, dataType);
229 230  
230 231 showDialog(mContext);
231   - LLAPIManager.history(fromDate, toDate, new LLAPIManagerListener() {
  232 + ApiServices.history(fromDate, toDate, new LLAPIManagerListener() {
232 233 @Override
233 234 public void onError(Error error) {
234 235 Debug.error("Get data history error");
app/src/main/java/com/dinhcv/lifelogpedometer/activity/HistoryDetailFragment.java
... ... @@ -20,6 +20,7 @@
20 20 import com.dinhcv.lifelogpedometer.interfaces.LLAPIManagerListener;
21 21 import com.dinhcv.lifelogpedometer.model.structure.history.HistoryInfo;
22 22 import com.dinhcv.lifelogpedometer.model.structure.history.HistoryItemInfo;
  23 +import com.dinhcv.lifelogpedometer.portal.ApiServices;
23 24 import com.dinhcv.lifelogpedometer.portal.LLAPIManager;
24 25 import com.dinhcv.lifelogpedometer.utils.Const;
25 26 import com.dinhcv.lifelogpedometer.utils.Debug;
... ... @@ -200,7 +201,7 @@
200 201 Date fromDate = Utils.getFromDate(mAnaDate, dataType);
201 202  
202 203 showDialog(mContext);
203   - LLAPIManager.historyDetail(fromDate, toDate, new LLAPIManagerListener() {
  204 + ApiServices.historyDetail(fromDate, toDate, new LLAPIManagerListener() {
204 205 @Override
205 206 public void onError(Error error) {
206 207 Debug.error("Get data history error");
app/src/main/java/com/dinhcv/lifelogpedometer/activity/InputConfirmCodeActivity.java
... ... @@ -13,6 +13,7 @@
13 13 import com.dinhcv.lifelogpedometer.R;
14 14 import com.dinhcv.lifelogpedometer.interfaces.LLAPIManagerListener;
15 15 import com.dinhcv.lifelogpedometer.model.Shareprefer.Setting;
  16 +import com.dinhcv.lifelogpedometer.portal.ApiServices;
16 17 import com.dinhcv.lifelogpedometer.portal.LLAPIManager;
17 18 import com.dinhcv.lifelogpedometer.utils.Const;
18 19 import com.dinhcv.lifelogpedometer.utils.Debug;
... ... @@ -60,7 +61,7 @@
60 61 progressDialog.setCancelable(false);
61 62 progressDialog.show();
62 63  
63   - LLAPIManager.forgetPassConfirm(mEmail, code, new LLAPIManagerListener() {
  64 + ApiServices.forgetPassConfirm(mEmail, code, new LLAPIManagerListener() {
64 65 @Override
65 66 public void onError(Error error) {
66 67 progressDialog.dismiss();
app/src/main/java/com/dinhcv/lifelogpedometer/activity/LoginActivity.java
... ... @@ -13,6 +13,7 @@
13 13 import com.dinhcv.lifelogpedometer.R;
14 14 import com.dinhcv.lifelogpedometer.interfaces.LLAPIManagerListener;
15 15 import com.dinhcv.lifelogpedometer.model.Shareprefer.Setting;
  16 +import com.dinhcv.lifelogpedometer.portal.ApiServices;
16 17 import com.dinhcv.lifelogpedometer.portal.LLAPIManager;
17 18 import com.dinhcv.lifelogpedometer.utils.Const;
18 19 import com.dinhcv.lifelogpedometer.utils.Debug;
... ... @@ -84,7 +85,7 @@
84 85 progressDialog.setCancelable(false);
85 86 progressDialog.show();
86 87  
87   - LLAPIManager.login(LoginActivity.this, user, pass, new LLAPIManagerListener() {
  88 + ApiServices.login(LoginActivity.this, user, pass, new LLAPIManagerListener() {
88 89 @Override
89 90 public void onError(Error error) {
90 91 progressDialog.dismiss();
... ... @@ -130,7 +131,7 @@
130 131 progressDialog.setCancelable(false);
131 132 progressDialog.show();
132 133  
133   - LLAPIManager.forgetPass(email, new LLAPIManagerListener() {
  134 + ApiServices.forgetPass(email, new LLAPIManagerListener() {
134 135 @Override
135 136 public void onError(Error error) {
136 137 progressDialog.dismiss();
app/src/main/java/com/dinhcv/lifelogpedometer/activity/RegisterActivity.java
... ... @@ -26,6 +26,7 @@
26 26 import com.dinhcv.lifelogpedometer.model.Shareprefer.Setting;
27 27 import com.dinhcv.lifelogpedometer.model.structure.RegisterInfo;
28 28 import com.dinhcv.lifelogpedometer.model.structure.SelectItemInfo;
  29 +import com.dinhcv.lifelogpedometer.portal.ApiServices;
29 30 import com.dinhcv.lifelogpedometer.portal.LLAPIManager;
30 31 import com.dinhcv.lifelogpedometer.utils.Debug;
31 32 import com.dinhcv.lifelogpedometer.utils.Utils;
... ... @@ -261,7 +262,7 @@
261 262 progressDialog.setCancelable(false);
262 263 progressDialog.show();
263 264  
264   - LLAPIManager.register(mRegisterInfo, new LLAPIManagerListener() {
  265 + ApiServices.register(mRegisterInfo, new LLAPIManagerListener() {
265 266 @Override
266 267 public void onError(Error error) {
267 268 progressDialog.dismiss();
... ... @@ -310,7 +311,7 @@
310 311 progressDialog.setCancelable(false);
311 312 progressDialog.show();
312 313  
313   - LLAPIManager.uploadImage(bitmap, new LLAPIManagerListener() {
  314 + ApiServices.uploadImage(bitmap, new LLAPIManagerListener() {
314 315 @Override
315 316 public void onError(Error error) {
316 317 progressDialog.dismiss();
app/src/main/java/com/dinhcv/lifelogpedometer/activity/TopDateFragment.java
... ... @@ -19,6 +19,7 @@
19 19 import com.dinhcv.lifelogpedometer.interfaces.LLAPIManagerListener;
20 20 import com.dinhcv.lifelogpedometer.model.structure.home.NoticeInfo;
21 21 import com.dinhcv.lifelogpedometer.model.structure.home.TagetInfo;
  22 +import com.dinhcv.lifelogpedometer.portal.ApiServices;
22 23 import com.dinhcv.lifelogpedometer.portal.LLAPIManager;
23 24 import com.dinhcv.lifelogpedometer.utils.Const;
24 25 import com.dinhcv.lifelogpedometer.utils.Debug;
... ... @@ -114,6 +115,7 @@
114 115 tvDate.setText(Utils.dateToStringFormatDayMonthYearJp(date));
115 116 mAnaDate = date;
116 117 getHomePage(mAnaDate, stepType);
  118 + getNews(mAnaDate);
117 119 }
118 120 });
119 121  
... ... @@ -127,6 +129,7 @@
127 129 tvDate.setText(Utils.dateToStringFormatDayMonthYearJp(date));
128 130 mAnaDate = date;
129 131 getHomePage(mAnaDate, stepType);
  132 + getNews(mAnaDate);
130 133 }
131 134 });
132 135  
... ... @@ -195,6 +198,7 @@
195 198 mAnaDate = date;
196 199  
197 200 getHomePage(mAnaDate, stepType);
  201 + getNews(mAnaDate);
198 202 }
199 203 }, mAnaYear, mAnaMonth, mAnaDay).show();
200 204  
201 205  
... ... @@ -217,13 +221,14 @@
217 221 stepType = Const.STEP_TYPE.WALKING;
218 222 updateUiStepType(false, true, false);
219 223 getHomePage(mAnaDate, stepType);
  224 + getNews(mAnaDate);
220 225 }
221 226  
222 227  
223 228 private void getHomePage(Date date, Const.STEP_TYPE stepType){
224 229  
225 230 showDialog(mContext);
226   - LLAPIManager.homePage(date, stepType, new LLAPIManagerListener() {
  231 + ApiServices.homePage(date, stepType, new LLAPIManagerListener() {
227 232 @Override
228 233 public void onError(Error error) {
229 234 Debug.error("Get data history error");
230 235  
231 236  
232 237  
233 238  
... ... @@ -296,17 +301,70 @@
296 301 tvStep.setText(String.valueOf(mTagetInfo.getSteps()));
297 302 tvRemain.setText(String.valueOf(mTagetInfo.getStepRemain()));
298 303 tvRateDone.setText(mContext.getResources().getString(R.string.percent_unit, mTagetInfo.getCompletePercent()));
  304 + }
299 305  
300   - List<NoticeInfo> infoLists = mTagetInfo.getNoticeList();
301   - if (infoLists != null && infoLists.size() >0){
302   - mNoticeAdapter = new NoticeAdapter(mContext, infoLists);
  306 + private void getNews(Date date){
  307 +
  308 + ApiServices.getNews(date, new LLAPIManagerListener() {
  309 + @Override
  310 + public void onError(Error error) {
  311 + Debug.error("Get data news error");
  312 + }
  313 +
  314 + @Override
  315 + public void onSuccess(String json) {
  316 + Debug.error("Get data news success");
  317 + loadNewsDone(json);
  318 + }
  319 +
  320 + @Override
  321 + public void onSuccess(JSONObject object) {
  322 + Debug.error("Get data news success");
  323 + }
  324 + });
  325 + }
  326 +
  327 + private void loadNewsDone(String jsonString) {
  328 +
  329 + List<NoticeInfo> contentList = new ArrayList<>();
  330 + JSONObject jsonObject = null;
  331 + try {
  332 + jsonObject = new JSONObject(jsonString);
  333 + int status = jsonObject.optInt("status");
  334 + if (status == 1) {
  335 + JSONObject jsonResult = jsonObject.optJSONObject("result");
  336 + JSONArray listNotice = jsonResult.getJSONArray("listNotice");
  337 +
  338 + if (listNotice != null) {
  339 +
  340 + for (int i = 0; i < listNotice.length(); i++) {
  341 + JSONObject obContent = (JSONObject) listNotice.get(i);
  342 + String content = obContent.optString("notice_content");
  343 + Debug.normal("Content: " + content);
  344 + contentList.add(new NoticeInfo(i+1,content));
  345 + }
  346 + }
  347 +
  348 + }
  349 + } catch (JSONException e) {
  350 + e.printStackTrace();
  351 + }
  352 +
  353 + addNews(contentList);
  354 + }
  355 +
  356 + private void addNews(List<NoticeInfo> noticeInfos){
  357 + if (noticeInfos != null && noticeInfos.size() >0){
  358 + mNoticeAdapter = new NoticeAdapter(mContext, noticeInfos);
303 359 lvNotice.setAdapter(mNoticeAdapter);
304 360 lvNotice.setExpanded(true);
  361 + }else {
  362 + lvNotice.setAdapter(null);
305 363 }
306   -
307 364 }
308 365  
309 366  
  367 +
310 368 @Override
311 369 public void onAttach(Context context) {
312 370 super.onAttach(context);
... ... @@ -337,6 +395,8 @@
337 395 super.onActivityResult(requestCode, resultCode, data);
338 396  
339 397 }
  398 +
  399 +
340 400  
341 401 }
app/src/main/java/com/dinhcv/lifelogpedometer/activity/TopTodayFragment.java
... ... @@ -26,6 +26,7 @@
26 26 import com.dinhcv.lifelogpedometer.model.StepModel;
27 27 import com.dinhcv.lifelogpedometer.model.structure.top.StepItemInfo;
28 28 import com.dinhcv.lifelogpedometer.model.structure.top.TopInfo;
  29 +import com.dinhcv.lifelogpedometer.portal.ApiServices;
29 30 import com.dinhcv.lifelogpedometer.portal.LLAPIManager;
30 31 import com.dinhcv.lifelogpedometer.utils.Const;
31 32 import com.dinhcv.lifelogpedometer.utils.DayAxisValueFormatter;
32 33  
... ... @@ -135,8 +136,11 @@
135 136 // slice for the "missing" steps until reaching the goal
136 137 sliceGoal = new PieModel("", Const.STEP_GOAL, Color.parseColor("#B7B8B6"));
137 138 pg.addPieSlice(sliceGoal);
  139 +
138 140 pg.setDrawValueInPie(false);
139 141 pg.setUsePieRotation(false);
  142 + pg.setInnerPadding(93);
  143 + pg.setInnerPaddingColor(R.color.background_main);
140 144 pg.startAnimation();
141 145 pg.setAutoCenterInSlice(false);
142 146  
... ... @@ -222,7 +226,7 @@
222 226 progress.setMessage(getString(R.string.loading));
223 227 progress.setCancelable(false);
224 228 progress.show();
225   - LLAPIManager.topInfo(date, stepType, new LLAPIManagerListener() {
  229 + ApiServices.topInfo(date, stepType, new LLAPIManagerListener() {
226 230 @Override
227 231 public void onError(Error error) {
228 232 Debug.error("Get data history error");
229 233  
230 234  
... ... @@ -587,10 +591,13 @@
587 591 public void onResume() {
588 592 super.onResume();
589 593 activityRunning = true;
  594 + Debug.normal("Today: "+ "Onresume ");
590 595 Sensor countSensor = sensorManager.getDefaultSensor(Sensor.TYPE_STEP_COUNTER);
591 596 if (countSensor != null) {
  597 + Debug.normal("Today: "+ "countSensor not null ");
592 598 sensorManager.registerListener(this, countSensor, SensorManager.SENSOR_DELAY_UI);
593 599 } else {
  600 + Debug.normal("Today: "+ "countSensor is null ");
594 601 Toast.makeText(mContext, getResources().getString(R.string.sensor_available), Toast.LENGTH_SHORT).show();
595 602 }
596 603 }
597 604  
... ... @@ -631,8 +638,9 @@
631 638 }
632 639  
633 640 private void creatLogStep(){
  641 + Debug.normal("Today: "+ "Create log "+ stepCount);
634 642  
635   - LLAPIManager.createLog(stepType, stepCount, mFromDate, mToDate, new LLAPIManagerListener() {
  643 + ApiServices.createLog(stepType, stepCount, mFromDate, mToDate, new LLAPIManagerListener() {
636 644 @Override
637 645 public void onError(Error error) {
638 646 Debug.error("Get data history error");
... ... @@ -649,6 +657,8 @@
649 657 }
650 658 });
651 659 }
  660 +
  661 +
652 662  
653 663 }
app/src/main/java/com/dinhcv/lifelogpedometer/activity/WelcomeActivity.java
... ... @@ -11,6 +11,7 @@
11 11 import com.dinhcv.lifelogpedometer.R;
12 12 import com.dinhcv.lifelogpedometer.interfaces.LLAPIManagerListener;
13 13 import com.dinhcv.lifelogpedometer.model.Shareprefer.Setting;
  14 +import com.dinhcv.lifelogpedometer.portal.ApiServices;
14 15 import com.dinhcv.lifelogpedometer.portal.LLAPIManager;
15 16 import com.dinhcv.lifelogpedometer.utils.Debug;
16 17  
... ... @@ -40,7 +41,7 @@
40 41  
41 42 private void handleRefreshToken(int id) {
42 43  
43   - LLAPIManager.refreshToken(WelcomeActivity.this, id, new LLAPIManagerListener() {
  44 + ApiServices.refreshToken(WelcomeActivity.this, id, new LLAPIManagerListener() {
44 45 @Override
45 46 public void onError(Error error) {
46 47 Debug.error("Version JSON result: ERROR " + error);
app/src/main/java/com/dinhcv/lifelogpedometer/model/structure/home/NoticeInfo.java
... ... @@ -4,6 +4,15 @@
4 4 private int id;
5 5 private String content;
6 6  
  7 + public NoticeInfo(){
  8 +
  9 + }
  10 +
  11 + public NoticeInfo(int id, String content){
  12 + this.id = id;
  13 + this.content = content;
  14 + }
  15 +
7 16 public int getId() {
8 17 return id;
9 18 }
app/src/main/java/com/dinhcv/lifelogpedometer/portal/ApiServices.java
  1 +package com.dinhcv.lifelogpedometer.portal;
  2 +
  3 +import android.content.Context;
  4 +import android.graphics.Bitmap;
  5 +
  6 +import com.dinhcv.lifelogpedometer.interfaces.LLAPIManagerListener;
  7 +import com.dinhcv.lifelogpedometer.model.structure.RegisterInfo;
  8 +import com.dinhcv.lifelogpedometer.utils.Const;
  9 +
  10 +import java.util.Date;
  11 +
  12 +/**
  13 + * Created by Administrator on 16/11/2017.
  14 + */
  15 +
  16 +public class ApiServices {
  17 +
  18 + public static void topInfo(final Date date, final Const.STEP_TYPE stepType, final LLAPIManagerListener action){
  19 + new LLAPIManager.TopInfo(date, stepType, action).execute();
  20 + }
  21 +
  22 + public static void homePage(final Date date, final Const.STEP_TYPE stepType, final LLAPIManagerListener action) {
  23 + new LLAPIManager.HomePage(date, stepType, action).execute();
  24 + }
  25 +
  26 +
  27 + public static void historyDetail(final Date fromDate, final Date toDate, final LLAPIManagerListener action) {
  28 + new LLAPIManager.HistoryDetail(fromDate, toDate, action).execute();
  29 + }
  30 +
  31 +
  32 + public static void history(final Date fromDate, final Date toDate, final LLAPIManagerListener action) {
  33 + new LLAPIManager.History(fromDate, toDate, action).execute();
  34 + }
  35 +
  36 +
  37 + public static void forgetPassConfirm(final String email, final String codeConfirm, final LLAPIManagerListener action) {
  38 + new LLAPIManager.ForgetPassConfirm(email, codeConfirm, action).execute();
  39 + }
  40 +
  41 +
  42 + public static void forgetPass(final String email, final LLAPIManagerListener action) {
  43 + new LLAPIManager.ForgetPass(email, action).execute();
  44 + }
  45 +
  46 +
  47 + public static void register(final RegisterInfo registerInfo, final LLAPIManagerListener action) {
  48 + new LLAPIManager.Register(registerInfo, action).execute();
  49 + }
  50 +
  51 +
  52 + public static void uploadImage(final Bitmap bitmap, final LLAPIManagerListener action) {
  53 + new LLAPIManager.UploadImage(bitmap, action).execute();
  54 + }
  55 +
  56 +
  57 + public static void login(final Context context, final String email, final String pass, final LLAPIManagerListener action) {
  58 + new LLAPIManager.Login(context, email, pass, action).execute();
  59 + }
  60 +
  61 + public static void createLog(final Const.STEP_TYPE stepType, final int stepCount, final Date startTime,
  62 + final Date endTime, final LLAPIManagerListener action) {
  63 + new LLAPIManager.CreateLog(stepType, stepCount, startTime, endTime, action).execute();
  64 + }
  65 +
  66 +
  67 + public static void refreshToken(final Context context, final int userId, final LLAPIManagerListener action) {
  68 + new LLAPIManager.RefreshToken(context, userId, action).execute();
  69 + }
  70 +
  71 + public static void getNews(final Date date, final LLAPIManagerListener action) {
  72 + new LLAPIManager.GetNews(date, action).execute();
  73 + }
  74 +
  75 +
  76 +}
app/src/main/java/com/dinhcv/lifelogpedometer/portal/LLAPIManager.java