Browse Source
fix #385, fix #417, fix #429, cleanup, prep for splash
renovate/org.robolectric-robolectric-4.x
fix #385, fix #417, fix #429, cleanup, prep for splash
renovate/org.robolectric-robolectric-4.x
Austin Huang
4 years ago
No known key found for this signature in database
GPG Key ID: 84C23AA04587A91F
10 changed files with 37 additions and 248 deletions
-
240app/src/main/java/awais/instagrabber/adapters/viewholder/PostViewerViewHolder.java
-
1app/src/main/java/awais/instagrabber/fragments/PostViewV2Fragment.java
-
8app/src/main/java/awais/instagrabber/fragments/StoryViewerFragment.java
-
7app/src/main/java/awais/instagrabber/fragments/main/FeedFragment.java
-
5app/src/main/res/drawable/launch.xml
-
5app/src/main/res/drawable/launch_dark.xml
-
5app/src/main/res/values-night/styles.xml
-
5app/src/main/res/values/color.xml
-
1app/src/main/res/values/strings.xml
-
8app/src/main/res/values/styles.xml
@ -1,240 +0,0 @@ |
|||
// package awais.instagrabber.adapters.viewholder; |
|||
// |
|||
// import android.content.res.ColorStateList; |
|||
// import android.content.res.Resources; |
|||
// import android.util.Log; |
|||
// import android.view.View; |
|||
// import android.widget.TextView; |
|||
// |
|||
// import androidx.annotation.NonNull; |
|||
// import androidx.core.content.ContextCompat; |
|||
// import androidx.core.view.ViewCompat; |
|||
// import androidx.recyclerview.widget.RecyclerView; |
|||
// import androidx.viewpager2.widget.ViewPager2; |
|||
// |
|||
// import com.google.android.exoplayer2.Player; |
|||
// import com.google.android.exoplayer2.SimpleExoPlayer; |
|||
// import com.google.android.exoplayer2.ui.PlayerView; |
|||
// |
|||
// import java.util.ArrayList; |
|||
// import java.util.List; |
|||
// |
|||
// import awais.instagrabber.R; |
|||
// import awais.instagrabber.adapters.PostViewAdapter.OnPostCaptionLongClickListener; |
|||
// import awais.instagrabber.adapters.PostViewAdapter.OnPostViewChildViewClickListener; |
|||
// import awais.instagrabber.adapters.PostViewerChildAdapter; |
|||
// import awais.instagrabber.databinding.ItemFullPostViewBinding; |
|||
// import awais.instagrabber.interfaces.MentionClickListener; |
|||
// import awais.instagrabber.models.PostChild; |
|||
// import awais.instagrabber.models.ProfileModel; |
|||
// import awais.instagrabber.models.ViewerPostModel; |
|||
// import awais.instagrabber.models.ViewerPostModelWrapper; |
|||
// import awais.instagrabber.models.enums.MediaItemType; |
|||
// import awais.instagrabber.utils.TextUtils; |
|||
// import awais.instagrabber.utils.Utils; |
|||
// |
|||
// public class PostViewerViewHolder extends RecyclerView.ViewHolder { |
|||
// private static final String TAG = "PostViewerViewHolder"; |
|||
// |
|||
// private final ItemFullPostViewBinding binding; |
|||
// private int currentChildPosition; |
|||
// |
|||
// public PostViewerViewHolder(@NonNull final ItemFullPostViewBinding binding) { |
|||
// super(binding.getRoot()); |
|||
// this.binding = binding; |
|||
// binding.topPanel.viewStoryPost.setVisibility(View.GONE); |
|||
// } |
|||
// |
|||
// public void bind(final ViewerPostModelWrapper wrapper, |
|||
// final int position, |
|||
// final OnPostViewChildViewClickListener clickListener, |
|||
// final OnPostCaptionLongClickListener longClickListener, |
|||
// final MentionClickListener mentionClickListener) { |
|||
// if (wrapper == null) return; |
|||
// final List<PostChild> items = wrapper.getViewerPostModels(); |
|||
// if (items == null || items.size() == 0) return; |
|||
// if (items.get(0) == null) return; |
|||
// final PostViewerChildAdapter adapter = new PostViewerChildAdapter(); |
|||
// binding.mediaViewPager.setAdapter(adapter); |
|||
// final PostChild firstPost = items.get(0); |
|||
// setPostInfo(firstPost, mentionClickListener); |
|||
// setMediaItems(items, adapter); |
|||
// setupListeners(wrapper, |
|||
// position, |
|||
// clickListener, |
|||
// longClickListener, |
|||
// mentionClickListener, |
|||
// firstPost.getLocation()); |
|||
// } |
|||
// |
|||
// private void setPostInfo(final PostChild firstPost, |
|||
// final MentionClickListener mentionClickListener) { |
|||
// final ProfileModel profileModel = firstPost.getProfileModel(); |
|||
// if (profileModel == null) return; |
|||
// binding.topPanel.title.setText(profileModel.getUsername()); |
|||
// final String locationName = firstPost.getLocationName(); |
|||
// if (!TextUtils.isEmpty(locationName)) { |
|||
// binding.topPanel.location.setVisibility(View.VISIBLE); |
|||
// binding.topPanel.location.setText(locationName); |
|||
// } else binding.topPanel.location.setVisibility(View.GONE); |
|||
// binding.topPanel.ivProfilePic.setImageURI(profileModel.getSdProfilePic()); |
|||
// binding.bottomPanel.commentsCount.setText(String.valueOf(firstPost.getCommentsCount())); |
|||
// final CharSequence postCaption = firstPost.getPostCaption(); |
|||
// if (TextUtils.hasMentions(postCaption)) { |
|||
// binding.bottomPanel.viewerCaption.setMentionClickListener(mentionClickListener); |
|||
// binding.bottomPanel.viewerCaption |
|||
// .setText(TextUtils.getMentionText(postCaption), TextView.BufferType.SPANNABLE); |
|||
// } else { |
|||
// binding.bottomPanel.viewerCaption.setMentionClickListener(null); |
|||
// binding.bottomPanel.viewerCaption.setText(postCaption); |
|||
// } |
|||
// binding.bottomPanel.tvPostDate.setText(firstPost.getPostDate()); |
|||
// setupLikes(firstPost); |
|||
// setupSave(firstPost); |
|||
// } |
|||
// |
|||
// private void setupLikes(final ViewerPostModel firstPost) { |
|||
// final boolean liked = firstPost.getLike(); |
|||
// final long likeCount = firstPost.getLikes(); |
|||
// final Resources resources = itemView.getContext().getResources(); |
|||
// if (liked) { |
|||
// final String unlikeString = resources.getString(R.string.unlike, String.valueOf(likeCount)); |
|||
// binding.btnLike.setText(unlikeString); |
|||
// ViewCompat.setBackgroundTintList(binding.btnLike, |
|||
// ColorStateList.valueOf(ContextCompat.getColor(itemView.getContext(), R.color.btn_pink_background))); |
|||
// } else { |
|||
// final String likeString = resources.getString(R.string.like, String.valueOf(likeCount)); |
|||
// binding.btnLike.setText(likeString); |
|||
// ViewCompat.setBackgroundTintList(binding.btnLike, |
|||
// ColorStateList.valueOf(ContextCompat.getColor(itemView.getContext(), R.color.btn_lightpink_background))); |
|||
// } |
|||
// } |
|||
// |
|||
// private void setupSave(final ViewerPostModel firstPost) { |
|||
// final boolean saved = firstPost.isSaved(); |
|||
// if (saved) { |
|||
// binding.btnBookmark.setText(R.string.unbookmark); |
|||
// ViewCompat.setBackgroundTintList(binding.btnBookmark, |
|||
// ColorStateList.valueOf(ContextCompat.getColor(itemView.getContext(), R.color.btn_orange_background))); |
|||
// } else { |
|||
// binding.btnBookmark.setText(R.string.bookmark); |
|||
// ViewCompat.setBackgroundTintList( |
|||
// binding.btnBookmark, |
|||
// ColorStateList.valueOf(ContextCompat.getColor(itemView.getContext(), R.color.btn_lightorange_background))); |
|||
// } |
|||
// } |
|||
// |
|||
// private void setupListeners(final ViewerPostModelWrapper wrapper, |
|||
// final int position, |
|||
// final OnPostViewChildViewClickListener clickListener, |
|||
// final OnPostCaptionLongClickListener longClickListener, |
|||
// final MentionClickListener mentionClickListener, |
|||
// final String location) { |
|||
// final View.OnClickListener onClickListener = v -> clickListener |
|||
// .onClick(v, wrapper, position, currentChildPosition); |
|||
// binding.bottomPanel.btnComments.setOnClickListener(onClickListener); |
|||
// binding.topPanel.title.setOnClickListener(onClickListener); |
|||
// binding.topPanel.ivProfilePic.setOnClickListener(onClickListener); |
|||
// binding.bottomPanel.btnDownload.setOnClickListener(onClickListener); |
|||
// binding.bottomPanel.viewerCaption.setOnClickListener(onClickListener); |
|||
// binding.btnLike.setOnClickListener(onClickListener); |
|||
// binding.btnBookmark.setOnClickListener(onClickListener); |
|||
// binding.bottomPanel.viewerCaption.setOnLongClickListener(v -> { |
|||
// longClickListener.onLongClick(binding.bottomPanel.viewerCaption.getText().toString()); |
|||
// return true; |
|||
// }); |
|||
// if (!TextUtils.isEmpty(location)) { |
|||
// binding.topPanel.location.setOnClickListener(v -> mentionClickListener |
|||
// .onClick(binding.topPanel.location, location, false, true)); |
|||
// } |
|||
// } |
|||
// |
|||
// private void setMediaItems(final List<ViewerPostModel> items, |
|||
// final PostViewerChildAdapter adapter) { |
|||
// final List<ViewerPostModel> filteredList = new ArrayList<>(); |
|||
// for (final ViewerPostModel model : items) { |
|||
// final MediaItemType itemType = model.getItemType(); |
|||
// if (itemType == MediaItemType.MEDIA_TYPE_VIDEO || itemType == MediaItemType.MEDIA_TYPE_IMAGE) { |
|||
// filteredList.add(model); |
|||
// } |
|||
// } |
|||
// binding.mediaCounter.setVisibility(filteredList.size() > 1 ? View.VISIBLE : View.GONE); |
|||
// final String counter = "1/" + filteredList.size(); |
|||
// binding.mediaCounter.setText(counter); |
|||
// adapter.submitList(filteredList); |
|||
// binding.mediaViewPager.registerOnPageChangeCallback(new ViewPager2.OnPageChangeCallback() { |
|||
// @Override |
|||
// public void onPageSelected(final int position) { |
|||
// if (filteredList.size() <= 0 || position >= filteredList.size()) return; |
|||
// currentChildPosition = position; |
|||
// final String counter = (position + 1) + "/" + filteredList.size(); |
|||
// binding.mediaCounter.setText(counter); |
|||
// final ViewerPostModel viewerPostModel = filteredList.get(position); |
|||
// if (viewerPostModel.getItemType() == MediaItemType.MEDIA_TYPE_VIDEO) { |
|||
// setVideoDetails(viewerPostModel); |
|||
// setVolumeListener(position); |
|||
// return; |
|||
// } |
|||
// setImageDetails(); |
|||
// } |
|||
// }); |
|||
// } |
|||
// |
|||
// private void setVolumeListener(final int position) { |
|||
// binding.bottomPanel.btnMute.setOnClickListener(v -> { |
|||
// try { |
|||
// final RecyclerView.ViewHolder viewHolder = ((RecyclerView) binding.mediaViewPager |
|||
// .getChildAt(0)).findViewHolderForAdapterPosition(position); |
|||
// if (viewHolder != null) { |
|||
// final View itemView = viewHolder.itemView; |
|||
// if (itemView instanceof PlayerView) { |
|||
// final SimpleExoPlayer player = (SimpleExoPlayer) ((PlayerView) itemView) |
|||
// .getPlayer(); |
|||
// if (player == null) return; |
|||
// final float vol = player.getVolume() == 0f ? 1f : 0f; |
|||
// player.setVolume(vol); |
|||
// binding.bottomPanel.btnMute.setImageResource(vol == 0f ? R.drawable.ic_volume_up_24 |
|||
// : R.drawable.ic_volume_off_24); |
|||
// Utils.sessionVolumeFull = vol == 1f; |
|||
// } |
|||
// } |
|||
// } catch (Exception e) { |
|||
// Log.e(TAG, "Error", e); |
|||
// } |
|||
// }); |
|||
// } |
|||
// |
|||
// private void setImageDetails() { |
|||
// binding.bottomPanel.btnMute.setVisibility(View.GONE); |
|||
// binding.bottomPanel.videoViewsContainer.setVisibility(View.GONE); |
|||
// } |
|||
// |
|||
// private void setVideoDetails(final ViewerPostModel viewerPostModel) { |
|||
// binding.bottomPanel.btnMute.setVisibility(View.VISIBLE); |
|||
// final long videoViews = viewerPostModel.getVideoViews(); |
|||
// if (videoViews < 0) { |
|||
// binding.bottomPanel.videoViewsContainer.setVisibility(View.GONE); |
|||
// return; |
|||
// } |
|||
// binding.bottomPanel.tvVideoViews.setText(String.valueOf(videoViews)); |
|||
// binding.bottomPanel.videoViewsContainer.setVisibility(View.VISIBLE); |
|||
// } |
|||
// |
|||
// public void stopPlayingVideo() { |
|||
// try { |
|||
// final RecyclerView.ViewHolder viewHolder = ((RecyclerView) binding.mediaViewPager |
|||
// .getChildAt(0)).findViewHolderForAdapterPosition(currentChildPosition); |
|||
// if (viewHolder != null) { |
|||
// final View itemView = viewHolder.itemView; |
|||
// if (itemView instanceof PlayerView) { |
|||
// final Player player = ((PlayerView) itemView).getPlayer(); |
|||
// if (player != null) { |
|||
// player.setPlayWhenReady(false); |
|||
// } |
|||
// } |
|||
// } |
|||
// } catch (Exception e) { |
|||
// Log.e(TAG, "Error", e); |
|||
// } |
|||
// } |
|||
// } |
@ -0,0 +1,5 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" |
|||
android:opacity="opaque"> |
|||
<item android:drawable="@color/white"/> |
|||
</layer-list> |
@ -0,0 +1,5 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" |
|||
android:opacity="opaque"> |
|||
<item android:drawable="@color/black"/> |
|||
</layer-list> |
Write
Preview
Loading…
Cancel
Save
Reference in new issue