mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-22 04:28:00 +01:00
rename photos to media
This commit is contained in:
parent
39fa01ab96
commit
728afc915c
16 changed files with 147 additions and 113 deletions
|
@ -21,7 +21,7 @@
|
|||
</activity>
|
||||
|
||||
<activity
|
||||
android:name=".activities.PhotosActivity"/>
|
||||
android:name=".activities.MediaActivity"/>
|
||||
|
||||
<activity
|
||||
android:name=".activities.ViewPagerActivity"
|
||||
|
|
|
@ -2,5 +2,5 @@ package com.simplemobiletools.gallery;
|
|||
|
||||
public class Constants {
|
||||
public static final String DIRECTORY = "directory";
|
||||
public static final String PHOTO = "photo";
|
||||
public static final String MEDIUM = "medium";
|
||||
}
|
||||
|
|
|
@ -4,13 +4,13 @@ public class Directory {
|
|||
private final String path;
|
||||
private final String thumbnail;
|
||||
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.thumbnail = thumbnail;
|
||||
this.name = name;
|
||||
this.photoCnt = photoCnt;
|
||||
this.mediaCnt = mediaCnt;
|
||||
}
|
||||
|
||||
public String getPath() {
|
||||
|
@ -25,11 +25,11 @@ public class Directory {
|
|||
return name;
|
||||
}
|
||||
|
||||
public int getPhotoCnt() {
|
||||
return photoCnt;
|
||||
public int getMediaCnt() {
|
||||
return mediaCnt;
|
||||
}
|
||||
|
||||
public void setPhotoCnt(int cnt) {
|
||||
photoCnt = cnt;
|
||||
public void setMediaCnt(int cnt) {
|
||||
mediaCnt = cnt;
|
||||
}
|
||||
}
|
||||
|
|
19
app/src/main/java/com/simplemobiletools/gallery/Media.java
Normal file
19
app/src/main/java/com/simplemobiletools/gallery/Media.java
Normal 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;
|
||||
}
|
||||
}
|
|
@ -152,8 +152,8 @@ public class MainActivity extends AppCompatActivity
|
|||
|
||||
if (directories.containsKey(fileDir)) {
|
||||
final Directory directory = directories.get(fileDir);
|
||||
final int newImageCnt = directory.getPhotoCnt() + 1;
|
||||
directory.setPhotoCnt(newImageCnt);
|
||||
final int newImageCnt = directory.getMediaCnt() + 1;
|
||||
directory.setMediaCnt(newImageCnt);
|
||||
} else if (!toBeDeleted.contains(fileDir)) {
|
||||
final String dirName = Utils.getFilename(fileDir);
|
||||
directories.put(fileDir, new Directory(fileDir, path, dirName, 1));
|
||||
|
@ -310,7 +310,7 @@ public class MainActivity extends AppCompatActivity
|
|||
|
||||
@Override
|
||||
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());
|
||||
startActivity(intent);
|
||||
}
|
||||
|
|
|
@ -28,9 +28,10 @@ import android.widget.GridView;
|
|||
import android.widget.Toast;
|
||||
|
||||
import com.simplemobiletools.gallery.Constants;
|
||||
import com.simplemobiletools.gallery.Media;
|
||||
import com.simplemobiletools.gallery.R;
|
||||
import com.simplemobiletools.gallery.Utils;
|
||||
import com.simplemobiletools.gallery.adapters.PhotosAdapter;
|
||||
import com.simplemobiletools.gallery.adapters.MediaAdapter;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
|
@ -40,13 +41,13 @@ import java.util.regex.Pattern;
|
|||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
|
||||
public class PhotosActivity extends AppCompatActivity
|
||||
public class MediaActivity extends AppCompatActivity
|
||||
implements AdapterView.OnItemClickListener, GridView.MultiChoiceModeListener, MediaScannerConnection.OnScanCompletedListener,
|
||||
GridView.OnTouchListener {
|
||||
@BindView(R.id.photos_grid) GridView gridView;
|
||||
@BindView(R.id.media_grid) GridView gridView;
|
||||
|
||||
private static final int STORAGE_PERMISSION = 1;
|
||||
private List<String> photos;
|
||||
private List<Media> media;
|
||||
private int selectedItemsCnt;
|
||||
private String path;
|
||||
private Snackbar snackbar;
|
||||
|
@ -57,7 +58,7 @@ public class PhotosActivity extends AppCompatActivity
|
|||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_photos);
|
||||
setContentView(R.layout.activity_media);
|
||||
ButterKnife.bind(this);
|
||||
}
|
||||
|
||||
|
@ -101,11 +102,11 @@ public class PhotosActivity extends AppCompatActivity
|
|||
private void initializeGallery() {
|
||||
toBeDeleted = new ArrayList<>();
|
||||
path = getIntent().getStringExtra(Constants.DIRECTORY);
|
||||
photos = getPhotos();
|
||||
media = getMedia();
|
||||
if (isDirEmpty())
|
||||
return;
|
||||
|
||||
final PhotosAdapter adapter = new PhotosAdapter(this, photos);
|
||||
final MediaAdapter adapter = new MediaAdapter(this, media);
|
||||
gridView.setAdapter(adapter);
|
||||
gridView.setOnItemClickListener(this);
|
||||
gridView.setMultiChoiceModeListener(this);
|
||||
|
@ -123,34 +124,39 @@ public class PhotosActivity extends AppCompatActivity
|
|||
}
|
||||
}
|
||||
|
||||
private List<String> getPhotos() {
|
||||
final List<String> myPhotos = new ArrayList<>();
|
||||
final Uri uri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
|
||||
final String where = MediaStore.Images.Media.DATA + " like ? ";
|
||||
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) + "/[^/]*";
|
||||
private List<Media> getMedia() {
|
||||
final List<Media> myMedia = new ArrayList<>();
|
||||
for (int i = 0; i < 2; i++) {
|
||||
Uri uri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
|
||||
if (i == 1) {
|
||||
uri = MediaStore.Video.Media.EXTERNAL_CONTENT_URI;
|
||||
}
|
||||
final String where = MediaStore.Images.Media.DATA + " like ? ";
|
||||
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()) {
|
||||
final int pathIndex = cursor.getColumnIndex(MediaStore.Images.Media.DATA);
|
||||
do {
|
||||
final String curPath = cursor.getString(pathIndex);
|
||||
if (curPath.matches(pattern) && !toBeDeleted.contains(curPath)) {
|
||||
final File file = new File(curPath);
|
||||
if (file.exists()) {
|
||||
myPhotos.add(cursor.getString(pathIndex));
|
||||
if (cursor != null && cursor.moveToFirst()) {
|
||||
final int pathIndex = cursor.getColumnIndex(MediaStore.Images.Media.DATA);
|
||||
do {
|
||||
final String curPath = cursor.getString(pathIndex);
|
||||
if (curPath.matches(pattern) && !toBeDeleted.contains(curPath)) {
|
||||
final File file = new File(curPath);
|
||||
if (file.exists()) {
|
||||
myMedia.add(new Media(cursor.getString(pathIndex), (i == 1)));
|
||||
}
|
||||
}
|
||||
}
|
||||
} while (cursor.moveToNext());
|
||||
cursor.close();
|
||||
} while (cursor.moveToNext());
|
||||
cursor.close();
|
||||
}
|
||||
}
|
||||
return myPhotos;
|
||||
return myMedia;
|
||||
}
|
||||
|
||||
private boolean isDirEmpty() {
|
||||
if (photos.size() <= 0) {
|
||||
if (media.size() <= 0) {
|
||||
deleteDirectoryIfEmpty();
|
||||
finish();
|
||||
return true;
|
||||
|
@ -166,7 +172,7 @@ public class PhotosActivity extends AppCompatActivity
|
|||
for (int i = 0; i < cnt; i++) {
|
||||
if (items.valueAt(i)) {
|
||||
final int id = items.keyAt(i);
|
||||
final String path = photos.get(id);
|
||||
final String path = media.get(id).getPath();
|
||||
toBeDeleted.add(path);
|
||||
deletedCnt++;
|
||||
}
|
||||
|
@ -176,9 +182,9 @@ public class PhotosActivity extends AppCompatActivity
|
|||
}
|
||||
|
||||
private void notifyDeletion(int cnt) {
|
||||
photos = getPhotos();
|
||||
media = getMedia();
|
||||
|
||||
if (photos.isEmpty()) {
|
||||
if (media.isEmpty()) {
|
||||
deleteFiles();
|
||||
} else {
|
||||
final CoordinatorLayout coordinator = (CoordinatorLayout) findViewById(R.id.coordinator_layout);
|
||||
|
@ -220,22 +226,22 @@ public class PhotosActivity extends AppCompatActivity
|
|||
snackbar.dismiss();
|
||||
isSnackbarShown = false;
|
||||
toBeDeleted.clear();
|
||||
photos = getPhotos();
|
||||
media = getMedia();
|
||||
updateGridView();
|
||||
}
|
||||
};
|
||||
|
||||
private void updateGridView() {
|
||||
if (!isDirEmpty()) {
|
||||
final PhotosAdapter adapter = (PhotosAdapter) gridView.getAdapter();
|
||||
adapter.updateItems(photos);
|
||||
final MediaAdapter adapter = (MediaAdapter) gridView.getAdapter();
|
||||
adapter.updateItems(media);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -255,7 +261,7 @@ public class PhotosActivity extends AppCompatActivity
|
|||
@Override
|
||||
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
|
||||
final MenuInflater inflater = mode.getMenuInflater();
|
||||
inflater.inflate(R.menu.photos_menu, menu);
|
||||
inflater.inflate(R.menu.media_menu, menu);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -283,7 +289,7 @@ public class PhotosActivity extends AppCompatActivity
|
|||
|
||||
@Override
|
||||
public void onScanCompleted(String path, Uri uri) {
|
||||
if (photos.isEmpty()) {
|
||||
if (media.isEmpty()) {
|
||||
finish();
|
||||
}
|
||||
}
|
|
@ -21,6 +21,7 @@ import android.widget.EditText;
|
|||
import android.widget.RelativeLayout;
|
||||
|
||||
import com.simplemobiletools.gallery.Constants;
|
||||
import com.simplemobiletools.gallery.Media;
|
||||
import com.simplemobiletools.gallery.MyViewPager;
|
||||
import com.simplemobiletools.gallery.R;
|
||||
import com.simplemobiletools.gallery.Utils;
|
||||
|
@ -44,7 +45,7 @@ public class ViewPagerActivity extends AppCompatActivity
|
|||
private int pos;
|
||||
private boolean isFullScreen;
|
||||
private ActionBar actionbar;
|
||||
private List<String> photos;
|
||||
private List<Media> media;
|
||||
private String path;
|
||||
private String directory;
|
||||
private boolean isUndoShown;
|
||||
|
@ -54,7 +55,7 @@ public class ViewPagerActivity extends AppCompatActivity
|
|||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_photo);
|
||||
setContentView(R.layout.activity_medium);
|
||||
ButterKnife.bind(this);
|
||||
|
||||
pos = 0;
|
||||
|
@ -64,15 +65,15 @@ public class ViewPagerActivity extends AppCompatActivity
|
|||
beingDeleted = "";
|
||||
hideSystemUI();
|
||||
|
||||
path = getIntent().getStringExtra(Constants.PHOTO);
|
||||
path = getIntent().getStringExtra(Constants.MEDIUM);
|
||||
MediaScannerConnection.scanFile(this, new String[]{path}, null, null);
|
||||
addUndoMargin();
|
||||
directory = new File(path).getParent();
|
||||
photos = getPhotos();
|
||||
media = getMedia();
|
||||
if (isDirEmpty())
|
||||
return;
|
||||
|
||||
final MyPagerAdapter adapter = new MyPagerAdapter(getSupportFragmentManager(), photos);
|
||||
final MyPagerAdapter adapter = new MyPagerAdapter(getSupportFragmentManager(), media);
|
||||
pager.setAdapter(adapter);
|
||||
pager.setCurrentItem(pos);
|
||||
pager.addOnPageChangeListener(this);
|
||||
|
@ -103,20 +104,20 @@ public class ViewPagerActivity extends AppCompatActivity
|
|||
deleteFile();
|
||||
switch (item.getItemId()) {
|
||||
case R.id.menu_share:
|
||||
shareImage();
|
||||
shareMedium();
|
||||
return true;
|
||||
case R.id.menu_delete:
|
||||
notifyDeletion();
|
||||
return true;
|
||||
case R.id.menu_edit:
|
||||
editImage();
|
||||
editMedium();
|
||||
return true;
|
||||
default:
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
}
|
||||
|
||||
private void shareImage() {
|
||||
private void shareMedium() {
|
||||
final String shareTitle = getResources().getString(R.string.share_via);
|
||||
final Intent sendIntent = new Intent();
|
||||
final File file = getCurrentFile();
|
||||
|
@ -130,7 +131,7 @@ public class ViewPagerActivity extends AppCompatActivity
|
|||
private void notifyDeletion() {
|
||||
toBeDeleted = getCurrentFile().getAbsolutePath();
|
||||
|
||||
if (photos.size() <= 1) {
|
||||
if (media.size() <= 1) {
|
||||
deleteFile();
|
||||
} else {
|
||||
Utils.showToast(this, R.string.file_deleted);
|
||||
|
@ -158,7 +159,7 @@ public class ViewPagerActivity extends AppCompatActivity
|
|||
}
|
||||
|
||||
private boolean isDirEmpty() {
|
||||
if (photos.size() <= 0) {
|
||||
if (media.size() <= 0) {
|
||||
deleteDirectoryIfEmpty();
|
||||
finish();
|
||||
return true;
|
||||
|
@ -166,7 +167,7 @@ public class ViewPagerActivity extends AppCompatActivity
|
|||
return false;
|
||||
}
|
||||
|
||||
private void editImage() {
|
||||
private void editMedium() {
|
||||
final File file = getCurrentFile();
|
||||
final String fullName = file.getName();
|
||||
final int dotAt = fullName.lastIndexOf(".");
|
||||
|
@ -206,7 +207,8 @@ public class ViewPagerActivity extends AppCompatActivity
|
|||
final File newFile = new File(file.getParent(), fileName + "." + extension);
|
||||
|
||||
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()};
|
||||
MediaScannerConnection.scanFile(getApplicationContext(), changedFiles, null, null);
|
||||
|
@ -222,12 +224,12 @@ public class ViewPagerActivity extends AppCompatActivity
|
|||
private void reloadViewPager() {
|
||||
final MyPagerAdapter adapter = (MyPagerAdapter) pager.getAdapter();
|
||||
final int curPos = pager.getCurrentItem();
|
||||
photos = getPhotos();
|
||||
media = getMedia();
|
||||
if (isDirEmpty())
|
||||
return;
|
||||
|
||||
pager.setAdapter(null);
|
||||
adapter.updateItems(photos);
|
||||
adapter.updateItems(media);
|
||||
pager.setAdapter(adapter);
|
||||
|
||||
final int newPos = Math.min(curPos, adapter.getCount());
|
||||
|
@ -245,34 +247,39 @@ public class ViewPagerActivity extends AppCompatActivity
|
|||
MediaScannerConnection.scanFile(getApplicationContext(), toBeDeleted, null, null);
|
||||
}
|
||||
|
||||
private List<String> getPhotos() {
|
||||
final List<String> photos = new ArrayList<>();
|
||||
final Uri uri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
|
||||
final String where = MediaStore.Images.Media.DATA + " like ? ";
|
||||
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) + "/[^/]*";
|
||||
private List<Media> getMedia() {
|
||||
final List<Media> media = new ArrayList<>();
|
||||
for (int i = 0; i < 2; i++) {
|
||||
Uri uri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
|
||||
if (i == 1) {
|
||||
uri = MediaStore.Video.Media.EXTERNAL_CONTENT_URI;
|
||||
}
|
||||
final String where = MediaStore.Images.Media.DATA + " like ? ";
|
||||
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;
|
||||
if (cursor != null && cursor.moveToFirst()) {
|
||||
final int pathIndex = cursor.getColumnIndex(MediaStore.Images.Media.DATA);
|
||||
do {
|
||||
final String curPath = cursor.getString(pathIndex);
|
||||
if (curPath.matches(pattern) && !curPath.equals(toBeDeleted) && !curPath.equals(beingDeleted)) {
|
||||
photos.add(curPath);
|
||||
int j = 0;
|
||||
if (cursor != null && cursor.moveToFirst()) {
|
||||
final int pathIndex = cursor.getColumnIndex(MediaStore.Images.Media.DATA);
|
||||
do {
|
||||
final String curPath = cursor.getString(pathIndex);
|
||||
if (curPath.matches(pattern) && !curPath.equals(toBeDeleted) && !curPath.equals(beingDeleted)) {
|
||||
media.add(new Media(curPath, j == 1));
|
||||
|
||||
if (curPath.equals(path)) {
|
||||
pos = i;
|
||||
if (curPath.equals(path)) {
|
||||
pos = j;
|
||||
}
|
||||
|
||||
j++;
|
||||
}
|
||||
|
||||
i++;
|
||||
}
|
||||
} while (cursor.moveToNext());
|
||||
cursor.close();
|
||||
} while (cursor.moveToNext());
|
||||
cursor.close();
|
||||
}
|
||||
}
|
||||
return photos;
|
||||
return media;
|
||||
}
|
||||
|
||||
public void photoClicked() {
|
||||
|
@ -307,11 +314,11 @@ public class ViewPagerActivity extends AppCompatActivity
|
|||
}
|
||||
|
||||
private void updateActionbarTitle() {
|
||||
setTitle(Utils.getFilename(photos.get(pager.getCurrentItem())));
|
||||
setTitle(Utils.getFilename(media.get(pager.getCurrentItem()).getPath()));
|
||||
}
|
||||
|
||||
private File getCurrentFile() {
|
||||
return new File(photos.get(pos));
|
||||
return new File(media.get(pos).getPath());
|
||||
}
|
||||
|
||||
private void addUndoMargin() {
|
||||
|
@ -364,7 +371,7 @@ public class ViewPagerActivity extends AppCompatActivity
|
|||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (photos.size() <= 1)
|
||||
if (media.size() <= 1)
|
||||
reloadViewPager();
|
||||
}
|
||||
});
|
||||
|
|
|
@ -41,7 +41,7 @@ public class DirectoryAdapter extends BaseAdapter {
|
|||
|
||||
final Directory dir = dirs.get(position);
|
||||
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);
|
||||
|
||||
return view;
|
||||
|
|
|
@ -8,18 +8,19 @@ import android.widget.BaseAdapter;
|
|||
import android.widget.ImageView;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.simplemobiletools.gallery.Media;
|
||||
import com.simplemobiletools.gallery.R;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class PhotosAdapter extends BaseAdapter {
|
||||
public class MediaAdapter extends BaseAdapter {
|
||||
private final Context context;
|
||||
private final List<String> photos;
|
||||
private final List<Media> media;
|
||||
private final LayoutInflater inflater;
|
||||
|
||||
public PhotosAdapter(Context context, List<String> photos) {
|
||||
public MediaAdapter(Context context, List<Media> media) {
|
||||
this.context = context;
|
||||
this.photos = photos;
|
||||
this.media = media;
|
||||
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) {
|
||||
ViewHolder holder;
|
||||
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);
|
||||
view.setTag(holder);
|
||||
} else {
|
||||
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);
|
||||
|
||||
return view;
|
||||
|
@ -42,12 +43,12 @@ public class PhotosAdapter extends BaseAdapter {
|
|||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return photos.size();
|
||||
return media.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getItem(int position) {
|
||||
return photos.get(position);
|
||||
return media.get(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -55,9 +56,9 @@ public class PhotosAdapter extends BaseAdapter {
|
|||
return 0;
|
||||
}
|
||||
|
||||
public void updateItems(List<String> newPhotos) {
|
||||
photos.clear();
|
||||
photos.addAll(newPhotos);
|
||||
public void updateItems(List<Media> newPhotos) {
|
||||
media.clear();
|
||||
media.addAll(newPhotos);
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
|
@ -65,7 +66,7 @@ public class PhotosAdapter extends BaseAdapter {
|
|||
ImageView photoThumbnail;
|
||||
|
||||
public ViewHolder(View view) {
|
||||
photoThumbnail = (ImageView) view.findViewById(R.id.photo_thumbnail);
|
||||
photoThumbnail = (ImageView) view.findViewById(R.id.medium_thumbnail);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -4,14 +4,15 @@ import android.support.v4.app.Fragment;
|
|||
import android.support.v4.app.FragmentManager;
|
||||
import android.support.v4.app.FragmentStatePagerAdapter;
|
||||
|
||||
import com.simplemobiletools.gallery.Media;
|
||||
import com.simplemobiletools.gallery.ViewPagerFragment;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
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);
|
||||
this.paths = paths;
|
||||
}
|
||||
|
@ -24,11 +25,11 @@ public class MyPagerAdapter extends FragmentStatePagerAdapter {
|
|||
@Override
|
||||
public Fragment getItem(int position) {
|
||||
final ViewPagerFragment fragment = new ViewPagerFragment();
|
||||
fragment.setPath(paths.get(position));
|
||||
fragment.setPath(paths.get(position).getPath());
|
||||
return fragment;
|
||||
}
|
||||
|
||||
public void updateItems(List<String> newPaths) {
|
||||
public void updateItems(List<Media> newPaths) {
|
||||
paths.clear();
|
||||
paths.addAll(newPaths);
|
||||
notifyDataSetChanged();
|
||||
|
|
|
@ -7,11 +7,11 @@
|
|||
android:background="@android:color/black">
|
||||
|
||||
<GridView
|
||||
android:id="@+id/photos_grid"
|
||||
android:id="@+id/media_grid"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:choiceMode="multipleChoiceModal"
|
||||
android:columnWidth="@dimen/photo_tmb_size"
|
||||
android:columnWidth="@dimen/medium_tmb_size"
|
||||
android:horizontalSpacing="1dp"
|
||||
android:numColumns="auto_fit"
|
||||
android:stretchMode="columnWidth"
|
|
@ -6,7 +6,7 @@
|
|||
android:foreground="@drawable/selector">
|
||||
|
||||
<com.simplemobiletools.gallery.MyImageView
|
||||
android:id="@+id/photo_thumbnail"
|
||||
android:id="@+id/medium_thumbnail"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"/>
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
<resources>
|
||||
<dimen name="activity_margin">16dp</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>
|
||||
</resources>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<resources>
|
||||
<string name="app_name">Simple Gallery</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="deleting">Deleting</string>
|
||||
<string name="edit">Edit</string>
|
||||
|
|
Loading…
Reference in a new issue