Search in sources :

Example 1 with LayoutElementParcelable

use of com.amaze.filemanager.adapters.data.LayoutElementParcelable in project AmazeFileManager by TeamAmaze.

the class MainFragment method addTo.

// method to add search result entry to the LIST_ELEMENT arrayList
private LayoutElementParcelable addTo(HybridFileParcelable mFile) {
    File f = new File(mFile.getPath());
    String size = "";
    if (!dataUtils.isFileHidden(mFile.getPath())) {
        if (mFile.isDirectory()) {
            size = "";
            LayoutElementParcelable layoutElement = new LayoutElementParcelable(f.getPath(), mFile.getPermission(), mFile.getLink(), size, 0, true, false, mFile.getDate() + "", getBoolean(PREFERENCE_SHOW_THUMB));
            layoutElement.setMode(mFile.getMode());
            LIST_ELEMENTS.add(layoutElement);
            folder_count++;
            return layoutElement;
        } else {
            long longSize = 0;
            try {
                if (mFile.getSize() != -1) {
                    longSize = mFile.getSize();
                    size = Formatter.formatFileSize(getContext(), longSize);
                } else {
                    size = "";
                    longSize = 0;
                }
            } catch (NumberFormatException e) {
            // e.printStackTrace();
            }
            try {
                LayoutElementParcelable layoutElement = new LayoutElementParcelable(f.getPath(), mFile.getPermission(), mFile.getLink(), size, longSize, false, false, mFile.getDate() + "", getBoolean(PREFERENCE_SHOW_THUMB));
                layoutElement.setMode(mFile.getMode());
                LIST_ELEMENTS.add(layoutElement);
                file_count++;
                return layoutElement;
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
    return null;
}
Also used : LayoutElementParcelable(com.amaze.filemanager.adapters.data.LayoutElementParcelable) File(java.io.File) SmbFile(jcifs.smb.SmbFile) HybridFile(com.amaze.filemanager.filesystem.HybridFile) SmbException(jcifs.smb.SmbException) ActivityNotFoundException(android.content.ActivityNotFoundException) MalformedURLException(java.net.MalformedURLException)

Example 2 with LayoutElementParcelable

use of com.amaze.filemanager.adapters.data.LayoutElementParcelable in project AmazeFileManager by TeamAmaze.

the class GeneralDialogCreation method deleteFilesDialog.

@SuppressWarnings("ConstantConditions")
public static void deleteFilesDialog(final Context c, final ArrayList<LayoutElementParcelable> layoutElements, final MainActivity mainActivity, final List<LayoutElementParcelable> positions, AppTheme appTheme) {
    final ArrayList<HybridFileParcelable> itemsToDelete = new ArrayList<>();
    int accentColor = mainActivity.getColorPreference().getColor(ColorUsage.ACCENT);
    // Build dialog with custom view layout and accent color.
    MaterialDialog dialog = new MaterialDialog.Builder(c).title(c.getString(R.string.dialog_delete_title)).customView(R.layout.dialog_delete, true).theme(appTheme.getMaterialDialogTheme()).negativeText(c.getString(R.string.cancel).toUpperCase()).positiveText(c.getString(R.string.delete).toUpperCase()).positiveColor(accentColor).negativeColor(accentColor).onPositive((dialog1, which) -> {
        Toast.makeText(c, c.getString(R.string.deleting), Toast.LENGTH_SHORT).show();
        mainActivity.mainActivityHelper.deleteFiles(itemsToDelete);
    }).build();
    // Get views from custom layout to set text values.
    final TextView categoryDirectories = (TextView) dialog.getCustomView().findViewById(R.id.category_directories);
    final TextView categoryFiles = (TextView) dialog.getCustomView().findViewById(R.id.category_files);
    final TextView listDirectories = (TextView) dialog.getCustomView().findViewById(R.id.list_directories);
    final TextView listFiles = (TextView) dialog.getCustomView().findViewById(R.id.list_files);
    final TextView total = (TextView) dialog.getCustomView().findViewById(R.id.total);
    // Parse items to delete.
    new AsyncTask<Void, Object, Void>() {

        long sizeTotal = 0;

        StringBuilder files = new StringBuilder();

        StringBuilder directories = new StringBuilder();

        int counterDirectories = 0;

        int counterFiles = 0;

        @Override
        protected void onPreExecute() {
            super.onPreExecute();
            listFiles.setText(c.getString(R.string.loading));
            listDirectories.setText(c.getString(R.string.loading));
            total.setText(c.getString(R.string.loading));
        }

        @Override
        protected Void doInBackground(Void... params) {
            for (int i = 0; i < positions.size(); i++) {
                final LayoutElementParcelable layoutElement = positions.get(i);
                itemsToDelete.add(layoutElement.generateBaseFile());
                // Build list of directories to delete.
                if (layoutElement.isDirectory) {
                    // Don't add newline between category and list.
                    if (counterDirectories != 0) {
                        directories.append("\n");
                    }
                    long sizeDirectory = layoutElement.generateBaseFile().folderSize(c);
                    directories.append(++counterDirectories).append(". ").append(layoutElement.title).append(" (").append(Formatter.formatFileSize(c, sizeDirectory)).append(")");
                    sizeTotal += sizeDirectory;
                // Build list of files to delete.
                } else {
                    // Don't add newline between category and list.
                    if (counterFiles != 0) {
                        files.append("\n");
                    }
                    files.append(++counterFiles).append(". ").append(layoutElement.title).append(" (").append(layoutElement.size).append(")");
                    sizeTotal += layoutElement.longSize;
                }
                publishProgress(sizeTotal, counterFiles, counterDirectories, files, directories);
            }
            return null;
        }

        @Override
        protected void onProgressUpdate(Object... result) {
            super.onProgressUpdate(result);
            int tempCounterFiles = (int) result[1];
            int tempCounterDirectories = (int) result[2];
            long tempSizeTotal = (long) result[0];
            StringBuilder tempFilesStringBuilder = (StringBuilder) result[3];
            StringBuilder tempDirectoriesStringBuilder = (StringBuilder) result[4];
            updateViews(tempSizeTotal, tempFilesStringBuilder, tempDirectoriesStringBuilder, tempCounterFiles, tempCounterDirectories);
        }

        @Override
        protected void onPostExecute(Void aVoid) {
            super.onPostExecute(aVoid);
            updateViews(sizeTotal, files, directories, counterFiles, counterDirectories);
        }

        private void updateViews(long tempSizeTotal, StringBuilder filesStringBuilder, StringBuilder directoriesStringBuilder, int... values) {
            int tempCounterFiles = values[0];
            int tempCounterDirectories = values[1];
            // Hide category and list for directories when zero.
            if (tempCounterDirectories == 0) {
                if (tempCounterDirectories == 0) {
                    categoryDirectories.setVisibility(View.GONE);
                    listDirectories.setVisibility(View.GONE);
                }
            // Hide category and list for files when zero.
            }
            if (tempCounterFiles == 0) {
                categoryFiles.setVisibility(View.GONE);
                listFiles.setVisibility(View.GONE);
            }
            if (tempCounterDirectories != 0 || tempCounterFiles != 0) {
                listDirectories.setText(directoriesStringBuilder);
                if (listDirectories.getVisibility() != View.VISIBLE && tempCounterDirectories != 0)
                    listDirectories.setVisibility(View.VISIBLE);
                listFiles.setText(filesStringBuilder);
                if (listFiles.getVisibility() != View.VISIBLE && tempCounterFiles != 0)
                    listFiles.setVisibility(View.VISIBLE);
                if (categoryDirectories.getVisibility() != View.VISIBLE && tempCounterDirectories != 0)
                    categoryDirectories.setVisibility(View.VISIBLE);
                if (categoryFiles.getVisibility() != View.VISIBLE && tempCounterFiles != 0)
                    categoryFiles.setVisibility(View.VISIBLE);
            }
            // Show total size with at least one directory or file and size is not zero.
            if (tempCounterFiles + tempCounterDirectories > 1 && tempSizeTotal > 0) {
                StringBuilder builderTotal = new StringBuilder().append(c.getString(R.string.total)).append(" ").append(Formatter.formatFileSize(c, tempSizeTotal));
                total.setText(builderTotal);
                if (total.getVisibility() != View.VISIBLE)
                    total.setVisibility(View.VISIBLE);
            } else {
                total.setVisibility(View.GONE);
            }
        }
    }.execute();
    // Set category text color for Jelly Bean (API 16) and later.
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        categoryDirectories.setTextColor(accentColor);
        categoryFiles.setTextColor(accentColor);
    }
    // Show dialog on screen.
    dialog.show();
}
Also used : LinearLayout(android.widget.LinearLayout) PreferencesConstants(com.amaze.filemanager.fragments.preference_fragments.PreferencesConstants) ColorUsage(com.amaze.filemanager.utils.color.ColorUsage) ShellNotRunningException(com.amaze.filemanager.exceptions.ShellNotRunningException) Uri(android.net.Uri) WindowManager(android.view.WindowManager) TextInputLayout(android.support.design.widget.TextInputLayout) ThemedActivity(com.amaze.filemanager.activities.superclasses.ThemedActivity) AppTheme(com.amaze.filemanager.utils.theme.AppTheme) CompressedHelper(com.amaze.filemanager.filesystem.compressed.CompressedHelper) RootHelper(com.amaze.filemanager.filesystem.RootHelper) GeneralSecurityException(java.security.GeneralSecurityException) CheckBox(android.widget.CheckBox) View(android.view.View) Button(android.widget.Button) RootUtils(com.amaze.filemanager.utils.RootUtils) PreferenceManager(android.preference.PreferenceManager) PieChart(com.github.mikephil.charting.charts.PieChart) PieData(com.github.mikephil.charting.data.PieData) LoadFolderSpaceDataTask(com.amaze.filemanager.asynchronous.asynctasks.LoadFolderSpaceDataTask) LayoutElementParcelable(com.amaze.filemanager.adapters.data.LayoutElementParcelable) M(android.os.Build.VERSION_CODES.M) AsyncTask(android.os.AsyncTask) Entry(com.github.mikephil.charting.data.Entry) InputType(android.text.InputType) FingerprintManager(android.hardware.fingerprint.FingerprintManager) Executors(java.util.concurrent.Executors) CryptUtil(com.amaze.filemanager.utils.files.CryptUtil) List(java.util.List) TextView(android.widget.TextView) HiddenAdapter(com.amaze.filemanager.adapters.HiddenAdapter) R(com.amaze.filemanager.R) MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) CountItemsOrAndSizeTask(com.amaze.filemanager.asynchronous.asynctasks.CountItemsOrAndSizeTask) AppCompatEditText(android.support.v7.widget.AppCompatEditText) SimpleTextWatcher(com.amaze.filemanager.utils.SimpleTextWatcher) Legend(com.github.mikephil.charting.components.Legend) Typeface(android.graphics.Typeface) Context(android.content.Context) IValueFormatter(com.github.mikephil.charting.formatter.IValueFormatter) HybridFile(com.amaze.filemanager.filesystem.HybridFile) MainFragment(com.amaze.filemanager.fragments.MainFragment) FingerprintHandler(com.amaze.filemanager.utils.FingerprintHandler) Intent(android.content.Intent) RequiresApi(android.support.annotation.RequiresApi) FileUtils.toHybridFileArrayList(com.amaze.filemanager.utils.files.FileUtils.toHybridFileArrayList) AppsListFragment(com.amaze.filemanager.fragments.AppsListFragment) Editable(android.text.Editable) InputMethodManager(android.view.inputmethod.InputMethodManager) MainActivity(com.amaze.filemanager.activities.MainActivity) ArrayList(java.util.ArrayList) AppCompatButton(android.support.v7.widget.AppCompatButton) HybridFileParcelable(com.amaze.filemanager.filesystem.HybridFileParcelable) PieDataSet(com.github.mikephil.charting.data.PieDataSet) Toast(android.widget.Toast) DataUtils(com.amaze.filemanager.utils.DataUtils) Build(android.os.Build) WeakReference(java.lang.ref.WeakReference) ExecutorService(java.util.concurrent.ExecutorService) Formatter(android.text.format.Formatter) GenerateHashesTask(com.amaze.filemanager.asynchronous.asynctasks.GenerateHashesTask) SpannableString(android.text.SpannableString) TextUtils(android.text.TextUtils) DialogAction(com.afollestad.materialdialogs.DialogAction) IOException(java.io.IOException) File(java.io.File) Theme(com.afollestad.materialdialogs.Theme) EncryptDecryptUtils(com.amaze.filemanager.utils.files.EncryptDecryptUtils) Color(android.graphics.Color) Utils(com.amaze.filemanager.utils.Utils) SharedPreferences(android.content.SharedPreferences) BasicActivity(com.amaze.filemanager.activities.superclasses.BasicActivity) ViewPortHandler(com.github.mikephil.charting.utils.ViewPortHandler) FileUtils(com.amaze.filemanager.utils.files.FileUtils) DialogUtils(com.afollestad.materialdialogs.util.DialogUtils) TextInputEditText(android.support.design.widget.TextInputEditText) PieEntry(com.github.mikephil.charting.data.PieEntry) OpenMode(com.amaze.filemanager.utils.OpenMode) EditText(android.widget.EditText) MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) FileUtils.toHybridFileArrayList(com.amaze.filemanager.utils.files.FileUtils.toHybridFileArrayList) ArrayList(java.util.ArrayList) LayoutElementParcelable(com.amaze.filemanager.adapters.data.LayoutElementParcelable) HybridFileParcelable(com.amaze.filemanager.filesystem.HybridFileParcelable) TextView(android.widget.TextView)

