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