mirror of
				https://github.com/KokaKiwi/BarInsta
				synced 2025-11-04 05:25:35 +00:00 
			
		
		
		
	fix story notifications
This commit is contained in:
		
							parent
							
								
									d21df4d21b
								
							
						
					
					
						commit
						d2e3f6c4df
					
				@ -43,7 +43,6 @@ import awais.instagrabber.utils.DownloadUtils;
 | 
			
		||||
import awais.instagrabber.utils.TextUtils;
 | 
			
		||||
import awais.instagrabber.webservices.ProfileService;
 | 
			
		||||
import awais.instagrabber.webservices.ServiceCallback;
 | 
			
		||||
import awais.instagrabber.webservices.StoriesService;
 | 
			
		||||
 | 
			
		||||
import static awais.instagrabber.utils.Utils.settingsHelper;
 | 
			
		||||
 | 
			
		||||
@ -104,8 +103,7 @@ public class ProfilePicDialogFragment extends DialogFragment {
 | 
			
		||||
    public void onViewCreated(@NonNull final View view, @Nullable final Bundle savedInstanceState) {
 | 
			
		||||
        super.onViewCreated(view, savedInstanceState);
 | 
			
		||||
        init();
 | 
			
		||||
        if (id.contains("_")) fetchStory();
 | 
			
		||||
        else fetchAvatar();
 | 
			
		||||
        fetchAvatar();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private void init() {
 | 
			
		||||
@ -150,26 +148,6 @@ public class ProfilePicDialogFragment extends DialogFragment {
 | 
			
		||||
        else new ProfilePictureFetcher(name, id, fetchListener, fallbackUrl, false).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private void fetchStory() {
 | 
			
		||||
        final StoriesService storiesService = StoriesService.getInstance();
 | 
			
		||||
        storiesService.fetch(id, new ServiceCallback<StoryModel>() {
 | 
			
		||||
            @Override
 | 
			
		||||
            public void onSuccess(final StoryModel result) {
 | 
			
		||||
                if (result != null) {
 | 
			
		||||
                    fetchListener.onResult(result.getStoryUrl());
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            @Override
 | 
			
		||||
            public void onFailure(final Throwable t) {
 | 
			
		||||
                final Context context = getContext();
 | 
			
		||||
                Log.d("austin_debug", "error", t);
 | 
			
		||||
                Toast.makeText(context, R.string.downloader_unknown_error, Toast.LENGTH_SHORT).show();
 | 
			
		||||
                getDialog().dismiss();
 | 
			
		||||
            }
 | 
			
		||||
        });
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private void setupPhoto() {
 | 
			
		||||
        if (TextUtils.isEmpty(url)) {
 | 
			
		||||
            url = fallbackUrl;
 | 
			
		||||
 | 
			
		||||
@ -75,7 +75,9 @@ public final class NotificationsViewerFragment extends Fragment implements Swipe
 | 
			
		||||
        @Override
 | 
			
		||||
        public void onPreviewClick(final NotificationModel model) {
 | 
			
		||||
            if (model.getType() == NotificationType.RESPONDED_STORY) {
 | 
			
		||||
                showProfilePicDialog(model);
 | 
			
		||||
                final NavDirections action = NotificationsViewerFragmentDirections.actionNotificationsViewerFragmentToStoryViewerFragment(
 | 
			
		||||
                        -1, null, false, false, model.getPostId(), model.getUsername(), false);
 | 
			
		||||
                NavHostFragment.findNavController(NotificationsViewerFragment.this).navigate(action);
 | 
			
		||||
            }
 | 
			
		||||
            else {
 | 
			
		||||
                mediaService.fetch(model.getPostId(), new ServiceCallback<FeedModel>() {
 | 
			
		||||
@ -151,7 +153,9 @@ public final class NotificationsViewerFragment extends Fragment implements Swipe
 | 
			
		||||
                                return;
 | 
			
		||||
                            }
 | 
			
		||||
                            else if (model.getType() == NotificationType.RESPONDED_STORY) {
 | 
			
		||||
                                showProfilePicDialog(model);
 | 
			
		||||
                                final NavDirections action = NotificationsViewerFragmentDirections.actionNotificationsViewerFragmentToStoryViewerFragment(
 | 
			
		||||
                                        -1, null, false, false, model.getPostId(), model.getUsername(), false);
 | 
			
		||||
                                NavHostFragment.findNavController(NotificationsViewerFragment.this).navigate(action);
 | 
			
		||||
                                return;
 | 
			
		||||
                            }
 | 
			
		||||
                            final AlertDialog alertDialog = new AlertDialog.Builder(context)
 | 
			
		||||
@ -292,15 +296,4 @@ public final class NotificationsViewerFragment extends Fragment implements Swipe
 | 
			
		||||
                .actionGlobalProfileFragment("@" + username);
 | 
			
		||||
        NavHostFragment.findNavController(this).navigate(action);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private void showProfilePicDialog(final NotificationModel model) {
 | 
			
		||||
        final FragmentManager fragmentManager = getParentFragmentManager();
 | 
			
		||||
        final ProfilePicDialogFragment fragment = new ProfilePicDialogFragment(model.getPostId(),
 | 
			
		||||
                                                                               model.getUsername(),
 | 
			
		||||
                                                                               model.getPreviewPic());
 | 
			
		||||
        final FragmentTransaction ft = fragmentManager.beginTransaction();
 | 
			
		||||
        ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN)
 | 
			
		||||
                .add(fragment, "profilePicDialog")
 | 
			
		||||
                .commit();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@ -74,6 +74,7 @@ import awais.instagrabber.asyncs.direct_messages.CreateThreadAction;
 | 
			
		||||
import awais.instagrabber.asyncs.direct_messages.DirectThreadBroadcaster;
 | 
			
		||||
import awais.instagrabber.customviews.helpers.SwipeGestureListener;
 | 
			
		||||
import awais.instagrabber.databinding.FragmentStoryViewerBinding;
 | 
			
		||||
import awais.instagrabber.fragments.main.FeedFragment;
 | 
			
		||||
import awais.instagrabber.fragments.main.ProfileFragmentDirections;
 | 
			
		||||
import awais.instagrabber.interfaces.SwipeEvent;
 | 
			
		||||
import awais.instagrabber.models.FeedStoryModel;
 | 
			
		||||
@ -692,6 +693,29 @@ public class StoryViewerFragment extends Fragment {
 | 
			
		||||
        }
 | 
			
		||||
        storiesViewModel.getList().setValue(Collections.emptyList());
 | 
			
		||||
        if (currentStoryMediaId == null) return;
 | 
			
		||||
        else if (currentFeedStoryIndex == -1) {
 | 
			
		||||
            storiesService.fetch(currentStoryMediaId, new ServiceCallback<StoryModel>() {
 | 
			
		||||
                @Override
 | 
			
		||||
                public void onSuccess(final StoryModel storyModel) {
 | 
			
		||||
                    fetching = false;
 | 
			
		||||
                    binding.storiesList.setVisibility(View.GONE);
 | 
			
		||||
                    if (storyModel == null) {
 | 
			
		||||
                        storiesViewModel.getList().setValue(Collections.emptyList());
 | 
			
		||||
                        currentStory = null;
 | 
			
		||||
                        return;
 | 
			
		||||
                    }
 | 
			
		||||
                    storiesViewModel.getList().setValue(Collections.singletonList(storyModel));
 | 
			
		||||
                    currentStory = storyModel;
 | 
			
		||||
                    refreshStory();
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                @Override
 | 
			
		||||
                public void onFailure(final Throwable t) {
 | 
			
		||||
                    Log.e(TAG, "Error", t);
 | 
			
		||||
                }
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
        else {
 | 
			
		||||
            final ServiceCallback<List<StoryModel>> storyCallback = new ServiceCallback<List<StoryModel>>() {
 | 
			
		||||
                @Override
 | 
			
		||||
                public void onSuccess(final List<StoryModel> storyModels) {
 | 
			
		||||
@ -720,6 +744,7 @@ public class StoryViewerFragment extends Fragment {
 | 
			
		||||
                    isHighlight,
 | 
			
		||||
                    storyCallback);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private void refreshStory() {
 | 
			
		||||
        if (binding.storiesList.getVisibility() == View.VISIBLE) {
 | 
			
		||||
 | 
			
		||||
@ -14,6 +14,9 @@
 | 
			
		||||
            android:name="type"
 | 
			
		||||
            app:argType="string"
 | 
			
		||||
            app:nullable="false" />
 | 
			
		||||
        <action
 | 
			
		||||
            android:id="@+id/action_notificationsViewerFragment_to_storyViewerFragment"
 | 
			
		||||
            app:destination="@id/storyViewerFragment" />
 | 
			
		||||
    </fragment>
 | 
			
		||||
 | 
			
		||||
    <action
 | 
			
		||||
@ -58,4 +61,37 @@
 | 
			
		||||
            app:argType="boolean"
 | 
			
		||||
            app:nullable="false" />
 | 
			
		||||
    </action>
 | 
			
		||||
 | 
			
		||||
    <fragment
 | 
			
		||||
        android:id="@+id/storyViewerFragment"
 | 
			
		||||
        android:name="awais.instagrabber.fragments.StoryViewerFragment"
 | 
			
		||||
        android:label="StoryViewerFragment"
 | 
			
		||||
        tools:layout="@layout/fragment_story_viewer">
 | 
			
		||||
        <argument
 | 
			
		||||
            android:name="feedStoryIndex"
 | 
			
		||||
            app:argType="integer"
 | 
			
		||||
            app:nullable="false" />
 | 
			
		||||
        <argument
 | 
			
		||||
            android:name="highlight"
 | 
			
		||||
            app:argType="string"
 | 
			
		||||
            app:nullable="true" />
 | 
			
		||||
        <argument
 | 
			
		||||
            android:name="isHashtag"
 | 
			
		||||
            app:argType="boolean" />
 | 
			
		||||
        <argument
 | 
			
		||||
            android:name="isLoc"
 | 
			
		||||
            app:argType="boolean" />
 | 
			
		||||
        <argument
 | 
			
		||||
            android:name="profileId"
 | 
			
		||||
            app:argType="string"
 | 
			
		||||
            app:nullable="true" />
 | 
			
		||||
        <argument
 | 
			
		||||
            android:name="username"
 | 
			
		||||
            app:argType="string"
 | 
			
		||||
            app:nullable="true" />
 | 
			
		||||
        <argument
 | 
			
		||||
            android:name="isArchive"
 | 
			
		||||
            app:argType="boolean"
 | 
			
		||||
            app:nullable="false" />
 | 
			
		||||
    </fragment>
 | 
			
		||||
</navigation>
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user