Example 3 with LayoutElementParcelable

use of com.amaze.filemanager.adapters.data.LayoutElementParcelable in project AmazeFileManager by TeamAmaze.

the class HybridFile method generateLayoutElement.

/**
 * Generates a {@link LayoutElementParcelable} adapted compatible element.
 * Currently supports only local filesystem
 */
public LayoutElementParcelable generateLayoutElement(boolean showThumbs) {
    switch(mode) {
        case FILE:
        case ROOT:
            File file = new File(path);
            LayoutElementParcelable layoutElement;
            if (isDirectory()) {
                layoutElement = new LayoutElementParcelable(path, RootHelper.parseFilePermission(file), "", folderSize() + "", 0, true, false, file.lastModified() + "", showThumbs);
            } else {
                layoutElement = new LayoutElementParcelable(file.getPath(), RootHelper.parseFilePermission(file), file.getPath(), file.length() + "", file.length(), false, false, file.lastModified() + "", showThumbs);
            }
            layoutElement.setMode(mode);
            return layoutElement;
        default:
            return null;
    }
}
Also used : LayoutElementParcelable(com.amaze.filemanager.adapters.data.LayoutElementParcelable) RemoteFile(net.schmizz.sshj.sftp.RemoteFile) File(java.io.File) SmbFile(jcifs.smb.SmbFile) DocumentFile(android.support.v4.provider.DocumentFile)

