Search in sources :

Example 1 with FileListAdapter

use of com.genonbeta.TrebleShot.adapter.FileListAdapter in project TrebleShot by genonbeta.

the class FileListFragment method onAdapter.

@Override
public FileListAdapter onAdapter() {
    return new FileListAdapter(getActivity(), new AccessDatabase(getActivity())) {

        @Override
        public void onBindViewHolder(@NonNull final ViewHolder holder, int position) {
            super.onBindViewHolder(holder, position);
            holder.getView().setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    FileListAdapter.GenericFileHolder fileInfo = getAdapter().getItem(holder);
                    if (mFileClickedListener == null || !mFileClickedListener.onFileClicked(fileInfo)) {
                        if (fileInfo instanceof FileListAdapter.FileHolder)
                            performLayoutClick(v, holder);
                        else if (fileInfo instanceof FileListAdapter.DirectoryHolder || fileInfo instanceof FileListAdapter.WritablePathHolder) {
                            FileListFragment.this.goPath(fileInfo.file);
                            if (isSelectionActivated() && !PreferenceManager.getDefaultSharedPreferences(getActivity()).getBoolean("helpFolderSelection", false))
                                createSnackbar(R.string.mesg_helpFolderSelection).setAction(R.string.butn_gotIt, new View.OnClickListener() {

                                    @Override
                                    public void onClick(View v) {
                                        PreferenceManager.getDefaultSharedPreferences(getActivity()).edit().putBoolean("helpFolderSelection", true).apply();
                                    }
                                }).show();
                        }
                    }
                }
            });
        }
    };
}
Also used : FileListAdapter(com.genonbeta.TrebleShot.adapter.FileListAdapter) AccessDatabase(com.genonbeta.TrebleShot.database.AccessDatabase) NonNull(android.support.annotation.NonNull) View(android.view.View)

Aggregations

NonNull (android.support.annotation.NonNull)1 View (android.view.View)1 FileListAdapter (com.genonbeta.TrebleShot.adapter.FileListAdapter)1 AccessDatabase (com.genonbeta.TrebleShot.database.AccessDatabase)1