1
0
mirror of https://github.com/KokaKiwi/BarInsta synced 2024-11-26 00:27:30 +00:00
This commit is contained in:
Austin Huang 2020-12-31 20:20:46 -05:00
parent 251228dcc4
commit f85e0fc54c
No known key found for this signature in database
GPG Key ID: 84C23AA04587A91F
14 changed files with 49 additions and 15 deletions

View File

@ -554,7 +554,7 @@ public class HashTagFragment extends Fragment implements SwipeRefreshLayout.OnRe
if (!hasStories) return; if (!hasStories) return;
// show stories // show stories
final NavDirections action = HashTagFragmentDirections final NavDirections action = HashTagFragmentDirections
.actionHashtagFragmentToStoryViewerFragment(-1, null, true, false, hashtagModel.getName(), hashtagModel.getName(), false); .actionHashtagFragmentToStoryViewerFragment(-1, null, true, false, hashtagModel.getName(), hashtagModel.getName(), false, false);
NavHostFragment.findNavController(this).navigate(action); NavHostFragment.findNavController(this).navigate(action);
}); });
} }

View File

@ -523,7 +523,7 @@ public class LocationFragment extends Fragment implements SwipeRefreshLayout.OnR
if (hasStories) { if (hasStories) {
// show stories // show stories
final NavDirections action = LocationFragmentDirections final NavDirections action = LocationFragmentDirections
.actionLocationFragmentToStoryViewerFragment(-1, null, false, true, locationId, locationModel.getName(), false); .actionLocationFragmentToStoryViewerFragment(-1, null, false, true, locationId, locationModel.getName(), false, false);
NavHostFragment.findNavController(this).navigate(action); NavHostFragment.findNavController(this).navigate(action);
} }
}); });

View File

