aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java/CustomView
diff options
context:
space:
mode:
authorAlex Ning <chineseperson5@gmail.com>2019-08-18 08:03:58 +0000
committerAlex Ning <chineseperson5@gmail.com>2019-08-18 08:03:58 +0000
commitffd1d6e204fc7032a13216fe0c6dbe78205b2a98 (patch)
tree31d8f2d48a772968d37dc20df0b91359fbe50bf7 /app/src/main/java/CustomView
parent1984332fddeebe02db8e569f821391a45f97d904 (diff)
downloadinfinity-for-reddit-ffd1d6e204fc7032a13216fe0c6dbe78205b2a98.tar
infinity-for-reddit-ffd1d6e204fc7032a13216fe0c6dbe78205b2a98.tar.gz
infinity-for-reddit-ffd1d6e204fc7032a13216fe0c6dbe78205b2a98.tar.bz2
infinity-for-reddit-ffd1d6e204fc7032a13216fe0c6dbe78205b2a98.tar.lz
infinity-for-reddit-ffd1d6e204fc7032a13216fe0c6dbe78205b2a98.tar.xz
infinity-for-reddit-ffd1d6e204fc7032a13216fe0c6dbe78205b2a98.tar.zst
infinity-for-reddit-ffd1d6e204fc7032a13216fe0c6dbe78205b2a98.zip
View messages in ViewMessageActivity. Use LinkResolverActivity to handle link clicking in CustomMarkwonView. Fixed cannot load user profile image after the post is deleted.
Diffstat (limited to 'app/src/main/java/CustomView')
-rw-r--r--app/src/main/java/CustomView/CustomMarkwonView.java33
1 files changed, 7 insertions, 26 deletions
diff --git a/app/src/main/java/CustomView/CustomMarkwonView.java b/app/src/main/java/CustomView/CustomMarkwonView.java
index d5828f13..940b6b76 100644
--- a/app/src/main/java/CustomView/CustomMarkwonView.java
+++ b/app/src/main/java/CustomView/CustomMarkwonView.java
@@ -6,11 +6,8 @@ import android.net.Uri;
import android.util.AttributeSet;
import androidx.annotation.Nullable;
-import androidx.browser.customtabs.CustomTabsIntent;
-import ml.docilealligator.infinityforreddit.R;
-import ml.docilealligator.infinityforreddit.ViewSubredditDetailActivity;
-import ml.docilealligator.infinityforreddit.ViewUserDetailActivity;
+import ml.docilealligator.infinityforreddit.LinkResolverActivity;
import ru.noties.markwon.SpannableConfiguration;
import ru.noties.markwon.view.MarkwonView;
@@ -26,30 +23,14 @@ public class CustomMarkwonView extends MarkwonView {
public void setMarkdown(@Nullable String markdown, Context context) {
SpannableConfiguration configuration = SpannableConfiguration.builder(context).linkResolver((view, link) -> {
- if(link.startsWith("/u/") || link.startsWith("u/")) {
- Intent intent = new Intent(context, ViewUserDetailActivity.class);
- intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, link.substring(3));
- context.startActivity(intent);
- } else if(link.startsWith("/r/") || link.startsWith("r/")) {
- Intent intent = new Intent(context, ViewSubredditDetailActivity.class);
- intent.putExtra(ViewSubredditDetailActivity.EXTRA_SUBREDDIT_NAME_KEY, link.substring(3));
- context.startActivity(intent);
+ Intent intent = new Intent(context, LinkResolverActivity.class);
+ Uri uri = Uri.parse(link);
+ if(uri.getScheme() == null && uri.getHost() == null) {
+ intent.setData(LinkResolverActivity.getRedditUriByPath(link));
} else {
- CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder();
- // add share action to menu list
- builder.addDefaultShareMenuItem();
- builder.setToolbarColor(context.getResources().getColor(R.color.colorPrimary));
- CustomTabsIntent customTabsIntent = builder.build();
- Uri uri = Uri.parse(link);
- if(uri.getHost() != null && uri.getHost().contains("reddit.com")) {
- customTabsIntent.intent.setPackage(context.getPackageName());
- }
- String uriString = uri.toString();
- if(!uriString.startsWith("http://") && (!uriString.startsWith("https://"))) {
- uriString = "http://" + uriString;
- }
- customTabsIntent.launchUrl(context, Uri.parse(uriString));
+ intent.setData(uri);
}
+ context.startActivity(intent);
}).build();
super.setMarkdown(configuration, markdown);