package shub.dpm;


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 listpat extends Activity implements B4AActivity{
	public static listpat 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, "shub.dpm", "shub.dpm.listpat");
			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 (listpat).");
				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, false))
		    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, "shub.dpm", "shub.dpm.listpat");
        
        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, "shub.dpm.listpat", processBA, activityBA, _activity, anywheresoftware.b4a.keywords.Common.Density, mostCurrent);
			_activity.reinitializeForShell(activityBA, "activity");
		}
        initializeProcessGlobals();		
        initializeGlobals();
        
        BA.LogInfo("** Activity (listpat) Create, isFirst = " + isFirst + " **");
        processBA.raiseEvent2(null, true, "activity_create", false, isFirst);
		isFirst = false;
		if (this != mostCurrent)
			return;
        processBA.setActivityPaused(false);
        BA.LogInfo("** Activity (listpat) 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 listpat.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 (listpat) Pause, UserClosed = " + activityBA.activity.isFinishing() + " **");
        else
            BA.LogInfo("** Activity (listpat) 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() {
            listpat mc = mostCurrent;
			if (mc == null || mc != activity.get())
				return;
			processBA.setActivityPaused(false);
            BA.LogInfo("** Activity (listpat) 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 String _jobname = "";
public anywheresoftware.b4a.objects.ScrollViewWrapper _sv = null;
public anywheresoftware.b4a.objects.ButtonWrapper _btnclose = null;
public anywheresoftware.b4a.objects.PanelWrapper _header = null;
public anywheresoftware.b4a.objects.PanelWrapper _table = null;
public static int _numberofcolumns = 0;
public static int _rowheight = 0;
public static int _columnwidth = 0;
public static int _headercolor = 0;
public static int _tablecolor = 0;
public static int _fontcolor = 0;
public static int _headerfontcolor = 0;
public static float _fontsize = 0f;
public static int _alignment = 0;
public static int _selectedrow = 0;
public static int _selectedrowcolor = 0;
public anywheresoftware.b4a.objects.collections.List _list1 = null;
public shub.dpm.main _main = null;
public shub.dpm.parameter _parameter = null;
public shub.dpm.about _about = null;
public shub.dpm.barcodescanner _barcodescanner = null;
public shub.dpm.allgfnkt _allgfnkt = null;
public shub.dpm.listdata _listdata = null;
public shub.dpm.starter _starter = null;
public shub.dpm.b4xpages _b4xpages = null;
public shub.dpm.b4xcollections _b4xcollections = null;
public shub.dpm.httputils2service _httputils2service = null;

public static void initializeProcessGlobals() {
             try {
                Class.forName(BA.applicationContext.getPackageName() + ".main").getMethod("initializeProcessGlobals").invoke(null, null);
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
}
public static String  _activity_create(boolean _firsttime) throws Exception{
 //BA.debugLineNum = 36;BA.debugLine="Sub Activity_Create(FirstTime As Boolean)";
 //BA.debugLineNum = 37;BA.debugLine="init_view";
_init_view();
 //BA.debugLineNum = 38;BA.debugLine="End Sub";
return "";
}
public static String  _activity_pause(boolean _userclosed) throws Exception{
 //BA.debugLineNum = 248;BA.debugLine="Sub Activity_Pause (UserClosed As Boolean)";
 //BA.debugLineNum = 250;BA.debugLine="End Sub";
return "";
}
public static String  _activity_resume() throws Exception{
 //BA.debugLineNum = 244;BA.debugLine="Sub Activity_Resume";
 //BA.debugLineNum = 246;BA.debugLine="End Sub";
return "";
}
public static String  _addrow(String[] _values) throws Exception{
int _lastrow = 0;
int _i = 0;
anywheresoftware.b4a.objects.LabelWrapper _l = null;
shub.dpm.listdata._rowcol _rc = null;
int _leftpos = 0;
int _colwi = 0;
 //BA.debugLineNum = 162;BA.debugLine="Sub AddRow(Values() As String)";
 //BA.debugLineNum = 163;BA.debugLine="If Values.Length <> NumberOfColumns Then";
if (_values.length!=_numberofcolumns) { 
 //BA.debugLineNum = 164;BA.debugLine="Log(\"Wrong number of values.\")";
anywheresoftware.b4a.keywords.Common.LogImpl("717170434","Wrong number of values.",0);
 //BA.debugLineNum = 165;BA.debugLine="Return";
if (true) return "";
 };
 //BA.debugLineNum = 167;BA.debugLine="Dim lastRow As Int";
_lastrow = 0;
 //BA.debugLineNum = 168;BA.debugLine="lastRow = NumberOfRows";
_lastrow = _numberofrows();
 //BA.debugLineNum = 169;BA.debugLine="For i = 0 To NumberOfColumns - 1";
{
final int step7 = 1;
final int limit7 = (int) (_numberofcolumns-1);
_i = (int) (0) ;
for (;_i <= limit7 ;_i = _i + step7 ) {
 //BA.debugLineNum = 170;BA.debugLine="Dim l As Label";
_l = new anywheresoftware.b4a.objects.LabelWrapper();
 //BA.debugLineNum = 171;BA.debugLine="l.Initialize(\"cell\")";
_l.Initialize(mostCurrent.activityBA,"cell");
 //BA.debugLineNum = 172;BA.debugLine="l.Text = Values(i)";
_l.setText(BA.ObjectToCharSequence(_values[_i]));
 //BA.debugLineNum = 173;BA.debugLine="l.Gravity = Alignment";
_l.setGravity(_alignment);
 //BA.debugLineNum = 174;BA.debugLine="If i=1 Then l.Gravity=Bit.Or(Gravity.FILL, Gravi";
if (_i==1) { 
_l.setGravity(anywheresoftware.b4a.keywords.Common.Bit.Or(anywheresoftware.b4a.keywords.Common.Gravity.FILL,anywheresoftware.b4a.keywords.Common.Gravity.CENTER_HORIZONTAL));};
 //BA.debugLineNum = 175;BA.debugLine="l.TextSize = FontSize";
_l.setTextSize(_fontsize);
 //BA.debugLineNum = 176;BA.debugLine="l.TextColor = FontColor";
_l.setTextColor(_fontcolor);
 //BA.debugLineNum = 177;BA.debugLine="Dim rc As RowCol";
_rc = new shub.dpm.listdata._rowcol();
 //BA.debugLineNum = 178;BA.debugLine="rc.Initialize";
_rc.Initialize();
 //BA.debugLineNum = 179;BA.debugLine="rc.Col = i";
_rc.Col /*int*/  = _i;
 //BA.debugLineNum = 180;BA.debugLine="rc.Row = lastRow";
_rc.Row /*int*/  = _lastrow;
 //BA.debugLineNum = 181;BA.debugLine="l.Tag = rc";
_l.setTag((Object)(_rc));
 //BA.debugLineNum = 182;BA.debugLine="Dim leftpos As Int";
_leftpos = 0;
 //BA.debugLineNum = 183;BA.debugLine="Dim colwi As Int";
_colwi = 0;
 //BA.debugLineNum = 184;BA.debugLine="If i=0 Then";
if (_i==0) { 
 //BA.debugLineNum = 185;BA.debugLine="leftpos=0";
_leftpos = (int) (0);
 //BA.debugLineNum = 186;BA.debugLine="colwi=20%x";
_colwi = anywheresoftware.b4a.keywords.Common.PerXToCurrent((float) (20),mostCurrent.activityBA);
 };
 //BA.debugLineNum = 188;BA.debugLine="If i=1 Then";
if (_i==1) { 
 //BA.debugLineNum = 189;BA.debugLine="leftpos=20%x";
_leftpos = anywheresoftware.b4a.keywords.Common.PerXToCurrent((float) (20),mostCurrent.activityBA);
 //BA.debugLineNum = 190;BA.debugLine="colwi=80%x";
_colwi = anywheresoftware.b4a.keywords.Common.PerXToCurrent((float) (80),mostCurrent.activityBA);
 };
 //BA.debugLineNum = 192;BA.debugLine="Table.AddView(l, leftpos, RowHeight * lastRow, c";
mostCurrent._table.AddView((android.view.View)(_l.getObject()),_leftpos,(int) (_rowheight*_lastrow),_colwi,_rowheight);
 }
};
 //BA.debugLineNum = 196;BA.debugLine="Table.Height = NumberOfRows * RowHeight";
mostCurrent._table.setHeight((int) (_numberofrows()*_rowheight));
 //BA.debugLineNum = 197;BA.debugLine="End Sub";
return "";
}
public static String  _bclose_click() throws Exception{
 //BA.debugLineNum = 253;BA.debugLine="Private Sub bClose_Click";
 //BA.debugLineNum = 254;BA.debugLine="Activity.Finish";
mostCurrent._activity.Finish();
 //BA.debugLineNum = 256;BA.debugLine="End Sub";
return "";
}
public static String  _cell_click() throws Exception{
shub.dpm.listdata._rowcol _rc = null;
anywheresoftware.b4a.objects.LabelWrapper _l = null;
int _i = 0;
anywheresoftware.b4a.objects.collections.Map _map1 = null;
 //BA.debugLineNum = 123;BA.debugLine="Sub Cell_Click";
 //BA.debugLineNum = 124;BA.debugLine="Dim rc As RowCol";
_rc = new shub.dpm.listdata._rowcol();
 //BA.debugLineNum = 125;BA.debugLine="Dim l As Label";
_l = new anywheresoftware.b4a.objects.LabelWrapper();
 //BA.debugLineNum = 126;BA.debugLine="l = Sender";
_l = (anywheresoftware.b4a.objects.LabelWrapper) anywheresoftware.b4a.AbsObjectWrapper.ConvertToWrapper(new anywheresoftware.b4a.objects.LabelWrapper(), (android.widget.TextView)(anywheresoftware.b4a.keywords.Common.Sender(mostCurrent.activityBA)));
 //BA.debugLineNum = 127;BA.debugLine="rc = l.Tag";
_rc = (shub.dpm.listdata._rowcol)(_l.getTag());
 //BA.debugLineNum = 128;BA.debugLine="SelectRow(rc.Row)";
_selectrow(_rc.Row /*int*/ );
 //BA.debugLineNum = 130;BA.debugLine="For i=0 To list1.Size-1";
{
final int step6 = 1;
final int limit6 = (int) (mostCurrent._list1.getSize()-1);
_i = (int) (0) ;
for (;_i <= limit6 ;_i = _i + step6 ) {
 //BA.debugLineNum = 131;BA.debugLine="If i=rc.Row Then";
if (_i==_rc.Row /*int*/ ) { 
 //BA.debugLineNum = 132;BA.debugLine="Dim map1 As Map";
_map1 = new anywheresoftware.b4a.objects.collections.Map();
 //BA.debugLineNum = 133;BA.debugLine="map1=list1.Get(i)";
_map1 = (anywheresoftware.b4a.objects.collections.Map) anywheresoftware.b4a.AbsObjectWrapper.ConvertToWrapper(new anywheresoftware.b4a.objects.collections.Map(), (anywheresoftware.b4a.objects.collections.Map.MyMap)(mostCurrent._list1.Get(_i)));
 };
 }
};
 //BA.debugLineNum = 137;BA.debugLine="End Sub";
return "";
}
public static String  _cell_longclick() throws Exception{
shub.dpm.listdata._rowcol _rc = null;
anywheresoftware.b4a.objects.LabelWrapper _l = null;
String _x = "";
int _i = 0;
anywheresoftware.b4a.objects.collections.Map _map1 = null;
 //BA.debugLineNum = 101;BA.debugLine="Sub Cell_LongClick";
 //BA.debugLineNum = 102;BA.debugLine="Dim rc As RowCol";
_rc = new shub.dpm.listdata._rowcol();
 //BA.debugLineNum = 103;BA.debugLine="Dim l As Label";
_l = new anywheresoftware.b4a.objects.LabelWrapper();
 //BA.debugLineNum = 104;BA.debugLine="Dim x As String";
_x = "";
 //BA.debugLineNum = 105;BA.debugLine="x=\"\"";
_x = "";
 //BA.debugLineNum = 106;BA.debugLine="l = Sender";
_l = (anywheresoftware.b4a.objects.LabelWrapper) anywheresoftware.b4a.AbsObjectWrapper.ConvertToWrapper(new anywheresoftware.b4a.objects.LabelWrapper(), (android.widget.TextView)(anywheresoftware.b4a.keywords.Common.Sender(mostCurrent.activityBA)));
 //BA.debugLineNum = 107;BA.debugLine="rc = l.Tag";
_rc = (shub.dpm.listdata._rowcol)(_l.getTag());
 //BA.debugLineNum = 108;BA.debugLine="SelectRow(rc.Row)";
_selectrow(_rc.Row /*int*/ );
 //BA.debugLineNum = 110;BA.debugLine="For i=0 To list1.Size-1";
{
final int step8 = 1;
final int limit8 = (int) (mostCurrent._list1.getSize()-1);
_i = (int) (0) ;
for (;_i <= limit8 ;_i = _i + step8 ) {
 //BA.debugLineNum = 111;BA.debugLine="If i=rc.Row Then";
if (_i==_rc.Row /*int*/ ) { 
 //BA.debugLineNum = 112;BA.debugLine="Dim map1 As Map";
_map1 = new anywheresoftware.b4a.objects.collections.Map();
 //BA.debugLineNum = 113;BA.debugLine="map1=list1.Get(i)";
_map1 = (anywheresoftware.b4a.objects.collections.Map) anywheresoftware.b4a.AbsObjectWrapper.ConvertToWrapper(new anywheresoftware.b4a.objects.collections.Map(), (anywheresoftware.b4a.objects.collections.Map.MyMap)(mostCurrent._list1.Get(_i)));
 //BA.debugLineNum = 114;BA.debugLine="x=map1.Get(\"id\")";
_x = BA.ObjectToString(_map1.Get((Object)("id")));
 };
 }
};
 //BA.debugLineNum = 119;BA.debugLine="AllgFnkt.PID=x";
mostCurrent._allgfnkt._pid /*String*/  = _x;
 //BA.debugLineNum = 120;BA.debugLine="Activity.Finish";
mostCurrent._activity.Finish();
 //BA.debugLineNum = 121;BA.debugLine="End Sub";
return "";
}
public static String  _clearall() throws Exception{
int _i = 0;
 //BA.debugLineNum = 237;BA.debugLine="Sub ClearAll";
 //BA.debugLineNum = 238;BA.debugLine="For i = Table.NumberOfViews -1 To 0 Step -1";
{
final int step1 = -1;
final int limit1 = (int) (0);
_i = (int) (mostCurrent._table.getNumberOfViews()-1) ;
for (;_i >= limit1 ;_i = _i + step1 ) {
 //BA.debugLineNum = 239;BA.debugLine="Table.RemoveViewAt(i)";
mostCurrent._table.RemoveViewAt(_i);
 }
};
 //BA.debugLineNum = 241;BA.debugLine="Table.Height = 0";
mostCurrent._table.setHeight((int) (0));
 //BA.debugLineNum = 242;BA.debugLine="SelectedRow = -1";
_selectedrow = (int) (-1);
 //BA.debugLineNum = 243;BA.debugLine="End Sub";
return "";
}
public static String  _get_data() throws Exception{
shub.dpm.httpjob _job = null;
 //BA.debugLineNum = 58;BA.debugLine="Sub Get_Data";
 //BA.debugLineNum = 59;BA.debugLine="Dim job As HttpJob";
_job = new shub.dpm.httpjob();
 //BA.debugLineNum = 60;BA.debugLine="jobname=\"GetData\"";
mostCurrent._jobname = "GetData";
 //BA.debugLineNum = 61;BA.debugLine="job.Initialize(jobname, Me)";
_job._initialize /*String*/ (processBA,mostCurrent._jobname,listpat.getObject());
 //BA.debugLineNum = 63;BA.debugLine="job.Download(AllgFnkt.sURL&\"/DPMService/api/Servi";
_job._download /*String*/ (mostCurrent._allgfnkt._surl /*String*/ +"/DPMService/api/Service_View_Pat/search/"+mostCurrent._allgfnkt._searchstring /*String*/ );
 //BA.debugLineNum = 64;BA.debugLine="End Sub";
return "";
}
public static String  _getcell(int _row,int _col) throws Exception{
 //BA.debugLineNum = 234;BA.debugLine="Sub GetCell(Row As Int, Col As Int) As String";
 //BA.debugLineNum = 235;BA.debugLine="Return GetView(Row, Col).Text";
if (true) return _getview(_row,_col).getText();
 //BA.debugLineNum = 236;BA.debugLine="End Sub";
return "";
}
public static anywheresoftware.b4a.objects.LabelWrapper  _getview(int _row,int _col) throws Exception{
anywheresoftware.b4a.objects.LabelWrapper _l = null;
 //BA.debugLineNum = 157;BA.debugLine="Sub GetView(Row As Int, Col As Int) As Label";
 //BA.debugLineNum = 158;BA.debugLine="Dim l As Label";
_l = new anywheresoftware.b4a.objects.LabelWrapper();
 //BA.debugLineNum = 159;BA.debugLine="l = Table.GetView(Row * NumberOfColumns + Col)";
_l = (anywheresoftware.b4a.objects.LabelWrapper) anywheresoftware.b4a.AbsObjectWrapper.ConvertToWrapper(new anywheresoftware.b4a.objects.LabelWrapper(), (android.widget.TextView)(mostCurrent._table.GetView((int) (_row*_numberofcolumns+_col)).getObject()));
 //BA.debugLineNum = 160;BA.debugLine="Return l";
if (true) return _l;
 //BA.debugLineNum = 161;BA.debugLine="End Sub";
return null;
}
public static String  _globals() throws Exception{
 //BA.debugLineNum = 10;BA.debugLine="Sub Globals";
 //BA.debugLineNum = 11;BA.debugLine="Dim jobname As String";
mostCurrent._jobname = "";
 //BA.debugLineNum = 12;BA.debugLine="Dim SV As ScrollView";
mostCurrent._sv = new anywheresoftware.b4a.objects.ScrollViewWrapper();
 //BA.debugLineNum = 13;BA.debugLine="Dim BtnClose As Button";
mostCurrent._btnclose = new anywheresoftware.b4a.objects.ButtonWrapper();
 //BA.debugLineNum = 14;BA.debugLine="Dim Header As Panel";
mostCurrent._header = new anywheresoftware.b4a.objects.PanelWrapper();
 //BA.debugLineNum = 15;BA.debugLine="Dim Table As Panel";
mostCurrent._table = new anywheresoftware.b4a.objects.PanelWrapper();
 //BA.debugLineNum = 16;BA.debugLine="Dim NumberOfColumns, RowHeight, ColumnWidth As In";
_numberofcolumns = 0;
_rowheight = 0;
_columnwidth = 0;
 //BA.debugLineNum = 17;BA.debugLine="Dim HeaderColor, TableColor, FontColor, HeaderFon";
_headercolor = 0;
_tablecolor = 0;
_fontcolor = 0;
_headerfontcolor = 0;
 //BA.debugLineNum = 18;BA.debugLine="Dim FontSize As Float";
_fontsize = 0f;
 //BA.debugLineNum = 19;BA.debugLine="Dim Alignment As Int";
_alignment = 0;
 //BA.debugLineNum = 20;BA.debugLine="Dim SelectedRow As Int";
_selectedrow = 0;
 //BA.debugLineNum = 21;BA.debugLine="Dim SelectedRowColor As Int";
_selectedrowcolor = 0;
 //BA.debugLineNum = 24;BA.debugLine="HeaderColor = Colors.Gray";
_headercolor = anywheresoftware.b4a.keywords.Common.Colors.Gray;
 //BA.debugLineNum = 25;BA.debugLine="NumberOfColumns = 2";
_numberofcolumns = (int) (2);
 //BA.debugLineNum = 26;BA.debugLine="RowHeight = 30dip";
_rowheight = anywheresoftware.b4a.keywords.Common.DipToCurrent((int) (30));
 //BA.debugLineNum = 27;BA.debugLine="TableColor = Colors.White";
_tablecolor = anywheresoftware.b4a.keywords.Common.Colors.White;
 //BA.debugLineNum = 28;BA.debugLine="FontColor = Colors.Black";
_fontcolor = anywheresoftware.b4a.keywords.Common.Colors.Black;
 //BA.debugLineNum = 29;BA.debugLine="HeaderFontColor = Colors.White";
_headerfontcolor = anywheresoftware.b4a.keywords.Common.Colors.White;
 //BA.debugLineNum = 30;BA.debugLine="FontSize = 11";
_fontsize = (float) (11);
 //BA.debugLineNum = 31;BA.debugLine="Alignment = Gravity.CENTER 'change to Gravity.LEF";
_alignment = anywheresoftware.b4a.keywords.Common.Gravity.CENTER;
 //BA.debugLineNum = 32;BA.debugLine="SelectedRowColor = Colors.Blue";
_selectedrowcolor = anywheresoftware.b4a.keywords.Common.Colors.Blue;
 //BA.debugLineNum = 33;BA.debugLine="Dim list1 As List";
mostCurrent._list1 = new anywheresoftware.b4a.objects.collections.List();
 //BA.debugLineNum = 34;BA.debugLine="End Sub";
return "";
}
public static String  _header_click() throws Exception{
anywheresoftware.b4a.objects.LabelWrapper _l = null;
int _col = 0;
 //BA.debugLineNum = 138;BA.debugLine="Sub Header_Click";
 //BA.debugLineNum = 139;BA.debugLine="Dim l As Label";
_l = new anywheresoftware.b4a.objects.LabelWrapper();
 //BA.debugLineNum = 140;BA.debugLine="Dim col As Int";
_col = 0;
 //BA.debugLineNum = 141;BA.debugLine="l = Sender";
_l = (anywheresoftware.b4a.objects.LabelWrapper) anywheresoftware.b4a.AbsObjectWrapper.ConvertToWrapper(new anywheresoftware.b4a.objects.LabelWrapper(), (android.widget.TextView)(anywheresoftware.b4a.keywords.Common.Sender(mostCurrent.activityBA)));
 //BA.debugLineNum = 142;BA.debugLine="col = l.Tag";
_col = (int)(BA.ObjectToNumber(_l.getTag()));
 //BA.debugLineNum = 144;BA.debugLine="End Sub";
return "";
}
public static String  _init_view() throws Exception{
 //BA.debugLineNum = 40;BA.debugLine="Sub init_view";
 //BA.debugLineNum = 42;BA.debugLine="SV.Initialize(0)";
mostCurrent._sv.Initialize(mostCurrent.activityBA,(int) (0));
 //BA.debugLineNum = 43;BA.debugLine="Activity.LoadLayout(\"LData\")";
mostCurrent._activity.LoadLayout("LData",mostCurrent.activityBA);
 //BA.debugLineNum = 45;BA.debugLine="Table = SV.Panel";
mostCurrent._table = mostCurrent._sv.getPanel();
 //BA.debugLineNum = 46;BA.debugLine="Table.Color = TableColor";
mostCurrent._table.setColor(_tablecolor);
 //BA.debugLineNum = 47;BA.debugLine="Activity.AddView(SV, 5%x, 10%y, 90%x, 80%y)";
mostCurrent._activity.AddView((android.view.View)(mostCurrent._sv.getObject()),anywheresoftware.b4a.keywords.Common.PerXToCurrent((float) (5),mostCurrent.activityBA),anywheresoftware.b4a.keywords.Common.PerYToCurrent((float) (10),mostCurrent.activityBA),anywheresoftware.b4a.keywords.Common.PerXToCurrent((float) (90),mostCurrent.activityBA),anywheresoftware.b4a.keywords.Common.PerYToCurrent((float) (80),mostCurrent.activityBA));
 //BA.debugLineNum = 48;BA.debugLine="Activity.Title=\"Chargen\"";
mostCurrent._activity.setTitle(BA.ObjectToCharSequence("Chargen"));
 //BA.debugLineNum = 49;BA.debugLine="ColumnWidth = SV.Width / NumberOfColumns";
_columnwidth = (int) (mostCurrent._sv.getWidth()/(double)_numberofcolumns);
 //BA.debugLineNum = 50;BA.debugLine="SelectedRow = -1";
_selectedrow = (int) (-1);
 //BA.debugLineNum = 52;BA.debugLine="SetHeader(Array As String(\"ID\", \"Patient\"))";
_setheader(new String[]{"ID","Patient"});
 //BA.debugLineNum = 54;BA.debugLine="Get_Data";
_get_data();
 //BA.debugLineNum = 55;BA.debugLine="Activity.Title=\"Daten \" & AllgFnkt.PatName";
mostCurrent._activity.setTitle(BA.ObjectToCharSequence("Daten "+mostCurrent._allgfnkt._patname /*String*/ ));
 //BA.debugLineNum = 56;BA.debugLine="End Sub";
return "";
}
public static String  _jobdone(shub.dpm.httpjob _job) throws Exception{
String _res = "";
anywheresoftware.b4a.objects.collections.JSONParser _parser = null;
int _i = 0;
anywheresoftware.b4a.objects.collections.Map _map1 = null;
String _s1 = "";
String _s2 = "";
 //BA.debugLineNum = 66;BA.debugLine="Sub JobDone(Job As HttpJob)";
 //BA.debugLineNum = 67;BA.debugLine="ProgressDialogHide";
anywheresoftware.b4a.keywords.Common.ProgressDialogHide();
 //BA.debugLineNum = 68;BA.debugLine="If Job.Success Then";
if (_job._success /*boolean*/ ) { 
 //BA.debugLineNum = 69;BA.debugLine="Dim res As String";
_res = "";
 //BA.debugLineNum = 70;BA.debugLine="res = Job.GetString";
_res = _job._getstring /*String*/ ();
 //BA.debugLineNum = 71;BA.debugLine="Dim parser As JSONParser";
_parser = new anywheresoftware.b4a.objects.collections.JSONParser();
 //BA.debugLineNum = 72;BA.debugLine="parser.Initialize(res)";
_parser.Initialize(_res);
 //BA.debugLineNum = 74;BA.debugLine="Log(\"Response from server: \" & res)";
anywheresoftware.b4a.keywords.Common.LogImpl("716777224","Response from server: "+_res,0);
 //BA.debugLineNum = 76;BA.debugLine="Select Job.JobName";
switch (BA.switchObjectToInt(_job._jobname /*String*/ ,"GetData")) {
case 0: {
 //BA.debugLineNum = 80;BA.debugLine="list1 = parser.NextArray";
mostCurrent._list1 = _parser.NextArray();
 //BA.debugLineNum = 81;BA.debugLine="Dim i As Int";
_i = 0;
 //BA.debugLineNum = 82;BA.debugLine="For i=0 To list1.Size-1";
{
final int step12 = 1;
final int limit12 = (int) (mostCurrent._list1.getSize()-1);
_i = (int) (0) ;
for (;_i <= limit12 ;_i = _i + step12 ) {
 //BA.debugLineNum = 83;BA.debugLine="Dim map1 As Map";
_map1 = new anywheresoftware.b4a.objects.collections.Map();
 //BA.debugLineNum = 84;BA.debugLine="map1=list1.Get(i)";
_map1 = (anywheresoftware.b4a.objects.collections.Map) anywheresoftware.b4a.AbsObjectWrapper.ConvertToWrapper(new anywheresoftware.b4a.objects.collections.Map(), (anywheresoftware.b4a.objects.collections.Map.MyMap)(mostCurrent._list1.Get(_i)));
 //BA.debugLineNum = 85;BA.debugLine="Dim s1 As String";
_s1 = "";
 //BA.debugLineNum = 86;BA.debugLine="Dim s2 As String";
_s2 = "";
 //BA.debugLineNum = 87;BA.debugLine="s1=map1.Get(\"id\")";
_s1 = BA.ObjectToString(_map1.Get((Object)("id")));
 //BA.debugLineNum = 88;BA.debugLine="s2=map1.Get(\"pat\")";
_s2 = BA.ObjectToString(_map1.Get((Object)("pat")));
 //BA.debugLineNum = 89;BA.debugLine="AddRow(Array As String(s1,s2))";
_addrow(new String[]{_s1,_s2});
 }
};
 //BA.debugLineNum = 91;BA.debugLine="If list1.Size<1 Then";
if (mostCurrent._list1.getSize()<1) { 
 //BA.debugLineNum = 92;BA.debugLine="ToastMessageShow(\"Keine Daten vorhanden.\",Tru";
anywheresoftware.b4a.keywords.Common.ToastMessageShow(BA.ObjectToCharSequence("Keine Daten vorhanden."),anywheresoftware.b4a.keywords.Common.True);
 //BA.debugLineNum = 93;BA.debugLine="Return";
if (true) return "";
 };
 break; }
}
;
 };
 //BA.debugLineNum = 97;BA.debugLine="End Sub";
return "";
}
public static int  _numberofrows() throws Exception{
 //BA.debugLineNum = 227;BA.debugLine="Sub NumberOfRows As Int";
 //BA.debugLineNum = 228;BA.debugLine="Return Table.NumberOfViews / NumberOfColumns";
if (true) return (int) (mostCurrent._table.getNumberOfViews()/(double)_numberofcolumns);
 //BA.debugLineNum = 229;BA.debugLine="End Sub";
return 0;
}
public static String  _process_globals() throws Exception{
 //BA.debugLineNum = 6;BA.debugLine="Sub Process_Globals";
 //BA.debugLineNum = 8;BA.debugLine="End Sub";
return "";
}
public static String  _selectrow(int _row) throws Exception{
int _col = 0;
 //BA.debugLineNum = 145;BA.debugLine="Sub SelectRow(Row As Int)";
 //BA.debugLineNum = 147;BA.debugLine="If SelectedRow > -1 Then";
if (_selectedrow>-1) { 
 //BA.debugLineNum = 148;BA.debugLine="For col = 0 To NumberOfColumns - 1";
{
final int step2 = 1;
final int limit2 = (int) (_numberofcolumns-1);
_col = (int) (0) ;
for (;_col <= limit2 ;_col = _col + step2 ) {
 //BA.debugLineNum = 149;BA.debugLine="GetView(SelectedRow, col).Color = Colors.Transp";
_getview(_selectedrow,_col).setColor(anywheresoftware.b4a.keywords.Common.Colors.Transparent);
 }
};
 };
 //BA.debugLineNum = 152;BA.debugLine="SelectedRow = Row";
_selectedrow = _row;
 //BA.debugLineNum = 153;BA.debugLine="For col = 0 To NumberOfColumns - 1";
{
final int step7 = 1;
final int limit7 = (int) (_numberofcolumns-1);
_col = (int) (0) ;
for (;_col <= limit7 ;_col = _col + step7 ) {
 //BA.debugLineNum = 154;BA.debugLine="GetView(Row, col).Color = SelectedRowColor";
_getview(_row,_col).setColor(_selectedrowcolor);
 }
};
 //BA.debugLineNum = 156;BA.debugLine="End Sub";
return "";
}
public static String  _setcell(int _row,int _col,String _value) throws Exception{
 //BA.debugLineNum = 231;BA.debugLine="Sub SetCell(Row As Int, Col As Int, Value As Strin";
 //BA.debugLineNum = 232;BA.debugLine="GetView(Row, Col).Text = Value";
_getview(_row,_col).setText(BA.ObjectToCharSequence(_value));
 //BA.debugLineNum = 233;BA.debugLine="End Sub";
return "";
}
public static String  _setheader(String[] _values) throws Exception{
int _i = 0;
anywheresoftware.b4a.objects.LabelWrapper _l = null;
int _leftpos = 0;
int _colwi = 0;
 //BA.debugLineNum = 199;BA.debugLine="Sub SetHeader(Values() As String)";
 //BA.debugLineNum = 200;BA.debugLine="If Header.IsInitialized Then Return 'should only";
if (mostCurrent._header.IsInitialized()) { 
if (true) return "";};
 //BA.debugLineNum = 201;BA.debugLine="Header.Initialize(\"\")";
mostCurrent._header.Initialize(mostCurrent.activityBA,"");
 //BA.debugLineNum = 202;BA.debugLine="For i = 0 To NumberOfColumns - 1";
{
final int step3 = 1;
final int limit3 = (int) (_numberofcolumns-1);
_i = (int) (0) ;
for (;_i <= limit3 ;_i = _i + step3 ) {
 //BA.debugLineNum = 203;BA.debugLine="Dim l As Label";
_l = new anywheresoftware.b4a.objects.LabelWrapper();
 //BA.debugLineNum = 204;BA.debugLine="l.Initialize(\"header\")";
_l.Initialize(mostCurrent.activityBA,"header");
 //BA.debugLineNum = 205;BA.debugLine="l.Text = Values(i)";
_l.setText(BA.ObjectToCharSequence(_values[_i]));
 //BA.debugLineNum = 206;BA.debugLine="l.Gravity = Gravity.CENTER";
_l.setGravity(anywheresoftware.b4a.keywords.Common.Gravity.CENTER);
 //BA.debugLineNum = 207;BA.debugLine="If i=1 Then l.Gravity=Bit.Or(Gravity.FILL, Gravi";
if (_i==1) { 
_l.setGravity(anywheresoftware.b4a.keywords.Common.Bit.Or(anywheresoftware.b4a.keywords.Common.Gravity.FILL,anywheresoftware.b4a.keywords.Common.Gravity.CENTER_HORIZONTAL));};
 //BA.debugLineNum = 208;BA.debugLine="l.TextSize = FontSize";
_l.setTextSize(_fontsize);
 //BA.debugLineNum = 209;BA.debugLine="l.Color = HeaderColor";
_l.setColor(_headercolor);
 //BA.debugLineNum = 210;BA.debugLine="l.TextColor = HeaderFontColor";
_l.setTextColor(_headerfontcolor);
 //BA.debugLineNum = 211;BA.debugLine="l.Tag = i";
_l.setTag((Object)(_i));
 //BA.debugLineNum = 212;BA.debugLine="Dim leftpos As Int";
_leftpos = 0;
 //BA.debugLineNum = 213;BA.debugLine="Dim colwi As Int";
_colwi = 0;
 //BA.debugLineNum = 214;BA.debugLine="If i=0 Then";
if (_i==0) { 
 //BA.debugLineNum = 215;BA.debugLine="leftpos=0";
_leftpos = (int) (0);
 //BA.debugLineNum = 216;BA.debugLine="colwi=20%x";
_colwi = anywheresoftware.b4a.keywords.Common.PerXToCurrent((float) (20),mostCurrent.activityBA);
 };
 //BA.debugLineNum = 218;BA.debugLine="If i=1 Then";
if (_i==1) { 
 //BA.debugLineNum = 219;BA.debugLine="leftpos=20%x";
_leftpos = anywheresoftware.b4a.keywords.Common.PerXToCurrent((float) (20),mostCurrent.activityBA);
 //BA.debugLineNum = 220;BA.debugLine="colwi=80%x";
_colwi = anywheresoftware.b4a.keywords.Common.PerXToCurrent((float) (80),mostCurrent.activityBA);
 };
 //BA.debugLineNum = 223;BA.debugLine="Header.AddView(l, leftpos , 0, colwi, RowHeight)";
mostCurrent._header.AddView((android.view.View)(_l.getObject()),_leftpos,(int) (0),_colwi,_rowheight);
 }
};
 //BA.debugLineNum = 225;BA.debugLine="Activity.AddView(Header, SV.Left, SV.Top - RowHei";
mostCurrent._activity.AddView((android.view.View)(mostCurrent._header.getObject()),mostCurrent._sv.getLeft(),(int) (mostCurrent._sv.getTop()-_rowheight),mostCurrent._sv.getWidth(),_rowheight);
 //BA.debugLineNum = 226;BA.debugLine="End Sub";
return "";
}
}
