File tree 1 file changed +13
-11
lines changed
app/src/main/java/fr/free/nrw/commons/campaigns
1 file changed +13
-11
lines changed Original file line number Diff line number Diff line change @@ -73,21 +73,23 @@ public void getCampaigns() {
73
73
}
74
74
return date1 .compareTo (date2 );
75
75
});
76
- Date campaignEndDate = null ;
76
+ Date campaignEndDate , campaignStartDate ;
77
+ Date currentDate = new Date ();
77
78
try {
78
- campaignEndDate = dateFormat .parse (campaigns .get (0 ).getEndDate ());
79
+ for (Campaign aCampaign : campaigns ) {
80
+ campaignEndDate = dateFormat .parse (aCampaign .getEndDate ());
81
+ campaignStartDate =
82
+ dateFormat .parse (aCampaign .getStartDate ());
83
+ if (campaignEndDate .compareTo (currentDate ) >= 0
84
+ && campaignStartDate .compareTo (currentDate ) <= 0 ) {
85
+ campaign = aCampaign ;
86
+ break ;
87
+ }
88
+ }
79
89
} catch (ParseException e ) {
80
90
e .printStackTrace ();
81
91
}
82
- if (campaignEndDate == null ) {
83
- view .showCampaigns (null );
84
- } else if (campaignEndDate .compareTo (new Date ()) > 0 ) {
85
- campaign = campaigns .get (0 );
86
- view .showCampaigns (campaign );
87
- } else {
88
- Log .e (TAG , "The campaigns has already finished" );
89
- view .showCampaigns (null );
90
- }
92
+ view .showCampaigns (campaign );
91
93
}
92
94
93
95
@ Override public void onError (Throwable e ) {
You can’t perform that action at this time.
0 commit comments