sad fucked up
This commit is contained in:
parent
cc5b512441
commit
14d08b9491
2 changed files with 12 additions and 10 deletions
|
@ -9,6 +9,7 @@ import androidx.core.view.updateLayoutParams
|
|||
import androidx.fragment.app.Fragment
|
||||
import ani.dantotsu.App
|
||||
import ani.dantotsu.R
|
||||
import ani.dantotsu.currContext
|
||||
import ani.dantotsu.databinding.FragmentOfflineBinding
|
||||
import ani.dantotsu.isOnline
|
||||
import ani.dantotsu.navBarHeight
|
||||
|
@ -16,6 +17,7 @@ import ani.dantotsu.startMainActivity
|
|||
import ani.dantotsu.statusBarHeight
|
||||
|
||||
class OfflineFragment : Fragment() {
|
||||
private var offline = false
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater,
|
||||
container: ViewGroup?,
|
||||
|
@ -26,15 +28,23 @@ class OfflineFragment : Fragment() {
|
|||
topMargin = statusBarHeight
|
||||
bottomMargin = navBarHeight
|
||||
}
|
||||
val offline = App.context?.getSharedPreferences("Dantotsu", Context.MODE_PRIVATE)
|
||||
offline = requireContext().getSharedPreferences("Dantotsu", Context.MODE_PRIVATE)
|
||||
?.getBoolean("offlineMode", false) ?: false
|
||||
binding.noInternet.text =
|
||||
if (!isOnline(requireContext())) getString(R.string.no_internet) else "OFFLINE MODE"
|
||||
binding.refreshButton.setOnClickListener {
|
||||
if (!isOnline(requireContext()) && offline) {
|
||||
println("Offline: $offline")
|
||||
println("Online: ${isOnline(requireContext())}")
|
||||
if (isOnline(requireContext()) && !offline) {
|
||||
startMainActivity(requireActivity())
|
||||
}
|
||||
}
|
||||
return binding.root
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
offline = requireContext().getSharedPreferences("Dantotsu", Context.MODE_PRIVATE)
|
||||
?.getBoolean("offlineMode", false) ?: false
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue