Browse Source
Merge branch 'master' into bottombar_redesign
renovate/org.robolectric-robolectric-4.x
Merge branch 'master' into bottombar_redesign
renovate/org.robolectric-robolectric-4.x
Austin Huang
4 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
33 changed files with 513 additions and 138 deletions
-
2app/build.gradle
-
28app/src/main/java/awais/instagrabber/activities/MainActivity.java
-
15app/src/main/java/awais/instagrabber/adapters/DirectItemsAdapter.java
-
16app/src/main/java/awais/instagrabber/adapters/viewholder/directmessages/DirectItemAnimatedMediaViewHolder.java
-
6app/src/main/java/awais/instagrabber/adapters/viewholder/directmessages/DirectItemDefaultViewHolder.java
-
19app/src/main/java/awais/instagrabber/adapters/viewholder/directmessages/DirectItemLinkViewHolder.java
-
19app/src/main/java/awais/instagrabber/adapters/viewholder/directmessages/DirectItemMediaShareViewHolder.java
-
25app/src/main/java/awais/instagrabber/adapters/viewholder/directmessages/DirectItemReelShareViewHolder.java
-
19app/src/main/java/awais/instagrabber/adapters/viewholder/directmessages/DirectItemTextViewHolder.java
-
13app/src/main/java/awais/instagrabber/adapters/viewholder/directmessages/DirectItemViewHolder.java
-
9app/src/main/java/awais/instagrabber/adapters/viewholder/directmessages/DirectItemVoiceMediaViewHolder.java
-
69app/src/main/java/awais/instagrabber/adapters/viewholder/directmessages/DirectItemXmaViewHolder.java
-
20app/src/main/java/awais/instagrabber/customviews/DirectItemContextMenu.java
-
24app/src/main/java/awais/instagrabber/customviews/PostsRecyclerView.java
-
36app/src/main/java/awais/instagrabber/fragments/directmessages/DirectMessageInboxFragment.java
-
12app/src/main/java/awais/instagrabber/fragments/directmessages/DirectMessageSettingsFragment.java
-
67app/src/main/java/awais/instagrabber/fragments/directmessages/DirectMessageThreadFragment.java
-
7app/src/main/java/awais/instagrabber/fragments/directmessages/DirectPendingInboxFragment.java
-
53app/src/main/java/awais/instagrabber/fragments/main/ProfileFragment.java
-
2app/src/main/java/awais/instagrabber/fragments/settings/NotificationsPreferencesFragment.java
-
6app/src/main/java/awais/instagrabber/models/enums/DirectItemType.java
-
10app/src/main/java/awais/instagrabber/repositories/responses/directmessages/DirectItem.java
-
104app/src/main/java/awais/instagrabber/repositories/responses/directmessages/DirectItemXma.java
-
18app/src/main/java/awais/instagrabber/utils/DMUtils.java
-
4app/src/main/java/awais/instagrabber/utils/DirectItemFactory.java
-
20app/src/main/java/awais/instagrabber/utils/ResponseBodyUtils.java
-
15app/src/main/java/awais/instagrabber/viewmodels/AppStateViewModel.java
-
2app/src/main/java/awais/instagrabber/viewmodels/DirectThreadViewModel.java
-
4app/src/main/res/values/color.xml
-
1app/src/main/res/values/ids.xml
-
2app/src/main/res/values/strings.xml
-
2app/src/main/res/values/themes.xml
-
2settings.gradle
@ -0,0 +1,69 @@ |
|||
package awais.instagrabber.adapters.viewholder.directmessages; |
|||
|
|||
import android.view.View; |
|||
import android.view.ViewGroup; |
|||
|
|||
import androidx.annotation.NonNull; |
|||
import androidx.core.util.Pair; |
|||
import androidx.recyclerview.widget.ItemTouchHelper; |
|||
|
|||
import com.facebook.drawee.backends.pipeline.Fresco; |
|||
|
|||
import awais.instagrabber.adapters.DirectItemsAdapter.DirectItemCallback; |
|||
import awais.instagrabber.databinding.LayoutDmAnimatedMediaBinding; |
|||
import awais.instagrabber.databinding.LayoutDmBaseBinding; |
|||
import awais.instagrabber.repositories.responses.User; |
|||
import awais.instagrabber.repositories.responses.directmessages.DirectItem; |
|||
import awais.instagrabber.repositories.responses.directmessages.DirectItemXma; |
|||
import awais.instagrabber.repositories.responses.directmessages.DirectThread; |
|||
import awais.instagrabber.utils.NumberUtils; |
|||
|
|||
public class DirectItemXmaViewHolder extends DirectItemViewHolder { |
|||
|
|||
private final LayoutDmAnimatedMediaBinding binding; |
|||
|
|||
public DirectItemXmaViewHolder(@NonNull final LayoutDmBaseBinding baseBinding, |
|||
@NonNull final LayoutDmAnimatedMediaBinding binding, |
|||
final User currentUser, |
|||
final DirectThread thread, |
|||
final DirectItemCallback callback) { |
|||
super(baseBinding, currentUser, thread, callback); |
|||
this.binding = binding; |
|||
setItemView(binding.getRoot()); |
|||
} |
|||
|
|||
@Override |
|||
public void bindItem(final DirectItem item, final MessageDirection messageDirection) { |
|||
final DirectItemXma xma = item.getXma(); |
|||
final DirectItemXma.XmaUrlInfo playableUrlInfo = xma.getPlayableUrlInfo(); |
|||
final DirectItemXma.XmaUrlInfo previewUrlInfo = xma.getPreviewUrlInfo(); |
|||
if (playableUrlInfo == null && previewUrlInfo == null) { |
|||
binding.ivAnimatedMessage.setController(null); |
|||
return; |
|||
} |
|||
final DirectItemXma.XmaUrlInfo urlInfo = playableUrlInfo != null ? playableUrlInfo : previewUrlInfo; |
|||
final String url = urlInfo.getUrl(); |
|||
final Pair<Integer, Integer> widthHeight = NumberUtils.calculateWidthHeight( |
|||
urlInfo.getHeight(), |
|||
urlInfo.getWidth(), |
|||
mediaImageMaxHeight, |
|||
mediaImageMaxWidth |
|||
); |
|||
binding.ivAnimatedMessage.setVisibility(View.VISIBLE); |
|||
final ViewGroup.LayoutParams layoutParams = binding.ivAnimatedMessage.getLayoutParams(); |
|||
final int width = widthHeight.first != null ? widthHeight.first : 0; |
|||
final int height = widthHeight.second != null ? widthHeight.second : 0; |
|||
layoutParams.width = width; |
|||
layoutParams.height = height; |
|||
binding.ivAnimatedMessage.requestLayout(); |
|||
binding.ivAnimatedMessage.setController(Fresco.newDraweeControllerBuilder() |
|||
.setUri(url) |
|||
.setAutoPlayAnimations(true) |
|||
.build()); |
|||
} |
|||
|
|||
@Override |
|||
public int getSwipeDirection() { |
|||
return ItemTouchHelper.ACTION_STATE_IDLE; |
|||
} |
|||
} |
@ -0,0 +1,104 @@ |
|||
package awais.instagrabber.repositories.responses.directmessages; |
|||
|
|||
import androidx.annotation.NonNull; |
|||
|
|||
import java.io.Serializable; |
|||
import java.util.Objects; |
|||
|
|||
public class DirectItemXma { |
|||
private final XmaUrlInfo previewUrlInfo; |
|||
private final XmaUrlInfo playableUrlInfo; |
|||
|
|||
public DirectItemXma(final XmaUrlInfo previewUrlInfo, final XmaUrlInfo playableUrlInfo) { |
|||
this.previewUrlInfo = previewUrlInfo; |
|||
this.playableUrlInfo = playableUrlInfo; |
|||
} |
|||
|
|||
public XmaUrlInfo getPreviewUrlInfo() { |
|||
return previewUrlInfo; |
|||
} |
|||
|
|||
public XmaUrlInfo getPlayableUrlInfo() { |
|||
return playableUrlInfo; |
|||
} |
|||
|
|||
@Override |
|||
public boolean equals(final Object o) { |
|||
if (this == o) return true; |
|||
if (o == null || getClass() != o.getClass()) return false; |
|||
final DirectItemXma that = (DirectItemXma) o; |
|||
return Objects.equals(previewUrlInfo, that.previewUrlInfo) && |
|||
Objects.equals(playableUrlInfo, that.playableUrlInfo); |
|||
} |
|||
|
|||
@Override |
|||
public int hashCode() { |
|||
return Objects.hash(previewUrlInfo, playableUrlInfo); |
|||
} |
|||
|
|||
@NonNull |
|||
@Override |
|||
public String toString() { |
|||
return "DirectItemXma{" + |
|||
"previewUrlInfo=" + previewUrlInfo + |
|||
", playableUrlInfo=" + playableUrlInfo + |
|||
'}'; |
|||
} |
|||
|
|||
public static class XmaUrlInfo implements Serializable { |
|||
private final String url; |
|||
private final long urlExpirationTimestampUs; |
|||
private final int width; |
|||
private final int height; |
|||
|
|||
public XmaUrlInfo(final String url, final long urlExpirationTimestampUs, final int width, final int height) { |
|||
this.url = url; |
|||
this.urlExpirationTimestampUs = urlExpirationTimestampUs; |
|||
this.width = width; |
|||
this.height = height; |
|||
} |
|||
|
|||
public String getUrl() { |
|||
return url; |
|||
} |
|||
|
|||
public long getUrlExpirationTimestampUs() { |
|||
return urlExpirationTimestampUs; |
|||
} |
|||
|
|||
public int getWidth() { |
|||
return width; |
|||
} |
|||
|
|||
public int getHeight() { |
|||
return height; |
|||
} |
|||
|
|||
@Override |
|||
public boolean equals(final Object o) { |
|||
if (this == o) return true; |
|||
if (o == null || getClass() != o.getClass()) return false; |
|||
final XmaUrlInfo that = (XmaUrlInfo) o; |
|||
return urlExpirationTimestampUs == that.urlExpirationTimestampUs && |
|||
width == that.width && |
|||
height == that.height && |
|||
Objects.equals(url, that.url); |
|||
} |
|||
|
|||
@Override |
|||
public int hashCode() { |
|||
return Objects.hash(url, urlExpirationTimestampUs, width, height); |
|||
} |
|||
|
|||
@NonNull |
|||
@Override |
|||
public String toString() { |
|||
return "XmaUrlInfo{" + |
|||
"url='" + url + '\'' + |
|||
", urlExpirationTimestampUs=" + urlExpirationTimestampUs + |
|||
", width=" + width + |
|||
", height=" + height + |
|||
'}'; |
|||
} |
|||
} |
|||
} |
@ -1,2 +1,2 @@ |
|||
include ':app' |
|||
rootProject.name = "InstaGrabber" |
|||
rootProject.name = "Barinsta" |
Write
Preview
Loading…
Cancel
Save
Reference in new issue