|
|
@ -50,6 +50,7 @@ import com.facebook.imagepipeline.request.ImageRequestBuilder; |
|
|
|
import com.google.android.exoplayer2.MediaItem; |
|
|
|
import com.google.android.exoplayer2.Player; |
|
|
|
import com.google.android.exoplayer2.SimpleExoPlayer; |
|
|
|
import com.google.android.exoplayer2.source.dash.DashMediaSource; |
|
|
|
import com.google.android.exoplayer2.source.LoadEventInfo; |
|
|
|
import com.google.android.exoplayer2.source.MediaLoadData; |
|
|
|
import com.google.android.exoplayer2.source.MediaSource; |
|
|
@ -643,6 +644,7 @@ public class StoryViewerFragment extends Fragment { |
|
|
|
|
|
|
|
private void resetView() { |
|
|
|
final Context context = getContext(); |
|
|
|
StoryModel live = null; |
|
|
|
slidePos = 0; |
|
|
|
lastSlidePos = 0; |
|
|
|
if (menuDownload != null) menuDownload.setVisible(false); |
|
|
@ -679,6 +681,7 @@ public class StoryViewerFragment extends Fragment { |
|
|
|
final FeedStoryModel model = models.get(currentFeedStoryIndex); |
|
|
|
currentStoryMediaId = model.getStoryMediaId(); |
|
|
|
currentStoryUsername = model.getProfileModel().getUsername(); |
|
|
|
if (model.isLive()) live = model.getFirstStoryModel(); |
|
|
|
} |
|
|
|
} else if (!TextUtils.isEmpty(fragmentArgs.getProfileId()) && !TextUtils.isEmpty(fragmentArgs.getUsername())) { |
|
|
|
currentStoryMediaId = fragmentArgs.getProfileId(); |
|
|
@ -756,7 +759,8 @@ public class StoryViewerFragment extends Fragment { |
|
|
|
Log.e(TAG, "Error", t); |
|
|
|
} |
|
|
|
}; |
|
|
|
storiesService.getUserStory(currentStoryMediaId, |
|
|
|
if (live != null) storyCallback.onSuccess(Collections.singletonList(live)); |
|
|
|
else storiesService.getUserStory(currentStoryMediaId, |
|
|
|
currentStoryUsername, |
|
|
|
isLoc, |
|
|
|
isHashtag, |
|
|
@ -786,41 +790,43 @@ public class StoryViewerFragment extends Fragment { |
|
|
|
final MediaItemType itemType = currentStory.getItemType(); |
|
|
|
|
|
|
|
if (menuDownload != null) menuDownload.setVisible(false); |
|
|
|
url = itemType == MediaItemType.MEDIA_TYPE_VIDEO ? currentStory.getVideoUrl() : currentStory.getStoryUrl(); |
|
|
|
url = itemType == MediaItemType.MEDIA_TYPE_IMAGE ? currentStory.getStoryUrl() : currentStory.getVideoUrl(); |
|
|
|
|
|
|
|
final String shortCode = currentStory.getTappableShortCode(); |
|
|
|
binding.viewStoryPost.setVisibility(shortCode != null ? View.VISIBLE : View.GONE); |
|
|
|
binding.viewStoryPost.setTag(shortCode); |
|
|
|
if (itemType != MediaItemType.MEDIA_TYPE_LIVE) { |
|
|
|
final String shortCode = currentStory.getTappableShortCode(); |
|
|
|
binding.viewStoryPost.setVisibility(shortCode != null ? View.VISIBLE : View.GONE); |
|
|
|
binding.viewStoryPost.setTag(shortCode); |
|
|
|
|
|
|
|
final String spotify = currentStory.getSpotify(); |
|
|
|
binding.spotify.setVisibility(spotify != null ? View.VISIBLE : View.GONE); |
|
|
|
binding.spotify.setTag(spotify); |
|
|
|
final String spotify = currentStory.getSpotify(); |
|
|
|
binding.spotify.setVisibility(spotify != null ? View.VISIBLE : View.GONE); |
|
|
|
binding.spotify.setTag(spotify); |
|
|
|
|
|
|
|
poll = currentStory.getPoll(); |
|
|
|
binding.poll.setVisibility(poll != null ? View.VISIBLE : View.GONE); |
|
|
|
binding.poll.setTag(poll); |
|
|
|
poll = currentStory.getPoll(); |
|
|
|
binding.poll.setVisibility(poll != null ? View.VISIBLE : View.GONE); |
|
|
|
binding.poll.setTag(poll); |
|
|
|
|
|
|
|
question = currentStory.getQuestion(); |
|
|
|
binding.answer.setVisibility((question != null && !TextUtils.isEmpty(cookie)) ? View.VISIBLE : View.GONE); |
|
|
|
binding.answer.setTag(question); |
|
|
|
question = currentStory.getQuestion(); |
|
|
|
binding.answer.setVisibility((question != null && !TextUtils.isEmpty(cookie)) ? View.VISIBLE : View.GONE); |
|
|
|
binding.answer.setTag(question); |
|
|
|
|
|
|
|
mentions = currentStory.getMentions(); |
|
|
|
binding.mention.setVisibility((mentions != null && mentions.length > 0) ? View.VISIBLE : View.GONE); |
|
|
|
binding.mention.setTag(mentions); |
|
|
|
mentions = currentStory.getMentions(); |
|
|
|
binding.mention.setVisibility((mentions != null && mentions.length > 0) ? View.VISIBLE : View.GONE); |
|
|
|
binding.mention.setTag(mentions); |
|
|
|
|
|
|
|
quiz = currentStory.getQuiz(); |
|
|
|
binding.quiz.setVisibility(quiz != null ? View.VISIBLE : View.GONE); |
|
|
|
binding.quiz.setTag(quiz); |
|
|
|
quiz = currentStory.getQuiz(); |
|
|
|
binding.quiz.setVisibility(quiz != null ? View.VISIBLE : View.GONE); |
|
|
|
binding.quiz.setTag(quiz); |
|
|
|
|
|
|
|
slider = currentStory.getSlider(); |
|
|
|
binding.slider.setVisibility(slider != null ? View.VISIBLE : View.GONE); |
|
|
|
binding.slider.setTag(slider); |
|
|
|
slider = currentStory.getSlider(); |
|
|
|
binding.slider.setVisibility(slider != null ? View.VISIBLE : View.GONE); |
|
|
|
binding.slider.setTag(slider); |
|
|
|
|
|
|
|
swipeUp = currentStory.getSwipeUp(); |
|
|
|
if (swipeUp != null) { |
|
|
|
binding.swipeUp.setVisibility(View.VISIBLE); |
|
|
|
binding.swipeUp.setText(swipeUp.getText()); |
|
|
|
binding.swipeUp.setTag(swipeUp.getUrl()); |
|
|
|
swipeUp = currentStory.getSwipeUp(); |
|
|
|
if (swipeUp != null) { |
|
|
|
binding.swipeUp.setVisibility(View.VISIBLE); |
|
|
|
binding.swipeUp.setText(swipeUp.getText()); |
|
|
|
binding.swipeUp.setTag(swipeUp.getUrl()); |
|
|
|
} else binding.swipeUp.setVisibility(View.GONE); |
|
|
|
} |
|
|
|
|
|
|
|
releasePlayer(); |
|
|
@ -832,6 +838,7 @@ public class StoryViewerFragment extends Fragment { |
|
|
|
} |
|
|
|
} |
|
|
|
if (itemType == MediaItemType.MEDIA_TYPE_VIDEO) setupVideo(); |
|
|
|
else if (itemType == MediaItemType.MEDIA_TYPE_LIVE) setupLive(); |
|
|
|
else setupImage(); |
|
|
|
|
|
|
|
final ActionBar actionBar = fragmentActivity.getSupportActionBar(); |
|
|
@ -957,6 +964,72 @@ public class StoryViewerFragment extends Fragment { |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
private void setupLive() { |
|
|
|
binding.playerView.setVisibility(View.VISIBLE); |
|
|
|
binding.progressView.setVisibility(View.GONE); |
|
|
|
binding.imageViewer.setVisibility(View.GONE); |
|
|
|
binding.imageViewer.setController(null); |
|
|
|
|
|
|
|
if (menuDownload != null) menuDownload.setVisible(false); |
|
|
|
if (menuDm != null) menuDm.setVisible(false); |
|
|
|
|
|
|
|
final Context context = getContext(); |
|
|
|
if (context == null) return; |
|
|
|
player = new SimpleExoPlayer.Builder(context).build(); |
|
|
|
binding.playerView.setPlayer(player); |
|
|
|
player.setPlayWhenReady(settingsHelper.getBoolean(Constants.AUTOPLAY_VIDEOS)); |
|
|
|
|
|
|
|
final Uri uri = Uri.parse(url); |
|
|
|
final MediaItem mediaItem = MediaItem.fromUri(uri); |
|
|
|
final DashMediaSource mediaSource = new DashMediaSource.Factory(new DefaultDataSourceFactory(context, "instagram")) |
|
|
|
.createMediaSource(mediaItem); |
|
|
|
mediaSource.addEventListener(new Handler(), new MediaSourceEventListener() { |
|
|
|
@Override |
|
|
|
public void onLoadCompleted(final int windowIndex, |
|
|
|
@Nullable final MediaSource.MediaPeriodId mediaPeriodId, |
|
|
|
final LoadEventInfo loadEventInfo, |
|
|
|
final MediaLoadData mediaLoadData) { |
|
|
|
binding.progressView.setVisibility(View.GONE); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void onLoadStarted(final int windowIndex, |
|
|
|
@Nullable final MediaSource.MediaPeriodId mediaPeriodId, |
|
|
|
final LoadEventInfo loadEventInfo, |
|
|
|
final MediaLoadData mediaLoadData) { |
|
|
|
binding.progressView.setVisibility(View.VISIBLE); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void onLoadCanceled(final int windowIndex, |
|
|
|
@Nullable final MediaSource.MediaPeriodId mediaPeriodId, |
|
|
|
final LoadEventInfo loadEventInfo, |
|
|
|
final MediaLoadData mediaLoadData) { |
|
|
|
binding.progressView.setVisibility(View.GONE); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void onLoadError(final int windowIndex, |
|
|
|
@Nullable final MediaSource.MediaPeriodId mediaPeriodId, |
|
|
|
final LoadEventInfo loadEventInfo, |
|
|
|
final MediaLoadData mediaLoadData, |
|
|
|
final IOException error, |
|
|
|
final boolean wasCanceled) { |
|
|
|
binding.progressView.setVisibility(View.GONE); |
|
|
|
} |
|
|
|
}); |
|
|
|
player.setMediaSource(mediaSource); |
|
|
|
player.prepare(); |
|
|
|
|
|
|
|
binding.playerView.setOnClickListener(v -> { |
|
|
|
if (player != null) { |
|
|
|
if (player.getPlaybackState() == Player.STATE_ENDED) player.seekTo(0); |
|
|
|
player.setPlayWhenReady(player.getPlaybackState() == Player.STATE_ENDED || !player.isPlaying()); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void openProfile(final String username) { |
|
|
|
final ActionBar actionBar = fragmentActivity.getSupportActionBar(); |
|
|
|
if (actionBar != null) { |
|
|
|