Skip to content

Commit

Permalink
Handle duplicate files. Fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreyPavlenko committed Dec 14, 2020
1 parent 76927c6 commit ee57c75
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 3 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
ext {
def abi = project.properties['ABI']
VERSION_CODE = 80
VERSION_CODE = 81
VERSION_NAME = "1.7.3"
SDK_MIN_VERSION = 23
SDK_TARGET_VERSION = 30
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,9 @@ private boolean queryContentProvider(Uri uri, MetaBuilder mb) {

mb.setImageUri(uri.toString());
return true;
} catch (Exception ex) {
Log.e(ex, "Failed to query content provider: " + uri);
return false;
}
}

Expand Down
11 changes: 10 additions & 1 deletion fermata/src/main/java/me/aap/fermata/media/lib/FileItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
import static me.aap.fermata.BuildConfig.DEBUG;
import static me.aap.fermata.util.Utils.isVideoFile;
import static me.aap.utils.async.Completed.completedNull;
import static me.aap.utils.security.SecurityUtils.md5;
import static me.aap.utils.text.TextUtils.appendHexString;

/**
* @author Andrey Pavlenko
Expand All @@ -35,7 +37,14 @@ static FileItem create(String id, BrowsableItem parent, VirtualResource file, De
if (i != null) {
FileItem f = (FileItem) i;
if (DEBUG && !parent.equals(f.getParent())) throw new AssertionError();
if (DEBUG && !file.equals(f.getResource())) throw new AssertionError();

if (!file.equals(f.getResource())) {
StringBuilder sb = new StringBuilder(id.length() + 33);
sb.append(id).append('_');
appendHexString(sb, md5(file.getRid().toString()));
return new FileItem(sb.toString(), parent, file, isVideo);
}

return f;
} else {
return new FileItem(id, parent, file, isVideo);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,8 @@ public boolean onSingleTapConfirmed(MotionEvent e) {
if (delay == 0) return false;

MainActivityDelegate a = getActivity();
if (a == null) return false;

View title = ((VideoView) gestureSource).getTitle();
View fb = a.getFloatingButton();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ public boolean shouldOverrideUrlLoading(@NonNull WebView view, @NonNull WebResou
if (isYoutubeUri(request.getUrl())) {
try {
MainActivityDelegate a = MainActivityDelegate.get(view.getContext());
if (a == null) return false;
YoutubeFragment f = a.showFragment(me.aap.fermata.R.id.youtube_fragment);
f.loadUrl(request.getUrl().toString());
return true;
Expand Down

0 comments on commit ee57c75

Please sign in to comment.