implemented sub dir view

This commit is contained in:
M M Arif
2019-10-17 22:47:27 +05:00
parent 7fe376fa44
commit d7b1a226d0
10 changed files with 151 additions and 67 deletions

View File

@@ -1,7 +1,6 @@
package org.mian.gitnex.adapters;
import android.content.Context;
import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -12,10 +11,8 @@ import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import org.mian.gitnex.R;
import org.mian.gitnex.activities.FileViewActivity;
import org.mian.gitnex.helpers.Toasty;
import org.mian.gitnex.models.Files;
import org.mian.gitnex.util.TinyDB;
import java.util.ArrayList;
import java.util.List;
@@ -29,6 +26,13 @@ public class FilesAdapter extends RecyclerView.Adapter<FilesAdapter.FilesViewHol
private Context mCtx;
private List<Files> filesListFull;
private FilesAdapterListener filesListener;
public interface FilesAdapterListener {
void onClickDir(String str);
void onClickFile(String str);
}
class FilesViewHolder extends RecyclerView.ViewHolder {
private ImageView fileTypeImage;
@@ -49,16 +53,12 @@ public class FilesAdapter extends RecyclerView.Adapter<FilesAdapter.FilesViewHol
public void onClick(View v) {
Context context = v.getContext();
TinyDB tinyDb = new TinyDB(context);
if(fileType.getText().toString().equals("file")) {
Intent intent = new Intent(context, FileViewActivity.class);
intent.putExtra("singleFileName", fileName.getText().toString());
context.startActivity(intent);
filesListener.onClickFile(fileName.getText().toString());
}
else if(fileType.getText().toString().equals("dir")) {
//tinyDb.putString("filesDir", fileName.getText().toString());
Toasty.info(context, context.getString(R.string.filesDirNotSupportedYet));
filesListener.onClickDir(fileName.getText().toString());
}
else {
Toasty.info(context, context.getString(R.string.filesGenericError));
@@ -134,10 +134,11 @@ public class FilesAdapter extends RecyclerView.Adapter<FilesAdapter.FilesViewHol
}
}
public FilesAdapter(Context mCtx, List<Files> filesListMain) {
public FilesAdapter(Context mCtx, List<Files> filesListMain, FilesAdapterListener filesListener) {
this.mCtx = mCtx;
this.filesList = filesListMain;
filesListFull = new ArrayList<>(filesList);
this.filesListener = filesListener;
}
@NonNull