package com.pas.abtahibo.parvaz;


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

public class starter extends android.app.Service{
	public static class starter_BR extends android.content.BroadcastReceiver {

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

	}
    static starter mostCurrent;
	public static BA processBA;
    private ServiceHelper _service;
    public static Class<?> getObject() {
		return starter.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.starter");
            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.starter", processBA, _service, anywheresoftware.b4a.keywords.Common.Density);
		}
        if (!true && ServiceHelper.StarterHelper.startFromServiceCreate(processBA, false) == false) {
				
		}
		else {
            processBA.setActivityPaused(false);
            BA.LogInfo("*** Service (starter) Create ***");
            processBA.raiseEvent(null, "service_create");
        }
        processBA.runHook("oncreate", this, null);
        if (true) {
			if (ServiceHelper.StarterHelper.runWaitForLayouts() == false) {
                BA.LogInfo("stopping spontaneous created service");
                stopSelf();
            }
		}
        BA.LogInfo("*** Service (starter) 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 (starter) 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 (starter) Create **");
                    processBA.raiseEvent(null, "service_create");
					handleStart(intent);
                    ServiceHelper.StarterHelper.removeWaitForLayout();
				}
			});
		}
        processBA.runHook("onstartcommand", this, new Object[] {intent, flags, startId});
        BA.LogInfo("*** Service (starter) Started completed ***");
		return android.app.Service.START_NOT_STICKY;
    }
    public void onTaskRemoved(android.content.Intent rootIntent) {
        super.onTaskRemoved(rootIntent);
        if (true)
            processBA.raiseEvent(null, "service_taskremoved");
            
    }
    private void handleStart(android.content.Intent intent) {
    	BA.LogInfo("** Service (starter) 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 (starter) 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 (true) {
            BA.LogInfo("** Service (starter) Destroy (ignored)**");
        }
        else {
            BA.LogInfo("** Service (starter) 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 static com.pas.abtahibo.parvaz.fileprovider _vvvvvvvv0 = null;
public static anywheresoftware.b4a.objects.collections.List _vvvvvvvvv1 = 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.myservice _vvvvvvvvvvvvvvvv0 = null;
public com.pas.abtahibo.parvaz.playservicebook _vvvvvvvvvvvvvvvvv1 = null;
public com.pas.abtahibo.parvaz.playsrds _vvvvvvvvvvvvvvvvv2 = 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 boolean  _application_error(anywheresoftware.b4a.objects.B4AException _error,String _stacktrace) throws Exception{
 //BA.debugLineNum = 31;BA.debugLine="Sub Application_Error (Error As Exception, StackTr";
 //BA.debugLineNum = 32;BA.debugLine="Return True";
if (true) return anywheresoftware.b4a.keywords.Common.True;
 //BA.debugLineNum = 33;BA.debugLine="End Sub";
return false;
}
public static String  _vvvvvvvvv2() throws Exception{
 //BA.debugLineNum = 40;BA.debugLine="Sub finishAll";
 //BA.debugLineNum = 42;BA.debugLine="Try";
try { //BA.debugLineNum = 44;BA.debugLine="func.cacelNotific(10)";
mostCurrent._vvvvvvvvvvvvvvvv7._v7 /*String*/ (processBA,(int) (10));
 //BA.debugLineNum = 46;BA.debugLine="func.savePFM(\"psbook\",1)";
mostCurrent._vvvvvvvvvvvvvvvv7._vvvvv2 /*String*/ (processBA,"psbook",BA.NumberToString(1));
 //BA.debugLineNum = 47;BA.debugLine="func.savePFM(\"psspeech\",1)";
mostCurrent._vvvvvvvvvvvvvvvv7._vvvvv2 /*String*/ (processBA,"psspeech",BA.NumberToString(1));
 //BA.debugLineNum = 48;BA.debugLine="func.savePFM(\"psquran\",1)";
mostCurrent._vvvvvvvvvvvvvvvv7._vvvvv2 /*String*/ (processBA,"psquran",BA.NumberToString(1));
 //BA.debugLineNum = 49;BA.debugLine="func.savePFM(\"psqus\",1)";
mostCurrent._vvvvvvvvvvvvvvvv7._vvvvv2 /*String*/ (processBA,"psqus",BA.NumberToString(1));
 //BA.debugLineNum = 50;BA.debugLine="func.savePFM(\"psmatn\",1)";
mostCurrent._vvvvvvvvvvvvvvvv7._vvvvv2 /*String*/ (processBA,"psmatn",BA.NumberToString(1));
 //BA.debugLineNum = 51;BA.debugLine="func.savePFM(\"psdoaa\",1)";
mostCurrent._vvvvvvvvvvvvvvvv7._vvvvv2 /*String*/ (processBA,"psdoaa",BA.NumberToString(1));
 //BA.debugLineNum = 52;BA.debugLine="func.savePFM(\"psahkam\",1)";
mostCurrent._vvvvvvvvvvvvvvvv7._vvvvv2 /*String*/ (processBA,"psahkam",BA.NumberToString(1));
 //BA.debugLineNum = 53;BA.debugLine="func.savePFM(\"psDS\",1)";
mostCurrent._vvvvvvvvvvvvvvvv7._vvvvv2 /*String*/ (processBA,"psDS",BA.NumberToString(1));
 //BA.debugLineNum = 55;BA.debugLine="StopService(myService)";
anywheresoftware.b4a.keywords.Common.StopService(processBA,(Object)(mostCurrent._vvvvvvvvvvvvvvvv0.getObject()));
 //BA.debugLineNum = 56;BA.debugLine="StopService(playServiceBook)";
anywheresoftware.b4a.keywords.Common.StopService(processBA,(Object)(mostCurrent._vvvvvvvvvvvvvvvvv1.getObject()));
 } 
       catch (Exception e14) {
			processBA.setLastException(e14); //BA.debugLineNum = 59;BA.debugLine="Log(LastException)";
anywheresoftware.b4a.keywords.Common.LogImpl("354198291",BA.ObjectToString(anywheresoftware.b4a.keywords.Common.LastException(processBA)),0);
 };
 //BA.debugLineNum = 62;BA.debugLine="End Sub";
return "";
}
public static String  _process_globals() throws Exception{
 //BA.debugLineNum = 6;BA.debugLine="Sub Process_Globals";
 //BA.debugLineNum = 8;BA.debugLine="Public Provider As FileProvider";
_vvvvvvvv0 = new com.pas.abtahibo.parvaz.fileprovider();
 //BA.debugLineNum = 9;BA.debugLine="Public mpLan As List";
_vvvvvvvvv1 = new anywheresoftware.b4a.objects.collections.List();
 //BA.debugLineNum = 11;BA.debugLine="End Sub";
return "";
}
public static String  _service_create() throws Exception{
anywheresoftware.b4a.objects.collections.JSONParser _parser = null;
 //BA.debugLineNum = 13;BA.debugLine="Sub Service_Create";
 //BA.debugLineNum = 15;BA.debugLine="Provider.Initialize";
_vvvvvvvv0._initialize /*String*/ (processBA);
 //BA.debugLineNum = 17;BA.debugLine="Dim parser As JSONParser";
_parser = new anywheresoftware.b4a.objects.collections.JSONParser();
 //BA.debugLineNum = 18;BA.debugLine="parser.Initialize(File.ReadString(File.DirAssets,";
_parser.Initialize(anywheresoftware.b4a.keywords.Common.File.ReadString(anywheresoftware.b4a.keywords.Common.File.getDirAssets(),"lang.json"));
 //BA.debugLineNum = 19;BA.debugLine="mpLan = parser.NextArray";
_vvvvvvvvv1 = _parser.NextArray();
 //BA.debugLineNum = 21;BA.debugLine="End Sub";
return "";
}
public static String  _service_destroy() throws Exception{
 //BA.debugLineNum = 36;BA.debugLine="Sub Service_Destroy";
 //BA.debugLineNum = 37;BA.debugLine="finishAll";
_vvvvvvvvv2();
 //BA.debugLineNum = 38;BA.debugLine="End Sub";
return "";
}
public static String  _service_start(anywheresoftware.b4a.objects.IntentWrapper _startingintent) throws Exception{
 //BA.debugLineNum = 23;BA.debugLine="Sub Service_Start (StartingIntent As Intent)";
 //BA.debugLineNum = 24;BA.debugLine="Service.StopAutomaticForeground";
mostCurrent._service.StopAutomaticForeground();
 //BA.debugLineNum = 25;BA.debugLine="End Sub";
return "";
}
public static String  _service_taskremoved() throws Exception{
 //BA.debugLineNum = 27;BA.debugLine="Sub Service_TaskRemoved";
 //BA.debugLineNum = 28;BA.debugLine="finishAll";
_vvvvvvvvv2();
 //BA.debugLineNum = 29;BA.debugLine="End Sub";
return "";
}
}
