mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-28 21:33:53 +01:00
Update master with backend overhaul branch (#2829)
* Beginnings of integration with Wikipedia client library. (#2642) * Remove remaining unnecessary API version check. * Roll up sleeves. * Add and integrate the beginnings of app adapter. * Remove vestigial event logging logic. Event logging is no longer used in this app. * Beginnings: remove StringUtils and associated redundancies. * Remove redundant capitalize() method. * Remove redundant urlEncode() method. * Remove redundant (and incomplete) language lists. * Remove redundant usages of SimpleDateFormat. * Remove redundant json type adapter. * Remove redundant MW error model classes. * Rip out redundant MW model classes. * Pass SessionManager into AppAdapter instead of injecting. * Wire up more of the AppAdapter. * Remove redundant Gson initialization and type adapters. * Rip out PageTitle. This was being used in some slightly incorrect/unexpected ways. * Don't need static WikiSite. * Bump data client library version * Bump library version and fix build * Fix tests * Fix build * Fix media of the day * With fixes in recently modified APIs
This commit is contained in:
parent
76e5a30fb5
commit
dcbf076965
76 changed files with 424 additions and 2122 deletions
|
|
@ -6,8 +6,9 @@ import android.util.AttributeSet;
|
|||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.wikipedia.util.DateUtil;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
|
@ -85,13 +86,11 @@ public class CampaignView extends SwipableCardView {
|
|||
if (campaign != null) {
|
||||
tvTitle.setText(campaign.getTitle());
|
||||
tvDescription.setText(campaign.getDescription());
|
||||
SimpleDateFormat inputDateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
||||
SimpleDateFormat outputDateFormat = new SimpleDateFormat("dd MMM");
|
||||
try {
|
||||
Date startDate = inputDateFormat.parse(campaign.getStartDate());
|
||||
Date endDate = inputDateFormat.parse(campaign.getEndDate());
|
||||
tvDates.setText(String.format("%1s - %2s", outputDateFormat.format(startDate),
|
||||
outputDateFormat.format(endDate)));
|
||||
Date startDate = DateUtil.getIso8601DateFormatShort().parse(campaign.getStartDate());
|
||||
Date endDate = DateUtil.getIso8601DateFormatShort().parse(campaign.getEndDate());
|
||||
tvDates.setText(String.format("%1s - %2s", DateUtil.getExtraShortDateString(startDate),
|
||||
DateUtil.getExtraShortDateString(endDate)));
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,8 +2,9 @@ package fr.free.nrw.commons.campaigns;
|
|||
|
||||
import android.annotation.SuppressLint;
|
||||
|
||||
import org.wikipedia.util.DateUtil;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
|
@ -71,7 +72,6 @@ public class CampaignsPresenter implements BasePresenter {
|
|||
|
||||
@Override public void onSuccess(CampaignResponseDTO campaignResponseDTO) {
|
||||
List<Campaign> campaigns = campaignResponseDTO.getCampaigns();
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
||||
if (campaigns == null || campaigns.isEmpty()) {
|
||||
Timber.e("The campaigns list is empty");
|
||||
view.showCampaigns(null);
|
||||
|
|
@ -79,8 +79,8 @@ public class CampaignsPresenter implements BasePresenter {
|
|||
Collections.sort(campaigns, (campaign, t1) -> {
|
||||
Date date1, date2;
|
||||
try {
|
||||
date1 = dateFormat.parse(campaign.getStartDate());
|
||||
date2 = dateFormat.parse(t1.getStartDate());
|
||||
date1 = DateUtil.getIso8601DateFormatShort().parse(campaign.getStartDate());
|
||||
date2 = DateUtil.getIso8601DateFormatShort().parse(t1.getStartDate());
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
return -1;
|
||||
|
|
@ -91,9 +91,8 @@ public class CampaignsPresenter implements BasePresenter {
|
|||
Date currentDate = new Date();
|
||||
try {
|
||||
for (Campaign aCampaign : campaigns) {
|
||||
campaignEndDate = dateFormat.parse(aCampaign.getEndDate());
|
||||
campaignStartDate =
|
||||
dateFormat.parse(aCampaign.getStartDate());
|
||||
campaignEndDate = DateUtil.getIso8601DateFormatShort().parse(aCampaign.getEndDate());
|
||||
campaignStartDate = DateUtil.getIso8601DateFormatShort().parse(aCampaign.getStartDate());
|
||||
if (campaignEndDate.compareTo(currentDate) >= 0
|
||||
&& campaignStartDate.compareTo(currentDate) <= 0) {
|
||||
campaign = aCampaign;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue