mirror of
https://github.com/NiciDieNase/chaosflix
synced 2024-11-23 04:43:07 +00:00
formatting
This commit is contained in:
parent
4c49e8f8a8
commit
2077e1ed54
12 changed files with 42 additions and 47 deletions
|
@ -21,20 +21,20 @@ class ChaosflixPreferenceManager(private val sharedPref: SharedPreferences) {
|
|||
var recommendationsGenerated: Boolean by BooleanPreferencesDelegate(RECOMMENDATIONS_GENERATED, false)
|
||||
|
||||
private inner class BooleanPreferencesDelegate(key: String, default: Boolean) :
|
||||
PreferencesDelegate<Boolean>(key,default, SharedPreferences::getBoolean, SharedPreferences.Editor::putBoolean)
|
||||
PreferencesDelegate<Boolean>(key, default, SharedPreferences::getBoolean, SharedPreferences.Editor::putBoolean)
|
||||
|
||||
private inner class StringPreferenceDelegate(key: String, default: String):
|
||||
PreferencesDelegate<String>(key,default, SharedPreferences::getString, SharedPreferences.Editor::putString)
|
||||
private inner class StringPreferenceDelegate(key: String, default: String) :
|
||||
PreferencesDelegate<String>(key, default, SharedPreferences::getString, SharedPreferences.Editor::putString)
|
||||
|
||||
private inner class LongPreferenceDelegate(key: String, default: Long):
|
||||
PreferencesDelegate<Long>(key,default, SharedPreferences::getLong, SharedPreferences.Editor::putLong)
|
||||
private inner class LongPreferenceDelegate(key: String, default: Long) :
|
||||
PreferencesDelegate<Long>(key, default, SharedPreferences::getLong, SharedPreferences.Editor::putLong)
|
||||
|
||||
abstract inner class PreferencesDelegate<T>(
|
||||
private val key: String,
|
||||
private val default: T,
|
||||
private val getter: SharedPreferences.(String, T) -> T?,
|
||||
private val setter: SharedPreferences.Editor.(String, T) -> SharedPreferences.Editor
|
||||
) : ReadWriteProperty<ChaosflixPreferenceManager, T> {
|
||||
private val key: String,
|
||||
private val default: T,
|
||||
private val getter: SharedPreferences.(String, T) -> T?,
|
||||
private val setter: SharedPreferences.Editor.(String, T) -> SharedPreferences.Editor
|
||||
) : ReadWriteProperty<ChaosflixPreferenceManager, T> {
|
||||
|
||||
override fun getValue(thisRef: ChaosflixPreferenceManager, property: KProperty<*>): T {
|
||||
return sharedPref.getter(key, default) ?: default
|
||||
|
|
|
@ -22,13 +22,13 @@ import de.nicidienase.chaosflix.common.userdata.entities.download.OfflineEvent
|
|||
import de.nicidienase.chaosflix.common.userdata.entities.download.OfflineEventDao
|
||||
import de.nicidienase.chaosflix.common.util.LiveEvent
|
||||
import de.nicidienase.chaosflix.common.viewmodel.DetailsViewModel
|
||||
import java.io.File
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.GlobalScope
|
||||
import kotlinx.coroutines.SupervisorJob
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
import java.io.File
|
||||
|
||||
class OfflineItemManager(
|
||||
context: Context,
|
||||
|
@ -198,7 +198,7 @@ class OfflineItemManager(
|
|||
|
||||
private fun getMovieDir(): String {
|
||||
val dir = preferencesManager.downloadFolder
|
||||
return if(dir.isNullOrBlank()){
|
||||
return if (dir.isNullOrBlank()) {
|
||||
Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MOVIES).path
|
||||
} else {
|
||||
dir
|
||||
|
|
|
@ -22,13 +22,13 @@ import de.nicidienase.chaosflix.common.userdata.entities.watchlist.WatchlistItem
|
|||
import de.nicidienase.chaosflix.common.util.ConferenceUtil
|
||||
import de.nicidienase.chaosflix.common.util.LiveEvent
|
||||
import de.nicidienase.chaosflix.common.util.SingleLiveEvent
|
||||
import java.io.IOException
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.SupervisorJob
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
import retrofit2.Response
|
||||
import java.io.IOException
|
||||
|
||||
class MediaRepository(
|
||||
private val recordingApi: RecordingService,
|
||||
|
|
|
@ -5,14 +5,14 @@ import android.util.Log
|
|||
import com.google.gson.Gson
|
||||
import de.nicidienase.chaosflix.BuildConfig
|
||||
import de.nicidienase.chaosflix.common.SingletonHolder2
|
||||
import java.io.File
|
||||
import java.net.SocketTimeoutException
|
||||
import java.util.concurrent.TimeUnit
|
||||
import okhttp3.Cache
|
||||
import okhttp3.Interceptor
|
||||
import okhttp3.OkHttpClient
|
||||
import retrofit2.Retrofit
|
||||
import retrofit2.converter.gson.GsonConverterFactory
|
||||
import java.io.File
|
||||
import java.net.SocketTimeoutException
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
class ApiFactory private constructor(apiUrl: String, cache: File? = null) {
|
||||
|
||||
|
|
|
@ -9,8 +9,8 @@ import androidx.paging.LivePagedListBuilder
|
|||
import androidx.paging.PagedList
|
||||
import de.nicidienase.chaosflix.R
|
||||
import de.nicidienase.chaosflix.common.ChaosflixDatabase
|
||||
import de.nicidienase.chaosflix.common.OfflineItemManager
|
||||
import de.nicidienase.chaosflix.common.ChaosflixPreferenceManager
|
||||
import de.nicidienase.chaosflix.common.OfflineItemManager
|
||||
import de.nicidienase.chaosflix.common.ResourcesFacade
|
||||
import de.nicidienase.chaosflix.common.mediadata.MediaRepository
|
||||
import de.nicidienase.chaosflix.common.mediadata.SearchResultDataSourceFactory
|
||||
|
@ -26,12 +26,12 @@ import kotlinx.coroutines.Dispatchers
|
|||
import kotlinx.coroutines.launch
|
||||
|
||||
class BrowseViewModel(
|
||||
val offlineItemManager: OfflineItemManager,
|
||||
private val mediaRepository: MediaRepository,
|
||||
private val database: ChaosflixDatabase,
|
||||
private val streamingRepository: StreamingRepository,
|
||||
private val preferencesManager: ChaosflixPreferenceManager,
|
||||
private val resources: ResourcesFacade
|
||||
val offlineItemManager: OfflineItemManager,
|
||||
private val mediaRepository: MediaRepository,
|
||||
private val database: ChaosflixDatabase,
|
||||
private val streamingRepository: StreamingRepository,
|
||||
private val preferencesManager: ChaosflixPreferenceManager,
|
||||
private val resources: ResourcesFacade
|
||||
) : ViewModel() {
|
||||
|
||||
val state: SingleLiveEvent<LiveEvent<State, Event, String>> = SingleLiveEvent()
|
||||
|
|
|
@ -8,25 +8,25 @@ import androidx.lifecycle.ViewModel
|
|||
import androidx.lifecycle.liveData
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import de.nicidienase.chaosflix.common.ChaosflixDatabase
|
||||
import de.nicidienase.chaosflix.common.ChaosflixPreferenceManager
|
||||
import de.nicidienase.chaosflix.common.ChaosflixUtil
|
||||
import de.nicidienase.chaosflix.common.OfflineItemManager
|
||||
import de.nicidienase.chaosflix.common.ChaosflixPreferenceManager
|
||||
import de.nicidienase.chaosflix.common.mediadata.MediaRepository
|
||||
import de.nicidienase.chaosflix.common.mediadata.entities.recording.persistence.Event
|
||||
import de.nicidienase.chaosflix.common.mediadata.entities.recording.persistence.Recording
|
||||
import de.nicidienase.chaosflix.common.userdata.entities.watchlist.WatchlistItem
|
||||
import de.nicidienase.chaosflix.common.util.LiveEvent
|
||||
import de.nicidienase.chaosflix.common.util.SingleLiveEvent
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import java.io.File
|
||||
import java.util.ArrayList
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
class DetailsViewModel(
|
||||
private val database: ChaosflixDatabase,
|
||||
private val offlineItemManager: OfflineItemManager,
|
||||
private val preferencesManager: ChaosflixPreferenceManager,
|
||||
private val mediaRepository: MediaRepository
|
||||
private val database: ChaosflixDatabase,
|
||||
private val offlineItemManager: OfflineItemManager,
|
||||
private val preferencesManager: ChaosflixPreferenceManager,
|
||||
private val mediaRepository: MediaRepository
|
||||
) : ViewModel() {
|
||||
|
||||
private var eventId: Long = 0
|
||||
|
|
|
@ -7,8 +7,8 @@ import androidx.lifecycle.ViewModel
|
|||
import androidx.lifecycle.ViewModelProvider
|
||||
import de.nicidienase.chaosflix.R
|
||||
import de.nicidienase.chaosflix.common.ChaosflixDatabase
|
||||
import de.nicidienase.chaosflix.common.OfflineItemManager
|
||||
import de.nicidienase.chaosflix.common.ChaosflixPreferenceManager
|
||||
import de.nicidienase.chaosflix.common.OfflineItemManager
|
||||
import de.nicidienase.chaosflix.common.ResourcesFacade
|
||||
import de.nicidienase.chaosflix.common.SingletonHolder
|
||||
import de.nicidienase.chaosflix.common.mediadata.MediaRepository
|
||||
|
|
|
@ -18,7 +18,6 @@ object ChannelManager {
|
|||
|
||||
enum class Channels {
|
||||
PROMOTED,
|
||||
|
||||
}
|
||||
|
||||
suspend fun setupChannels(context: Context, viewmodel: BrowseViewModel, prefs: ChaosflixPreferenceManager) {
|
||||
|
@ -59,9 +58,9 @@ object ChannelManager {
|
|||
val programUri = context.contentResolver.insert(TvContractCompat.PreviewPrograms.CONTENT_URI, toContentValues)
|
||||
ContentUris.parseId(programUri)
|
||||
}
|
||||
Log.d(TAG,"Added $programmIds")
|
||||
Log.d(TAG, "Added $programmIds")
|
||||
}
|
||||
}
|
||||
|
||||
private val TAG = ChannelManager::class.java.simpleName
|
||||
}
|
||||
}
|
||||
|
|
|
@ -51,21 +51,21 @@ class ChaosRecommendationsService : IntentService("ChaosRecommendationService")
|
|||
.asBitmap()
|
||||
.load(event.thumbUrl)
|
||||
.submit(cardWidth, cardHeight) // Only use for synchronous .get()
|
||||
.get();
|
||||
.get()
|
||||
|
||||
val id = event.id.toInt()
|
||||
val contentRecommendation = builder.setIdTag("Event-$id")
|
||||
.setTitle(event.title)
|
||||
.setText(event.subtitle)
|
||||
.setContentImage(bitmap)
|
||||
.setContentIntentData(ContentRecommendation.INTENT_TYPE_ACTIVITY,buildPendingIntent(event),0,null)
|
||||
.setContentIntentData(ContentRecommendation.INTENT_TYPE_ACTIVITY, buildPendingIntent(event), 0, null)
|
||||
.build()
|
||||
val notification = contentRecommendation.getNotificationObject(applicationContext)
|
||||
notificationManager?.notify(id, notification)
|
||||
|
||||
Log.d(TAG, "Added notification for ${event.title}")
|
||||
|
||||
if(++ count >= MAX_RECOMMENDATIONS){
|
||||
if (++ count >= MAX_RECOMMENDATIONS) {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
@ -93,5 +93,4 @@ class ChaosRecommendationsService : IntentService("ChaosRecommendationService")
|
|||
private val TAG = ChaosRecommendationsService::class.java.simpleName
|
||||
private const val MAX_RECOMMENDATIONS = 6
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,8 +24,8 @@ class ConferencesActivity : androidx.fragment.app.FragmentActivity() {
|
|||
val prefs = ChaosflixPreferenceManager(PreferenceManager.getDefaultSharedPreferences(applicationContext))
|
||||
|
||||
val viewmodel = ViewModelProvider(
|
||||
this,ViewModelFactory.getInstance(this)).get(BrowseViewModel::class.java)
|
||||
if(android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
|
||||
this, ViewModelFactory.getInstance(this)).get(BrowseViewModel::class.java)
|
||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
|
||||
lifecycleScope.launch {
|
||||
ChannelManager.setupChannels(this@ConferencesActivity, viewmodel, prefs)
|
||||
}
|
||||
|
@ -38,7 +38,6 @@ class ConferencesActivity : androidx.fragment.app.FragmentActivity() {
|
|||
// startService(Intent(this, ChaosRecommendationsService::class.java))
|
||||
}
|
||||
|
||||
|
||||
companion object {
|
||||
private val TAG = ConferencesActivity::class.java.simpleName
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ class DetailsActivity : androidx.fragment.app.FragmentActivity() {
|
|||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_event_details)
|
||||
lifecycleScope.launch {
|
||||
val fragment = if(intent.action == Intent.ACTION_VIEW) {
|
||||
val fragment = if (intent.action == Intent.ACTION_VIEW) {
|
||||
val guid = intent.data.lastPathSegment
|
||||
EventDetailsFragment().apply {
|
||||
arguments = bundleOf(EventDetailsFragment.ARG_EVENT_GUID to guid)
|
||||
|
|
|
@ -98,7 +98,6 @@ class EventDetailsFragment : DetailsSupportFragment() {
|
|||
detailsViewModel = ViewModelProvider(this, viewModelFactory).get(DetailsViewModel::class.java)
|
||||
playerViewModel = ViewModelProvider(this, viewModelFactory).get(PlayerViewModel::class.java)
|
||||
|
||||
|
||||
val detailsPresenter = FullWidthDetailsOverviewRowPresenter(
|
||||
EventDetailsDescriptionPresenter(requireContext()))
|
||||
|
||||
|
@ -122,7 +121,7 @@ class EventDetailsFragment : DetailsSupportFragment() {
|
|||
playerViewModel.setEvent(guid)
|
||||
val eventLiveData = detailsViewModel.setEventByGuid(guid)
|
||||
eventLiveData.observe(viewLifecycleOwner, Observer { event ->
|
||||
if(event != null){
|
||||
if (event != null) {
|
||||
title = event.title
|
||||
|
||||
initializeBackgroundWithImage(event.posterUrl)
|
||||
|
@ -139,7 +138,6 @@ class EventDetailsFragment : DetailsSupportFragment() {
|
|||
|
||||
onItemViewClickedListener = ItemViewClickedListener(this@EventDetailsFragment)
|
||||
|
||||
|
||||
startEntranceTransition()
|
||||
setupObserver(detailsViewModel)
|
||||
}
|
||||
|
@ -169,7 +167,7 @@ class EventDetailsFragment : DetailsSupportFragment() {
|
|||
detailsOverview.actionsAdapter = actionAdapter
|
||||
event.thumbUrl.let { setThumb(it, detailsOverview) }
|
||||
liveData.observe(viewLifecycleOwner, Observer {
|
||||
if(it != null){
|
||||
if (it != null) {
|
||||
detailsOverview.item = it
|
||||
}
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue