From 4dce2cb0ed7569cb5de1274108ceb4cf766cba2f Mon Sep 17 00:00:00 2001
From: unknown <leo112071@gmail.com>
Date: Thu, 22 Feb 2018 12:58:58 +0700
Subject: [PATCH] New Jogging history bug fixed

---
 .idea/modules.xml                             |  3 +-
 .../leo/fitnessdiy/JoggingActivity.java       | 43 +++++++++----------
 2 files changed, 22 insertions(+), 24 deletions(-)

diff --git a/.idea/modules.xml b/.idea/modules.xml
index abc31fc..223896e 100644
--- a/.idea/modules.xml
+++ b/.idea/modules.xml
@@ -2,8 +2,9 @@
 <project version="4">
   <component name="ProjectModuleManager">
     <modules>
-      <module fileurl="file://$PROJECT_DIR$/android.iml" filepath="$PROJECT_DIR$/android.iml" />
+      <module fileurl="file://F:\informatika\pbd\fitness\android.iml" filepath="F:\informatika\pbd\fitness\android.iml" />
       <module fileurl="file://$PROJECT_DIR$/app/app.iml" filepath="$PROJECT_DIR$/app/app.iml" />
+      <module fileurl="file://$PROJECT_DIR$/fitness.iml" filepath="$PROJECT_DIR$/fitness.iml" />
     </modules>
   </component>
 </project>
\ No newline at end of file
diff --git a/app/src/main/java/com/example/leo/fitnessdiy/JoggingActivity.java b/app/src/main/java/com/example/leo/fitnessdiy/JoggingActivity.java
index 0350792..5ade481 100644
--- a/app/src/main/java/com/example/leo/fitnessdiy/JoggingActivity.java
+++ b/app/src/main/java/com/example/leo/fitnessdiy/JoggingActivity.java
@@ -59,6 +59,7 @@ import org.json.JSONException;
 import org.json.JSONObject;
 
 import java.io.IOException;
+import java.net.HttpURLConnection;
 import java.net.MalformedURLException;
 import java.net.URL;
 import java.text.SimpleDateFormat;
@@ -111,10 +112,7 @@ public class JoggingActivity extends FragmentActivity implements OnMapReadyCallb
     @Override
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
-        if (android.os.Build.VERSION.SDK_INT > 9) {
-            StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
-            StrictMode.setThreadPolicy(policy);
-        }
+
         // save instance state
         if (savedInstanceState != null) {
             mLastKnownLocation = savedInstanceState.getParcelable(KEY_LOCATION);
@@ -454,7 +452,7 @@ public class JoggingActivity extends FragmentActivity implements OnMapReadyCallb
     }
 
     public void stopJogging(View view) {
-        infoJoggingEnd.setText("\n" + getCurrentLocation());
+        infoJoggingEnd.setText(getCurrentLocation());
         mButton.setText("START");
         mButton.setOnClickListener(new View.OnClickListener() {
             @Override
@@ -477,32 +475,31 @@ public class JoggingActivity extends FragmentActivity implements OnMapReadyCallb
         );
         // TODO : id_user sesuai id user yang login
         int id_user = 1;
+        String url = api.newJoggingHistory(
+                id_user,
+                jogging.getDate(),
+                jogging.getStart(),
+                jogging.getEnd(),
+                jogging.getDistance(),
+                jogging.getStartingPoint(),
+                jogging.getEndPoint()
+        );
+        Log.d(TAG, url);
         try {
-            String url = api.newJoggingHistory(
-                    id_user,
-                    jogging.getDate(),
-                    jogging.getStart(),
-                    jogging.getEnd(),
-                    jogging.getDistance(),
-                    jogging.getStartingPoint(),
-                    jogging.getEndPoint()
-            );
-            Log.d(TAG, url);
             String response = NetworkUtils.getResponseFromHttpUrl(
                     new URL(url)
             );
-            JSONObject jsonObject = new JSONObject(response);
-            if (jsonObject.getString("error") == null) {
-                Log.d(TAG, "Inserting new record successful");
-            } else {
-                Log.e(TAG, jsonObject.getString("error"));
-            }
+            Log.d(TAG, response);
+//            JSONObject jsonObject = new JSONObject(response);
+//            if (jsonObject.getString("error") == null) {
+//                Log.d(TAG, "Inserting new record successful");
+//            } else {
+//                Log.e(TAG, jsonObject.getString("error"));
+//            }
         } catch (MalformedURLException e) {
             e.printStackTrace();
         } catch (IOException e) {
             e.printStackTrace();
-        } catch (JSONException e) {
-            e.printStackTrace();
         }
     }
 
-- 
GitLab