Scenario: Assume that the bottom navigation bar contains Home fragment which can open another fragment say Product Listing. From Product Listing fragment, user can open Product Detail fragment in order to see the details of any item.
Problem: Suppose user has scrolled the list in Product Listing fragment and reached at 100th item & tapped an item to see its detail in Product Detail fragment. Now when user presses back button in order to go back in Product Listing fragment, list is being shown from start.
Is there any way or work around to overcome this issue. I want to show the 100th item to user while coming back.
Overrided method Onstart(), OnCreateView(), OnViewCreated(),OnResume() of Product Listing fragment are executed while coming back from Product Detail fragment.
View view;
Unbinder unbinder;
@Override
public View onCreateView(@NotNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
if (view == null) {
view = inflater.inflate(R.layout.product_listing_screen, container, false);
return view;
} else {
return view;
}
}
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
Timber.e("%s onViewCreated Called ", TAG);
unbinder = ButterKnife.bind(this, view);
}
@Override
public void onResume() {
super.onResume();
Timber.e("%s onResume Called ", TAG);
if (adapter == null || adapterList.size() == 0) {
updateProductListingCategory(itemId); // This is the method making a web request. And while coming back from detail fragment, it isn't called again.
}
}