mirror of
https://github.com/TeamNewPipe/NewPipe
synced 2024-11-11 21:09:10 +01:00
Auto-format using Ktlint
This commit is contained in:
parent
ff7344438b
commit
b0415a5289
@ -7,11 +7,11 @@ import androidx.room.Query
|
|||||||
import androidx.room.Transaction
|
import androidx.room.Transaction
|
||||||
import androidx.room.Update
|
import androidx.room.Update
|
||||||
import io.reactivex.Flowable
|
import io.reactivex.Flowable
|
||||||
|
import java.util.Date
|
||||||
import org.schabi.newpipe.database.feed.model.FeedEntity
|
import org.schabi.newpipe.database.feed.model.FeedEntity
|
||||||
import org.schabi.newpipe.database.feed.model.FeedLastUpdatedEntity
|
import org.schabi.newpipe.database.feed.model.FeedLastUpdatedEntity
|
||||||
import org.schabi.newpipe.database.stream.model.StreamEntity
|
import org.schabi.newpipe.database.stream.model.StreamEntity
|
||||||
import org.schabi.newpipe.database.subscription.SubscriptionEntity
|
import org.schabi.newpipe.database.subscription.SubscriptionEntity
|
||||||
import java.util.Date
|
|
||||||
|
|
||||||
@Dao
|
@Dao
|
||||||
abstract class FeedDAO {
|
abstract class FeedDAO {
|
||||||
|
@ -4,10 +4,10 @@ import androidx.room.ColumnInfo
|
|||||||
import androidx.room.Entity
|
import androidx.room.Entity
|
||||||
import androidx.room.ForeignKey
|
import androidx.room.ForeignKey
|
||||||
import androidx.room.PrimaryKey
|
import androidx.room.PrimaryKey
|
||||||
|
import java.util.Date
|
||||||
import org.schabi.newpipe.database.feed.model.FeedLastUpdatedEntity.Companion.FEED_LAST_UPDATED_TABLE
|
import org.schabi.newpipe.database.feed.model.FeedLastUpdatedEntity.Companion.FEED_LAST_UPDATED_TABLE
|
||||||
import org.schabi.newpipe.database.feed.model.FeedLastUpdatedEntity.Companion.SUBSCRIPTION_ID
|
import org.schabi.newpipe.database.feed.model.FeedLastUpdatedEntity.Companion.SUBSCRIPTION_ID
|
||||||
import org.schabi.newpipe.database.subscription.SubscriptionEntity
|
import org.schabi.newpipe.database.subscription.SubscriptionEntity
|
||||||
import java.util.Date
|
|
||||||
|
|
||||||
@Entity(
|
@Entity(
|
||||||
tableName = FEED_LAST_UPDATED_TABLE,
|
tableName = FEED_LAST_UPDATED_TABLE,
|
||||||
|
@ -2,8 +2,8 @@ package org.schabi.newpipe.database.history.model
|
|||||||
|
|
||||||
import androidx.room.ColumnInfo
|
import androidx.room.ColumnInfo
|
||||||
import androidx.room.Embedded
|
import androidx.room.Embedded
|
||||||
import org.schabi.newpipe.database.stream.model.StreamEntity
|
|
||||||
import java.util.Date
|
import java.util.Date
|
||||||
|
import org.schabi.newpipe.database.stream.model.StreamEntity
|
||||||
|
|
||||||
data class StreamHistoryEntry(
|
data class StreamHistoryEntry(
|
||||||
@Embedded
|
@Embedded
|
||||||
|
@ -2,11 +2,11 @@ package org.schabi.newpipe.database.stream
|
|||||||
|
|
||||||
import androidx.room.ColumnInfo
|
import androidx.room.ColumnInfo
|
||||||
import androidx.room.Embedded
|
import androidx.room.Embedded
|
||||||
|
import java.util.Date
|
||||||
import org.schabi.newpipe.database.LocalItem
|
import org.schabi.newpipe.database.LocalItem
|
||||||
import org.schabi.newpipe.database.history.model.StreamHistoryEntity
|
import org.schabi.newpipe.database.history.model.StreamHistoryEntity
|
||||||
import org.schabi.newpipe.database.stream.model.StreamEntity
|
import org.schabi.newpipe.database.stream.model.StreamEntity
|
||||||
import org.schabi.newpipe.extractor.stream.StreamInfoItem
|
import org.schabi.newpipe.extractor.stream.StreamInfoItem
|
||||||
import java.util.Date
|
|
||||||
|
|
||||||
class StreamStatisticsEntry(
|
class StreamStatisticsEntry(
|
||||||
@Embedded
|
@Embedded
|
||||||
|
@ -7,13 +7,13 @@ import androidx.room.OnConflictStrategy
|
|||||||
import androidx.room.Query
|
import androidx.room.Query
|
||||||
import androidx.room.Transaction
|
import androidx.room.Transaction
|
||||||
import io.reactivex.Flowable
|
import io.reactivex.Flowable
|
||||||
|
import java.util.Date
|
||||||
import org.schabi.newpipe.database.BasicDAO
|
import org.schabi.newpipe.database.BasicDAO
|
||||||
import org.schabi.newpipe.database.stream.model.StreamEntity
|
import org.schabi.newpipe.database.stream.model.StreamEntity
|
||||||
import org.schabi.newpipe.database.stream.model.StreamEntity.Companion.STREAM_ID
|
import org.schabi.newpipe.database.stream.model.StreamEntity.Companion.STREAM_ID
|
||||||
import org.schabi.newpipe.extractor.stream.StreamType
|
import org.schabi.newpipe.extractor.stream.StreamType
|
||||||
import org.schabi.newpipe.extractor.stream.StreamType.AUDIO_LIVE_STREAM
|
import org.schabi.newpipe.extractor.stream.StreamType.AUDIO_LIVE_STREAM
|
||||||
import org.schabi.newpipe.extractor.stream.StreamType.LIVE_STREAM
|
import org.schabi.newpipe.extractor.stream.StreamType.LIVE_STREAM
|
||||||
import java.util.Date
|
|
||||||
|
|
||||||
@Dao
|
@Dao
|
||||||
abstract class StreamDAO : BasicDAO<StreamEntity> {
|
abstract class StreamDAO : BasicDAO<StreamEntity> {
|
||||||
@ -98,7 +98,6 @@ abstract class StreamDAO : BasicDAO<StreamEntity> {
|
|||||||
if (existentMinimalStream.duration > 0 && newerStream.duration < 0) {
|
if (existentMinimalStream.duration > 0 && newerStream.duration < 0) {
|
||||||
newerStream.duration = existentMinimalStream.duration
|
newerStream.duration = existentMinimalStream.duration
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -136,5 +135,6 @@ abstract class StreamDAO : BasicDAO<StreamEntity> {
|
|||||||
var isUploadDateApproximation: Boolean? = null,
|
var isUploadDateApproximation: Boolean? = null,
|
||||||
|
|
||||||
@ColumnInfo(name = StreamEntity.STREAM_DURATION)
|
@ColumnInfo(name = StreamEntity.STREAM_DURATION)
|
||||||
var duration: Long)
|
var duration: Long
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,9 @@ import androidx.room.Entity
|
|||||||
import androidx.room.Ignore
|
import androidx.room.Ignore
|
||||||
import androidx.room.Index
|
import androidx.room.Index
|
||||||
import androidx.room.PrimaryKey
|
import androidx.room.PrimaryKey
|
||||||
|
import java.io.Serializable
|
||||||
|
import java.util.Calendar
|
||||||
|
import java.util.Date
|
||||||
import org.schabi.newpipe.database.stream.model.StreamEntity.Companion.STREAM_SERVICE_ID
|
import org.schabi.newpipe.database.stream.model.StreamEntity.Companion.STREAM_SERVICE_ID
|
||||||
import org.schabi.newpipe.database.stream.model.StreamEntity.Companion.STREAM_TABLE
|
import org.schabi.newpipe.database.stream.model.StreamEntity.Companion.STREAM_TABLE
|
||||||
import org.schabi.newpipe.database.stream.model.StreamEntity.Companion.STREAM_URL
|
import org.schabi.newpipe.database.stream.model.StreamEntity.Companion.STREAM_URL
|
||||||
@ -13,9 +16,6 @@ import org.schabi.newpipe.extractor.stream.StreamInfo
|
|||||||
import org.schabi.newpipe.extractor.stream.StreamInfoItem
|
import org.schabi.newpipe.extractor.stream.StreamInfoItem
|
||||||
import org.schabi.newpipe.extractor.stream.StreamType
|
import org.schabi.newpipe.extractor.stream.StreamType
|
||||||
import org.schabi.newpipe.player.playqueue.PlayQueueItem
|
import org.schabi.newpipe.player.playqueue.PlayQueueItem
|
||||||
import java.io.Serializable
|
|
||||||
import java.util.Calendar
|
|
||||||
import java.util.Date
|
|
||||||
|
|
||||||
@Entity(tableName = STREAM_TABLE,
|
@Entity(tableName = STREAM_TABLE,
|
||||||
indices = [
|
indices = [
|
||||||
|
@ -7,6 +7,8 @@ import io.reactivex.Flowable
|
|||||||
import io.reactivex.Maybe
|
import io.reactivex.Maybe
|
||||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||||
import io.reactivex.schedulers.Schedulers
|
import io.reactivex.schedulers.Schedulers
|
||||||
|
import java.util.Calendar
|
||||||
|
import java.util.Date
|
||||||
import org.schabi.newpipe.MainActivity.DEBUG
|
import org.schabi.newpipe.MainActivity.DEBUG
|
||||||
import org.schabi.newpipe.NewPipeDatabase
|
import org.schabi.newpipe.NewPipeDatabase
|
||||||
import org.schabi.newpipe.database.feed.model.FeedEntity
|
import org.schabi.newpipe.database.feed.model.FeedEntity
|
||||||
@ -16,8 +18,6 @@ import org.schabi.newpipe.database.stream.model.StreamEntity
|
|||||||
import org.schabi.newpipe.extractor.stream.StreamInfoItem
|
import org.schabi.newpipe.extractor.stream.StreamInfoItem
|
||||||
import org.schabi.newpipe.extractor.stream.StreamType
|
import org.schabi.newpipe.extractor.stream.StreamType
|
||||||
import org.schabi.newpipe.local.subscription.FeedGroupIcon
|
import org.schabi.newpipe.local.subscription.FeedGroupIcon
|
||||||
import java.util.Calendar
|
|
||||||
import java.util.Date
|
|
||||||
|
|
||||||
class FeedDatabaseManager(context: Context) {
|
class FeedDatabaseManager(context: Context) {
|
||||||
private val database = NewPipeDatabase.getInstance(context)
|
private val database = NewPipeDatabase.getInstance(context)
|
||||||
@ -70,8 +70,11 @@ class FeedDatabaseManager(context: Context) {
|
|||||||
fun markAsOutdated(subscriptionId: Long) = feedTable
|
fun markAsOutdated(subscriptionId: Long) = feedTable
|
||||||
.setLastUpdatedForSubscription(FeedLastUpdatedEntity(subscriptionId, null))
|
.setLastUpdatedForSubscription(FeedLastUpdatedEntity(subscriptionId, null))
|
||||||
|
|
||||||
fun upsertAll(subscriptionId: Long, items: List<StreamInfoItem>,
|
fun upsertAll(
|
||||||
oldestAllowedDate: Date = FEED_OLDEST_ALLOWED_DATE.time) {
|
subscriptionId: Long,
|
||||||
|
items: List<StreamInfoItem>,
|
||||||
|
oldestAllowedDate: Date = FEED_OLDEST_ALLOWED_DATE.time
|
||||||
|
) {
|
||||||
val itemsToInsert = ArrayList<StreamInfoItem>()
|
val itemsToInsert = ArrayList<StreamInfoItem>()
|
||||||
loop@ for (streamItem in items) {
|
loop@ for (streamItem in items) {
|
||||||
val uploadDate = streamItem.uploadDate
|
val uploadDate = streamItem.uploadDate
|
||||||
@ -161,6 +164,5 @@ class FeedDatabaseManager(context: Context) {
|
|||||||
FeedGroupEntity.GROUP_ALL_ID -> feedTable.oldestSubscriptionUpdateFromAll()
|
FeedGroupEntity.GROUP_ALL_ID -> feedTable.oldestSubscriptionUpdateFromAll()
|
||||||
else -> feedTable.oldestSubscriptionUpdate(groupId)
|
else -> feedTable.oldestSubscriptionUpdate(groupId)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,6 +33,7 @@ import androidx.lifecycle.Observer
|
|||||||
import androidx.lifecycle.ViewModelProviders
|
import androidx.lifecycle.ViewModelProviders
|
||||||
import androidx.preference.PreferenceManager
|
import androidx.preference.PreferenceManager
|
||||||
import icepick.State
|
import icepick.State
|
||||||
|
import java.util.Calendar
|
||||||
import kotlinx.android.synthetic.main.error_retry.error_button_retry
|
import kotlinx.android.synthetic.main.error_retry.error_button_retry
|
||||||
import kotlinx.android.synthetic.main.error_retry.error_message_view
|
import kotlinx.android.synthetic.main.error_retry.error_message_view
|
||||||
import kotlinx.android.synthetic.main.fragment_feed.empty_state_view
|
import kotlinx.android.synthetic.main.fragment_feed.empty_state_view
|
||||||
@ -50,7 +51,6 @@ import org.schabi.newpipe.local.feed.service.FeedLoadService
|
|||||||
import org.schabi.newpipe.report.UserAction
|
import org.schabi.newpipe.report.UserAction
|
||||||
import org.schabi.newpipe.util.AnimationUtils.animateView
|
import org.schabi.newpipe.util.AnimationUtils.animateView
|
||||||
import org.schabi.newpipe.util.Localization
|
import org.schabi.newpipe.util.Localization
|
||||||
import java.util.Calendar
|
|
||||||
|
|
||||||
class FeedFragment : BaseListFragment<FeedState, Unit>() {
|
class FeedFragment : BaseListFragment<FeedState, Unit>() {
|
||||||
private lateinit var viewModel: FeedViewModel
|
private lateinit var viewModel: FeedViewModel
|
||||||
@ -272,7 +272,6 @@ class FeedFragment : BaseListFragment<FeedState, Unit>() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private fun handleErrorState(errorState: FeedState.ErrorState): Boolean {
|
private fun handleErrorState(errorState: FeedState.ErrorState): Boolean {
|
||||||
hideLoading()
|
hideLoading()
|
||||||
errorState.error?.let {
|
errorState.error?.let {
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
package org.schabi.newpipe.local.feed
|
package org.schabi.newpipe.local.feed
|
||||||
|
|
||||||
import androidx.annotation.StringRes
|
import androidx.annotation.StringRes
|
||||||
import org.schabi.newpipe.extractor.stream.StreamInfoItem
|
|
||||||
import java.util.Calendar
|
import java.util.Calendar
|
||||||
|
import org.schabi.newpipe.extractor.stream.StreamInfoItem
|
||||||
|
|
||||||
sealed class FeedState {
|
sealed class FeedState {
|
||||||
data class ProgressState(
|
data class ProgressState(
|
||||||
|
@ -9,6 +9,9 @@ import io.reactivex.Flowable
|
|||||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||||
import io.reactivex.functions.Function4
|
import io.reactivex.functions.Function4
|
||||||
import io.reactivex.schedulers.Schedulers
|
import io.reactivex.schedulers.Schedulers
|
||||||
|
import java.util.Calendar
|
||||||
|
import java.util.Date
|
||||||
|
import java.util.concurrent.TimeUnit
|
||||||
import org.schabi.newpipe.database.feed.model.FeedGroupEntity
|
import org.schabi.newpipe.database.feed.model.FeedGroupEntity
|
||||||
import org.schabi.newpipe.extractor.stream.StreamInfoItem
|
import org.schabi.newpipe.extractor.stream.StreamInfoItem
|
||||||
import org.schabi.newpipe.local.feed.service.FeedEventManager
|
import org.schabi.newpipe.local.feed.service.FeedEventManager
|
||||||
@ -17,9 +20,6 @@ import org.schabi.newpipe.local.feed.service.FeedEventManager.Event.IdleEvent
|
|||||||
import org.schabi.newpipe.local.feed.service.FeedEventManager.Event.ProgressEvent
|
import org.schabi.newpipe.local.feed.service.FeedEventManager.Event.ProgressEvent
|
||||||
import org.schabi.newpipe.local.feed.service.FeedEventManager.Event.SuccessResultEvent
|
import org.schabi.newpipe.local.feed.service.FeedEventManager.Event.SuccessResultEvent
|
||||||
import org.schabi.newpipe.util.DEFAULT_THROTTLE_TIMEOUT
|
import org.schabi.newpipe.util.DEFAULT_THROTTLE_TIMEOUT
|
||||||
import java.util.Calendar
|
|
||||||
import java.util.Date
|
|
||||||
import java.util.concurrent.TimeUnit
|
|
||||||
|
|
||||||
class FeedViewModel(applicationContext: Context, val groupId: Long = FeedGroupEntity.GROUP_ALL_ID) : ViewModel() {
|
class FeedViewModel(applicationContext: Context, val groupId: Long = FeedGroupEntity.GROUP_ALL_ID) : ViewModel() {
|
||||||
class Factory(val context: Context, val groupId: Long = FeedGroupEntity.GROUP_ALL_ID) : ViewModelProvider.Factory {
|
class Factory(val context: Context, val groupId: Long = FeedGroupEntity.GROUP_ALL_ID) : ViewModelProvider.Factory {
|
||||||
|
@ -3,8 +3,8 @@ package org.schabi.newpipe.local.feed.service
|
|||||||
import androidx.annotation.StringRes
|
import androidx.annotation.StringRes
|
||||||
import io.reactivex.Flowable
|
import io.reactivex.Flowable
|
||||||
import io.reactivex.processors.BehaviorProcessor
|
import io.reactivex.processors.BehaviorProcessor
|
||||||
import org.schabi.newpipe.local.feed.service.FeedEventManager.Event.IdleEvent
|
|
||||||
import java.util.concurrent.atomic.AtomicBoolean
|
import java.util.concurrent.atomic.AtomicBoolean
|
||||||
|
import org.schabi.newpipe.local.feed.service.FeedEventManager.Event.IdleEvent
|
||||||
|
|
||||||
object FeedEventManager {
|
object FeedEventManager {
|
||||||
private var processor: BehaviorProcessor<Event> = BehaviorProcessor.create()
|
private var processor: BehaviorProcessor<Event> = BehaviorProcessor.create()
|
||||||
@ -34,5 +34,4 @@ object FeedEventManager {
|
|||||||
data class SuccessResultEvent(val itemsErrors: List<Throwable> = emptyList()) : Event()
|
data class SuccessResultEvent(val itemsErrors: List<Throwable> = emptyList()) : Event()
|
||||||
data class ErrorResultEvent(val error: Throwable) : Event()
|
data class ErrorResultEvent(val error: Throwable) : Event()
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -40,6 +40,11 @@ import io.reactivex.functions.Consumer
|
|||||||
import io.reactivex.functions.Function
|
import io.reactivex.functions.Function
|
||||||
import io.reactivex.processors.PublishProcessor
|
import io.reactivex.processors.PublishProcessor
|
||||||
import io.reactivex.schedulers.Schedulers
|
import io.reactivex.schedulers.Schedulers
|
||||||
|
import java.io.IOException
|
||||||
|
import java.util.Calendar
|
||||||
|
import java.util.concurrent.TimeUnit
|
||||||
|
import java.util.concurrent.atomic.AtomicBoolean
|
||||||
|
import java.util.concurrent.atomic.AtomicInteger
|
||||||
import org.reactivestreams.Subscriber
|
import org.reactivestreams.Subscriber
|
||||||
import org.reactivestreams.Subscription
|
import org.reactivestreams.Subscription
|
||||||
import org.schabi.newpipe.MainActivity.DEBUG
|
import org.schabi.newpipe.MainActivity.DEBUG
|
||||||
@ -57,11 +62,6 @@ import org.schabi.newpipe.local.feed.service.FeedEventManager.postEvent
|
|||||||
import org.schabi.newpipe.local.subscription.SubscriptionManager
|
import org.schabi.newpipe.local.subscription.SubscriptionManager
|
||||||
import org.schabi.newpipe.util.ExceptionUtils
|
import org.schabi.newpipe.util.ExceptionUtils
|
||||||
import org.schabi.newpipe.util.ExtractorHelper
|
import org.schabi.newpipe.util.ExtractorHelper
|
||||||
import java.io.IOException
|
|
||||||
import java.util.Calendar
|
|
||||||
import java.util.concurrent.TimeUnit
|
|
||||||
import java.util.concurrent.atomic.AtomicBoolean
|
|
||||||
import java.util.concurrent.atomic.AtomicInteger
|
|
||||||
|
|
||||||
class FeedLoadService : Service() {
|
class FeedLoadService : Service() {
|
||||||
companion object {
|
companion object {
|
||||||
@ -314,7 +314,6 @@ class FeedLoadService : Service() {
|
|||||||
feedResultsHolder.addErrors(RequestException.wrapList(subscriptionId, info))
|
feedResultsHolder.addErrors(RequestException.wrapList(subscriptionId, info))
|
||||||
feedDatabaseManager.markAsOutdated(subscriptionId)
|
feedDatabaseManager.markAsOutdated(subscriptionId)
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (notification.isOnError) {
|
} else if (notification.isOnError) {
|
||||||
val error = notification.error!!
|
val error = notification.error!!
|
||||||
feedResultsHolder.addError(error)
|
feedResultsHolder.addError(error)
|
||||||
@ -327,7 +326,6 @@ class FeedLoadService : Service() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private val errorHandlingConsumer: Consumer<Notification<Pair<Long, ListInfo<StreamInfoItem>>>>
|
private val errorHandlingConsumer: Consumer<Notification<Pair<Long, ListInfo<StreamInfoItem>>>>
|
||||||
get() = Consumer {
|
get() = Consumer {
|
||||||
if (it.isOnError) {
|
if (it.isOnError) {
|
||||||
|
@ -29,6 +29,12 @@ import com.xwray.groupie.Section
|
|||||||
import com.xwray.groupie.kotlinandroidextensions.GroupieViewHolder
|
import com.xwray.groupie.kotlinandroidextensions.GroupieViewHolder
|
||||||
import icepick.State
|
import icepick.State
|
||||||
import io.reactivex.disposables.CompositeDisposable
|
import io.reactivex.disposables.CompositeDisposable
|
||||||
|
import java.io.File
|
||||||
|
import java.text.SimpleDateFormat
|
||||||
|
import java.util.Date
|
||||||
|
import java.util.Locale
|
||||||
|
import kotlin.math.floor
|
||||||
|
import kotlin.math.max
|
||||||
import kotlinx.android.synthetic.main.dialog_title.view.itemAdditionalDetails
|
import kotlinx.android.synthetic.main.dialog_title.view.itemAdditionalDetails
|
||||||
import kotlinx.android.synthetic.main.dialog_title.view.itemTitleView
|
import kotlinx.android.synthetic.main.dialog_title.view.itemTitleView
|
||||||
import kotlinx.android.synthetic.main.fragment_subscription.items_list
|
import kotlinx.android.synthetic.main.fragment_subscription.items_list
|
||||||
@ -62,12 +68,6 @@ import org.schabi.newpipe.util.NavigationHelper
|
|||||||
import org.schabi.newpipe.util.OnClickGesture
|
import org.schabi.newpipe.util.OnClickGesture
|
||||||
import org.schabi.newpipe.util.ShareUtils
|
import org.schabi.newpipe.util.ShareUtils
|
||||||
import org.schabi.newpipe.util.ThemeHelper
|
import org.schabi.newpipe.util.ThemeHelper
|
||||||
import java.io.File
|
|
||||||
import java.text.SimpleDateFormat
|
|
||||||
import java.util.Date
|
|
||||||
import java.util.Locale
|
|
||||||
import kotlin.math.floor
|
|
||||||
import kotlin.math.max
|
|
||||||
|
|
||||||
class SubscriptionFragment : BaseStateFragment<SubscriptionState>() {
|
class SubscriptionFragment : BaseStateFragment<SubscriptionState>() {
|
||||||
private lateinit var viewModel: SubscriptionViewModel
|
private lateinit var viewModel: SubscriptionViewModel
|
||||||
@ -173,7 +173,6 @@ class SubscriptionFragment : BaseStateFragment<SubscriptionState>() {
|
|||||||
importExportItem.isExpanded = false
|
importExportItem.isExpanded = false
|
||||||
importExportItem.notifyChanged(FeedImportExportItem.REFRESH_EXPANDED_STATUS)
|
importExportItem.notifyChanged(FeedImportExportItem.REFRESH_EXPANDED_STATUS)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -266,7 +265,6 @@ class SubscriptionFragment : BaseStateFragment<SubscriptionState>() {
|
|||||||
{ onExportSelected() },
|
{ onExportSelected() },
|
||||||
importExportItemExpandedState ?: false)
|
importExportItemExpandedState ?: false)
|
||||||
groupAdapter.add(Section(importExportItem, listOf(subscriptionsSection)))
|
groupAdapter.add(Section(importExportItem, listOf(subscriptionsSection)))
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun initViews(rootView: View, savedInstanceState: Bundle?) {
|
override fun initViews(rootView: View, savedInstanceState: Bundle?) {
|
||||||
@ -428,8 +426,8 @@ class SubscriptionFragment : BaseStateFragment<SubscriptionState>() {
|
|||||||
getString(R.string.list_view_mode_auto_key) -> {
|
getString(R.string.list_view_mode_auto_key) -> {
|
||||||
val configuration = resources.configuration
|
val configuration = resources.configuration
|
||||||
|
|
||||||
(configuration.orientation == Configuration.ORIENTATION_LANDSCAPE
|
(configuration.orientation == Configuration.ORIENTATION_LANDSCAPE &&
|
||||||
&& configuration.isLayoutSizeAtLeast(Configuration.SCREENLAYOUT_SIZE_LARGE))
|
configuration.isLayoutSizeAtLeast(Configuration.SCREENLAYOUT_SIZE_LARGE))
|
||||||
}
|
}
|
||||||
getString(R.string.list_view_mode_grid_key) -> true
|
getString(R.string.list_view_mode_grid_key) -> true
|
||||||
else -> false
|
else -> false
|
||||||
|
@ -6,11 +6,11 @@ import androidx.lifecycle.LiveData
|
|||||||
import androidx.lifecycle.MutableLiveData
|
import androidx.lifecycle.MutableLiveData
|
||||||
import com.xwray.groupie.Group
|
import com.xwray.groupie.Group
|
||||||
import io.reactivex.schedulers.Schedulers
|
import io.reactivex.schedulers.Schedulers
|
||||||
|
import java.util.concurrent.TimeUnit
|
||||||
import org.schabi.newpipe.local.feed.FeedDatabaseManager
|
import org.schabi.newpipe.local.feed.FeedDatabaseManager
|
||||||
import org.schabi.newpipe.local.subscription.item.ChannelItem
|
import org.schabi.newpipe.local.subscription.item.ChannelItem
|
||||||
import org.schabi.newpipe.local.subscription.item.FeedGroupCardItem
|
import org.schabi.newpipe.local.subscription.item.FeedGroupCardItem
|
||||||
import org.schabi.newpipe.util.DEFAULT_THROTTLE_TIMEOUT
|
import org.schabi.newpipe.util.DEFAULT_THROTTLE_TIMEOUT
|
||||||
import java.util.concurrent.TimeUnit
|
|
||||||
|
|
||||||
class SubscriptionViewModel(application: Application) : AndroidViewModel(application) {
|
class SubscriptionViewModel(application: Application) : AndroidViewModel(application) {
|
||||||
private var feedDatabaseManager: FeedDatabaseManager = FeedDatabaseManager(application)
|
private var feedDatabaseManager: FeedDatabaseManager = FeedDatabaseManager(application)
|
||||||
|
@ -22,6 +22,7 @@ import com.xwray.groupie.Section
|
|||||||
import com.xwray.groupie.kotlinandroidextensions.GroupieViewHolder
|
import com.xwray.groupie.kotlinandroidextensions.GroupieViewHolder
|
||||||
import icepick.Icepick
|
import icepick.Icepick
|
||||||
import icepick.State
|
import icepick.State
|
||||||
|
import java.io.Serializable
|
||||||
import kotlinx.android.synthetic.main.dialog_feed_group_create.cancel_button
|
import kotlinx.android.synthetic.main.dialog_feed_group_create.cancel_button
|
||||||
import kotlinx.android.synthetic.main.dialog_feed_group_create.confirm_button
|
import kotlinx.android.synthetic.main.dialog_feed_group_create.confirm_button
|
||||||
import kotlinx.android.synthetic.main.dialog_feed_group_create.delete_button
|
import kotlinx.android.synthetic.main.dialog_feed_group_create.delete_button
|
||||||
@ -51,7 +52,6 @@ import org.schabi.newpipe.local.subscription.item.EmptyPlaceholderItem
|
|||||||
import org.schabi.newpipe.local.subscription.item.PickerIconItem
|
import org.schabi.newpipe.local.subscription.item.PickerIconItem
|
||||||
import org.schabi.newpipe.local.subscription.item.PickerSubscriptionItem
|
import org.schabi.newpipe.local.subscription.item.PickerSubscriptionItem
|
||||||
import org.schabi.newpipe.util.ThemeHelper
|
import org.schabi.newpipe.util.ThemeHelper
|
||||||
import java.io.Serializable
|
|
||||||
|
|
||||||
class FeedGroupDialog : DialogFragment() {
|
class FeedGroupDialog : DialogFragment() {
|
||||||
private lateinit var viewModel: FeedGroupDialogViewModel
|
private lateinit var viewModel: FeedGroupDialogViewModel
|
||||||
|
@ -16,7 +16,6 @@ import org.schabi.newpipe.local.feed.FeedDatabaseManager
|
|||||||
import org.schabi.newpipe.local.subscription.FeedGroupIcon
|
import org.schabi.newpipe.local.subscription.FeedGroupIcon
|
||||||
import org.schabi.newpipe.local.subscription.SubscriptionManager
|
import org.schabi.newpipe.local.subscription.SubscriptionManager
|
||||||
|
|
||||||
|
|
||||||
class FeedGroupDialogViewModel(applicationContext: Context, val groupId: Long = FeedGroupEntity.GROUP_ALL_ID) : ViewModel() {
|
class FeedGroupDialogViewModel(applicationContext: Context, val groupId: Long = FeedGroupEntity.GROUP_ALL_ID) : ViewModel() {
|
||||||
class Factory(val context: Context, val groupId: Long = FeedGroupEntity.GROUP_ALL_ID) : ViewModelProvider.Factory {
|
class Factory(val context: Context, val groupId: Long = FeedGroupEntity.GROUP_ALL_ID) : ViewModelProvider.Factory {
|
||||||
@Suppress("UNCHECKED_CAST")
|
@Suppress("UNCHECKED_CAST")
|
||||||
|
@ -16,6 +16,7 @@ import com.xwray.groupie.TouchCallback
|
|||||||
import com.xwray.groupie.kotlinandroidextensions.GroupieViewHolder
|
import com.xwray.groupie.kotlinandroidextensions.GroupieViewHolder
|
||||||
import icepick.Icepick
|
import icepick.Icepick
|
||||||
import icepick.State
|
import icepick.State
|
||||||
|
import java.util.Collections
|
||||||
import kotlinx.android.synthetic.main.dialog_feed_group_reorder.confirm_button
|
import kotlinx.android.synthetic.main.dialog_feed_group_reorder.confirm_button
|
||||||
import kotlinx.android.synthetic.main.dialog_feed_group_reorder.feed_groups_list
|
import kotlinx.android.synthetic.main.dialog_feed_group_reorder.feed_groups_list
|
||||||
import org.schabi.newpipe.R
|
import org.schabi.newpipe.R
|
||||||
@ -24,7 +25,6 @@ import org.schabi.newpipe.local.subscription.dialog.FeedGroupReorderDialogViewMo
|
|||||||
import org.schabi.newpipe.local.subscription.dialog.FeedGroupReorderDialogViewModel.DialogEvent.SuccessEvent
|
import org.schabi.newpipe.local.subscription.dialog.FeedGroupReorderDialogViewModel.DialogEvent.SuccessEvent
|
||||||
import org.schabi.newpipe.local.subscription.item.FeedGroupReorderItem
|
import org.schabi.newpipe.local.subscription.item.FeedGroupReorderItem
|
||||||
import org.schabi.newpipe.util.ThemeHelper
|
import org.schabi.newpipe.util.ThemeHelper
|
||||||
import java.util.Collections
|
|
||||||
|
|
||||||
class FeedGroupReorderDialog : DialogFragment() {
|
class FeedGroupReorderDialog : DialogFragment() {
|
||||||
private lateinit var viewModel: FeedGroupReorderDialogViewModel
|
private lateinit var viewModel: FeedGroupReorderDialogViewModel
|
||||||
@ -93,8 +93,11 @@ class FeedGroupReorderDialog : DialogFragment() {
|
|||||||
private fun getItemTouchCallback(): SimpleCallback {
|
private fun getItemTouchCallback(): SimpleCallback {
|
||||||
return object : TouchCallback() {
|
return object : TouchCallback() {
|
||||||
|
|
||||||
override fun onMove(recyclerView: RecyclerView, source: RecyclerView.ViewHolder,
|
override fun onMove(
|
||||||
target: RecyclerView.ViewHolder): Boolean {
|
recyclerView: RecyclerView,
|
||||||
|
source: RecyclerView.ViewHolder,
|
||||||
|
target: RecyclerView.ViewHolder
|
||||||
|
): Boolean {
|
||||||
val sourceIndex = source.adapterPosition
|
val sourceIndex = source.adapterPosition
|
||||||
val targetIndex = target.adapterPosition
|
val targetIndex = target.adapterPosition
|
||||||
|
|
||||||
|
@ -14,7 +14,6 @@ import org.schabi.newpipe.util.ImageDisplayConstants
|
|||||||
import org.schabi.newpipe.util.Localization
|
import org.schabi.newpipe.util.Localization
|
||||||
import org.schabi.newpipe.util.OnClickGesture
|
import org.schabi.newpipe.util.OnClickGesture
|
||||||
|
|
||||||
|
|
||||||
class ChannelItem(
|
class ChannelItem(
|
||||||
private val infoItem: ChannelInfoItem,
|
private val infoItem: ChannelInfoItem,
|
||||||
private val subscriptionId: Long = -1L,
|
private val subscriptionId: Long = -1L,
|
||||||
|
@ -19,8 +19,8 @@ data class FeedGroupReorderItem(
|
|||||||
val icon: FeedGroupIcon,
|
val icon: FeedGroupIcon,
|
||||||
val dragCallback: ItemTouchHelper
|
val dragCallback: ItemTouchHelper
|
||||||
) : Item() {
|
) : Item() {
|
||||||
constructor (feedGroupEntity: FeedGroupEntity, dragCallback: ItemTouchHelper)
|
constructor (feedGroupEntity: FeedGroupEntity, dragCallback: ItemTouchHelper) :
|
||||||
: this(feedGroupEntity.uid, feedGroupEntity.name, feedGroupEntity.icon, dragCallback)
|
this(feedGroupEntity.uid, feedGroupEntity.name, feedGroupEntity.icon, dragCallback)
|
||||||
|
|
||||||
override fun getId(): Long {
|
override fun getId(): Long {
|
||||||
return when (groupId) {
|
return when (groupId) {
|
||||||
|
@ -108,7 +108,6 @@ class FeedImportExportItem(
|
|||||||
} catch (e: ExtractionException) {
|
} catch (e: ExtractionException) {
|
||||||
throw RuntimeException("Services array contains an entry that it's not a valid service name ($serviceName)", e)
|
throw RuntimeException("Services array contains an entry that it's not a valid service name ($serviceName)", e)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
package org.schabi.newpipe.util
|
package org.schabi.newpipe.util
|
||||||
|
|
||||||
|
import java.io.IOException
|
||||||
|
import java.io.InterruptedIOException
|
||||||
|
import java.net.SocketException
|
||||||
|
import javax.net.ssl.SSLException
|
||||||
import org.junit.Assert.assertFalse
|
import org.junit.Assert.assertFalse
|
||||||
import org.junit.Assert.assertTrue
|
import org.junit.Assert.assertTrue
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.schabi.newpipe.util.ExceptionUtils.Companion.hasAssignableCause
|
import org.schabi.newpipe.util.ExceptionUtils.Companion.hasAssignableCause
|
||||||
import org.schabi.newpipe.util.ExceptionUtils.Companion.hasExactCause
|
import org.schabi.newpipe.util.ExceptionUtils.Companion.hasExactCause
|
||||||
import java.io.IOException
|
|
||||||
import java.io.InterruptedIOException
|
|
||||||
import java.net.SocketException
|
|
||||||
import javax.net.ssl.SSLException
|
|
||||||
|
|
||||||
class ExceptionUtilsTest {
|
class ExceptionUtilsTest {
|
||||||
@Test fun `assignable causes`() {
|
@Test fun `assignable causes`() {
|
||||||
|
Loading…
Reference in New Issue
Block a user