mirror of
https://github.com/fork-maintainers/iceraven-browser
synced 2024-11-02 03:40:16 +00:00
[fenix] For https://github.com/mozilla-mobile/fenix/issues/1459 - Try more ways to get title for history item
This commit is contained in:
parent
677de4c1c1
commit
05cf3d6370
@ -5,6 +5,7 @@
|
|||||||
package org.mozilla.fenix.library.history
|
package org.mozilla.fenix.library.history
|
||||||
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import android.text.TextUtils
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.Menu
|
import android.view.Menu
|
||||||
import android.view.MenuInflater
|
import android.view.MenuInflater
|
||||||
@ -30,6 +31,7 @@ import org.mozilla.fenix.ext.requireComponents
|
|||||||
import org.mozilla.fenix.mvi.ActionBusFactory
|
import org.mozilla.fenix.mvi.ActionBusFactory
|
||||||
import org.mozilla.fenix.mvi.getAutoDisposeObservable
|
import org.mozilla.fenix.mvi.getAutoDisposeObservable
|
||||||
import org.mozilla.fenix.mvi.getManagedEmitter
|
import org.mozilla.fenix.mvi.getManagedEmitter
|
||||||
|
import java.net.MalformedURLException
|
||||||
import java.net.URL
|
import java.net.URL
|
||||||
import kotlin.coroutines.CoroutineContext
|
import kotlin.coroutines.CoroutineContext
|
||||||
|
|
||||||
@ -154,7 +156,15 @@ class HistoryFragment : Fragment(), CoroutineScope, BackHandler {
|
|||||||
// See https://github.com/mozilla-mobile/android-components/issues/2643
|
// See https://github.com/mozilla-mobile/android-components/issues/2643
|
||||||
.filter { allowedVisitTypes.contains(it.visitType) }
|
.filter { allowedVisitTypes.contains(it.visitType) }
|
||||||
|
|
||||||
.mapIndexed { id, item -> HistoryItem(id, item.title ?: URL(item.url).host, item.url, item.visitTime) }
|
.mapIndexed { id, item ->
|
||||||
|
HistoryItem(
|
||||||
|
id, if (TextUtils.isEmpty(item.title!!)) try {
|
||||||
|
URL(item.url).host
|
||||||
|
} catch (e: MalformedURLException) {
|
||||||
|
item.url
|
||||||
|
} else item.title!!, item.url, item.visitTime
|
||||||
|
)
|
||||||
|
}
|
||||||
.toList()
|
.toList()
|
||||||
|
|
||||||
coroutineScope {
|
coroutineScope {
|
||||||
|
Loading…
Reference in New Issue
Block a user