UnifiedNlp/src/org/microg/nlp/ProviderService.java
mar-v-in 8ff926120c Major cleanup, Add support for Geocoder
Using spaces for indentation from now on
Add support for forced locations (debug)
2014-12-25 12:49:33 +01:00

55 lines
1.2 KiB
Java

package org.microg.nlp;
import android.app.IntentService;
import android.content.Intent;
import android.os.IBinder;
public abstract class ProviderService<T extends Provider> extends IntentService {
private T provider;
/**
* Creates an ProviderService. Invoked by your subclass's constructor.
*
* @param tag Used for debugging.
*/
public ProviderService(String tag) {
super(tag);
}
@Override
public void onCreate() {
super.onCreate();
provider = createProvider();
}
@Override
public IBinder onBind(Intent intent) {
return provider.getBinder();
}
@Override
public void onDestroy() {
provider = null;
}
/**
* Create a {@link org.microg.nlp.Provider}.
* This is most likely only called once
*
* @return a new {@link org.microg.nlp.Provider} instance
*/
protected abstract T createProvider();
@Override
protected void onHandleIntent(Intent intent) {
// Default implementation is to do nothing
}
/**
* @return the currently used {@link org.microg.nlp.Provider} instance
*/
protected T getCurrentProvider() {
return provider;
}
}