Fix local state if fragment is initialized before services

Signed-off-by: Unpublished <unpublished@gmx.net>
This commit is contained in:
Unpublished 2019-07-29 11:11:50 +02:00
parent 53a4844ab2
commit bdbeb5bc27

View file

@ -101,9 +101,7 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
implements DisplayUtils.AvatarGenerationListener { implements DisplayUtils.AvatarGenerationListener {
private static final int showFilenameColumnThreshold = 4; private static final int showFilenameColumnThreshold = 4;
private final FileDownloader.FileDownloaderBinder downloaderBinder; private final ComponentsGetter transferServiceGetter;
private final FileUploader.FileUploaderBinder uploaderBinder;
private final OperationsService.OperationsServiceBinder operationsServiceBinder;
private final String userId; private final String userId;
private Context mContext; private Context mContext;
private AppPreferences preferences; private AppPreferences preferences;
@ -152,9 +150,7 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
this.gridView = gridView; this.gridView = gridView;
checkedFiles = new HashSet<>(); checkedFiles = new HashSet<>();
downloaderBinder = transferServiceGetter.getFileDownloaderBinder(); this.transferServiceGetter = transferServiceGetter;
uploaderBinder = transferServiceGetter.getFileUploaderBinder();
operationsServiceBinder = transferServiceGetter.getOperationsServiceBinder();
if (account != null) { if (account != null) {
AccountManager platformAccountManager = AccountManager.get(mContext); AccountManager platformAccountManager = AccountManager.get(mContext);
@ -442,17 +438,20 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
gridViewHolder.localFileIndicator.setVisibility(View.INVISIBLE); // default first gridViewHolder.localFileIndicator.setVisibility(View.INVISIBLE); // default first
OperationsService.OperationsServiceBinder operationsServiceBinder = transferServiceGetter.getOperationsServiceBinder();
FileDownloader.FileDownloaderBinder fileDownloaderBinder = transferServiceGetter.getFileDownloaderBinder();
FileUploader.FileUploaderBinder fileUploaderBinder = transferServiceGetter.getFileUploaderBinder();
if (operationsServiceBinder != null && operationsServiceBinder.isSynchronizing(account, file)) { if (operationsServiceBinder != null && operationsServiceBinder.isSynchronizing(account, file)) {
//synchronizing //synchronizing
gridViewHolder.localFileIndicator.setImageResource(R.drawable.ic_synchronizing); gridViewHolder.localFileIndicator.setImageResource(R.drawable.ic_synchronizing);
gridViewHolder.localFileIndicator.setVisibility(View.VISIBLE); gridViewHolder.localFileIndicator.setVisibility(View.VISIBLE);
} else if (downloaderBinder != null && downloaderBinder.isDownloading(account, file)) { } else if (fileDownloaderBinder != null && fileDownloaderBinder.isDownloading(account, file)) {
// downloading // downloading
gridViewHolder.localFileIndicator.setImageResource(R.drawable.ic_synchronizing); gridViewHolder.localFileIndicator.setImageResource(R.drawable.ic_synchronizing);
gridViewHolder.localFileIndicator.setVisibility(View.VISIBLE); gridViewHolder.localFileIndicator.setVisibility(View.VISIBLE);
} else if (uploaderBinder != null && uploaderBinder.isUploading(account, file)) { } else if (fileUploaderBinder != null && fileUploaderBinder.isUploading(account, file)) {
//uploading //uploading
gridViewHolder.localFileIndicator.setImageResource(R.drawable.ic_synchronizing); gridViewHolder.localFileIndicator.setImageResource(R.drawable.ic_synchronizing);
gridViewHolder.localFileIndicator.setVisibility(View.VISIBLE); gridViewHolder.localFileIndicator.setVisibility(View.VISIBLE);