mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-25 14:08:00 +01:00
do not include subfolders in photos of folders
This commit is contained in:
parent
eed77d4738
commit
e38ac2893d
2 changed files with 13 additions and 4 deletions
|
@ -12,6 +12,7 @@ import android.widget.GridView;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import gallery.simplemobiletools.com.Constants;
|
||||
import gallery.simplemobiletools.com.R;
|
||||
|
@ -40,11 +41,15 @@ public class PhotosActivity extends AppCompatActivity implements AdapterView.OnI
|
|||
final String[] columns = {MediaStore.Images.Media.DATA};
|
||||
final String order = MediaStore.Images.Media.DATE_MODIFIED + " DESC";
|
||||
final Cursor cursor = getContentResolver().query(uri, columns, where, args, order);
|
||||
final String pattern = Pattern.quote(path) + "/[^/]*";
|
||||
|
||||
if (cursor != null && cursor.moveToFirst()) {
|
||||
final int pathIndex = cursor.getColumnIndex(MediaStore.Images.Media.DATA);
|
||||
do {
|
||||
final String curPath = cursor.getString(pathIndex);
|
||||
if (curPath.toLowerCase().matches(pattern)) {
|
||||
photos.add(cursor.getString(pathIndex));
|
||||
}
|
||||
} while (cursor.moveToNext());
|
||||
cursor.close();
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@ import android.support.v7.app.AppCompatActivity;
|
|||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import gallery.simplemobiletools.com.Constants;
|
||||
import gallery.simplemobiletools.com.MyViewPager;
|
||||
|
@ -40,16 +41,19 @@ public class ViewPagerActivity extends AppCompatActivity {
|
|||
final String[] columns = {MediaStore.Images.Media.DATA};
|
||||
final String order = MediaStore.Images.Media.DATE_MODIFIED + " DESC";
|
||||
final Cursor cursor = getContentResolver().query(uri, columns, where, args, order);
|
||||
final String pattern = Pattern.quote(fileDir) + "/[^/]*";
|
||||
|
||||
int i = 0;
|
||||
if (cursor != null && cursor.moveToFirst()) {
|
||||
final int pathIndex = cursor.getColumnIndex(MediaStore.Images.Media.DATA);
|
||||
do {
|
||||
final String curPath = cursor.getString(pathIndex);
|
||||
if (curPath.toLowerCase().matches(pattern)) {
|
||||
photos.add(curPath);
|
||||
|
||||
if (curPath.equals(path))
|
||||
pos = i;
|
||||
}
|
||||
|
||||
i++;
|
||||
} while (cursor.moveToNext());
|
||||
|
|
Loading…
Reference in a new issue