Only show "New" next to apps added in the last two weeks.
Previously, the definition of "New" was whether or not the added and last updated dates were the same. This made sense, because we only showed apps from the past few weeks (depending on preferences) as new. Now that we show up to 200 apps in the first screen, regardless of age, this check is no longer helpful.
This commit is contained in:
parent
c5051e8813
commit
d41b0d330f
@ -38,6 +38,12 @@ import org.fdroid.fdroid.views.apps.FeatureImage;
|
|||||||
* + {@link R.id#featured_image} ({@link ImageView}, optional)
|
* + {@link R.id#featured_image} ({@link ImageView}, optional)
|
||||||
*/
|
*/
|
||||||
public class AppCardController extends RecyclerView.ViewHolder implements ImageLoadingListener, View.OnClickListener {
|
public class AppCardController extends RecyclerView.ViewHolder implements ImageLoadingListener, View.OnClickListener {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* After this many days, don't consider showing the "New" tag next to an app.
|
||||||
|
*/
|
||||||
|
private static final int DAYS_TO_CONSIDER_NEW = 14;
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
private final ImageView icon;
|
private final ImageView icon;
|
||||||
|
|
||||||
@ -104,7 +110,7 @@ public class AppCardController extends RecyclerView.ViewHolder implements ImageL
|
|||||||
summary.setText(Utils.formatAppNameAndSummary(app.name, app.summary));
|
summary.setText(Utils.formatAppNameAndSummary(app.name, app.summary));
|
||||||
|
|
||||||
if (newTag != null) {
|
if (newTag != null) {
|
||||||
if (app.added != null && app.lastUpdated != null && app.added.equals(app.lastUpdated)) {
|
if (isConsideredNew(app)) {
|
||||||
newTag.setVisibility(View.VISIBLE);
|
newTag.setVisibility(View.VISIBLE);
|
||||||
} else {
|
} else {
|
||||||
newTag.setVisibility(View.GONE);
|
newTag.setVisibility(View.GONE);
|
||||||
@ -130,6 +136,15 @@ public class AppCardController extends RecyclerView.ViewHolder implements ImageL
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean isConsideredNew(@NonNull App app) {
|
||||||
|
//noinspection SimplifiableIfStatement
|
||||||
|
if (app.added == null || app.lastUpdated == null || !app.added.equals(app.lastUpdated)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Utils.daysSince(app.added) <= DAYS_TO_CONSIDER_NEW;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* When the user clicks/touches an app card, we launch the {@link AppDetails2} activity in response.
|
* When the user clicks/touches an app card, we launch the {@link AppDetails2} activity in response.
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user