Skip to content
Snippets Groups Projects
Commit 4dce2cb0 authored by unknown's avatar unknown
Browse files

New Jogging history bug fixed

parent d3883cbb
No related merge requests found
...@@ -2,8 +2,9 @@ ...@@ -2,8 +2,9 @@
<project version="4"> <project version="4">
<component name="ProjectModuleManager"> <component name="ProjectModuleManager">
<modules> <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$/app/app.iml" filepath="$PROJECT_DIR$/app/app.iml" />
<module fileurl="file://$PROJECT_DIR$/fitness.iml" filepath="$PROJECT_DIR$/fitness.iml" />
</modules> </modules>
</component> </component>
</project> </project>
\ No newline at end of file
...@@ -59,6 +59,7 @@ import org.json.JSONException; ...@@ -59,6 +59,7 @@ import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
import java.io.IOException; import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.MalformedURLException; import java.net.MalformedURLException;
import java.net.URL; import java.net.URL;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
...@@ -111,10 +112,7 @@ public class JoggingActivity extends FragmentActivity implements OnMapReadyCallb ...@@ -111,10 +112,7 @@ public class JoggingActivity extends FragmentActivity implements OnMapReadyCallb
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(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 // save instance state
if (savedInstanceState != null) { if (savedInstanceState != null) {
mLastKnownLocation = savedInstanceState.getParcelable(KEY_LOCATION); mLastKnownLocation = savedInstanceState.getParcelable(KEY_LOCATION);
...@@ -454,7 +452,7 @@ public class JoggingActivity extends FragmentActivity implements OnMapReadyCallb ...@@ -454,7 +452,7 @@ public class JoggingActivity extends FragmentActivity implements OnMapReadyCallb
} }
public void stopJogging(View view) { public void stopJogging(View view) {
infoJoggingEnd.setText("\n" + getCurrentLocation()); infoJoggingEnd.setText(getCurrentLocation());
mButton.setText("START"); mButton.setText("START");
mButton.setOnClickListener(new View.OnClickListener() { mButton.setOnClickListener(new View.OnClickListener() {
@Override @Override
...@@ -477,32 +475,31 @@ public class JoggingActivity extends FragmentActivity implements OnMapReadyCallb ...@@ -477,32 +475,31 @@ public class JoggingActivity extends FragmentActivity implements OnMapReadyCallb
); );
// TODO : id_user sesuai id user yang login // TODO : id_user sesuai id user yang login
int id_user = 1; 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 { 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( String response = NetworkUtils.getResponseFromHttpUrl(
new URL(url) new URL(url)
); );
JSONObject jsonObject = new JSONObject(response); Log.d(TAG, response);
if (jsonObject.getString("error") == null) { // JSONObject jsonObject = new JSONObject(response);
Log.d(TAG, "Inserting new record successful"); // if (jsonObject.getString("error") == null) {
} else { // Log.d(TAG, "Inserting new record successful");
Log.e(TAG, jsonObject.getString("error")); // } else {
} // Log.e(TAG, jsonObject.getString("error"));
// }
} catch (MalformedURLException e) { } catch (MalformedURLException e) {
e.printStackTrace(); e.printStackTrace();
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} catch (JSONException e) {
e.printStackTrace();
} }
} }
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment