From 7ddf356de90abfe5bf1e40a8af3e397cf06e0808 Mon Sep 17 00:00:00 2001 From: Austin Huang Date: Tue, 11 Aug 2020 14:14:30 -0400 Subject: [PATCH] layout finalization --- app/src/main/java/awais/instagrabber/MainHelper.java | 2 +- .../java/awais/instagrabber/activities/Main.java | 4 ++-- .../awais/instagrabber/adapters/FeedAdapter.java | 12 +++++++++--- .../adapters/viewholder/FeedItemViewHolder.java | 4 ++-- app/src/main/res/layout/layout_profile_view.xml | 4 ---- 5 files changed, 14 insertions(+), 12 deletions(-) diff --git a/app/src/main/java/awais/instagrabber/MainHelper.java b/app/src/main/java/awais/instagrabber/MainHelper.java index ab82ba7d..7edb9940 100755 --- a/app/src/main/java/awais/instagrabber/MainHelper.java +++ b/app/src/main/java/awais/instagrabber/MainHelper.java @@ -280,7 +280,7 @@ public final class MainHelper implements SwipeRefreshLayout.OnRefreshListener { isLoggedIn = !Utils.isEmpty(cookie); if (!isLoggedIn) { main.mainBinding.drawerLayout.removeView(main.mainBinding.feedView.feedLayout); - main.mainBinding.drawerLayout.removeView(main.mainBinding.discoverSwipeRefreshLayout); + main.mainBinding.drawerLayout.removeView(main.mainBinding.discoverLayout); iconFeed.setAlpha(0.4f); iconDiscover.setAlpha(0.4f); } else { diff --git a/app/src/main/java/awais/instagrabber/activities/Main.java b/app/src/main/java/awais/instagrabber/activities/Main.java index ea4bc9e7..73140cca 100755 --- a/app/src/main/java/awais/instagrabber/activities/Main.java +++ b/app/src/main/java/awais/instagrabber/activities/Main.java @@ -81,7 +81,7 @@ public final class Main extends BaseLanguageActivity { (!mainHelper.isLoggedIn && Utils.settingsHelper.getBoolean(Constants.STORIESIG)), true, result -> { if (result != null && result.length > 0) startActivity(new Intent(Main.this, StoryViewer.class) - .putExtra(Constants.EXTRAS_USERNAME, userQuery) + .putExtra(Constants.EXTRAS_USERNAME, userQuery.replace("@", "")) .putExtra(Constants.EXTRAS_HIGHLIGHT, highlightModel.getTitle()) .putExtra(Constants.EXTRAS_STORIES, result) ); @@ -199,7 +199,7 @@ public final class Main extends BaseLanguageActivity { ((hashtagModel != null) ? Constants.EXTRAS_HASHTAG : (locationModel != null ? Constants.EXTRAS_LOCATION : Constants.EXTRAS_PROFILE)), ((hashtagModel != null) ? hashtagModel : (locationModel != null ? locationModel : profileModel))); } - else intent = new Intent(this, StoryViewer.class).putExtra(Constants.EXTRAS_USERNAME, userQuery) + else intent = new Intent(this, StoryViewer.class).putExtra(Constants.EXTRAS_USERNAME, userQuery.replace("@", "")) .putExtra(Constants.EXTRAS_STORIES, storyModels) .putExtra(Constants.EXTRAS_HASHTAG, (hashtagModel != null)); startActivity(intent); diff --git a/app/src/main/java/awais/instagrabber/adapters/FeedAdapter.java b/app/src/main/java/awais/instagrabber/adapters/FeedAdapter.java index 008cdd5c..91a0da95 100755 --- a/app/src/main/java/awais/instagrabber/adapters/FeedAdapter.java +++ b/app/src/main/java/awais/instagrabber/adapters/FeedAdapter.java @@ -7,8 +7,10 @@ import android.content.DialogInterface; import android.content.Intent; import android.graphics.Typeface; import android.net.Uri; +import android.text.SpannableString; import android.text.SpannableStringBuilder; import android.text.Spanned; +import android.text.method.LinkMovementMethod; import android.text.style.StyleSpan; import android.util.Log; import android.view.LayoutInflater; @@ -198,7 +200,13 @@ public final class FeedAdapter extends RecyclerView.Adapter final ProfileModel profileModel = feedModel.getProfileModel(); if (profileModel != null) { glideRequestManager.load(profileModel.getSdProfilePic()).into(viewHolder.profilePic); - viewHolder.username.setText("@"+profileModel.getUsername()); + final int titleLen = profileModel.getUsername().length() + 1; + final SpannableString spannableString = new SpannableString("@"+profileModel.getUsername()); + spannableString.setSpan(new CommentMentionClickSpan(), 0, titleLen, 0); + viewHolder.username.setText(spannableString); + viewHolder.username.setMovementMethod(new LinkMovementMethod()); + viewHolder.username.setMentionClickListener((view, text, isHashtag) -> + mentionClickListener.onClick(null, profileModel.getUsername(), false)); } viewHolder.viewPost.setOnClickListener(clickListener); @@ -416,8 +424,6 @@ public final class FeedAdapter extends RecyclerView.Adapter @NonNull @Override public Object instantiateItem(@NonNull final ViewGroup container, final int position) { - if (BuildConfig.DEBUG) container.setBackgroundColor(0xFF_0a_c0_09); // todo remove - final Context context = container.getContext(); final ViewerPostModel sliderItem = sliderItems[position]; diff --git a/app/src/main/java/awais/instagrabber/adapters/viewholder/FeedItemViewHolder.java b/app/src/main/java/awais/instagrabber/adapters/viewholder/FeedItemViewHolder.java index 8f1e2d2e..b1ac0ffd 100755 --- a/app/src/main/java/awais/instagrabber/adapters/viewholder/FeedItemViewHolder.java +++ b/app/src/main/java/awais/instagrabber/adapters/viewholder/FeedItemViewHolder.java @@ -16,8 +16,8 @@ import awais.instagrabber.customviews.RamboTextView; public final class FeedItemViewHolder extends RecyclerView.ViewHolder { public final ImageView profilePic, btnMute, btnDownload; - public final TextView username, commentsCount, videoViews, mediaCounter, tvPostDate, location; - public final RamboTextView viewerCaption; + public final TextView commentsCount, videoViews, mediaCounter, tvPostDate, location; + public final RamboTextView username, viewerCaption; public final View btnComments, videoViewsParent, viewPost; public final ViewPager mediaList; public final PhotoView imageView; diff --git a/app/src/main/res/layout/layout_profile_view.xml b/app/src/main/res/layout/layout_profile_view.xml index 9312eb2e..15554aef 100644 --- a/app/src/main/res/layout/layout_profile_view.xml +++ b/app/src/main/res/layout/layout_profile_view.xml @@ -434,10 +434,6 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:clipToPadding="false" - android:paddingStart="8dp" - android:paddingLeft="8dp" - android:paddingEnd="8dp" - android:paddingRight="8dp" tools:listitem="@layout/item_post" />