Skip to content

Commit

Permalink
Add back reloading addon on start
Browse files Browse the repository at this point in the history
  • Loading branch information
levinli303 committed Mar 14, 2022
1 parent c650ed8 commit da9af00
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
xmlns:tools="http://schemas.android.com/tools"
package="space.celestia.mobilecelestia"
android:installLocation="auto"
android:versionCode="256"
android:versionCode="257"
android:versionName="1.5.5">

<uses-feature android:glEsVersion="0x00020000" android:required="true" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,19 @@ import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.Button
import androidx.lifecycle.lifecycleScope
import com.google.android.material.progressindicator.LinearProgressIndicator
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.launch
import space.celestia.mobilecelestia.R
import space.celestia.mobilecelestia.common.NavigationFragment
import space.celestia.mobilecelestia.common.replace
import space.celestia.mobilecelestia.resource.model.ResourceAPI
import space.celestia.mobilecelestia.resource.model.ResourceAPIService
import space.celestia.mobilecelestia.resource.model.ResourceItem
import space.celestia.mobilecelestia.resource.model.ResourceManager
import space.celestia.mobilecelestia.utils.CelestiaString
import space.celestia.mobilecelestia.utils.commonHandler
import space.celestia.mobilecelestia.utils.showAlert
import java.io.File
import javax.inject.Inject
Expand All @@ -34,6 +39,8 @@ import javax.inject.Inject
class ResourceItemFragment : NavigationFragment.SubFragment(), ResourceManager.Listener {
@Inject
lateinit var resourceManager: ResourceManager
@Inject
lateinit var resourceAPI: ResourceAPIService

private lateinit var language: String

Expand Down Expand Up @@ -97,6 +104,16 @@ class ResourceItemFragment : NavigationFragment.SubFragment(), ResourceManager.L
.appendQueryParameter("titleVisibility", "visible")
.build()
replace(CommonWebFragment.newInstance(uri), R.id.resource_item_container)

// Fetch the latest item, this is needed as user might come
// here from Installed where the URL might be incorrect
lifecycleScope.launch {
try {
val result = resourceAPI.item(language, item.id).commonHandler(ResourceItem::class.java, ResourceAPI.gson)
item = result
updateUI()
} catch (ignored: Throwable) {}
}
}
}

Expand Down

0 comments on commit da9af00

Please sign in to comment.