From 3467e9de660600db3068479895dbb2006017a7af Mon Sep 17 00:00:00 2001 From: LuK1337 Date: Thu, 21 Jul 2022 22:13:09 +0200 Subject: [PATCH] Use user specified Locale in BaseStatePageAdapter::setPagerTitles() This is a hacky solution for wrong ViewPager titles. Closes: #483 --- .../anitrend/base/custom/pager/BaseStatePageAdapter.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/mxt/anitrend/base/custom/pager/BaseStatePageAdapter.java b/app/src/main/java/com/mxt/anitrend/base/custom/pager/BaseStatePageAdapter.java index 5dd07776d..019a0d209 100644 --- a/app/src/main/java/com/mxt/anitrend/base/custom/pager/BaseStatePageAdapter.java +++ b/app/src/main/java/com/mxt/anitrend/base/custom/pager/BaseStatePageAdapter.java @@ -1,6 +1,7 @@ package com.mxt.anitrend.base.custom.pager; import android.content.Context; +import android.content.res.Configuration; import android.os.Bundle; import androidx.annotation.ArrayRes; @@ -8,6 +9,9 @@ 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; /** @@ -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() {