Skip to content

Commit

Permalink
fix #1418
Browse files Browse the repository at this point in the history
  • Loading branch information
fire-light42 authored Dec 6, 2024
1 parent 680030d commit c9b1c31
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ class MainActivity : AppCompatActivity(), ColorPickerDialogListener, BiometricCa
synchronized(apis) {
for (api in apis) {
if (str.startsWith(api.mainUrl)) {
loadResult(str, api.name)
loadResult(str, api.name, "")
return true
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ class DownloadFragment : Fragment() {
}

DOWNLOAD_ACTION_LOAD_RESULT -> {
activity?.loadResult(click.data.url, click.data.apiName)
activity?.loadResult(click.data.url, click.data.apiName, click.data.name)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ class HomeViewModel : ViewModel() {
}

fun click(load: LoadClickCallback) {
loadResult(load.response.url, load.response.apiName, load.action)
loadResult(load.response.url, load.response.apiName, load.response.name, load.action)
}

// only save the key if it is from UI, as we don't want internal functions changing the setting
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,7 @@ class LibraryFragment : Fragment() {
activity?.loadResult(
card.url,
apiName,
card.name
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ fun ResultEpisode.getWatchProgress(): Float {

object ResultFragment {
private const val URL_BUNDLE = "url"
private const val NAME_BUNDLE = "name"
private const val API_NAME_BUNDLE = "apiName"
private const val SEASON_BUNDLE = "season"
private const val EPISODE_BUNDLE = "episode"
Expand All @@ -137,6 +138,7 @@ object ResultFragment {
return Bundle().apply {
putString(URL_BUNDLE, card.url)
putString(API_NAME_BUNDLE, card.apiName)
putString(NAME_BUNDLE, card.name)
if (card is DataStoreHelper.ResumeWatchingResult) {
if (card.season != null)
putInt(SEASON_BUNDLE, card.season)
Expand All @@ -155,12 +157,14 @@ object ResultFragment {
fun newInstance(
url: String,
apiName: String,
name : String,
startAction: Int = 0,
startValue: Int = 0
): Bundle {
return Bundle().apply {
putString(URL_BUNDLE, url)
putString(API_NAME_BUNDLE, apiName)
putString(NAME_BUNDLE, name)
putInt(START_ACTION_BUNDLE, startAction)
putInt(START_VALUE_BUNDLE, startValue)
putBoolean(RESTART_BUNDLE, true)
Expand Down Expand Up @@ -218,6 +222,7 @@ object ResultFragment {
data class StoredData(
val url: String,
val apiName: String,
val name : String,
val showFillers: Boolean,
val dubStatus: DubStatus,
val start: AutoResume?,
Expand All @@ -230,6 +235,7 @@ object ResultFragment {
val settingsManager = PreferenceManager.getDefaultSharedPreferences(context)
val url = arguments?.getString(URL_BUNDLE) ?: return null
val apiName = arguments?.getString(API_NAME_BUNDLE) ?: return null
val name = arguments?.getString(NAME_BUNDLE) ?: return null
val showFillers =
settingsManager.getBoolean(context.getString(R.string.show_fillers_key), false)
val dubStatus = if (context.getApiDubstatusSettings()
Expand Down Expand Up @@ -258,7 +264,7 @@ object ResultFragment {
season = resumeSeason
)
}
return StoredData(url, apiName, showFillers, dubStatus, start, playerAction, restart)
return StoredData(url, apiName, name, showFillers, dubStatus, start, playerAction, restart)
}

/*private fun reloadViewModel(forceReload: Boolean) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,11 @@ open class ResultFragmentPhone : FullScreenPlayer() {

// ===== ===== =====

binding?.resultSearch?.isGone = storedData.name.isBlank()
binding?.resultSearch?.setOnClickListener {
QuickSearchFragment.pushSearch(activity, storedData.name)
}

resultBinding?.apply {
resultReloadConnectionerror.setOnClickListener {
viewModel.load(
Expand Down Expand Up @@ -745,6 +750,7 @@ open class ResultFragmentPhone : FullScreenPlayer() {
}

binding?.apply {
resultSearch.isGone = d.title.isBlank()
resultSearch.setOnClickListener {
QuickSearchFragment.pushSearch(activity, d.title)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -756,15 +756,17 @@ object AppContextUtils {
fun loadResult(
url: String,
apiName: String,
name : String,
startAction: Int = 0,
startValue: Int = 0
) {
(activity as FragmentActivity?)?.loadResult(url, apiName, startAction, startValue)
(activity as FragmentActivity?)?.loadResult(url, apiName, name, startAction, startValue)
}

fun FragmentActivity.loadResult(
url: String,
apiName: String,
name : String,
startAction: Int = 0,
startValue: Int = 0
) {
Expand All @@ -780,7 +782,7 @@ object AppContextUtils {
// viewModelStore.clear()
this.navigate(
getResultsId(),
ResultFragment.newInstance(url, apiName, startAction, startValue)
ResultFragment.newInstance(url, apiName, name, startAction, startValue)
)
}
}
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/res/navigation/mobile_navigation.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@
<argument
android:name="apiName"
app:argType="string" />
<argument
android:name="name"
app:argType="string" />
<argument
android:name="startAction"
android:defaultValue="0"
Expand Down

0 comments on commit c9b1c31

Please sign in to comment.