diff --git a/app/src/main/java/com/github/libretube/ui/fragments/HomeFragment.kt b/app/src/main/java/com/github/libretube/ui/fragments/HomeFragment.kt index 244a912c1..b56c5e99d 100644 --- a/app/src/main/java/com/github/libretube/ui/fragments/HomeFragment.kt +++ b/app/src/main/java/com/github/libretube/ui/fragments/HomeFragment.kt @@ -1,11 +1,13 @@ package com.github.libretube.ui.fragments +import android.content.Intent import android.os.Bundle import android.util.Log import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import android.widget.Toast +import android.widget.Toast.makeText import androidx.lifecycle.lifecycleScope import androidx.recyclerview.widget.GridLayoutManager import androidx.recyclerview.widget.LinearLayoutManager @@ -14,6 +16,8 @@ import com.github.libretube.api.RetrofitInstance import com.github.libretube.constants.PreferenceKeys import com.github.libretube.databinding.FragmentHomeBinding import com.github.libretube.extensions.TAG +import com.github.libretube.extensions.getStyledSnackBar +import com.github.libretube.ui.activities.SettingsActivity import com.github.libretube.ui.adapters.ChannelAdapter import com.github.libretube.ui.adapters.TrendingAdapter import com.github.libretube.ui.base.BaseFragment @@ -79,6 +83,26 @@ class HomeFragment : BaseFragment() { } runOnUiThread { binding.progressBar.visibility = View.GONE + + // show a [SnackBar] if there are no trending videos available + if (response.isEmpty()) { + binding.root.getStyledSnackBar( + R.string.change_region + ) + .setAction( + R.string.settings + ) { + startActivity( + Intent( + context, + SettingsActivity::class.java + ) + ) + } + .show() + return@runOnUiThread + } + if ( PreferenceHelper.getBoolean( PreferenceKeys.ALTERNATIVE_TRENDING_LAYOUT, diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index c9e82e5c2..50df12478 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -332,6 +332,7 @@ Play next Navigation bar Please select at least one item + Trending seems to be unavailable for the current region. Please select another in the settings. Download Service