package com.pas.abtahibo.parvaz;


import anywheresoftware.b4a.BA;
import anywheresoftware.b4a.objects.ServiceHelper;
import anywheresoftware.b4a.debug.*;

public class myservice extends android.app.Service{
	public static class myservice_BR extends android.content.BroadcastReceiver {

		@Override
		public void onReceive(android.content.Context context, android.content.Intent intent) {
            BA.LogInfo("** Receiver (myservice) OnReceive **");
			android.content.Intent in = new android.content.Intent(context, myservice.class);
			if (intent != null)
				in.putExtra("b4a_internal_intent", intent);
            ServiceHelper.StarterHelper.startServiceFromReceiver (context, in, false, BA.class);
		}

	}
    static myservice mostCurrent;
	public static BA processBA;
    private ServiceHelper _service;
    public static Class<?> getObject() {
		return myservice.class;
	}
	@Override
	public void onCreate() {
        super.onCreate();
        mostCurrent = this;
        if (processBA == null) {
		    processBA = new BA(this, null, null, "com.pas.abtahibo.parvaz", "com.pas.abtahibo.parvaz.myservice");
            if (BA.isShellModeRuntimeCheck(processBA)) {
                processBA.raiseEvent2(null, true, "SHELL", false);
		    }
            try {
                Class.forName(BA.applicationContext.getPackageName() + ".main").getMethod("initializeProcessGlobals").invoke(null, null);
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
            processBA.loadHtSubs(this.getClass());
            ServiceHelper.init();
        }
        _service = new ServiceHelper(this);
        processBA.service = this;
        
        if (BA.isShellModeRuntimeCheck(processBA)) {
			processBA.raiseEvent2(null, true, "CREATE", true, "com.pas.abtahibo.parvaz.myservice", processBA, _service, anywheresoftware.b4a.keywords.Common.Density);
		}
        if (!false && ServiceHelper.StarterHelper.startFromServiceCreate(processBA, false) == false) {
				
		}
		else {
            processBA.setActivityPaused(false);
            BA.LogInfo("*** Service (myservice) Create ***");
            processBA.raiseEvent(null, "service_create");
        }
        processBA.runHook("oncreate", this, null);
        if (false) {
			if (ServiceHelper.StarterHelper.runWaitForLayouts() == false) {
                BA.LogInfo("stopping spontaneous created service");
                stopSelf();
            }
		}
        BA.LogInfo("*** Service (myservice) Create completed ***");
    }
		@Override
	public void onStart(android.content.Intent intent, int startId) {
		onStartCommand(intent, 0, 0);
    }
    @Override
    public int onStartCommand(final android.content.Intent intent, int flags, int startId) {
        BA.LogInfo("*** Service (myservice) Started ***");
    	if (ServiceHelper.StarterHelper.onStartCommand(processBA, new Runnable() {
            public void run() {
                handleStart(intent);
            }}))
			;
		else {
			ServiceHelper.StarterHelper.addWaitForLayout (new Runnable() {
				public void run() {
                    processBA.setActivityPaused(false);
                    BA.LogInfo("** Service (myservice) Create **");
                    processBA.raiseEvent(null, "service_create");
					handleStart(intent);
                    ServiceHelper.StarterHelper.removeWaitForLayout();
				}
			});
		}
        processBA.runHook("onstartcommand", this, new Object[] {intent, flags, startId});
        BA.LogInfo("*** Service (myservice) Started completed ***");
		return android.app.Service.START_NOT_STICKY;
    }
    public void onTaskRemoved(android.content.Intent rootIntent) {
        super.onTaskRemoved(rootIntent);
        if (false)
            processBA.raiseEvent(null, "service_taskremoved");
            
    }
    private void handleStart(android.content.Intent intent) {
    	BA.LogInfo("** Service (myservice) Start **");
    	java.lang.reflect.Method startEvent = processBA.htSubs.get("service_start");
    	if (startEvent != null) {
    		if (startEvent.getParameterTypes().length > 0) {
    			anywheresoftware.b4a.objects.IntentWrapper iw = ServiceHelper.StarterHelper.handleStartIntent(intent, _service, processBA);
    			processBA.raiseEvent(null, "service_start", iw);
    		}
    		else {
    			processBA.raiseEvent(null, "service_start");
    		}
    	}
    }

	public void onTimeout(int startId) {
        BA.LogInfo("** Service (myservice) Timeout **");
        anywheresoftware.b4a.objects.collections.Map params = new anywheresoftware.b4a.objects.collections.Map();
        params.Initialize();
        params.Put("StartId", startId);
        processBA.raiseEvent(null, "service_timeout", params);
            
    }
	@Override
	public void onDestroy() {
        super.onDestroy();
        if (false) {
            BA.LogInfo("** Service (myservice) Destroy (ignored)**");
        }
        else {
            BA.LogInfo("** Service (myservice) Destroy **");
		    processBA.raiseEvent(null, "service_destroy");
            processBA.service = null;
		    mostCurrent = null;
		    processBA.setActivityPaused(true);
            processBA.runHook("ondestroy", this, null);
        }
	}

@Override
	public android.os.IBinder onBind(android.content.Intent intent) {
		return null;
	}public anywheresoftware.b4a.keywords.Common __c = null;
public b4a.example.dateutils _vvvvvvvvvvvvvvvv1 = null;
public com.pas.abtahibo.parvaz.main _vvvvvvvvvvvvvvvv2 = null;
public com.pas.abtahibo.parvaz.actbook _vvvvvvvvvvvvvvvv3 = null;
public com.pas.abtahibo.parvaz.actapps _vvvvvvvvvvvvvvvv4 = null;
public com.pas.abtahibo.parvaz.actguide _vvvvvvvvvvvvvvvv5 = null;
public com.pas.abtahibo.parvaz.actnotific _vvvvvvvvvvvvvvvv6 = null;
public com.pas.abtahibo.parvaz.func _vvvvvvvvvvvvvvvv7 = null;
public com.pas.abtahibo.parvaz.playservicebook _vvvvvvvvvvvvvvvvv1 = null;
public com.pas.abtahibo.parvaz.playsrds _vvvvvvvvvvvvvvvvv2 = null;
public com.pas.abtahibo.parvaz.starter _vvvvvvvvvvvvvvvvv3 = null;
public com.pas.abtahibo.parvaz.support _vvvvvvvvvvvvvvvvv4 = null;
public com.pas.abtahibo.parvaz.urls _vvvvvvvvvvvvvvvvv5 = null;
public com.pas.abtahibo.parvaz.xuiviewsutils _vvvvvvvvvvvvvvvvv6 = null;
public static String  _vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv3(String _action) throws Exception{
String[] _hh = null;
String _playp = "";
String _wihse = "";
boolean _bill = false;
 //BA.debugLineNum = 21;BA.debugLine="Sub changePlay(Action As String)";
 //BA.debugLineNum = 23;BA.debugLine="Try";
try { //BA.debugLineNum = 24;BA.debugLine="Log(Action)";
anywheresoftware.b4a.keywords.Common.LogImpl("341156611",_action,0);
 //BA.debugLineNum = 26;BA.debugLine="Dim hh() As String = Regex.Split(\";;\",Action)";
_hh = anywheresoftware.b4a.keywords.Common.Regex.Split(";;",_action);
 //BA.debugLineNum = 28;BA.debugLine="Dim playP As String = hh(0)";
_playp = _hh[(int) (0)];
 //BA.debugLineNum = 29;BA.debugLine="Dim wihSe As String = hh(1)";
_wihse = _hh[(int) (1)];
 //BA.debugLineNum = 31;BA.debugLine="Dim bill As Boolean";
_bill = false;
 //BA.debugLineNum = 32;BA.debugLine="If playP = \"play\" Then";
if ((_playp).equals("play")) { 
 //BA.debugLineNum = 33;BA.debugLine="bill = True";
_bill = anywheresoftware.b4a.keywords.Common.True;
 }else {
 //BA.debugLineNum = 35;BA.debugLine="bill = False";
_bill = anywheresoftware.b4a.keywords.Common.False;
 };
 //BA.debugLineNum = 39;BA.debugLine="Select wihSe";
switch (BA.switchObjectToInt(_wihse,"book","book2")) {
case 0: {
 //BA.debugLineNum = 42;BA.debugLine="If bill Then";
if (_bill) { 
 //BA.debugLineNum = 43;BA.debugLine="If Not(playServiceBook.playBook.IsPlaying) Th";
if (anywheresoftware.b4a.keywords.Common.Not(mostCurrent._vvvvvvvvvvvvvvvvv1._vvvvvvvv4 /*anywheresoftware.b4a.objects.MediaPlayerWrapper*/ .IsPlaying())) { 
 //BA.debugLineNum = 44;BA.debugLine="playServiceBook.playBook.Play";
mostCurrent._vvvvvvvvvvvvvvvvv1._vvvvvvvv4 /*anywheresoftware.b4a.objects.MediaPlayerWrapper*/ .Play();
 };
 }else {
 //BA.debugLineNum = 47;BA.debugLine="If playServiceBook.playBook.IsPlaying Then";
if (mostCurrent._vvvvvvvvvvvvvvvvv1._vvvvvvvv4 /*anywheresoftware.b4a.objects.MediaPlayerWrapper*/ .IsPlaying()) { 
 //BA.debugLineNum = 48;BA.debugLine="playServiceBook.playBook.Pause";
mostCurrent._vvvvvvvvvvvvvvvvv1._vvvvvvvv4 /*anywheresoftware.b4a.objects.MediaPlayerWrapper*/ .Pause();
 };
 };
 //BA.debugLineNum = 52;BA.debugLine="CallSub(actBook,\"ppBook\")";
anywheresoftware.b4a.keywords.Common.CallSubNew(processBA,(Object)(mostCurrent._vvvvvvvvvvvvvvvv3.getObject()),"ppBook");
 //BA.debugLineNum = 53;BA.debugLine="If IsPaused(actBook) Then";
if (anywheresoftware.b4a.keywords.Common.IsPaused(processBA,(Object)(mostCurrent._vvvvvvvvvvvvvvvv3.getObject()))) { 
 //BA.debugLineNum = 54;BA.debugLine="func.savePFM(\"playBBook\",-1)";
mostCurrent._vvvvvvvvvvvvvvvv7._vvvvv2 /*String*/ (processBA,"playBBook",BA.NumberToString(-1));
 };
 break; }
case 1: {
 //BA.debugLineNum = 58;BA.debugLine="If bill Then";
if (_bill) { 
 //BA.debugLineNum = 59;BA.debugLine="If Not(playServiceBook.play2Book.IsPlaying) T";
if (anywheresoftware.b4a.keywords.Common.Not(mostCurrent._vvvvvvvvvvvvvvvvv1._vvvvvvvv5 /*anywheresoftware.b4a.audio.MediaPlayerStreamWrapper*/ .IsPlaying())) { 
 //BA.debugLineNum = 60;BA.debugLine="playServiceBook.play2Book.Play";
mostCurrent._vvvvvvvvvvvvvvvvv1._vvvvvvvv5 /*anywheresoftware.b4a.audio.MediaPlayerStreamWrapper*/ .Play();
 };
 }else {
 //BA.debugLineNum = 63;BA.debugLine="If playServiceBook.play2Book.IsPlaying Then";
if (mostCurrent._vvvvvvvvvvvvvvvvv1._vvvvvvvv5 /*anywheresoftware.b4a.audio.MediaPlayerStreamWrapper*/ .IsPlaying()) { 
 //BA.debugLineNum = 64;BA.debugLine="playServiceBook.play2Book.Pause";
mostCurrent._vvvvvvvvvvvvvvvvv1._vvvvvvvv5 /*anywheresoftware.b4a.audio.MediaPlayerStreamWrapper*/ .Pause();
 };
 };
 //BA.debugLineNum = 68;BA.debugLine="CallSub(actBook,\"ppBook\")";
anywheresoftware.b4a.keywords.Common.CallSubNew(processBA,(Object)(mostCurrent._vvvvvvvvvvvvvvvv3.getObject()),"ppBook");
 //BA.debugLineNum = 69;BA.debugLine="If IsPaused(actBook) Then";
if (anywheresoftware.b4a.keywords.Common.IsPaused(processBA,(Object)(mostCurrent._vvvvvvvvvvvvvvvv3.getObject()))) { 
 //BA.debugLineNum = 70;BA.debugLine="func.savePFM(\"playBBook\",-1)";
mostCurrent._vvvvvvvvvvvvvvvv7._vvvvv2 /*String*/ (processBA,"playBBook",BA.NumberToString(-1));
 };
 break; }
}
;
 } 
       catch (Exception e43) {
			processBA.setLastException(e43); //BA.debugLineNum = 78;BA.debugLine="Log(LastException)";
anywheresoftware.b4a.keywords.Common.LogImpl("341156665",BA.ObjectToString(anywheresoftware.b4a.keywords.Common.LastException(processBA)),0);
 };
 //BA.debugLineNum = 81;BA.debugLine="End Sub";
return "";
}
public static String  _process_globals() throws Exception{
 //BA.debugLineNum = 6;BA.debugLine="Sub Process_Globals";
 //BA.debugLineNum = 7;BA.debugLine="End Sub";
return "";
}
public static String  _service_create() throws Exception{
 //BA.debugLineNum = 9;BA.debugLine="Sub Service_Create";
 //BA.debugLineNum = 10;BA.debugLine="End Sub";
return "";
}
public static String  _service_destroy() throws Exception{
 //BA.debugLineNum = 83;BA.debugLine="Sub Service_Destroy";
 //BA.debugLineNum = 85;BA.debugLine="End Sub";
return "";
}
public static String  _service_start(anywheresoftware.b4a.objects.IntentWrapper _startingintent) throws Exception{
 //BA.debugLineNum = 12;BA.debugLine="Sub Service_Start (StartingIntent As Intent)";
 //BA.debugLineNum = 13;BA.debugLine="If StartingIntent.IsInitialized Then";
if (_startingintent.IsInitialized()) { 
 //BA.debugLineNum = 14;BA.debugLine="changePlay(StartingIntent.Action)";
_vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv3(_startingintent.getAction());
 };
 //BA.debugLineNum = 17;BA.debugLine="Service.StopAutomaticForeground";
mostCurrent._service.StopAutomaticForeground();
 //BA.debugLineNum = 19;BA.debugLine="End Sub";
return "";
}
}
