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