@@ -37,12 +37,6 @@ public class HandlingAlbums {
37
37
ArrayList <File > excludedfolders ;
38
38
AlbumsComparators albumsComparators ;
39
39
40
- public HandlingAlbums () {
41
- excludedfolders = new ArrayList <File >();
42
- dispAlbums = new ArrayList <Album >();
43
- selectedAlbums = new ArrayList <Album >();
44
- }
45
-
46
40
public HandlingAlbums (Context context ) {
47
41
SP = context .getSharedPreferences ("albums-sort" , Context .MODE_PRIVATE );
48
42
customAlbumsHandler = new CustomAlbumsHandler (context );
@@ -88,17 +82,19 @@ public ArrayList<Album> getValidFolders(boolean hidden) {
88
82
private void fetchRecursivelyFolder (File dir , ArrayList <Album > folders ) {
89
83
if (!excludedfolders .contains (dir )) {
90
84
File [] listFiles = dir .listFiles (new ImageFileFilter ());
91
- if (listFiles .length > 0 )
85
+ if (listFiles != null && listFiles .length > 0 )
92
86
folders .add (new Album (dir .getAbsolutePath (), dir .getName (), listFiles .length ));
93
87
94
88
File [] children = dir .listFiles (new FoldersFileFilter ());
95
- for (File temp : children ) {
96
- File nomedia = new File (temp , ".nomedia" );
97
- if (!excludedfolders .contains (temp ) && !temp .isHidden () && !nomedia .exists ()) {
89
+ if (children != null ) {
90
+ for (File temp : children ) {
91
+ File nomedia = new File (temp , ".nomedia" );
92
+ if (!excludedfolders .contains (temp ) && !temp .isHidden () && !nomedia .exists ()) {
98
93
/*File[] files = temp.listFiles(new ImageFileFilter());
99
94
if (files.length > 0)
100
95
folders.add(new Album(temp.getAbsolutePath(), temp.getName(), files.length));*/
101
- fetchRecursivelyFolder (temp , folders );
96
+ fetchRecursivelyFolder (temp , folders );
97
+ }
102
98
}
103
99
}
104
100
}
@@ -107,26 +103,30 @@ private void fetchRecursivelyFolder(File dir, ArrayList<Album> folders) {
107
103
private void fetchRecursivelyHiddenFolder (File dir , ArrayList <Album > folders ) {
108
104
if (!excludedfolders .contains (dir )) {
109
105
File [] asdf = dir .listFiles (new FoldersFileFilter ());
110
- for (File temp : asdf ) {
111
- File nomedia = new File (temp , ".nomedia" );
112
- if (!excludedfolders .contains (temp ) && nomedia .exists ()) {
113
- File [] files = temp .listFiles (new ImageFileFilter ());
114
- if (files .length > 0 )
115
- folders .add (new Album (temp .getAbsolutePath (), temp .getName (), files .length ));
106
+ if (asdf !=null ) {
107
+ for (File temp : asdf ) {
108
+ File nomedia = new File (temp , ".nomedia" );
109
+ if (!excludedfolders .contains (temp ) && nomedia .exists ()) {
110
+ File [] files = temp .listFiles (new ImageFileFilter ());
111
+ if (files != null && files .length > 0 )
112
+ folders .add (new Album (temp .getAbsolutePath (), temp .getName (), files .length ));
113
+ }
114
+ fetchRecursivelyHiddenFolder (temp , folders );
116
115
}
117
- fetchRecursivelyHiddenFolder (temp , folders );
118
116
}
119
117
}
120
118
}
121
119
private void fetchRecursivelyFolder (File dir ) {
122
120
if (!excludedfolders .contains (dir )) {
123
121
checkAndAddAlbum (dir );
124
122
File [] children = dir .listFiles (new FoldersFileFilter ());
125
- for (File temp : children ) {
126
- File nomedia = new File (temp , ".nomedia" );
127
- if (!excludedfolders .contains (temp ) && !temp .isHidden () && !nomedia .exists ()) {
128
- //not excluded/hidden folder
129
- fetchRecursivelyFolder (temp );
123
+ if (children != null ) {
124
+ for (File temp : children ) {
125
+ File nomedia = new File (temp , ".nomedia" );
126
+ if (!excludedfolders .contains (temp ) && !temp .isHidden () && !nomedia .exists ()) {
127
+ //not excluded/hidden folder
128
+ fetchRecursivelyFolder (temp );
129
+ }
130
130
}
131
131
}
132
132
}
@@ -135,19 +135,21 @@ private void fetchRecursivelyFolder(File dir) {
135
135
private void fetchRecursivelyHiddenFolder (File dir ) {
136
136
if (!excludedfolders .contains (dir )) {
137
137
File [] folders = dir .listFiles (new FoldersFileFilter ());
138
- for (File temp : folders ) {
139
- File nomedia = new File (temp , ".nomedia" );
140
- if (!excludedfolders .contains (temp ) && nomedia .exists ()) {
141
- checkAndAddAlbum (temp );
138
+ if (folders != null ) {
139
+ for (File temp : folders ) {
140
+ File nomedia = new File (temp , ".nomedia" );
141
+ if (!excludedfolders .contains (temp ) && nomedia .exists ()) {
142
+ checkAndAddAlbum (temp );
143
+ }
144
+ fetchRecursivelyHiddenFolder (temp );
142
145
}
143
- fetchRecursivelyHiddenFolder (temp );
144
146
}
145
147
}
146
148
}
147
149
148
150
public void checkAndAddAlbum (File temp ) {
149
151
File [] files = temp .listFiles (new ImageFileFilter ());
150
- if (files .length > 0 ) {
152
+ if (files != null && files .length > 0 ) {
151
153
//valid folder
152
154
Album asd = new Album (temp .getAbsolutePath (), temp .getName (), files .length );
153
155
asd .setCoverPath (customAlbumsHandler .getPhotPrevieAlbum (asd .getPath ()));
0 commit comments