mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 12:23:58 +01:00
Bug fix in campaigns (#2119)
* Bug fix in campaigns * remove hardcoded reference to camapign at index 0
This commit is contained in:
parent
46db38b8e9
commit
4425c36713
1 changed files with 13 additions and 11 deletions
|
|
@ -73,21 +73,23 @@ public class CampaignsPresenter implements BasePresenter {
|
||||||
}
|
}
|
||||||
return date1.compareTo(date2);
|
return date1.compareTo(date2);
|
||||||
});
|
});
|
||||||
Date campaignEndDate = null;
|
Date campaignEndDate, campaignStartDate;
|
||||||
|
Date currentDate = new Date();
|
||||||
try {
|
try {
|
||||||
campaignEndDate = dateFormat.parse(campaigns.get(0).getEndDate());
|
for (Campaign aCampaign : campaigns) {
|
||||||
|
campaignEndDate = dateFormat.parse(aCampaign.getEndDate());
|
||||||
|
campaignStartDate =
|
||||||
|
dateFormat.parse(aCampaign.getStartDate());
|
||||||
|
if (campaignEndDate.compareTo(currentDate) >= 0
|
||||||
|
&& campaignStartDate.compareTo(currentDate) <= 0) {
|
||||||
|
campaign = aCampaign;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
} catch (ParseException e) {
|
} catch (ParseException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
if (campaignEndDate == null) {
|
view.showCampaigns(campaign);
|
||||||
view.showCampaigns(null);
|
|
||||||
} else if (campaignEndDate.compareTo(new Date()) > 0) {
|
|
||||||
campaign = campaigns.get(0);
|
|
||||||
view.showCampaigns(campaign);
|
|
||||||
} else {
|
|
||||||
Log.e(TAG, "The campaigns has already finished");
|
|
||||||
view.showCampaigns(null);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public void onError(Throwable e) {
|
@Override public void onError(Throwable e) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue