package ed.smith.calendar.example;


import anywheresoftware.b4a.B4AMenuItem;
import android.app.Activity;
import android.os.Bundle;
import anywheresoftware.b4a.BA;
import anywheresoftware.b4a.BALayout;
import anywheresoftware.b4a.B4AActivity;
import anywheresoftware.b4a.ObjectWrapper;
import anywheresoftware.b4a.objects.ActivityWrapper;
import java.lang.reflect.InvocationTargetException;
import anywheresoftware.b4a.B4AUncaughtException;
import anywheresoftware.b4a.debug.*;
import java.lang.ref.WeakReference;

public class main extends Activity implements B4AActivity{
	public static main mostCurrent;
	static boolean afterFirstLayout;
	static boolean isFirst = true;
    private static boolean processGlobalsRun = false;
	BALayout layout;
	public static BA processBA;
	BA activityBA;
    ActivityWrapper _activity;
    java.util.ArrayList<B4AMenuItem> menuItems;
	public static final boolean fullScreen = false;
	public static final boolean includeTitle = true;
    public static WeakReference<Activity> previousOne;
    public static boolean dontPause;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
        mostCurrent = this;
		if (processBA == null) {
			processBA = new BA(this.getApplicationContext(), null, null, "ed.smith.calendar.example", "ed.smith.calendar.example.main");
			processBA.loadHtSubs(this.getClass());
	        float deviceScale = getApplicationContext().getResources().getDisplayMetrics().density;
	        BALayout.setDeviceScale(deviceScale);
            
		}
		else if (previousOne != null) {
			Activity p = previousOne.get();
			if (p != null && p != this) {
                BA.LogInfo("Killing previous instance (main).");
				p.finish();
			}
		}
        processBA.setActivityPaused(true);
        processBA.runHook("oncreate", this, null);
		if (!includeTitle) {
        	this.getWindow().requestFeature(android.view.Window.FEATURE_NO_TITLE);
        }
        if (fullScreen) {
        	getWindow().setFlags(android.view.WindowManager.LayoutParams.FLAG_FULLSCREEN,   
        			android.view.WindowManager.LayoutParams.FLAG_FULLSCREEN);
        }
		
        processBA.sharedProcessBA.activityBA = null;
		layout = new BALayout(this);
		setContentView(layout);
		afterFirstLayout = false;
        WaitForLayout wl = new WaitForLayout();
        if (anywheresoftware.b4a.objects.ServiceHelper.StarterHelper.startFromActivity(this, processBA, wl, true))
		    BA.handler.postDelayed(wl, 5);

	}
	static class WaitForLayout implements Runnable {
		public void run() {
			if (afterFirstLayout)
				return;
			if (mostCurrent == null)
				return;
            
			if (mostCurrent.layout.getWidth() == 0) {
				BA.handler.postDelayed(this, 5);
				return;
			}
			mostCurrent.layout.getLayoutParams().height = mostCurrent.layout.getHeight();
			mostCurrent.layout.getLayoutParams().width = mostCurrent.layout.getWidth();
			afterFirstLayout = true;
			mostCurrent.afterFirstLayout();
		}
	}
	private void afterFirstLayout() {
        if (this != mostCurrent)
			return;
		activityBA = new BA(this, layout, processBA, "ed.smith.calendar.example", "ed.smith.calendar.example.main");
        
        processBA.sharedProcessBA.activityBA = new java.lang.ref.WeakReference<BA>(activityBA);
        anywheresoftware.b4a.objects.ViewWrapper.lastId = 0;
        _activity = new ActivityWrapper(activityBA, "activity");
        anywheresoftware.b4a.Msgbox.isDismissing = false;
        if (BA.isShellModeRuntimeCheck(processBA)) {
			if (isFirst)
				processBA.raiseEvent2(null, true, "SHELL", false);
			processBA.raiseEvent2(null, true, "CREATE", true, "ed.smith.calendar.example.main", processBA, activityBA, _activity, anywheresoftware.b4a.keywords.Common.Density, mostCurrent);
			_activity.reinitializeForShell(activityBA, "activity");
		}
        initializeProcessGlobals();		
        initializeGlobals();
        
        BA.LogInfo("** Activity (main) Create, isFirst = " + isFirst + " **");
        processBA.raiseEvent2(null, true, "activity_create", false, isFirst);
		isFirst = false;
		if (this != mostCurrent)
			return;
        processBA.setActivityPaused(false);
        BA.LogInfo("** Activity (main) Resume **");
        processBA.raiseEvent(null, "activity_resume");
        if (android.os.Build.VERSION.SDK_INT >= 11) {
			try {
				android.app.Activity.class.getMethod("invalidateOptionsMenu").invoke(this,(Object[]) null);
			} catch (Exception e) {
				e.printStackTrace();
			}
		}

	}
	public void addMenuItem(B4AMenuItem item) {
		if (menuItems == null)
			menuItems = new java.util.ArrayList<B4AMenuItem>();
		menuItems.add(item);
	}
	@Override
	public boolean onCreateOptionsMenu(android.view.Menu menu) {
		super.onCreateOptionsMenu(menu);
        try {
            if (processBA.subExists("activity_actionbarhomeclick")) {
                Class.forName("android.app.ActionBar").getMethod("setHomeButtonEnabled", boolean.class).invoke(
                    getClass().getMethod("getActionBar").invoke(this), true);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        if (processBA.runHook("oncreateoptionsmenu", this, new Object[] {menu}))
            return true;
		if (menuItems == null)
			return false;
		for (B4AMenuItem bmi : menuItems) {
			android.view.MenuItem mi = menu.add(bmi.title);
			if (bmi.drawable != null)
				mi.setIcon(bmi.drawable);
            if (android.os.Build.VERSION.SDK_INT >= 11) {
				try {
                    if (bmi.addToBar) {
				        android.view.MenuItem.class.getMethod("setShowAsAction", int.class).invoke(mi, 1);
                    }
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
			mi.setOnMenuItemClickListener(new B4AMenuItemsClickListener(bmi.eventName.toLowerCase(BA.cul)));
		}
        
		return true;
	}   
 @Override
 public boolean onOptionsItemSelected(android.view.MenuItem item) {
    if (item.getItemId() == 16908332) {
        processBA.raiseEvent(null, "activity_actionbarhomeclick");
        return true;
    }
    else
        return super.onOptionsItemSelected(item); 
}
@Override
 public boolean onPrepareOptionsMenu(android.view.Menu menu) {
    super.onPrepareOptionsMenu(menu);
    processBA.runHook("onprepareoptionsmenu", this, new Object[] {menu});
    return true;
    
 }
 protected void onStart() {
    super.onStart();
    processBA.runHook("onstart", this, null);
}
 protected void onStop() {
    super.onStop();
    processBA.runHook("onstop", this, null);
}
    public void onWindowFocusChanged(boolean hasFocus) {
       super.onWindowFocusChanged(hasFocus);
       if (processBA.subExists("activity_windowfocuschanged"))
           processBA.raiseEvent2(null, true, "activity_windowfocuschanged", false, hasFocus);
    }
	private class B4AMenuItemsClickListener implements android.view.MenuItem.OnMenuItemClickListener {
		private final String eventName;
		public B4AMenuItemsClickListener(String eventName) {
			this.eventName = eventName;
		}
		public boolean onMenuItemClick(android.view.MenuItem item) {
			processBA.raiseEventFromUI(item.getTitle(), eventName + "_click");
			return true;
		}
	}
    public static Class<?> getObject() {
		return main.class;
	}
    private Boolean onKeySubExist = null;
    private Boolean onKeyUpSubExist = null;
	@Override
	public boolean onKeyDown(int keyCode, android.view.KeyEvent event) {
        if (processBA.runHook("onkeydown", this, new Object[] {keyCode, event}))
            return true;
		if (onKeySubExist == null)
			onKeySubExist = processBA.subExists("activity_keypress");
		if (onKeySubExist) {
			if (keyCode == anywheresoftware.b4a.keywords.constants.KeyCodes.KEYCODE_BACK &&
					android.os.Build.VERSION.SDK_INT >= 18) {
				HandleKeyDelayed hk = new HandleKeyDelayed();
				hk.kc = keyCode;
				BA.handler.post(hk);
				return true;
			}
			else {
				boolean res = new HandleKeyDelayed().runDirectly(keyCode);
				if (res)
					return true;
			}
		}
		return super.onKeyDown(keyCode, event);
	}
	private class HandleKeyDelayed implements Runnable {
		int kc;
		public void run() {
			runDirectly(kc);
		}
		public boolean runDirectly(int keyCode) {
			Boolean res =  (Boolean)processBA.raiseEvent2(_activity, false, "activity_keypress", false, keyCode);
			if (res == null || res == true) {
                return true;
            }
            else if (keyCode == anywheresoftware.b4a.keywords.constants.KeyCodes.KEYCODE_BACK) {
				finish();
				return true;
			}
            return false;
		}
		
	}
    @Override
	public boolean onKeyUp(int keyCode, android.view.KeyEvent event) {
        if (processBA.runHook("onkeyup", this, new Object[] {keyCode, event}))
            return true;
		if (onKeyUpSubExist == null)
			onKeyUpSubExist = processBA.subExists("activity_keyup");
		if (onKeyUpSubExist) {
			Boolean res =  (Boolean)processBA.raiseEvent2(_activity, false, "activity_keyup", false, keyCode);
			if (res == null || res == true)
				return true;
		}
		return super.onKeyUp(keyCode, event);
	}
	@Override
	public void onNewIntent(android.content.Intent intent) {
        super.onNewIntent(intent);
		this.setIntent(intent);
        processBA.runHook("onnewintent", this, new Object[] {intent});
	}
    @Override 
	public void onPause() {
		super.onPause();
        if (_activity == null)
            return;
        if (this != mostCurrent)
			return;
		anywheresoftware.b4a.Msgbox.dismiss(true);
        if (!dontPause)
            BA.LogInfo("** Activity (main) Pause, UserClosed = " + activityBA.activity.isFinishing() + " **");
        else
            BA.LogInfo("** Activity (main) Pause event (activity is not paused). **");
        if (mostCurrent != null)
            processBA.raiseEvent2(_activity, true, "activity_pause", false, activityBA.activity.isFinishing());		
        if (!dontPause) {
            processBA.setActivityPaused(true);
            mostCurrent = null;
        }

        if (!activityBA.activity.isFinishing())
			previousOne = new WeakReference<Activity>(this);
        anywheresoftware.b4a.Msgbox.isDismissing = false;
        processBA.runHook("onpause", this, null);
	}

	@Override
	public void onDestroy() {
        super.onDestroy();
		previousOne = null;
        processBA.runHook("ondestroy", this, null);
	}
    @Override 
	public void onResume() {
		super.onResume();
        mostCurrent = this;
        anywheresoftware.b4a.Msgbox.isDismissing = false;
        if (activityBA != null) { //will be null during activity create (which waits for AfterLayout).
        	ResumeMessage rm = new ResumeMessage(mostCurrent);
        	BA.handler.post(rm);
        }
        processBA.runHook("onresume", this, null);
	}
    private static class ResumeMessage implements Runnable {
    	private final WeakReference<Activity> activity;
    	public ResumeMessage(Activity activity) {
    		this.activity = new WeakReference<Activity>(activity);
    	}
		public void run() {
            main mc = mostCurrent;
			if (mc == null || mc != activity.get())
				return;
			processBA.setActivityPaused(false);
            BA.LogInfo("** Activity (main) Resume **");
            if (mc != mostCurrent)
                return;
		    processBA.raiseEvent(mc._activity, "activity_resume", (Object[])null);
		}
    }
	@Override
	protected void onActivityResult(int requestCode, int resultCode,
	      android.content.Intent data) {
		processBA.onActivityResult(requestCode, resultCode, data);
        processBA.runHook("onactivityresult", this, new Object[] {requestCode, resultCode});
	}
	private static void initializeGlobals() {
		processBA.raiseEvent2(null, true, "globals", false, (Object[])null);
	}
    public void onRequestPermissionsResult(int requestCode,
        String permissions[], int[] grantResults) {
        for (int i = 0;i < permissions.length;i++) {
            Object[] o = new Object[] {permissions[i], grantResults[i] == 0};
            processBA.raiseEventFromDifferentThread(null,null, 0, "activity_permissionresult", true, o);
        }
            
    }

public anywheresoftware.b4a.keywords.Common __c = null;
public static de.amberhome.objects.preferenceactivity.PreferenceManager _manager = null;
public static de.amberhome.objects.preferenceactivity.PreferenceScreenWrapper _screen = null;
public static int _calendarnumber = 0;
public anywheresoftware.b4a.objects.collections.Map _mymap = null;
public anywheresoftware.b4a.objects.ListViewWrapper _listview1 = null;
public edsmith.calendar.Calendar _cal = null;
public anywheresoftware.b4a.objects.ScrollViewWrapper _scrollview1 = null;
public anywheresoftware.b4a.objects.EditTextWrapper _edittext1 = null;
public anywheresoftware.b4a.objects.CompoundButtonWrapper.RadioButtonWrapper _rbtnreadcalendar = null;
public anywheresoftware.b4a.objects.CompoundButtonWrapper.RadioButtonWrapper _rbtnwritecalendar = null;
public anywheresoftware.b4a.objects.CompoundButtonWrapper.RadioButtonWrapper _rbtnalldayevent = null;
public anywheresoftware.b4a.objects.CompoundButtonWrapper.RadioButtonWrapper _rbtncreaterecur = null;
public anywheresoftware.b4a.objects.CompoundButtonWrapper.RadioButtonWrapper _rbtndelete = null;
public anywheresoftware.b4a.objects.ListViewWrapper _listview2 = null;
public anywheresoftware.b4a.objects.collections.List _mycalendarlist = null;
public anywheresoftware.b4a.objects.CompoundButtonWrapper.RadioButtonWrapper _rbtnsearch = null;

public static boolean isAnyActivityVisible() {
    boolean vis = false;
vis = vis | (main.mostCurrent != null);
return vis;}
public static String  _activity_create(boolean _firsttime) throws Exception{
String _calnum = "";
anywheresoftware.b4a.objects.collections.List _mylist = null;
int _i = 0;
 //BA.debugLineNum = 40;BA.debugLine="Sub Activity_Create(FirstTime As Boolean)";
 //BA.debugLineNum = 42;BA.debugLine="If FirstTime Then";
if (_firsttime) { 
 //BA.debugLineNum = 43;BA.debugLine="CreatePreferenceScreen					'preference screen us";
_createpreferencescreen();
 };
 //BA.debugLineNum = 45;BA.debugLine="Activity.AddMenuItem(\"Settings\",\"Settings\")";
mostCurrent._activity.AddMenuItem(BA.ObjectToCharSequence("Settings"),"Settings");
 //BA.debugLineNum = 47;BA.debugLine="Activity.LoadLayout(\"layout1\")";
mostCurrent._activity.LoadLayout("layout1",mostCurrent.activityBA);
 //BA.debugLineNum = 48;BA.debugLine="ListView2.ScrollingBackgroundColor = Colors.ARGB(";
mostCurrent._listview2.setScrollingBackgroundColor(anywheresoftware.b4a.keywords.Common.Colors.ARGB((int) (255),(int) (85),(int) (107),(int) (47)));
 //BA.debugLineNum = 49;BA.debugLine="mycalendarlist.Initialize";
mostCurrent._mycalendarlist.Initialize();
 //BA.debugLineNum = 51;BA.debugLine="Dim myMap As Map";
mostCurrent._mymap = new anywheresoftware.b4a.objects.collections.Map();
 //BA.debugLineNum = 52;BA.debugLine="myMap.Initialize";
mostCurrent._mymap.Initialize();
 //BA.debugLineNum = 56;BA.debugLine="Dim calnum As String";
_calnum = "";
 //BA.debugLineNum = 60;BA.debugLine="Dim mylist As List";
_mylist = new anywheresoftware.b4a.objects.collections.List();
 //BA.debugLineNum = 61;BA.debugLine="mylist.Initialize";
_mylist.Initialize();
 //BA.debugLineNum = 66;BA.debugLine="Dim cal As MyCalendar";
mostCurrent._cal = new edsmith.calendar.Calendar();
 //BA.debugLineNum = 67;BA.debugLine="cal.Initialize";
mostCurrent._cal.Initialize(processBA);
 //BA.debugLineNum = 69;BA.debugLine="Dim i As Int";
_i = 0;
 //BA.debugLineNum = 71;BA.debugLine="myMap = cal.GetListOfAllCalendars(True)		'get a \"";
mostCurrent._mymap = mostCurrent._cal.GetListOfAllCalendars(anywheresoftware.b4a.keywords.Common.True);
 //BA.debugLineNum = 72;BA.debugLine="For i = 0 To myMap.Size-1					'the 'Value' contai";
{
final int step17 = 1;
final int limit17 = (int) (mostCurrent._mymap.getSize()-1);
_i = (int) (0) ;
for (;_i <= limit17 ;_i = _i + step17 ) {
 //BA.debugLineNum = 75;BA.debugLine="ListView1.AddTwoLines2(myMap.GetValueAt(i),myMap";
mostCurrent._listview1.AddTwoLines2(BA.ObjectToCharSequence(mostCurrent._mymap.GetValueAt(_i)),BA.ObjectToCharSequence(mostCurrent._mymap.GetKeyAt(_i)),mostCurrent._mymap.GetKeyAt(_i));
 }
};
 //BA.debugLineNum = 78;BA.debugLine="End Sub";
return "";
}
public static String  _activity_pause(boolean _userclosed) throws Exception{
 //BA.debugLineNum = 89;BA.debugLine="Sub Activity_Pause (UserClosed As Boolean)";
 //BA.debugLineNum = 91;BA.debugLine="End Sub";
return "";
}
public static String  _activity_resume() throws Exception{
 //BA.debugLineNum = 80;BA.debugLine="Sub Activity_Resume";
 //BA.debugLineNum = 81;BA.debugLine="If IsNumber(manager.GetString(\"CalendarNumber\") )";
if (anywheresoftware.b4a.keywords.Common.IsNumber(_manager.GetString("CalendarNumber"))) { 
 //BA.debugLineNum = 82;BA.debugLine="CalendarNumber = manager.GetString(\"CalendarNumb";
_calendarnumber = (int)(Double.parseDouble(_manager.GetString("CalendarNumber")));
 }else {
 //BA.debugLineNum = 84;BA.debugLine="CalendarNumber = -1";
_calendarnumber = (int) (-1);
 };
 //BA.debugLineNum = 86;BA.debugLine="Log(CalendarNumber)";
anywheresoftware.b4a.keywords.Common.LogImpl("4196614",BA.NumberToString(_calendarnumber),0);
 //BA.debugLineNum = 87;BA.debugLine="End Sub";
return "";
}
public static String  _createpreferencescreen() throws Exception{
de.amberhome.objects.preferenceactivity.PreferenceCategoryWrapper _cat3 = null;
de.amberhome.objects.preferenceactivity.PreferenceScreenWrapper _intentscreen = null;
int _i = 0;
anywheresoftware.b4a.objects.collections.Map _tempmap = null;
 //BA.debugLineNum = 94;BA.debugLine="Sub CreatePreferenceScreen";
 //BA.debugLineNum = 95;BA.debugLine="screen.Initialize(\"Settings\", \"\")";
_screen.Initialize("Settings","");
 //BA.debugLineNum = 96;BA.debugLine="Dim cat3 As AHPreferenceCategory";
_cat3 = new de.amberhome.objects.preferenceactivity.PreferenceCategoryWrapper();
 //BA.debugLineNum = 97;BA.debugLine="Dim intentScreen As AHPreferenceScreen";
_intentscreen = new de.amberhome.objects.preferenceactivity.PreferenceScreenWrapper();
 //BA.debugLineNum = 102;BA.debugLine="cal.Initialize";
mostCurrent._cal.Initialize(processBA);
 //BA.debugLineNum = 103;BA.debugLine="Dim i As Int";
_i = 0;
 //BA.debugLineNum = 104;BA.debugLine="Dim tempMap As Map";
_tempmap = new anywheresoftware.b4a.objects.collections.Map();
 //BA.debugLineNum = 105;BA.debugLine="tempMap.Initialize";
_tempmap.Initialize();
 //BA.debugLineNum = 108;BA.debugLine="myMap = cal.GetListOfAllCalendars(True)";
mostCurrent._mymap = mostCurrent._cal.GetListOfAllCalendars(anywheresoftware.b4a.keywords.Common.True);
 //BA.debugLineNum = 109;BA.debugLine="For i = 0 To myMap.Size-1";
{
final int step9 = 1;
final int limit9 = (int) (mostCurrent._mymap.getSize()-1);
_i = (int) (0) ;
for (;_i <= limit9 ;_i = _i + step9 ) {
 //BA.debugLineNum = 112;BA.debugLine="tempMap.Put(myMap.GetKeyAt(i),myMap.GetValueAt(";
_tempmap.Put(mostCurrent._mymap.GetKeyAt(_i),mostCurrent._mymap.GetValueAt(_i));
 }
};
 //BA.debugLineNum = 116;BA.debugLine="cat3.Initialize(\"Calendar to use for events\")";
_cat3.Initialize("Calendar to use for events");
 //BA.debugLineNum = 117;BA.debugLine="cat3.AddList2(\"CalendarNumber\",\"Calenders\", \"Sele";
_cat3.AddList2("CalendarNumber","Calenders","Select the required calendar","","",_tempmap);
 //BA.debugLineNum = 121;BA.debugLine="screen.AddPreferenceCategory(cat3)";
_screen.AddPreferenceCategory(_cat3);
 //BA.debugLineNum = 122;BA.debugLine="End Sub";
return "";
}
public static String  _edittext1_focuschanged(boolean _hasfocus) throws Exception{
 //BA.debugLineNum = 235;BA.debugLine="Sub EditText1_FocusChanged (HasFocus As Boolean)";
 //BA.debugLineNum = 236;BA.debugLine="If HasFocus Then rbtnSearch.Checked = True";
if (_hasfocus) { 
mostCurrent._rbtnsearch.setChecked(anywheresoftware.b4a.keywords.Common.True);};
 //BA.debugLineNum = 237;BA.debugLine="End Sub";
return "";
}
public static String  _globals() throws Exception{
 //BA.debugLineNum = 20;BA.debugLine="Sub Globals";
 //BA.debugLineNum = 23;BA.debugLine="Dim myMap As Map";
mostCurrent._mymap = new anywheresoftware.b4a.objects.collections.Map();
 //BA.debugLineNum = 25;BA.debugLine="Dim ListView1 As ListView";
mostCurrent._listview1 = new anywheresoftware.b4a.objects.ListViewWrapper();
 //BA.debugLineNum = 26;BA.debugLine="Dim cal As MyCalendar";
mostCurrent._cal = new edsmith.calendar.Calendar();
 //BA.debugLineNum = 27;BA.debugLine="Dim ScrollView1 As ScrollView";
mostCurrent._scrollview1 = new anywheresoftware.b4a.objects.ScrollViewWrapper();
 //BA.debugLineNum = 28;BA.debugLine="Dim EditText1 As EditText";
mostCurrent._edittext1 = new anywheresoftware.b4a.objects.EditTextWrapper();
 //BA.debugLineNum = 29;BA.debugLine="Dim rbtnReadCalendar As RadioButton";
mostCurrent._rbtnreadcalendar = new anywheresoftware.b4a.objects.CompoundButtonWrapper.RadioButtonWrapper();
 //BA.debugLineNum = 30;BA.debugLine="Dim rbtnWriteCalendar As RadioButton";
mostCurrent._rbtnwritecalendar = new anywheresoftware.b4a.objects.CompoundButtonWrapper.RadioButtonWrapper();
 //BA.debugLineNum = 31;BA.debugLine="Dim rbtnAllDayEvent As RadioButton";
mostCurrent._rbtnalldayevent = new anywheresoftware.b4a.objects.CompoundButtonWrapper.RadioButtonWrapper();
 //BA.debugLineNum = 32;BA.debugLine="Dim rbtnCreateRecur As RadioButton";
mostCurrent._rbtncreaterecur = new anywheresoftware.b4a.objects.CompoundButtonWrapper.RadioButtonWrapper();
 //BA.debugLineNum = 34;BA.debugLine="Dim rbtnDelete As RadioButton";
mostCurrent._rbtndelete = new anywheresoftware.b4a.objects.CompoundButtonWrapper.RadioButtonWrapper();
 //BA.debugLineNum = 35;BA.debugLine="Dim ListView2 As ListView";
mostCurrent._listview2 = new anywheresoftware.b4a.objects.ListViewWrapper();
 //BA.debugLineNum = 36;BA.debugLine="Dim mycalendarlist As List";
mostCurrent._mycalendarlist = new anywheresoftware.b4a.objects.collections.List();
 //BA.debugLineNum = 37;BA.debugLine="Dim rbtnSearch As RadioButton";
mostCurrent._rbtnsearch = new anywheresoftware.b4a.objects.CompoundButtonWrapper.RadioButtonWrapper();
 //BA.debugLineNum = 38;BA.debugLine="End Sub";
return "";
}
public static String  _listview1_itemclick(int _position,Object _value) throws Exception{
String _mystring = "";
String _time1 = "";
String _time2 = "";
int _x = 0;
 //BA.debugLineNum = 129;BA.debugLine="Sub ListView1_ItemClick (Position As Int, Value As";
 //BA.debugLineNum = 130;BA.debugLine="If rbtnReadCalendar.Checked = True Then		'read al";
if (mostCurrent._rbtnreadcalendar.getChecked()==anywheresoftware.b4a.keywords.Common.True) { 
 //BA.debugLineNum = 131;BA.debugLine="ListView2.Clear";
mostCurrent._listview2.Clear();
 //BA.debugLineNum = 132;BA.debugLine="mycalendarlist.Clear";
mostCurrent._mycalendarlist.Clear();
 //BA.debugLineNum = 133;BA.debugLine="Dim MyString As String";
_mystring = "";
 //BA.debugLineNum = 134;BA.debugLine="mycalendarlist = cal.GetListofEventsforCalendarB";
mostCurrent._mycalendarlist = mostCurrent._cal.GetListofEventsforCalendarBetweenDates((int)(BA.ObjectToNumber(_value)),anywheresoftware.b4a.keywords.Common.DateTime.Add(anywheresoftware.b4a.keywords.Common.DateTime.getNow(),(int) (0),(int) (0),(int) (-7)),anywheresoftware.b4a.keywords.Common.DateTime.Add(anywheresoftware.b4a.keywords.Common.DateTime.getNow(),(int) (0),(int) (1),(int) (0)));
 //BA.debugLineNum = 144;BA.debugLine="EditText1.Text = \"\"		'clear the text";
mostCurrent._edittext1.setText(BA.ObjectToCharSequence(""));
 //BA.debugLineNum = 145;BA.debugLine="Dim time1, time2 As String";
_time1 = "";
_time2 = "";
 //BA.debugLineNum = 146;BA.debugLine="For x = 0 To mycalendarlist.Size-1 Step 7";
{
final int step8 = 7;
final int limit8 = (int) (mostCurrent._mycalendarlist.getSize()-1);
_x = (int) (0) ;
for (;_x <= limit8 ;_x = _x + step8 ) {
 //BA.debugLineNum = 147;BA.debugLine="ListView2.AddTwoLines2(mycalendarlist.Get(x + 0";
mostCurrent._listview2.AddTwoLines2(BA.ObjectToCharSequence(mostCurrent._mycalendarlist.Get((int) (_x+0))),BA.ObjectToCharSequence(mostCurrent._mycalendarlist.Get((int) (_x+1))),mostCurrent._mycalendarlist.Get((int) (_x+6)));
 //BA.debugLineNum = 161;BA.debugLine="Log(mycalendarlist.Get(x))";
anywheresoftware.b4a.keywords.Common.LogImpl("4458784",BA.ObjectToString(mostCurrent._mycalendarlist.Get(_x)),0);
 }
};
 }else if(mostCurrent._rbtnwritecalendar.getChecked()==anywheresoftware.b4a.keywords.Common.True) { 
 //BA.debugLineNum = 167;BA.debugLine="cal.CreateEventWithReminder(Value,\"Calendar Exam";
mostCurrent._cal.CreateEventWithReminder((int)(BA.ObjectToNumber(_value)),"Calendar Example Reminder","This is an example of creating an event in the selected calendar using the Calendar_ID","Location Here",(long) (anywheresoftware.b4a.keywords.Common.DateTime.getNow()+900000),(long) (anywheresoftware.b4a.keywords.Common.DateTime.getNow()+1800000),(long) (13),BA.ObjectToString(anywheresoftware.b4a.keywords.Common.Null),anywheresoftware.b4a.keywords.Common.False);
 //BA.debugLineNum = 175;BA.debugLine="rbtnReadCalendar.Checked = True";
mostCurrent._rbtnreadcalendar.setChecked(anywheresoftware.b4a.keywords.Common.True);
 }else if(mostCurrent._rbtnalldayevent.getChecked()==anywheresoftware.b4a.keywords.Common.True) { 
 //BA.debugLineNum = 179;BA.debugLine="cal.CreateEvent(Value,\"Calendar Example All Day\"";
mostCurrent._cal.CreateEvent((int)(BA.ObjectToNumber(_value)),"Calendar Example All Day","This is an all day event in the selected calendar using the Calendar_ID","Location Here",(long) ((anywheresoftware.b4a.keywords.Common.DateTime.DateParse(anywheresoftware.b4a.keywords.Common.DateTime.Date(anywheresoftware.b4a.keywords.Common.DateTime.getNow()))+1)),anywheresoftware.b4a.keywords.Common.DateTime.Add(anywheresoftware.b4a.keywords.Common.DateTime.DateParse(anywheresoftware.b4a.keywords.Common.DateTime.Date(anywheresoftware.b4a.keywords.Common.DateTime.getNow())),(int) (0),(int) (0),(int) (1)),BA.ObjectToString(anywheresoftware.b4a.keywords.Common.Null),anywheresoftware.b4a.keywords.Common.True);
 //BA.debugLineNum = 185;BA.debugLine="rbtnReadCalendar.Checked = True";
mostCurrent._rbtnreadcalendar.setChecked(anywheresoftware.b4a.keywords.Common.True);
 }else if(mostCurrent._rbtncreaterecur.getChecked()==anywheresoftware.b4a.keywords.Common.True) { 
 //BA.debugLineNum = 188;BA.debugLine="cal.CreateEvent(Value,\"Calendar Example Recurrin";
mostCurrent._cal.CreateEvent((int)(BA.ObjectToNumber(_value)),"Calendar Example Recurring","This is a Recurring event specifies 10 events which occur every other day","Location Here",(long) (anywheresoftware.b4a.keywords.Common.DateTime.getNow()+900000),(long) (anywheresoftware.b4a.keywords.Common.DateTime.getNow()+1800000),"FREQ=DAILY;COUNT=6;INTERVAL=2",anywheresoftware.b4a.keywords.Common.False);
 //BA.debugLineNum = 194;BA.debugLine="rbtnReadCalendar.Checked = True";
mostCurrent._rbtnreadcalendar.setChecked(anywheresoftware.b4a.keywords.Common.True);
 }else if(mostCurrent._rbtnsearch.getChecked()==anywheresoftware.b4a.keywords.Common.True) { 
 //BA.debugLineNum = 197;BA.debugLine="ListView2.Clear";
mostCurrent._listview2.Clear();
 //BA.debugLineNum = 198;BA.debugLine="mycalendarlist.Clear";
mostCurrent._mycalendarlist.Clear();
 //BA.debugLineNum = 201;BA.debugLine="mycalendarlist = cal.ListofEventsWithTitleKeywor";
mostCurrent._mycalendarlist = mostCurrent._cal.ListofEventsWithTitleKeywordBetweenDates((int)(BA.ObjectToNumber(_value)),mostCurrent._edittext1.getText(),anywheresoftware.b4a.keywords.Common.DateTime.Add(anywheresoftware.b4a.keywords.Common.DateTime.getNow(),(int) (0),(int) (0),(int) (-7)),anywheresoftware.b4a.keywords.Common.DateTime.Add(anywheresoftware.b4a.keywords.Common.DateTime.getNow(),(int) (0),(int) (1),(int) (0)));
 //BA.debugLineNum = 211;BA.debugLine="EditText1.Text = \"\"		'clear the text";
mostCurrent._edittext1.setText(BA.ObjectToCharSequence(""));
 //BA.debugLineNum = 212;BA.debugLine="Dim time1, time2 As String";
_time1 = "";
_time2 = "";
 //BA.debugLineNum = 213;BA.debugLine="For x = 0 To mycalendarlist.Size-1 Step 7";
{
final int step27 = 7;
final int limit27 = (int) (mostCurrent._mycalendarlist.getSize()-1);
_x = (int) (0) ;
for (;_x <= limit27 ;_x = _x + step27 ) {
 //BA.debugLineNum = 214;BA.debugLine="ListView2.AddTwoLines2(mycalendarlist.Get(x + 0";
mostCurrent._listview2.AddTwoLines2(BA.ObjectToCharSequence(mostCurrent._mycalendarlist.Get((int) (_x+0))),BA.ObjectToCharSequence(mostCurrent._mycalendarlist.Get((int) (_x+1))),mostCurrent._mycalendarlist.Get((int) (_x+6)));
 }
};
 //BA.debugLineNum = 216;BA.debugLine="rbtnReadCalendar.Checked = True";
mostCurrent._rbtnreadcalendar.setChecked(anywheresoftware.b4a.keywords.Common.True);
 };
 //BA.debugLineNum = 219;BA.debugLine="End Sub";
return "";
}
public static String  _listview2_itemclick(int _position,Object _value) throws Exception{
 //BA.debugLineNum = 221;BA.debugLine="Sub ListView2_ItemClick (Position As Int, Value As";
 //BA.debugLineNum = 223;BA.debugLine="End Sub";
return "";
}
public static String  _listview2_itemlongclick(int _position,Object _value) throws Exception{
 //BA.debugLineNum = 225;BA.debugLine="Sub ListView2_ItemLongClick (Position As Int, Valu";
 //BA.debugLineNum = 227;BA.debugLine="If Msgbox2(\"DELETE?\" & CRLF & QUOTE & mycalendarl";
if (anywheresoftware.b4a.keywords.Common.Msgbox2(BA.ObjectToCharSequence("DELETE?"+anywheresoftware.b4a.keywords.Common.CRLF+anywheresoftware.b4a.keywords.Common.QUOTE+BA.ObjectToString(mostCurrent._mycalendarlist.Get((int) (_position*7)))+anywheresoftware.b4a.keywords.Common.QUOTE),BA.ObjectToCharSequence("Confirm Delete"),"Yes","","No",(android.graphics.Bitmap)(anywheresoftware.b4a.keywords.Common.Null),mostCurrent.activityBA)==anywheresoftware.b4a.keywords.Common.DialogResponse.POSITIVE) { 
 //BA.debugLineNum = 228;BA.debugLine="cal.DeleteCalendarEntry(Value)";
mostCurrent._cal.DeleteCalendarEntry((int)(BA.ObjectToNumber(_value)));
 };
 //BA.debugLineNum = 230;BA.debugLine="End Sub";
return "";
}

public static void initializeProcessGlobals() {
    
    if (main.processGlobalsRun == false) {
	    main.processGlobalsRun = true;
		try {
		        main._process_globals();
		
        } catch (Exception e) {
			throw new RuntimeException(e);
		}
    }
}public static String  _process_globals() throws Exception{
 //BA.debugLineNum = 12;BA.debugLine="Sub Process_Globals";
 //BA.debugLineNum = 15;BA.debugLine="Dim manager As AHPreferenceManager";
_manager = new de.amberhome.objects.preferenceactivity.PreferenceManager();
 //BA.debugLineNum = 16;BA.debugLine="Dim screen As AHPreferenceScreen";
_screen = new de.amberhome.objects.preferenceactivity.PreferenceScreenWrapper();
 //BA.debugLineNum = 17;BA.debugLine="Dim CalendarNumber As Int";
_calendarnumber = 0;
 //BA.debugLineNum = 18;BA.debugLine="End Sub";
return "";
}
public static String  _rbtnsearch_checkedchange(boolean _checked) throws Exception{
 //BA.debugLineNum = 232;BA.debugLine="Sub rbtnSearch_CheckedChange(Checked As Boolean)";
 //BA.debugLineNum = 234;BA.debugLine="End Sub";
return "";
}
public static String  _settings_click() throws Exception{
 //BA.debugLineNum = 125;BA.debugLine="Sub Settings_Click";
 //BA.debugLineNum = 126;BA.debugLine="StartActivity(screen.CreateIntent)			'start the s";
anywheresoftware.b4a.keywords.Common.StartActivity(processBA,(Object)(_screen.CreateIntent()));
 //BA.debugLineNum = 127;BA.debugLine="End Sub";
return "";
}
}
