mirror of
https://github.com/KokaKiwi/BarInsta
synced 2024-11-22 14:47:29 +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.utils.TextUtils;
|
||||||
import awais.instagrabber.webservices.ProfileService;
|
import awais.instagrabber.webservices.ProfileService;
|
||||||
import awais.instagrabber.webservices.ServiceCallback;
|
import awais.instagrabber.webservices.ServiceCallback;
|
||||||
import awais.instagrabber.webservices.StoriesService;
|
|
||||||
|
|
||||||
import static awais.instagrabber.utils.Utils.settingsHelper;
|
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) {
|
public void onViewCreated(@NonNull final View view, @Nullable final Bundle savedInstanceState) {
|
||||||
super.onViewCreated(view, savedInstanceState);
|
super.onViewCreated(view, savedInstanceState);
|
||||||
init();
|
init();
|
||||||
if (id.contains("_")) fetchStory();
|
fetchAvatar();
|
||||||
else fetchAvatar();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void init() {
|
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);
|
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() {
|
private void setupPhoto() {
|
||||||
if (TextUtils.isEmpty(url)) {
|
if (TextUtils.isEmpty(url)) {
|
||||||
url = fallbackUrl;
|
url = fallbackUrl;
|
||||||
|
@ -75,7 +75,9 @@ public final class NotificationsViewerFragment extends Fragment implements Swipe
|
|||||||
@Override
|
@Override
|
||||||
public void onPreviewClick(final NotificationModel model) {
|
public void onPreviewClick(final NotificationModel model) {
|
||||||
if (model.getType() == NotificationType.RESPONDED_STORY) {
|
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 {
|
else {
|
||||||
mediaService.fetch(model.getPostId(), new ServiceCallback<FeedModel>() {
|
mediaService.fetch(model.getPostId(), new ServiceCallback<FeedModel>() {
|
||||||
@ -151,7 +153,9 @@ public final class NotificationsViewerFragment extends Fragment implements Swipe
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (model.getType() == NotificationType.RESPONDED_STORY) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
final AlertDialog alertDialog = new AlertDialog.Builder(context)
|
final AlertDialog alertDialog = new AlertDialog.Builder(context)
|
||||||
@ -292,15 +296,4 @@ public final class NotificationsViewerFragment extends Fragment implements Swipe
|
|||||||
.actionGlobalProfileFragment("@" + username);
|
.actionGlobalProfileFragment("@" + username);
|
||||||
NavHostFragment.findNavController(this).navigate(action);
|
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.asyncs.direct_messages.DirectThreadBroadcaster;
|
||||||
import awais.instagrabber.customviews.helpers.SwipeGestureListener;
|
import awais.instagrabber.customviews.helpers.SwipeGestureListener;
|
||||||
import awais.instagrabber.databinding.FragmentStoryViewerBinding;
|
import awais.instagrabber.databinding.FragmentStoryViewerBinding;
|
||||||
|
import awais.instagrabber.fragments.main.FeedFragment;
|
||||||
import awais.instagrabber.fragments.main.ProfileFragmentDirections;
|
import awais.instagrabber.fragments.main.ProfileFragmentDirections;
|
||||||
import awais.instagrabber.interfaces.SwipeEvent;
|
import awais.instagrabber.interfaces.SwipeEvent;
|
||||||
import awais.instagrabber.models.FeedStoryModel;
|
import awais.instagrabber.models.FeedStoryModel;
|
||||||
@ -692,33 +693,57 @@ public class StoryViewerFragment extends Fragment {
|
|||||||
}
|
}
|
||||||
storiesViewModel.getList().setValue(Collections.emptyList());
|
storiesViewModel.getList().setValue(Collections.emptyList());
|
||||||
if (currentStoryMediaId == null) return;
|
if (currentStoryMediaId == null) return;
|
||||||
final ServiceCallback<List<StoryModel>> storyCallback = new ServiceCallback<List<StoryModel>>() {
|
else if (currentFeedStoryIndex == -1) {
|
||||||
@Override
|
storiesService.fetch(currentStoryMediaId, new ServiceCallback<StoryModel>() {
|
||||||
public void onSuccess(final List<StoryModel> storyModels) {
|
@Override
|
||||||
fetching = false;
|
public void onSuccess(final StoryModel storyModel) {
|
||||||
if (storyModels == null || storyModels.isEmpty()) {
|
fetching = false;
|
||||||
storiesViewModel.getList().setValue(Collections.emptyList());
|
|
||||||
currentStory = null;
|
|
||||||
binding.storiesList.setVisibility(View.GONE);
|
binding.storiesList.setVisibility(View.GONE);
|
||||||
return;
|
if (storyModel == null) {
|
||||||
|
storiesViewModel.getList().setValue(Collections.emptyList());
|
||||||
|
currentStory = null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
storiesViewModel.getList().setValue(Collections.singletonList(storyModel));
|
||||||
|
currentStory = storyModel;
|
||||||
|
refreshStory();
|
||||||
}
|
}
|
||||||
binding.storiesList.setVisibility(View.VISIBLE);
|
|
||||||
storiesViewModel.getList().setValue(storyModels);
|
|
||||||
currentStory = storyModels.get(0);
|
|
||||||
refreshStory();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(final Throwable t) {
|
public void onFailure(final Throwable t) {
|
||||||
Log.e(TAG, "Error", t);
|
Log.e(TAG, "Error", t);
|
||||||
}
|
}
|
||||||
};
|
});
|
||||||
storiesService.getUserStory(currentStoryMediaId,
|
}
|
||||||
currentStoryUsername,
|
else {
|
||||||
isLoc,
|
final ServiceCallback<List<StoryModel>> storyCallback = new ServiceCallback<List<StoryModel>>() {
|
||||||
isHashtag,
|
@Override
|
||||||
isHighlight,
|
public void onSuccess(final List<StoryModel> storyModels) {
|
||||||
storyCallback);
|
fetching = false;
|
||||||
|
if (storyModels == null || storyModels.isEmpty()) {
|
||||||
|
storiesViewModel.getList().setValue(Collections.emptyList());
|
||||||
|
currentStory = null;
|
||||||
|
binding.storiesList.setVisibility(View.GONE);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
binding.storiesList.setVisibility(View.VISIBLE);
|
||||||
|
storiesViewModel.getList().setValue(storyModels);
|
||||||
|
currentStory = storyModels.get(0);
|
||||||
|
refreshStory();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFailure(final Throwable t) {
|
||||||
|
Log.e(TAG, "Error", t);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
storiesService.getUserStory(currentStoryMediaId,
|
||||||
|
currentStoryUsername,
|
||||||
|
isLoc,
|
||||||
|
isHashtag,
|
||||||
|
isHighlight,
|
||||||
|
storyCallback);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void refreshStory() {
|
private void refreshStory() {
|
||||||
|
@ -14,6 +14,9 @@
|
|||||||
android:name="type"
|
android:name="type"
|
||||||
app:argType="string"
|
app:argType="string"
|
||||||
app:nullable="false" />
|
app:nullable="false" />
|
||||||
|
<action
|
||||||
|
android:id="@+id/action_notificationsViewerFragment_to_storyViewerFragment"
|
||||||
|
app:destination="@id/storyViewerFragment" />
|
||||||
</fragment>
|
</fragment>
|
||||||
|
|
||||||
<action
|
<action
|
||||||
@ -58,4 +61,37 @@
|
|||||||
app:argType="boolean"
|
app:argType="boolean"
|
||||||
app:nullable="false" />
|
app:nullable="false" />
|
||||||
</action>
|
</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>
|
</navigation>
|
Loading…
Reference in New Issue
Block a user