mirror of
https://github.com/NiciDieNase/chaosflix
synced 2024-11-23 12:53:08 +00:00
start implementing a bound service
This commit is contained in:
parent
666f6ac6d6
commit
5069bd6c92
4 changed files with 60 additions and 0 deletions
|
@ -30,12 +30,20 @@ dependencies {
|
|||
compile 'com.android.support:appcompat-v7:25.3.0'
|
||||
compile 'com.github.bumptech.glide:glide:3.7.0'
|
||||
|
||||
compile 'io.reactivex.rxjava2:rxandroid:2.0.1'
|
||||
compile 'io.reactivex.rxjava2:rxjava:2.0.1'
|
||||
compile 'com.squareup.retrofit2:retrofit:2.2.0'
|
||||
compile 'com.squareup.retrofit2:converter-gson:2.2.0'
|
||||
compile 'com.squareup.retrofit2:adapter-rxjava2:2.2.0'
|
||||
|
||||
compile 'com.github.satyan:sugar:1.4'
|
||||
compile 'com.jakewharton:butterknife:8.5.1'
|
||||
annotationProcessor 'com.jakewharton:butterknife-compiler:8.5.1'
|
||||
|
||||
debugCompile 'com.facebook.stetho:stetho:1.4.2'
|
||||
debugCompile 'com.facebook.stetho:stetho-okhttp:1.4.2'
|
||||
debugCompile 'com.facebook.stetho:stetho-okhttp3:1.4.2'
|
||||
|
||||
testCompile 'junit:junit:4.12'
|
||||
androidTestCompile 'junit:junit:4.12'
|
||||
androidTestCompile ('com.android.support.test:runner:0.5') {
|
||||
|
|
|
@ -17,4 +17,10 @@ public class ChaosflixApplication extends Application {
|
|||
super.onCreate();
|
||||
SugarContext.init(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTerminate() {
|
||||
SugarContext.terminate();
|
||||
super.onTerminate();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
package de.nicidienase.chaosflix.network;
|
||||
|
||||
import android.app.Service;
|
||||
import android.content.Intent;
|
||||
import android.os.Binder;
|
||||
import android.os.IBinder;
|
||||
import android.support.annotation.Nullable;
|
||||
|
||||
import de.nicidienase.chaosflix.R;
|
||||
import retrofit2.Retrofit;
|
||||
import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory;
|
||||
import retrofit2.converter.gson.GsonConverterFactory;
|
||||
|
||||
/**
|
||||
* Created by felix on 24.03.17.
|
||||
*/
|
||||
|
||||
public class MediaApiService extends Service {
|
||||
|
||||
private final IBinder mBinder = new LocalBinder();
|
||||
private final MediaCCCService mApiService;
|
||||
|
||||
public class LocalBinder extends Binder {
|
||||
MediaApiService getService() {
|
||||
return MediaApiService.this;
|
||||
}
|
||||
}
|
||||
|
||||
public MediaApiService(){
|
||||
Retrofit retrofit = new Retrofit.Builder()
|
||||
.baseUrl(getString(R.string.api_media_ccc_url))
|
||||
.addConverterFactory(GsonConverterFactory.create())
|
||||
.addCallAdapterFactory(RxJava2CallAdapterFactory.create())
|
||||
.build();
|
||||
mApiService = retrofit.create(MediaCCCService.class);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public IBinder onBind(Intent intent) {
|
||||
return mBinder;
|
||||
}
|
||||
|
||||
}
|
|
@ -38,4 +38,6 @@
|
|||
<string name="oops">Oops</string>
|
||||
<string name="related_talks">Random Talks in the same Track</string>
|
||||
<string name="random_talks">Other random Talks at this Conference</string>
|
||||
<string name="api_media_ccc_url">https://api.media.ccc.de</string>
|
||||
<string name="streaming_media_ccc_url">https://streaming.media.ccc.de</string>
|
||||
</resources>
|
||||
|
|
Loading…
Reference in a new issue