From af08f7ec87aae78cace22d597da22b485d4e89cc Mon Sep 17 00:00:00 2001 From: rizkihalasan <13515095@std.stei.itb.ac.id> Date: Thu, 22 Feb 2018 16:52:48 +0700 Subject: [PATCH] level change to database --- .idea/modules.xml | 3 +- .../example/leo/fitnessdiy/LevelActivity.java | 37 +++++++++++++++++++ .../example/leo/fitnessdiy/routes/api.java | 2 + gradle.properties | 5 +++ 4 files changed, 45 insertions(+), 2 deletions(-) diff --git a/.idea/modules.xml b/.idea/modules.xml index 223896e..abc31fc 100644 --- a/.idea/modules.xml +++ b/.idea/modules.xml @@ -2,9 +2,8 @@ <project version="4"> <component name="ProjectModuleManager"> <modules> - <module fileurl="file://F:\informatika\pbd\fitness\android.iml" filepath="F:\informatika\pbd\fitness\android.iml" /> + <module fileurl="file://$PROJECT_DIR$/android.iml" filepath="$PROJECT_DIR$/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" /> </modules> </component> </project> \ No newline at end of file diff --git a/app/src/main/java/com/example/leo/fitnessdiy/LevelActivity.java b/app/src/main/java/com/example/leo/fitnessdiy/LevelActivity.java index f3c7b13..52996ef 100644 --- a/app/src/main/java/com/example/leo/fitnessdiy/LevelActivity.java +++ b/app/src/main/java/com/example/leo/fitnessdiy/LevelActivity.java @@ -1,13 +1,24 @@ package com.example.leo.fitnessdiy; +import android.content.Intent; import android.content.SharedPreferences; +import android.os.StrictMode; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.util.Log; import android.view.View; import android.widget.RadioButton; +import com.example.leo.fitnessdiy.model.Users; 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.util.Scanner; public class LevelActivity extends AppCompatActivity { private SharedPreferences mPreferences; @@ -50,6 +61,32 @@ public class LevelActivity extends AppCompatActivity { preferencesEditor.putString(UsersSharedPreferences.LEVEL_USERS, level); preferencesEditor.apply(); Log.d("LEVEL", mPreferences.getString(UsersSharedPreferences.LEVEL_USERS, "level salah")); + editLevel(level, mPreferences); + Intent i = new Intent(getApplicationContext(), HomeActivity.class); + startActivity(i); + } + public void editLevel(String level, SharedPreferences mPreferences){ + int user = mPreferences.getInt(UsersSharedPreferences.ID_USERS, 0); + String urlstring = api.EDIT_LEVEL_URL+"user="+user+"&level="+level; + 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(); + } } } diff --git a/app/src/main/java/com/example/leo/fitnessdiy/routes/api.java b/app/src/main/java/com/example/leo/fitnessdiy/routes/api.java index 8da80de..2296148 100644 --- a/app/src/main/java/com/example/leo/fitnessdiy/routes/api.java +++ b/app/src/main/java/com/example/leo/fitnessdiy/routes/api.java @@ -26,4 +26,6 @@ public class api { public static final String PUSHUP_HISTORY_URL = BASE_URL + "pushup_history.php?user="; 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?"; } diff --git a/gradle.properties b/gradle.properties index 43350e5..4c6d70e 100644 --- a/gradle.properties +++ b/gradle.properties @@ -12,3 +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 +#Thu Feb 22 15:51:55 ICT 2018 +systemProp.http.proxyPassword=07007831 +systemProp.http.proxyHost=cache.itb.ac.id +systemProp.http.proxyUser=rizki_halasan +systemProp.http.proxyPort=8080 -- GitLab