package cz.flashcards3000;


import anywheresoftware.b4a.BA;
import anywheresoftware.b4a.objects.ReceiverHelper;
import anywheresoftware.b4a.debug.*;

public class schedule extends android.content.BroadcastReceiver{
		
    static schedule mostCurrent;
	public static BA processBA;
    private ReceiverHelper _receiver;
    private static boolean firstTime = true;
    public static Class<?> getObject() {
		return schedule.class;
	}
	@Override
	public void onReceive(android.content.Context context, android.content.Intent intent) {
        mostCurrent = this;
       
        if (processBA == null) {
           
		    processBA = new BA(context, null, null, anywheresoftware.b4a.BA.SharedProcessBA.ModuleType.RECEIVER, "cz.flashcards3000.schedule");
            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());
        }
         _receiver = new ReceiverHelper(this);
        if (BA.isShellModeRuntimeCheck(processBA)) {
			processBA.raiseEvent2(null, true, "CREATE", true, "cz.flashcards3000.schedule", processBA, _receiver, anywheresoftware.b4a.keywords.Common.Density);
		}
        processBA.setActivityPaused(false);
        BA.LogInfo("*** Receiver (schedule) Receive " + (firstTime ? "(first time)" : "") + " ***");
        anywheresoftware.b4a.objects.IntentWrapper iw = new anywheresoftware.b4a.objects.IntentWrapper();
        iw.setObject(intent);
        processBA.raiseEvent(null, "receiver_receive", firstTime, iw);
        firstTime = false;
    }
	
public anywheresoftware.b4a.keywords.Common __c = null;
public static anywheresoftware.b4a.objects.drawable.CanvasWrapper.BitmapWrapper _smiley = null;
public static anywheresoftware.b4a.objects.NotificationWrapper _ntf = null;
public b4a.example.dateutils _dateutils = null;
public cz.flashcards3000.main _main = null;
public cz.flashcards3000.starter _starter = null;
public cz.flashcards3000.tools _tools = null;
public cz.flashcards3000.cl _cl = null;
public cz.flashcards3000.as_properties _as_properties = null;
public cz.flashcards3000.b4xpages _b4xpages = null;
public cz.flashcards3000.b4xcollections _b4xcollections = null;
public cz.flashcards3000.dbutils _dbutils = null;
public cz.flashcards3000.httputils2service _httputils2service = null;
public cz.flashcards3000.throwables_static _throwables_static = null;
public cz.flashcards3000.xuiviewsutils _xuiviewsutils = null;
public static String  _process_globals() throws Exception{
 //BA.debugLineNum = 1;BA.debugLine="Sub Process_Globals";
 //BA.debugLineNum = 2;BA.debugLine="Private smiley As Bitmap";
_smiley = new anywheresoftware.b4a.objects.drawable.CanvasWrapper.BitmapWrapper();
 //BA.debugLineNum = 3;BA.debugLine="Public ntf As Notification";
_ntf = new anywheresoftware.b4a.objects.NotificationWrapper();
 //BA.debugLineNum = 4;BA.debugLine="End Sub";
return "";
}
public static void  _receiver_receive(boolean _firsttime,anywheresoftware.b4a.objects.IntentWrapper _startingintent) throws Exception{
ResumableSub_Receiver_Receive rsub = new ResumableSub_Receiver_Receive(null,_firsttime,_startingintent);
rsub.resume(processBA, null);
}
public static class ResumableSub_Receiver_Receive extends BA.ResumableSub {
public ResumableSub_Receiver_Receive(cz.flashcards3000.schedule parent,boolean _firsttime,anywheresoftware.b4a.objects.IntentWrapper _startingintent) {
this.parent = parent;
this._firsttime = _firsttime;
this._startingintent = _startingintent;
}
cz.flashcards3000.schedule parent;
boolean _firsttime;
anywheresoftware.b4a.objects.IntentWrapper _startingintent;
long _t = 0L;
b4a.example.dateutils._period _p = null;
long _nexttime = 0L;

@Override
public void resume(BA ba, Object[] result) throws Exception{

    while (true) {
        switch (state) {
            case -1:
return;

case 0:
//C
this.state = 1;
 //BA.debugLineNum = 10;BA.debugLine="If StartingIntent.Action = \"\" Then";
if (true) break;

case 1:
//if
this.state = 4;
if ((_startingintent.getAction()).equals("")) { 
this.state = 3;
}if (true) break;

case 3:
//C
this.state = 4;
 //BA.debugLineNum = 12;BA.debugLine="StartNotification";
_startnotification();
 //BA.debugLineNum = 15;BA.debugLine="Wait For (SetNextEvent) Complete (t As Long)";
anywheresoftware.b4a.keywords.Common.WaitFor("complete", processBA, this, _setnextevent());
this.state = 8;
return;
case 8:
//C
this.state = 4;
_t = (Long) result[0];
;
 //BA.debugLineNum = 17;BA.debugLine="StartReceiverAt(Me, t, True)";
anywheresoftware.b4a.keywords.Common.StartReceiverAt(processBA,schedule.getObject(),_t,anywheresoftware.b4a.keywords.Common.True);
 if (true) break;
;
 //BA.debugLineNum = 21;BA.debugLine="If StartingIntent.Action = \"inanhour\" Then";

case 4:
//if
this.state = 7;
if ((_startingintent.getAction()).equals("inanhour")) { 
this.state = 6;
}if (true) break;

case 6:
//C
this.state = 7;
 //BA.debugLineNum = 22;BA.debugLine="Dim p As Period";
_p = new b4a.example.dateutils._period();
 //BA.debugLineNum = 23;BA.debugLine="p.Hours = 1";
_p.Hours = (int) (1);
 //BA.debugLineNum = 24;BA.debugLine="Dim NextTime As Long = DateUtils.AddPeriod(DateT";
_nexttime = parent.mostCurrent._dateutils._addperiod(processBA,anywheresoftware.b4a.keywords.Common.DateTime.getNow(),_p);
 //BA.debugLineNum = 26;BA.debugLine="Sleep(1000)";
anywheresoftware.b4a.keywords.Common.Sleep(processBA,this,(int) (1000));
this.state = 9;
return;
case 9:
//C
this.state = 7;
;
 //BA.debugLineNum = 27;BA.debugLine="StartReceiverAt(Me, NextTime, True)";
anywheresoftware.b4a.keywords.Common.StartReceiverAt(processBA,schedule.getObject(),_nexttime,anywheresoftware.b4a.keywords.Common.True);
 //BA.debugLineNum = 28;BA.debugLine="ntf.Cancel(4)";
parent._ntf.Cancel((int) (4));
 if (true) break;

case 7:
//C
this.state = -1;
;
 //BA.debugLineNum = 30;BA.debugLine="End Sub";
if (true) break;

            }
        }
    }
}
public static void  _complete(long _t) throws Exception{
}
public static anywheresoftware.b4a.keywords.Common.ResumableSubWrapper  _setnextevent() throws Exception{
ResumableSub_SetNextEvent rsub = new ResumableSub_SetNextEvent(null);
rsub.resume(processBA, null);
return (anywheresoftware.b4a.keywords.Common.ResumableSubWrapper) anywheresoftware.b4a.AbsObjectWrapper.ConvertToWrapper(new anywheresoftware.b4a.keywords.Common.ResumableSubWrapper(), rsub);
}
public static class ResumableSub_SetNextEvent extends BA.ResumableSub {
public ResumableSub_SetNextEvent(cz.flashcards3000.schedule parent) {
this.parent = parent;
}
cz.flashcards3000.schedule parent;
String _cas = "";
long _t = 0L;
long _tret = 0L;
adr.stringfunctions.stringfunctions _sf = null;
anywheresoftware.b4a.objects.collections.List _l = null;
String _h = "";
String _m = "";

@Override
public void resume(BA ba, Object[] result) throws Exception{

    while (true) {
        switch (state) {
            case -1:
{
anywheresoftware.b4a.keywords.Common.ReturnFromResumableSub(this,null);return;}
case 0:
//C
this.state = 1;
 //BA.debugLineNum = 45;BA.debugLine="Dim cas As String = Starter.rem_time";
_cas = parent.mostCurrent._starter._rem_time /*String*/ ;
 //BA.debugLineNum = 46;BA.debugLine="Dim t, tret As Long";
_t = 0L;
_tret = 0L;
 //BA.debugLineNum = 47;BA.debugLine="Dim sf As StringFunctions";
_sf = new adr.stringfunctions.stringfunctions();
 //BA.debugLineNum = 48;BA.debugLine="sf.Initialize";
_sf._initialize(processBA);
 //BA.debugLineNum = 49;BA.debugLine="Dim l As List = sf.split(cas, \":\")";
_l = new anywheresoftware.b4a.objects.collections.List();
_l = _sf._vvvvvv5(_cas,":");
 //BA.debugLineNum = 50;BA.debugLine="Dim h As String = l.Get(0)";
_h = BA.ObjectToString(_l.Get((int) (0)));
 //BA.debugLineNum = 51;BA.debugLine="Dim m As String = l.Get(1)";
_m = BA.ObjectToString(_l.Get((int) (1)));
 //BA.debugLineNum = 52;BA.debugLine="t = DateUtils.SetDateAndTime(DateTime.GetYear(Dat";
_t = parent.mostCurrent._dateutils._setdateandtime(processBA,anywheresoftware.b4a.keywords.Common.DateTime.GetYear(anywheresoftware.b4a.keywords.Common.DateTime.getNow()),anywheresoftware.b4a.keywords.Common.DateTime.GetMonth(anywheresoftware.b4a.keywords.Common.DateTime.getNow()),anywheresoftware.b4a.keywords.Common.DateTime.GetDayOfMonth(anywheresoftware.b4a.keywords.Common.DateTime.getNow()),(int)(Double.parseDouble(_h)),(int)(Double.parseDouble(_m)),(int) (0));
 //BA.debugLineNum = 55;BA.debugLine="If t > DateTime.Now Then";
if (true) break;

case 1:
//if
this.state = 6;
if (_t>anywheresoftware.b4a.keywords.Common.DateTime.getNow()) { 
this.state = 3;
}else {
this.state = 5;
}if (true) break;

case 3:
//C
this.state = 6;
 //BA.debugLineNum = 56;BA.debugLine="tret = t";
_tret = _t;
 if (true) break;

case 5:
//C
this.state = 6;
 //BA.debugLineNum = 58;BA.debugLine="tret = DateTime.Add(t, 0, 0, 1) 'next day";
_tret = anywheresoftware.b4a.keywords.Common.DateTime.Add(_t,(int) (0),(int) (0),(int) (1));
 if (true) break;

case 6:
//C
this.state = -1;
;
 //BA.debugLineNum = 60;BA.debugLine="Return tret";
if (true) {
anywheresoftware.b4a.keywords.Common.ReturnFromResumableSub(this,(Object)(_tret));return;};
 //BA.debugLineNum = 61;BA.debugLine="End Sub";
if (true) break;

            }
        }
    }
}
public static String  _startnotification() throws Exception{
String _sched = "";
cz.flashcards3000.nb6 _n = null;
anywheresoftware.b4a.objects.CSBuilder _cs = null;
 //BA.debugLineNum = 32;BA.debugLine="Private Sub StartNotification";
 //BA.debugLineNum = 34;BA.debugLine="Dim sched As String = Starter.loc_schedule";
_sched = mostCurrent._starter._loc_schedule /*String*/ ;
 //BA.debugLineNum = 35;BA.debugLine="Dim n As NB6";
_n = new cz.flashcards3000.nb6();
 //BA.debugLineNum = 36;BA.debugLine="smiley = LoadBitmapResize(File.DirAssets, \"ic_lau";
_smiley = anywheresoftware.b4a.keywords.Common.LoadBitmapResize(anywheresoftware.b4a.keywords.Common.File.getDirAssets(),"ic_launcher.png",anywheresoftware.b4a.keywords.Common.DipToCurrent((int) (24)),anywheresoftware.b4a.keywords.Common.DipToCurrent((int) (24)),anywheresoftware.b4a.keywords.Common.False);
 //BA.debugLineNum = 37;BA.debugLine="n.Initialize(\"default\", Application.LabelName, \"D";
_n._initialize /*cz.flashcards3000.nb6*/ (processBA,"default",(Object)(anywheresoftware.b4a.keywords.Common.Application.getLabelName()),"DEFAULT")._autocancel /*cz.flashcards3000.nb6*/ (anywheresoftware.b4a.keywords.Common.True)._smallicon /*cz.flashcards3000.nb6*/ (_smiley);
 //BA.debugLineNum = 38;BA.debugLine="Dim cs As CSBuilder";
_cs = new anywheresoftware.b4a.objects.CSBuilder();
 //BA.debugLineNum = 39;BA.debugLine="n.AddButtonAction(smiley, cs.Initialize.Color(Col";
_n._addbuttonaction /*cz.flashcards3000.nb6*/ (_smiley,(Object)(_cs.Initialize().Color(anywheresoftware.b4a.keywords.Common.Colors.Green).Bold().Append(BA.ObjectToCharSequence(mostCurrent._starter._loc_inanhour /*String*/ )).PopAll().getObject()),schedule.getObject(),"inanhour");
 //BA.debugLineNum = 40;BA.debugLine="ntf = n.Build(\"Flash cards\", sched, \"tag1\", Main)";
_ntf = _n._build /*anywheresoftware.b4a.objects.NotificationWrapper*/ ((Object)("Flash cards"),(Object)(_sched),"tag1",(Object)(mostCurrent._main.getObject()));
 //BA.debugLineNum = 41;BA.debugLine="ntf.Notify(4)";
_ntf.Notify((int) (4));
 //BA.debugLineNum = 42;BA.debugLine="End Sub";
return "";
}
}
