mirror of
https://github.com/KokaKiwi/BarInsta
synced 2024-11-07 23:47:30 +00:00
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()));
|
||||
NavHostFragment.findNavController(NotificationsViewerFragment.this).navigate(action);
|
||||
} 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>() {
|
||||
@Override
|
||||
public void onSuccess(final Media feedModel) {
|
||||
final PostViewV2Fragment fragment = PostViewV2Fragment
|
||||
.builder(feedModel)
|
||||
.build();
|
||||
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();
|
||||
}
|
||||
});
|
||||
|
@ -87,6 +87,7 @@ import awais.instagrabber.models.stickers.SwipeUpModel;
|
||||
import awais.instagrabber.repositories.requests.StoryViewerOptions;
|
||||
import awais.instagrabber.repositories.requests.StoryViewerOptions.Type;
|
||||
import awais.instagrabber.repositories.requests.directmessages.BroadcastOptions;
|
||||
import awais.instagrabber.repositories.responses.Media;
|
||||
import awais.instagrabber.repositories.responses.StoryStickerResponse;
|
||||
import awais.instagrabber.repositories.responses.directmessages.DirectThreadBroadcastResponse;
|
||||
import awais.instagrabber.utils.Constants;
|
||||
@ -99,6 +100,7 @@ import awais.instagrabber.viewmodels.FeedStoriesViewModel;
|
||||
import awais.instagrabber.viewmodels.HighlightsViewModel;
|
||||
import awais.instagrabber.viewmodels.StoriesViewModel;
|
||||
import awais.instagrabber.webservices.DirectMessagesService;
|
||||
import awais.instagrabber.webservices.MediaService;
|
||||
import awais.instagrabber.webservices.ServiceCallback;
|
||||
import awais.instagrabber.webservices.StoriesService;
|
||||
import awaisomereport.LogCollector;
|
||||
@ -123,6 +125,7 @@ public class StoryViewerFragment extends Fragment {
|
||||
private SwipeEvent swipeEvent;
|
||||
private GestureDetectorCompat gestureDetector;
|
||||
private StoriesService storiesService;
|
||||
private MediaService mediaService;
|
||||
private StoryModel currentStory;
|
||||
private int slidePos;
|
||||
private int lastSlidePos;
|
||||
@ -161,6 +164,7 @@ public class StoryViewerFragment extends Fragment {
|
||||
final String deviceId = settingsHelper.getString(Constants.DEVICE_UUID);
|
||||
fragmentActivity = (AppCompatActivity) requireActivity();
|
||||
storiesService = StoriesService.getInstance(csrfToken, userIdFromCookie, deviceId);
|
||||
mediaService = MediaService.getInstance(null, null, 0);
|
||||
directMessagesService = DirectMessagesService.getInstance(csrfToken, userIdFromCookie, deviceId);
|
||||
setHasOptionsMenu(true);
|
||||
}
|
||||
@ -422,35 +426,40 @@ public class StoryViewerFragment extends Fragment {
|
||||
binding.spotify.setOnClickListener(v -> {
|
||||
final Object tag = v.getTag();
|
||||
if (tag instanceof CharSequence) {
|
||||
final Intent intent = new Intent(Intent.ACTION_VIEW);
|
||||
intent.setData(Uri.parse(tag.toString()));
|
||||
startActivity(intent);
|
||||
Utils.openURL(context, tag.toString());
|
||||
}
|
||||
});
|
||||
binding.swipeUp.setOnClickListener(v -> {
|
||||
final Object tag = v.getTag();
|
||||
if (tag instanceof CharSequence) {
|
||||
final Intent intent = new Intent(Intent.ACTION_VIEW);
|
||||
intent.setData(Uri.parse(tag.toString()));
|
||||
startActivity(intent);
|
||||
Utils.openURL(context, tag.toString());
|
||||
}
|
||||
});
|
||||
binding.viewStoryPost.setOnClickListener(v -> {
|
||||
final Object tag = v.getTag();
|
||||
if (!(tag instanceof CharSequence)) return;
|
||||
final String shortCode = tag.toString();
|
||||
final String mediaId = tag.toString();
|
||||
final AlertDialog alertDialog = new AlertDialog.Builder(context)
|
||||
.setCancelable(false)
|
||||
.setView(R.layout.dialog_opening_post)
|
||||
.create();
|
||||
alertDialog.show();
|
||||
new PostFetcher(shortCode, feedModel -> {
|
||||
final PostViewV2Fragment fragment = PostViewV2Fragment
|
||||
.builder(feedModel)
|
||||
.build();
|
||||
fragment.setOnShowListener(dialog -> alertDialog.dismiss());
|
||||
fragment.show(getChildFragmentManager(), "post_view");
|
||||
}).execute();
|
||||
mediaService.fetch(Long.valueOf(mediaId), new ServiceCallback<Media>() {
|
||||
@Override
|
||||
public void onSuccess(final Media feedModel) {
|
||||
final PostViewV2Fragment fragment = PostViewV2Fragment
|
||||
.builder(feedModel)
|
||||
.build();
|
||||
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 Object tag = v.getTag();
|
||||
|
@ -987,7 +987,7 @@ public final class ResponseBodyUtils {
|
||||
model.setVideoUrl(ResponseBodyUtils.getHighQualityPost(videoResources, true, true, false));
|
||||
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user