|
|
@@ -47,8 +47,11 @@ public class KPICell extends RelativeLayout implements View.OnClickListener,KPIL
|
|
|
private TextView mShipTV,mContainerTV,mTeuTV,mSelectionTV;
|
|
|
private KPIListView mItemListView;
|
|
|
private ValueAnimator mAnimation;
|
|
|
- public void init() {
|
|
|
|
|
|
+ public void init(int w, int h) {
|
|
|
+
|
|
|
+ mWidth = w;
|
|
|
+ mHeight = h;
|
|
|
mCell = this;
|
|
|
|
|
|
mShipTV = findViewById(R.id.shipmentTV);
|
|
|
@@ -68,7 +71,6 @@ public class KPICell extends RelativeLayout implements View.OnClickListener,KPIL
|
|
|
|
|
|
mChartView = findViewById(R.id.chart_view);
|
|
|
|
|
|
-
|
|
|
if (mAnimation == null) {
|
|
|
mAnimation = ValueAnimator.ofFloat(0f, 100f);
|
|
|
|
|
|
@@ -169,6 +171,28 @@ public class KPICell extends RelativeLayout implements View.OnClickListener,KPIL
|
|
|
// });
|
|
|
}
|
|
|
|
|
|
+ private void resizePieChartView(int w) {
|
|
|
+
|
|
|
+ int leftInterval = dp2px(getContext(),60);
|
|
|
+ int rightInterval = dp2px(getContext(),60);
|
|
|
+
|
|
|
+ final int pieW = (w - leftInterval - rightInterval);
|
|
|
+
|
|
|
+
|
|
|
+ mChartView.post(new Runnable() {
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+
|
|
|
+ LayoutParams layout = (LayoutParams)mChartView.getLayoutParams();
|
|
|
+ layout.width = (int)pieW;
|
|
|
+ layout.height = (int)pieW;
|
|
|
+ mChartView.setLayoutParams(layout);
|
|
|
+ mChartView.requestLayout();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
public void setMonthShipment(String shipment, int color) {
|
|
|
mShipTV.setText("Shipment:" + shipment);
|
|
|
mShipTV.setTextColor(color);
|
|
|
@@ -199,27 +223,35 @@ public class KPICell extends RelativeLayout implements View.OnClickListener,KPIL
|
|
|
|
|
|
super.onSizeChanged(w, h, oldw, oldh);
|
|
|
|
|
|
- int leftInterval = dp2px(getContext(),60);
|
|
|
- int rightInterval = dp2px(getContext(),60);
|
|
|
+ }
|
|
|
|
|
|
- final int pieW = (w - leftInterval - rightInterval);
|
|
|
+ private int mWidth = 0;
|
|
|
+ private int mHeight = 0;
|
|
|
|
|
|
+ public int getKPIWidth() {
|
|
|
+ return mWidth;
|
|
|
+ }
|
|
|
|
|
|
- mChartView.post(new Runnable() {
|
|
|
+ public int getKPIHeight() {
|
|
|
+ return mHeight;
|
|
|
+ }
|
|
|
|
|
|
- @Override
|
|
|
- public void run() {
|
|
|
+ @Override
|
|
|
+ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
|
|
+ super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
|
|
|
|
|
- LayoutParams layout = (LayoutParams)mChartView.getLayoutParams();
|
|
|
- layout.width = (int)pieW;
|
|
|
- layout.height = (int)pieW;
|
|
|
- mChartView.setLayoutParams(layout);
|
|
|
- mChartView.requestLayout();
|
|
|
- }
|
|
|
- });
|
|
|
+ int w = getMeasuredWidth();
|
|
|
+ int h = getMeasuredHeight();
|
|
|
|
|
|
+ if (w != mWidth) {
|
|
|
+// resizePieChartView(w);
|
|
|
+ }
|
|
|
+
|
|
|
+ mWidth = w;
|
|
|
+ mHeight = h;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
float mTotal = 0;
|
|
|
private ArrayList<PieChartView.ChartItem> preparePieChartItems() {
|
|
|
|