cleanup dependencies and fix warnings

This commit is contained in:
Felix Bürkle 2018-12-10 00:57:14 +01:00
parent 7910f63278
commit f4c3cc59cf
9 changed files with 41 additions and 32 deletions

View file

@ -3,7 +3,7 @@ package de.nicidienase.chaosflix.common
import android.arch.persistence.room.Room import android.arch.persistence.room.Room
import android.content.Context import android.content.Context
class DatabaseFactory private constructor(context: Context) { class DatabaseFactory private constructor() {
companion object : SingletonHolder<ChaosflixDatabase, Context>({ companion object : SingletonHolder<ChaosflixDatabase, Context>({
Room.databaseBuilder( Room.databaseBuilder(

View file

@ -45,7 +45,7 @@ class OfflineItemManager(context: Context,
fun updateDownloadStatus(offlineEvents: List<OfflineEvent>) { fun updateDownloadStatus(offlineEvents: List<OfflineEvent>) {
if (offlineEvents.size > 0) { if (offlineEvents.size > 0) {
val downloadRef = offlineEvents.map { it.downloadReference }.toTypedArray().toLongArray() ?: longArrayOf() val downloadRef = offlineEvents.map { it.downloadReference }.toTypedArray().toLongArray()
updateDownloads(downloadRef) updateDownloads(downloadRef)
} }
} }

View file

@ -9,7 +9,6 @@ import de.nicidienase.chaosflix.common.OfflineItemManager
import de.nicidienase.chaosflix.common.PreferencesManager import de.nicidienase.chaosflix.common.PreferencesManager
import de.nicidienase.chaosflix.common.mediadata.entities.recording.persistence.PersistentEvent import de.nicidienase.chaosflix.common.mediadata.entities.recording.persistence.PersistentEvent
import de.nicidienase.chaosflix.common.mediadata.entities.recording.persistence.PersistentRecording import de.nicidienase.chaosflix.common.mediadata.entities.recording.persistence.PersistentRecording
import de.nicidienase.chaosflix.common.mediadata.network.RecordingService
import de.nicidienase.chaosflix.common.mediadata.sync.Downloader import de.nicidienase.chaosflix.common.mediadata.sync.Downloader
import de.nicidienase.chaosflix.common.userdata.entities.watchlist.WatchlistItem import de.nicidienase.chaosflix.common.userdata.entities.watchlist.WatchlistItem
import de.nicidienase.chaosflix.common.util.LiveEvent import de.nicidienase.chaosflix.common.util.LiveEvent
@ -19,7 +18,6 @@ import java.io.File
class DetailsViewModel( class DetailsViewModel(
val database: ChaosflixDatabase, val database: ChaosflixDatabase,
recordingApi: RecordingService,
val offlineItemManager: OfflineItemManager, val offlineItemManager: OfflineItemManager,
val preferencesManager: PreferencesManager, val preferencesManager: PreferencesManager,
val downloader: Downloader val downloader: Downloader

View file

@ -30,7 +30,7 @@ class ViewModelFactory(context: Context) : ViewModelProvider.Factory {
} else if (modelClass.isAssignableFrom(PlayerViewModel::class.java)) { } else if (modelClass.isAssignableFrom(PlayerViewModel::class.java)) {
return PlayerViewModel(database) as T return PlayerViewModel(database) as T
} else if (modelClass.isAssignableFrom(DetailsViewModel::class.java)) { } else if (modelClass.isAssignableFrom(DetailsViewModel::class.java)) {
return DetailsViewModel(database, recordingApi, offlineItemManager, preferencesManager, downloader) as T return DetailsViewModel(database, offlineItemManager, preferencesManager, downloader) as T
} else if (modelClass.isAssignableFrom(PreferencesViewModel::class.java)){ } else if (modelClass.isAssignableFrom(PreferencesViewModel::class.java)){
return PreferencesViewModel(downloader) as T return PreferencesViewModel(downloader) as T
} else { } else {

View file

@ -25,7 +25,6 @@ android {
useProguard false useProguard false
// shrinkResources true // shrinkResources true
// minifyEnabled true // minifyEnabled true
useProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro' 'proguard-rules.pro'
} }
@ -62,8 +61,6 @@ dependencies {
implementation "com.android.support:preference-leanback-v17:${rootProject.ext.supportLibraryVersion}" implementation "com.android.support:preference-leanback-v17:${rootProject.ext.supportLibraryVersion}"
implementation "com.android.support:recyclerview-v7:${rootProject.ext.supportLibraryVersion}" implementation "com.android.support:recyclerview-v7:${rootProject.ext.supportLibraryVersion}"
implementation "android.arch.lifecycle:common-java8:${rootProject.ext.archCompVersion}"
kapt "android.arch.lifecycle:compiler:${rootProject.ext.archCompVersion}"
implementation "org.jetbrains.kotlin:kotlin-reflect:1.2.71" implementation "org.jetbrains.kotlin:kotlin-reflect:1.2.71"
implementation 'com.google.android.exoplayer:exoplayer:2.7.0' implementation 'com.google.android.exoplayer:exoplayer:2.7.0'
@ -82,9 +79,4 @@ dependencies {
androidTestImplementation 'org.hamcrest:hamcrest-library:1.3' androidTestImplementation 'org.hamcrest:hamcrest-library:1.3'
androidTestImplementation 'com.squareup.okhttp3:mockwebserver:3.6.0' androidTestImplementation 'com.squareup.okhttp3:mockwebserver:3.6.0'
androidTestImplementation group: 'commons-io', name: 'commons-io', version: '2.4' androidTestImplementation group: 'commons-io', name: 'commons-io', version: '2.4'
testImplementation 'org.mockito:mockito-core:2.11.0'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
}
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
} }

View file

@ -10,9 +10,10 @@ import android.support.v17.leanback.widget.DividerRow;
import android.support.v17.leanback.widget.HeaderItem; import android.support.v17.leanback.widget.HeaderItem;
import android.support.v17.leanback.widget.ListRow; import android.support.v17.leanback.widget.ListRow;
import android.support.v17.leanback.widget.ListRowPresenter; import android.support.v17.leanback.widget.ListRowPresenter;
import android.support.v17.leanback.widget.Row;
import android.support.v17.leanback.widget.SectionRow; import android.support.v17.leanback.widget.SectionRow;
import android.support.v4.app.FragmentManager;
import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
@ -78,7 +79,13 @@ public class ConferencesBrowseFragment extends BrowseSupportFragment {
viewModel = ViewModelProviders.of(this, new ViewModelFactory(requireContext())).get(BrowseViewModel.class); viewModel = ViewModelProviders.of(this, new ViewModelFactory(requireContext())).get(BrowseViewModel.class);
final BrowseErrorFragment errorFragment = BrowseErrorFragment.showErrorFragment(getFragmentManager(), FRAGMENT); FragmentManager fragmentManager = getFragmentManager();
final BrowseErrorFragment errorFragment;
if(fragmentManager != null){
errorFragment = BrowseErrorFragment.showErrorFragment(fragmentManager, FRAGMENT);
}else {
errorFragment = null;
}
CardPresenter conferencePresenter = new CardPresenter(R.style.ConferenceCardStyle); CardPresenter conferencePresenter = new CardPresenter(R.style.ConferenceCardStyle);
CardPresenter eventPresenter = new CardPresenter(R.style.EventCardStyle); CardPresenter eventPresenter = new CardPresenter(R.style.EventCardStyle);
@ -113,7 +120,7 @@ public class ConferencesBrowseFragment extends BrowseSupportFragment {
if (downloaderEvent.getData() != null) { if (downloaderEvent.getData() != null) {
} }
if (downloaderEvent.getError() != null) { if (downloaderEvent.getError() != null) {
if (!errorFragment.isDetached()) { if (errorFragment != null && !errorFragment.isDetached()) {
errorFragment.setErrorContent(downloaderEvent.getError()); errorFragment.setErrorContent(downloaderEvent.getError());
} }
} }
@ -121,14 +128,18 @@ public class ConferencesBrowseFragment extends BrowseSupportFragment {
case RUNNING: case RUNNING:
break; break;
case DONE: case DONE:
errorFragment.dismiss(); if(errorFragment != null){
errorFragment.dismiss();
}
break; break;
} }
}); });
viewModel.getConferenceGroups().observe(this, conferenceGroups -> { viewModel.getConferenceGroups().observe(this, conferenceGroups -> {
if (conferenceGroups != null && conferenceGroups.size() > 0) { if (conferenceGroups != null && conferenceGroups.size() > 0) {
errorFragment.dismiss(); if(errorFragment != null){
errorFragment.dismiss();
}
Collections.sort(conferenceGroups); Collections.sort(conferenceGroups);
for (ConferenceGroup group : conferenceGroups) { for (ConferenceGroup group : conferenceGroups) {
ListRow row; ListRow row;
@ -136,7 +147,7 @@ public class ConferencesBrowseFragment extends BrowseSupportFragment {
if (conferencesGroupRows.containsKey(group.getName())) { if (conferencesGroupRows.containsKey(group.getName())) {
row = conferencesGroupRows.get(group.getName()); row = conferencesGroupRows.get(group.getName());
} else { } else {
row = buildRow(Collections.EMPTY_LIST, conferencePresenter, group.getName(), ConferenceUtil.getStringForTag(group.getName())); row = buildRow(new ArrayList<>(), conferencePresenter, group.getName(), ConferenceUtil.getStringForTag(group.getName()));
rowsAdapter.add(row); rowsAdapter.add(row);
conferencesGroupRows.put(group.getName(), row); conferencesGroupRows.put(group.getName(), row);
} }
@ -168,9 +179,11 @@ public class ConferencesBrowseFragment extends BrowseSupportFragment {
}); });
} }
private Row bindConferencesToRow(CardPresenter cardPresenter, ConferenceGroup group, ListRow row) { private void bindConferencesToRow(CardPresenter cardPresenter, ConferenceGroup group, ListRow row) {
viewModel.getConferencesByGroup(group.getId()).observe(this, conferences -> { viewModel.getConferencesByGroup(group.getId()).observe(this, conferences -> {
Collections.sort(conferences); if(conferences != null){
Collections.sort(conferences);
}
((ArrayObjectAdapter) row.getAdapter()).setItems(conferences, new DiffCallback<PersistentConference>() { ((ArrayObjectAdapter) row.getAdapter()).setItems(conferences, new DiffCallback<PersistentConference>() {
@Override @Override
public boolean areItemsTheSame(@NonNull PersistentConference oldItem, @NonNull PersistentConference newItem) { public boolean areItemsTheSame(@NonNull PersistentConference oldItem, @NonNull PersistentConference newItem) {
@ -183,7 +196,6 @@ public class ConferencesBrowseFragment extends BrowseSupportFragment {
} }
}); });
}); });
return row;
} }
private void addStreams(CardPresenter cardPresenter, List<LiveConference> liveConferences) { private void addStreams(CardPresenter cardPresenter, List<LiveConference> liveConferences) {

View file

@ -218,9 +218,7 @@ class EventDetailsFragment : DetailsSupportFragment() {
.load(thumbUrl) .load(thumbUrl)
.into(object : SimpleTarget<Bitmap>(DETAIL_THUMB_WIDTH, DETAIL_THUMB_HEIGHT) { .into(object : SimpleTarget<Bitmap>(DETAIL_THUMB_WIDTH, DETAIL_THUMB_HEIGHT) {
override fun onResourceReady(resource: Bitmap, transition: Transition<in Bitmap>?) { override fun onResourceReady(resource: Bitmap, transition: Transition<in Bitmap>?) {
if (resource != null) { detailsOverview.setImageBitmap(requireContext(), resource)
detailsOverview.setImageBitmap(requireContext(), resource)
}
} }
override fun onLoadFailed(errorDrawable: Drawable?) { override fun onLoadFailed(errorDrawable: Drawable?) {
@ -239,9 +237,7 @@ class EventDetailsFragment : DetailsSupportFragment() {
.apply(options) .apply(options)
.into(object : SimpleTarget<Bitmap>() { .into(object : SimpleTarget<Bitmap>() {
override fun onResourceReady(resource: Bitmap, transition: Transition<in Bitmap>?) { override fun onResourceReady(resource: Bitmap, transition: Transition<in Bitmap>?) {
if(resource != null){ detailsBackgroundController.coverBitmap = resource
detailsBackgroundController.coverBitmap = resource
}
} }
}) })

View file

@ -7,6 +7,7 @@ import android.content.DialogInterface
import android.content.Intent import android.content.Intent
import android.net.Uri import android.net.Uri
import android.os.Bundle import android.os.Bundle
import android.support.design.widget.AppBarLayout
import android.support.design.widget.Snackbar import android.support.design.widget.Snackbar
import android.support.v4.app.Fragment import android.support.v4.app.Fragment
import android.support.v7.app.AlertDialog import android.support.v7.app.AlertDialog
@ -85,7 +86,7 @@ class EventDetailsFragment : Fragment() {
binding.relatedItemsList.layoutManager = LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false); binding.relatedItemsList.layoutManager = LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false);
} }
binding.appbar.addOnOffsetChangedListener { appBarLayout, verticalOffset -> binding.appbar.addOnOffsetChangedListener(AppBarLayout.OnOffsetChangedListener { appBarLayout, verticalOffset ->
val v = Math.abs(verticalOffset).toDouble() / appBarLayout.totalScrollRange val v = Math.abs(verticalOffset).toDouble() / appBarLayout.totalScrollRange
if (appBarExpanded xor (v > 0.8)) { if (appBarExpanded xor (v > 0.8)) {
if (listener != null) { if (listener != null) {
@ -94,7 +95,7 @@ class EventDetailsFragment : Fragment() {
appBarExpanded = v > 0.8 appBarExpanded = v > 0.8
// binding.collapsingToolbar.isTitleEnabled = appBarExpanded // binding.collapsingToolbar.isTitleEnabled = appBarExpanded
} }
} })
viewModel = ViewModelProviders.of( viewModel = ViewModelProviders.of(
requireActivity(), requireActivity(),

View file

@ -24,7 +24,7 @@ class PlayerEventListener implements Player.EventListener, SimpleExoPlayer.Video
} }
@Override @Override
public void onTimelineChanged(Timeline timeline, Object manifest) { public void onTimelineChanged(Timeline timeline, Object manifest, int reason) {
} }
@ -67,6 +67,11 @@ class PlayerEventListener implements Player.EventListener, SimpleExoPlayer.Video
} }
@Override
public void onShuffleModeEnabledChanged(boolean shuffleModeEnabled) {
}
@Override @Override
public void onPlayerError(ExoPlaybackException error) { public void onPlayerError(ExoPlaybackException error) {
String errorMessage = error.getCause().getMessage(); String errorMessage = error.getCause().getMessage();
@ -75,7 +80,7 @@ class PlayerEventListener implements Player.EventListener, SimpleExoPlayer.Video
} }
@Override @Override
public void onPositionDiscontinuity() { public void onPositionDiscontinuity(int reason) {
} }
@ -84,6 +89,11 @@ class PlayerEventListener implements Player.EventListener, SimpleExoPlayer.Video
} }
@Override
public void onSeekProcessed() {
}
@Override @Override
public void onVideoSizeChanged(int width, int height, int unappliedRotationDegrees, float pixelWidthHeightRatio) { public void onVideoSizeChanged(int width, int height, int unappliedRotationDegrees, float pixelWidthHeightRatio) {