Skip to content
Snippets Groups Projects
Commit d49a1485 authored by unknown's avatar unknown
Browse files
parents 172c0de8 41b1993f
No related merge requests found
......@@ -53,15 +53,20 @@ public class PushupActivity extends AppCompatActivity{
SimpleDateFormat formatDate = new SimpleDateFormat("yyyy-MM-dd");
pushup_date = formatDate.format(new Date());
user = Integer.toString(mPreferences.getInt(UsersSharedPreferences.ID_USERS, -999));
}
public void setPushUpFrequency(String level){
TextView pushUpTask = (TextView)findViewById(R.id.pushUpTask);
if(level.equals("begineer")){
pushup_frequency = ""+30;
pushUpTask.setText("Do Push Up 30 times");
}else if(level.equals("intermediate")){
pushup_frequency = ""+60;
pushUpTask.setText("Do Push Up 60 times");
}else if(level.equals("advanced")){
pushup_frequency = ""+90;
pushUpTask.setText("Do Push Up 90 times");
}
}
......@@ -84,7 +89,7 @@ public class PushupActivity extends AppCompatActivity{
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);
addPushupHistory(user, pushup_date, pushup_time_start, pushup_time_end, pushup_frequency);
Log.d(LOG_TAG, "waktu selesai pushup : "+pushup_time_end);
}
......@@ -101,11 +106,12 @@ public class PushupActivity extends AppCompatActivity{
Log.d(LOG_TAG, "waktu mulai pushup : "+pushup_time_start);
}
public void addPlankHistory(String user, String pushup_date, String pushup_time_start,
public void addPushupHistory(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;
Log.d(LOG_TAG+" (URL) : ", urlstring);
if (android.os.Build.VERSION.SDK_INT > 9) {
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
......@@ -123,7 +129,7 @@ public class PushupActivity extends AppCompatActivity{
}
} catch (MalformedURLException e){
e.printStackTrace();
}catch (IOException e) {
} catch (IOException e) {
e.printStackTrace();
}
}
......
......@@ -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 SitupActivity extends AppCompatActivity{
private String user;
private String situp_date;
private String situp_time_start;
private String situp_time_end;
private String situp_frequency;
private String LOG_TAG = "SITUP ACTIVITY";
@Override
protected void onCreate(Bundle savedInstanceState) {
......@@ -32,15 +50,22 @@ public class SitupActivity extends AppCompatActivity{
int background = mPreferences.getInt(BACKGROUND_KEY, R.drawable.green_theme);
getWindow().getDecorView().setBackground(getResources().getDrawable(background));
user = Integer.toString(mPreferences.getInt(UsersSharedPreferences.ID_USERS, -999));
SimpleDateFormat formatDate = new SimpleDateFormat("yyyy-MM-dd");
situp_date = formatDate.format(new Date());
}
public void setSitUpFrequency(String level){
TextView sitUpTask = (TextView)findViewById(R.id.sitUpTask);
if(level.equals("begineer")){
situp_frequency = ""+30;
sitUpTask.setText("Do Sit Up 30 times");
}else if(level.equals("intermediate")){
situp_frequency = ""+60;
sitUpTask.setText("Do Sit Up 60 times");
}else if(level.equals("advanced")){
situp_frequency = ""+90;
sitUpTask.setText("Do Sit Up 90 times");
}
}
......@@ -59,6 +84,11 @@ public class SitupActivity extends AppCompatActivity{
public void taskComplete(View view) {
TextView tv = (TextView)findViewById(R.id.sitUpTask);
tv.setText("Berhasil");
SimpleDateFormat formatTime = new SimpleDateFormat("HH:mm:ss");
situp_time_end = formatTime.format(new Date());
Log.d(LOG_TAG, "waktu selesai situp : "+situp_time_end);
addSitupHistory(user, situp_date, situp_time_start, situp_time_end, situp_frequency);
}
public void taskBegin(View view) {
......@@ -68,5 +98,37 @@ public class SitupActivity extends AppCompatActivity{
Button button2 = (Button) findViewById(R.id.finish_situp_button);
button2.setVisibility(View.VISIBLE);
SimpleDateFormat formatTime = new SimpleDateFormat("HH:mm:ss");
situp_time_start = formatTime.format(new Date());
Log.d(LOG_TAG, "waktu mulai situp : "+situp_time_start);
}
public void addSitupHistory(String user, String situp_date, String situp_time_start,
String situp_time_end, String situp_frequency){
String urlstring = api.ADD_SITUP_HISTORY_URL+"user="+user+"&situp_date="+situp_date+"&situp_time_start="+situp_time_start+
"&situp_time_end="+situp_time_end+"&situp_frequency="+situp_frequency;
Log.d(LOG_TAG+" (URL) : ", urlstring);
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();
}
}
}
......@@ -34,4 +34,6 @@ public class api {
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?";
public static final String ADD_SITUP_HISTORY_URL = BASE_URL + "add_situp_history.php?";
}
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