rename photos to media

This commit is contained in:
tibbi 2016-06-05 23:22:32 +02:00
parent 39fa01ab96
commit 728afc915c
16 changed files with 147 additions and 113 deletions

View file

@ -21,7 +21,7 @@
</activity> </activity>
<activity <activity
android:name=".activities.PhotosActivity"/> android:name=".activities.MediaActivity"/>
<activity <activity
android:name=".activities.ViewPagerActivity" android:name=".activities.ViewPagerActivity"

View file

@ -2,5 +2,5 @@ package com.simplemobiletools.gallery;
public class Constants { public class Constants {
public static final String DIRECTORY = "directory"; public static final String DIRECTORY = "directory";
public static final String PHOTO = "photo"; public static final String MEDIUM = "medium";
} }

View file

@ -4,13 +4,13 @@ public class Directory {
private final String path; private final String path;
private final String thumbnail; private final String thumbnail;
private final String name; private final String name;
private int photoCnt; private int mediaCnt;
public Directory(String path, String thumbnail, String name, int photoCnt) { public Directory(String path, String thumbnail, String name, int mediaCnt) {
this.path = path; this.path = path;
this.thumbnail = thumbnail; this.thumbnail = thumbnail;
this.name = name; this.name = name;
this.photoCnt = photoCnt; this.mediaCnt = mediaCnt;
} }
public String getPath() { public String getPath() {
@ -25,11 +25,11 @@ public class Directory {
return name; return name;
} }
public int getPhotoCnt() { public int getMediaCnt() {
return photoCnt; return mediaCnt;
} }
public void setPhotoCnt(int cnt) { public void setMediaCnt(int cnt) {
photoCnt = cnt; mediaCnt = cnt;
} }
} }

View file

@ -0,0 +1,19 @@
package com.simplemobiletools.gallery;
public class Media {
private final String path;
private final boolean isVideo;
public Media(String path, boolean isVideo) {
this.path = path;
this.isVideo = isVideo;
}
public String getPath() {
return path;
}
public boolean getIsVideo() {
return isVideo;
}
}

View file

@ -152,8 +152,8 @@ public class MainActivity extends AppCompatActivity
if (directories.containsKey(fileDir)) { if (directories.containsKey(fileDir)) {
final Directory directory = directories.get(fileDir); final Directory directory = directories.get(fileDir);
final int newImageCnt = directory.getPhotoCnt() + 1; final int newImageCnt = directory.getMediaCnt() + 1;
directory.setPhotoCnt(newImageCnt); directory.setMediaCnt(newImageCnt);
} else if (!toBeDeleted.contains(fileDir)) { } else if (!toBeDeleted.contains(fileDir)) {
final String dirName = Utils.getFilename(fileDir); final String dirName = Utils.getFilename(fileDir);
directories.put(fileDir, new Directory(fileDir, path, dirName, 1)); directories.put(fileDir, new Directory(fileDir, path, dirName, 1));
@ -310,7 +310,7 @@ public class MainActivity extends AppCompatActivity
@Override @Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) { public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
final Intent intent = new Intent(this, PhotosActivity.class); final Intent intent = new Intent(this, MediaActivity.class);
intent.putExtra(Constants.DIRECTORY, dirs.get(position).getPath()); intent.putExtra(Constants.DIRECTORY, dirs.get(position).getPath());
startActivity(intent); startActivity(intent);
} }

View file

