13
13
import android .view .MenuItem ;
14
14
import android .view .View ;
15
15
import android .widget .ImageView ;
16
+ import android .widget .LinearLayout ;
17
+ import android .widget .ProgressBar ;
16
18
import android .widget .RelativeLayout ;
17
19
import android .widget .TextView ;
18
20
@@ -46,6 +48,8 @@ public class AchievementsActivity extends NavigationBaseActivity {
46
48
47
49
private static final double BADGE_IMAGE_WIDTH_RATIO = 0.4 ;
48
50
private static final double BADGE_IMAGE_HEIGHT_RATIO = 0.3 ;
51
+ private Boolean isUploadFetched = false ;
52
+ private Boolean isStatisticsFetched = false ;
49
53
50
54
@ BindView (R .id .achievement_badge )
51
55
ImageView imageView ;
@@ -61,6 +65,16 @@ public class AchievementsActivity extends NavigationBaseActivity {
61
65
CircleProgressBar imagesUsedByWikiProgessbar ;
62
66
@ BindView (R .id .image_featured )
63
67
TextView imagesFeatured ;
68
+ @ BindView (R .id .progressBar )
69
+ ProgressBar progressBar ;
70
+ @ BindView (R .id .layout_image_uploaded )
71
+ RelativeLayout layoutImageUploaded ;
72
+ @ BindView (R .id .layout_image_reverts )
73
+ RelativeLayout layoutImageReverts ;
74
+ @ BindView (R .id .layout_image_used_by_wiki )
75
+ RelativeLayout layoutImageUsedByWiki ;
76
+ @ BindView (R .id .layout_statistics )
77
+ LinearLayout layoutStatistics ;
64
78
@ Inject
65
79
SessionManager sessionManager ;
66
80
@ Inject
@@ -99,6 +113,8 @@ protected void onCreate(Bundle savedInstanceState) {
99
113
imageView .requestLayout ();
100
114
101
115
setSupportActionBar (toolbar );
116
+ progressBar .setVisibility (View .VISIBLE );
117
+ hideLayouts ();
102
118
setAchievements ();
103
119
setUploadCount ();
104
120
initDrawer ();
@@ -182,6 +198,8 @@ private void setUploadProgress( int uploadCount){
182
198
Log .i ("uploadCount" ,Integer .toString (uploadCount ));
183
199
imagesUploadedProgressbar .setProgress (100 *uploadCount /25 );
184
200
imagesUploadedProgressbar .setProgressTextFormatPattern (uploadCount +"/25" );
201
+ isUploadFetched = true ;
202
+ hideProgressBar ();
185
203
}
186
204
187
205
/**
@@ -216,6 +234,8 @@ private void inflateAchievements( Achievements achievements){
216
234
imagesUsedByWikiProgessbar .setProgress (100 *achievements .getUniqueUsedImages ()/25 );
217
235
imagesUsedByWikiProgessbar .setProgressTextFormatPattern (achievements .getUniqueUsedImages () + "/25" );
218
236
imagesFeatured .setText (Integer .toString (achievements .getFeaturedImages ()));
237
+ isStatisticsFetched = true ;
238
+ hideProgressBar ();
219
239
}
220
240
221
241
/**
@@ -230,4 +250,29 @@ public static void startYourself(Context context) {
230
250
context .startActivity (intent );
231
251
}
232
252
253
+ /**
254
+ * to hide progressbar
255
+ */
256
+ private void hideProgressBar () {
257
+ if (progressBar != null && isUploadFetched && isStatisticsFetched ) {
258
+ progressBar .setVisibility (View .GONE );
259
+ layoutImageReverts .setVisibility (View .VISIBLE );
260
+ layoutImageUploaded .setVisibility (View .VISIBLE );
261
+ layoutImageUsedByWiki .setVisibility (View .VISIBLE );
262
+ layoutStatistics .setVisibility (View .VISIBLE );
263
+ imageView .setVisibility (View .VISIBLE );
264
+ }
265
+ }
266
+
267
+ /**
268
+ * used to hide the layouts while fetching results from api
269
+ */
270
+ private void hideLayouts (){
271
+ layoutImageUsedByWiki .setVisibility (View .INVISIBLE );
272
+ layoutImageUploaded .setVisibility (View .INVISIBLE );
273
+ layoutImageReverts .setVisibility (View .INVISIBLE );
274
+ layoutStatistics .setVisibility (View .INVISIBLE );
275
+ imageView .setVisibility (View .INVISIBLE );
276
+ }
277
+
233
278
}
0 commit comments