Search in sources :

Example 1 with UploaderAdapter

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));
    }
}
Also used : HashMap(java.util.HashMap) FileSortOrder(com.owncloud.android.utils.FileSortOrder) MaterialButton(com.google.android.material.button.MaterialButton) LinkedList(java.util.LinkedList) OCFile(com.owncloud.android.datamodel.OCFile) ListView(android.widget.ListView) UploaderAdapter(com.owncloud.android.ui.adapter.UploaderAdapter) Button(android.widget.Button) MaterialButton(com.google.android.material.button.MaterialButton) Map(java.util.Map) HashMap(java.util.HashMap) ActionBar(androidx.appcompat.app.ActionBar)

Aggregations

Button (android.widget.Button)1 ListView (android.widget.ListView)1 ActionBar (androidx.appcompat.app.ActionBar)1 MaterialButton (com.google.android.material.button.MaterialButton)1 OCFile (com.owncloud.android.datamodel.OCFile)1 UploaderAdapter (com.owncloud.android.ui.adapter.UploaderAdapter)1 FileSortOrder (com.owncloud.android.utils.FileSortOrder)1 HashMap (java.util.HashMap)1 LinkedList (java.util.LinkedList)1 Map (java.util.Map)1