Ammar Githam
4 years ago
13 changed files with 250 additions and 73 deletions
-
47app/src/main/java/awais/instagrabber/adapters/viewholder/directmessages/DirectMessageMediaShareViewHolder.java
-
25app/src/main/java/awais/instagrabber/adapters/viewholder/directmessages/DirectMessageMediaViewHolder.java
-
23app/src/main/java/awais/instagrabber/adapters/viewholder/directmessages/DirectMessageRavenMediaViewHolder.java
-
19app/src/main/java/awais/instagrabber/adapters/viewholder/directmessages/DirectMessageReelShareViewHolder.java
-
19app/src/main/java/awais/instagrabber/adapters/viewholder/directmessages/DirectMessageStoryShareViewHolder.java
-
3app/src/main/java/awais/instagrabber/asyncs/DiscoverFetcher.java
-
45app/src/main/java/awais/instagrabber/models/direct_messages/DirectItemModel.java
-
12app/src/main/java/awais/instagrabber/utils/NumberUtils.java
-
73app/src/main/java/awais/instagrabber/utils/ResponseBodyUtils.java
-
4app/src/main/res/layout/fragment_direct_messages_thread.xml
-
5app/src/main/res/layout/layout_dm_animated_media.xml
-
4app/src/main/res/layout/layout_dm_media.xml
-
2app/src/main/res/navigation/direct_messages_nav_graph.xml
@ -1,32 +1,53 @@ |
|||
package awais.instagrabber.adapters.viewholder.directmessages; |
|||
|
|||
import android.view.View; |
|||
import android.view.ViewGroup; |
|||
|
|||
import androidx.annotation.NonNull; |
|||
import androidx.core.util.Pair; |
|||
|
|||
import awais.instagrabber.R; |
|||
import awais.instagrabber.databinding.LayoutDmBaseBinding; |
|||
import awais.instagrabber.databinding.LayoutDmMediaBinding; |
|||
import awais.instagrabber.models.direct_messages.DirectItemModel; |
|||
import awais.instagrabber.models.enums.MediaItemType; |
|||
import awais.instagrabber.utils.NumberUtils; |
|||
import awais.instagrabber.utils.Utils; |
|||
|
|||
public class DirectMessageMediaViewHolder extends DirectMessageItemViewHolder { |
|||
|
|||
private final LayoutDmMediaBinding binding; |
|||
private final int maxHeight; |
|||
private final int maxWidth; |
|||
|
|||
public DirectMessageMediaViewHolder(@NonNull final LayoutDmBaseBinding baseBinding, |
|||
@NonNull final LayoutDmMediaBinding binding, |
|||
final View.OnClickListener onClickListener) { |
|||
super(baseBinding, onClickListener); |
|||
this.binding = binding; |
|||
maxHeight = itemView.getResources().getDimensionPixelSize(R.dimen.dm_media_img_max_height); |
|||
maxWidth = (int) (Utils.displayMetrics.widthPixels * 0.8); |
|||
setItemView(binding.getRoot()); |
|||
} |
|||
|
|||
@Override |
|||
public void bindItem(final DirectItemModel directItemModel) { |
|||
final DirectItemModel.DirectItemMediaModel mediaModel = directItemModel.getMediaModel(); |
|||
final Pair<Integer, Integer> widthHeight = NumberUtils.calculateWidthHeight( |
|||
mediaModel.getHeight(), |
|||
mediaModel.getWidth(), |
|||
maxHeight, |
|||
maxWidth |
|||
); |
|||
final ViewGroup.LayoutParams layoutParams = binding.ivMediaPreview.getLayoutParams(); |
|||
layoutParams.width = widthHeight.first != null ? widthHeight.first : 0; |
|||
layoutParams.height = widthHeight.second != null ? widthHeight.second : 0; |
|||
binding.ivMediaPreview.requestLayout(); |
|||
binding.ivMediaPreview.requestLayout(); |
|||
binding.ivMediaPreview.setImageURI(mediaModel.getThumbUrl()); |
|||
final MediaItemType modelMediaType = mediaModel.getMediaType(); |
|||
binding.typeIcon.setVisibility(modelMediaType == MediaItemType.MEDIA_TYPE_VIDEO |
|||
|| modelMediaType == MediaItemType.MEDIA_TYPE_SLIDER ? View.VISIBLE : View.GONE); |
|||
binding.typeIcon.setVisibility(modelMediaType == MediaItemType.MEDIA_TYPE_VIDEO || modelMediaType == MediaItemType.MEDIA_TYPE_SLIDER |
|||
? View.VISIBLE |
|||
: View.GONE); |
|||
} |
|||
} |
@ -1,6 +1,5 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<com.facebook.drawee.view.SimpleDraweeView xmlns:android="http://schemas.android.com/apk/res/android" |
|||
android:id="@+id/ivAnimatedMessage" |
|||
android:layout_width="wrap_content" |
|||
android:layout_height="wrap_content" |
|||
android:maxHeight="@dimen/dm_media_img_max_height" /> |
|||
android:layout_width="match_parent" |
|||
android:layout_height="@dimen/dm_media_img_max_height" /> |
Write
Preview
Loading…
Cancel
Save
Reference in new issue