Commit ed0df607 authored by Donald's avatar Donald

fixed #171

 now is possible to change the column count of media programmaticaly with the volume keys and with the ScaleGesture pinch in/pinch out
 fixed a backup issue with content from mediastore
 commented draggable scroolbar
parent 09575a0c
......@@ -474,7 +474,7 @@ public class Album implements Serializable {
found_id_album = true;
}
Log.d(s, "onScanCompleted: "+s);
m.setPath(s); m.setUri(uri);
m.setPath(s); m.setUri(uri.toString());
}
});
......
......@@ -66,7 +66,7 @@ public class Media implements Parcelable, Serializable {
private String path = null;
private long dateModified = -1;
private String mime = null;
private Uri uri = null;
private String uri = null;
private long id;
private long size = 0;
......@@ -93,9 +93,9 @@ public class Media implements Parcelable, Serializable {
}
public Media(Context context, Uri mediaUri) {
this.uri = mediaUri;
this.uri = mediaUri.toString();
this.path = null;
setMIME(context.getContentResolver().getType(uri));
setMIME(context.getContentResolver().getType(getUri()));
}
public Media(@NotNull Cursor cur) {
......@@ -104,11 +104,11 @@ public class Media implements Parcelable, Serializable {
this.dateModified = cur.getLong(cur.getColumnIndex(MediaStore.Images.Media.DATE_TAKEN));
setMIME(cur.getString(cur.getColumnIndex(MediaStore.Images.Media.MIME_TYPE)));
this.id = cur.getLong(cur.getColumnIndex(MediaStore.Images.Media._ID));
this.uri = ContentUris.withAppendedId(MediaStore.Files.getContentUri("external"), getId());
this.uri = ContentUris.withAppendedId(MediaStore.Files.getContentUri("external"), getId()).toString();
}
public void setUri(Uri uri) {
this.uri = uri;
public void setUri(String uriString) {
this.uri = uriString;
}
public void setPath(String path) {
......@@ -143,7 +143,7 @@ public class Media implements Parcelable, Serializable {
public boolean isVideo() { return getMIME().startsWith("video"); }
public Uri getUri() {
return isFromContentProvider() ? uri : Uri.fromFile(new File(path));
return isFromContentProvider() ? Uri.parse(uri) : Uri.fromFile(new File(path));
}
@TestOnly
......@@ -402,7 +402,6 @@ public class Media implements Parcelable, Serializable {
dest.writeString(this.path);
dest.writeLong(this.dateModified);
dest.writeString(this.mime);
dest.writeParcelable(this.uri, flags);
dest.writeLong(this.id);
dest.writeLong(this.size);
dest.writeByte(this.selected ? (byte) 1 : (byte) 0);
......@@ -412,7 +411,6 @@ public class Media implements Parcelable, Serializable {
this.path = in.readString();
this.dateModified = in.readLong();
this.mime = in.readString();
this.uri = in.readParcelable(Uri.class.getClassLoader());
this.id = in.readLong();
this.size = in.readLong();
this.selected = in.readByte() != 0;
......
......@@ -271,7 +271,7 @@ public class MainActivity extends SharedMediaActivity {
rvAlbums.addItemDecoration(rvAlbumsDecoration);
// TODO: 07/08/16 not change this
changeSpanCountRvMedia(Measure.getPhotosColumns(MainActivity.this));
//changeSpanCountRvMedia(Measure.getPhotosColumns(MainActivity.this));
int status_height = Measure.getStatusBarHeight(getResources()),
navBarHeight = Measure.getNavBarHeight(MainActivity.this);
......@@ -356,7 +356,7 @@ public class MainActivity extends SharedMediaActivity {
rvMedia.setHasFixedSize(true);
rvMedia.setItemAnimator(new DefaultItemAnimator());
changeSpanCountRvMedia(Measure.getPhotosColumns(getApplicationContext()));
changeSpanCountRvMedia(SP.getInt("span_count", Measure.getPhotosColumns(getApplicationContext())));
rvAlbumsDecoration = new GridSpacingItemDecoration(Measure.getAlbumsColumns(MainActivity.this), Measure.pxToDp(3, getApplicationContext()), true);
rvAlbums.addItemDecoration(rvAlbumsDecoration);
......@@ -380,19 +380,20 @@ public class MainActivity extends SharedMediaActivity {
@Override
public boolean onScaleBegin(ScaleGestureDetector detector) {
swipeRefreshLayout.setEnabled(false);
mediaAdapter.setOnClickListener(null);
mediaAdapter.setOnLongClickListener(null);
return super.onScaleBegin(detector);
}
@Override
public boolean onScale(ScaleGestureDetector detector) {
Log.d(TAG, "onScale: ");
int spanCount = ((GridLayoutManager) rvMedia.getLayoutManager()).getSpanCount();
if (detector.getCurrentSpan() > 200 && detector.getTimeDelta() > 300) {
if (detector.getCurrentSpan() > 200 && detector.getTimeDelta() > 400) {
if (detector.getCurrentSpan() > detector.getPreviousSpan()) {
changeSpanCountRvMedia(spanCount + 1);
changeSpanCountRvMedia(spanCount - 1);
return true;
} else if(detector.getCurrentSpan() < detector.getPreviousSpan()) {
changeSpanCountRvMedia(spanCount - 1);
changeSpanCountRvMedia(spanCount + 1);
return true;
}
}
......@@ -403,8 +404,9 @@ public class MainActivity extends SharedMediaActivity {
@Override
public void onScaleEnd(ScaleGestureDetector detector) {
super.onScaleEnd(detector);
mediaAdapter.setOnClickListener(photosOnClickListener);
mediaAdapter.setOnLongClickListener(photosOnLongClickListener);
swipeRefreshLayout.setEnabled(true);
Log.d(TAG, "onScaleEnd: ");
}
});
......@@ -517,6 +519,8 @@ public class MainActivity extends SharedMediaActivity {
rvMediaDecoration = new GridSpacingItemDecoration(spanCount, Measure.pxToDp(3, getApplicationContext()), true);
rvMedia.setLayoutManager(new GridLayoutManager(getApplicationContext(), spanCount));
rvMedia.addItemDecoration(rvMediaDecoration);
SP.putInt("span_count", spanCount);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment