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

add exercise task according to level

parent af08f7ec
Branches
No related merge requests found
......@@ -12,6 +12,7 @@ import android.widget.TextView;
import com.example.leo.fitnessdiy.Utilities.NetworkUtils;
import com.example.leo.fitnessdiy.model.Users;
import com.example.leo.fitnessdiy.model.UsersSharedPreferences;
import com.example.leo.fitnessdiy.routes.api;
import org.json.JSONArray;
......@@ -24,29 +25,26 @@ import java.util.ArrayList;
public class PlankActivity extends AppCompatActivity {
private String LOG_TAG = "TES PLANK ACTIVITY";
Users user = getUser(1);
String sharedPrefFile = "com.example.leo.fitnessdiy";
private SharedPreferences mPreferences;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_plank);
SharedPreferences mPreferences;
String sharedPrefFile = "com.example.leo.fitnessdiy";
final String BACKGROUND_KEY = "background";
mPreferences = getSharedPreferences(sharedPrefFile, MODE_PRIVATE);
mPreferences = getSharedPreferences(sharedPrefFile, MODE_PRIVATE);
int background = mPreferences.getInt(BACKGROUND_KEY, R.drawable.green_theme);
getWindow().getDecorView().setBackground(getResources().getDrawable(background));
}
public int setCountTime(Users user){
if(user.getLevel().equals("begineer")){
public int setCountTime(String level){
if(level.equals("begineer")){
return 60000;
} else if(user.getLevel().equals("intermediate")){
} else if(level.equals("intermediate")){
return 120000;
} else {
return 180000;
......@@ -64,7 +62,9 @@ public class PlankActivity extends AppCompatActivity {
public void countDownPlank(View view) {
final TextView countText = findViewById(R.id.count_timer);
new CountDownTimer(setCountTime(user), 1000){
mPreferences = getSharedPreferences(sharedPrefFile, MODE_PRIVATE);
String level = mPreferences.getString(UsersSharedPreferences.LEVEL_USERS, "begineer");
new CountDownTimer(setCountTime(level), 1000){
@Override
public void onTick(long l) {
String waktu = milisecondToMinutes(l);
......@@ -79,22 +79,6 @@ public class PlankActivity extends AppCompatActivity {
}
public Users getUser(int user_id){
Users user = new Users();
try {
URL url = new URL("http://ekiwae21.000webhostapp.com/fitness-server/users.php?user="+user_id);
String fetchResults = NetworkUtils.getResponseFromHttpUrl(url);
user = Users.initializeData(fetchResults);
Log.d(LOG_TAG, Integer.toString(user.getId()));
Log.d(LOG_TAG, user.getLevel());
} catch (IOException e) {
e.printStackTrace();
}
return user;
}
public void openVideo(View view) {
String url = (String)view.getTag();
......
......@@ -8,6 +8,8 @@ import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.TextView;
import com.example.leo.fitnessdiy.model.UsersSharedPreferences;
/**
* Created by Heil on 2/19/2018.
*/
......@@ -24,10 +26,24 @@ public class PushupActivity extends AppCompatActivity{
final String BACKGROUND_KEY = "background";
mPreferences = getSharedPreferences(sharedPrefFile, MODE_PRIVATE);
String level = mPreferences.getString(UsersSharedPreferences.LEVEL_USERS, "begineer");
setPushUpFrequency(level);
int background = mPreferences.getInt(BACKGROUND_KEY, R.drawable.green_theme);
getWindow().getDecorView().setBackground(getResources().getDrawable(background));
}
public void setPushUpFrequency(String level){
TextView pushUpTask = (TextView)findViewById(R.id.pushUpTask);
if(level.equals("begineer")){
pushUpTask.setText("Do Push Up 30 times");
}else if(level.equals("intermediate")){
pushUpTask.setText("Do Push Up 60 times");
}else if(level.equals("advanced")){
pushUpTask.setText("Do Push Up 90 times");
}
}
public void openVideo(View view) {
String url = (String)view.getTag();
......
......@@ -8,6 +8,8 @@ import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.TextView;
import com.example.leo.fitnessdiy.model.UsersSharedPreferences;
/**
* Created by Heil on 2/19/2018.
*/
......@@ -24,10 +26,24 @@ public class SitupActivity extends AppCompatActivity{
final String BACKGROUND_KEY = "background";
mPreferences = getSharedPreferences(sharedPrefFile, MODE_PRIVATE);
String level = mPreferences.getString(UsersSharedPreferences.LEVEL_USERS, "begineer");
setSitUpFrequency(level);
int background = mPreferences.getInt(BACKGROUND_KEY, R.drawable.green_theme);
getWindow().getDecorView().setBackground(getResources().getDrawable(background));
}
public void setSitUpFrequency(String level){
TextView pushUpTask = (TextView)findViewById(R.id.pushUpTask);
if(level.equals("begineer")){
pushUpTask.setText("Do Push Up 30 times");
}else if(level.equals("intermediate")){
pushUpTask.setText("Do Push Up 60 times");
}else if(level.equals("advanced")){
pushUpTask.setText("Do Push Up 90 times");
}
}
public void openVideo(View view) {
String url = (String)view.getTag();
......
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