parent
b3ed64ddaf
commit
a656e8e133
@ -20,10 +20,8 @@ import org.fdroid.fdroid.AppUpdateStatusManager;
|
||||
import org.fdroid.fdroid.data.App;
|
||||
import org.fdroid.fdroid.data.AppProvider;
|
||||
import org.fdroid.fdroid.data.Schema;
|
||||
import org.fdroid.fdroid.views.updates.items.AppNotification;
|
||||
import org.fdroid.fdroid.views.updates.items.AppStatus;
|
||||
import org.fdroid.fdroid.views.updates.items.AppUpdateData;
|
||||
import org.fdroid.fdroid.views.updates.items.DonationPrompt;
|
||||
import org.fdroid.fdroid.views.updates.items.UpdateableApp;
|
||||
import org.fdroid.fdroid.views.updates.items.UpdateableAppsHeader;
|
||||
|
||||
@ -45,8 +43,8 @@ import java.util.Set;
|
||||
* + Once "Show apps" is expanded then each app is shown along with its own download button.
|
||||
*
|
||||
* It does this by maintaining several different lists of interesting apps. Each list contains wrappers
|
||||
* around the piece of data it wants to render ({@link AppStatus}, {@link DonationPrompt},
|
||||
* {@link AppNotification}, {@link UpdateableApp}). Instead of juggling the various viewTypes
|
||||
* around the piece of data it wants to render ({@link AppStatus}, {@link UpdateableApp}).
|
||||
* Instead of juggling the various viewTypes
|
||||
* to find out which position in the adapter corresponds to which view type, this is handled by
|
||||
* the {@link UpdatesAdapter#delegatesManager}.
|
||||
*
|
||||
@ -68,8 +66,6 @@ public class UpdatesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
|
||||
private final AppCompatActivity activity;
|
||||
|
||||
private final List<AppStatus> appsToShowStatus = new ArrayList<>();
|
||||
private final List<DonationPrompt> appsToPromptForDonation = new ArrayList<>();
|
||||
private final List<AppNotification> appsToNotifyAbout = new ArrayList<>();
|
||||
private final List<UpdateableApp> updateableApps = new ArrayList<>();
|
||||
|
||||
private boolean showAllUpdateableApps = false;
|
||||
@ -78,8 +74,6 @@ public class UpdatesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
|
||||
this.activity = activity;
|
||||
|
||||
delegatesManager.addDelegate(new AppStatus.Delegate(activity))
|
||||
.addDelegate(new AppNotification.Delegate())
|
||||
.addDelegate(new DonationPrompt.Delegate())
|
||||
.addDelegate(new UpdateableApp.Delegate(activity))
|
||||
.addDelegate(new UpdateableAppsHeader.Delegate(activity));
|
||||
|
||||
@ -164,9 +158,6 @@ public class UpdatesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
items.addAll(appsToPromptForDonation);
|
||||
items.addAll(appsToNotifyAbout);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,56 +0,0 @@
|
||||
package org.fdroid.fdroid.views.updates.items;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.hannesdorfmann.adapterdelegates3.AdapterDelegate;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Each of these apps has a notification to display to the user.
|
||||
* The notification will have come from the apps metadata, provided by its maintainer. It may be
|
||||
* something about the app being removed from the repository, or perhaps security problems that
|
||||
* were identified in the app.
|
||||
*/
|
||||
public class AppNotification extends AppUpdateData {
|
||||
|
||||
public AppNotification(Activity activity) {
|
||||
super(activity);
|
||||
}
|
||||
|
||||
public static class Delegate extends AdapterDelegate<List<AppUpdateData>> {
|
||||
|
||||
@Override
|
||||
protected boolean isForViewType(@NonNull List<AppUpdateData> items, int position) {
|
||||
return items.get(position) instanceof AppNotification;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
protected RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent) {
|
||||
return new ViewHolder(new TextView(parent.getContext()));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onBindViewHolder(@NonNull List<AppUpdateData> items, int position, @NonNull RecyclerView.ViewHolder holder, @NonNull List<Object> payloads) {
|
||||
AppNotification app = (AppNotification) items.get(position);
|
||||
((ViewHolder) holder).bindApp(app);
|
||||
}
|
||||
}
|
||||
|
||||
public static class ViewHolder extends RecyclerView.ViewHolder {
|
||||
public ViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
}
|
||||
|
||||
public void bindApp(AppNotification app) {
|
||||
((TextView) itemView).setText("");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,54 +0,0 @@
|
||||
package org.fdroid.fdroid.views.updates.items;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.hannesdorfmann.adapterdelegates3.AdapterDelegate;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* The app (if any) which we should prompt the user about potentially donating to (due to having
|
||||
* updated several times).
|
||||
*/
|
||||
public class DonationPrompt extends AppUpdateData {
|
||||
|
||||
public DonationPrompt(Activity activity) {
|
||||
super(activity);
|
||||
}
|
||||
|
||||
public static class Delegate extends AdapterDelegate<List<AppUpdateData>> {
|
||||
|
||||
@Override
|
||||
protected boolean isForViewType(@NonNull List<AppUpdateData> items, int position) {
|
||||
return items.get(position) instanceof DonationPrompt;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
protected RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent) {
|
||||
return new ViewHolder(new TextView(parent.getContext()));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onBindViewHolder(@NonNull List<AppUpdateData> items, int position, @NonNull RecyclerView.ViewHolder holder, @NonNull List<Object> payloads) {
|
||||
DonationPrompt app = (DonationPrompt) items.get(position);
|
||||
((ViewHolder) holder).bindApp(app);
|
||||
}
|
||||
}
|
||||
|
||||
public static class ViewHolder extends RecyclerView.ViewHolder {
|
||||
public ViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
}
|
||||
|
||||
public void bindApp(DonationPrompt app) {
|
||||
((TextView) itemView).setText("");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user