From ef1f3a53e4f00cd7e4a03979611298c1639a03e7 Mon Sep 17 00:00:00 2001 From: Jacques Foucry Date: Sun, 12 Apr 2020 10:32:00 +0200 Subject: [PATCH 1/4] Try add reading values from activity --- .../pilldroid/MedicamentDetailFragment.java | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/net/foucry/pilldroid/MedicamentDetailFragment.java b/app/src/main/java/net/foucry/pilldroid/MedicamentDetailFragment.java index ac7caa3..b9f843d 100644 --- a/app/src/main/java/net/foucry/pilldroid/MedicamentDetailFragment.java +++ b/app/src/main/java/net/foucry/pilldroid/MedicamentDetailFragment.java @@ -2,9 +2,11 @@ package net.foucry.pilldroid; import android.app.Activity; import android.content.Context; +import android.content.Intent; import android.support.design.widget.CollapsingToolbarLayout; import android.os.Bundle; import android.support.v4.app.Fragment; +import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -18,11 +20,13 @@ import android.widget.Toast; * on handsets. */ public class MedicamentDetailFragment extends Fragment { + /** * The fragment argument representing the item ID that this fragment * represents. */ public static final String ARG_ITEM_ID = "medicament"; + private static final String TAG = MedicamentListActivity.class.getName(); /** * The dummy content this fragment is presenting. @@ -55,8 +59,7 @@ public class MedicamentDetailFragment extends Fragment { } @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, - Bundle savedInstanceState) { + public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View detailView = inflater.inflate(R.layout.medicament_detail, container, false); View nameView; View adminModeView; @@ -119,6 +122,14 @@ public class MedicamentDetailFragment extends Fragment { { Context context = getContext(); Toast.makeText(context, "***PROUT***", Toast.LENGTH_SHORT).show(); + + Intent intent = getIntent(); + + String presentation = intent.getStringExtra("Presentation"); + String name = intent.getStringExtra("Nom"); + + Log.d(TAG, "value of Presentation "+ presentation); + Log.d(TAG, "value of Nom "+ name); super.onStop(); } } From f8bcbeb9b70e8ab8823a941ed59b1ceaca3b8172 Mon Sep 17 00:00:00 2001 From: jacques Date: Sun, 12 Apr 2020 17:57:10 +0000 Subject: [PATCH 2/4] Realign --- app/build.gradle | 6 +++--- app/src/main/java/net/foucry/pilldroid/DBHelper.java | 2 +- build.gradle | 3 ++- gradle/wrapper/gradle-wrapper.properties | 4 ++-- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index aa4b7ee..e971d73 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -19,13 +19,13 @@ android { productFlavors { } compileOptions { - sourceCompatibility JavaVersion.VERSION_1_6 + sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } /*dexOptions { incremental false }*/ - buildToolsVersion = '29.0.2' + buildToolsVersion = buildToolsVersion1 } repositories { @@ -37,7 +37,7 @@ repositories { dependencies { implementation fileTree(include: ['*.jar'], dir: 'libs') - testImplementation 'junit:junit:4.12' + testImplementation 'junit:junit:4.13' implementation 'com.android.support:appcompat-v7:27.1.1' implementation 'com.android.support:recyclerview-v7:27.1.1' implementation 'com.android.support:design:27.1.1' diff --git a/app/src/main/java/net/foucry/pilldroid/DBHelper.java b/app/src/main/java/net/foucry/pilldroid/DBHelper.java index ca450e7..a8a93fc 100644 --- a/app/src/main/java/net/foucry/pilldroid/DBHelper.java +++ b/app/src/main/java/net/foucry/pilldroid/DBHelper.java @@ -20,7 +20,7 @@ class DBHelper extends SQLiteOpenHelper { private static final int DATABASE_VERSION = 1; private static String DATABASE_NAME = "ordonnance.db"; - private static final String TABLE_DRUG = "drug"; + private static final String TABLE_DRUG = "drug"; private static final String KEY_ID = "id"; private static final String KEY_CIS = "cis"; private static final String KEY_CIP13 = "cip13"; diff --git a/build.gradle b/build.gradle index 4fdbf45..47e20d3 100644 --- a/build.gradle +++ b/build.gradle @@ -9,7 +9,7 @@ buildscript { google() } dependencies { - classpath 'com.android.tools.build:gradle:3.5.1' + classpath 'com.android.tools.build:gradle:3.6.2' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files @@ -19,6 +19,7 @@ ext { compileSdkVersion = '27' buildToolsVersion = '27.0.1' var = '3.4.2' + buildToolsVersion1 = '29.0.3' } allprojects { diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index cd89f37..8c344a9 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Thu Jul 11 18:46:50 CEST 2019 +#Sun Apr 12 14:00:20 UTC 2020 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip From 3483aa72525e5a436b710322ff6062da763e5e19 Mon Sep 17 00:00:00 2001 From: jacques Date: Sun, 12 Apr 2020 17:57:48 +0000 Subject: [PATCH 3/4] Realign --- .../pilldroid/MedicamentDetailActivity.java | 1 + .../pilldroid/MedicamentDetailFragment.java | 18 +++++++++++++----- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/net/foucry/pilldroid/MedicamentDetailActivity.java b/app/src/main/java/net/foucry/pilldroid/MedicamentDetailActivity.java index 773be84..3e047d1 100644 --- a/app/src/main/java/net/foucry/pilldroid/MedicamentDetailActivity.java +++ b/app/src/main/java/net/foucry/pilldroid/MedicamentDetailActivity.java @@ -36,6 +36,7 @@ public class MedicamentDetailActivity extends AppCompatActivity { Snackbar.make(view, "Will be use to save changes in a drug", Snackbar.LENGTH_LONG) .setAction("Action", null).show(); setResult(1); + finish(); } }); diff --git a/app/src/main/java/net/foucry/pilldroid/MedicamentDetailFragment.java b/app/src/main/java/net/foucry/pilldroid/MedicamentDetailFragment.java index b9f843d..7c2b196 100644 --- a/app/src/main/java/net/foucry/pilldroid/MedicamentDetailFragment.java +++ b/app/src/main/java/net/foucry/pilldroid/MedicamentDetailFragment.java @@ -122,14 +122,22 @@ public class MedicamentDetailFragment extends Fragment { { Context context = getContext(); Toast.makeText(context, "***PROUT***", Toast.LENGTH_SHORT).show(); + View currentView = getView(); + View nameView; + View adminModeView; + View presentationView; + View stockView; + View priseView; + View warningView; + View alertView; - Intent intent = getIntent(); + stockView = currentView.findViewById(R.id.alert_cell); + TextView stockValue = stockView.findViewById(R.id.valeur); - String presentation = intent.getStringExtra("Presentation"); - String name = intent.getStringExtra("Nom"); + Log.d(TAG, "StockValue == "+ stockValue); + Log.d(TAG, "medicamentID "+ medicament.getId()); - Log.d(TAG, "value of Presentation "+ presentation); - Log.d(TAG, "value of Nom "+ name); + Toast.makeText(context,"stock value "+ stockValue, Toast.LENGTH_SHORT).show(); super.onStop(); } } From c0b32b767d56cc3c5cac1f100c80d1695db1bacf Mon Sep 17 00:00:00 2001 From: jacques Date: Sun, 12 Apr 2020 18:39:29 +0000 Subject: [PATCH 4/4] Read value from the view --- .../java/net/foucry/pilldroid/MedicamentDetailFragment.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/net/foucry/pilldroid/MedicamentDetailFragment.java b/app/src/main/java/net/foucry/pilldroid/MedicamentDetailFragment.java index 7c2b196..db6a986 100644 --- a/app/src/main/java/net/foucry/pilldroid/MedicamentDetailFragment.java +++ b/app/src/main/java/net/foucry/pilldroid/MedicamentDetailFragment.java @@ -2,7 +2,7 @@ package net.foucry.pilldroid; import android.app.Activity; import android.content.Context; -import android.content.Intent; + import android.support.design.widget.CollapsingToolbarLayout; import android.os.Bundle; import android.support.v4.app.Fragment; @@ -132,7 +132,8 @@ public class MedicamentDetailFragment extends Fragment { View alertView; stockView = currentView.findViewById(R.id.alert_cell); - TextView stockValue = stockView.findViewById(R.id.valeur); + TextView stockTextView = stockView.findViewById(R.id.valeur); + String stockValue = stockTextView.getText().toString(); Log.d(TAG, "StockValue == "+ stockValue); Log.d(TAG, "medicamentID "+ medicament.getId());