Skip to content

Commit

Permalink
version 1.1
Browse files Browse the repository at this point in the history
* Add new Example
* performance enhancement
  • Loading branch information
abbasalim committed Sep 13, 2018
1 parent 8509670 commit e1b502c
Show file tree
Hide file tree
Showing 13 changed files with 43 additions and 6 deletions.
19 changes: 19 additions & 0 deletions app/src/main/java/ir/esfandune/sample/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@
import com.esfandune.sample.R;

import java.io.File;
import java.io.FileFilter;
import java.util.ArrayList;

import ir.esfandune.filepickerDialog.filter.CompositeFilter;
import ir.esfandune.filepickerDialog.ui.PickerDialog;

public class MainActivity extends AppCompatActivity {
Expand Down Expand Up @@ -80,4 +83,20 @@ public void onFileClicked(File clickedFile) {
});
}

public void slctFiltrdFileClick(View view) {
ArrayList<FileFilter> ff = new ArrayList<>();
ff.add(new FileFilter() {
@Override
public boolean accept(File file) {
return file.isDirectory() || file.getName().endsWith(".pdf");
}
});
CompositeFilter cf = new CompositeFilter(ff);
PickerDialog.FilePicker(this, null, true, cf).onFileSelect(new PickerDialog.FileClickListener() {
@Override
public void onFileClicked(File clickedFile) {

}
});
}
}
6 changes: 6 additions & 0 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,10 @@
android:onClick="slctFolderClick"
android:text="Select Folder" />

<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="slctFiltrdFileClick"
android:text="Select pdf File AND show Hidden Files" />

</LinearLayout>
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public void onBindViewHolder(DirectoryViewHolder holder, int position) {
if (currentFile.getPath().equals(PickerDialog.GO_BACK_ITEM_PATH)) {
holder.mFileImage.setImageResource(R.drawable.ic_back);
holder.mFileSubtitle.setText("");
holder.mFileTitle.setText("بازگشت");
holder.mFileTitle.setText(R.string.back);
}else {
FileTypeUtils.FileType fileType = FileTypeUtils.getFileType(currentFile);
holder.mFileImage.setImageResource(fileType.getIcon());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public class PickerDialog extends DialogFragment {
private DirectoryAdapter rcAdapter;
private FileClickListener OnFileClicked;
private FolderClickListener OnFolderClicked;
private boolean FolderPickMod;

public static PickerDialog FolderPicker(AppCompatActivity Act) {
return FolderPicker(Act, null, false, new CompositeFilter(new ArrayList<FileFilter>()));
Expand Down Expand Up @@ -118,7 +119,7 @@ public void onClick(View v) {
}

private void initFilesList() {
rcAdapter = new DirectoryAdapter(getActivity(), FileUtils.getFileListByDirPath(mPath, mFilter, showHidden), !mPath.equals("/storage"));
rcAdapter = new DirectoryAdapter(getActivity(), FileUtils.getFileListByDirPath(mPath, mFilter, showHidden, FolderPickMod), !mPath.equals("/storage"));
rcAdapter.setOnItemClickListener(new DirectoryAdapter.OnItemClickListener() {
@Override
public void onItemClick(View view, int position) {
Expand Down Expand Up @@ -162,7 +163,8 @@ private void initArgs() {
}
mFilter = (CompositeFilter) getArguments().getSerializable(ARG_FILTER);
showHidden = getArguments().getBoolean(ARG_SHOW_HIDDEN);
slctFolder.setVisibility(getArguments().getBoolean(ARG_FOLDER_PICKER) ? View.VISIBLE : View.GONE);
FolderPickMod = getArguments().getBoolean(ARG_FOLDER_PICKER);
slctFolder.setVisibility(FolderPickMod ? View.VISIBLE : View.GONE);

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* Created by Dimorinny on 24.10.15.
*/
public class FileUtils {
public static List<File> getFileListByDirPath(String path, FileFilter filter,boolean showHidden) {
public static List<File> getFileListByDirPath(String path, FileFilter filter, boolean showHidden, boolean onlyDir) {
File directory = new File(path);
File[] files = directory.listFiles(filter);

Expand All @@ -21,8 +21,10 @@ public static List<File> getFileListByDirPath(String path, FileFilter filter,boo

List<File> result =new ArrayList<>();
for (File f:files) {
if (showHidden || !f.getName().startsWith("."))
result.add(f);
if (showHidden || !f.getName().startsWith(".")) {
if (!onlyDir || f.isDirectory())
result.add(f);
}
}
// List<File> result = Arrays.asList(files); چون add نداره و سایز ثابته
Collections.sort(result, new FileComparator());
Expand Down
1 change: 1 addition & 0 deletions library/src/main/res/values-cs/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@
<string name="type_power_point">Prezentace</string>
<string name="type_word">Dokument</string>
<string name="type_apk">APK</string>
<string name="back">Vrátit</string>
</resources>
1 change: 1 addition & 0 deletions library/src/main/res/values-de/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@
<string name="type_power_point">Presentation</string>
<string name="type_word">Dokument</string>
<string name="type_apk">APK</string>
<string name="back">Zurück</string>
</resources>
1 change: 1 addition & 0 deletions library/src/main/res/values-es/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@
<string name="type_power_point">Powerpoint</string>
<string name="type_video">Vídeo</string>
<string name="type_word">Documento Word</string>
<string name="back">Volver</string>
</resources>
1 change: 1 addition & 0 deletions library/src/main/res/values-fa/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@
<string name="type_apk">APK</string>
<string name="type_wave">پشتیبان حسابداری موج</string>
<string name="selectfolder">انتخاب این پوشه</string>
<string name="back">بازگشت</string>
</resources>
1 change: 1 addition & 0 deletions library/src/main/res/values-ru/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@
<string name="type_power_point">Презентация</string>
<string name="type_word">Документ</string>
<string name="type_archive">Архив</string>
<string name="back">Вернуться</string>
</resources>
1 change: 1 addition & 0 deletions library/src/main/res/values-sk/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@
<string name="type_power_point">Prezentácia</string>
<string name="type_word">Dokument</string>
<string name="type_apk">APK</string>
<string name="back">Vrátiť</string>
</resources>
1 change: 1 addition & 0 deletions library/src/main/res/values-zh/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@
<string name="type_power_point">PPT</string>
<string name="type_word">WORD</string>
<string name="type_apk">APK</string>
<string name="back">返回的</string>
</resources>
1 change: 1 addition & 0 deletions library/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@
<string name="type_apk">APK</string>
<string name="type_wave">waveAccounting</string>
<string name="selectfolder">Select</string>
<string name="back">Back</string>
</resources>

0 comments on commit e1b502c

Please sign in to comment.