package lib.morkim.mfw.ui;

import android.app.Service;
import android.content.Context;
import android.os.Bundle;

import java.util.UUID;

import lib.morkim.mfw.app.MorkimApp;

public abstract class MorkimService<C extends Controller>
		extends Service
		implements Viewable<UpdateListener, C, EmptyPresenter> {

	protected C controller;
	protected EmptyPresenter presenter;

	@Override
	public void onCreate() {
		super.onCreate();

		UiComponentHelper.createUiComponents(this, getApplication());
	}

	@Override
	public void onBindViews() {

	}

	@Override
	public void onAttachController(C controller) {
		this.controller = controller;
	}

	@Override
	public void onAttachPresenter(EmptyPresenter presenter) {
		this.presenter = presenter;
	}

	@Override
	public Bundle getBundledData() {
		return null;//getIntent().getExtras();
	}

	protected int layoutId() {
		return 0;
	}

	@Override
	public void onDestroy() {
		super.onDestroy();

		((MorkimApp) getApplication()).destroyController(this);
	}

	@Override
	public void keepScreenOn(boolean keepOn) {

	}

	@Override
	public Context getContext() {
		return this;
	}

	@Override
	public void runOnUi(Runnable runnable) {}

	@Override
	public UUID getInstanceId() {
		return null;
	}

	@Override
	public void registerPermissionListener(String permission, onPermissionResultListener listener) {}

	@Override
	public <T> T getParentListener() {
		return null;
	}

	@Override
	public <T> T getChildListener() {
		return (T) controller;
	}
}

@@ -1047,32 +1047,85 @@
  keepOn) %7B%0A%0A%09%7D%0A%0A
+%09@Override%0A%09public void finish() %7B%0A%09%09stopSelf();%0A%09%7D%0A%0A
 %09@Override%0A%09publ

make finish call stop self for service