Posts

Showing posts with the label android-viewpager

How to set a priority of retrofit requests

How to set a priority of retrofit requests I have ViewPager and in this ViewPager there are 4 fragments. Sorry but I can't to add a code, because that would be very big. Each of my fragments on create does asynchronous retrofit request to server. I have access_token and refresh_token too. So when my access_token expires I need to do a call using refresh_token to update my access_token . So when I launch my application it opens viewPager with my 4 fragments doing asynchronous requests. That means 4 requests at a time. And when my access_token is expired and I'm launching my app, all the fragments try to update the access token using refresh token. Turns out that one fragment updates the access_token (after the update refresh_token changes) other fragments try to update the token too, but I'm getting 401 because 1 fragment already updated the token and other fragments try to update the access_token using old refresh token. ViewPager access_token refresh_token access_tok...

Tabs of TabLayout not showing

Tabs of TabLayout not showing I have a main activity, which hosts a fragment, which in turn hosts a TabLayout (with a ViewPager). The tab bar is shown, baut the tabs themselves are not shown. Here is my code in the main activity for displaying the host fragment: Fragment fragment = new BMITabsFragment(); FragmentManager fragmentManager = getSupportFragmentManager(); fragmentManager.beginTransaction().replace(R.id.content_frame, fragment).addToBackStack(Constants.BMI_TABS_FRAGMENT).commit(); Here is my the Fragment which hosts the TabLayout, which is BMITabsFragment (s.a.): public class BMITabsFragment extends Fragment { ... @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (getArguments() != null) { mParam1 = getArguments().getString(ARG_PARAM1); mParam2 = getArguments().getString(ARG_PARAM2); } } @Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onVi...