mirror of
https://github.com/KokaKiwi/BarInsta
synced 2024-11-14 18:57:30 +00:00
fix observer delegations
This commit is contained in:
parent
57ffd32c83
commit
d106ac5c0a
@ -213,7 +213,7 @@ class StoryViewerFragment : Fragment() {
|
|||||||
storiesViewModel.setMedia(position)
|
storiesViewModel.setMedia(position)
|
||||||
}
|
}
|
||||||
binding.storiesList.adapter = storiesAdapter
|
binding.storiesList.adapter = storiesAdapter
|
||||||
storiesViewModel.getCurrentStory().observe(viewLifecycleOwner, {
|
storiesViewModel.getCurrentStory().observe(fragmentActivity, {
|
||||||
if (it?.items != null && it.items.size > 1) {
|
if (it?.items != null && it.items.size > 1) {
|
||||||
val storyMedias = it.items.toMutableList()
|
val storyMedias = it.items.toMutableList()
|
||||||
val newItem = storyMedias.get(0)
|
val newItem = storyMedias.get(0)
|
||||||
@ -231,19 +231,19 @@ class StoryViewerFragment : Fragment() {
|
|||||||
binding.storiesList.visibility = View.GONE
|
binding.storiesList.visibility = View.GONE
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
storiesViewModel.getDate().observe(viewLifecycleOwner, {
|
storiesViewModel.getDate().observe(fragmentActivity, {
|
||||||
val actionBar = fragmentActivity.supportActionBar
|
val actionBar = fragmentActivity.supportActionBar
|
||||||
if (actionBar != null && it != null) actionBar.subtitle = it
|
if (actionBar != null && it != null) actionBar.subtitle = it
|
||||||
})
|
})
|
||||||
storiesViewModel.getTitle().observe(viewLifecycleOwner, {
|
storiesViewModel.getTitle().observe(fragmentActivity, {
|
||||||
val actionBar = fragmentActivity.supportActionBar
|
val actionBar = fragmentActivity.supportActionBar
|
||||||
if (actionBar != null && it != null) actionBar.title = it
|
if (actionBar != null && it != null) actionBar.title = it
|
||||||
})
|
})
|
||||||
storiesViewModel.getCurrentMedia().observe(viewLifecycleOwner, { refreshStory(it) })
|
storiesViewModel.getCurrentMedia().observe(fragmentActivity, { refreshStory(it) })
|
||||||
storiesViewModel.getCurrentIndex().observe(viewLifecycleOwner, {
|
storiesViewModel.getCurrentIndex().observe(fragmentActivity, {
|
||||||
storiesAdapter!!.paginate(it)
|
storiesAdapter!!.paginate(it)
|
||||||
})
|
})
|
||||||
storiesViewModel.getOptions().observe(viewLifecycleOwner, {
|
storiesViewModel.getOptions().observe(fragmentActivity, {
|
||||||
binding.stickers.isEnabled = it.first.size > 0
|
binding.stickers.isEnabled = it.first.size > 0
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -268,7 +268,7 @@ class StoryViewerFragment : Fragment() {
|
|||||||
when (type) {
|
when (type) {
|
||||||
StoryViewerOptions.Type.HIGHLIGHT -> {
|
StoryViewerOptions.Type.HIGHLIGHT -> {
|
||||||
storiesViewModel.fetchHighlights(options!!.id)
|
storiesViewModel.fetchHighlights(options!!.id)
|
||||||
storiesViewModel.highlights.observe(viewLifecycleOwner) {
|
storiesViewModel.highlights.observe(fragmentActivity) {
|
||||||
setupMultipage(it)
|
setupMultipage(it)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -319,7 +319,7 @@ class StoryViewerFragment : Fragment() {
|
|||||||
|
|
||||||
private fun setupMultipage(models: List<Story>?) {
|
private fun setupMultipage(models: List<Story>?) {
|
||||||
if (models == null) return
|
if (models == null) return
|
||||||
storiesViewModel.getPagination().observe(viewLifecycleOwner, {
|
storiesViewModel.getPagination().observe(fragmentActivity, {
|
||||||
when (it) {
|
when (it) {
|
||||||
StoryPaginationType.FORWARD -> {
|
StoryPaginationType.FORWARD -> {
|
||||||
if (currentFeedStoryIndex == models.size - 1)
|
if (currentFeedStoryIndex == models.size - 1)
|
||||||
|
@ -319,14 +319,6 @@ public class FeedFragment extends Fragment implements SwipeRefreshLayout.OnRefre
|
|||||||
return super.onOptionsItemSelected(item);
|
return super.onOptionsItemSelected(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onResume() {
|
|
||||||
super.onResume();
|
|
||||||
// temporary fix
|
|
||||||
feedStoriesViewModel.getList().removeObservers(getViewLifecycleOwner());
|
|
||||||
feedStoriesViewModel.getList().observe(getViewLifecycleOwner(), feedStoriesAdapter::submitList);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onRefresh() {
|
public void onRefresh() {
|
||||||
binding.feedRecyclerView.refresh();
|
binding.feedRecyclerView.refresh();
|
||||||
@ -382,7 +374,7 @@ public class FeedFragment extends Fragment implements SwipeRefreshLayout.OnRefre
|
|||||||
storiesRecyclerView = binding.header;
|
storiesRecyclerView = binding.header;
|
||||||
storiesRecyclerView.setLayoutManager(new LinearLayoutManager(context, RecyclerView.HORIZONTAL, false));
|
storiesRecyclerView.setLayoutManager(new LinearLayoutManager(context, RecyclerView.HORIZONTAL, false));
|
||||||
storiesRecyclerView.setAdapter(feedStoriesAdapter);
|
storiesRecyclerView.setAdapter(feedStoriesAdapter);
|
||||||
feedStoriesViewModel.getList().observe(getViewLifecycleOwner(), feedStoriesAdapter::submitList);
|
feedStoriesViewModel.getList().observe(fragmentActivity, feedStoriesAdapter::submitList);
|
||||||
fetchStories();
|
fetchStories();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user