Skip to content
Snippets Groups Projects
Commit 5916f66d authored by Rizki Halasan's avatar Rizki Halasan
Browse files

pushup history

parent 6b561cfe
Branches
No related merge requests found
......@@ -58,10 +58,11 @@ public class PlankActivity extends AppCompatActivity {
Date date = new Date();
plank_date = formatDate.format(date);
Log.d(LOG_TAG, plank_date);
// Log.d(LOG_TAG, plank_date);
plank_time_start = formatTime.format(date);
Log.d(LOG_TAG, plank_time_start);
// Log.d(LOG_TAG, plank_time_start);
user = Integer.toString(mPreferences.getInt(UsersSharedPreferences.ID_USERS, -999));
}
public int setCountTime(String level){
......@@ -104,16 +105,16 @@ public class PlankActivity extends AppCompatActivity {
SimpleDateFormat formatTime = new SimpleDateFormat("HH:mm:ss");
plank_time_end = formatTime.format(new Date());
Log.d(LOG_TAG, plank_time_end);
String user = Integer.toString(mPreferences.getInt(UsersSharedPreferences.ID_USERS, -999));
addThePlankHistory(user, plank_date, plank_time_start, plank_time_end, plank_duration);
addPlankHistory(user, plank_date, plank_time_start, plank_time_end, plank_duration);
}
}.start();
}
public void addThePlankHistory(String user, String plank_date, String plank_time_start,
String plank_time_end, String plank_duration){
public void addPlankHistory(String user, String plank_date, String plank_time_start,
String plank_time_end, String plank_duration){
String urlstring = api.ADD_PLANK_HISTORY_URL+"user="+user+"&plank_date="+plank_date+"&plank_time_start="+plank_time_start+
"&plank_time_end="+plank_time_end+"&plank_duration="+plank_duration;
"&plank_time_end="+plank_time_end+"&plank_duration="+plank_duration;
if (android.os.Build.VERSION.SDK_INT > 9) {
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
......
......@@ -4,18 +4,36 @@ import android.content.Intent;
import android.content.SharedPreferences;
import android.net.Uri;
import android.os.Bundle;
import android.os.StrictMode;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import com.example.leo.fitnessdiy.model.UsersSharedPreferences;
import com.example.leo.fitnessdiy.routes.api;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Scanner;
/**
* Created by Heil on 2/19/2018.
*/
public class PushupActivity extends AppCompatActivity{
private String user;
private String pushup_date;
private String pushup_time_start;
private String pushup_time_end;
private String pushup_frequency;
private String LOG_TAG = "PUSHUP ACTIVITY";
@Override
protected void onCreate(Bundle savedInstanceState) {
......@@ -32,6 +50,9 @@ public class PushupActivity extends AppCompatActivity{
int background = mPreferences.getInt(BACKGROUND_KEY, R.drawable.green_theme);
getWindow().getDecorView().setBackground(getResources().getDrawable(background));
SimpleDateFormat formatDate = new SimpleDateFormat("yyyy-MM-dd");
pushup_date = formatDate.format(new Date());
}
public void setPushUpFrequency(String level){
......@@ -60,6 +81,11 @@ public class PushupActivity extends AppCompatActivity{
public void taskComplete(View view) {
TextView tv = (TextView)findViewById(R.id.pushUpTask);
tv.setText("Berhasil");
SimpleDateFormat formatTime = new SimpleDateFormat("HH:mm:ss");
pushup_time_end = formatTime.format(new Date());
addPlankHistory(user, pushup_date, pushup_time_start, pushup_time_end, pushup_frequency);
Log.d(LOG_TAG, "waktu selesai pushup : "+pushup_time_end);
}
public void taskBegin(View view) {
......@@ -69,5 +95,36 @@ public class PushupActivity extends AppCompatActivity{
Button button2 = (Button) findViewById(R.id.finish_pushup_button);
button2.setVisibility(View.VISIBLE);
SimpleDateFormat formatTime = new SimpleDateFormat("HH:mm:ss");
pushup_time_start = formatTime.format(new Date());
Log.d(LOG_TAG, "waktu mulai pushup : "+pushup_time_start);
}
public void addPlankHistory(String user, String pushup_date, String pushup_time_start,
String pushup_time_end, String pushup_frequency){
String urlstring = api.ADD_PUSHUP_HISTORY_URL+"user="+user+"&pushup_date="+pushup_date+"&pushup_time_start="+pushup_time_start+
"&pushup_time_end="+pushup_time_end+"&pushup_frequency="+pushup_frequency;
if (android.os.Build.VERSION.SDK_INT > 9) {
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(policy);
}
try{
URL url = new URL(urlstring);
HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
try{
InputStream in = urlConnection.getInputStream();
Scanner scanner = new Scanner(in);
} finally {
urlConnection.disconnect();
}
} catch (MalformedURLException e){
e.printStackTrace();
}catch (IOException e) {
e.printStackTrace();
}
}
}
......@@ -14,8 +14,8 @@ public class api {
public static final String USERS_URL = BASE_URL + "users.php?user=";
public static final String newJoggingHistory(int id_user, String date,
String start, String end, float distance,
String sPoint, String ePoint) {
String start, String end, float distance,
String sPoint, String ePoint) {
return BASE_URL + "new_jogging_history.php?user=" + id_user +
"&date="+date+"&start="+start+"&end="+end+"&distance="+distance+"&spoint="+
sPoint+"&epoint=" + ePoint;
......@@ -32,4 +32,6 @@ public class api {
public static final String EDIT_LEVEL_URL = BASE_URL + "edit_level.php?";
public static final String ADD_PLANK_HISTORY_URL = BASE_URL + "add_plank_history.php?";
public static final String ADD_PUSHUP_HISTORY_URL = BASE_URL + "add_pushup_history.php?";
}
......@@ -12,4 +12,8 @@
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
#Fri Feb 23 11:52:54 ICT 2018
#Fri Feb 23 14:55:09 ICT 2018
systemProp.http.proxyPassword=07007831
systemProp.http.proxyHost=cache.itb.ac.id
systemProp.http.proxyUser=rizki_halasan
systemProp.http.proxyPort=8080
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