mirror of
https://github.com/KokaKiwi/BarInsta
synced 2024-11-22 06:37:30 +00:00
various story fixes, closes #1496
This commit is contained in:
parent
19d3434dbf
commit
80787c7e5e
@ -473,11 +473,11 @@ public class StoryViewerFragment extends Fragment {
|
|||||||
poll = (PollSticker) tag;
|
poll = (PollSticker) tag;
|
||||||
final List<Tally> tallies = poll.getTallies();
|
final List<Tally> tallies = poll.getTallies();
|
||||||
final String[] choices = tallies.stream()
|
final String[] choices = tallies.stream()
|
||||||
.map(t -> (poll.getViewerVote() == tallies.indexOf(t) ? "√ " : "")
|
.map(t -> (poll.getViewerVote() != null && poll.getViewerVote() == tallies.indexOf(t) ? "√ " : "")
|
||||||
+ t.getText() + " (" + t.getCount() + ")" )
|
+ t.getText() + " (" + t.getCount() + ")" )
|
||||||
.toArray(String[]::new);
|
.toArray(String[]::new);
|
||||||
final ArrayAdapter adapter = new ArrayAdapter<>(context, android.R.layout.simple_list_item_1, choices);
|
final ArrayAdapter adapter = new ArrayAdapter<>(context, android.R.layout.simple_list_item_1, choices);
|
||||||
if (poll.getViewerVote() > -1) {
|
if (poll.getViewerVote() != null) {
|
||||||
new AlertDialog.Builder(context)
|
new AlertDialog.Builder(context)
|
||||||
.setTitle(R.string.voted_story_poll)
|
.setTitle(R.string.voted_story_poll)
|
||||||
.setAdapter(adapter, null)
|
.setAdapter(adapter, null)
|
||||||
@ -577,16 +577,17 @@ public class StoryViewerFragment extends Fragment {
|
|||||||
.setPositiveButton(R.string.cancel, null)
|
.setPositiveButton(R.string.cancel, null)
|
||||||
.show();
|
.show();
|
||||||
} else if (tag instanceof QuizSticker) {
|
} else if (tag instanceof QuizSticker) {
|
||||||
|
quiz = (QuizSticker) tag;
|
||||||
final List<Tally> tallies = quiz.getTallies();
|
final List<Tally> tallies = quiz.getTallies();
|
||||||
final String[] choices = tallies.stream().map(
|
final String[] choices = tallies.stream().map(
|
||||||
t -> (quiz.getViewerAnswer() == tallies.indexOf(t) ? "√ " : "") +
|
t -> (quiz.getViewerAnswer() != null && quiz.getViewerAnswer() == tallies.indexOf(t) ? "√ " : "") +
|
||||||
(quiz.getCorrectAnswer() == tallies.indexOf(t) ? "*** " : "") +
|
(quiz.getCorrectAnswer() == tallies.indexOf(t) ? "*** " : "") +
|
||||||
t.getText() + " (" + t.getCount() + ")"
|
t.getText() + " (" + t.getCount() + ")"
|
||||||
).toArray(String[]::new);
|
).toArray(String[]::new);
|
||||||
new AlertDialog.Builder(context)
|
new AlertDialog.Builder(context)
|
||||||
.setTitle(quiz.getViewerAnswer() > -1 ? getString(R.string.story_quizzed) : quiz.getQuestion())
|
.setTitle(quiz.getViewerAnswer() != null ? getString(R.string.story_quizzed) : quiz.getQuestion())
|
||||||
.setAdapter(new ArrayAdapter<>(context, android.R.layout.simple_list_item_1, choices), (d, w) -> {
|
.setAdapter(new ArrayAdapter<>(context, android.R.layout.simple_list_item_1, choices), (d, w) -> {
|
||||||
if (quiz.getViewerAnswer() == -1) {
|
if (quiz.getViewerAnswer() == null) {
|
||||||
sticking = true;
|
sticking = true;
|
||||||
storiesRepository.respondToQuiz(
|
storiesRepository.respondToQuiz(
|
||||||
csrfToken,
|
csrfToken,
|
||||||
@ -901,7 +902,7 @@ public class StoryViewerFragment extends Fragment {
|
|||||||
}
|
}
|
||||||
lastSlidePos = slidePos;
|
lastSlidePos = slidePos;
|
||||||
|
|
||||||
final MediaItemType itemType = currentStory.getMediaType();
|
final MediaItemType itemType = currentStory.getType();
|
||||||
|
|
||||||
url = itemType == MediaItemType.MEDIA_TYPE_IMAGE
|
url = itemType == MediaItemType.MEDIA_TYPE_IMAGE
|
||||||
? ResponseBodyUtils.getImageUrl(currentStory)
|
? ResponseBodyUtils.getImageUrl(currentStory)
|
||||||
@ -966,7 +967,7 @@ public class StoryViewerFragment extends Fragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (currentStory.getStoryCta() != null) {
|
if (currentStory.getStoryCta() != null) {
|
||||||
final StoryCta swipeUp = currentStory.getStoryCta().get(0).getLinks();
|
final StoryCta swipeUp = currentStory.getStoryCta().get(0).getLinks().get(0);
|
||||||
binding.swipeUp.setVisibility(View.VISIBLE);
|
binding.swipeUp.setVisibility(View.VISIBLE);
|
||||||
binding.swipeUp.setText(currentStory.getLinkText());
|
binding.swipeUp.setText(currentStory.getLinkText());
|
||||||
final String swipeUpUrl = swipeUp.getWebUri();
|
final String swipeUpUrl = swipeUp.getWebUri();
|
||||||
|
@ -6,8 +6,8 @@ import awais.instagrabber.repositories.responses.Location
|
|||||||
import awais.instagrabber.repositories.responses.User
|
import awais.instagrabber.repositories.responses.User
|
||||||
|
|
||||||
data class PollSticker(
|
data class PollSticker(
|
||||||
val pollId: Long?,
|
val pollId: Long,
|
||||||
val question: String?,
|
val question: String?,
|
||||||
val tallies: List<Tally>?,
|
val tallies: List<Tally>,
|
||||||
var viewerVote: Int = -1
|
var viewerVote: Int?
|
||||||
) : Serializable
|
) : Serializable
|
@ -7,6 +7,6 @@ import awais.instagrabber.repositories.responses.User
|
|||||||
|
|
||||||
data class QuestionSticker(
|
data class QuestionSticker(
|
||||||
val questionType: String?,
|
val questionType: String?,
|
||||||
val questionId: Long?,
|
val questionId: Long,
|
||||||
val question: String?
|
val question: String
|
||||||
) : Serializable
|
) : Serializable
|
@ -8,7 +8,7 @@ import awais.instagrabber.repositories.responses.User
|
|||||||
data class QuizSticker(
|
data class QuizSticker(
|
||||||
val quizId: Long?,
|
val quizId: Long?,
|
||||||
val question: String?,
|
val question: String?,
|
||||||
val tallies: List<Tally>?,
|
val tallies: List<Tally>,
|
||||||
var viewerAnswer: Int? = -1,
|
var viewerAnswer: Int?,
|
||||||
val correctAnswer: Int?
|
val correctAnswer: Int
|
||||||
) : Serializable
|
) : Serializable
|
@ -1,6 +1,7 @@
|
|||||||
package awais.instagrabber.repositories.responses.stories
|
package awais.instagrabber.repositories.responses.stories
|
||||||
|
|
||||||
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.ImageVersions2
|
import awais.instagrabber.repositories.responses.ImageVersions2
|
||||||
import awais.instagrabber.repositories.responses.MediaCandidate
|
import awais.instagrabber.repositories.responses.MediaCandidate
|
||||||
import awais.instagrabber.repositories.responses.User
|
import awais.instagrabber.repositories.responses.User
|
||||||
@ -9,36 +10,36 @@ import java.io.Serializable
|
|||||||
|
|
||||||
data class StoryMedia(
|
data class StoryMedia(
|
||||||
// inherited from Media
|
// inherited from Media
|
||||||
val pk: String? = null,
|
val pk: String? = null,
|
||||||
val id: String? = null,
|
val id: String? = null,
|
||||||
val takenAt: Long = -1,
|
val takenAt: Long = -1,
|
||||||
val user: User? = null,
|
val user: User? = null,
|
||||||
val canReshare: Boolean = false,
|
val canReshare: Boolean = false,
|
||||||
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 isReelMedia: Boolean = false,
|
val isReelMedia: Boolean = false,
|
||||||
val videoVersions: List<MediaCandidate>? = null,
|
val videoVersions: List<MediaCandidate>? = null,
|
||||||
val hasAudio: Boolean = false,
|
val hasAudio: Boolean = false,
|
||||||
val videoDuration: Double = 0.0,
|
val videoDuration: Double = 0.0,
|
||||||
val viewCount: Long = 0,
|
val viewCount: Long = 0,
|
||||||
val title: String? = null,
|
val title: String? = null,
|
||||||
// story-specific
|
// story-specific
|
||||||
val canReply: Boolean = false,
|
val canReply: Boolean = false,
|
||||||
val linkText: String? = null, // required for story_cta
|
val linkText: String? = null, // required for story_cta
|
||||||
// stickers
|
// stickers
|
||||||
val reelMentions: List<StorySticker>? = null,
|
val reelMentions: List<StorySticker>? = null,
|
||||||
val storyHashtags: List<StorySticker>? = null,
|
val storyHashtags: List<StorySticker>? = null,
|
||||||
val storyLocations: List<StorySticker>? = null,
|
val storyLocations: List<StorySticker>? = null,
|
||||||
val storyFeedMedia: List<StorySticker>? = null,
|
val storyFeedMedia: List<StorySticker>? = null,
|
||||||
val storyPolls: List<StorySticker>? = null,
|
val storyPolls: List<StorySticker>? = null,
|
||||||
val storyQuestions: List<StorySticker>? = null,
|
val storyQuestions: List<StorySticker>? = null,
|
||||||
val storyQuizs: List<StorySticker>? = null,
|
val storyQuizs: List<StorySticker>? = null,
|
||||||
val storyCta: List<StorySticker>? = null,
|
val storyCta: List<StorySticker>? = null,
|
||||||
val storySliders: List<StorySticker>? = null,
|
val storySliders: List<StorySticker>? = null,
|
||||||
// spotify/soundcloud button, not a sticker
|
// spotify/soundcloud button, not a sticker
|
||||||
val storyAppAttribution: StoryAppAttribution? = null
|
val storyAppAttribution: StoryAppAttribution? = null
|
||||||
) : Serializable {
|
) : Serializable {
|
||||||
private var dateString: String? = null
|
private var dateString: String? = null
|
||||||
var position = 0
|
var position = 0
|
||||||
@ -48,6 +49,9 @@ data class StoryMedia(
|
|||||||
// val date: String by lazy {
|
// val date: String by lazy {
|
||||||
// if (takenAt <= 0) "" else Utils.datetimeParser.format(Date(takenAt * 1000L))
|
// if (takenAt <= 0) "" else Utils.datetimeParser.format(Date(takenAt * 1000L))
|
||||||
// }
|
// }
|
||||||
|
val type: MediaItemType?
|
||||||
|
get() = valueOf(mediaType)
|
||||||
|
|
||||||
val date: String
|
val date: String
|
||||||
get() {
|
get() {
|
||||||
if (takenAt <= 0) return ""
|
if (takenAt <= 0) return ""
|
||||||
|
@ -14,6 +14,6 @@ data class StorySticker(
|
|||||||
val pollSticker: PollSticker?, // story_polls
|
val pollSticker: PollSticker?, // story_polls
|
||||||
val questionSticker: QuestionSticker?, // story_questions
|
val questionSticker: QuestionSticker?, // story_questions
|
||||||
val quizSticker: QuizSticker?, // story_quizs
|
val quizSticker: QuizSticker?, // story_quizs
|
||||||
val links: StoryCta?, // story_cta, requires link_text from the story
|
val links: List<StoryCta?>?, // story_cta, requires link_text from the story
|
||||||
val sliderSticker: SliderSticker? // story_sliders
|
val sliderSticker: SliderSticker? // story_sliders
|
||||||
) : Serializable
|
) : Serializable
|
@ -396,7 +396,7 @@ object DownloadUtils {
|
|||||||
) {
|
) {
|
||||||
val downloadDir = getDownloadDir(context, storyModel.user?.username) ?: return
|
val downloadDir = getDownloadDir(context, storyModel.user?.username) ?: return
|
||||||
val url =
|
val url =
|
||||||
if (storyModel.mediaType == MediaItemType.MEDIA_TYPE_VIDEO) ResponseBodyUtils.getVideoUrl(storyModel)
|
if (storyModel.type == MediaItemType.MEDIA_TYPE_VIDEO) ResponseBodyUtils.getVideoUrl(storyModel)
|
||||||
else ResponseBodyUtils.getImageUrl(storyModel)
|
else ResponseBodyUtils.getImageUrl(storyModel)
|
||||||
val extension = getFileExtensionFromUrl(url)
|
val extension = getFileExtensionFromUrl(url)
|
||||||
val baseFileName = (storyModel.id + "_"
|
val baseFileName = (storyModel.id + "_"
|
||||||
|
Loading…
Reference in New Issue
Block a user