thkouk00

conditional rendering in loyalty dropdowns v2

...@@ -78,15 +78,13 @@ public class LoyaltyActivity extends Activity implements View.OnClickListener, ...@@ -78,15 +78,13 @@ public class LoyaltyActivity extends Activity implements View.OnClickListener,
78 @Override 78 @Override
79 public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) { 79 public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
80 // parent.getItemAtPosition(pos) 80 // parent.getItemAtPosition(pos)
81 - ImageView chartImg = findViewById(R.id.cl_chart).findViewById(R.id.iv_chart);
82 - ImageView innerChartImg = findViewById(R.id.cl_chart).findViewById(R.id.iv_inner_chart);
83 81
84 if (parent.getId() == mCouponSpinner.getId()) { 82 if (parent.getId() == mCouponSpinner.getId()) {
85 if (pos == 1) { 83 if (pos == 1) {
86 mRedemptionSpinner.setVisibility(View.GONE); 84 mRedemptionSpinner.setVisibility(View.GONE);
87 findViewById(R.id.cl_tab_analysis).setVisibility(View.GONE); 85 findViewById(R.id.cl_tab_analysis).setVisibility(View.GONE);
88 - findViewById(R.id.cl_chart).setVisibility(View.GONE); 86 + findViewById(R.id.cl_chart).findViewById(R.id.cl_inner_chart).setVisibility(View.GONE);
89 -// findViewById(R.id.cl_chart2).setVisibility(View.VISIBLE); 87 + findViewById(R.id.cl_chart).findViewById(R.id.cl_inner_chart2).setVisibility(View.VISIBLE);
90 findViewById(R.id.cl_chart_info).findViewById(R.id.analysis_tab).setVisibility(View.GONE); 88 findViewById(R.id.cl_chart_info).findViewById(R.id.analysis_tab).setVisibility(View.GONE);
91 findViewById(R.id.cl_chart_info).findViewById(R.id.analysis_tab2).setVisibility(View.GONE); 89 findViewById(R.id.cl_chart_info).findViewById(R.id.analysis_tab2).setVisibility(View.GONE);
92 findViewById(R.id.cl_chart_info).findViewById(R.id.analysis_tab3).setVisibility(View.GONE); 90 findViewById(R.id.cl_chart_info).findViewById(R.id.analysis_tab3).setVisibility(View.GONE);
...@@ -94,8 +92,8 @@ public class LoyaltyActivity extends Activity implements View.OnClickListener, ...@@ -94,8 +92,8 @@ public class LoyaltyActivity extends Activity implements View.OnClickListener,
94 findViewById(R.id.cl_chart_info).findViewById(R.id.analysis_tab5).setVisibility(View.VISIBLE); 92 findViewById(R.id.cl_chart_info).findViewById(R.id.analysis_tab5).setVisibility(View.VISIBLE);
95 } else { 93 } else {
96 mRedemptionSpinner.setVisibility(View.VISIBLE); 94 mRedemptionSpinner.setVisibility(View.VISIBLE);
97 - findViewById(R.id.cl_chart).setVisibility(View.VISIBLE); 95 + findViewById(R.id.cl_chart).findViewById(R.id.cl_inner_chart).setVisibility(View.VISIBLE);
98 -// findViewById(R.id.cl_chart2).setVisibility(View.GONE); 96 + findViewById(R.id.cl_chart).findViewById(R.id.cl_inner_chart2).setVisibility(View.GONE);
99 findViewById(R.id.cl_tab_analysis).setVisibility(View.VISIBLE); 97 findViewById(R.id.cl_tab_analysis).setVisibility(View.VISIBLE);
100 findViewById(R.id.cl_chart_info).findViewById(R.id.analysis_tab).setVisibility(View.VISIBLE); 98 findViewById(R.id.cl_chart_info).findViewById(R.id.analysis_tab).setVisibility(View.VISIBLE);
101 findViewById(R.id.cl_chart_info).findViewById(R.id.analysis_tab2).setVisibility(View.VISIBLE); 99 findViewById(R.id.cl_chart_info).findViewById(R.id.analysis_tab2).setVisibility(View.VISIBLE);
......
...@@ -18,6 +18,14 @@ ...@@ -18,6 +18,14 @@
18 android:orientation="vertical" 18 android:orientation="vertical"
19 app:layout_constraintGuide_percent="0.85" /> 19 app:layout_constraintGuide_percent="0.85" />
20 20
21 + <include
22 + android:id="@+id/piechart"
23 + layout="@layout/cos_piechart2"
24 + app:layout_constraintBottom_toBottomOf="parent"
25 + app:layout_constraintEnd_toEndOf="@+id/iv_chart"
26 + app:layout_constraintStart_toStartOf="parent"
27 + app:layout_constraintTop_toTopOf="parent" />
28 +
21 <ImageView 29 <ImageView
22 android:id="@+id/iv_chart" 30 android:id="@+id/iv_chart"
23 android:layout_width="0dp" 31 android:layout_width="0dp"
......
1 +<?xml version="1.0" encoding="utf-8"?>
2 +<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
3 + xmlns:app="http://schemas.android.com/apk/res-auto"
4 + android:layout_width="200dp"
5 + android:layout_height="200dp">
6 +
7 + <androidx.constraintlayout.widget.Guideline
8 + android:id="@+id/gl_vertical_15_guideline"
9 + android:layout_width="wrap_content"
10 + android:layout_height="wrap_content"
11 + android:orientation="vertical"
12 + app:layout_constraintGuide_percent="0.15" />
13 +
14 + <androidx.constraintlayout.widget.Guideline
15 + android:id="@+id/gl_vertical_85_guideline"
16 + android:layout_width="wrap_content"
17 + android:layout_height="wrap_content"
18 + android:orientation="vertical"
19 + app:layout_constraintGuide_percent="0.85" />
20 +
21 + <include
22 + android:id="@+id/cl_inner_chart"
23 + layout="@layout/cos_piechart"
24 + android:layout_width="200dp"
25 + android:layout_height="200dp"
26 + app:layout_constraintEnd_toEndOf="parent"
27 + app:layout_constraintStart_toStartOf="parent"
28 + app:layout_constraintTop_toTopOf="parent" />
29 +
30 + <include
31 + android:id="@+id/cl_inner_chart2"
32 + layout="@layout/cos_piechart2"
33 + android:layout_width="200dp"
34 + android:layout_height="200dp"
35 + app:layout_constraintEnd_toEndOf="parent"
36 + app:layout_constraintStart_toStartOf="parent"
37 + app:layout_constraintTop_toTopOf="parent" />
38 +</androidx.constraintlayout.widget.ConstraintLayout>
...\ No newline at end of file ...\ No newline at end of file
...@@ -63,7 +63,7 @@ ...@@ -63,7 +63,7 @@
63 63
64 <include 64 <include
65 android:id="@+id/cl_chart" 65 android:id="@+id/cl_chart"
66 - layout="@layout/cos_piechart" 66 + layout="@layout/cos_piechart_conditional_render"
67 android:layout_width="200dp" 67 android:layout_width="200dp"
68 android:layout_height="200dp" 68 android:layout_height="200dp"
69 app:layout_constraintEnd_toEndOf="parent" 69 app:layout_constraintEnd_toEndOf="parent"
......