ktlint format

This commit is contained in:
Felix 2020-06-12 01:41:03 +02:00
parent bb3c709267
commit 9ed70c11f4
16 changed files with 66 additions and 82 deletions

View file

@ -7,7 +7,7 @@
- [touch] Link for events can be opened from details
# 0.7.0
- [debug] im/export also for progess (not only bookmarks)
- [debug] im/export also for progress (not only bookmarks)
- [debug] debug menu disabled by default
- [touch] navigation rework
- [touch] global search

View file

@ -145,7 +145,6 @@ abstract class ChaosflixDatabase : RoomDatabase() {
`endDate` INTEGER NOT NULL,
`description` TEXT)""")
}
}
}
}

View file

@ -11,14 +11,15 @@ import java.util.Date
import javax.net.ssl.SSLHandshakeException
class EventInfoRepository(
private val api: EventInfoApi,
private val dao: EventInfoDao) {
private val api: EventInfoApi,
private val dao: EventInfoDao
) {
suspend fun updateMediaInfo() {
val eventInfoWrapper = withNetworkErrorHandling {
return@withNetworkErrorHandling api.getVocEvents()
}
if(eventInfoWrapper != null) {
if (eventInfoWrapper != null) {
val eventInfos = eventInfoWrapper.events.values.mapNotNull { EventInfo.fromVocEventDto(it) }
dao.updateOrInsert(eventInfos)
}
@ -45,4 +46,4 @@ class EventInfoRepository(
companion object {
private val TAG = EventInfoRepository::class.java.simpleName
}
}
}

View file

@ -8,18 +8,18 @@ import java.util.Date
import java.util.Locale
@Entity(tableName = "event_info")
data class EventInfo(
@PrimaryKey(autoGenerate = true)
var id: Long = 0,
var name: String,
var location: String,
var streaming: Boolean?,
var startDate: Date,
var endDate: Date,
var description: String?
@PrimaryKey(autoGenerate = true)
var id: Long = 0,
var name: String,
var location: String,
var streaming: Boolean?,
var startDate: Date,
var endDate: Date,
var description: String?
) {
fun getDateText(): String {
val simpleDateFormat = SimpleDateFormat("dd.MM.yyyy", Locale.getDefault())
return if(startDate == endDate) {
return if (startDate == endDate) {
simpleDateFormat.format(startDate)
} else {
"${simpleDateFormat.format(startDate)} - ${simpleDateFormat.format(endDate)}"
@ -28,20 +28,18 @@ data class EventInfo(
companion object {
fun fromVocEventDto(dto: VocEventDto): EventInfo? {
return if(dto.name == null
|| dto.location == null
|| dto.startDate == null
|| dto.endDate == null
return if (dto.name == null ||
dto.location == null ||
dto.startDate == null ||
dto.endDate == null
) {
null
} else {
val dateFormat = SimpleDateFormat("yyyy-MM-dd", Locale.getDefault())
val startDate = dateFormat.parse(dto.startDate)
val endDate = dateFormat.parse(dto.endDate)
EventInfo(0,dto.name, dto.location, dto.streaming, startDate, endDate, dto.description)
EventInfo(0, dto.name, dto.location, dto.streaming, startDate, endDate, dto.description)
}
}
}
}

View file

@ -6,7 +6,7 @@ import androidx.room.Query
import de.nicidienase.chaosflix.common.mediadata.entities.recording.persistence.BaseDao
@Dao
abstract class EventInfoDao: BaseDao<EventInfo>() {
abstract class EventInfoDao : BaseDao<EventInfo>() {
@Query("SELECT * FROM event_info")
abstract fun getAll(): LiveData<List<EventInfo>>

View file

@ -5,13 +5,13 @@ import com.google.gson.annotations.SerializedName
@Keep
data class EventInfoWrapperDto(
@SerializedName("voc_events") val events: Map<String, VocEventDto>,
@SerializedName("voc_events_count") val eventsCount: CountInfo
@SerializedName("voc_events") val events: Map<String, VocEventDto>,
@SerializedName("voc_events_count") val eventsCount: CountInfo
)
data class CountInfo(
val all: Int,
val with_streaming: Int,
val without_streaming: Int,
val undefined_streaming: Int
val all: Int,
val with_streaming: Int,
val without_streaming: Int,
val undefined_streaming: Int
)

View file

@ -5,21 +5,21 @@ import com.google.gson.annotations.SerializedName
@Keep
data class VocEventDto(
val name: String?,
@SerializedName("short_name")
val shortName: String?,
val location: String?,
@SerializedName("start_date")
val startDate: String?, // Date: YYYY-MM-DD
@SerializedName("end_date")
val endDate: String?, // Date: YYYY-MM-DD
val description: String?,
@SerializedName("voc_wiki_path")
val vocWikiPath: String?,
val streaming: Boolean?,
@SerializedName("planing_status")
val planingStatus: String?,
val cases: List<String>?,
val buildup: String?, // Date: YYYY-MM-DD
val teardown: String? // Date: YYYY-MM-DD
)
val name: String?,
@SerializedName("short_name")
val shortName: String?,
val location: String?,
@SerializedName("start_date")
val startDate: String?, // Date: YYYY-MM-DD
@SerializedName("end_date")
val endDate: String?, // Date: YYYY-MM-DD
val description: String?,
@SerializedName("voc_wiki_path")
val vocWikiPath: String?,
val streaming: Boolean?,
@SerializedName("planing_status")
val planingStatus: String?,
val cases: List<String>?,
val buildup: String?, // Date: YYYY-MM-DD
val teardown: String? // Date: YYYY-MM-DD
)

View file

@ -3,7 +3,6 @@ package de.nicidienase.chaosflix.common.mediadata.network
import android.os.Build
import com.google.gson.Gson
import de.nicidienase.chaosflix.BuildConfig
import de.nicidienase.chaosflix.common.SingletonHolder2
import de.nicidienase.chaosflix.common.SingletonHolder3
import java.io.File
import java.util.concurrent.TimeUnit

View file

@ -8,4 +8,3 @@ interface EventInfoApi {
@GET("/eventkalender/events.json")
suspend fun getVocEvents(): EventInfoWrapperDto
}

View file

@ -19,11 +19,11 @@ import de.nicidienase.chaosflix.common.userdata.entities.watchlist.WatchlistItem
import de.nicidienase.chaosflix.common.util.LiveEvent
import de.nicidienase.chaosflix.common.util.SingleLiveEvent
import de.nicidienase.chaosflix.touch.browse.cast.CastService
import java.io.File
import java.util.ArrayList
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import java.io.File
import java.util.ArrayList
class DetailsViewModel(
private val database: ChaosflixDatabase,
@ -280,15 +280,15 @@ class DetailsViewModel(
}
sealed class State {
object PlayOfflineItem: State()
object PlayOnlineItem: State()
object SelectRecording: State()
object DownloadRecording: State()
data class DisplayEvent(val event: Event): State()
object PlayExternal: State()
object Error: State()
object LoadingRecordings: State()
data class OpenCustomTab(val uri: Uri): State()
object PlayOfflineItem : State()
object PlayOnlineItem : State()
object SelectRecording : State()
object DownloadRecording : State()
data class DisplayEvent(val event: Event) : State()
object PlayExternal : State()
object Error : State()
object LoadingRecordings : State()
data class OpenCustomTab(val uri: Uri) : State()
}
private fun postStateWithEventAndRecordings(s: State, e: Event) {
@ -301,7 +301,7 @@ class DetailsViewModel(
}
}
fun openLink() {
fun openLink() {
eventId.value?.let {
viewModelScope.launch {
val eventSync = mediaRepository.getEventSync(it)
@ -313,7 +313,7 @@ class DetailsViewModel(
}
private fun openCustomTab(link: String?) {
if(link != null) {
if (link != null) {
try {
state.postValue(
LiveEvent(
@ -321,7 +321,6 @@ class DetailsViewModel(
)
)
} catch (e: Exception) {
}
}
}

View file

@ -8,7 +8,7 @@ import org.junit.jupiter.api.Test
class ChaosflixUtilTest {
val api = ApiFactory.getInstance("https://api.media.ccc.de","https://c3voc.de", null).recordingApi
val api = ApiFactory.getInstance("https://api.media.ccc.de", "https://c3voc.de", null).recordingApi
@Test
fun testGPN19() = genericTest("gpn19", false)

View file

@ -2,16 +2,16 @@ package de.nicidienase.chaosflix.common.mediadata
import de.nicidienase.chaosflix.common.mediadata.entities.eventinfo.EventInfo
import de.nicidienase.chaosflix.common.mediadata.network.ApiFactory
import java.util.Date
import kotlinx.coroutines.runBlocking
import org.hamcrest.MatcherAssert.assertThat
import org.hamcrest.Matchers
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
import java.util.Date
class EventInfoServiceTest {
private val apiFactory = ApiFactory.getInstance("https://api.media.ccc.de","https://c3voc.de", null)
private val apiFactory = ApiFactory.getInstance("https://api.media.ccc.de", "https://c3voc.de", null)
private val api = apiFactory.eventInfoApi
@BeforeEach
@ -33,6 +33,4 @@ class EventInfoServiceTest {
val partition = eventInfos.partition { it.startDate.after(now) }
assertThat(partition.first.size, Matchers.lessThanOrEqualTo(partition.second.size))
}
}

View file

@ -10,7 +10,7 @@ import org.junit.jupiter.api.Test
class RecordingServiceTest {
private val apiFactory = ApiFactory.getInstance("https://api.media.ccc.de","https://c3voc.de", null)
private val apiFactory = ApiFactory.getInstance("https://api.media.ccc.de", "https://c3voc.de", null)
private val api = apiFactory.recordingApi
@BeforeEach

View file

@ -1,6 +1,5 @@
package de.nicidienase.chaosflix.touch.browse.streaming
import android.net.Uri
import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.recyclerview.widget.DiffUtil
@ -9,7 +8,7 @@ import androidx.recyclerview.widget.RecyclerView
import de.nicidienase.chaosflix.common.mediadata.entities.eventinfo.EventInfo
import de.nicidienase.chaosflix.touch.databinding.ItemEventinfoBinding
class EventInfoAdapter(private val clickListener: (EventInfo) -> Unit): ListAdapter<EventInfo, EventInfoAdapter.ViewHolder>(diffUtilCallback) {
class EventInfoAdapter(private val clickListener: (EventInfo) -> Unit) : ListAdapter<EventInfo, EventInfoAdapter.ViewHolder>(diffUtilCallback) {
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
val binding = ItemEventinfoBinding.inflate(LayoutInflater.from(parent.context), parent, false)
@ -21,7 +20,7 @@ class EventInfoAdapter(private val clickListener: (EventInfo) -> Unit): ListAdap
holder.binding.item = item
}
inner class ViewHolder(val binding: ItemEventinfoBinding): RecyclerView.ViewHolder(binding.root) {
inner class ViewHolder(val binding: ItemEventinfoBinding) : RecyclerView.ViewHolder(binding.root) {
init {
binding.root.setOnClickListener {
clickListener.invoke(getItem(bindingAdapterPosition))
@ -32,11 +31,10 @@ class EventInfoAdapter(private val clickListener: (EventInfo) -> Unit): ListAdap
companion object {
private val diffUtilCallback = object : DiffUtil.ItemCallback<EventInfo>() {
override fun areItemsTheSame(oldItem: EventInfo, newItem: EventInfo): Boolean =
oldItem=== newItem
oldItem === newItem
override fun areContentsTheSame(oldItem: EventInfo, newItem: EventInfo): Boolean =
oldItem == newItem
}
}
}
}

View file

@ -1,7 +1,6 @@
package de.nicidienase.chaosflix.touch.browse.streaming
import android.content.DialogInterface
import android.content.Intent
import android.net.Uri
import android.os.Bundle
import android.util.Log
@ -10,9 +9,7 @@ import android.view.View
import android.view.ViewGroup
import android.widget.Toast
import androidx.appcompat.app.AlertDialog
import androidx.browser.customtabs.CustomTabsClient
import androidx.browser.customtabs.CustomTabsIntent
import androidx.browser.customtabs.CustomTabsService
import androidx.fragment.app.Fragment
import androidx.fragment.app.viewModels
import androidx.lifecycle.Observer

View file

@ -381,10 +381,6 @@ class EventDetailsFragment : Fragment() {
viewModel.playInExternalPlayer()
return true
}
R.id.action_frontend_link -> {
viewModel.openFrontendLink()
return true
}
R.id.action_link -> {
viewModel.openLink()
return true