fixed settings value issues.
authorTrillGates <williamtrillgates@gmail.com>
Fri, 23 Jul 2021 09:43:23 +0000 (17:43 +0800)
committerTrillGates <williamtrillgates@gmail.com>
Fri, 23 Jul 2021 09:43:23 +0000 (17:43 +0800)
app/src/main/java/com/ic/sport/PedometerActivity.java
app/src/main/java/com/ic/sport/adapter/PedSetupAdapter.java
app/src/main/java/com/ic/sport/fragment/pedometer/PedSetupDialogFragment.java
app/src/main/java/com/ic/sport/fragment/pedometer/PedSetupFragment.java
app/src/main/java/com/ic/sport/util/SPUtils.java

index 8ae7dc9..e2a689d 100644 (file)
@@ -1,13 +1,14 @@
 package com.ic.sport;
 
+import android.os.Bundle;
+
 import androidx.appcompat.app.AppCompatActivity;
 import androidx.lifecycle.ViewModelProvider;
 import androidx.recyclerview.widget.LinearLayoutManager;
 import androidx.recyclerview.widget.RecyclerView;
 import androidx.viewpager2.widget.ViewPager2;
 
-import android.os.Bundle;
-
+import com.ic.iclooger.ICLogger;
 import com.ic.sport.adapter.FragmentAdapter;
 import com.ic.sport.adapter.IndicatorAdapter;
 import com.ic.sport.fragment.pedometer.PedMainFragment;
@@ -80,14 +81,16 @@ public class PedometerActivity extends AppCompatActivity
 
     @Override
     public void onDialogUpdate(int type, int value) {
-        ((PedSetupFragment) myAdapter.getFragment(0)).updateSetuUpValue(type, value);
+        ICLogger.d("type ==> " + type + " value ==> " + value);
+        ((PedSetupFragment) myAdapter.getFragment(0)).updateSetUpValue(type, value);
         switch (type) {
             case 0:
                 pedometerModel.syncPedHeightSetting(value);
                 SPUtils.setPedHeightSP(getApplicationContext(), value);
+                break;
             case 1:
                 pedometerModel.syncPedWeightSetting(value);
-                SPUtils.setPedWighttSP(getApplicationContext(), value);
+                SPUtils.setPedWeightSP(getApplicationContext(), value);
                 break;
         }
     }
index 067d2e6..7c73df2 100644 (file)
@@ -43,7 +43,7 @@ public class PedSetupAdapter extends RecyclerView.Adapter<PedSetupAdapter.SetUpH
         setupArray = new PedSetupEntity[3];
         int[] valueArray = new int[]{
                 SPUtils.getPedHeightSP(context),
-                SPUtils.getPedWighttSP(context),
+                SPUtils.getPedWightSP(context),
                 SPUtils.getPedTargetSP(context)
         };
 
index 2227247..d05c118 100644 (file)
@@ -8,7 +8,6 @@ import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
 import android.view.Window;
-import android.widget.ImageButton;
 import android.widget.ImageView;
 
 import androidx.annotation.NonNull;
@@ -66,7 +65,7 @@ public class PedSetupDialogFragment extends DialogFragment {
         }
 
         VALUE_CURR[0] = SPUtils.getPedHeightSP(mContext);
-        VALUE_CURR[1] = SPUtils.getPedWighttSP(mContext);
+        VALUE_CURR[1] = SPUtils.getPedWightSP(mContext);
 
         UNIT_RES[0] = getString(R.string.tips_height_unit);
         UNIT_RES[1] = getString(R.string.tips_weight_unit);
index fda808f..3f4f670 100644 (file)
@@ -3,6 +3,9 @@ package com.ic.sport.fragment.pedometer;
 import android.content.Context;
 import android.graphics.Rect;
 import android.os.Bundle;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
 
 import androidx.annotation.NonNull;
 import androidx.fragment.app.Fragment;
@@ -10,10 +13,6 @@ import androidx.fragment.app.FragmentManager;
 import androidx.recyclerview.widget.LinearLayoutManager;
 import androidx.recyclerview.widget.RecyclerView;
 
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-
 import com.ic.sport.R;
 import com.ic.sport.adapter.PedSetupAdapter;
 
@@ -83,7 +82,7 @@ public class PedSetupFragment extends Fragment {
         alertDialog.show(fm, "PedSetupDialog");
     };
 
-    public void updateSetuUpValue(int type, int value) {
+    public void updateSetUpValue(int type, int value) {
         setupAdapter.notifyUpdateValue(type, value);
     }
 
index a409d4e..c8d9811 100644 (file)
@@ -3,6 +3,8 @@ package com.ic.sport.util;
 import android.content.Context;
 import android.content.SharedPreferences;
 
+import com.ic.iclooger.ICLogger;
+
 public class SPUtils {
 
     private static final String Ped_Height = "Ped_Height";
@@ -15,26 +17,32 @@ public class SPUtils {
     }
 
     public static int getPedHeightSP(Context context) {
-        return getSp(context).getInt(Ped_Height, 170);
+        int getHeight = getSp(context).getInt(Ped_Height, 170);
+        ICLogger.d("getHeight == > " + getHeight);
+        return getHeight;
     }
 
-    public static int getPedWighttSP(Context context) {
-        return getSp(context).getInt(Ped_Weight, 75);
+    public static int getPedWightSP(Context context) {
+        int getWeight = getSp(context).getInt(Ped_Weight, 75);
+        ICLogger.d("getWeight == > " + getWeight);
+        return getWeight;
     }
 
     public static int getPedTargetSP(Context context) {
         return getSp(context).getInt(Ped_Target, 10000);
     }
 
-    public static void setPedHeightSP(Context context,int height) {
+    public static void setPedHeightSP(Context context, int height) {
+        ICLogger.d("setHeight == > " + height);
         SharedPreferences.Editor editor = getSp(context).edit();
         if (editor != null) {
-            editor.putInt(Ped_Weight, height);
+            editor.putInt(Ped_Height, height);
             editor.apply();
         }
     }
 
-    public static void setPedWighttSP(Context context,int weight) {
+    public static void setPedWeightSP(Context context, int weight) {
+        ICLogger.d("setWeight == > " + weight);
         SharedPreferences.Editor editor = getSp(context).edit();
         if (editor != null) {
             editor.putInt(Ped_Weight, weight);
@@ -42,7 +50,7 @@ public class SPUtils {
         }
     }
 
-    public static void setPedTargetSP(Context context,int target) {
+    public static void setPedTargetSP(Context context, int target) {
         SharedPreferences.Editor editor = getSp(context).edit();
         if (editor != null) {
             editor.putInt(Ped_Target, target);