@ -28,9 +28,10 @@ import android.widget.GridView;
import android.widget.Toast; import android.widget.Toast;
import com.simplemobiletools.gallery.Constants; import com.simplemobiletools.gallery.Constants;
import com.simplemobiletools.gallery.Media;
import com.simplemobiletools.gallery.R; import com.simplemobiletools.gallery.R;
import com.simplemobiletools.gallery.Utils; import com.simplemobiletools.gallery.Utils;
import com.simplemobiletools.gallery.adapters.PhotosAdapter; import com.simplemobiletools.gallery.adapters.MediaAdapter;
import java.io.File; import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
@ -40,13 +41,13 @@ import java.util.regex.Pattern;
import butterknife.BindView; import butterknife.BindView;
import butterknife.ButterKnife; import butterknife.ButterKnife;
public class PhotosActivity extends AppCompatActivity public class MediaActivity extends AppCompatActivity
implements AdapterView.OnItemClickListener, GridView.MultiChoiceModeListener, MediaScannerConnection.OnScanCompletedListener, implements AdapterView.OnItemClickListener, GridView.MultiChoiceModeListener, MediaScannerConnection.OnScanCompletedListener,
GridView.OnTouchListener { GridView.OnTouchListener {
@BindView(R.id.photos_grid) GridView gridView; @BindView(R.id.media_grid) GridView gridView;
private static final int STORAGE_PERMISSION = 1; private static final int STORAGE_PERMISSION = 1;
private List<String> photos; private List<Media> media;
private int selectedItemsCnt; private int selectedItemsCnt;
private String path; private String path;
private Snackbar snackbar; private Snackbar snackbar;
@ -57,7 +58,7 @@ public class PhotosActivity extends AppCompatActivity
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.activity_photos); setContentView(R.layout.activity_media);
ButterKnife.bind(this); ButterKnife.bind(this);
} }
@ -101,11 +102,11 @@ public class PhotosActivity extends AppCompatActivity
private void initializeGallery() { private void initializeGallery() {
toBeDeleted = new ArrayList<>(); toBeDeleted = new ArrayList<>();
path = getIntent().getStringExtra(Constants.DIRECTORY); path = getIntent().getStringExtra(Constants.DIRECTORY);
photos = getPhotos(); media = getMedia();
if (isDirEmpty()) if (isDirEmpty())
return; return;
final PhotosAdapter adapter = new PhotosAdapter(this, photos); final MediaAdapter adapter = new MediaAdapter(this, media);
gridView.setAdapter(adapter); gridView.setAdapter(adapter);
gridView.setOnItemClickListener(this); gridView.setOnItemClickListener(this);
gridView.setMultiChoiceModeListener(this); gridView.setMultiChoiceModeListener(this);
@ -123,34 +124,39 @@ public class PhotosActivity extends AppCompatActivity
} }
} }
private List<String> getPhotos() { private List<Media> getMedia() {
final List<String> myPhotos = new ArrayList<>(); final List<Media> myMedia = new ArrayList<>();
final Uri uri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI; for (int i = 0; i < 2; i++) {
final String where = MediaStore.Images.Media.DATA + " like ? "; Uri uri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
final String[] args = new String[]{path + "%"}; if (i == 1) {
final String[] columns = {MediaStore.Images.Media.DATA}; uri = MediaStore.Video.Media.EXTERNAL_CONTENT_URI;
final String order = MediaStore.Images.Media.DATE_MODIFIED + " DESC"; }
final Cursor cursor = getContentResolver().query(uri, columns, where, args, order); final String where = MediaStore.Images.Media.DATA + " like ? ";
final String pattern = Pattern.quote(path) + "/[^/]*"; final String[] args = new String[]{path + "%"};
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()) { if (cursor != null && cursor.moveToFirst()) {
final int pathIndex = cursor.getColumnIndex(MediaStore.Images.Media.DATA); final int pathIndex = cursor.getColumnIndex(MediaStore.Images.Media.DATA);
do { do {
final String curPath = cursor.getString(pathIndex); final String curPath = cursor.getString(pathIndex);
if (curPath.matches(pattern) && !toBeDeleted.contains(curPath)) { if (curPath.matches(pattern) && !toBeDeleted.contains(curPath)) {
final File file = new File(curPath); final File file = new File(curPath);
if (file.exists()) { if (file.exists()) {
myPhotos.add(cursor.getString(pathIndex)); myMedia.add(new Media(cursor.getString(pathIndex), (i == 1)));
}
} }
} } while (cursor.moveToNext());
} while (cursor.moveToNext()); cursor.close();
cursor.close(); }
} }
return myPhotos; return myMedia;
} }
private boolean isDirEmpty() { private boolean isDirEmpty() {
if (photos.size() <= 0) { if (media.size() <= 0) {
deleteDirectoryIfEmpty(); deleteDirectoryIfEmpty();
finish(); finish();
return true; return true;
@ -166,7 +172,7 @@ public class PhotosActivity extends AppCompatActivity
for (int i = 0; i < cnt; i++) { for (int i = 0; i < cnt; i++) {
if (items.valueAt(i)) { if (items.valueAt(i)) {
final int id = items.keyAt(i); final int id = items.keyAt(i);
final String path = photos.get(id); final String path = media.get(id).getPath();
toBeDeleted.add(path); toBeDeleted.add(path);
deletedCnt++; deletedCnt++;
} }
@ -176,9 +182,9 @@ public class PhotosActivity extends AppCompatActivity
} }
private void notifyDeletion(int cnt) { private void notifyDeletion(int cnt) {
photos = getPhotos(); media = getMedia();
if (photos.isEmpty()) { if (media.isEmpty()) {
deleteFiles(); deleteFiles();
} else { } else {
final CoordinatorLayout coordinator = (CoordinatorLayout) findViewById(R.id.coordinator_layout); final CoordinatorLayout coordinator = (CoordinatorLayout) findViewById(R.id.coordinator_layout);
@ -220,22 +226,22 @@ public class PhotosActivity extends AppCompatActivity
snackbar.dismiss(); snackbar.dismiss();
isSnackbarShown = false; isSnackbarShown = false;
toBeDeleted.clear(); toBeDeleted.clear();
photos = getPhotos(); media = getMedia();
updateGridView(); updateGridView();
} }
}; };
private void updateGridView() { private void updateGridView() {
if (!isDirEmpty()) { if (!isDirEmpty()) {
final PhotosAdapter adapter = (PhotosAdapter) gridView.getAdapter(); final MediaAdapter adapter = (MediaAdapter) gridView.getAdapter();
adapter.updateItems(photos); adapter.updateItems(media);
} }
} }
@Override @Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) { public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
final Intent intent = new Intent(this, ViewPagerActivity.class); final Intent intent = new Intent(this, ViewPagerActivity.class);
intent.putExtra(Constants.PHOTO, photos.get(position)); intent.putExtra(Constants.MEDIUM, media.get(position).getPath());
startActivity(intent); startActivity(intent);
} }
@ -255,7 +261,7 @@ public class PhotosActivity extends AppCompatActivity
@Override @Override
public boolean onCreateActionMode(ActionMode mode, Menu menu) { public boolean onCreateActionMode(ActionMode mode, Menu menu) {
final MenuInflater inflater = mode.getMenuInflater(); final MenuInflater inflater = mode.getMenuInflater();
inflater.inflate(R.menu.photos_menu, menu); inflater.inflate(R.menu.media_menu, menu);
return true; return true;
} }
@ -283,7 +289,7 @@ public class PhotosActivity extends AppCompatActivity
@Override @Override
public void onScanCompleted(String path, Uri uri) { public void onScanCompleted(String path, Uri uri) {
if (photos.isEmpty()) { if (media.isEmpty()) {
finish(); finish();
} }
} }

View file

@ -21,6 +21,7 @@ import android.widget.EditText;
import android.widget.RelativeLayout; import android.widget.RelativeLayout;
import com.simplemobiletools.gallery.Constants; import com.simplemobiletools.gallery.Constants;
import com.simplemobiletools.gallery.Media;
import com.simplemobiletools.gallery.MyViewPager; import com.simplemobiletools.gallery.MyViewPager;
import com.simplemobiletools.gallery.R; import com.simplemobiletools.gallery.R;
import com.simplemobiletools.gallery.Utils; import com.simplemobiletools.gallery.Utils;
@ -44,7 +45,7 @@ public class ViewPagerActivity extends AppCompatActivity
private int pos; private int pos;
private boolean isFullScreen; private boolean isFullScreen;
private ActionBar actionbar; private ActionBar actionbar;
private List<String> photos; private List<Media> media;
private String path; private String path;
private String directory; private String directory;
private boolean isUndoShown; private boolean isUndoShown;
@ -54,7 +55,7 @@ public class ViewPagerActivity extends AppCompatActivity
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.activity_photo); setContentView(R.layout.activity_medium);
ButterKnife.bind(this); ButterKnife.bind(this);
pos = 0; pos = 0;
@ -64,15 +65,15 @@ public class ViewPagerActivity extends AppCompatActivity
beingDeleted = ""; beingDeleted = "";
hideSystemUI(); hideSystemUI();
path = getIntent().getStringExtra(Constants.PHOTO); path = getIntent().getStringExtra(Constants.MEDIUM);
MediaScannerConnection.scanFile(this, new String[]{path}, null, null); MediaScannerConnection.scanFile(this, new String[]{path}, null, null);
addUndoMargin(); addUndoMargin();
directory = new File(path).getParent(); directory = new File(path).getParent();
photos = getPhotos(); media = getMedia();
if (isDirEmpty()) if (isDirEmpty())
return; return;
final MyPagerAdapter adapter = new MyPagerAdapter(getSupportFragmentManager(), photos); final MyPagerAdapter adapter = new MyPagerAdapter(getSupportFragmentManager(), media);
pager.setAdapter(adapter); pager.setAdapter(adapter);
pager.setCurrentItem(pos); pager.setCurrentItem(pos);
pager.addOnPageChangeListener(this); pager.addOnPageChangeListener(this);
@ -103,20 +104,20 @@ public class ViewPagerActivity extends AppCompatActivity
deleteFile(); deleteFile();
switch (item.getItemId()) { switch (item.getItemId()) {
case R.id.menu_share: case R.id.menu_share:
shareImage(); shareMedium();
return true; return true;
case R.id.menu_delete: case R.id.menu_delete:
notifyDeletion(); notifyDeletion();
return true; return true;
case R.id.menu_edit: case R.id.menu_edit:
editImage(); editMedium();
return true; return true;
default: default:
return super.onOptionsItemSelected(item); return super.onOptionsItemSelected(item);
} }
} }
private void shareImage() { private void shareMedium() {
final String shareTitle = getResources().getString(R.string.share_via); final String shareTitle = getResources().getString(R.string.share_via);
final Intent sendIntent = new Intent(); final Intent sendIntent = new Intent();
final File file = getCurrentFile(); final File file = getCurrentFile();
@ -130,7 +131,7 @@ public class ViewPagerActivity extends AppCompatActivity
private void notifyDeletion() { private void notifyDeletion() {
toBeDeleted = getCurrentFile().getAbsolutePath(); toBeDeleted = getCurrentFile().getAbsolutePath();
if (photos.size() <= 1) { if (media.size() <= 1) {
deleteFile(); deleteFile();
} else { } else {
Utils.showToast(this, R.string.file_deleted); Utils.showToast(this, R.string.file_deleted);
@ -158,7 +159,7 @@ public class ViewPagerActivity extends AppCompatActivity
} }
private boolean isDirEmpty() { private boolean isDirEmpty() {
if (photos.size() <= 0) { if (media.size() <= 0) {
deleteDirectoryIfEmpty(); deleteDirectoryIfEmpty();
finish(); finish();
return true; return true;
@ -166,7 +167,7 @@ public class ViewPagerActivity extends AppCompatActivity
return false; return false;
} }
private void editImage() { private void editMedium() {
final File file = getCurrentFile(); final File file = getCurrentFile();
final String fullName = file.getName(); final String fullName = file.getName();
final int dotAt = fullName.lastIndexOf("."); final int dotAt = fullName.lastIndexOf(".");
@ -206,7 +207,8 @@ public class ViewPagerActivity extends AppCompatActivity
final File newFile = new File(file.getParent(), fileName + "." + extension); final File newFile = new File(file.getParent(), fileName + "." + extension);
if (file.renameTo(newFile)) { if (file.renameTo(newFile)) {
photos.set(pager.getCurrentItem(), newFile.getAbsolutePath()); final int currItem = pager.getCurrentItem();
media.set(currItem, new Media(newFile.getAbsolutePath(), media.get(currItem).getIsVideo()));
final String[] changedFiles = {file.getAbsolutePath(), newFile.getAbsolutePath()}; final String[] changedFiles = {file.getAbsolutePath(), newFile.getAbsolutePath()};
MediaScannerConnection.scanFile(getApplicationContext(), changedFiles, null, null); MediaScannerConnection.scanFile(getApplicationContext(), changedFiles, null, null);
@ -222,12 +224,12 @@ public class ViewPagerActivity extends AppCompatActivity
private void reloadViewPager() { private void reloadViewPager() {
final MyPagerAdapter adapter = (MyPagerAdapter) pager.getAdapter(); final MyPagerAdapter adapter = (MyPagerAdapter) pager.getAdapter();
final int curPos = pager.getCurrentItem(); final int curPos = pager.getCurrentItem();
photos = getPhotos(); media = getMedia();
if (isDirEmpty()) if (isDirEmpty())
return; return;
pager.setAdapter(null); pager.setAdapter(null);
adapter.updateItems(photos); adapter.updateItems(media);
pager.setAdapter(adapter); pager.setAdapter(adapter);
final int newPos = Math.min(curPos, adapter.getCount()); final int newPos = Math.min(curPos, adapter.getCount());
@ -245,34 +247,39 @@ public class ViewPagerActivity extends AppCompatActivity
MediaScannerConnection.scanFile(getApplicationContext(), toBeDeleted, null, null); MediaScannerConnection.scanFile(getApplicationContext(), toBeDeleted, null, null);
} }
private List<String> getPhotos() { private List<Media> getMedia() {
final List<String> photos = new ArrayList<>(); final List<Media> media = new ArrayList<>();
final Uri uri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI; for (int i = 0; i < 2; i++) {
final String where = MediaStore.Images.Media.DATA + " like ? "; Uri uri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
final String[] args = new String[]{directory + "%"}; if (i == 1) {
final String[] columns = {MediaStore.Images.Media.DATA}; uri = MediaStore.Video.Media.EXTERNAL_CONTENT_URI;
final String order = MediaStore.Images.Media.DATE_MODIFIED + " DESC"; }
final Cursor cursor = getContentResolver().query(uri, columns, where, args, order); final String where = MediaStore.Images.Media.DATA + " like ? ";
final String pattern = Pattern.quote(directory) + "/[^/]*"; final String[] args = new String[]{directory + "%"};
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(directory) + "/[^/]*";
int i = 0; int j = 0;
if (cursor != null && cursor.moveToFirst()) { if (cursor != null && cursor.moveToFirst()) {
final int pathIndex = cursor.getColumnIndex(MediaStore.Images.Media.DATA); final int pathIndex = cursor.getColumnIndex(MediaStore.Images.Media.DATA);
do { do {
final String curPath = cursor.getString(pathIndex); final String curPath = cursor.getString(pathIndex);
if (curPath.matches(pattern) && !curPath.equals(toBeDeleted) && !curPath.equals(beingDeleted)) { if (curPath.matches(pattern) && !curPath.equals(toBeDeleted) && !curPath.equals(beingDeleted)) {
photos.add(curPath); media.add(new Media(curPath, j == 1));
if (curPath.equals(path)) { if (curPath.equals(path)) {
pos = i; pos = j;
}
j++;
} }
} while (cursor.moveToNext());
i++; cursor.close();
} }
} while (cursor.moveToNext());
cursor.close();
} }
return photos; return media;
} }
public void photoClicked() { public void photoClicked() {
@ -307,11 +314,11 @@ public class ViewPagerActivity extends AppCompatActivity
} }
private void updateActionbarTitle() { private void updateActionbarTitle() {
setTitle(Utils.getFilename(photos.get(pager.getCurrentItem()))); setTitle(Utils.getFilename(media.get(pager.getCurrentItem()).getPath()));
} }
private File getCurrentFile() { private File getCurrentFile() {
return new File(photos.get(pos)); return new File(media.get(pos).getPath());
} }
private void addUndoMargin() { private void addUndoMargin() {
@ -364,7 +371,7 @@ public class ViewPagerActivity extends AppCompatActivity
runOnUiThread(new Runnable() { runOnUiThread(new Runnable() {
@Override @Override
public void run() { public void run() {
if (photos.size() <= 1) if (media.size() <= 1)
reloadViewPager(); reloadViewPager();
} }
}); });

View file

@ -41,7 +41,7 @@ public class DirectoryAdapter extends BaseAdapter {
final Directory dir = dirs.get(position); final Directory dir = dirs.get(position);
holder.dirName.setText(dir.getName()); holder.dirName.setText(dir.getName());
holder.photoCnt.setText(String.valueOf(dir.getPhotoCnt())); holder.photoCnt.setText(String.valueOf(dir.getMediaCnt()));
Glide.with(context).load(dir.getThumbnail()).placeholder(R.color.tmb_background).centerCrop().crossFade().into(holder.dirThumbnail); Glide.with(context).load(dir.getThumbnail()).placeholder(R.color.tmb_background).centerCrop().crossFade().into(holder.dirThumbnail);
return view; return view;

View file

@ -8,18 +8,19 @@ import android.widget.BaseAdapter;
import android.widget.ImageView; import android.widget.ImageView;
import com.bumptech.glide.Glide; import com.bumptech.glide.Glide;
import com.simplemobiletools.gallery.Media;
import com.simplemobiletools.gallery.R; import com.simplemobiletools.gallery.R;
import java.util.List; import java.util.List;
public class PhotosAdapter extends BaseAdapter { public class MediaAdapter extends BaseAdapter {
private final Context context; private final Context context;
private final List<String> photos; private final List<Media> media;
private final LayoutInflater inflater; private final LayoutInflater inflater;
public PhotosAdapter(Context context, List<String> photos) { public MediaAdapter(Context context, List<Media> media) {
this.context = context; this.context = context;
this.photos = photos; this.media = media;
this.inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); this.inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
} }
@ -27,14 +28,14 @@ public class PhotosAdapter extends BaseAdapter {
public View getView(int position, View view, ViewGroup parent) { public View getView(int position, View view, ViewGroup parent) {
ViewHolder holder; ViewHolder holder;
if (view == null) { if (view == null) {
view = inflater.inflate(R.layout.photo_item, parent, false); view = inflater.inflate(R.layout.medium_item, parent, false);
holder = new ViewHolder(view); holder = new ViewHolder(view);
view.setTag(holder); view.setTag(holder);
} else { } else {
holder = (ViewHolder) view.getTag(); holder = (ViewHolder) view.getTag();
} }
final String path = photos.get(position); final String path = media.get(position).getPath();
Glide.with(context).load(path).placeholder(R.color.tmb_background).centerCrop().crossFade().into(holder.photoThumbnail); Glide.with(context).load(path).placeholder(R.color.tmb_background).centerCrop().crossFade().into(holder.photoThumbnail);
return view; return view;
@ -42,12 +43,12 @@ public class PhotosAdapter extends BaseAdapter {
@Override @Override
public int getCount() { public int getCount() {
return photos.size(); return media.size();
} }
@Override @Override
public Object getItem(int position) { public Object getItem(int position) {
return photos.get(position); return media.get(position);
} }
@Override @Override
@ -55,9 +56,9 @@ public class PhotosAdapter extends BaseAdapter {
return 0; return 0;
} }
public void updateItems(List<String> newPhotos) { public void updateItems(List<Media> newPhotos) {
photos.clear(); media.clear();
photos.addAll(newPhotos); media.addAll(newPhotos);
notifyDataSetChanged(); notifyDataSetChanged();
} }
@ -65,7 +66,7 @@ public class PhotosAdapter extends BaseAdapter {
ImageView photoThumbnail; ImageView photoThumbnail;
public ViewHolder(View view) { public ViewHolder(View view) {
photoThumbnail = (ImageView) view.findViewById(R.id.photo_thumbnail); photoThumbnail = (ImageView) view.findViewById(R.id.medium_thumbnail);
} }
} }
} }

View file

@ -4,14 +4,15 @@ import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter; import android.support.v4.app.FragmentStatePagerAdapter;
import com.simplemobiletools.gallery.Media;
import com.simplemobiletools.gallery.ViewPagerFragment; import com.simplemobiletools.gallery.ViewPagerFragment;
import java.util.List; import java.util.List;
public class MyPagerAdapter extends FragmentStatePagerAdapter { public class MyPagerAdapter extends FragmentStatePagerAdapter {
private List<String> paths; private List<Media> paths;
public MyPagerAdapter(FragmentManager fm, List<String> paths) { public MyPagerAdapter(FragmentManager fm, List<Media> paths) {
super(fm); super(fm);
this.paths = paths; this.paths = paths;
} }
@ -24,11 +25,11 @@ public class MyPagerAdapter extends FragmentStatePagerAdapter {
@Override @Override
public Fragment getItem(int position) { public Fragment getItem(int position) {
final ViewPagerFragment fragment = new ViewPagerFragment(); final ViewPagerFragment fragment = new ViewPagerFragment();
fragment.setPath(paths.get(position)); fragment.setPath(paths.get(position).getPath());
return fragment; return fragment;
} }
public void updateItems(List<String> newPaths) { public void updateItems(List<Media> newPaths) {
paths.clear(); paths.clear();
paths.addAll(newPaths); paths.addAll(newPaths);
notifyDataSetChanged(); notifyDataSetChanged();

View file

@ -7,11 +7,11 @@
android:background="@android:color/black"> android:background="@android:color/black">
<GridView <GridView
android:id="@+id/photos_grid" android:id="@+id/media_grid"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:choiceMode="multipleChoiceModal" android:choiceMode="multipleChoiceModal"
android:columnWidth="@dimen/photo_tmb_size" android:columnWidth="@dimen/medium_tmb_size"
android:horizontalSpacing="1dp" android:horizontalSpacing="1dp"
android:numColumns="auto_fit" android:numColumns="auto_fit"
android:stretchMode="columnWidth" android:stretchMode="columnWidth"

View file

@ -6,7 +6,7 @@
android:foreground="@drawable/selector"> android:foreground="@drawable/selector">
<com.simplemobiletools.gallery.MyImageView <com.simplemobiletools.gallery.MyImageView
android:id="@+id/photo_thumbnail" android:id="@+id/medium_thumbnail"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"/> android:layout_height="match_parent"/>

View file

@ -1,6 +1,6 @@
<resources> <resources>
<dimen name="activity_margin">16dp</dimen> <dimen name="activity_margin">16dp</dimen>
<dimen name="dir_tmb_size">150dp</dimen> <dimen name="dir_tmb_size">150dp</dimen>
<dimen name="photo_tmb_size">100dp</dimen> <dimen name="medium_tmb_size">100dp</dimen>
<dimen name="undo_padding">8dp</dimen> <dimen name="undo_padding">8dp</dimen>
</resources> </resources>

View file

@ -1,7 +1,7 @@
<resources> <resources>
<string name="app_name">Simple Gallery</string> <string name="app_name">Simple Gallery</string>
<string name="share_via">Share via</string> <string name="share_via">Share via</string>
<string name="no_permissions">Not much to do in a gallery without accessing your photos</string> <string name="no_permissions">Not much to do in a gallery without accessing your photos and videos</string>
<string name="delete">Delete</string> <string name="delete">Delete</string>
<string name="deleting">Deleting</string> <string name="deleting">Deleting</string>
<string name="edit">Edit</string> <string name="edit">Edit</string>