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

integrasi history plank

parent 3dcb6a31
No related merge requests found
......@@ -2,9 +2,10 @@
<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" />
<module fileurl="file://D:\tugas\sem6\pbd\tubes\android\fitness.iml" filepath="D:\tugas\sem6\pbd\tubes\android\fitness.iml" />
<module fileurl="file://D:\Semester 6\PBD\Tugas Besar\android\fitness.iml" filepath="D:\Semester 6\PBD\Tugas Besar\android\fitness.iml" />
</modules>
</component>
......
......@@ -4,6 +4,7 @@ import android.content.Intent;
import android.content.SharedPreferences;
import android.net.Uri;
import android.os.CountDownTimer;
import android.os.StrictMode;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
......@@ -20,33 +21,58 @@ import org.json.JSONException;
import org.json.JSONObject;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.Scanner;
public class PlankActivity extends AppCompatActivity {
private String LOG_TAG = "TES PLANK ACTIVITY";
String sharedPrefFile = "com.example.leo.fitnessdiy";
private String user;
private String plank_date;
private String plank_time_start;
private String plank_time_end;
private String plank_duration;
private SharedPreferences mPreferences;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_plank);
SharedPreferences mPreferences;
final String BACKGROUND_KEY = "background";
mPreferences = getSharedPreferences(sharedPrefFile, MODE_PRIVATE);
int background = mPreferences.getInt(BACKGROUND_KEY, R.drawable.green_theme);
getWindow().getDecorView().setBackground(getResources().getDrawable(background));
SimpleDateFormat formatDate = new SimpleDateFormat("yyyy-MM-dd");
SimpleDateFormat formatTime = new SimpleDateFormat("HH:mm:ss");
Date date = new Date();
plank_date = formatDate.format(date);
Log.d(LOG_TAG, plank_date);
plank_time_start = formatTime.format(date);
Log.d(LOG_TAG, plank_time_start);
}
public int setCountTime(String level){
if(level.equals("begineer")){
plank_duration = ""+60;
return 60000;
} else if(level.equals("intermediate")){
plank_duration = ""+120;
return 120000;
} else {
plank_duration = ""+180;
return 180000;
}
}
......@@ -74,11 +100,41 @@ public class PlankActivity extends AppCompatActivity {
@Override
public void onFinish() {
countText.setText("BERHASIL");
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);
}
}.start();
}
public void addThePlankHistory(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;
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();
}
}
public void openVideo(View view) {
String url = (String)view.getTag();
......
......@@ -30,4 +30,6 @@ public class api {
public static final String SITUP_HISTORY_URL = BASE_URL + "situp_history.php?user=";
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?";
}
......@@ -12,8 +12,4 @@
# 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:16:21 GMT+07:00 2018
systemProp.http.proxyPassword=02414056
systemProp.http.proxyHost=cache.itb.ac.id
systemProp.http.proxyUser=leo16515325
systemProp.http.proxyPort=8080
#Fri Feb 23 11:52:54 ICT 2018
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