cleanup upload list adapter

# Conflicts:
#	src/main/java/com/owncloud/android/ui/adapter/ExpandableUploadListAdapter.java
This commit is contained in:
AndyScherzinger 2017-08-16 22:19:43 +02:00
parent d96dee930a
commit 4b1fd06b81
No known key found for this signature in database
GPG key ID: 6CADC7E3523C308B

View file

@ -79,8 +79,8 @@ public class ExpandableUploadListAdapter extends BaseExpandableListAdapter imple
}
abstract class UploadGroup implements Refresh {
OCUpload[] items;
String name;
private OCUpload[] items;
private String name;
public UploadGroup(String groupName) {
this.name = groupName;
@ -91,6 +91,14 @@ public class ExpandableUploadListAdapter extends BaseExpandableListAdapter imple
return name;
}
public OCUpload[] getItems() {
return items;
}
public void setItems(OCUpload[] items) {
this.items = items;
}
public int getGroupItemCount() {
return items == null ? 0 : items.length;
}
@ -145,31 +153,33 @@ public class ExpandableUploadListAdapter extends BaseExpandableListAdapter imple
mParentActivity = parentActivity;
mUploadsStorageManager = new UploadsStorageManager(mParentActivity.getContentResolver(), parentActivity.getApplicationContext());
mUploadGroups = new UploadGroup[3];
mUploadGroups[0] = new UploadGroup(mParentActivity.getString(R.string.uploads_view_group_current_uploads)) {
@Override
public void refresh() {
items = mUploadsStorageManager.getCurrentAndPendingUploadsForCurrentAccount();
Arrays.sort(items, comparator);
setItems(mUploadsStorageManager.getCurrentAndPendingUploadsForCurrentAccount());
Arrays.sort(getItems(), comparator);
}
};
mUploadGroups[1] = new UploadGroup(mParentActivity.getString(R.string.uploads_view_group_failed_uploads)) {
@Override
public void refresh() {
items = mUploadsStorageManager.getFailedButNotDelayedUploadsForCurrentAccount();
Arrays.sort(items, comparator);
setItems(mUploadsStorageManager.getFailedButNotDelayedUploadsForCurrentAccount());
Arrays.sort(getItems(), comparator);
}
};
mUploadGroups[2] = new UploadGroup(mParentActivity.getString(R.string.uploads_view_group_finished_uploads)) {
@Override
public void refresh() {
items = mUploadsStorageManager.getFinishedUploadsForCurrentAccount();
Arrays.sort(items, comparator);
setItems(mUploadsStorageManager.getFinishedUploadsForCurrentAccount());
Arrays.sort(getItems(), comparator);
}
};
loadUploadItemsFromDb();
}
@Override
public void registerDataSetObserver(DataSetObserver observer) {
super.registerDataSetObserver(observer);