Simplification

pull/172/head
M66B 6 years ago
parent 1aa488cad5
commit 45f46cf852

@ -1569,22 +1569,11 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
@Override @Override
public boolean onOpenLink(String url) { public boolean onOpenLink(String url) {
Uri uri = Uri.parse(url);
if ("cid".equals(uri.getScheme()) || "data".equals(uri.getScheme()))
return false;
if (parentFragment == null) if (parentFragment == null)
return false; return false;
Bundle args = new Bundle(); Uri uri = Uri.parse(url);
args.putParcelable("uri", uri); return AdapterMessage.ViewHolder.this.onOpenLink(uri, null);
args.putString("title", null);
FragmentDialogLink fragment = new FragmentDialogLink();
fragment.setArguments(args);
fragment.show(parentFragment.getParentFragmentManager(), "open:link");
return true;
} }
}); });
webView.setOnTouchListener(ViewHolder.this); webView.setOnTouchListener(ViewHolder.this);
@ -3340,12 +3329,11 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
if (image.length > 0 && image[0].getSource() != null) { if (image.length > 0 && image[0].getSource() != null) {
ImageHelper.AnnotatedSource a = new ImageHelper.AnnotatedSource(image[0].getSource()); ImageHelper.AnnotatedSource a = new ImageHelper.AnnotatedSource(image[0].getSource());
Uri uri = Uri.parse(a.getSource()); Uri uri = Uri.parse(a.getSource());
if ("http".equals(uri.getScheme()) || "https".equals(uri.getScheme())) { if ("http".equals(uri.getScheme()) || "https".equals(uri.getScheme()))
onOpenLink(uri, null); if (onOpenLink(uri, null))
return true; return true;
} }
} }
}
URLSpan[] link = buffer.getSpans(off, off, URLSpan.class); URLSpan[] link = buffer.getSpans(off, off, URLSpan.class);
if (link.length > 0) { if (link.length > 0) {
@ -3361,7 +3349,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
if (url.equals(title)) if (url.equals(title))
title = null; title = null;
onOpenLink(uri, title); if (onOpenLink(uri, title))
return true; return true;
} }
@ -3385,8 +3373,8 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
} }
} }
private void onOpenLink(final Uri uri, String title) { private boolean onOpenLink(final Uri uri, String title) {
Log.i("Opening uri=" + uri); Log.i("Opening uri=" + uri + " title=" + title);
if (BuildConfig.APPLICATION_ID.equals(uri.getHost()) && "/activate/".equals(uri.getPath())) { if (BuildConfig.APPLICATION_ID.equals(uri.getHost()) && "/activate/".equals(uri.getPath())) {
try { try {
@ -3398,8 +3386,8 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
Log.unexpectedError(parentFragment.getParentFragmentManager(), ex); Log.unexpectedError(parentFragment.getParentFragmentManager(), ex);
} }
} else { } else {
if ("cid".equals(uri.getScheme())) if ("cid".equals(uri.getScheme()) || "data".equals(uri.getScheme()))
return; return false;
Bundle args = new Bundle(); Bundle args = new Bundle();
args.putParcelable("uri", uri); args.putParcelable("uri", uri);
@ -3409,6 +3397,8 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
fragment.setArguments(args); fragment.setArguments(args);
fragment.show(parentFragment.getParentFragmentManager(), "open:link"); fragment.show(parentFragment.getParentFragmentManager(), "open:link");
} }
return true;
} }
private void onOpenImage(long id, String source) { private void onOpenImage(long id, String source) {

Loading…
Cancel
Save