diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/constant/PreferenceKeys.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/constant/PreferenceKeys.kt index fd5f62bfb..d85870e35 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/constant/PreferenceKeys.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/constant/PreferenceKeys.kt @@ -65,6 +65,7 @@ val mediaPreloadKey = KBooleanKey(KEY_MEDIA_PRELOAD, false) val mediaPreloadOnWifiOnlyKey = KBooleanKey(KEY_PRELOAD_WIFI_ONLY, true) val autoRefreshCompatibilityModeKey = KBooleanKey("auto_refresh_compatibility_mode", Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) val floatingDetailedContentsKey = KBooleanKey("floating_detailed_contents", true) +val localTrendsWoeIdKey = KIntKey(SharedPreferenceConstants.KEY_LOCAL_TRENDS_WOEID, 1) object themeBackgroundAlphaKey : KSimpleKey(KEY_THEME_BACKGROUND_ALPHA, 0xFF) { override fun read(preferences: SharedPreferences): Int { diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/TrendsSuggestionsFragment.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/TrendsSuggestionsFragment.kt index c9d6075bb..2567b3d57 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/TrendsSuggestionsFragment.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/TrendsSuggestionsFragment.kt @@ -30,10 +30,12 @@ import android.widget.AdapterView import android.widget.ListView import com.squareup.otto.Subscribe import kotlinx.android.synthetic.main.fragment_content_listview.* +import org.mariotaku.kpreferences.get import org.mariotaku.sqliteqb.library.Expression import org.mariotaku.twidere.R import org.mariotaku.twidere.adapter.TrendsAdapter import org.mariotaku.twidere.constant.IntentConstants.EXTRA_EXTRAS +import org.mariotaku.twidere.constant.localTrendsWoeIdKey import org.mariotaku.twidere.model.UserKey import org.mariotaku.twidere.model.message.TrendsRefreshedEvent import org.mariotaku.twidere.model.tab.extra.TrendsTabExtras @@ -43,13 +45,16 @@ import org.mariotaku.twidere.util.Utils class TrendsSuggestionsFragment : AbsContentListViewFragment(), LoaderCallbacks, AdapterView.OnItemClickListener { - private val accountKey: UserKey? get() = Utils.getAccountKeys(context, arguments)?.firstOrNull() - ?: Utils.getDefaultAccountKey(context) private val tabExtras: TrendsTabExtras? get() = arguments.getParcelable(EXTRA_EXTRAS) + private val accountKey: UserKey? get() { + return Utils.getAccountKeys(context, arguments)?.firstOrNull() + ?: Utils.getDefaultAccountKey(context) + } + private val woeId: Int get() { - val id = tabExtras?.woeId ?: return 1 - return if (id > 0) id else 1 + val id = tabExtras?.woeId ?: 0 + return if (id > 0) id else preferences[localTrendsWoeIdKey] } override fun onActivityCreated(savedInstanceState: Bundle?) {