From 2077e1ed54ab8bfc384c162d047e4a3f5420a694 Mon Sep 17 00:00:00 2001 From: Felix Date: Sun, 12 Apr 2020 19:30:15 +0200 Subject: [PATCH] formatting --- .../common/ChaosflixPreferenceManager.kt | 20 +++++++++---------- .../chaosflix/common/OfflineItemManager.kt | 4 ++-- .../common/mediadata/MediaRepository.kt | 2 +- .../common/mediadata/network/ApiFactory.kt | 6 +++--- .../common/viewmodel/BrowseViewModel.kt | 14 ++++++------- .../common/viewmodel/DetailsViewModel.kt | 14 ++++++------- .../common/viewmodel/ViewModelFactory.kt | 2 +- .../chaosflix/leanback/ChannelManager.kt | 5 ++--- .../leanback/ChaosRecommendationsService.kt | 9 ++++----- .../conferences/ConferencesActivity.kt | 5 ++--- .../leanback/detail/DetailsActivity.kt | 2 +- .../leanback/detail/EventDetailsFragment.kt | 6 ++---- 12 files changed, 42 insertions(+), 47 deletions(-) diff --git a/common/src/main/java/de/nicidienase/chaosflix/common/ChaosflixPreferenceManager.kt b/common/src/main/java/de/nicidienase/chaosflix/common/ChaosflixPreferenceManager.kt index 65b4bed2..7d89ede9 100644 --- a/common/src/main/java/de/nicidienase/chaosflix/common/ChaosflixPreferenceManager.kt +++ b/common/src/main/java/de/nicidienase/chaosflix/common/ChaosflixPreferenceManager.kt @@ -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(key,default, SharedPreferences::getBoolean, SharedPreferences.Editor::putBoolean) + PreferencesDelegate(key, default, SharedPreferences::getBoolean, SharedPreferences.Editor::putBoolean) - private inner class StringPreferenceDelegate(key: String, default: String): - PreferencesDelegate(key,default, SharedPreferences::getString, SharedPreferences.Editor::putString) + private inner class StringPreferenceDelegate(key: String, default: String) : + PreferencesDelegate(key, default, SharedPreferences::getString, SharedPreferences.Editor::putString) - private inner class LongPreferenceDelegate(key: String, default: Long): - PreferencesDelegate(key,default, SharedPreferences::getLong, SharedPreferences.Editor::putLong) + private inner class LongPreferenceDelegate(key: String, default: Long) : + PreferencesDelegate(key, default, SharedPreferences::getLong, SharedPreferences.Editor::putLong) abstract inner class PreferencesDelegate( - 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 { + 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 { override fun getValue(thisRef: ChaosflixPreferenceManager, property: KProperty<*>): T { return sharedPref.getter(key, default) ?: default diff --git a/common/src/main/java/de/nicidienase/chaosflix/common/OfflineItemManager.kt b/common/src/main/java/de/nicidienase/chaosflix/common/OfflineItemManager.kt index b108a915..70a69044 100644 --- a/common/src/main/java/de/nicidienase/chaosflix/common/OfflineItemManager.kt +++ b/common/src/main/java/de/nicidienase/chaosflix/common/OfflineItemManager.kt @@ -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 diff --git a/common/src/main/java/de/nicidienase/chaosflix/common/mediadata/MediaRepository.kt b/common/src/main/java/de/nicidienase/chaosflix/common/mediadata/MediaRepository.kt index 04a4b0b9..49c634c5 100644 --- a/common/src/main/java/de/nicidienase/chaosflix/common/mediadata/MediaRepository.kt +++ b/common/src/main/java/de/nicidienase/chaosflix/common/mediadata/MediaRepository.kt @@ -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, diff --git a/common/src/main/java/de/nicidienase/chaosflix/common/mediadata/network/ApiFactory.kt b/common/src/main/java/de/nicidienase/chaosflix/common/mediadata/network/ApiFactory.kt index b5947328..dfb4ecf2 100644 --- a/common/src/main/java/de/nicidienase/chaosflix/common/mediadata/network/ApiFactory.kt +++ b/common/src/main/java/de/nicidienase/chaosflix/common/mediadata/network/ApiFactory.kt @@ -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) { diff --git a/common/src/main/java/de/nicidienase/chaosflix/common/viewmodel/BrowseViewModel.kt b/common/src/main/java/de/nicidienase/chaosflix/common/viewmodel/BrowseViewModel.kt index b0335e28..260565be 100644 --- a/common/src/main/java/de/nicidienase/chaosflix/common/viewmodel/BrowseViewModel.kt +++ b/common/src/main/java/de/nicidienase/chaosflix/common/viewmodel/BrowseViewModel.kt @@ -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> = SingleLiveEvent() diff --git a/common/src/main/java/de/nicidienase/chaosflix/common/viewmodel/DetailsViewModel.kt b/common/src/main/java/de/nicidienase/chaosflix/common/viewmodel/DetailsViewModel.kt index 410c339e..d5c7619a 100644 --- a/common/src/main/java/de/nicidienase/chaosflix/common/viewmodel/DetailsViewModel.kt +++ b/common/src/main/java/de/nicidienase/chaosflix/common/viewmodel/DetailsViewModel.kt @@ -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 diff --git a/common/src/main/java/de/nicidienase/chaosflix/common/viewmodel/ViewModelFactory.kt b/common/src/main/java/de/nicidienase/chaosflix/common/viewmodel/ViewModelFactory.kt index 0e37bd70..1d7302b6 100644 --- a/common/src/main/java/de/nicidienase/chaosflix/common/viewmodel/ViewModelFactory.kt +++ b/common/src/main/java/de/nicidienase/chaosflix/common/viewmodel/ViewModelFactory.kt @@ -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 diff --git a/leanback/src/main/java/de/nicidienase/chaosflix/leanback/ChannelManager.kt b/leanback/src/main/java/de/nicidienase/chaosflix/leanback/ChannelManager.kt index 7574cde3..549133ae 100644 --- a/leanback/src/main/java/de/nicidienase/chaosflix/leanback/ChannelManager.kt +++ b/leanback/src/main/java/de/nicidienase/chaosflix/leanback/ChannelManager.kt @@ -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 -} \ No newline at end of file +} diff --git a/leanback/src/main/java/de/nicidienase/chaosflix/leanback/ChaosRecommendationsService.kt b/leanback/src/main/java/de/nicidienase/chaosflix/leanback/ChaosRecommendationsService.kt index a9b232f5..54afe45b 100644 --- a/leanback/src/main/java/de/nicidienase/chaosflix/leanback/ChaosRecommendationsService.kt +++ b/leanback/src/main/java/de/nicidienase/chaosflix/leanback/ChaosRecommendationsService.kt @@ -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 } - -} \ No newline at end of file +} diff --git a/leanback/src/main/java/de/nicidienase/chaosflix/leanback/conferences/ConferencesActivity.kt b/leanback/src/main/java/de/nicidienase/chaosflix/leanback/conferences/ConferencesActivity.kt index 066c273b..dc281f20 100644 --- a/leanback/src/main/java/de/nicidienase/chaosflix/leanback/conferences/ConferencesActivity.kt +++ b/leanback/src/main/java/de/nicidienase/chaosflix/leanback/conferences/ConferencesActivity.kt @@ -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 } diff --git a/leanback/src/main/java/de/nicidienase/chaosflix/leanback/detail/DetailsActivity.kt b/leanback/src/main/java/de/nicidienase/chaosflix/leanback/detail/DetailsActivity.kt index 3586706f..72f47ad3 100644 --- a/leanback/src/main/java/de/nicidienase/chaosflix/leanback/detail/DetailsActivity.kt +++ b/leanback/src/main/java/de/nicidienase/chaosflix/leanback/detail/DetailsActivity.kt @@ -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) diff --git a/leanback/src/main/java/de/nicidienase/chaosflix/leanback/detail/EventDetailsFragment.kt b/leanback/src/main/java/de/nicidienase/chaosflix/leanback/detail/EventDetailsFragment.kt index 9b56c67d..35a52f72 100644 --- a/leanback/src/main/java/de/nicidienase/chaosflix/leanback/detail/EventDetailsFragment.kt +++ b/leanback/src/main/java/de/nicidienase/chaosflix/leanback/detail/EventDetailsFragment.kt @@ -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 } })