Răsfoiți Sursa

1.修改Android Apex Mobile KPI显示空白。

Pen Li 8 ani în urmă
părinte
comite
490607a3b4

+ 7 - 6
Apex Mobile/app/src/main/java/com/usai/apex/KPI/PieChartView.java

@@ -29,11 +29,11 @@ import java.util.Random;
 
 public class PieChartView extends View {
 
-    private static float titleFontSize = 40.0f;
-    private static float nameFontSize = 50.0f;
-    private static float detal = 10;
-    private static double M_PI = 3.14159265358979323846264338327950288;
-    private static double M_PI_2 = 1.57079632679489661923132169163975144;
+    private  float titleFontSize = 40.0f;
+    private  float nameFontSize = 50.0f;
+    private  float detal = 10;
+    private  double M_PI = 3.14159265358979323846264338327950288;
+    private  double M_PI_2 = 1.57079632679489661923132169163975144;
 
     public interface PieChartItemClickListener {
 
@@ -167,7 +167,7 @@ public class PieChartView extends View {
     private Paint mBrush = new Paint(Paint.ANTI_ALIAS_FLAG);
     private int mWidth,mHeight;
     private Context mCtx;
-    private ArrayList<ChartItem> chartItems;
+    private ArrayList<ChartItem> chartItems = new ArrayList<>();
     private ChartItem mSelectedItem;
     private float mRadius;
     private PieChartItemClickListener mPieChartItemClickListener;
@@ -206,6 +206,7 @@ public class PieChartView extends View {
             }
 
         } else {
+            chartItems = new ArrayList<>();
             total = 0;
         }
 

+ 24 - 17
Apex Mobile/app/src/main/java/com/usai/apex/mainframe/KPIFragment.java

@@ -113,8 +113,13 @@ public class KPIFragment extends Fragment implements KPICell.KPIListener {
         // Inflate the layout for this fragment
         View root = inflater.inflate(R.layout.fragment_kpi, container, false);
 
-        mWidth = container.getMeasuredWidth();
-        mHeight = container.getMeasuredHeight();
+        if (savedInstanceState != null) {
+            mWidth = savedInstanceState.getInt("width");
+            mHeight = savedInstanceState.getInt("height");
+        } else {
+            mWidth = container.getMeasuredWidth();
+            mHeight = container.getMeasuredHeight();
+        }
 
         mContext = getContext();
         self = this;
@@ -170,21 +175,21 @@ public class KPIFragment extends Fragment implements KPICell.KPIListener {
 
         mSwipeRefresh.setEnabled(true);
 
-        if (savedInstanceState != null) {
-            String kpiString = savedInstanceState.getString("KPIData");
-            if (kpiString != null) {
-                try {
-                    mData = new JSONObject(kpiString);
-                    prepareData();
-                } catch (JSONException e) {
-                    e.printStackTrace();
-                }
-            }
-        }
-
-        if (mKPIArr == null || mKPIArr.size() == 0) {
-            loadKPIData();
-        }
+//        if (savedInstanceState != null) {
+//            String kpiString = savedInstanceState.getString("KPIData");
+//            if (kpiString != null) {
+//                try {
+//                    mData = new JSONObject(kpiString);
+//                    prepareData();
+//                } catch (JSONException e) {
+//                    e.printStackTrace();
+//                }
+//            }
+//        }
+//
+//        if (mKPIArr == null || mKPIArr.size() == 0) {
+//            loadKPIData();
+//        }
 
         return root;
     }
@@ -232,6 +237,8 @@ public class KPIFragment extends Fragment implements KPICell.KPIListener {
         if (mData != null) {
             outState.putString("KPIData",mData.toString());
             outState.putInt("currentKPI",currentKPI);
+            outState.putInt("width",mWidth);
+            outState.putInt("height",mHeight);
         }
         mKPIArr.clear();
         mAdapter.notifyDataSetChanged();