Search in sources :

Example 11 with AccessDatabase

use of com.genonbeta.TrebleShot.database.AccessDatabase 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

AccessDatabase (com.genonbeta.TrebleShot.database.AccessDatabase)11 View (android.view.View)4 NetworkDevice (com.genonbeta.TrebleShot.object.NetworkDevice)4 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)2 RecyclerView (android.support.v7.widget.RecyclerView)2 TextDrawable (com.amulyakhare.textdrawable.TextDrawable)2 PathResolverRecyclerAdapter (com.genonbeta.TrebleShot.adapter.PathResolverRecyclerAdapter)2 WorkerService (com.genonbeta.TrebleShot.service.WorkerService)2 IOException (java.io.IOException)2 Intent (android.content.Intent)1 ServiceConnection (android.content.ServiceConnection)1 Bitmap (android.graphics.Bitmap)1 Canvas (android.graphics.Canvas)1 MediaScannerConnection (android.media.MediaScannerConnection)1 Bundle (android.os.Bundle)1 ChooserTarget (android.service.chooser.ChooserTarget)1 NonNull (android.support.annotation.NonNull)1 Nullable (android.support.annotation.Nullable)1 NavigationView (android.support.design.widget.NavigationView)1 ActionBarDrawerToggle (android.support.v7.app.ActionBarDrawerToggle)1