|
|
@@ -1,27 +1,36 @@
|
|
|
package com.usai.apex;
|
|
|
|
|
|
+import com.usai.util.dbUtil;
|
|
|
+
|
|
|
import android.app.ActionBar;
|
|
|
import android.content.Intent;
|
|
|
+import android.database.Cursor;
|
|
|
+import android.database.sqlite.SQLiteDatabase;
|
|
|
import android.os.Bundle;
|
|
|
import android.support.v4.app.FragmentActivity;
|
|
|
+import android.support.v4.widget.SimpleCursorAdapter;
|
|
|
import android.text.TextUtils;
|
|
|
import android.util.Log;
|
|
|
-import android.view.Menu;
|
|
|
import android.view.View;
|
|
|
import android.view.View.OnClickListener;
|
|
|
+import android.widget.AutoCompleteTextView;
|
|
|
import android.widget.Button;
|
|
|
-import android.widget.EditText;
|
|
|
-import android.widget.ImageButton;
|
|
|
import android.widget.RadioGroup;
|
|
|
+import android.widget.RadioGroup.OnCheckedChangeListener;
|
|
|
import android.widget.TextView;
|
|
|
|
|
|
public class FunctionSelectActivity extends FragmentActivity implements
|
|
|
- OnClickListener {
|
|
|
+ OnClickListener
|
|
|
+{
|
|
|
// String user=null;
|
|
|
// String password=null;
|
|
|
+ Cursor m_cur_container_no, m_cur_hbol;
|
|
|
+ SQLiteDatabase m_db;
|
|
|
+ SimpleCursorAdapter history_adapter;
|
|
|
|
|
|
@Override
|
|
|
- protected void onCreate(Bundle savedInstanceState) {
|
|
|
+ protected void onCreate(Bundle savedInstanceState)
|
|
|
+ {
|
|
|
// user = ApexTrackingApplication.get_user();
|
|
|
// password= getIntent().getStringExtra("password");
|
|
|
super.onCreate(savedInstanceState);
|
|
|
@@ -50,128 +59,229 @@ public class FunctionSelectActivity extends FragmentActivity implements
|
|
|
tv_about.setOnClickListener(this);
|
|
|
Button btn_search = (Button) findViewById(R.id.btn_search);
|
|
|
btn_search.setOnClickListener(this);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ m_db = dbUtil.OpenDB(this, null, true);
|
|
|
+ m_cur_container_no = m_db.query("search_history", new String[] {
|
|
|
+ "h_val", "_id" }, "h_field='container_no' and user='"
|
|
|
+ + ApexTrackingApplication.get_user() + "'", null, null, null,
|
|
|
+ "h_time", null);
|
|
|
+ startManagingCursor(m_cur_container_no);
|
|
|
+
|
|
|
+ m_cur_hbol = m_db.query("search_history",
|
|
|
+ new String[] { "h_val", "_id" }, "h_field='hbol' and user='"
|
|
|
+ + ApexTrackingApplication.get_user() + "'", null, null,
|
|
|
+ null, "h_time", null);
|
|
|
+ startManagingCursor(m_cur_hbol);
|
|
|
+
|
|
|
+ AutoCompleteTextView atv_criterion = (AutoCompleteTextView) findViewById(R.id.atv_criterion);
|
|
|
+ history_adapter = new SimpleCursorAdapter(this, R.layout.dropdown_item,
|
|
|
+ m_cur_hbol, new String[] { "h_val" },
|
|
|
+ new int[] { R.id.drop_item });
|
|
|
+ atv_criterion.setAdapter(history_adapter);
|
|
|
+
|
|
|
+
|
|
|
+ RadioGroup rg = (RadioGroup) findViewById(R.id.radioGroup1);
|
|
|
+ rg.setOnCheckedChangeListener(new OnCheckedChangeListener(){
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onCheckedChanged(RadioGroup group, int checkedId)
|
|
|
+ {
|
|
|
+ if(checkedId==R.id.radio0)
|
|
|
+ {
|
|
|
+ history_adapter.swapCursor(m_cur_hbol);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ history_adapter.swapCursor(m_cur_container_no);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
-// @Override
|
|
|
-// public boolean onCreateOptionsMenu(Menu menu) {
|
|
|
-// // Inflate the menu; this adds items to the action bar if it is present.
|
|
|
-// getMenuInflater().inflate(R.menu.function_select, menu);
|
|
|
-// return true;
|
|
|
-// }
|
|
|
+ // @Override
|
|
|
+ // public boolean onCreateOptionsMenu(Menu menu) {
|
|
|
+ // // Inflate the menu; this adds items to the action bar if it is present.
|
|
|
+ // getMenuInflater().inflate(R.menu.function_select, menu);
|
|
|
+ // return true;F
|
|
|
+ // }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected void onDestroy()
|
|
|
+ {
|
|
|
+ dbUtil.CloseDB(m_db);
|
|
|
+ super.onDestroy();
|
|
|
+ }
|
|
|
|
|
|
@Override
|
|
|
- public void onClick(View v) {
|
|
|
+ public void onClick(View v)
|
|
|
+ {
|
|
|
String TAG = "onClick@FunctionSelectActivity";
|
|
|
Log.d(TAG, "ID=" + v.getId());
|
|
|
- switch (v.getId()) {
|
|
|
- case R.id.btn_search:
|
|
|
- EditText et = (EditText) findViewById(R.id.et_criterion);
|
|
|
- String cargo_criterion = et.getText().toString();
|
|
|
- if (TextUtils.isEmpty(cargo_criterion)) {
|
|
|
- et.setError(getString(R.string.error_field_required));
|
|
|
- et.requestFocus();
|
|
|
- } else {
|
|
|
- Intent intent = new Intent();
|
|
|
- intent.setClass(this, DetailActivity.class);
|
|
|
-
|
|
|
- intent.putExtra("action0", "Tracking");
|
|
|
- intent.putExtra("function_name", "Cargo Tracking");
|
|
|
- intent.putExtra("cargo_criterion", cargo_criterion);
|
|
|
- intent.putExtra("actions_count", 1);
|
|
|
- intent.putExtra("_id", "dumb");
|
|
|
- RadioGroup rg = (RadioGroup) findViewById(R.id.radioGroup1);
|
|
|
- if (rg.getCheckedRadioButtonId() == R.id.radio0)
|
|
|
- intent.putExtra("criterion_type", 0);
|
|
|
+ switch (v.getId())
|
|
|
+ {
|
|
|
+ case R.id.btn_search:
|
|
|
+ AutoCompleteTextView et = (AutoCompleteTextView) findViewById(R.id.atv_criterion);
|
|
|
+ String cargo_criterion = et.getText().toString();
|
|
|
+ if (TextUtils.isEmpty(cargo_criterion))
|
|
|
+ {
|
|
|
+ et.setError(getString(R.string.error_field_required));
|
|
|
+ et.requestFocus();
|
|
|
+ }
|
|
|
else
|
|
|
- intent.putExtra("criterion_type", 1);
|
|
|
- // hbol
|
|
|
- // container_no
|
|
|
+ {
|
|
|
+ Intent intent = new Intent();
|
|
|
+ intent.setClass(this, DetailActivity.class);
|
|
|
+
|
|
|
+ intent.putExtra("action0", "Tracking");
|
|
|
+ intent.putExtra("function_name", "Cargo Tracking");
|
|
|
+ intent.putExtra("cargo_criterion", cargo_criterion);
|
|
|
+ intent.putExtra("actions_count", 1);
|
|
|
+ intent.putExtra("_id", "dumb");
|
|
|
+ String h_field;
|
|
|
+ RadioGroup rg = (RadioGroup) findViewById(R.id.radioGroup1);
|
|
|
+ if (rg.getCheckedRadioButtonId() == R.id.radio0)
|
|
|
+ {
|
|
|
+ intent.putExtra("criterion_type", 0);
|
|
|
+ h_field = "hbol";
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ intent.putExtra("criterion_type", 1);
|
|
|
+ h_field = "container_no";
|
|
|
+ }
|
|
|
+ String user = ApexTrackingApplication.get_user();
|
|
|
+ long h_time = System.currentTimeMillis();
|
|
|
+ int count = dbUtil
|
|
|
+ .get_count(m_db, "search_history", "user='" + user
|
|
|
+ + "' and h_field='" + h_field + "'");
|
|
|
+ if (count < 10)
|
|
|
+ {
|
|
|
+ m_db.execSQL("insert into search_history(h_val,h_field,h_time,user) values('"
|
|
|
+ + cargo_criterion + "','" + h_field + "',"+h_time+",'"+user+"')");
|
|
|
+ }
|
|
|
+ {
|
|
|
+ int _id=dbUtil.get_recordid(m_db, "search_history", "user='" + user
|
|
|
+ + "' and h_field='" + h_field + "'", "h_time");
|
|
|
+ m_db.execSQL("update search_history set h_val='"+cargo_criterion+"' , h_time='"+h_time+"' where _id="+_id);
|
|
|
+ }
|
|
|
+ // dbUtil.isRecordExist(m_db, "search_history", where);
|
|
|
+ // ContentValues cv = new ContentValues();
|
|
|
+ // cv.put("h_val", cargo_criterion);
|
|
|
+ // cv.put("h_field", dbUtil.NUMBER_TYPE_BLACK);
|
|
|
+ // cv.put("h_time", 3);
|
|
|
+ // cv.put("user", ApexTrackingApplication.get_user());
|
|
|
+ // db.insert("user_numberlist", null, cv);
|
|
|
+ // hbol
|
|
|
+ // container_no
|
|
|
+ startActivity(intent);
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case R.id.tv_booking:
|
|
|
+ {
|
|
|
+ Intent intent = new Intent();
|
|
|
+ intent.setClass(this, SearchListActivity.class);
|
|
|
+ // intent.putExtra("user", ApexTrackingApplication.get_user());
|
|
|
+ // intent.putExtra("password", password);
|
|
|
+ intent.putExtra("function_name", "Ocean Booking");
|
|
|
startActivity(intent);
|
|
|
+ break;
|
|
|
}
|
|
|
- break;
|
|
|
- case R.id.tv_booking: {
|
|
|
- Intent intent = new Intent();
|
|
|
- intent.setClass(this, SearchListActivity.class);
|
|
|
- // intent.putExtra("user", ApexTrackingApplication.get_user());
|
|
|
- // intent.putExtra("password", password);
|
|
|
- intent.putExtra("function_name", "Ocean Booking");
|
|
|
- startActivity(intent);
|
|
|
- break;
|
|
|
- }
|
|
|
- case R.id.tv_info: {
|
|
|
- Intent intent = new Intent();
|
|
|
- intent.setClass(this, SearchListActivity.class);
|
|
|
- // intent.putExtra("user", user);
|
|
|
- // intent.putExtra("password", password);
|
|
|
- intent.putExtra("function_name", "Ocean B/L info.");
|
|
|
- startActivity(intent);
|
|
|
- break;
|
|
|
- }
|
|
|
- case R.id.tv_detail: {
|
|
|
- Intent intent = new Intent();
|
|
|
- intent.setClass(this, SearchListActivity.class);
|
|
|
- // intent.putExtra("user", user);
|
|
|
- // intent.putExtra("password", password);
|
|
|
- intent.putExtra("function_name", "Container detail");
|
|
|
- startActivity(intent);
|
|
|
- break;
|
|
|
- }
|
|
|
- // case R.id.tv_cargo:
|
|
|
- // {
|
|
|
- // Intent intent = new Intent();
|
|
|
- // intent.setClass(this, CargoTrackingActivity.class);
|
|
|
- // intent.putExtra("user", user);
|
|
|
- // intent.putExtra("password", password);
|
|
|
- // intent.putExtra("function_name", "Cargo Tracking");
|
|
|
- // startActivity(intent);
|
|
|
- // }
|
|
|
- //
|
|
|
- // break;
|
|
|
- case R.id.tv_doc:
|
|
|
- {
|
|
|
- Intent intent = new Intent();
|
|
|
- intent.setClass(this, SearchListActivity.class);
|
|
|
- // intent.putExtra("user", user);
|
|
|
- // intent.putExtra("password", password);
|
|
|
- intent.putExtra("function_name", "Download Document");
|
|
|
- startActivity(intent);
|
|
|
- break;
|
|
|
- }
|
|
|
- case R.id.tv_password: {
|
|
|
- Intent intent = new Intent();
|
|
|
- intent.setClass(this, ChangePasswordActivity.class);
|
|
|
- // intent.putExtra("function_name", "Container detail");
|
|
|
- startActivity(intent);
|
|
|
- break;
|
|
|
- }
|
|
|
- case R.id.tv_exit: {
|
|
|
- finish();
|
|
|
- System.exit(0);
|
|
|
- break;
|
|
|
- }
|
|
|
- case R.id.tv_about: {
|
|
|
- Intent intent = new Intent();
|
|
|
- intent.setClass(this, AboutActivity.class);
|
|
|
- startActivity(intent);
|
|
|
-
|
|
|
- break;
|
|
|
- }
|
|
|
- case R.id.tv_location: {
|
|
|
- Log.d("==============", "start location activity");
|
|
|
- Intent intent = new Intent();
|
|
|
- intent.setClass(this, InnerMapActivity.class);
|
|
|
+ case R.id.tv_info:
|
|
|
+ {
|
|
|
+ Intent intent = new Intent();
|
|
|
+ intent.setClass(this, SearchListActivity.class);
|
|
|
+ // intent.putExtra("user", user);
|
|
|
+ // intent.putExtra("password", password);
|
|
|
+ intent.putExtra("function_name", "Ocean B/L info.");
|
|
|
+ startActivity(intent);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case R.id.tv_detail:
|
|
|
+ {
|
|
|
+ Intent intent = new Intent();
|
|
|
+ intent.setClass(this, SearchListActivity.class);
|
|
|
+ // intent.putExtra("user", user);
|
|
|
+ // intent.putExtra("password", password);
|
|
|
+ intent.putExtra("function_name", "Container detail");
|
|
|
+ startActivity(intent);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ // case R.id.tv_cargo:
|
|
|
+ // {
|
|
|
+ // Intent intent = new Intent();
|
|
|
+ // intent.setClass(this, CargoTrackingActivity.class);
|
|
|
// intent.putExtra("user", user);
|
|
|
// intent.putExtra("password", password);
|
|
|
- // intent.putExtra("function_name", "Container detail");
|
|
|
- startActivity(intent);
|
|
|
- break;
|
|
|
- }
|
|
|
+ // intent.putExtra("function_name", "Cargo Tracking");
|
|
|
+ // startActivity(intent);
|
|
|
+ // }
|
|
|
+ //
|
|
|
+ // break;
|
|
|
+ case R.id.tv_doc:
|
|
|
+ {
|
|
|
+ Intent intent = new Intent();
|
|
|
+ intent.setClass(this, SearchListActivity.class);
|
|
|
+ // intent.putExtra("user", user);
|
|
|
+ // intent.putExtra("password", password);
|
|
|
+ intent.putExtra("function_name", "Download Document");
|
|
|
+ startActivity(intent);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case R.id.tv_password:
|
|
|
+ {
|
|
|
+ Intent intent = new Intent();
|
|
|
+ intent.setClass(this, ChangePasswordActivity.class);
|
|
|
+ // intent.putExtra("function_name", "Container detail");
|
|
|
+ startActivity(intent);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case R.id.tv_exit:
|
|
|
+ {
|
|
|
+ finish();
|
|
|
+ System.exit(0);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case R.id.tv_about:
|
|
|
+ {
|
|
|
+ Intent intent = new Intent();
|
|
|
+ intent.setClass(this, AboutActivity.class);
|
|
|
+ startActivity(intent);
|
|
|
+
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case R.id.tv_location:
|
|
|
+ {
|
|
|
+ Log.d("==============", "start location activity");
|
|
|
+ Intent intent = new Intent();
|
|
|
+ intent.setClass(this, InnerMapActivity.class);
|
|
|
+ // intent.putExtra("user", user);
|
|
|
+ // intent.putExtra("password", password);
|
|
|
+ // intent.putExtra("function_name", "Container detail");
|
|
|
+ startActivity(intent);
|
|
|
+ break;
|
|
|
+ }
|
|
|
|
|
|
- default:
|
|
|
- break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
}
|
|
|
// TODO Auto-generated method stub
|
|
|
|
|
|
}
|
|
|
+ // class HistoryAdapter extends SimpleCursorAdapter{
|
|
|
+ //
|
|
|
+ // public HistoryAdapter(Context context, int layout, Cursor c,
|
|
|
+ // String[] from, int[] to)
|
|
|
+ // {
|
|
|
+ // super(context, layout, c, from, to,FLAG_AUTO_REQUERY);
|
|
|
+ // // TODO Auto-generated constructor stub
|
|
|
+ // }
|
|
|
+ //
|
|
|
+ // }
|
|
|
|
|
|
}
|