@ -77,7 +77,7 @@ public final class NotificationsViewerFragment extends Fragment implements Swipe
public void onPreviewClick(final NotificationModel model) { public void onPreviewClick(final NotificationModel model) {
if (model.getType() == NotificationType.RESPONDED_STORY) { if (model.getType() == NotificationType.RESPONDED_STORY) {
final NavDirections action = NotificationsViewerFragmentDirections.actionNotificationsViewerFragmentToStoryViewerFragment( final NavDirections action = NotificationsViewerFragmentDirections.actionNotificationsViewerFragmentToStoryViewerFragment(
-1, null, false, false, model.getPostId(), model.getUsername(), false); -1, null, false, false, model.getPostId(), model.getUsername(), false, true);
NavHostFragment.findNavController(NotificationsViewerFragment.this).navigate(action); NavHostFragment.findNavController(NotificationsViewerFragment.this).navigate(action);
} }
else { else {
@ -155,7 +155,7 @@ public final class NotificationsViewerFragment extends Fragment implements Swipe
} }
else if (model.getType() == NotificationType.RESPONDED_STORY) { else if (model.getType() == NotificationType.RESPONDED_STORY) {
final NavDirections action = NotificationsViewerFragmentDirections.actionNotificationsViewerFragmentToStoryViewerFragment( final NavDirections action = NotificationsViewerFragmentDirections.actionNotificationsViewerFragmentToStoryViewerFragment(
-1, null, false, false, model.getPostId(), model.getUsername(), false); -1, null, false, false, model.getPostId(), model.getUsername(), false, true);
NavHostFragment.findNavController(NotificationsViewerFragment.this).navigate(action); NavHostFragment.findNavController(NotificationsViewerFragment.this).navigate(action);
return; return;
} }

View File

@ -63,7 +63,7 @@ public final class StoryListViewerFragment extends Fragment implements SwipeRefr
@Override @Override
public void onFeedStoryClick(final FeedStoryModel model, final int position) { public void onFeedStoryClick(final FeedStoryModel model, final int position) {
if (model == null) return; if (model == null) return;
final NavDirections action = StoryListViewerFragmentDirections.actionStoryListFragmentToStoryViewerFragment(position, null, false, false, null, null, false); final NavDirections action = StoryListViewerFragmentDirections.actionStoryListFragmentToStoryViewerFragment(position, null, false, false, null, null, false, false);
NavHostFragment.findNavController(StoryListViewerFragment.this).navigate(action); NavHostFragment.findNavController(StoryListViewerFragment.this).navigate(action);
} }
@ -78,7 +78,7 @@ public final class StoryListViewerFragment extends Fragment implements SwipeRefr
public void onHighlightClick(final HighlightModel model, final int position) { public void onHighlightClick(final HighlightModel model, final int position) {
if (model == null) return; if (model == null) return;
final NavDirections action = StoryListViewerFragmentDirections.actionStoryListFragmentToStoryViewerFragment( final NavDirections action = StoryListViewerFragmentDirections.actionStoryListFragmentToStoryViewerFragment(
position, getString(R.string.action_archive), false, false, null, null, true); position, getString(R.string.action_archive), false, false, null, null, true, false);
NavHostFragment.findNavController(StoryListViewerFragment.this).navigate(action); NavHostFragment.findNavController(StoryListViewerFragment.this).navigate(action);
} }
@ -138,6 +138,13 @@ public final class StoryListViewerFragment extends Fragment implements SwipeRefr
shouldRefresh = false; shouldRefresh = false;
} }
@Override
public void onResume() {
super.onResume();
final ActionBar actionBar = fragmentActivity.getSupportActionBar();
if (actionBar != null) actionBar.setTitle(type == "feed" ? R.string.feed_stories : R.string.action_archive);
}
@Override @Override
public void onDestroy() { public void onDestroy() {
if (archivesViewModel != null) archivesViewModel.getList().postValue(null); if (archivesViewModel != null) archivesViewModel.getList().postValue(null);

View File

@ -133,14 +133,13 @@ public class StoryViewerFragment extends Fragment {
private SimpleExoPlayer player; private SimpleExoPlayer player;
private boolean isHashtag, isLoc; private boolean isHashtag, isLoc;
private String highlight; private String highlight;
private boolean fetching = false, sticking = false; private boolean fetching = false, sticking = false, shouldRefresh = true;
private int currentFeedStoryIndex; private int currentFeedStoryIndex;
private double sliderValue; private double sliderValue;
private StoriesViewModel storiesViewModel; private StoriesViewModel storiesViewModel;
private boolean shouldRefresh = true;
private StoryViewerFragmentArgs fragmentArgs; private StoryViewerFragmentArgs fragmentArgs;
private ViewModel viewModel; private ViewModel viewModel;
private boolean isHighlight, isArchive; private boolean isHighlight, isArchive, isNotification;
private final String cookie = settingsHelper.getString(Constants.COOKIE); private final String cookie = settingsHelper.getString(Constants.COOKIE);
@ -258,6 +257,7 @@ public class StoryViewerFragment extends Fragment {
highlight = fragmentArgs.getHighlight(); highlight = fragmentArgs.getHighlight();
isHighlight = !TextUtils.isEmpty(highlight); isHighlight = !TextUtils.isEmpty(highlight);
isArchive = fragmentArgs.getIsArchive(); isArchive = fragmentArgs.getIsArchive();
isNotification = fragmentArgs.getIsNotification();
if (currentFeedStoryIndex >= 0) { if (currentFeedStoryIndex >= 0) {
viewModel = isHighlight viewModel = isHighlight
? isArchive ? isArchive
@ -693,7 +693,7 @@ public class StoryViewerFragment extends Fragment {
} }
storiesViewModel.getList().setValue(Collections.emptyList()); storiesViewModel.getList().setValue(Collections.emptyList());
if (currentStoryMediaId == null) return; if (currentStoryMediaId == null) return;
else if (currentFeedStoryIndex == -1) { else if (isNotification) {
storiesService.fetch(currentStoryMediaId, new ServiceCallback<StoryModel>() { storiesService.fetch(currentStoryMediaId, new ServiceCallback<StoryModel>() {
@Override @Override
public void onSuccess(final StoryModel storyModel) { public void onSuccess(final StoryModel storyModel) {
@ -728,7 +728,9 @@ public class StoryViewerFragment extends Fragment {
binding.storiesList.setVisibility(View.GONE); binding.storiesList.setVisibility(View.GONE);
return; return;
} }
binding.storiesList.setVisibility(View.VISIBLE); binding.storiesList.setVisibility((storyModels.size() == 1 && currentFeedStoryIndex == -1) ? View.GONE : View.VISIBLE);
binding.btnBackward.setVisibility(currentFeedStoryIndex == -1 ? View.GONE : View.VISIBLE);
binding.btnForward.setVisibility(currentFeedStoryIndex == -1 ? View.GONE : View.VISIBLE);
storiesViewModel.getList().setValue(storyModels); storiesViewModel.getList().setValue(storyModels);
currentStory = storyModels.get(0); currentStory = storyModels.get(0);
refreshStory(); refreshStory();

View File

@ -357,7 +357,7 @@ public class FeedFragment extends Fragment implements SwipeRefreshLayout.OnRefre
new FeedStoriesAdapter.OnFeedStoryClickListener() { new FeedStoriesAdapter.OnFeedStoryClickListener() {
@Override @Override
public void onFeedStoryClick(FeedStoryModel model, int position) { public void onFeedStoryClick(FeedStoryModel model, int position) {
final NavDirections action = FeedFragmentDirections.actionFeedFragmentToStoryViewerFragment(position, null, false, false, null, null, false); final NavDirections action = FeedFragmentDirections.actionFeedFragmentToStoryViewerFragment(position, null, false, false, null, null, false, false);
NavHostFragment.findNavController(FeedFragment.this).navigate(action); NavHostFragment.findNavController(FeedFragment.this).navigate(action);
} }

View File

@ -1008,7 +1008,7 @@ public class ProfileFragment extends Fragment implements SwipeRefreshLayout.OnRe
if (which == 1) { if (which == 1) {
// show stories // show stories
final NavDirections action = ProfileFragmentDirections final NavDirections action = ProfileFragmentDirections
.actionProfileFragmentToStoryViewerFragment(-1, null, false, false, profileModel.getId(), username, false); .actionProfileFragmentToStoryViewerFragment(-1, null, false, false, profileModel.getId(), username, false, false);
NavHostFragment.findNavController(this).navigate(action); NavHostFragment.findNavController(this).navigate(action);
return; return;
} }
@ -1069,7 +1069,7 @@ public class ProfileFragment extends Fragment implements SwipeRefreshLayout.OnRe
highlightsViewModel = new ViewModelProvider(fragmentActivity).get(HighlightsViewModel.class); highlightsViewModel = new ViewModelProvider(fragmentActivity).get(HighlightsViewModel.class);
highlightsAdapter = new HighlightsAdapter((model, position) -> { highlightsAdapter = new HighlightsAdapter((model, position) -> {
final NavDirections action = ProfileFragmentDirections final NavDirections action = ProfileFragmentDirections
.actionProfileFragmentToStoryViewerFragment(position, model.getTitle(), false, false, null, null, false); .actionProfileFragmentToStoryViewerFragment(position, model.getTitle(), false, false, null, null, false, false);
NavHostFragment.findNavController(this).navigate(action); NavHostFragment.findNavController(this).navigate(action);
}); });
final Context context = getContext(); final Context context = getContext();

View File

@ -217,7 +217,7 @@ public class StoriesService extends BaseService {
null, null,
highlightNode.getString(Constants.EXTRAS_ID), highlightNode.getString(Constants.EXTRAS_ID),
highlightNode.getJSONObject("cover_image_version").getString("url"), highlightNode.getJSONObject("cover_image_version").getString("url"),
highlightNode.getLong("timestamp"), highlightNode.getLong("latest_reel_media"),
highlightNode.getInt("media_count") highlightNode.getInt("media_count")
)); ));
} }
@ -246,6 +246,7 @@ public class StoriesService extends BaseService {
final boolean highlight, final boolean highlight,
final ServiceCallback<List<StoryModel>> callback) { final ServiceCallback<List<StoryModel>> callback) {
final String url = buildUrl(id, isLoc, isHashtag, highlight); final String url = buildUrl(id, isLoc, isHashtag, highlight);
Log.d("austin_debug", url);
final Call<String> userStoryCall = repository.getUserStory(Constants.I_USER_AGENT, url); final Call<String> userStoryCall = repository.getUserStory(Constants.I_USER_AGENT, url);
userStoryCall.enqueue(new Callback<String>() { userStoryCall.enqueue(new Callback<String>() {
@Override @Override

View File

@ -134,5 +134,9 @@
android:name="isArchive" android:name="isArchive"
app:argType="boolean" app:argType="boolean"
app:nullable="false" /> app:nullable="false" />
<argument
android:name="isNotification"
app:argType="boolean"
app:nullable="false" />
</fragment> </fragment>
</navigation> </navigation>

View File

@ -101,6 +101,10 @@
android:name="isArchive" android:name="isArchive"
app:argType="boolean" app:argType="boolean"
app:nullable="false" /> app:nullable="false" />
<argument
android:name="isNotification"
app:argType="boolean"
app:nullable="false" />
</fragment> </fragment>
<action <action
android:id="@+id/action_global_hashTagFragment" android:id="@+id/action_global_hashTagFragment"

View File

@ -109,5 +109,9 @@
android:name="isArchive" android:name="isArchive"
app:argType="boolean" app:argType="boolean"
app:nullable="false" /> app:nullable="false" />
<argument
android:name="isNotification"
app:argType="boolean"
app:nullable="false" />
</fragment> </fragment>
</navigation> </navigation>

View File

@ -93,5 +93,9 @@
android:name="isArchive" android:name="isArchive"
app:argType="boolean" app:argType="boolean"
app:nullable="false" /> app:nullable="false" />
<argument
android:name="isNotification"
app:argType="boolean"
app:nullable="false" />
</fragment> </fragment>
</navigation> </navigation>

View File

@ -183,6 +183,10 @@
android:name="isArchive" android:name="isArchive"
app:argType="boolean" app:argType="boolean"
app:nullable="false" /> app:nullable="false" />
<argument
android:name="isNotification"
app:argType="boolean"
app:nullable="false" />
</fragment> </fragment>
<fragment <fragment
android:id="@+id/directMessagesThreadFragment" android:id="@+id/directMessagesThreadFragment"

View File

@ -68,5 +68,9 @@
android:name="isArchive" android:name="isArchive"
app:argType="boolean" app:argType="boolean"
app:nullable="false" /> app:nullable="false" />
<argument
android:name="isNotification"
app:argType="boolean"
app:nullable="false" />
</fragment> </fragment>
</navigation> </navigation>