|
46 | 46 | import net.gnu.util.FileUtil; |
47 | 47 | import net.gnu.util.Util; |
48 | 48 | import net.gnu.common.*; |
| 49 | +import java.util.*; |
49 | 50 |
|
50 | 51 | public class ArrAdapter extends RecyclerAdapter<LayoutElement, ArrAdapter.ViewHolder> { |
51 | 52 |
|
52 | 53 | private static final String TAG = "ArrAdapter"; |
53 | 54 |
|
54 | 55 | private final int backgroundResource; |
55 | 56 | private final ContentFragment contentFrag; |
56 | | - |
| 57 | + List<LayoutElement> dataSourceL2; |
| 58 | + |
57 | 59 | public void toggleChecked(final boolean checked) { |
58 | 60 | if (checked) { |
59 | 61 | contentFrag.allCbx.setSelected(true); |
@@ -108,6 +110,13 @@ public ViewHolder(final View convertView) { |
108 | 110 | public ArrAdapter(final ContentFragment fileFrag, final List<LayoutElement> objects) { |
109 | 111 | super(objects); |
110 | 112 | this.contentFrag = fileFrag; |
| 113 | + if (fileFrag.type == Frag.TYPE.EXPLORER) { |
| 114 | + if (fileFrag.slidingTabsFragment.side == SlidingTabsFragment.Side.LEFT) { |
| 115 | + dataSourceL2 = fileFrag.activity.dataSourceL2OfLeft; |
| 116 | + } else { |
| 117 | + dataSourceL2 = fileFrag.activity.dataSourceL2OfRight; |
| 118 | + } |
| 119 | + } |
111 | 120 |
|
112 | 121 | final int[] attrs = new int[]{R.attr.selectableItemBackground}; |
113 | 122 | final TypedArray typedArray = fileFrag.activity.obtainStyledAttributes(attrs); |
@@ -209,10 +218,10 @@ public void onBindViewHolder(final ViewHolder holder, final int position) { |
209 | 218 | boolean inDataSource2 = false; |
210 | 219 | boolean isPartial = false; |
211 | 220 | //Log.d(TAG, "dataSource2" + Util.collectionToString(dataSourceL2, true, "\n")); |
212 | | - if (contentFrag.multiFiles && contentFrag.dataSourceL2 != null) { |
| 221 | + if (contentFrag.multiFiles && dataSourceL2 != null) { |
213 | 222 | final String fPathD = fPath + "/"; |
214 | 223 | String f2Path; |
215 | | - for (LayoutElement f2 : contentFrag.dataSourceL2) { |
| 224 | + for (LayoutElement f2 : dataSourceL2) { |
216 | 225 | f2Path = f2.path; |
217 | 226 | if (f2.equals(le) || fPath.startsWith(f2Path + "/")) { |
218 | 227 | inDataSource2 = true; |
@@ -632,15 +641,15 @@ public void onMenuModeChange(MenuBuilder menu) {} |
632 | 641 | } else { |
633 | 642 | final int id = v.getId(); |
634 | 643 | if (contentFrag.multiFiles) {// || fileFrag.suffix != null && fileFrag.suffix.length() == 0 |
635 | | - boolean inSelected = false; |
636 | | - if (contentFrag.dataSourceL2 != null) |
637 | | - for (LayoutElement st : contentFrag.dataSourceL2) { |
638 | | - if (rowItem.path.equals(st.path) || fPath.startsWith(st.path + "/")) { |
639 | | - inSelected = true; |
640 | | - break; |
641 | | - } |
642 | | - } |
643 | | - if (!inSelected) { |
| 644 | +// boolean inSelected = false; |
| 645 | +// if (dataSourceL2 != null) |
| 646 | +// for (LayoutElement st : dataSourceL2) { |
| 647 | +// if (rowItem.path.equals(st.path) || fPath.startsWith(st.path + "/")) { |
| 648 | +// inSelected = true; |
| 649 | +// break; |
| 650 | +// } |
| 651 | +// } |
| 652 | +// if (!inSelected) { |
644 | 653 | if (id == R.id.icon) { |
645 | 654 | contentFrag.tempPreviewL2 = rowItem; |
646 | 655 | notifyDataSetChanged(); |
@@ -726,41 +735,41 @@ public void onMenuModeChange(MenuBuilder menu) {} |
726 | 735 | contentFrag.selectionStatusTV.setText(contentFrag.selectedInList1.size() |
727 | 736 | + "/" + contentFrag.dataSourceL1.size()); |
728 | 737 | } |
729 | | - } else { // inselected |
730 | | - if (id == R.id.icon) { //dir |
731 | | - contentFrag.tempPreviewL2 = rowItem; |
732 | | - notifyDataSetChanged(); |
733 | | - if (f.isFile()) { |
734 | | - load(rowItem, f, fPath, pos); |
735 | | - } else if (contentFrag.slidingTabsFragment.side == SlidingTabsFragment.Side.LEFT) {//ContentFragment dir//fileFrag.type == -1 |
736 | | - if (contentFrag.activity.slideFrag2 != null) { |
737 | | - Frag frag = contentFrag.activity.slideFrag2.getCurrentFragment(); |
738 | | - if (frag.type == Frag.TYPE.EXPLORER) { |
739 | | - ((ContentFragment)frag).changeDir(path, true); |
740 | | - } else { |
741 | | - contentFrag.activity.slideFrag2.setCurrentItem(contentFrag.activity.slideFrag2.indexOfAdapter(contentFrag.activity.curExplorerFrag), true); |
742 | | - contentFrag.activity.curExplorerFrag.changeDir(path, true); |
743 | | - } |
744 | | - } |
745 | | - } else {//dir |
746 | | - //if (fileFrag.activity.slideFrag2 != null) { |
747 | | - Frag frag = contentFrag.activity.slideFrag.getCurrentFragment(); |
748 | | - if (frag.type == Frag.TYPE.EXPLORER) { |
749 | | - ((ContentFragment)frag).changeDir(path, true); |
750 | | - } else { |
751 | | - contentFrag.activity.slideFrag.setCurrentItem(contentFrag.activity.slideFrag.indexOfAdapter(contentFrag.activity.curContentFrag), true); |
752 | | - contentFrag.activity.curContentFrag.changeDir(path, true); |
753 | | - } |
754 | | - } |
755 | | - } else if (f.isFile()) { |
756 | | -// if (v.getId() == R.id.icon) { |
757 | | -// contentFrag.tempPreviewL2 = rowItem; |
| 738 | +// } else { // inselected |
| 739 | +// if (id == R.id.icon) { //dir |
| 740 | +// contentFrag.tempPreviewL2 = rowItem; |
| 741 | +// notifyDataSetChanged(); |
| 742 | +// if (f.isFile()) { |
758 | 743 | // load(rowItem, f, fPath, pos); |
759 | | -// } else { |
760 | | - openFile(rowItem, f, fPath); |
| 744 | +// } else if (contentFrag.slidingTabsFragment.side == SlidingTabsFragment.Side.LEFT) {//ContentFragment dir//fileFrag.type == -1 |
| 745 | +// if (contentFrag.activity.slideFrag2 != null) { |
| 746 | +// Frag frag = contentFrag.activity.slideFrag2.getCurrentFragment(); |
| 747 | +// if (frag.type == Frag.TYPE.EXPLORER) { |
| 748 | +// ((ContentFragment)frag).changeDir(path, true); |
| 749 | +// } else { |
| 750 | +// contentFrag.activity.slideFrag2.setCurrentItem(contentFrag.activity.slideFrag2.indexOfAdapter(contentFrag.activity.curExplorerFrag), true); |
| 751 | +// contentFrag.activity.curExplorerFrag.changeDir(path, true); |
| 752 | +// } |
| 753 | +// } |
| 754 | +// } else {//dir |
| 755 | +// //if (fileFrag.activity.slideFrag2 != null) { |
| 756 | +// Frag frag = contentFrag.activity.slideFrag.getCurrentFragment(); |
| 757 | +// if (frag.type == Frag.TYPE.EXPLORER) { |
| 758 | +// ((ContentFragment)frag).changeDir(path, true); |
| 759 | +// } else { |
| 760 | +// contentFrag.activity.slideFrag.setCurrentItem(contentFrag.activity.slideFrag.indexOfAdapter(contentFrag.activity.curContentFrag), true); |
| 761 | +// contentFrag.activity.curContentFrag.changeDir(path, true); |
| 762 | +// } |
761 | 763 | // } |
762 | | - } |
763 | | - } |
| 764 | +// } else if (f.isFile()) { |
| 765 | +//// if (v.getId() == R.id.icon) { |
| 766 | +//// contentFrag.tempPreviewL2 = rowItem; |
| 767 | +//// load(rowItem, f, fPath, pos); |
| 768 | +//// } else { |
| 769 | +// openFile(rowItem, f, fPath); |
| 770 | +//// } |
| 771 | +// } |
| 772 | +// } |
764 | 773 | } else { //!multifile no preview |
765 | 774 | if (id == R.id.cbx) { |
766 | 775 | // chọn mới đầu tiên |
@@ -1144,8 +1153,8 @@ public boolean onLongClick(final View v) { |
1144 | 1153 | Log.d(TAG, "multiFiles " + contentFrag.multiFiles); |
1145 | 1154 |
|
1146 | 1155 | boolean inSelectedFiles = false; |
1147 | | - if (contentFrag.dataSourceL2 != null) |
1148 | | - for (LayoutElement st : contentFrag.dataSourceL2) { |
| 1156 | + if (dataSourceL2 != null) |
| 1157 | + for (LayoutElement st : dataSourceL2) { |
1149 | 1158 | if (f.equals(st) || fPath.startsWith(st.path + "/")) { |
1150 | 1159 | inSelectedFiles = true; |
1151 | 1160 | break; |
|
0 commit comments