LibreTube/app/src/main/java/com/github/libretube/activities/NoInternetActivity.kt

42 lines
1.4 KiB
Kotlin
Raw Normal View History

2022-07-01 20:24:20 +05:30
package com.github.libretube.activities
2022-07-01 20:14:14 +05:30
import android.content.Intent
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
2022-07-06 19:54:24 +05:30
import com.github.libretube.R
2022-07-01 20:14:14 +05:30
import com.github.libretube.databinding.ActivityNointernetBinding
2022-07-06 19:54:24 +05:30
import com.github.libretube.util.ConnectionHelper
2022-07-01 20:14:14 +05:30
import com.github.libretube.util.ThemeHelper
2022-07-06 19:54:24 +05:30
import com.google.android.material.snackbar.Snackbar
2022-07-01 20:14:14 +05:30
class NoInternetActivity : AppCompatActivity() {
private lateinit var binding: ActivityNointernetBinding
override fun onCreate(savedInstanceState: Bundle?) {
2022-07-12 21:09:00 +05:30
ThemeHelper.updateTheme(this)
2022-07-01 20:14:14 +05:30
super.onCreate(savedInstanceState)
2022-07-06 19:54:24 +05:30
2022-07-01 20:14:14 +05:30
binding = ActivityNointernetBinding.inflate(layoutInflater)
2022-07-06 19:54:24 +05:30
// retry button
2022-07-01 20:14:14 +05:30
binding.retryButton.setOnClickListener {
2022-07-06 19:54:24 +05:30
if (ConnectionHelper.isNetworkAvailable(this)) {
ThemeHelper.restartMainActivity(this)
} else {
val snackBar = Snackbar
.make(binding.root, R.string.turnInternetOn, Snackbar.LENGTH_LONG)
snackBar.show()
}
2022-07-01 20:14:14 +05:30
}
binding.noInternetSettingsImageView.setOnClickListener {
val intent = Intent(this, SettingsActivity::class.java)
startActivity(intent)
}
setContentView(binding.root)
}
override fun onBackPressed() {
finishAffinity()
super.onBackPressed()
}
2022-07-01 20:25:21 +05:30
}