Example 4 with LayoutElementParcelable

use of com.amaze.filemanager.adapters.data.LayoutElementParcelable in project AmazeFileManager by TeamAmaze.

the class RecyclerAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(final RecyclerView.ViewHolder vholder, int p) {
    if (vholder instanceof ItemViewHolder) {
        final ItemViewHolder holder = (ItemViewHolder) vholder;
        final boolean isBackButton = getBoolean(PREFERENCE_SHOW_GOBACK_BUTTON) && p == 0;
        if (isBackButton) {
            holder.about.setVisibility(View.GONE);
        }
        if (mainFrag.IS_LIST) {
            if (p == getItemCount() - 1) {
                holder.rl.setMinimumHeight((int) minRowHeight);
                if (itemsDigested.size() == (getBoolean(PREFERENCE_SHOW_GOBACK_BUTTON) ? 1 : 0))
                    holder.txtTitle.setText(R.string.nofiles);
                else
                    holder.txtTitle.setText("");
                return;
            }
        }
        if (!this.stoppedAnimation && !itemsDigested.get(p).getAnimating()) {
            animate(holder);
            itemsDigested.get(p).setAnimate(true);
        }
        final LayoutElementParcelable rowItem = itemsDigested.get(p).elem;
        if (mainFrag.IS_LIST) {
            holder.rl.setOnClickListener(v -> {
                mainFrag.onListItemClicked(isBackButton, vholder.getAdapterPosition(), rowItem, holder.checkImageView);
            });
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
                holder.checkImageView.setBackground(new CircleGradientDrawable(accentColor, utilsProvider.getAppTheme(), mainFrag.getResources().getDisplayMetrics()));
            } else {
                holder.checkImageView.setBackgroundDrawable(new CircleGradientDrawable(accentColor, utilsProvider.getAppTheme(), mainFrag.getResources().getDisplayMetrics()));
            }
            holder.rl.setOnLongClickListener(p1 -> {
                // check if the item on which action is performed is not the first {goback} item
                if (!isBackButton) {
                    toggleChecked(vholder.getAdapterPosition(), holder.checkImageView);
                }
                return true;
            });
            holder.txtTitle.setText(rowItem.title);
            holder.genericText.setText("");
            if (holder.about != null) {
                if (utilsProvider.getAppTheme().equals(AppTheme.LIGHT))
                    holder.about.setColorFilter(grey_color);
                showPopup(holder.about, rowItem, p);
            }
            holder.genericIcon.setOnClickListener(v -> {
                int id = v.getId();
                if (id == R.id.generic_icon || id == R.id.picture_icon || id == R.id.apk_icon) {
                    // TODO: transform icon on press to the properties dialog with animation
                    if (!isBackButton) {
                        toggleChecked(vholder.getAdapterPosition(), holder.checkImageView);
                    } else
                        mainFrag.goBack();
                }
            });
            holder.pictureIcon.setOnClickListener(view -> {
                if (!isBackButton) {
                    toggleChecked(vholder.getAdapterPosition(), holder.checkImageView);
                } else
                    mainFrag.goBack();
            });
            holder.apkIcon.setOnClickListener(view -> {
                if (!isBackButton) {
                    toggleChecked(vholder.getAdapterPosition(), holder.checkImageView);
                } else
                    mainFrag.goBack();
            });
            // resetting icons visibility
            holder.genericIcon.setVisibility(View.GONE);
            holder.pictureIcon.setVisibility(View.GONE);
            holder.apkIcon.setVisibility(View.GONE);
            holder.checkImageView.setVisibility(View.INVISIBLE);
            // pictureIcon is circular drawable
            switch(rowItem.filetype) {
                case Icons.IMAGE:
                case Icons.VIDEO:
                    if (getBoolean(PREFERENCE_SHOW_THUMB)) {
                        if (getBoolean(PREFERENCE_USE_CIRCULAR_IMAGES)) {
                            showThumbnailWithBackground(holder, rowItem.iconData, holder.pictureIcon, rowItem.iconData::setImageBroken);
                        } else {
                            showThumbnailWithBackground(holder, rowItem.iconData, holder.apkIcon, rowItem.iconData::setImageBroken);
                        }
                    }
                    break;
                case Icons.APK:
                    if (getBoolean(PREFERENCE_SHOW_THUMB)) {
                        showThumbnailWithBackground(holder, rowItem.iconData, holder.apkIcon, rowItem.iconData::setImageBroken);
                    }
                    break;
                case Icons.NOT_KNOWN:
                    holder.genericIcon.setVisibility(View.VISIBLE);
                    // if the file type is any unknown variable
                    String ext = !rowItem.isDirectory ? MimeTypes.getExtension(rowItem.title) : null;
                    if (ext != null && ext.trim().length() != 0) {
                        holder.genericText.setText(ext);
                        holder.genericIcon.setImageDrawable(null);
                    // holder.genericIcon.setVisibility(View.INVISIBLE);
                    } else {
                        // we could not find the extension, set a generic file type icon probably a directory
                        modelProvider.getPreloadRequestBuilder(rowItem.iconData).into(holder.genericIcon);
                    }
                    break;
                case Icons.ENCRYPTED:
                    if (getBoolean(PREFERENCE_SHOW_THUMB)) {
                        holder.genericIcon.setVisibility(View.VISIBLE);
                        modelProvider.getPreloadRequestBuilder(rowItem.iconData).into(holder.genericIcon);
                    }
                    break;
                default:
                    holder.genericIcon.setVisibility(View.VISIBLE);
                    modelProvider.getPreloadRequestBuilder(rowItem.iconData).into(holder.genericIcon);
                    break;
            }
            if (utilsProvider.getAppTheme().equals(AppTheme.LIGHT)) {
                holder.rl.setBackgroundResource(R.drawable.safr_ripple_white);
            } else {
                holder.rl.setBackgroundResource(R.drawable.safr_ripple_black);
            }
            holder.rl.setSelected(false);
            if (itemsDigested.get(p).getChecked() == ListItem.CHECKED) {
                holder.checkImageView.setVisibility(View.VISIBLE);
                // so that user can still look at the thumbs even after selection
                if ((rowItem.filetype != Icons.IMAGE && rowItem.filetype != Icons.APK && rowItem.filetype != Icons.VIDEO)) {
                    holder.apkIcon.setVisibility(View.GONE);
                    holder.pictureIcon.setVisibility(View.GONE);
                    holder.genericIcon.setVisibility(View.VISIBLE);
                    GradientDrawable gradientDrawable = (GradientDrawable) holder.genericIcon.getBackground();
                    gradientDrawable.setColor(goBackColor);
                }
                holder.rl.setSelected(true);
            // holder.genericText.setText("");
            } else {
                holder.checkImageView.setVisibility(View.INVISIBLE);
                if (!rowItem.iconData.isImageBroken()) {
                    GradientDrawable gradientDrawable = (GradientDrawable) holder.genericIcon.getBackground();
                    if (getBoolean(PREFERENCE_COLORIZE_ICONS)) {
                        if (rowItem.isDirectory) {
                            gradientDrawable.setColor(iconSkinColor);
                        } else {
                            ColorUtils.colorizeIcons(context, rowItem.filetype, gradientDrawable, iconSkinColor);
                        }
                    } else
                        gradientDrawable.setColor(iconSkinColor);
                    if (isBackButton) {
                        gradientDrawable.setColor(goBackColor);
                    }
                }
            }
            if (getBoolean(PREFERENCE_SHOW_PERMISSIONS))
                holder.perm.setText(rowItem.permissions);
            if (getBoolean(PREFERENCE_SHOW_LAST_MODIFIED)) {
                holder.date.setText(rowItem.date1);
            } else {
                holder.date.setVisibility(View.GONE);
            }
            if (isBackButton) {
                holder.date.setText(rowItem.size);
                holder.txtDesc.setText("");
            } else if (getBoolean(PREFERENCE_SHOW_FILE_SIZE)) {
                holder.txtDesc.setText(rowItem.size);
            }
        } else {
            // view is a grid view
            holder.checkImageViewGrid.setColorFilter(accentColor);
            holder.rl.setOnClickListener(v -> {
                mainFrag.onListItemClicked(isBackButton, vholder.getAdapterPosition(), rowItem, holder.checkImageViewGrid);
            });
            holder.rl.setOnLongClickListener(p1 -> {
                if (!isBackButton) {
                    toggleChecked(vholder.getAdapterPosition(), holder.checkImageViewGrid);
                }
                return true;
            });
            holder.txtTitle.setText(rowItem.title);
            holder.imageView1.setVisibility(View.INVISIBLE);
            holder.genericIcon.setVisibility(View.VISIBLE);
            holder.checkImageViewGrid.setVisibility(View.INVISIBLE);
            ((RoundedImageView) holder.genericIcon).setRelativeSize(1.25f, 1.25f);
            GlideApp.with(mainFrag).load(rowItem.iconData.image).into(holder.genericIcon);
            if (rowItem.filetype == Icons.IMAGE || rowItem.filetype == Icons.VIDEO) {
                holder.imageView1.setVisibility(View.VISIBLE);
                holder.imageView1.setImageDrawable(null);
                if (utilsProvider.getAppTheme().equals(AppTheme.DARK) || utilsProvider.getAppTheme().equals(AppTheme.BLACK))
                    holder.imageView1.setBackgroundColor(Color.BLACK);
                showRoundedThumbnail(holder, rowItem.iconData, holder.imageView1, rowItem.iconData::setImageBroken);
            } else if (rowItem.filetype == Icons.APK) {
                showRoundedThumbnail(holder, rowItem.iconData, holder.genericIcon, rowItem.iconData::setImageBroken);
            }
            if (holder.genericIcon.getVisibility() == View.VISIBLE) {
                View iconBackground = getBoolean(PREFERENCE_USE_CIRCULAR_IMAGES) ? holder.genericIcon : holder.iconLayout;
                if (rowItem.isDirectory) {
                    iconBackground.setBackgroundColor(iconSkinColor);
                } else {
                    switch(rowItem.filetype) {
                        case Icons.VIDEO:
                            iconBackground.setBackgroundColor(videoColor);
                            break;
                        case Icons.AUDIO:
                            iconBackground.setBackgroundColor(audioColor);
                            break;
                        case Icons.PDF:
                            iconBackground.setBackgroundColor(pdfColor);
                            break;
                        case Icons.CODE:
                            iconBackground.setBackgroundColor(codeColor);
                            break;
                        case Icons.TEXT:
                            iconBackground.setBackgroundColor(textColor);
                            break;
                        case Icons.COMPRESSED:
                            iconBackground.setBackgroundColor(archiveColor);
                            break;
                        case Icons.NOT_KNOWN:
                            iconBackground.setBackgroundColor(genericColor);
                            break;
                        case Icons.APK:
                        case Icons.IMAGE:
                            // While these are loading or if they fail, color has to be set (done in showRoundedThumbnail()).
                            break;
                        default:
                            iconBackground.setBackgroundColor(iconSkinColor);
                            break;
                    }
                }
                if (isBackButton) {
                    iconBackground.setBackgroundColor(goBackColor);
                }
            }
            if (itemsDigested.get(p).getChecked() == ListItem.CHECKED) {
                if (holder.genericIcon.getVisibility() == View.VISIBLE) {
                    View iconBackground = getBoolean(PREFERENCE_USE_CIRCULAR_IMAGES) ? holder.genericIcon : holder.iconLayout;
                    iconBackground.setBackgroundColor(iconSkinColor);
                // holder.genericIcon.setImageDrawable(main.getResources().getDrawable(R.drawable.abc_ic_cab_done_holo_dark));
                }
                holder.checkImageViewGrid.setVisibility(View.VISIBLE);
                holder.rl.setBackgroundColor(Utils.getColor(context, R.color.item_background));
            } else {
                holder.checkImageViewGrid.setVisibility(View.INVISIBLE);
                if (utilsProvider.getAppTheme().equals(AppTheme.LIGHT))
                    holder.rl.setBackgroundResource(R.drawable.item_doc_grid);
                else {
                    holder.rl.setBackgroundResource(R.drawable.ic_grid_card_background_dark);
                    holder.rl.findViewById(R.id.icon_frame).setBackgroundColor(Utils.getColor(context, R.color.icon_background_dark));
                }
            }
            if (holder.about != null) {
                if (utilsProvider.getAppTheme().equals(AppTheme.LIGHT))
                    holder.about.setColorFilter(grey_color);
                showPopup(holder.about, rowItem, p);
            }
            if (getBoolean(PREFERENCE_SHOW_LAST_MODIFIED))
                holder.date.setText(rowItem.date1);
            if (isBackButton) {
                holder.date.setText(rowItem.size);
                holder.txtDesc.setText("");
            }
            /*else if(main.SHOW_SIZE)
                holder.txtDesc.setText(rowItem.getSize());
           */
            if (getBoolean(PREFERENCE_SHOW_PERMISSIONS))
                holder.perm.setText(rowItem.permissions);
        }
    }
}
Also used : RoundedImageView(com.amaze.filemanager.ui.views.RoundedImageView) LayoutElementParcelable(com.amaze.filemanager.adapters.data.LayoutElementParcelable) CircleGradientDrawable(com.amaze.filemanager.ui.views.CircleGradientDrawable) ItemViewHolder(com.amaze.filemanager.adapters.holders.ItemViewHolder) ImageView(android.widget.ImageView) View(android.view.View) RoundedImageView(com.amaze.filemanager.ui.views.RoundedImageView) RecyclerView(android.support.v7.widget.RecyclerView) CircleGradientDrawable(com.amaze.filemanager.ui.views.CircleGradientDrawable) GradientDrawable(android.graphics.drawable.GradientDrawable)

Example 5 with LayoutElementParcelable

use of com.amaze.filemanager.adapters.data.LayoutElementParcelable in project AmazeFileManager by TeamAmaze.

the class RecyclerAdapter method createHeaders.

public void createHeaders(boolean invalidate, List<IconDataParcelable> uris) {
    boolean[] headers = new boolean[] { false, false };
    for (int i = 0; i < itemsDigested.size(); i++) {
        if (itemsDigested.get(i).elem != null) {
            LayoutElementParcelable nextItem = itemsDigested.get(i).elem;
            if (!headers[0] && nextItem.isDirectory) {
                headers[0] = true;
                itemsDigested.add(i, new ListItem(TYPE_HEADER_FOLDERS));
                uris.add(i, null);
                continue;
            }
            if (!headers[1] && !nextItem.isDirectory && !nextItem.title.equals(".") && !nextItem.title.equals("..")) {
                headers[1] = true;
                itemsDigested.add(i, new ListItem(TYPE_HEADER_FILES));
                uris.add(i, null);
                // leave this continue for symmetry
                continue;
            }
        }
    }
    if (invalidate) {
        notifyDataSetChanged();
    }
}
Also used : LayoutElementParcelable(com.amaze.filemanager.adapters.data.LayoutElementParcelable)

Aggregations

LayoutElementParcelable (com.amaze.filemanager.adapters.data.LayoutElementParcelable)18 File (java.io.File)11 ArrayList (java.util.ArrayList)11 SmbFile (jcifs.smb.SmbFile)11 HybridFile (com.amaze.filemanager.filesystem.HybridFile)10 HybridFileParcelable (com.amaze.filemanager.filesystem.HybridFileParcelable)10 Cursor (android.database.Cursor)6 ActivityNotFoundException (android.content.ActivityNotFoundException)2 Intent (android.content.Intent)2 SharedPreferences (android.content.SharedPreferences)2 View (android.view.View)2 SmbException (jcifs.smb.SmbException)2 Context (android.content.Context)1 Color (android.graphics.Color)1 Typeface (android.graphics.Typeface)1 GradientDrawable (android.graphics.drawable.GradientDrawable)1 FingerprintManager (android.hardware.fingerprint.FingerprintManager)1 Uri (android.net.Uri)1 AsyncTask (android.os.AsyncTask)1 Build (android.os.Build)1