use of com.owncloud.android.ui.adapter.UploaderAdapter in project android by nextcloud.
the class ReceiveExternalFilesActivity method populateDirectoryList.
private void populateDirectoryList() {
setContentView(R.layout.receive_external_files);
setupEmptyList();
setupToolbar();
ActionBar actionBar = getSupportActionBar();
setupActionBarSubtitle();
ListView mListView = findViewById(android.R.id.list);
findViewById(R.id.sort_list_button_group).setVisibility(View.VISIBLE);
findViewById(R.id.switch_grid_view_button).setVisibility(View.GONE);
String current_dir = mParents.peek();
boolean notRoot = mParents.size() > 1;
if (actionBar != null) {
if (TextUtils.isEmpty(current_dir)) {
ThemeToolbarUtils.setColoredTitle(actionBar, R.string.uploader_top_message, this);
} else {
ThemeToolbarUtils.setColoredTitle(actionBar, current_dir, this);
}
actionBar.setDisplayHomeAsUpEnabled(notRoot);
actionBar.setHomeButtonEnabled(notRoot);
}
String full_path = generatePath(mParents);
Log_OC.d(TAG, "Populating view with content of : " + full_path);
mFile = getStorageManager().getFileByPath(full_path);
if (mFile != null) {
List<OCFile> files = getStorageManager().getFolderContent(mFile, false);
if (files.isEmpty()) {
setMessageForEmptyList(R.string.file_list_empty_headline, R.string.empty, R.drawable.uploads);
} else {
mEmptyListContainer.setVisibility(View.GONE);
files = sortFileList(files);
List<Map<String, Object>> data = new LinkedList<>();
for (OCFile f : files) {
Map<String, Object> h = new HashMap<>();
h.put("dirname", f);
data.add(h);
}
UploaderAdapter sa = new UploaderAdapter(this, data, R.layout.uploader_list_item_layout, new String[] { "dirname" }, new int[] { R.id.filename }, getStorageManager(), getUser().get());
mListView.setAdapter(sa);
}
MaterialButton btnChooseFolder = findViewById(R.id.uploader_choose_folder);
ThemeButtonUtils.colorPrimaryButton(btnChooseFolder, this);
btnChooseFolder.setOnClickListener(this);
if (mFile.canWrite()) {
btnChooseFolder.setEnabled(true);
ThemeButtonUtils.colorPrimaryButton(btnChooseFolder, this);
} else {
btnChooseFolder.setEnabled(false);
btnChooseFolder.setBackgroundColor(Color.GRAY);
}
ThemeToolbarUtils.colorStatusBar(this);
ThemeToolbarUtils.tintBackButton(actionBar, this);
Button btnNewFolder = findViewById(R.id.uploader_cancel);
btnNewFolder.setTextColor(ThemeColorUtils.primaryColor(this, true));
btnNewFolder.setOnClickListener(this);
mListView.setOnItemClickListener(this);
sortButton = findViewById(R.id.sort_button);
FileSortOrder sortOrder = preferences.getSortOrderByFolder(mFile);
sortButton.setText(DisplayUtils.getSortOrderStringId(sortOrder));
sortButton.setOnClickListener(l -> openSortingOrderDialogFragment(getSupportFragmentManager(), sortOrder));
}
}
Aggregations