mirror of
https://github.com/KokaKiwi/BarInsta
synced 2024-11-22 06:37:30 +00:00
convert stuff to kotlin
This commit is contained in:
parent
49e348765b
commit
19d3434dbf
@ -171,7 +171,7 @@ public final class FeedAdapterV2 extends ListAdapter<Media, RecyclerView.ViewHol
|
||||
|
||||
@Override
|
||||
public int getItemViewType(final int position) {
|
||||
return getItem(position).getMediaType().getId();
|
||||
return getItem(position).getType().getId();
|
||||
}
|
||||
|
||||
public void setLayoutPreferences(@NonNull final PostsLayoutPreferences layoutPreferences) {
|
||||
|
@ -68,7 +68,7 @@ public final class SliderItemsAdapter extends ListAdapter<Media, SliderItemViewH
|
||||
@Override
|
||||
public int getItemViewType(final int position) {
|
||||
final Media media = getItem(position);
|
||||
return media.getMediaType().getId();
|
||||
return media.getType().getId();
|
||||
}
|
||||
|
||||
// @NonNull
|
||||
|
@ -71,7 +71,7 @@ public class FeedGridItemViewHolder extends RecyclerView.ViewHolder {
|
||||
setUserDetails(media, layoutPreferences);
|
||||
String thumbnailUrl = null;
|
||||
final int typeIconRes;
|
||||
final MediaItemType mediaType = media.getMediaType();
|
||||
final MediaItemType mediaType = media.getType();
|
||||
if (mediaType == null) return;
|
||||
switch (mediaType) {
|
||||
case MEDIA_TYPE_IMAGE:
|
||||
@ -118,7 +118,7 @@ public class FeedGridItemViewHolder extends RecyclerView.ViewHolder {
|
||||
return;
|
||||
}
|
||||
AppExecutors.INSTANCE.getMainThread().execute(() -> {
|
||||
switch (media.getMediaType()) {
|
||||
switch (media.getType()) {
|
||||
case MEDIA_TYPE_IMAGE:
|
||||
case MEDIA_TYPE_VIDEO:
|
||||
binding.downloaded.setVisibility(checkList.get(0) ? View.VISIBLE : View.GONE);
|
||||
|
@ -45,7 +45,7 @@ public class SearchItemViewHolder extends RecyclerView.ViewHolder {
|
||||
case HASHTAG:
|
||||
final Hashtag hashtag = searchItem.getHashtag();
|
||||
title = "#" + hashtag.getName();
|
||||
subtitle = hashtag.getSubtitle();
|
||||
subtitle = hashtag.getSearchResultSubtitle();
|
||||
picUrl = "res:/" + R.drawable.ic_hashtag;
|
||||
break;
|
||||
case LOCATION:
|
||||
|
@ -69,7 +69,7 @@ public class DirectItemMediaShareViewHolder extends DirectItemViewHolder {
|
||||
});
|
||||
final int index;
|
||||
final Media toDisplay;
|
||||
final MediaItemType mediaType = media.getMediaType();
|
||||
final MediaItemType mediaType = media.getType();
|
||||
switch (mediaType) {
|
||||
case MEDIA_TYPE_SLIDER:
|
||||
toDisplay = media.getCarouselMedia().stream()
|
||||
|
@ -48,7 +48,7 @@ public class DirectItemMediaViewHolder extends DirectItemViewHolder {
|
||||
.build());
|
||||
final Media media = directItemModel.getMedia();
|
||||
itemView.setOnClickListener(v -> openMedia(media, -1));
|
||||
final MediaItemType modelMediaType = media.getMediaType();
|
||||
final MediaItemType modelMediaType = media.getType();
|
||||
binding.typeIcon.setVisibility(modelMediaType == MediaItemType.MEDIA_TYPE_VIDEO || modelMediaType == MediaItemType.MEDIA_TYPE_SLIDER
|
||||
? View.VISIBLE
|
||||
: View.GONE);
|
||||
|
@ -117,7 +117,7 @@ public class DirectItemRavenMediaViewHolder extends DirectItemViewHolder {
|
||||
final Media media = visualMedia.getMedia();
|
||||
final RavenMediaViewMode viewMode = visualMedia.getViewMode();
|
||||
if (viewMode != RavenMediaViewMode.PERMANENT) {
|
||||
final MediaItemType mediaType = media.getMediaType();
|
||||
final MediaItemType mediaType = media.getType();
|
||||
final boolean expired = TextUtils.isEmpty(media.getId());
|
||||
final int info;
|
||||
switch (mediaType) {
|
||||
@ -166,7 +166,7 @@ public class DirectItemRavenMediaViewHolder extends DirectItemViewHolder {
|
||||
.setRoundingParams(roundingParams)
|
||||
.setActualImageScaleType(ScalingUtils.ScaleType.CENTER_CROP)
|
||||
.build());
|
||||
final MediaItemType modelMediaType = media.getMediaType();
|
||||
final MediaItemType modelMediaType = media.getType();
|
||||
binding.typeIcon.setVisibility(modelMediaType == MediaItemType.MEDIA_TYPE_VIDEO || modelMediaType == MediaItemType.MEDIA_TYPE_SLIDER
|
||||
? View.VISIBLE
|
||||
: View.GONE);
|
||||
|
@ -52,7 +52,7 @@ public class DirectItemReelShareViewHolder extends DirectItemViewHolder {
|
||||
if (media == null) return;
|
||||
final User user = media.getUser();
|
||||
if (user == null) return;
|
||||
final boolean expired = media.getMediaType() == null;
|
||||
final boolean expired = media.getType() == null;
|
||||
if (expired) {
|
||||
binding.preview.setVisibility(View.GONE);
|
||||
binding.typeIcon.setVisibility(View.GONE);
|
||||
@ -159,7 +159,7 @@ public class DirectItemReelShareViewHolder extends DirectItemViewHolder {
|
||||
}
|
||||
|
||||
private void setPreview(final Media media) {
|
||||
final MediaItemType mediaType = media.getMediaType();
|
||||
final MediaItemType mediaType = media.getType();
|
||||
if (mediaType == null) return;
|
||||
binding.typeIcon.setVisibility(mediaType == MediaItemType.MEDIA_TYPE_VIDEO || mediaType == MediaItemType.MEDIA_TYPE_SLIDER
|
||||
? View.VISIBLE : View.GONE);
|
||||
|
@ -66,7 +66,7 @@ public class DirectItemStoryShareViewHolder extends DirectItemViewHolder {
|
||||
}
|
||||
|
||||
private void setupPreview(final MessageDirection messageDirection, final Media storyShareMedia) {
|
||||
final MediaItemType mediaType = storyShareMedia.getMediaType();
|
||||
final MediaItemType mediaType = storyShareMedia.getType();
|
||||
binding.typeIcon.setVisibility(mediaType == MediaItemType.MEDIA_TYPE_VIDEO ? View.VISIBLE : View.GONE);
|
||||
final RoundingParams roundingParams = messageDirection == MessageDirection.INCOMING
|
||||
? RoundingParams.fromCornersRadii(dmRadiusSmall, dmRadius, dmRadius, dmRadius)
|
||||
|
@ -266,7 +266,7 @@ public abstract class DirectItemViewHolder extends RecyclerView.ViewHolder imple
|
||||
break;
|
||||
case MEDIA_SHARE:
|
||||
Media mediaShare = replied.getMediaShare();
|
||||
if (mediaShare.getMediaType() == MediaItemType.MEDIA_TYPE_SLIDER) {
|
||||
if (mediaShare.getType() == MediaItemType.MEDIA_TYPE_SLIDER) {
|
||||
mediaShare = mediaShare.getCarouselMedia().get(0);
|
||||
}
|
||||
url = ResponseBodyUtils.getThumbUrl(mediaShare);
|
||||
|
@ -46,7 +46,7 @@ public abstract class FeedItemViewHolder extends RecyclerView.ViewHolder {
|
||||
bottomBinding.tvPostDate.setText(media.getDate());
|
||||
setupComments(media);
|
||||
setupCaption(media);
|
||||
if (media.getMediaType() != MediaItemType.MEDIA_TYPE_SLIDER) {
|
||||
if (media.getType() != MediaItemType.MEDIA_TYPE_SLIDER) {
|
||||
bottomBinding.btnDownload.setOnClickListener(v -> feedItemCallback.onDownloadClick(media, -1));
|
||||
}
|
||||
bindItem(media);
|
||||
|
@ -33,7 +33,7 @@ public class DiscoverPostFetchService implements PostFetcher.PostFetchService {
|
||||
onFailure(new RuntimeException("result is null"));
|
||||
return;
|
||||
}
|
||||
moreAvailable = result.isMoreAvailable();
|
||||
moreAvailable = result.getMoreAvailable();
|
||||
topicalExploreRequest.setMaxId(result.getNextMaxId());
|
||||
final List<WrappedMedia> items = result.getItems();
|
||||
final List<Media> posts;
|
||||
|
@ -268,7 +268,7 @@ public class PostsRecyclerView extends RecyclerView {
|
||||
|
||||
private List<String> getDisplayUrl(final Media feedModel) {
|
||||
List<String> urls = Collections.emptyList();
|
||||
switch (feedModel.getMediaType()) {
|
||||
switch (feedModel.getType()) {
|
||||
case MEDIA_TYPE_IMAGE:
|
||||
case MEDIA_TYPE_VIDEO:
|
||||
urls = Collections.singletonList(ResponseBodyUtils.getImageUrl(feedModel));
|
||||
|
@ -522,7 +522,7 @@ public class HashTagFragment extends Fragment implements SwipeRefreshLayout.OnRe
|
||||
final SpannableStringBuilder span = new SpannableStringBuilder(getResources().getQuantityString(R.plurals.main_posts_count_inline,
|
||||
hashtagModel.getMediaCount() > 2000000000L
|
||||
? 2000000000
|
||||
: hashtagModel.getMediaCount().intValue(),
|
||||
: Long.valueOf(hashtagModel.getMediaCount()).intValue(),
|
||||
postCount));
|
||||
span.setSpan(new RelativeSizeSpan(1.2f), 0, postCount.length(), 0);
|
||||
span.setSpan(new StyleSpan(Typeface.BOLD), 0, postCount.length(), 0);
|
||||
|
@ -219,8 +219,8 @@ public class PostViewV2Fragment extends Fragment implements EditTextDialogFragme
|
||||
// wasPaused = true;
|
||||
if (settingsHelper.getBoolean(PreferenceKeys.PLAY_IN_BACKGROUND)) return;
|
||||
final Media media = viewModel.getMedia();
|
||||
if (media.getMediaType() == null) return;
|
||||
switch (media.getMediaType()) {
|
||||
if (media.getType() == null) return;
|
||||
switch (media.getType()) {
|
||||
case MEDIA_TYPE_VIDEO:
|
||||
if (videoPlayerViewHelper != null) {
|
||||
videoPlayerViewHelper.pause();
|
||||
@ -252,8 +252,8 @@ public class PostViewV2Fragment extends Fragment implements EditTextDialogFragme
|
||||
super.onDestroyView();
|
||||
showSystemUI();
|
||||
final Media media = viewModel.getMedia();
|
||||
if (media.getMediaType() == null) return;
|
||||
switch (media.getMediaType()) {
|
||||
if (media.getType() == null) return;
|
||||
switch (media.getType()) {
|
||||
case MEDIA_TYPE_VIDEO:
|
||||
if (videoPlayerViewHelper != null) {
|
||||
videoPlayerViewHelper.releasePlayer();
|
||||
@ -271,7 +271,7 @@ public class PostViewV2Fragment extends Fragment implements EditTextDialogFragme
|
||||
public void onSaveInstanceState(@NonNull final Bundle outState) {
|
||||
super.onSaveInstanceState(outState);
|
||||
final Media media = viewModel.getMedia();
|
||||
if (media.getMediaType() == MediaItemType.MEDIA_TYPE_SLIDER) {
|
||||
if (media.getType() == MediaItemType.MEDIA_TYPE_SLIDER) {
|
||||
outState.putInt(ARG_SLIDER_POSITION, sliderPosition);
|
||||
}
|
||||
}
|
||||
@ -293,7 +293,7 @@ public class PostViewV2Fragment extends Fragment implements EditTextDialogFragme
|
||||
return;
|
||||
}
|
||||
final Media media = (Media) feedModelSerializable;
|
||||
if (media.getMediaType() == MediaItemType.MEDIA_TYPE_SLIDER && sliderPosition == -1) {
|
||||
if (media.getType() == MediaItemType.MEDIA_TYPE_SLIDER && sliderPosition == -1) {
|
||||
sliderPosition = arguments.getInt(ARG_SLIDER_POSITION, 0);
|
||||
}
|
||||
viewModel.setMedia(media);
|
||||
@ -902,7 +902,7 @@ public class PostViewV2Fragment extends Fragment implements EditTextDialogFragme
|
||||
|
||||
final boolean hasVideo = media.getCarouselMedia()
|
||||
.stream()
|
||||
.anyMatch(postChild -> postChild.getMediaType() == MediaItemType.MEDIA_TYPE_VIDEO);
|
||||
.anyMatch(postChild -> postChild.getType() == MediaItemType.MEDIA_TYPE_VIDEO);
|
||||
if (hasVideo) {
|
||||
final View child = sliderParent.getChildAt(0);
|
||||
if (child instanceof RecyclerView) {
|
||||
@ -918,7 +918,7 @@ public class PostViewV2Fragment extends Fragment implements EditTextDialogFragme
|
||||
@Override
|
||||
public void onItemClicked(final int position, final Media media, final View view) {
|
||||
if (media == null
|
||||
|| media.getMediaType() != MediaItemType.MEDIA_TYPE_IMAGE
|
||||
|| media.getType() != MediaItemType.MEDIA_TYPE_IMAGE
|
||||
|| !(view instanceof ZoomableDraweeView)) {
|
||||
return;
|
||||
}
|
||||
@ -1012,7 +1012,7 @@ public class PostViewV2Fragment extends Fragment implements EditTextDialogFragme
|
||||
// }
|
||||
// }
|
||||
video = false;
|
||||
if (childMedia.getMediaType() == MediaItemType.MEDIA_TYPE_VIDEO) {
|
||||
if (childMedia.getType() == MediaItemType.MEDIA_TYPE_VIDEO) {
|
||||
// if (view instanceof RecyclerView) {
|
||||
// final RecyclerView.ViewHolder viewHolder = ((RecyclerView) view).findViewHolderForAdapterPosition(position);
|
||||
// if (viewHolder instanceof SliderVideoViewHolder) {
|
||||
@ -1409,7 +1409,7 @@ public class PostViewV2Fragment extends Fragment implements EditTextDialogFragme
|
||||
// if (wasControlsVisible) {
|
||||
// showPlayerControls();
|
||||
// }
|
||||
if (media.getMediaType() == MediaItemType.MEDIA_TYPE_SLIDER) {
|
||||
if (media.getType() == MediaItemType.MEDIA_TYPE_SLIDER) {
|
||||
binding.mediaCounter.setVisibility(View.VISIBLE);
|
||||
}
|
||||
detailsVisible = true;
|
||||
|
@ -921,7 +921,7 @@ public class DirectMessageThreadFragment extends Fragment implements DirectReact
|
||||
|
||||
@NonNull
|
||||
private String getMediaPreviewTextString(final Media media) {
|
||||
final MediaItemType mediaType = media.getMediaType();
|
||||
final MediaItemType mediaType = media.getType();
|
||||
switch (mediaType) {
|
||||
case MEDIA_TYPE_IMAGE:
|
||||
return getString(R.string.photo);
|
||||
|
@ -1,35 +1,24 @@
|
||||
package awais.instagrabber.models.enums;
|
||||
package awais.instagrabber.models.enums
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import java.io.Serializable
|
||||
import java.util.*
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public enum FollowingType implements Serializable {
|
||||
@SerializedName("1")
|
||||
enum class FollowingType(val id: Int) : Serializable {
|
||||
FOLLOWING(1),
|
||||
@SerializedName("0")
|
||||
NOT_FOLLOWING(0);
|
||||
|
||||
private final int id;
|
||||
private static final Map<Integer, FollowingType> map = new HashMap<>();
|
||||
companion object {
|
||||
private val map: MutableMap<Int, FollowingType> = mutableMapOf()
|
||||
|
||||
static {
|
||||
for (FollowingType type : FollowingType.values()) {
|
||||
map.put(type.id, type);
|
||||
}
|
||||
@JvmStatic
|
||||
fun valueOf(id: Int): FollowingType? {
|
||||
return map[id]
|
||||
}
|
||||
|
||||
FollowingType(final int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public static FollowingType valueOf(final int id) {
|
||||
return map.get(id);
|
||||
init {
|
||||
for (type in values()) {
|
||||
map[type.id] = type
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,42 +1,26 @@
|
||||
package awais.instagrabber.models.enums;
|
||||
package awais.instagrabber.models.enums
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import java.io.Serializable
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public enum MediaItemType implements Serializable {
|
||||
@SerializedName("1")
|
||||
enum class MediaItemType(val id: Int) : Serializable {
|
||||
MEDIA_TYPE_IMAGE(1),
|
||||
@SerializedName("2")
|
||||
MEDIA_TYPE_VIDEO(2),
|
||||
@SerializedName("8")
|
||||
MEDIA_TYPE_SLIDER(8),
|
||||
@SerializedName("11")
|
||||
MEDIA_TYPE_VOICE(11),
|
||||
// 5 is arbitrary
|
||||
@SerializedName("5")
|
||||
MEDIA_TYPE_LIVE(5);
|
||||
MEDIA_TYPE_LIVE(5); // arbitrary
|
||||
|
||||
private final int id;
|
||||
private static final Map<Integer, MediaItemType> map = new HashMap<>();
|
||||
companion object {
|
||||
private val map: MutableMap<Int, MediaItemType> = mutableMapOf()
|
||||
|
||||
static {
|
||||
for (MediaItemType type : MediaItemType.values()) {
|
||||
map.put(type.id, type);
|
||||
}
|
||||
@JvmStatic
|
||||
fun valueOf(id: Int): MediaItemType? {
|
||||
return map[id]
|
||||
}
|
||||
|
||||
MediaItemType(final int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public static MediaItemType valueOf(final int id) {
|
||||
return map.get(id);
|
||||
init {
|
||||
for (type in values()) {
|
||||
map[type.id] = type
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,51 +1,10 @@
|
||||
package awais.instagrabber.repositories.responses;
|
||||
package awais.instagrabber.repositories.responses
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import awais.instagrabber.models.Comment
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import awais.instagrabber.models.Comment;
|
||||
|
||||
public class ChildCommentsFetchResponse {
|
||||
private final int childCommentCount;
|
||||
private final String nextMaxChildCursor;
|
||||
private final List<Comment> childComments;
|
||||
private final boolean hasMoreTailChildComments;
|
||||
|
||||
public ChildCommentsFetchResponse(final int childCommentCount,
|
||||
final String nextMaxChildCursor,
|
||||
final List<Comment> childComments,
|
||||
final boolean hasMoreTailChildComments) {
|
||||
this.childCommentCount = childCommentCount;
|
||||
this.nextMaxChildCursor = nextMaxChildCursor;
|
||||
this.childComments = childComments;
|
||||
this.hasMoreTailChildComments = hasMoreTailChildComments;
|
||||
}
|
||||
|
||||
public int getChildCommentCount() {
|
||||
return childCommentCount;
|
||||
}
|
||||
|
||||
public String getNextMaxChildCursor() {
|
||||
return nextMaxChildCursor;
|
||||
}
|
||||
|
||||
public boolean getHasMoreTailChildComments() {
|
||||
return hasMoreTailChildComments;
|
||||
}
|
||||
|
||||
public List<Comment> getChildComments() {
|
||||
return childComments;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ChildCommentsFetchResponse{" +
|
||||
"childCommentCount=" + childCommentCount +
|
||||
", nextMaxChildCursor='" + nextMaxChildCursor + '\'' +
|
||||
", childComments=" + childComments +
|
||||
", hasMoreTailChildComments=" + hasMoreTailChildComments +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
data class ChildCommentsFetchResponse(
|
||||
val childCommentCount: Int,
|
||||
val nextMaxChildCursor: String?,
|
||||
val childComments: List<Comment>?,
|
||||
val hasMoreTailChildComments: Boolean?
|
||||
)
|
@ -1,51 +1,10 @@
|
||||
package awais.instagrabber.repositories.responses;
|
||||
package awais.instagrabber.repositories.responses
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import awais.instagrabber.models.Comment
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import awais.instagrabber.models.Comment;
|
||||
|
||||
public class CommentsFetchResponse {
|
||||
private final int commentCount;
|
||||
private final String nextMinId;
|
||||
private final List<Comment> comments;
|
||||
private final boolean hasMoreComments;
|
||||
|
||||
public CommentsFetchResponse(final int commentCount,
|
||||
final String nextMinId,
|
||||
final List<Comment> comments,
|
||||
final boolean hasMoreComments) {
|
||||
this.commentCount = commentCount;
|
||||
this.nextMinId = nextMinId;
|
||||
this.comments = comments;
|
||||
this.hasMoreComments = hasMoreComments;
|
||||
}
|
||||
|
||||
public int getCommentCount() {
|
||||
return commentCount;
|
||||
}
|
||||
|
||||
public String getNextMinId() {
|
||||
return nextMinId;
|
||||
}
|
||||
|
||||
public List<Comment> getComments() {
|
||||
return comments;
|
||||
}
|
||||
|
||||
public boolean getHasMoreComments() {
|
||||
return hasMoreComments;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CommentsFetchResponse{" +
|
||||
"commentCount=" + commentCount +
|
||||
", nextMinId='" + nextMinId + '\'' +
|
||||
", comments=" + comments +
|
||||
", hasMoreComments=" + hasMoreComments +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
data class CommentsFetchResponse(
|
||||
val commentCount: Int,
|
||||
val nextMinId: String?,
|
||||
val comments: List<Comment>?,
|
||||
val hasMoreComments: Boolean
|
||||
)
|
@ -1,63 +1,12 @@
|
||||
package awais.instagrabber.repositories.responses;
|
||||
package awais.instagrabber.repositories.responses
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Objects;
|
||||
import awais.instagrabber.models.enums.FollowingType
|
||||
import java.io.Serializable
|
||||
|
||||
import awais.instagrabber.models.enums.FollowingType;
|
||||
|
||||
public final class Hashtag implements Serializable {
|
||||
private final FollowingType following; // 0 false 1 true; not on search results
|
||||
private final long mediaCount;
|
||||
private final String id;
|
||||
private final String name;
|
||||
private final String searchResultSubtitle; // shows how many posts there are on search results
|
||||
|
||||
public Hashtag(final String id,
|
||||
final String name,
|
||||
final long mediaCount,
|
||||
final FollowingType following,
|
||||
final String searchResultSubtitle) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.mediaCount = mediaCount;
|
||||
this.following = following;
|
||||
this.searchResultSubtitle = searchResultSubtitle;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public Long getMediaCount() {
|
||||
return mediaCount;
|
||||
}
|
||||
|
||||
public FollowingType getFollowing() {
|
||||
return following;
|
||||
}
|
||||
|
||||
public String getSubtitle() {
|
||||
return searchResultSubtitle;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
final Hashtag hashtag = (Hashtag) o;
|
||||
return mediaCount == hashtag.mediaCount &&
|
||||
following == hashtag.following &&
|
||||
Objects.equals(id, hashtag.id) &&
|
||||
Objects.equals(name, hashtag.name) &&
|
||||
Objects.equals(searchResultSubtitle, hashtag.searchResultSubtitle);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(following, mediaCount, id, name, searchResultSubtitle);
|
||||
}
|
||||
}
|
||||
data class Hashtag(
|
||||
val id: String,
|
||||
val name: String,
|
||||
val mediaCount: Long,
|
||||
val following: FollowingType?, // 0 false 1 true; not on search results
|
||||
val searchResultSubtitle: String? // shows how many posts there are on search results
|
||||
) : Serializable
|
@ -1,57 +1,11 @@
|
||||
package awais.instagrabber.repositories.responses;
|
||||
package awais.instagrabber.repositories.responses
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class LocationFeedResponse {
|
||||
private final int numResults;
|
||||
private final String nextMaxId;
|
||||
private final boolean moreAvailable;
|
||||
private final long mediaCount;
|
||||
private final String status;
|
||||
private final List<Media> items;
|
||||
private final Location location;
|
||||
|
||||
public LocationFeedResponse(final int numResults,
|
||||
final String nextMaxId,
|
||||
final boolean moreAvailable,
|
||||
final long mediaCount,
|
||||
final String status,
|
||||
final List<Media> items,
|
||||
final Location location) {
|
||||
this.numResults = numResults;
|
||||
this.nextMaxId = nextMaxId;
|
||||
this.moreAvailable = moreAvailable;
|
||||
this.mediaCount = mediaCount;
|
||||
this.status = status;
|
||||
this.items = items;
|
||||
this.location = location;
|
||||
}
|
||||
|
||||
public int getNumResults() {
|
||||
return numResults;
|
||||
}
|
||||
|
||||
public String getNextMaxId() {
|
||||
return nextMaxId;
|
||||
}
|
||||
|
||||
public boolean isMoreAvailable() {
|
||||
return moreAvailable;
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public List<Media> getItems() {
|
||||
return items;
|
||||
}
|
||||
|
||||
public long getMediaCount() {
|
||||
return mediaCount;
|
||||
}
|
||||
|
||||
public Location getLocation() {
|
||||
return location;
|
||||
}
|
||||
}
|
||||
data class LocationFeedResponse(
|
||||
val numResults: Int,
|
||||
val nextMaxId: String?,
|
||||
val moreAvailable: Boolean?,
|
||||
val mediaCount: Long?,
|
||||
val status: String,
|
||||
val items: List<Media>?,
|
||||
val location: Location
|
||||
)
|
@ -1,25 +0,0 @@
|
||||
package awais.instagrabber.repositories.responses;
|
||||
|
||||
public class LoginRequiredResponse {
|
||||
private String message = "login_required";
|
||||
private int logoutReason;
|
||||
private String status = "fail";
|
||||
|
||||
public LoginRequiredResponse(final String message, final int logoutReason, final String status) {
|
||||
this.message = message;
|
||||
this.logoutReason = logoutReason;
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public int getLogoutReason() {
|
||||
return logoutReason;
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
package awais.instagrabber.repositories.responses
|
||||
|
||||
import awais.instagrabber.models.enums.MediaItemType
|
||||
import awais.instagrabber.models.enums.MediaItemType.Companion.valueOf
|
||||
import awais.instagrabber.repositories.responses.feed.EndOfFeedDemarcator
|
||||
import awais.instagrabber.utils.TextUtils
|
||||
import java.io.Serializable
|
||||
@ -15,7 +16,7 @@ data class Media(
|
||||
val imageVersions2: ImageVersions2? = null,
|
||||
val originalWidth: Int = 0,
|
||||
val originalHeight: Int = 0,
|
||||
val mediaType: MediaItemType? = null,
|
||||
val mediaType: Int = 0,
|
||||
val commentLikesEnabled: Boolean = false,
|
||||
val commentsDisabled: Boolean = false,
|
||||
val nextMaxId: Long = -1,
|
||||
@ -58,6 +59,9 @@ data class Media(
|
||||
return dateString ?: ""
|
||||
}
|
||||
|
||||
val type: MediaItemType?
|
||||
get() = valueOf(mediaType)
|
||||
|
||||
fun setPostCaption(caption: String?) {
|
||||
var caption1: Caption? = this.caption
|
||||
if (caption1 == null) {
|
||||
|
@ -1,33 +1,7 @@
|
||||
package awais.instagrabber.repositories.responses;
|
||||
package awais.instagrabber.repositories.responses
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class UserSearchResponse {
|
||||
private final int numResults;
|
||||
private final List<User> users;
|
||||
private final boolean hasMore;
|
||||
private final String status;
|
||||
|
||||
public UserSearchResponse(final int numResults, final List<User> users, final boolean hasMore, final String status) {
|
||||
this.numResults = numResults;
|
||||
this.users = users;
|
||||
this.hasMore = hasMore;
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public int getNumResults() {
|
||||
return numResults;
|
||||
}
|
||||
|
||||
public List<User> getUsers() {
|
||||
return users;
|
||||
}
|
||||
|
||||
public boolean hasMore() {
|
||||
return hasMore;
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
}
|
||||
data class UserSearchResponse(
|
||||
val numResults: Int,
|
||||
val users: List<User>?,
|
||||
val status: String
|
||||
)
|
@ -1,63 +1,14 @@
|
||||
package awais.instagrabber.repositories.responses.discover;
|
||||
package awais.instagrabber.repositories.responses.discover
|
||||
|
||||
import java.io.Serializable;
|
||||
import awais.instagrabber.repositories.responses.Media
|
||||
import java.io.Serializable
|
||||
|
||||
import awais.instagrabber.repositories.responses.Media;
|
||||
|
||||
public class TopicCluster implements Serializable {
|
||||
private final String id;
|
||||
private final String title;
|
||||
private final String type;
|
||||
private final boolean canMute;
|
||||
private final boolean isMuted;
|
||||
private final int rankedPosition;
|
||||
private Media coverMedia;
|
||||
|
||||
public TopicCluster(final String id,
|
||||
final String title,
|
||||
final String type,
|
||||
final boolean canMute,
|
||||
final boolean isMuted,
|
||||
final int rankedPosition,
|
||||
final Media coverMedia) {
|
||||
this.id = id;
|
||||
this.title = title;
|
||||
this.type = type;
|
||||
this.canMute = canMute;
|
||||
this.isMuted = isMuted;
|
||||
this.rankedPosition = rankedPosition;
|
||||
this.coverMedia = coverMedia;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public boolean isCanMute() {
|
||||
return canMute;
|
||||
}
|
||||
|
||||
public boolean isMuted() {
|
||||
return isMuted;
|
||||
}
|
||||
|
||||
public int getRankedPosition() {
|
||||
return rankedPosition;
|
||||
}
|
||||
|
||||
public Media getCoverMedia() {
|
||||
return coverMedia;
|
||||
}
|
||||
|
||||
public void setCoverMedia(final Media coverMedia) {
|
||||
this.coverMedia = coverMedia;
|
||||
}
|
||||
}
|
||||
data class TopicCluster(
|
||||
val id: String,
|
||||
val title: String,
|
||||
val type: String?,
|
||||
val canMute: Boolean?,
|
||||
val isMuted: Boolean?,
|
||||
val rankedPosition: Int,
|
||||
var coverMedia: Media?
|
||||
) : Serializable
|
@ -1,58 +1,13 @@
|
||||
package awais.instagrabber.repositories.responses.discover;
|
||||
package awais.instagrabber.repositories.responses.discover
|
||||
|
||||
import java.util.List;
|
||||
import awais.instagrabber.repositories.responses.WrappedMedia;
|
||||
import awais.instagrabber.repositories.responses.WrappedMedia
|
||||
|
||||
public class TopicalExploreFeedResponse {
|
||||
private final boolean moreAvailable;
|
||||
private final String nextMaxId;
|
||||
private final String maxId;
|
||||
private final String status;
|
||||
private final int numResults;
|
||||
private final List<TopicCluster> clusters;
|
||||
private final List<WrappedMedia> items;
|
||||
|
||||
public TopicalExploreFeedResponse(final boolean moreAvailable,
|
||||
final String nextMaxId,
|
||||
final String maxId,
|
||||
final String status,
|
||||
final int numResults,
|
||||
final List<TopicCluster> clusters,
|
||||
final List<WrappedMedia> items) {
|
||||
this.moreAvailable = moreAvailable;
|
||||
this.nextMaxId = nextMaxId;
|
||||
this.maxId = maxId;
|
||||
this.status = status;
|
||||
this.numResults = numResults;
|
||||
this.clusters = clusters;
|
||||
this.items = items;
|
||||
}
|
||||
|
||||
public boolean isMoreAvailable() {
|
||||
return moreAvailable;
|
||||
}
|
||||
|
||||
public String getNextMaxId() {
|
||||
return nextMaxId;
|
||||
}
|
||||
|
||||
public String getMaxId() {
|
||||
return maxId;
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public int getNumResults() {
|
||||
return numResults;
|
||||
}
|
||||
|
||||
public List<TopicCluster> getClusters() {
|
||||
return clusters;
|
||||
}
|
||||
|
||||
public List<WrappedMedia> getItems() {
|
||||
return items;
|
||||
}
|
||||
}
|
||||
data class TopicalExploreFeedResponse(
|
||||
val moreAvailable: Boolean,
|
||||
val nextMaxId: String?,
|
||||
val maxId: String?,
|
||||
val status: String,
|
||||
val numResults: Int,
|
||||
val clusters: List<TopicCluster>?,
|
||||
val items: List<WrappedMedia>?
|
||||
)
|
@ -109,7 +109,7 @@ public final class DMUtils {
|
||||
.getString(R.string.dms_inbox_shared_location, username != null ? username : "", item.getLocation().getName());
|
||||
break;
|
||||
case MEDIA: {
|
||||
final MediaItemType mediaType = item.getMedia().getMediaType();
|
||||
final MediaItemType mediaType = item.getMedia().getType();
|
||||
subtitle = getMediaSpecificSubtitle(username, resources, mediaType);
|
||||
break;
|
||||
}
|
||||
@ -304,7 +304,7 @@ public final class DMUtils {
|
||||
}
|
||||
return subtitle;
|
||||
}
|
||||
final MediaItemType mediaType = visualMedia.getMedia().getMediaType();
|
||||
final MediaItemType mediaType = visualMedia.getMedia().getType();
|
||||
subtitle = getMediaSpecificSubtitle(username, resources, mediaType);
|
||||
return subtitle;
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ fun createImageOrVideo(
|
||||
imageVersions2 = imageVersions2,
|
||||
originalWidth = width,
|
||||
originalHeight = height,
|
||||
mediaType = if (isVideo) MediaItemType.MEDIA_TYPE_VIDEO else MediaItemType.MEDIA_TYPE_IMAGE,
|
||||
mediaType = if (isVideo) MediaItemType.MEDIA_TYPE_VIDEO.id else MediaItemType.MEDIA_TYPE_IMAGE.id,
|
||||
videoVersions = videoVersions,
|
||||
)
|
||||
return DirectItem(
|
||||
@ -82,7 +82,7 @@ fun createVoice(
|
||||
)
|
||||
val media = Media(
|
||||
id = UUID.randomUUID().toString(),
|
||||
mediaType = MediaItemType.MEDIA_TYPE_VOICE,
|
||||
mediaType = MediaItemType.MEDIA_TYPE_VOICE.id,
|
||||
audio = audio,
|
||||
)
|
||||
val voiceMedia = DirectItemVoiceMedia(
|
||||
|
@ -285,10 +285,10 @@ object DownloadUtils {
|
||||
username = user.username
|
||||
}
|
||||
val userFolderPaths: List<String> = getSubPathForUserFolder(username)
|
||||
when (media.mediaType) {
|
||||
when (media.type) {
|
||||
MediaItemType.MEDIA_TYPE_IMAGE, MediaItemType.MEDIA_TYPE_VIDEO -> {
|
||||
val url =
|
||||
if (media.mediaType == MediaItemType.MEDIA_TYPE_VIDEO) ResponseBodyUtils.getVideoUrl(
|
||||
if (media.type == MediaItemType.MEDIA_TYPE_VIDEO) ResponseBodyUtils.getVideoUrl(
|
||||
media
|
||||
) else ResponseBodyUtils.getImageUrl(media)
|
||||
val file = getDownloadSavePaths(ArrayList(userFolderPaths), media.code, url, "")
|
||||
@ -308,7 +308,7 @@ object DownloadUtils {
|
||||
while (i < sliderItems!!.size) {
|
||||
val child = sliderItems[i]
|
||||
val url =
|
||||
if (child.mediaType == MediaItemType.MEDIA_TYPE_VIDEO) ResponseBodyUtils.getVideoUrl(
|
||||
if (child.type == MediaItemType.MEDIA_TYPE_VIDEO) ResponseBodyUtils.getVideoUrl(
|
||||
child
|
||||
) else ResponseBodyUtils.getImageUrl(child)
|
||||
val file = getDownloadChildSavePaths(
|
||||
@ -446,7 +446,7 @@ object DownloadUtils {
|
||||
val mediaUser = media.user
|
||||
val username = mediaUser?.username ?: ""
|
||||
val userFolderPaths = getSubPathForUserFolder(username)
|
||||
when (media.mediaType) {
|
||||
when (media.type) {
|
||||
MediaItemType.MEDIA_TYPE_IMAGE, MediaItemType.MEDIA_TYPE_VIDEO -> {
|
||||
val url = getUrlOfType(media)
|
||||
var fileName = media.id
|
||||
@ -525,7 +525,7 @@ object DownloadUtils {
|
||||
}
|
||||
|
||||
private fun getUrlOfType(media: Media): String? {
|
||||
when (media.mediaType) {
|
||||
when (media.type) {
|
||||
MediaItemType.MEDIA_TYPE_IMAGE -> {
|
||||
return ResponseBodyUtils.getImageUrl(media)
|
||||
}
|
||||
|
@ -243,7 +243,7 @@ public final class ResponseBodyUtils {
|
||||
imageVersions2,
|
||||
width,
|
||||
height,
|
||||
mediaItemType,
|
||||
mediaItemType.getId(),
|
||||
false,
|
||||
feedItem.optBoolean("comments_disabled"),
|
||||
-1,
|
||||
|
@ -60,8 +60,8 @@ class PostViewV2ViewModel : ViewModel() {
|
||||
date.postValue(media.date)
|
||||
likeCount.postValue(media.likeCount)
|
||||
commentCount.postValue(media.commentCount)
|
||||
viewCount.postValue(if (media.mediaType == MediaItemType.MEDIA_TYPE_VIDEO) media.viewCount else null)
|
||||
type.postValue(media.mediaType)
|
||||
viewCount.postValue(if (media.type == MediaItemType.MEDIA_TYPE_VIDEO) media.viewCount else null)
|
||||
type.postValue(media.type)
|
||||
liked.postValue(media.hasLiked)
|
||||
saved.postValue(media.hasViewerSaved)
|
||||
initOptions()
|
||||
@ -310,7 +310,7 @@ class PostViewV2ViewModel : ViewModel() {
|
||||
return data
|
||||
}
|
||||
val mediaId = media.id
|
||||
val mediaType = media.mediaType
|
||||
val mediaType = media.type
|
||||
if (mediaId == null || mediaType == null) {
|
||||
data.postValue(error("media id or type is null", null))
|
||||
return data
|
||||
|
@ -119,13 +119,13 @@ public class FeedService {
|
||||
nextMaxId = group.getNextMaxId();
|
||||
final List<Media> feedItems = group.getFeedItems();
|
||||
for (final Media feedItem : feedItems) {
|
||||
if (feedItem == null || feedItem.isInjected() || feedItem.getMediaType() == null) continue;
|
||||
if (feedItem == null || feedItem.isInjected() || feedItem.getType() == null) continue;
|
||||
allPosts.add(feedItem);
|
||||
}
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (media == null || media.isInjected() || media.getMediaType() == null) continue;
|
||||
if (media == null || media.isInjected() || media.getType() == null) continue;
|
||||
allPosts.add(media);
|
||||
}
|
||||
return new PostsFetchResponse(allPosts, moreAvailable, nextMaxId);
|
||||
|
@ -53,7 +53,7 @@ public class LocationService {
|
||||
}
|
||||
final PostsFetchResponse postsFetchResponse = new PostsFetchResponse(
|
||||
body.getItems(),
|
||||
body.isMoreAvailable(),
|
||||
body.getMoreAvailable(),
|
||||
body.getNextMaxId()
|
||||
);
|
||||
callback.onSuccess(postsFetchResponse);
|
||||
|
Loading…
Reference in New Issue
Block a user