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.content.Context
class DatabaseFactory private constructor(context: Context) {
class DatabaseFactory private constructor() {
companion object : SingletonHolder<ChaosflixDatabase, Context>({
Room.databaseBuilder(

View file

@ -45,7 +45,7 @@ class OfflineItemManager(context: Context,
fun updateDownloadStatus(offlineEvents: List<OfflineEvent>) {
if (offlineEvents.size > 0) {
val downloadRef = offlineEvents.map { it.downloadReference }.toTypedArray().toLongArray() ?: longArrayOf()
val downloadRef = offlineEvents.map { it.downloadReference }.toTypedArray().toLongArray()
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.mediadata.entities.recording.persistence.PersistentEvent
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.userdata.entities.watchlist.WatchlistItem
import de.nicidienase.chaosflix.common.util.LiveEvent
@ -19,7 +18,6 @@ import java.io.File
class DetailsViewModel(
val database: ChaosflixDatabase,
recordingApi: RecordingService,
val offlineItemManager: OfflineItemManager,
val preferencesManager: PreferencesManager,
val downloader: Downloader

View file

@ -30,7 +30,7 @@ class ViewModelFactory(context: Context) : ViewModelProvider.Factory {
} else if (modelClass.isAssignableFrom(PlayerViewModel::class.java)) {
return PlayerViewModel(database) as T
} 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)){
return PreferencesViewModel(downloader) as T
} else {

View file

@ -25,7 +25,6 @@ android {
useProguard false
// shrinkResources true
// minifyEnabled true
useProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro'
}
@ -62,8 +61,6 @@ dependencies {
implementation "com.android.support:preference-leanback-v17:${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 'com.google.android.exoplayer:exoplayer:2.7.0'
@ -82,9 +79,4 @@ dependencies {
androidTestImplementation 'org.hamcrest:hamcrest-library:1.3'
androidTestImplementation 'com.squareup.okhttp3:mockwebserver:3.6.0'
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.ListRow;
import android.support.v17.leanback.widget.ListRowPresenter;
import android.support.v17.leanback.widget.Row;
import android.support.v17.leanback.widget.SectionRow;
import android.support.v4.app.FragmentManager;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
@ -78,7 +79,13 @@ public class ConferencesBrowseFragment extends BrowseSupportFragment {
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 eventPresenter = new CardPresenter(R.style.EventCardStyle);
@ -113,7 +120,7 @@ public class ConferencesBrowseFragment extends BrowseSupportFragment {
if (downloaderEvent.getData() != null) {
}
if (downloaderEvent.getError() != null) {
if (!errorFragment.isDetached()) {
if (errorFragment != null && !errorFragment.isDetached()) {
errorFragment.setErrorContent(downloaderEvent.getError());
}
}
@ -121,14 +128,18 @@ public class ConferencesBrowseFragment extends BrowseSupportFragment {
case RUNNING:
break;
case DONE:
errorFragment.dismiss();
if(errorFragment != null){
errorFragment.dismiss();
}
break;
}
});
viewModel.getConferenceGroups().observe(this, conferenceGroups -> {
if (conferenceGroups != null && conferenceGroups.size() > 0) {
errorFragment.dismiss();
if(errorFragment != null){
errorFragment.dismiss();
}
Collections.sort(conferenceGroups);
for (ConferenceGroup group : conferenceGroups) {
ListRow row;
@ -136,7 +147,7 @@ public class ConferencesBrowseFragment extends BrowseSupportFragment {
if (conferencesGroupRows.containsKey(group.getName())) {
row = conferencesGroupRows.get(group.getName());
} 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);
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 -> {
Collections.sort(conferences);
if(conferences != null){
Collections.sort(conferences);
}
((ArrayObjectAdapter) row.getAdapter()).setItems(conferences, new DiffCallback<PersistentConference>() {
@Override
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) {

View file

@ -218,9 +218,7 @@ class EventDetailsFragment : DetailsSupportFragment() {
.load(thumbUrl)
.into(object : SimpleTarget<Bitmap>(DETAIL_THUMB_WIDTH, DETAIL_THUMB_HEIGHT) {
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?) {
@ -239,9 +237,7 @@ class EventDetailsFragment : DetailsSupportFragment() {
.apply(options)
.into(object : SimpleTarget<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.net.Uri
import android.os.Bundle
import android.support.design.widget.AppBarLayout
import android.support.design.widget.Snackbar
import android.support.v4.app.Fragment
import android.support.v7.app.AlertDialog
@ -85,7 +86,7 @@ class EventDetailsFragment : Fragment() {
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
if (appBarExpanded xor (v > 0.8)) {
if (listener != null) {
@ -94,7 +95,7 @@ class EventDetailsFragment : Fragment() {
appBarExpanded = v > 0.8
// binding.collapsingToolbar.isTitleEnabled = appBarExpanded
}
}
})
viewModel = ViewModelProviders.of(
requireActivity(),

View file

@ -24,7 +24,7 @@ class PlayerEventListener implements Player.EventListener, SimpleExoPlayer.Video
}
@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
public void onPlayerError(ExoPlaybackException error) {
String errorMessage = error.getCause().getMessage();
@ -75,7 +80,7 @@ class PlayerEventListener implements Player.EventListener, SimpleExoPlayer.Video
}
@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
public void onVideoSizeChanged(int width, int height, int unappliedRotationDegrees, float pixelWidthHeightRatio) {