better story buttons handling, close #810
This commit is contained in:
parent
7c706e277b
commit
e6961fcee6
@ -103,17 +103,24 @@ public final class NotificationsViewerFragment extends Fragment implements Swipe
|
|||||||
model.getArgs().getUsername()));
|
model.getArgs().getUsername()));
|
||||||
NavHostFragment.findNavController(NotificationsViewerFragment.this).navigate(action);
|
NavHostFragment.findNavController(NotificationsViewerFragment.this).navigate(action);
|
||||||
} else {
|
} else {
|
||||||
|
final AlertDialog alertDialog = new AlertDialog.Builder(context)
|
||||||
|
.setCancelable(false)
|
||||||
|
.setView(R.layout.dialog_opening_post)
|
||||||
|
.create();
|
||||||
|
alertDialog.show();
|
||||||
mediaService.fetch(mediaId, new ServiceCallback<Media>() {
|
mediaService.fetch(mediaId, new ServiceCallback<Media>() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(final Media feedModel) {
|
public void onSuccess(final Media feedModel) {
|
||||||
final PostViewV2Fragment fragment = PostViewV2Fragment
|
final PostViewV2Fragment fragment = PostViewV2Fragment
|
||||||
.builder(feedModel)
|
.builder(feedModel)
|
||||||
.build();
|
.build();
|
||||||
|
fragment.setOnShowListener(dialog -> alertDialog.dismiss());
|
||||||
fragment.show(getChildFragmentManager(), "post_view");
|
fragment.show(getChildFragmentManager(), "post_view");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(final Throwable t) {
|
public void onFailure(final Throwable t) {
|
||||||
|
alertDialog.dismiss();
|
||||||
Toast.makeText(context, R.string.downloader_unknown_error, Toast.LENGTH_SHORT).show();
|
Toast.makeText(context, R.string.downloader_unknown_error, Toast.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -87,6 +87,7 @@ import awais.instagrabber.models.stickers.SwipeUpModel;
|
|||||||
import awais.instagrabber.repositories.requests.StoryViewerOptions;
|
import awais.instagrabber.repositories.requests.StoryViewerOptions;
|
||||||
import awais.instagrabber.repositories.requests.StoryViewerOptions.Type;
|
import awais.instagrabber.repositories.requests.StoryViewerOptions.Type;
|
||||||
import awais.instagrabber.repositories.requests.directmessages.BroadcastOptions;
|
import awais.instagrabber.repositories.requests.directmessages.BroadcastOptions;
|
||||||
|
import awais.instagrabber.repositories.responses.Media;
|
||||||
import awais.instagrabber.repositories.responses.StoryStickerResponse;
|
import awais.instagrabber.repositories.responses.StoryStickerResponse;
|
||||||
import awais.instagrabber.repositories.responses.directmessages.DirectThreadBroadcastResponse;
|
import awais.instagrabber.repositories.responses.directmessages.DirectThreadBroadcastResponse;
|
||||||
import awais.instagrabber.utils.Constants;
|
import awais.instagrabber.utils.Constants;
|
||||||
@ -99,6 +100,7 @@ import awais.instagrabber.viewmodels.FeedStoriesViewModel;
|
|||||||
import awais.instagrabber.viewmodels.HighlightsViewModel;
|
import awais.instagrabber.viewmodels.HighlightsViewModel;
|
||||||
import awais.instagrabber.viewmodels.StoriesViewModel;
|
import awais.instagrabber.viewmodels.StoriesViewModel;
|
||||||
import awais.instagrabber.webservices.DirectMessagesService;
|
import awais.instagrabber.webservices.DirectMessagesService;
|
||||||
|
import awais.instagrabber.webservices.MediaService;
|
||||||
import awais.instagrabber.webservices.ServiceCallback;
|
import awais.instagrabber.webservices.ServiceCallback;
|
||||||
import awais.instagrabber.webservices.StoriesService;
|
import awais.instagrabber.webservices.StoriesService;
|
||||||
import awaisomereport.LogCollector;
|
import awaisomereport.LogCollector;
|
||||||
@ -123,6 +125,7 @@ public class StoryViewerFragment extends Fragment {
|
|||||||
private SwipeEvent swipeEvent;
|
private SwipeEvent swipeEvent;
|
||||||
private GestureDetectorCompat gestureDetector;
|
private GestureDetectorCompat gestureDetector;
|
||||||
private StoriesService storiesService;
|
private StoriesService storiesService;
|
||||||
|
private MediaService mediaService;
|
||||||
private StoryModel currentStory;
|
private StoryModel currentStory;
|
||||||
private int slidePos;
|
private int slidePos;
|
||||||
private int lastSlidePos;
|
private int lastSlidePos;
|
||||||
@ -161,6 +164,7 @@ public class StoryViewerFragment extends Fragment {
|
|||||||
final String deviceId = settingsHelper.getString(Constants.DEVICE_UUID);
|
final String deviceId = settingsHelper.getString(Constants.DEVICE_UUID);
|
||||||
fragmentActivity = (AppCompatActivity) requireActivity();
|
fragmentActivity = (AppCompatActivity) requireActivity();
|
||||||
storiesService = StoriesService.getInstance(csrfToken, userIdFromCookie, deviceId);
|
storiesService = StoriesService.getInstance(csrfToken, userIdFromCookie, deviceId);
|
||||||
|
mediaService = MediaService.getInstance(null, null, 0);
|
||||||
directMessagesService = DirectMessagesService.getInstance(csrfToken, userIdFromCookie, deviceId);
|
directMessagesService = DirectMessagesService.getInstance(csrfToken, userIdFromCookie, deviceId);
|
||||||
setHasOptionsMenu(true);
|
setHasOptionsMenu(true);
|
||||||
}
|
}
|
||||||
@ -422,35 +426,40 @@ public class StoryViewerFragment extends Fragment {
|
|||||||
binding.spotify.setOnClickListener(v -> {
|
binding.spotify.setOnClickListener(v -> {
|
||||||
final Object tag = v.getTag();
|
final Object tag = v.getTag();
|
||||||
if (tag instanceof CharSequence) {
|
if (tag instanceof CharSequence) {
|
||||||
final Intent intent = new Intent(Intent.ACTION_VIEW);
|
Utils.openURL(context, tag.toString());
|
||||||
intent.setData(Uri.parse(tag.toString()));
|
|
||||||
startActivity(intent);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
binding.swipeUp.setOnClickListener(v -> {
|
binding.swipeUp.setOnClickListener(v -> {
|
||||||
final Object tag = v.getTag();
|
final Object tag = v.getTag();
|
||||||
if (tag instanceof CharSequence) {
|
if (tag instanceof CharSequence) {
|
||||||
final Intent intent = new Intent(Intent.ACTION_VIEW);
|
Utils.openURL(context, tag.toString());
|
||||||
intent.setData(Uri.parse(tag.toString()));
|
|
||||||
startActivity(intent);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
binding.viewStoryPost.setOnClickListener(v -> {
|
binding.viewStoryPost.setOnClickListener(v -> {
|
||||||
final Object tag = v.getTag();
|
final Object tag = v.getTag();
|
||||||
if (!(tag instanceof CharSequence)) return;
|
if (!(tag instanceof CharSequence)) return;
|
||||||
final String shortCode = tag.toString();
|
final String mediaId = tag.toString();
|
||||||
final AlertDialog alertDialog = new AlertDialog.Builder(context)
|
final AlertDialog alertDialog = new AlertDialog.Builder(context)
|
||||||
.setCancelable(false)
|
.setCancelable(false)
|
||||||
.setView(R.layout.dialog_opening_post)
|
.setView(R.layout.dialog_opening_post)
|
||||||
.create();
|
.create();
|
||||||
alertDialog.show();
|
alertDialog.show();
|
||||||
new PostFetcher(shortCode, feedModel -> {
|
mediaService.fetch(Long.valueOf(mediaId), new ServiceCallback<Media>() {
|
||||||
final PostViewV2Fragment fragment = PostViewV2Fragment
|
@Override
|
||||||
.builder(feedModel)
|
public void onSuccess(final Media feedModel) {
|
||||||
.build();
|
final PostViewV2Fragment fragment = PostViewV2Fragment
|
||||||
fragment.setOnShowListener(dialog -> alertDialog.dismiss());
|
.builder(feedModel)
|
||||||
fragment.show(getChildFragmentManager(), "post_view");
|
.build();
|
||||||
}).execute();
|
fragment.setOnShowListener(dialog -> alertDialog.dismiss());
|
||||||
|
fragment.show(getChildFragmentManager(), "post_view");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFailure(final Throwable t) {
|
||||||
|
alertDialog.dismiss();
|
||||||
|
Toast.makeText(context, R.string.downloader_unknown_error, Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
final View.OnClickListener storyActionListener = v -> {
|
final View.OnClickListener storyActionListener = v -> {
|
||||||
final Object tag = v.getTag();
|
final Object tag = v.getTag();
|
||||||
|
@ -987,7 +987,7 @@ public final class ResponseBodyUtils {
|
|||||||
model.setVideoUrl(ResponseBodyUtils.getHighQualityPost(videoResources, true, true, false));
|
model.setVideoUrl(ResponseBodyUtils.getHighQualityPost(videoResources, true, true, false));
|
||||||
|
|
||||||
if (data.has("story_feed_media")) {
|
if (data.has("story_feed_media")) {
|
||||||
model.setTappableShortCode(data.getJSONArray("story_feed_media").getJSONObject(0).optString("media_code"));
|
model.setTappableShortCode(data.getJSONArray("story_feed_media").getJSONObject(0).optString("media_id"));
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: this may not be limited to spotify
|
// TODO: this may not be limited to spotify
|
||||||
|
Loading…
Reference in New Issue
Block a user