Skip to content

Commit

Permalink
Use user specified Locale in BaseStatePageAdapter::setPagerTitles()
Browse files Browse the repository at this point in the history
This is a hacky solution for wrong ViewPager titles.

Closes: #483
  • Loading branch information
luk1337 committed Jul 21, 2022
1 parent 0ff2761 commit 3467e9d
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
package com.mxt.anitrend.base.custom.pager;

import android.content.Context;
import android.content.res.Configuration;
import android.os.Bundle;

import androidx.annotation.ArrayRes;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentStatePagerAdapter;

import com.mxt.anitrend.extension.KoinExt;
import com.mxt.anitrend.util.Settings;

import java.util.Locale;

/**
Expand All @@ -27,7 +31,9 @@ public BaseStatePageAdapter(FragmentManager fragmentManager, Context context) {
}

public void setPagerTitles(@ArrayRes int mTitleRes) {
mTitles = context.getResources().getStringArray(mTitleRes);
Configuration configuration = new Configuration(context.getResources().getConfiguration());
configuration.setLocale(new Locale(KoinExt.get(Settings.class).getUserLanguage()));
mTitles = context.createConfigurationContext(configuration).getResources().getStringArray(mTitleRes);
}

public String[] getPagerTitles() {
Expand Down

0 comments on commit 3467e9d

Please sign in to comment.