mirror of
https://github.com/Corewala/Buran
synced 2025-01-03 05:34:28 +00:00
Relaunches if internet is found after unsuccessful launch
This commit is contained in:
parent
01df294462
commit
79056fe060
1 changed files with 26 additions and 5 deletions
|
@ -24,7 +24,6 @@ import androidx.databinding.DataBindingUtil
|
||||||
import androidx.preference.PreferenceManager
|
import androidx.preference.PreferenceManager
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import com.google.android.material.snackbar.Snackbar
|
import com.google.android.material.snackbar.Snackbar
|
||||||
import corewala.*
|
|
||||||
import corewala.buran.BuildConfig
|
import corewala.buran.BuildConfig
|
||||||
import corewala.buran.Buran
|
import corewala.buran.Buran
|
||||||
import corewala.buran.OmniTerm
|
import corewala.buran.OmniTerm
|
||||||
|
@ -40,11 +39,15 @@ import corewala.buran.ui.bookmarks.BookmarkDialog
|
||||||
import corewala.buran.ui.bookmarks.BookmarksDialog
|
import corewala.buran.ui.bookmarks.BookmarksDialog
|
||||||
import corewala.buran.ui.content_image.ImageDialog
|
import corewala.buran.ui.content_image.ImageDialog
|
||||||
import corewala.buran.ui.content_text.TextDialog
|
import corewala.buran.ui.content_text.TextDialog
|
||||||
import corewala.buran.ui.gemtext_adapter.*
|
import corewala.buran.ui.gemtext_adapter.AbstractGemtextAdapter
|
||||||
import corewala.buran.ui.modals_menus.about.AboutDialog
|
import corewala.buran.ui.modals_menus.about.AboutDialog
|
||||||
import corewala.buran.ui.modals_menus.history.HistoryDialog
|
import corewala.buran.ui.modals_menus.history.HistoryDialog
|
||||||
import corewala.buran.ui.modals_menus.overflow.OverflowPopup
|
import corewala.buran.ui.modals_menus.overflow.OverflowPopup
|
||||||
import corewala.buran.ui.settings.SettingsActivity
|
import corewala.buran.ui.settings.SettingsActivity
|
||||||
|
import corewala.hideKeyboard
|
||||||
|
import corewala.showKeyboard
|
||||||
|
import corewala.toPx
|
||||||
|
import corewala.visibleRetainingSpace
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.io.FileInputStream
|
import java.io.FileInputStream
|
||||||
import java.io.FileOutputStream
|
import java.io.FileOutputStream
|
||||||
|
@ -76,6 +79,8 @@ class GemActivity : AppCompatActivity() {
|
||||||
|
|
||||||
private var internetStatus: Boolean = false
|
private var internetStatus: Boolean = false
|
||||||
|
|
||||||
|
private var initialised: Boolean = false
|
||||||
|
|
||||||
lateinit var adapter: AbstractGemtextAdapter
|
lateinit var adapter: AbstractGemtextAdapter
|
||||||
|
|
||||||
private val onLink: (link: URI, longTap: Boolean, adapterPosition: Int) -> Unit = { uri, longTap, position: Int ->
|
private val onLink: (link: URI, longTap: Boolean, adapterPosition: Int) -> Unit = { uri, longTap, position: Int ->
|
||||||
|
@ -185,6 +190,8 @@ class GemActivity : AppCompatActivity() {
|
||||||
}.show()
|
}.show()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
initialised = true
|
||||||
}else{
|
}else{
|
||||||
loadingView(false)
|
loadingView(false)
|
||||||
Snackbar.make(binding.root, getString(R.string.no_internet), Snackbar.LENGTH_LONG).show()
|
Snackbar.make(binding.root, getString(R.string.no_internet), Snackbar.LENGTH_LONG).show()
|
||||||
|
@ -285,7 +292,14 @@ class GemActivity : AppCompatActivity() {
|
||||||
|
|
||||||
binding.pullToRefresh.setOnRefreshListener {
|
binding.pullToRefresh.setOnRefreshListener {
|
||||||
if(getInternetStatus()){
|
if(getInternetStatus()){
|
||||||
refresh()
|
if(initialised){
|
||||||
|
refresh()
|
||||||
|
}else{
|
||||||
|
val intent = baseContext.packageManager.getLaunchIntentForPackage(baseContext.packageName)
|
||||||
|
intent!!.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
|
||||||
|
finish()
|
||||||
|
startActivity(intent)
|
||||||
|
}
|
||||||
}else{
|
}else{
|
||||||
binding.pullToRefresh.isRefreshing = false
|
binding.pullToRefresh.isRefreshing = false
|
||||||
Snackbar.make(binding.root, getString(R.string.no_internet), Snackbar.LENGTH_LONG).show()
|
Snackbar.make(binding.root, getString(R.string.no_internet), Snackbar.LENGTH_LONG).show()
|
||||||
|
@ -656,8 +670,15 @@ class GemActivity : AppCompatActivity() {
|
||||||
|
|
||||||
private fun request(address: String){
|
private fun request(address: String){
|
||||||
if(getInternetStatus()){
|
if(getInternetStatus()){
|
||||||
loadingView(true)
|
if(initialised){
|
||||||
return model.request(address)
|
loadingView(true)
|
||||||
|
return model.request(address)
|
||||||
|
}else{
|
||||||
|
val intent = baseContext.packageManager.getLaunchIntentForPackage(baseContext.packageName)
|
||||||
|
intent!!.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
|
||||||
|
finish()
|
||||||
|
startActivity(intent)
|
||||||
|
}
|
||||||
}else{
|
}else{
|
||||||
Snackbar.make(binding.root, getString(R.string.no_internet), Snackbar.LENGTH_LONG).show()
|
Snackbar.make(binding.root, getString(R.string.no_internet), Snackbar.LENGTH_LONG).show()
|
||||||
loadingView(false)
|
loadingView(false)
|
||||||
|
|
Loading…
Reference in a new issue