Skip to content

Commit

Permalink
change datasource selection, activitycreated
Browse files Browse the repository at this point in the history
  • Loading branch information
PowerExplorer committed Jun 18, 2019
1 parent d3a91c7 commit df59425
Show file tree
Hide file tree
Showing 10 changed files with 503 additions and 419 deletions.
2 changes: 1 addition & 1 deletion PowerFileExplorer/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="net.gnu.explorer"
android:versionCode="64"
android:versionName="1.0.6"
android:versionName="1.0.7beta"
>

<!-- Min/target SDK versions (<uses-sdk>) managed by build.gradle
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@
import com.amaze.filemanager.filesystem.BaseFile;
import com.amaze.filemanager.utils.OpenMode;
import java.io.File;
import java.io.*;
import android.support.v4.content.*;

public class LayoutElement implements Parcelable {
public class LayoutElement implements Parcelable, Serializable {

//private static final String CURRENT_YEAR = String.valueOf(Calendar.getInstance().get(Calendar.YEAR));

Expand Down Expand Up @@ -149,6 +151,7 @@ public LayoutElement(Parcel im) {
// lastModifiedStr = im.readString();
//lengthStr = im.readString();
length = im.readLong();
mode = OpenMode.getOpenMode(im.readInt());
bf = generateBaseFile();
}

Expand All @@ -175,6 +178,7 @@ public void writeToParcel(Parcel p1, int p2) {
// p1.writeString(lastModifiedStr);
//p1.writeString(lengthStr);
p1.writeLong(length);
p1.writeInt(mode.ordinal());
}

public static final Parcelable.Creator<LayoutElement> CREATOR =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class ScreenSlidePagerAdapter extends FragmentStatePagerAdapter {//}imple

private static final String TAG = "ScreenSlidePagerAdapter";

private final List<File> mListOfMedia;
private final ArrayList<File> mListOfMedia;
private final ViewPager viewPager;
List<ComparableEntry<Integer, ImageFragment>> fragMap = new ArrayList<>(3);
final GestureDetector.OnDoubleTapListener onDoubleTapListener;
Expand All @@ -31,7 +31,7 @@ public class ScreenSlidePagerAdapter extends FragmentStatePagerAdapter {//}imple

public ScreenSlidePagerAdapter(final FragmentManager fm,
final ViewPager vp,
final List<File> listOfMedia,
final ArrayList<File> listOfMedia,
final GestureDetector.OnDoubleTapListener onDoubleTapListener
) {
super(fm);
Expand Down
103 changes: 56 additions & 47 deletions PowerFileExplorer/src/main/java/net/gnu/explorer/ArrAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,16 @@
import net.gnu.util.FileUtil;
import net.gnu.util.Util;
import net.gnu.common.*;
import java.util.*;

public class ArrAdapter extends RecyclerAdapter<LayoutElement, ArrAdapter.ViewHolder> {

private static final String TAG = "ArrAdapter";

private final int backgroundResource;
private final ContentFragment contentFrag;

List<LayoutElement> dataSourceL2;

public void toggleChecked(final boolean checked) {
if (checked) {
contentFrag.allCbx.setSelected(true);
Expand Down Expand Up @@ -108,6 +110,13 @@ public ViewHolder(final View convertView) {
public ArrAdapter(final ContentFragment fileFrag, final List<LayoutElement> objects) {
super(objects);
this.contentFrag = fileFrag;
if (fileFrag.type == Frag.TYPE.EXPLORER) {
if (fileFrag.slidingTabsFragment.side == SlidingTabsFragment.Side.LEFT) {
dataSourceL2 = fileFrag.activity.dataSourceL2OfLeft;
} else {
dataSourceL2 = fileFrag.activity.dataSourceL2OfRight;
}
}

final int[] attrs = new int[]{R.attr.selectableItemBackground};
final TypedArray typedArray = fileFrag.activity.obtainStyledAttributes(attrs);
Expand Down Expand Up @@ -209,10 +218,10 @@ public void onBindViewHolder(final ViewHolder holder, final int position) {
boolean inDataSource2 = false;
boolean isPartial = false;
//Log.d(TAG, "dataSource2" + Util.collectionToString(dataSourceL2, true, "\n"));
if (contentFrag.multiFiles && contentFrag.dataSourceL2 != null) {
if (contentFrag.multiFiles && dataSourceL2 != null) {
final String fPathD = fPath + "/";
String f2Path;
for (LayoutElement f2 : contentFrag.dataSourceL2) {
for (LayoutElement f2 : dataSourceL2) {
f2Path = f2.path;
if (f2.equals(le) || fPath.startsWith(f2Path + "/")) {
inDataSource2 = true;
Expand Down Expand Up @@ -632,15 +641,15 @@ public void onMenuModeChange(MenuBuilder menu) {}
} else {
final int id = v.getId();
if (contentFrag.multiFiles) {// || fileFrag.suffix != null && fileFrag.suffix.length() == 0
boolean inSelected = false;
if (contentFrag.dataSourceL2 != null)
for (LayoutElement st : contentFrag.dataSourceL2) {
if (rowItem.path.equals(st.path) || fPath.startsWith(st.path + "/")) {
inSelected = true;
break;
}
}
if (!inSelected) {
// boolean inSelected = false;
// if (dataSourceL2 != null)
// for (LayoutElement st : dataSourceL2) {
// if (rowItem.path.equals(st.path) || fPath.startsWith(st.path + "/")) {
// inSelected = true;
// break;
// }
// }
// if (!inSelected) {
if (id == R.id.icon) {
contentFrag.tempPreviewL2 = rowItem;
notifyDataSetChanged();
Expand Down Expand Up @@ -726,41 +735,41 @@ public void onMenuModeChange(MenuBuilder menu) {}
contentFrag.selectionStatusTV.setText(contentFrag.selectedInList1.size()
+ "/" + contentFrag.dataSourceL1.size());
}
} else { // inselected
if (id == R.id.icon) { //dir
contentFrag.tempPreviewL2 = rowItem;
notifyDataSetChanged();
if (f.isFile()) {
load(rowItem, f, fPath, pos);
} else if (contentFrag.slidingTabsFragment.side == SlidingTabsFragment.Side.LEFT) {//ContentFragment dir//fileFrag.type == -1
if (contentFrag.activity.slideFrag2 != null) {
Frag frag = contentFrag.activity.slideFrag2.getCurrentFragment();
if (frag.type == Frag.TYPE.EXPLORER) {
((ContentFragment)frag).changeDir(path, true);
} else {
contentFrag.activity.slideFrag2.setCurrentItem(contentFrag.activity.slideFrag2.indexOfAdapter(contentFrag.activity.curExplorerFrag), true);
contentFrag.activity.curExplorerFrag.changeDir(path, true);
}
}
} else {//dir
//if (fileFrag.activity.slideFrag2 != null) {
Frag frag = contentFrag.activity.slideFrag.getCurrentFragment();
if (frag.type == Frag.TYPE.EXPLORER) {
((ContentFragment)frag).changeDir(path, true);
} else {
contentFrag.activity.slideFrag.setCurrentItem(contentFrag.activity.slideFrag.indexOfAdapter(contentFrag.activity.curContentFrag), true);
contentFrag.activity.curContentFrag.changeDir(path, true);
}
}
} else if (f.isFile()) {
// if (v.getId() == R.id.icon) {
// contentFrag.tempPreviewL2 = rowItem;
// } else { // inselected
// if (id == R.id.icon) { //dir
// contentFrag.tempPreviewL2 = rowItem;
// notifyDataSetChanged();
// if (f.isFile()) {
// load(rowItem, f, fPath, pos);
// } else {
openFile(rowItem, f, fPath);
// } else if (contentFrag.slidingTabsFragment.side == SlidingTabsFragment.Side.LEFT) {//ContentFragment dir//fileFrag.type == -1
// if (contentFrag.activity.slideFrag2 != null) {
// Frag frag = contentFrag.activity.slideFrag2.getCurrentFragment();
// if (frag.type == Frag.TYPE.EXPLORER) {
// ((ContentFragment)frag).changeDir(path, true);
// } else {
// contentFrag.activity.slideFrag2.setCurrentItem(contentFrag.activity.slideFrag2.indexOfAdapter(contentFrag.activity.curExplorerFrag), true);
// contentFrag.activity.curExplorerFrag.changeDir(path, true);
// }
// }
// } else {//dir
// //if (fileFrag.activity.slideFrag2 != null) {
// Frag frag = contentFrag.activity.slideFrag.getCurrentFragment();
// if (frag.type == Frag.TYPE.EXPLORER) {
// ((ContentFragment)frag).changeDir(path, true);
// } else {
// contentFrag.activity.slideFrag.setCurrentItem(contentFrag.activity.slideFrag.indexOfAdapter(contentFrag.activity.curContentFrag), true);
// contentFrag.activity.curContentFrag.changeDir(path, true);
// }
// }
}
}
// } else if (f.isFile()) {
//// if (v.getId() == R.id.icon) {
//// contentFrag.tempPreviewL2 = rowItem;
//// load(rowItem, f, fPath, pos);
//// } else {
// openFile(rowItem, f, fPath);
//// }
// }
// }
} else { //!multifile no preview
if (id == R.id.cbx) {
// chọn mới đầu tiên
Expand Down Expand Up @@ -1144,8 +1153,8 @@ public boolean onLongClick(final View v) {
Log.d(TAG, "multiFiles " + contentFrag.multiFiles);

boolean inSelectedFiles = false;
if (contentFrag.dataSourceL2 != null)
for (LayoutElement st : contentFrag.dataSourceL2) {
if (dataSourceL2 != null)
for (LayoutElement st : dataSourceL2) {
if (f.equals(st) || fPath.startsWith(st.path + "/")) {
inSelectedFiles = true;
break;
Expand Down
Loading

0 comments on commit df59425

Please sign in to comment.