|
@@ -1,67 +1,93 @@
|
|
|
package com.usai.apex;
|
|
package com.usai.apex;
|
|
|
|
|
|
|
|
|
|
+import java.util.Calendar;
|
|
|
import java.util.HashMap;
|
|
import java.util.HashMap;
|
|
|
-import java.util.Iterator;
|
|
|
|
|
-
|
|
|
|
|
import com.usai.util.Network;
|
|
import com.usai.util.Network;
|
|
|
import com.usai.util.dbUtil;
|
|
import com.usai.util.dbUtil;
|
|
|
|
|
|
|
|
import android.os.Bundle;
|
|
import android.os.Bundle;
|
|
|
|
|
+import android.app.ActionBar;
|
|
|
import android.app.Activity;
|
|
import android.app.Activity;
|
|
|
|
|
+import android.app.AlertDialog;
|
|
|
|
|
+import android.app.AlertDialog.Builder;
|
|
|
|
|
+import android.app.DatePickerDialog;
|
|
|
|
|
+import android.app.Dialog;
|
|
|
|
|
+import android.content.DialogInterface;
|
|
|
import android.content.Intent;
|
|
import android.content.Intent;
|
|
|
import android.database.Cursor;
|
|
import android.database.Cursor;
|
|
|
import android.database.sqlite.SQLiteDatabase;
|
|
import android.database.sqlite.SQLiteDatabase;
|
|
|
|
|
+import android.support.v4.app.DialogFragment;
|
|
|
|
|
+import android.support.v4.app.FragmentActivity;
|
|
|
import android.text.Editable;
|
|
import android.text.Editable;
|
|
|
import android.text.InputType;
|
|
import android.text.InputType;
|
|
|
|
|
+import android.text.TextUtils;
|
|
|
import android.text.TextWatcher;
|
|
import android.text.TextWatcher;
|
|
|
|
|
+import android.util.Log;
|
|
|
import android.view.Menu;
|
|
import android.view.Menu;
|
|
|
import android.view.MenuItem;
|
|
import android.view.MenuItem;
|
|
|
import android.view.View;
|
|
import android.view.View;
|
|
|
import android.view.View.OnClickListener;
|
|
import android.view.View.OnClickListener;
|
|
|
|
|
+import android.widget.AdapterView;
|
|
|
|
|
+import android.widget.AdapterView.OnItemSelectedListener;
|
|
|
|
|
+import android.widget.ArrayAdapter;
|
|
|
import android.widget.Button;
|
|
import android.widget.Button;
|
|
|
-import android.widget.CompoundButton;
|
|
|
|
|
|
|
+import android.widget.DatePicker;
|
|
|
import android.widget.EditText;
|
|
import android.widget.EditText;
|
|
|
import android.widget.LinearLayout;
|
|
import android.widget.LinearLayout;
|
|
|
import android.widget.RelativeLayout;
|
|
import android.widget.RelativeLayout;
|
|
|
-import android.widget.Switch;
|
|
|
|
|
|
|
+import android.widget.Spinner;
|
|
|
import android.widget.TextView;
|
|
import android.widget.TextView;
|
|
|
|
|
|
|
|
-public class SearchListActivity extends Activity implements OnClickListener
|
|
|
|
|
|
|
+public class SearchListActivity extends FragmentActivity implements
|
|
|
|
|
+ OnClickListener
|
|
|
{
|
|
{
|
|
|
|
|
|
|
|
- LinearLayout ll_list;
|
|
|
|
|
- String user = null;
|
|
|
|
|
-// String password = null;
|
|
|
|
|
- String function_name = null;
|
|
|
|
|
- HashMap<String, Field> hashMap = new HashMap<String, Field>();
|
|
|
|
|
- private class Field
|
|
|
|
|
- {
|
|
|
|
|
- String name;
|
|
|
|
|
- String value;
|
|
|
|
|
- public Field(String n,String v)
|
|
|
|
|
- {
|
|
|
|
|
- name=n;
|
|
|
|
|
- value=v;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ // String[] spin_valbool = { "True", "False" };
|
|
|
|
|
+ LinearLayout ll_list;
|
|
|
|
|
+ String user = null;
|
|
|
|
|
+ // String password = null;
|
|
|
|
|
+ String function_name = null;
|
|
|
|
|
+ HashMap<String, String> hashMap = new HashMap<String, String>();
|
|
|
|
|
+
|
|
|
|
|
+ // private class Field
|
|
|
|
|
+ // {
|
|
|
|
|
+ // String name;
|
|
|
|
|
+ // String value;
|
|
|
|
|
+ // public Field(String n,String v)
|
|
|
|
|
+ // {
|
|
|
|
|
+ // name=n;
|
|
|
|
|
+ // value=v;
|
|
|
|
|
+ // }
|
|
|
|
|
+ // }
|
|
|
@Override
|
|
@Override
|
|
|
protected void onCreate(Bundle savedInstanceState)
|
|
protected void onCreate(Bundle savedInstanceState)
|
|
|
{
|
|
{
|
|
|
super.onCreate(savedInstanceState);
|
|
super.onCreate(savedInstanceState);
|
|
|
setContentView(R.layout.activity_search_list);
|
|
setContentView(R.layout.activity_search_list);
|
|
|
- user = ApexTrackingApplication.get_user();
|
|
|
|
|
|
|
|
|
|
-// password = ApexTrackingApplication.get_pass();
|
|
|
|
|
|
|
+ user = ApexTrackingApplication.get_user();
|
|
|
|
|
+
|
|
|
|
|
+ // password = ApexTrackingApplication.get_pass();
|
|
|
function_name = getIntent().getStringExtra("function_name");
|
|
function_name = getIntent().getStringExtra("function_name");
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
+ setTitle(getIntent().getStringExtra("title"));
|
|
|
|
|
+
|
|
|
ll_list = (LinearLayout) findViewById(R.id.ll_list);
|
|
ll_list = (LinearLayout) findViewById(R.id.ll_list);
|
|
|
Button btnok = (Button) findViewById(R.id.btnok);
|
|
Button btnok = (Button) findViewById(R.id.btnok);
|
|
|
btnok.setOnClickListener(this);
|
|
btnok.setOnClickListener(this);
|
|
|
Button btncancel = (Button) findViewById(R.id.btncancel);
|
|
Button btncancel = (Button) findViewById(R.id.btncancel);
|
|
|
btncancel.setOnClickListener(this);
|
|
btncancel.setOnClickListener(this);
|
|
|
|
|
+ Button btnclear = (Button) findViewById(R.id.btn_clear);
|
|
|
|
|
+ btnclear.setOnClickListener(this);
|
|
|
|
|
+ if (savedInstanceState != null)
|
|
|
|
|
+ {
|
|
|
|
|
+ hashMap = (HashMap<String, String>) savedInstanceState
|
|
|
|
|
+ .getSerializable("hashMap");
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
-
|
|
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
protected void onResume()
|
|
protected void onResume()
|
|
|
{
|
|
{
|
|
@@ -71,7 +97,7 @@ public class SearchListActivity extends Activity implements OnClickListener
|
|
|
|
|
|
|
|
void init()
|
|
void init()
|
|
|
{
|
|
{
|
|
|
- hashMap.clear();
|
|
|
|
|
|
|
+ // hashMap.clear();
|
|
|
ll_list.removeAllViews();
|
|
ll_list.removeAllViews();
|
|
|
SQLiteDatabase db = dbUtil.OpenDB(this, null, true);
|
|
SQLiteDatabase db = dbUtil.OpenDB(this, null, true);
|
|
|
Cursor cursor = db.query("fields_info", new String[] { "aname",
|
|
Cursor cursor = db.query("fields_info", new String[] { "aname",
|
|
@@ -85,87 +111,251 @@ public class SearchListActivity extends Activity implements OnClickListener
|
|
|
String field_type = cursor.getString(1);
|
|
String field_type = cursor.getString(1);
|
|
|
final String name = cursor.getString(2);
|
|
final String name = cursor.getString(2);
|
|
|
|
|
|
|
|
-// hashMap.put(aname, field);
|
|
|
|
|
|
|
+ // hashMap.put(aname, field);
|
|
|
|
|
|
|
|
if (field_type.equals("boolean"))
|
|
if (field_type.equals("boolean"))
|
|
|
{
|
|
{
|
|
|
- RelativeLayout switchitem = (RelativeLayout) this
|
|
|
|
|
|
|
+ RelativeLayout spinneritem = (RelativeLayout) this
|
|
|
.getLayoutInflater().inflate(
|
|
.getLayoutInflater().inflate(
|
|
|
- R.layout.search_item_switch, null);
|
|
|
|
|
- TextView tvname = (TextView) switchitem
|
|
|
|
|
|
|
+ R.layout.search_item_spinner, null);
|
|
|
|
|
+ spinneritem.setTag("search_item_spinner");
|
|
|
|
|
+ TextView tvname = (TextView) spinneritem
|
|
|
.findViewById(R.id.aname);
|
|
.findViewById(R.id.aname);
|
|
|
tvname.setText(aname);
|
|
tvname.setText(aname);
|
|
|
- Switch switch_bool = (Switch) switchitem
|
|
|
|
|
- .findViewById(R.id.switch_bool);
|
|
|
|
|
- switch_bool.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener(){
|
|
|
|
|
|
|
+ tvname.setTag(name);
|
|
|
|
|
+ Spinner spinner_bool = (Spinner) spinneritem
|
|
|
|
|
+ .findViewById(R.id.sp_bool);
|
|
|
|
|
+ ArrayAdapter<CharSequence> adapter = ArrayAdapter
|
|
|
|
|
+ .createFromResource(this, R.array.spinner_bool_val,
|
|
|
|
|
+ android.R.layout.simple_spinner_item);
|
|
|
|
|
+ adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
|
|
|
|
+ spinner_bool.setAdapter(adapter);
|
|
|
|
|
+ String val = hashMap.get(name);
|
|
|
|
|
+ if (val != null)
|
|
|
|
|
+ {
|
|
|
|
|
+ if (val.equals("true"))
|
|
|
|
|
+ spinner_bool.setSelection(1);
|
|
|
|
|
+ else if (val.equals("false"))
|
|
|
|
|
+ spinner_bool.setSelection(2);
|
|
|
|
|
+ else
|
|
|
|
|
+ spinner_bool.setSelection(0);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ spinner_bool
|
|
|
|
|
+ .setOnItemSelectedListener(new OnItemSelectedListener()
|
|
|
|
|
+ {
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void onItemSelected(AdapterView<?> arg0,
|
|
|
|
|
+ View arg1, int arg2, long arg3)
|
|
|
|
|
+ {
|
|
|
|
|
+ if (arg2 == 1)
|
|
|
|
|
+ hashMap.put(name, "true");
|
|
|
|
|
+ else if (arg2 == 2)
|
|
|
|
|
+ hashMap.put(name, "false");
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void onNothingSelected(AdapterView<?> arg0)
|
|
|
|
|
+ {
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ });
|
|
|
|
|
+ // String val = hashMap.get(name);
|
|
|
|
|
+ // if(val!=null)
|
|
|
|
|
+
|
|
|
|
|
+ // switch_bool.setOnCheckedChangeListener(new
|
|
|
|
|
+ // CompoundButton.OnCheckedChangeListener(){
|
|
|
|
|
+ //
|
|
|
|
|
+ // @Override
|
|
|
|
|
+ // public void onCheckedChanged(CompoundButton buttonView,
|
|
|
|
|
+ // boolean isChecked)
|
|
|
|
|
+ // {
|
|
|
|
|
+ // String val;
|
|
|
|
|
+ // if(isChecked)
|
|
|
|
|
+ // val="true";
|
|
|
|
|
+ // else
|
|
|
|
|
+ // val="false";
|
|
|
|
|
+ // Field field = new Field(name,val);
|
|
|
|
|
+ // field.name = name;
|
|
|
|
|
+ // hashMap.put(aname,field);
|
|
|
|
|
+ //
|
|
|
|
|
+ // }
|
|
|
|
|
+ //
|
|
|
|
|
+ // });
|
|
|
|
|
+ ll_list.addView(spinneritem);
|
|
|
|
|
+ }
|
|
|
|
|
+ else if (field_type.equals("time"))
|
|
|
|
|
+ {
|
|
|
|
|
+
|
|
|
|
|
+ RelativeLayout timeitem = (RelativeLayout) this
|
|
|
|
|
+ .getLayoutInflater().inflate(
|
|
|
|
|
+ R.layout.search_item_datepicker, null);
|
|
|
|
|
+ timeitem.setTag("search_item_datepicker");
|
|
|
|
|
+ TextView tvname = (TextView) timeitem.findViewById(R.id.aname);
|
|
|
|
|
+ tvname.setText(aname);
|
|
|
|
|
+ tvname.setTag(name);
|
|
|
|
|
+ final EditText edit_from = (EditText) timeitem
|
|
|
|
|
+ .findViewById(R.id.et_from);
|
|
|
|
|
+ final EditText edit_to = (EditText) timeitem
|
|
|
|
|
+ .findViewById(R.id.et_to);
|
|
|
|
|
+
|
|
|
|
|
+ String val_from = hashMap.get(name + "_from");
|
|
|
|
|
+ String val_to = hashMap.get(name + "_to");
|
|
|
|
|
+ if (val_from != null)
|
|
|
|
|
+ {
|
|
|
|
|
+ edit_from.setText(val_from);
|
|
|
|
|
+ }
|
|
|
|
|
+ if (val_to != null)
|
|
|
|
|
+ edit_to.setText(val_to);
|
|
|
|
|
+ // edit_from.setInputType(InputType.TYPE_DATETIME_VARIATION_DATE
|
|
|
|
|
+ // | InputType.TYPE_CLASS_DATETIME);
|
|
|
|
|
+ final Calendar c = Calendar.getInstance();
|
|
|
|
|
+ // int mYear =
|
|
|
|
|
+ // int mMonth = c.get(Calendar.MONTH);
|
|
|
|
|
+ // int mDay = c.get(Calendar.DAY_OF_MONTH);
|
|
|
|
|
+ // final DatePickerDialog dialog =
|
|
|
|
|
+ Button btn_clear_from = (Button) timeitem
|
|
|
|
|
+ .findViewById(R.id.btn_clear_from);
|
|
|
|
|
+ btn_clear_from.setOnClickListener(new OnClickListener()
|
|
|
|
|
+ {
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
- public void onCheckedChanged(CompoundButton buttonView,
|
|
|
|
|
- boolean isChecked)
|
|
|
|
|
- {
|
|
|
|
|
- String val;
|
|
|
|
|
- if(isChecked)
|
|
|
|
|
- val="true";
|
|
|
|
|
- else
|
|
|
|
|
- val="false";
|
|
|
|
|
- Field field = new Field(name,val);
|
|
|
|
|
- field.name = name;
|
|
|
|
|
- hashMap.put(aname,field);
|
|
|
|
|
-
|
|
|
|
|
|
|
+ public void onClick(View v)
|
|
|
|
|
+ {
|
|
|
|
|
+ edit_from.setText("");
|
|
|
|
|
+ hashMap.remove(name+"_from");
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
});
|
|
});
|
|
|
- ll_list.addView(switchitem);
|
|
|
|
|
|
|
+ Button btn_clear_to = (Button) timeitem
|
|
|
|
|
+ .findViewById(R.id.btn_clear_to);
|
|
|
|
|
+ btn_clear_to.setOnClickListener(new OnClickListener()
|
|
|
|
|
+ {
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void onClick(View v)
|
|
|
|
|
+ {
|
|
|
|
|
+ edit_to.setText("");
|
|
|
|
|
+ hashMap.remove(name+"_to");
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ edit_from.setOnClickListener(new OnClickListener()
|
|
|
|
|
+ {
|
|
|
|
|
+ public void onClick(View v)
|
|
|
|
|
+ {
|
|
|
|
|
+ new DatePickerDialog(SearchListActivity.this,
|
|
|
|
|
+ new DatePickerDialog.OnDateSetListener()
|
|
|
|
|
+ {
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void onDateSet(DatePicker view,
|
|
|
|
|
+ int year, int monthOfYear,
|
|
|
|
|
+ int dayOfMonth)
|
|
|
|
|
+ {
|
|
|
|
|
+ edit_from
|
|
|
|
|
+ .setText((monthOfYear + 1)
|
|
|
|
|
+ + "/" + dayOfMonth
|
|
|
|
|
+ + "/" + year);
|
|
|
|
|
+ hashMap.put(name+"_from",(monthOfYear + 1)
|
|
|
|
|
+ + "/" + dayOfMonth
|
|
|
|
|
+ + "/" + year);
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }, c.get(Calendar.YEAR), c.get(Calendar.MONTH),
|
|
|
|
|
+ c.get(Calendar.DAY_OF_MONTH)).show();
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ edit_to.setOnClickListener(new OnClickListener()
|
|
|
|
|
+ {
|
|
|
|
|
+ public void onClick(View v)
|
|
|
|
|
+ {
|
|
|
|
|
+ new DatePickerDialog(SearchListActivity.this,
|
|
|
|
|
+ new DatePickerDialog.OnDateSetListener()
|
|
|
|
|
+ {
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void onDateSet(DatePicker view,
|
|
|
|
|
+ int year, int monthOfYear,
|
|
|
|
|
+ int dayOfMonth)
|
|
|
|
|
+ {
|
|
|
|
|
+ edit_to.setText((monthOfYear + 1) + "/"
|
|
|
|
|
+ + dayOfMonth + "/" + year);
|
|
|
|
|
+ hashMap.put(name+"_to",(monthOfYear + 1)
|
|
|
|
|
+ + "/" + dayOfMonth
|
|
|
|
|
+ + "/" + year);
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }, c.get(Calendar.YEAR), c.get(Calendar.MONTH),
|
|
|
|
|
+ c.get(Calendar.DAY_OF_MONTH)).show();
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ ll_list.addView(timeitem);
|
|
|
}
|
|
}
|
|
|
else
|
|
else
|
|
|
{
|
|
{
|
|
|
RelativeLayout edititem = (RelativeLayout) this
|
|
RelativeLayout edititem = (RelativeLayout) this
|
|
|
.getLayoutInflater().inflate(R.layout.search_item_edit,
|
|
.getLayoutInflater().inflate(R.layout.search_item_edit,
|
|
|
null);
|
|
null);
|
|
|
|
|
+ edititem.setTag("search_item_edit");
|
|
|
TextView tvname = (TextView) edititem.findViewById(R.id.aname);
|
|
TextView tvname = (TextView) edititem.findViewById(R.id.aname);
|
|
|
tvname.setText(aname);
|
|
tvname.setText(aname);
|
|
|
|
|
+ tvname.setTag(name);
|
|
|
EditText edit = (EditText) edititem.findViewById(R.id.edit_val);
|
|
EditText edit = (EditText) edititem.findViewById(R.id.edit_val);
|
|
|
|
|
+ String val = hashMap.get(name);
|
|
|
|
|
+ if (val != null)
|
|
|
|
|
+ {
|
|
|
|
|
+ edit.setText(val);
|
|
|
|
|
+ }
|
|
|
edit.addTextChangedListener(new TextWatcher()
|
|
edit.addTextChangedListener(new TextWatcher()
|
|
|
{
|
|
{
|
|
|
@Override
|
|
@Override
|
|
|
public void onTextChanged(CharSequence s, int start,
|
|
public void onTextChanged(CharSequence s, int start,
|
|
|
int before, int count)
|
|
int before, int count)
|
|
|
{
|
|
{
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
public void beforeTextChanged(CharSequence s, int start,
|
|
public void beforeTextChanged(CharSequence s, int start,
|
|
|
int count, int after)
|
|
int count, int after)
|
|
|
{
|
|
{
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
public void afterTextChanged(Editable s)
|
|
public void afterTextChanged(Editable s)
|
|
|
{
|
|
{
|
|
|
- // ��editText�иı��ֵ���õ�HashMap��
|
|
|
|
|
String val = s.toString();
|
|
String val = s.toString();
|
|
|
val.trim();
|
|
val.trim();
|
|
|
if (val.length() > 0)
|
|
if (val.length() > 0)
|
|
|
{
|
|
{
|
|
|
- Field field = new Field(name,val);
|
|
|
|
|
- field.name = name;
|
|
|
|
|
- hashMap.put(aname,field);
|
|
|
|
|
|
|
+
|
|
|
|
|
+ hashMap.put(name, val);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
});
|
|
});
|
|
|
- if (field_type.equals("time"))
|
|
|
|
|
- edit.setInputType(InputType.TYPE_DATETIME_VARIATION_DATE
|
|
|
|
|
- | InputType.TYPE_CLASS_DATETIME);
|
|
|
|
|
- else if (field_type.equals("int"))
|
|
|
|
|
|
|
+ if (field_type.equals("int"))
|
|
|
edit.setInputType(InputType.TYPE_CLASS_NUMBER);
|
|
edit.setInputType(InputType.TYPE_CLASS_NUMBER);
|
|
|
|
|
|
|
|
ll_list.addView(edititem);
|
|
ll_list.addView(edititem);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+ dbUtil.CloseCursor(cursor);
|
|
|
|
|
+ dbUtil.CloseDB(db);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -176,39 +366,128 @@ public class SearchListActivity extends Activity implements OnClickListener
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
|
+ protected void onSaveInstanceState(Bundle outState)
|
|
|
|
|
+ {
|
|
|
|
|
+ outState.putSerializable("hashmap", hashMap);
|
|
|
|
|
+ super.onSaveInstanceState(outState);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
public void onClick(View v)
|
|
public void onClick(View v)
|
|
|
{
|
|
{
|
|
|
switch (v.getId())
|
|
switch (v.getId())
|
|
|
{
|
|
{
|
|
|
- case R.id.btnok:
|
|
|
|
|
- {
|
|
|
|
|
- Intent intent = new Intent();
|
|
|
|
|
- intent.setClass(this, ResultActivity.class);
|
|
|
|
|
-// intent.putExtra("user", user);
|
|
|
|
|
-// intent.putExtra("password", password);
|
|
|
|
|
- intent.putExtra("function_name", function_name);
|
|
|
|
|
- Bundle parms = new Bundle();
|
|
|
|
|
- parms.putString("module_name", function_name);
|
|
|
|
|
- parms.putString("columns", dbUtil.get_fields(user, function_name));
|
|
|
|
|
- Iterator<String> iter = hashMap.keySet().iterator();
|
|
|
|
|
- while (iter.hasNext())
|
|
|
|
|
|
|
+ case R.id.btnok:
|
|
|
{
|
|
{
|
|
|
- String aname = (String) iter.next();
|
|
|
|
|
- Field field = (Field) hashMap.get(aname);
|
|
|
|
|
- parms.putString(field.name, field.value);
|
|
|
|
|
|
|
+ Intent intent = new Intent();
|
|
|
|
|
+ intent.setClass(this, ResultActivity.class);
|
|
|
|
|
+ // intent.putExtra("user", user);
|
|
|
|
|
+ // intent.putExtra("password", password);
|
|
|
|
|
+ intent.putExtra("function_name", function_name);
|
|
|
|
|
+ Bundle parms = new Bundle();
|
|
|
|
|
+ parms.putString("module_name", function_name);
|
|
|
|
|
+ parms.putString("columns",
|
|
|
|
|
+ dbUtil.get_fields(user, function_name));
|
|
|
|
|
+ for (int i = 0; i < ll_list.getChildCount(); i++)
|
|
|
|
|
+ {
|
|
|
|
|
+ View item = ll_list.getChildAt(i);
|
|
|
|
|
+ String tag = item.getTag().toString();
|
|
|
|
|
+ TextView tv_aname = (TextView) item
|
|
|
|
|
+ .findViewById(R.id.aname);
|
|
|
|
|
+ String field_name = tv_aname.getTag().toString();
|
|
|
|
|
+ String val = "";
|
|
|
|
|
+ if (tag.equals("search_item_spinner"))
|
|
|
|
|
+ {
|
|
|
|
|
+ Spinner spinner_bool = (Spinner) item
|
|
|
|
|
+ .findViewById(R.id.sp_bool);
|
|
|
|
|
+ long sel = spinner_bool.getSelectedItemId();
|
|
|
|
|
+ if (sel == 1)
|
|
|
|
|
+ val = "true";
|
|
|
|
|
+ else if (sel == 2)
|
|
|
|
|
+ val = "false";
|
|
|
|
|
+ else
|
|
|
|
|
+ val = "";
|
|
|
|
|
+ if (!TextUtils.isEmpty(val))
|
|
|
|
|
+ parms.putString(field_name, val);
|
|
|
|
|
+ }
|
|
|
|
|
+ else if (tag.equals("search_item_edit"))
|
|
|
|
|
+ {
|
|
|
|
|
+ EditText edit = (EditText) item
|
|
|
|
|
+ .findViewById(R.id.edit_val);
|
|
|
|
|
+ val = edit.getText().toString().trim();
|
|
|
|
|
+ if (!TextUtils.isEmpty(val))
|
|
|
|
|
+ parms.putString(field_name, val);
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ else if (tag.equals("search_item_datepicker"))
|
|
|
|
|
+ {
|
|
|
|
|
+ EditText et_from = (EditText) item
|
|
|
|
|
+ .findViewById(R.id.et_from);
|
|
|
|
|
+ String val_from = et_from.getText().toString().trim();
|
|
|
|
|
+ EditText et_to = (EditText) item
|
|
|
|
|
+ .findViewById(R.id.et_to);
|
|
|
|
|
+ String val_to = et_to.getText().toString().trim();
|
|
|
|
|
+ if (!TextUtils.isEmpty(val_from))
|
|
|
|
|
+ parms.putString(field_name + "_from", val_from);
|
|
|
|
|
+ if (!TextUtils.isEmpty(val_to))
|
|
|
|
|
+ parms.putString(field_name + "_to", val_to);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ // Iterator<String> iter = hashMap.keySet().iterator();
|
|
|
|
|
+ // while (iter.hasNext())
|
|
|
|
|
+ // {
|
|
|
|
|
+ // String aname = (String) iter.next();
|
|
|
|
|
+ // Field field = (Field) hashMap.get(aname);
|
|
|
|
|
+ // parms.putString(field.name, field.value);
|
|
|
|
|
+ // }
|
|
|
|
|
+ intent.putExtra("searchParms", parms);
|
|
|
|
|
+
|
|
|
|
|
+ startActivity(intent);
|
|
|
|
|
+
|
|
|
|
|
+ break;
|
|
|
}
|
|
}
|
|
|
- intent.putExtra("searchParms", parms);
|
|
|
|
|
|
|
+ case R.id.btncancel:
|
|
|
|
|
+ finish();
|
|
|
|
|
+ break;
|
|
|
|
|
+ case R.id.btn_clear:
|
|
|
|
|
+ {
|
|
|
|
|
+ AlertDialog.Builder builder = new Builder(
|
|
|
|
|
+ SearchListActivity.this);
|
|
|
|
|
+ builder.setMessage("Click Reset button to reset");
|
|
|
|
|
|
|
|
- startActivity(intent);
|
|
|
|
|
|
|
+ builder.setTitle("Confirm reset");
|
|
|
|
|
|
|
|
- break;
|
|
|
|
|
- }
|
|
|
|
|
- case R.id.btncancel:
|
|
|
|
|
- finish();
|
|
|
|
|
- break;
|
|
|
|
|
- default:
|
|
|
|
|
- break;
|
|
|
|
|
|
|
+ builder.setPositiveButton("Reset", new Dialog.OnClickListener()
|
|
|
|
|
+ {
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void onClick(DialogInterface dialog, int which)
|
|
|
|
|
+ {
|
|
|
|
|
+ hashMap.clear();
|
|
|
|
|
+ init();
|
|
|
|
|
+ dialog.dismiss();
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ builder.setNegativeButton("Cancel",
|
|
|
|
|
+ new Dialog.OnClickListener()
|
|
|
|
|
+ {
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void onClick(DialogInterface dialog,
|
|
|
|
|
+ int which)
|
|
|
|
|
+ {
|
|
|
|
|
+ dialog.dismiss();
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ builder.create().show();
|
|
|
|
|
+ }
|
|
|
|
|
+ default:
|
|
|
|
|
+ break;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|
|
@@ -219,25 +498,25 @@ public class SearchListActivity extends Activity implements OnClickListener
|
|
|
Intent intent = new Intent();
|
|
Intent intent = new Intent();
|
|
|
switch (item.getItemId())
|
|
switch (item.getItemId())
|
|
|
{
|
|
{
|
|
|
- case R.id.action_custom_fields:
|
|
|
|
|
- intent.setClass(this, CustomizeFieldsActivity.class);
|
|
|
|
|
-// intent.putExtra("user", user);
|
|
|
|
|
- // intent.putExtra("password", password);
|
|
|
|
|
- intent.putExtra("function_name", function_name);
|
|
|
|
|
- intent.putExtra("behavior", Network.BEHAVIOR_SEARCH);
|
|
|
|
|
- startActivity(intent);
|
|
|
|
|
- break;
|
|
|
|
|
- case R.id.action_help:
|
|
|
|
|
- // Intent intent = new Intent();
|
|
|
|
|
- intent.setClass(this, HelpActivity.class);
|
|
|
|
|
- intent.putExtra("caller", "search");
|
|
|
|
|
- // // intent.putExtra("password", password);
|
|
|
|
|
- // intent.putExtra("function_name", function_name);
|
|
|
|
|
- // intent.putExtra("behavior", Network.BEHAVIOR_SEARCH);
|
|
|
|
|
- startActivity(intent);
|
|
|
|
|
- break;
|
|
|
|
|
- default:
|
|
|
|
|
- break;
|
|
|
|
|
|
|
+ case R.id.action_custom_fields:
|
|
|
|
|
+ intent.setClass(this, CustomizeFieldsActivity.class);
|
|
|
|
|
+ // intent.putExtra("user", user);
|
|
|
|
|
+ // intent.putExtra("password", password);
|
|
|
|
|
+ intent.putExtra("function_name", function_name);
|
|
|
|
|
+ intent.putExtra("behavior", Network.BEHAVIOR_SEARCH);
|
|
|
|
|
+ startActivity(intent);
|
|
|
|
|
+ break;
|
|
|
|
|
+ case R.id.action_help:
|
|
|
|
|
+ // Intent intent = new Intent();
|
|
|
|
|
+ intent.setClass(this, HelpActivity.class);
|
|
|
|
|
+ intent.putExtra("caller", "search");
|
|
|
|
|
+ // // intent.putExtra("password", password);
|
|
|
|
|
+ // intent.putExtra("function_name", function_name);
|
|
|
|
|
+ // intent.putExtra("behavior", Network.BEHAVIOR_SEARCH);
|
|
|
|
|
+ startActivity(intent);
|
|
|
|
|
+ break;
|
|
|
|
|
+ default:
|
|
|
|
|
+ break;
|
|
|
}
|
|
}
|
|
|
return super.onOptionsItemSelected(item);
|
|
return super.onOptionsItemSelected(item);
|
|
|
}
|
|
}
|