mirror of
https://github.com/NiciDieNase/chaosflix
synced 2024-11-23 12:53:08 +00:00
fix crashes
This commit is contained in:
parent
e874933acd
commit
48f263b39a
13 changed files with 65 additions and 62 deletions
|
@ -43,6 +43,7 @@
|
|||
<activity android:name=".activities.PlaybackOverlayActivity"
|
||||
android:exported="true"
|
||||
android:theme="@style/Theme.Leanback"/>
|
||||
<service android:name=".network.MediaApiService"/>
|
||||
|
||||
<meta-data android:name="DATABASE" android:value="mediaccc.db" />
|
||||
<meta-data android:name="VERSION" android:value="2" />
|
||||
|
|
|
@ -20,13 +20,16 @@ import io.reactivex.Single;
|
|||
|
||||
public class AbstractServiceConnectedAcitivty extends Activity {
|
||||
private MediaApiService mMediaApiService = null;
|
||||
private Single<MediaApiService> mApiServiceObservable;
|
||||
|
||||
@Override
|
||||
public void onCreate(@Nullable Bundle savedInstanceState, @Nullable PersistableBundle persistentState) {
|
||||
super.onCreate(savedInstanceState, persistentState);
|
||||
|
||||
}
|
||||
|
||||
public Single<MediaApiService> getmApiServiceObservable() {
|
||||
Intent s = new Intent(this, MediaApiService.class);
|
||||
mApiServiceObservable = Single.create(e -> {
|
||||
return Single.create(e -> {
|
||||
if(mMediaApiService != null){
|
||||
e.onSuccess(mMediaApiService);
|
||||
} else {
|
||||
|
@ -39,14 +42,10 @@ public class AbstractServiceConnectedAcitivty extends Activity {
|
|||
|
||||
@Override
|
||||
public void onServiceDisconnected(ComponentName name) {
|
||||
|
||||
mMediaApiService = null;
|
||||
}
|
||||
}, Context.BIND_AUTO_CREATE);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public Single<MediaApiService> getmApiServiceObservable() {
|
||||
return mApiServiceObservable;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,8 +13,8 @@ import java.util.Set;
|
|||
* Created by felix on 17.03.17.
|
||||
*/
|
||||
|
||||
public class Conferences{
|
||||
private static final String TAG = Conferences.class.getSimpleName();
|
||||
public class ConferencesWrapper {
|
||||
private static final String TAG = ConferencesWrapper.class.getSimpleName();
|
||||
private List<Conference> conferences;
|
||||
|
||||
private final String CONGRESS = "congress";
|
|
@ -1,16 +1,11 @@
|
|||
package de.nicidienase.chaosflix.fragments;
|
||||
|
||||
import android.content.ComponentName;
|
||||
import android.content.Intent;
|
||||
import android.content.ServiceConnection;
|
||||
import android.os.Bundle;
|
||||
import android.os.IBinder;
|
||||
import android.support.v17.leanback.app.BrowseFragment;
|
||||
import android.support.v17.leanback.widget.ArrayObjectAdapter;
|
||||
import android.support.v17.leanback.widget.HeaderItem;
|
||||
import android.support.v17.leanback.widget.ListRow;
|
||||
import android.support.v17.leanback.widget.ListRowPresenter;
|
||||
import android.util.Log;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
@ -21,16 +16,10 @@ import de.nicidienase.chaosflix.CardPresenter;
|
|||
import de.nicidienase.chaosflix.ItemViewClickedListener;
|
||||
import de.nicidienase.chaosflix.R;
|
||||
import de.nicidienase.chaosflix.activities.AbstractServiceConnectedAcitivty;
|
||||
import de.nicidienase.chaosflix.activities.ConferencesActivity;
|
||||
import de.nicidienase.chaosflix.entities.recording.Conference;
|
||||
import de.nicidienase.chaosflix.entities.recording.Conferences;
|
||||
import de.nicidienase.chaosflix.network.MediaApiService;
|
||||
import de.nicidienase.chaosflix.network.RecordingClient;
|
||||
import io.reactivex.Observer;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
|
||||
/**
|
||||
* Created by felix on 21.03.17.
|
||||
|
@ -51,7 +40,8 @@ public class ConferencesBrowseFragment extends BrowseFragment {
|
|||
setTitle(getResources().getString(R.string.app_name));
|
||||
final BrowseErrorFragment errorFragment =
|
||||
BrowseErrorFragment.showErrorFragment(getFragmentManager(),FRAGMENT);
|
||||
((AbstractServiceConnectedAcitivty)getActivity()).getmApiServiceObservable().subscribe(mediaApiService -> {
|
||||
((AbstractServiceConnectedAcitivty)getActivity()).getmApiServiceObservable()
|
||||
.subscribe(mediaApiService -> {
|
||||
mMediaApiService = mediaApiService;
|
||||
mMediaApiService.getConferences()
|
||||
.doOnError(t -> {errorFragment.setErrorContent(t.getMessage());})
|
||||
|
@ -109,7 +99,7 @@ public class ConferencesBrowseFragment extends BrowseFragment {
|
|||
case "fiffkon":
|
||||
return "FifFKon";
|
||||
case "other mConferences":
|
||||
return "other Conferences";
|
||||
return "other ConferencesWrapper";
|
||||
case "blinkenlights":
|
||||
return "Blinkenlights";
|
||||
case "chaoscologne":
|
||||
|
@ -117,7 +107,7 @@ public class ConferencesBrowseFragment extends BrowseFragment {
|
|||
case "cryptocon":
|
||||
return "CryptoCon";
|
||||
case "other conferences":
|
||||
return "Other Conferences";
|
||||
return "Other ConferencesWrapper";
|
||||
case "denog":
|
||||
return "DENOG";
|
||||
case "vcfb":
|
||||
|
|
|
@ -5,7 +5,6 @@ import android.os.Handler;
|
|||
import android.support.v17.leanback.app.VerticalGridFragment;
|
||||
import android.support.v17.leanback.widget.ArrayObjectAdapter;
|
||||
import android.support.v17.leanback.widget.VerticalGridPresenter;
|
||||
import android.util.Log;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
@ -14,12 +13,8 @@ import de.nicidienase.chaosflix.CardPresenter;
|
|||
import de.nicidienase.chaosflix.ItemViewClickedListener;
|
||||
import de.nicidienase.chaosflix.activities.AbstractServiceConnectedAcitivty;
|
||||
import de.nicidienase.chaosflix.entities.recording.Conference;
|
||||
import de.nicidienase.chaosflix.entities.recording.Conferences;
|
||||
import de.nicidienase.chaosflix.network.MediaApiService;
|
||||
import de.nicidienase.chaosflix.network.RecordingClient;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
|
||||
/**
|
||||
* Created by felix on 20.03.17.
|
||||
|
@ -39,6 +34,7 @@ public class ConferencesGridFragment extends VerticalGridFragment {
|
|||
((AbstractServiceConnectedAcitivty)getActivity()).getmApiServiceObservable().subscribe(mediaApiService -> {
|
||||
mMediaApiService = mediaApiService;
|
||||
mMediaApiService.getConferences()
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(conferences -> {
|
||||
List<Conference> conferenceList = conferences.getConferences();
|
||||
Collections.sort(conferenceList);
|
||||
|
|
|
@ -55,6 +55,7 @@ import de.nicidienase.chaosflix.entities.recording.Event;
|
|||
import de.nicidienase.chaosflix.network.MediaApiService;
|
||||
import de.nicidienase.chaosflix.network.RecordingClient;
|
||||
import io.reactivex.Observer;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
|
@ -93,6 +94,7 @@ public class EventsBrowseFragment extends BrowseFragment {
|
|||
mMediaApiService = mediaApiService;
|
||||
|
||||
mMediaApiService.getConference(mConference.getApiID())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.doOnError(t -> errorFragment.setErrorContent(t.getMessage()))
|
||||
.subscribe(conference -> {
|
||||
mConference = conference;
|
||||
|
|
|
@ -48,6 +48,7 @@ import de.nicidienase.chaosflix.entities.recording.Recording;
|
|||
import de.nicidienase.chaosflix.network.MediaApiService;
|
||||
import de.nicidienase.chaosflix.network.RecordingClient;
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
|
@ -98,7 +99,9 @@ public class EventsDetailsFragment extends DetailsFragment {
|
|||
detailsOverviewRow.setActionsAdapter(recordingActionsAdapter);
|
||||
adapter.add(detailsOverviewRow);
|
||||
mediaApiService.getConference(
|
||||
mSelectedEvent.getParentConferenceID()).subscribe(conference -> {
|
||||
mSelectedEvent.getParentConferenceID())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(conference -> {
|
||||
String tag = null;
|
||||
if(mSelectedEvent.getTags().size()>0) {
|
||||
tag = mSelectedEvent.getTags().get(0);
|
||||
|
|
|
@ -57,6 +57,7 @@ import de.nicidienase.chaosflix.entities.recording.Event;
|
|||
import de.nicidienase.chaosflix.entities.recording.Recording;
|
||||
import de.nicidienase.chaosflix.network.MediaApiService;
|
||||
import de.nicidienase.chaosflix.network.RecordingClient;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
|
@ -114,7 +115,7 @@ public class PlaybackOverlayFragment extends PlaybackFragment {
|
|||
|
||||
mMediaApiService.getEvent(mSelectedEvent.getApiID())
|
||||
.subscribe(event -> {
|
||||
for(Recording r : mSelectedEvent.getRecordings()){
|
||||
for(Recording r : event.getRecordings()){
|
||||
if(r.getApiID() == mRecordingID){
|
||||
mSelectedRecording = r;
|
||||
}
|
||||
|
|
|
@ -10,16 +10,16 @@ import java.util.List;
|
|||
|
||||
import de.nicidienase.chaosflix.R;
|
||||
import de.nicidienase.chaosflix.entities.recording.Conference;
|
||||
import de.nicidienase.chaosflix.entities.recording.Conferences;
|
||||
import de.nicidienase.chaosflix.entities.recording.ConferencesWrapper;
|
||||
import de.nicidienase.chaosflix.entities.recording.Event;
|
||||
import de.nicidienase.chaosflix.entities.recording.Recording;
|
||||
import de.nicidienase.chaosflix.entities.streaming.LiveConference;
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
import okhttp3.OkHttpClient;
|
||||
import retrofit2.Retrofit;
|
||||
import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory;
|
||||
import retrofit2.converter.gson.GsonConverterFactory;
|
||||
import retrofit2.http.Path;
|
||||
|
||||
/**
|
||||
* Created by felix on 24.03.17.
|
||||
|
@ -28,8 +28,8 @@ import retrofit2.http.Path;
|
|||
public class MediaApiService extends Service {
|
||||
|
||||
private final IBinder mBinder = new LocalBinder();
|
||||
private final RecordingService mRecordingApiService;
|
||||
private final StreamingService mStreamingApiService;
|
||||
private RecordingService mRecordingApiService;
|
||||
private StreamingService mStreamingApiService;
|
||||
|
||||
public class LocalBinder extends Binder {
|
||||
public MediaApiService getService() {
|
||||
|
@ -38,6 +38,11 @@ public class MediaApiService extends Service {
|
|||
}
|
||||
|
||||
public MediaApiService(){
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
OkHttpClient client = new OkHttpClient();
|
||||
GsonConverterFactory gsonConverterFactory = GsonConverterFactory.create();
|
||||
RxJava2CallAdapterFactory rxJava2CallAdapterFactory = RxJava2CallAdapterFactory.create();
|
||||
|
@ -65,27 +70,33 @@ public class MediaApiService extends Service {
|
|||
return mBinder;
|
||||
}
|
||||
|
||||
public Observable<Conferences> getConferences(){
|
||||
return mRecordingApiService.getConferences();
|
||||
public Observable<ConferencesWrapper> getConferences(){
|
||||
return mRecordingApiService.getConferences()
|
||||
.subscribeOn(Schedulers.io());
|
||||
};
|
||||
|
||||
public Observable<Conference> getConference(long id){
|
||||
return mRecordingApiService.getConference(id);
|
||||
return mRecordingApiService.getConference(id)
|
||||
.subscribeOn(Schedulers.io());
|
||||
}
|
||||
|
||||
public Observable<List<Event>> getEvents(){
|
||||
return mRecordingApiService.getAllEvents();
|
||||
return mRecordingApiService.getAllEvents()
|
||||
.subscribeOn(Schedulers.io());
|
||||
}
|
||||
|
||||
public Observable<Event> getEvent(long id){
|
||||
return mRecordingApiService.getEvent(id);
|
||||
return mRecordingApiService.getEvent(id)
|
||||
.subscribeOn(Schedulers.io());
|
||||
}
|
||||
|
||||
public Observable<Recording> getRecording(long id){
|
||||
return mRecordingApiService.getRecording(id);
|
||||
return mRecordingApiService.getRecording(id)
|
||||
.subscribeOn(Schedulers.io());
|
||||
}
|
||||
|
||||
public Observable<List<LiveConference>> getStreamingConferences(){
|
||||
return mStreamingApiService.getStreamingConferences();
|
||||
return mStreamingApiService.getStreamingConferences()
|
||||
.subscribeOn(Schedulers.io());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ package de.nicidienase.chaosflix.network;
|
|||
import java.util.List;
|
||||
|
||||
import de.nicidienase.chaosflix.entities.recording.Conference;
|
||||
import de.nicidienase.chaosflix.entities.recording.Conferences;
|
||||
import de.nicidienase.chaosflix.entities.recording.ConferencesWrapper;
|
||||
import de.nicidienase.chaosflix.entities.recording.Event;
|
||||
import de.nicidienase.chaosflix.entities.recording.Recording;
|
||||
import io.reactivex.Observable;
|
||||
|
@ -36,7 +36,7 @@ public class RecordingClient implements RecordingService {
|
|||
|
||||
|
||||
@Override
|
||||
public Observable<Conferences> getConferences() {
|
||||
public Observable<ConferencesWrapper> getConferences() {
|
||||
return service.getConferences();
|
||||
}
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ package de.nicidienase.chaosflix.network;
|
|||
import java.util.List;
|
||||
|
||||
import de.nicidienase.chaosflix.entities.recording.Conference;
|
||||
import de.nicidienase.chaosflix.entities.recording.Conferences;
|
||||
import de.nicidienase.chaosflix.entities.recording.ConferencesWrapper;
|
||||
import de.nicidienase.chaosflix.entities.recording.Event;
|
||||
import de.nicidienase.chaosflix.entities.recording.Recording;
|
||||
import io.reactivex.Observable;
|
||||
|
@ -17,7 +17,7 @@ import retrofit2.http.Path;
|
|||
public interface RecordingService {
|
||||
|
||||
@GET("public/conferences")
|
||||
Observable<Conferences> getConferences();
|
||||
Observable<ConferencesWrapper> getConferences();
|
||||
|
||||
@GET("public/conferences/{id}")
|
||||
Observable<Conference> getConference(@Path("id") long id);
|
||||
|
|
|
@ -37,62 +37,62 @@ public class RecordingClientTest {
|
|||
|
||||
@Test
|
||||
public void getEventTest() throws IOException {
|
||||
client.getEvent(3674).subscribe(
|
||||
client.getEvent(3674).blockingSubscribe(
|
||||
event -> assertEquals("bfc2ab1f-8384-4d7d-801a-dde8c81e039c", event.getGuid()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getEventRecordingsTest() throws IOException {
|
||||
client.getEvent(3674).subscribe(event -> assertEquals(9, event.getRecordings().size()));
|
||||
client.getEvent(3674).blockingSubscribe(event -> assertEquals(9, event.getRecordings().size()));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void getRecordingTest() throws IOException {
|
||||
client.getRecording(14142).subscribe(
|
||||
recording -> assertEquals("2016-12-29T03:16:16.105+01:00",
|
||||
client.getRecording(14142)
|
||||
.blockingSubscribe(recording -> assertEquals("2016-12-29T03:16:16.105+01:00",
|
||||
recording.getUpdatedAt()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getConferencEventListTest() throws IOException {
|
||||
client.getConferences().subscribe(conferences ->
|
||||
client.getConferences().blockingSubscribe(conferences ->
|
||||
assertEquals(99, conferences.getConferences().size()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void eventTagsTest() throws IOException {
|
||||
client.getConference(101).subscribe(
|
||||
client.getConference(101).blockingSubscribe(
|
||||
conference -> assertEquals(12, conference.getEventsByTags().keySet().size()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void sortTest() throws IOException {
|
||||
client.getConferences().subscribe(conferences -> {
|
||||
client.getConferences().blockingSubscribe(conferences -> {
|
||||
Collections.sort(conferences.getConferences());
|
||||
for (Conference conf : conferences.getConferences()) {
|
||||
client.getConference(conf.getApiID())
|
||||
.subscribe(conference -> Collections.sort(conference.getEvents()));
|
||||
.blockingSubscribe(conference -> Collections.sort(conference.getEvents()));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void sortAllEvents() throws IOException {
|
||||
client.getAllEvents().subscribe(events -> Collections.sort(events));
|
||||
client.getAllEvents().blockingSubscribe(events -> Collections.sort(events));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void mrmcd13() throws IOException {
|
||||
client.getConference(38).subscribe(conference ->
|
||||
client.getConference(38).blockingSubscribe(conference ->
|
||||
Collections.sort(Lists.newArrayList(conference.getEventsByTags().keySet())));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTagsToTalksRation() throws IOException {
|
||||
client.getConferences().subscribe(conferences -> {
|
||||
client.getConferences().blockingSubscribe(conferences -> {
|
||||
for (Conference conf : conferences.getConferences()) {
|
||||
client.getConference(conf.getApiID()).subscribe(conference -> {
|
||||
client.getConference(conf.getApiID()).blockingSubscribe(conference -> {
|
||||
System.out.print(conference.getAcronym() + ": " + conference.getEventsByTags().keySet());
|
||||
float sum = 0;
|
||||
for (Event e : conference.getEvents()) {
|
||||
|
|
|
@ -41,13 +41,13 @@ public class StreamingClientTest {
|
|||
|
||||
@Test
|
||||
public void test1() throws IOException {
|
||||
service.getStreamingConferences().subscribe((List<LiveConference> liveConferences) -> assertEquals(1, liveConferences.size()));
|
||||
service.getStreamingConferences().blockingSubscribe(List<LiveConference> liveConferences) -> assertEquals(1, liveConferences.size()));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test2() throws IOException {
|
||||
service.getStreamingConferences().subscribe(
|
||||
service.getStreamingConferences().blockingSubscribe
|
||||
(List<LiveConference> liveConferences) -> assertEquals("FOSSGIS 2017", liveConferences.get(0).getConference()));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue