mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-04-14 19:56:32 +00:00
fix crash
# Conflicts: # Habitica/src/main/java/com/habitrpg/android/habitica/helpers/AppConfigManager.kt
This commit is contained in:
parent
7e8366a3ce
commit
4dfc7ec1a1
4 changed files with 45 additions and 10 deletions
|
|
@ -30,7 +30,6 @@
|
|||
android:value="@string/application_ad_id"/>
|
||||
<activity
|
||||
android:name=".ui.activities.MainActivity"
|
||||
android:label="@string/app_name"
|
||||
android:theme="@style/LaunchAppTheme"
|
||||
android:windowSoftInputMode="stateHidden|adjustResize"
|
||||
android:configChanges="screenSize | smallestScreenSize | screenLayout | orientation"
|
||||
|
|
|
|||
|
|
@ -18,12 +18,16 @@ class AppConfigManager(contentRepository: ContentRepository?): com.habitrpg.comm
|
|||
private var worldState: WorldState? = null
|
||||
|
||||
init {
|
||||
contentRepository?.getWorldState()?.subscribe(
|
||||
{
|
||||
worldState = it
|
||||
},
|
||||
ExceptionHandler.rx()
|
||||
)
|
||||
try {
|
||||
contentRepository?.getWorldState()?.subscribe(
|
||||
{
|
||||
worldState = it
|
||||
},
|
||||
ExceptionHandler.rx()
|
||||
)
|
||||
} catch (_: java.lang.IllegalStateException) {
|
||||
// pass
|
||||
}
|
||||
}
|
||||
|
||||
private val remoteConfig = FirebaseRemoteConfig.getInstance()
|
||||
|
|
|
|||
|
|
@ -222,7 +222,11 @@ class TaskAlarmManager(
|
|||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
|
||||
alarmManager?.setWindow(AlarmManager.RTC_WAKEUP, time, 60000, pendingIntent)
|
||||
} else {
|
||||
alarmManager?.setAlarmClock(AlarmClockInfo(time, pendingIntent), pendingIntent)
|
||||
try {
|
||||
alarmManager?.setAlarmClock(AlarmClockInfo(time, pendingIntent), pendingIntent)
|
||||
} catch (e: SecurityException) {
|
||||
alarmManager?.setWindow(AlarmManager.RTC_WAKEUP, time, 60000, pendingIntent)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,11 +6,14 @@ import android.view.LayoutInflater
|
|||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.webkit.WebChromeClient
|
||||
import com.habitrpg.android.habitica.BuildConfig
|
||||
import android.webkit.WebResourceRequest
|
||||
import android.webkit.WebView
|
||||
import android.webkit.WebViewClient
|
||||
import com.habitrpg.android.habitica.R
|
||||
import com.habitrpg.android.habitica.components.UserComponent
|
||||
import com.habitrpg.android.habitica.databinding.FragmentNewsBinding
|
||||
import com.habitrpg.android.habitica.extensions.subscribeWithErrorHandler
|
||||
import com.habitrpg.android.habitica.helpers.MainNavigationController
|
||||
|
||||
class NewsFragment : BaseMainFragment<FragmentNewsBinding>() {
|
||||
|
||||
|
|
@ -29,13 +32,38 @@ class NewsFragment : BaseMainFragment<FragmentNewsBinding>() {
|
|||
return super.onCreateView(inflater, container, savedInstanceState)
|
||||
}
|
||||
|
||||
private val webviewClient = object : WebViewClient() {
|
||||
|
||||
override fun shouldOverrideUrlLoading(view: WebView?, url: String?): Boolean {
|
||||
if (url?.contains("/static/new-stuff") == true) {
|
||||
view?.loadUrl(url)
|
||||
} else if (url != null) {
|
||||
MainNavigationController.navigate(url)
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
override fun shouldOverrideUrlLoading(
|
||||
view: WebView?,
|
||||
request: WebResourceRequest?
|
||||
): Boolean {
|
||||
if (request?.url?.path == "/static/new-stuff") {
|
||||
view?.loadUrl(request.url.toString())
|
||||
} else {
|
||||
request?.url?.let { MainNavigationController.navigate(it) }
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("SetJavaScriptEnabled")
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
val address = if (BuildConfig.DEBUG) BuildConfig.BASE_URL else context?.getString(R.string.base_url)
|
||||
val address = context?.getString(R.string.base_url)
|
||||
val webSettings = binding?.newsWebview?.settings
|
||||
webSettings?.javaScriptEnabled = true
|
||||
webSettings?.domStorageEnabled = true
|
||||
binding?.newsWebview?.webViewClient = webviewClient
|
||||
binding?.newsWebview?.webChromeClient = object : WebChromeClient() {
|
||||
}
|
||||
binding?.newsWebview?.loadUrl("$address/static/new-stuff")
|
||||
|
|
|
|||
Loading…
Reference in a new issue