Ray Zhang 12 жил өмнө
parent
commit
e45abfda82

+ 1 - 0
Apex/.settings/org.eclipse.core.resources.prefs

@@ -1,2 +1,3 @@
 eclipse.preferences.version=1
+encoding//src/com/usai/apex/SearchActivity.java=UTF-8
 encoding//src/com/usai/util/dbUtil.java=UTF-8

+ 29 - 6
Apex/res/layout/activity_result.xml

@@ -4,16 +4,40 @@
     android:layout_height="match_parent"
     tools:context=".ResultActivity" >
 
-    <HorizontalScrollView
-        android:id="@+id/horizontalScrollView1"
+    <LinearLayout
+        android:id="@+id/status"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
-        >
+        android:layout_centerInParent="true"
+        android:layout_gravity="center"
+        android:gravity="center_horizontal"
+        android:orientation="vertical"
+        android:visibility="gone" >
+
+        <ProgressBar
+            style="?android:attr/progressBarStyleLarge"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_marginBottom="8dp" />
+
+        <TextView
+            android:id="@+id/status_message"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_marginBottom="16dp"
+            android:fontFamily="sans-serif-light"
+            android:text="Loading..."
+            android:textAppearance="?android:attr/textAppearanceMedium" />
+    </LinearLayout>
+
+    <HorizontalScrollView
+        android:id="@+id/search_form"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content" >
 
         <TableLayout
             android:layout_width="wrap_content"
-            android:layout_height="fill_parent"
-             >
+            android:layout_height="fill_parent" >
 
             <TableRow
                 android:id="@+id/tr_count"
@@ -35,7 +59,6 @@
                 android:layout_height="wrap_content" >
             </TableRow>
         </TableLayout>
-
     </HorizontalScrollView>
 
 </RelativeLayout>

+ 4 - 0
Apex/src/com/usai/apex/ApexTrackingApplication.java

@@ -30,4 +30,8 @@ public class ApexTrackingApplication extends Application
 		m_sessionid = id;
 	}
 
+	public static String get_sessionid()
+	{
+		return m_sessionid;
+	}
 }

+ 1 - 94
Apex/src/com/usai/apex/LoginFragment.java

@@ -116,100 +116,7 @@ public class LoginFragment extends Fragment/* implements OnClickListener */
 		// return super.onCreateView(inflater, container, savedInstanceState);
 	}
 
-	// @Override
-	// public void onClick(View v)
-	// {
-	// // TODO Auto-generated method stub
-	// if (v.getId() == R.id.sign_in_button)
-	// {
-	// SharedPreferences sharedPrefrences = getActivity()
-	// .getSharedPreferences("test", Context.MODE_PRIVATE);
-	// Intent intent = new Intent();
-	// intent.setClass(getActivity(), FunctionSelectActivity.class);
-	// getActivity().startActivity(intent);
-	// }
-	//
-	// }
-
-	// /**
-	// * A dummy authentication store containing known user names and passwords.
-	// * TODO: remove after connecting to a real authentication system.
-	// */
-	// private static final String[] DUMMY_CREDENTIALS = new String[] {
-	// "foo@example.com:hello", "bar@example.com:world" };
-	//
-	// /**
-	// * The default email to populate the email field with.
-	// */
-	// public static final String EXTRA_EMAIL =
-	// "com.example.android.authenticatordemo.extra.EMAIL";
-	//
-	// /**
-	// * Keep track of the login task to ensure we can cancel it if requested.
-	// */
-	// private UserLoginTask mAuthTask = null;
-	//
-	// // Values for email and password at the time of the login attempt.
-	// private String mUser;
-	// private String mPassword;
-	//
-	// // UI references.
-	// private EditText mUserView;
-	// private EditText mPasswordView;
-
-	// @Override
-	// protected void onCreate(Bundle savedInstanceState)
-	// {
-	// super.onCreate(savedInstanceState);
-	//
-	// setContentView(R.layout.activity_login);
-	//
-	// // Set up the login form.
-	// mUser = getIntent().getStringExtra(EXTRA_EMAIL);
-	// mUserView = (EditText) findViewById(R.id.email);
-	// mUserView.setText(mUser);
-	//
-	// mPasswordView = (EditText) findViewById(R.id.password);
-	// mPasswordView
-	// .setOnEditorActionListener(new TextView.OnEditorActionListener()
-	// {
-	// @Override
-	// public boolean onEditorAction(TextView textView, int id,
-	// KeyEvent keyEvent)
-	// {
-	// if (id == R.id.login || id == EditorInfo.IME_NULL)
-	// {
-	// attemptLogin();
-	// return true;
-	// }
-	// return false;
-	// }
-	// });
-	//
-	// mLoginFormView = findViewById(R.id.login_form);
-	// mLoginStatusView = findViewById(R.id.login_status);
-	// mLoginStatusMessageView = (TextView)
-	// findViewById(R.id.login_status_message);
-	//
-	// findViewById(R.id.sign_in_button).setOnClickListener(
-	// new View.OnClickListener()
-	// {
-	// @Override
-	// public void onClick(View view)
-	// {
-	// attemptLogin();
-	// }
-	// });
-	// }
-	//
-	// @Override
-	// public boolean onCreateOptionsMenu(Menu menu)
-	// {
-	// super.onCreateOptionsMenu(menu);
-	// getMenuInflater().inflate(R.menu.login, menu);
-	// return true;
-	// }
-	//
+	
 	// /**
 	// * Attempts to sign in or register the account specified by the login
 	// form.

+ 315 - 10
Apex/src/com/usai/apex/ResultActivity.java

@@ -1,51 +1,90 @@
 package com.usai.apex;
 
+import java.util.ArrayList;
+import java.util.HashMap;
+
+import org.json.JSONException;
+import org.json.JSONObject;
+
 import com.usai.util.Network;
 import com.usai.util.dbUtil;
 
+import android.R.bool;
+import android.R.integer;
+import android.os.AsyncTask;
+import android.os.Build;
 import android.os.Bundle;
+import android.animation.Animator;
+import android.animation.AnimatorListenerAdapter;
 import android.app.Activity;
 import android.content.Intent;
 import android.database.Cursor;
 import android.database.sqlite.SQLiteDatabase;
+import android.util.Log;
+import android.view.Gravity;
 import android.view.Menu;
 import android.view.MenuItem;
+import android.view.View;
 import android.widget.Button;
 import android.widget.TableRow;
+import android.widget.TextView;
+import android.widget.Toast;
 
 public class ResultActivity extends Activity
 {
 	String user = null;
 	String password = null;
-	String function_name=null;
+	String function_name = null;
+	private SearchTask m_task = null;
+
+	Bundle searchParms = null;
+	SearchResult searchresult = new SearchResult();
+
+	HashMap<String, Integer> showfieldmap = new HashMap<String, Integer>();
+	private TextView mStatusMessageView;
+	private View mSearchFormView;
+	private View mStatusView;
+
 	@Override
 	protected void onCreate(Bundle savedInstanceState)
 	{
 		user = getIntent().getStringExtra("user");
 		password = getIntent().getStringExtra("password");
 		function_name = getIntent().getStringExtra("function_name");
+		searchParms = getIntent().getBundleExtra("searchParms");
 		super.onCreate(savedInstanceState);
 		setContentView(R.layout.activity_result);
+		mSearchFormView = findViewById(R.id.search_form);
+		mStatusView = findViewById(R.id.status);
+		mStatusMessageView = (TextView) findViewById(R.id.status_message);
 		initTable();
+		requestdata(true);
 
 	}
+
 	void initTable()
 	{
 		SQLiteDatabase db = dbUtil.OpenDB(this, null, false);
 		Cursor cursor = db.query("fields_info",
-				new String[] { "aname", "_id" },
-				"function_name='"+function_name+"' and user='"+user+"' and behavior="+Network.BEHAVIOR_RESULT+" and show = 1",
-				 null, null, null, "priority , aname", null);
-		TableRow headerRow= (TableRow)findViewById(R.id.tr_header);
+				new String[] { "aname", "_id" }, "function_name='"
+						+ function_name + "' and user='" + user
+						+ "' and behavior=" + Network.BEHAVIOR_RESULT
+						+ " and show = 1", null, null, null,
+				"priority , aname", null);
+		TableRow headerRow = (TableRow) findViewById(R.id.tr_header);
+		int pos = 0;
+		showfieldmap.clear();
+		headerRow.removeAllViews();
 		while (cursor.moveToNext())
 		{
-			cursor.getString(0);
+			String aname = cursor.getString(0);
 			Button btn = new Button(this);
-			btn.setText(cursor.getString(0));
+			btn.setText(aname);
 			headerRow.addView(btn);
+			showfieldmap.put(aname, pos);
 		}
 		dbUtil.CloseCursor(cursor);
-		dbUtil.CloseDB(db);		
+		dbUtil.CloseDB(db);
 	}
 
 	@Override
@@ -55,6 +94,7 @@ public class ResultActivity extends Activity
 		getMenuInflater().inflate(R.menu.result, menu);
 		return true;
 	}
+
 	@Override
 	public boolean onOptionsItemSelected(MenuItem item)
 	{
@@ -64,10 +104,10 @@ public class ResultActivity extends Activity
 			Intent intent = new Intent();
 			intent.setClass(this, CustomizeFieldsActivity.class);
 			intent.putExtra("user", user);
-//			intent.putExtra("password", password);
+			// intent.putExtra("password", password);
 			intent.putExtra("function_name", function_name);
 			intent.putExtra("behavior", Network.BEHAVIOR_RESULT);
-			startActivity(intent);		
+			startActivity(intent);
 			break;
 
 		default:
@@ -75,4 +115,269 @@ public class ResultActivity extends Activity
 		}
 		return super.onOptionsItemSelected(item);
 	}
+
+	public void requestdata(boolean requestcount)
+	{
+		if (m_task != null)
+		{
+			return;
+		}
+		mStatusMessageView.setText(R.string.login_progress_signing_in);
+		showProgress(true);
+		m_task = new SearchTask();
+		m_task.execute(requestcount);
+
+	}
+
+	private void showProgress(final boolean show)
+	{
+		// On Honeycomb MR2 we have the ViewPropertyAnimator APIs, which allow
+		// for very easy animations. If available, use these APIs to fade-in
+		// the progress spinner.
+		if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2)
+		{
+			int shortAnimTime = getResources().getInteger(
+					android.R.integer.config_shortAnimTime);
+
+			mStatusView.setVisibility(View.VISIBLE);
+			mStatusView.animate().setDuration(shortAnimTime)
+					.alpha(show ? 1 : 0)
+					.setListener(new AnimatorListenerAdapter()
+					{
+						@Override
+						public void onAnimationEnd(Animator animation)
+						{
+							mStatusView.setVisibility(show ? View.VISIBLE
+									: View.INVISIBLE);
+						}
+					});
+
+			mSearchFormView.setVisibility(View.VISIBLE);
+			mSearchFormView.animate().setDuration(shortAnimTime)
+					.alpha(show ? 0 : 1)
+					.setListener(new AnimatorListenerAdapter()
+					{
+						@Override
+						public void onAnimationEnd(Animator animation)
+						{
+							mSearchFormView.setVisibility(show ? View.INVISIBLE
+									: View.VISIBLE);
+						}
+					});
+		}
+		else
+		{
+			// The ViewPropertyAnimator APIs are not available, so simply show
+			// and hide the relevant UI components.
+			mStatusView.setVisibility(show ? View.VISIBLE : View.INVISIBLE);
+			mSearchFormView.setVisibility(show ? View.INVISIBLE : View.VISIBLE);
+		}
+	}
+
+	public class SearchTask extends AsyncTask<Boolean, Void, Boolean>
+	{
+		// int err_code = ERR_CODE_NONE;
+		int errorcode;
+
+		@Override
+		protected Boolean doInBackground(Boolean... params)
+		{
+
+			if (!Network.NetworkIsAvailable())
+
+			{
+				errorcode = Network.RESULT_NET_NOTAVAILABLE;
+				return false;
+			}
+
+			if (params[0])
+			{
+				int ret = Network.get_recordcount(user, password, searchParms);
+				if (ret >= 0)
+				{
+					searchresult.put_totalcount(ret);
+				}
+				else
+				{
+					errorcode = ret;
+					return false;
+				}
+			}
+			if (true)
+				return true;
+			String jstr = Network.get_records(user, password, searchParms);
+			if (jstr == null || jstr.length() <= 0)
+			{
+				// Log.d(TAG, "json is wrong");
+				errorcode = Network.RESULT_NET_ERROR;
+				return false;
+			}
+
+			JSONObject jsobj;
+			//
+			// array = new JSONArray(json);
+			try
+			{
+				jsobj = new JSONObject(jstr);
+				if (searchresult.get_fieldscount() == 0)
+				{
+					JSONObject objfields = jsobj.getJSONObject("fields");
+					searchresult.init_fields(objfields.toString());
+				}
+				JSONObject objrecords = jsobj.getJSONObject("records");
+				searchresult.add_records(objrecords.toString());
+				errorcode = Network.RESULT_TRUE;
+				return true;
+
+			}
+			catch (JSONException e)
+			{
+				// TODO Auto-generated catch block
+				e.printStackTrace();
+			}
+			errorcode = Network.RESULT_NET_ERROR;
+			return false;
+
+		}
+
+		@Override
+		protected void onPostExecute(final Boolean success)
+		{
+			Log.i("onPostExecute", "entry");
+			m_task = null;
+			showProgress(false);
+
+			switch (errorcode)
+			{
+			case Network.RESULT_NET_NOTAVAILABLE:
+			{
+				Toast toast = Toast.makeText(getApplicationContext(),
+						getText(R.string.msg_connection_none),
+						Toast.LENGTH_LONG);
+				toast.setGravity(Gravity.CENTER, 0, 0);
+				toast.show();
+				return;
+			}
+			case Network.RESULT_NET_ERROR:
+			{
+				Toast toast = Toast.makeText(getApplicationContext(),
+						getText(R.string.msg_net_error), Toast.LENGTH_LONG);
+				toast.setGravity(Gravity.CENTER, 0, 0);
+				toast.show();
+				return;
+			}
+			case Network.RESULT_ERROR:
+			// case Network.RESULT_RESPONSE_NULL:
+			{
+				Toast toast = Toast.makeText(getApplicationContext(),
+						getText(R.string.msg_net_resulterror),
+						Toast.LENGTH_LONG);
+				toast.setGravity(Gravity.CENTER, 0, 0);
+				toast.show();
+				return;
+			}
+
+			default:
+				break;
+			}
+
+			if (success)
+			{
+
+				// SharedPreferences.Editor editor = RunOnce.edit();
+				// editor.putBoolean("FirstRun"+globalUtil.getVerName(this),
+				// false);
+				// // Don't forget to commit your edits!!!
+				// editor.commit();
+
+				// Intent intent = new Intent();
+				// intent.setClass(getActivity(), FunctionSelectActivity.class);
+				// intent.putExtra("user", m_sUser);
+				// intent.putExtra("password", m_sPassword);
+				// startActivity(intent);
+				// getActivity().finish();
+			}
+			else
+			{
+				// m_etPassword
+				// .setError(getString(R.string.error_incorrect_password));
+				// m_etPassword.requestFocus();
+			}
+		}
+
+		@Override
+		protected void onCancelled()
+		{
+			// mAuthTask = null;
+			// showProgress(false);
+		}
+	}
+
+	private class SearchResult
+	{
+		int total_count = 0;
+		// int count = 0;
+		ArrayList<record> records = new ArrayList<record>();
+		ArrayList<field> fields = new ArrayList<field>();
+
+		public void init_fields(String jsonfields)
+		{
+
+		}
+
+		public void add_records(String records)
+		{
+
+		}
+
+		public int get_totalcount()
+		{
+			return total_count;
+		}
+
+		public void put_totalcount(int c)
+		{
+			total_count = c;
+		}
+
+		public int get_count()
+		{
+			return records.size();
+		}
+
+		public int get_fieldscount()
+		{
+			return fields.size();
+		}
+
+		private class record
+		{
+			ArrayList<Object> values;
+
+		}
+
+		private class field
+		{
+			String name = null;
+			String aliasname = null;
+			String type = null;
+
+			public String get_name()
+			{
+				return name;
+			}
+
+			public String get_aliasname()
+			{
+				return aliasname;
+			}
+
+			public String get_type()
+			{
+				return type;
+			}
+
+		}
+
+	}
 }

+ 163 - 111
Apex/src/com/usai/apex/SearchActivity.java

@@ -1,28 +1,37 @@
 package com.usai.apex;
 
-import com.usai.apex.CustomizeFieldsActivity.fieldedit;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
 import com.usai.util.Network;
 import com.usai.util.dbUtil;
 
 import android.os.Bundle;
-import android.app.AlertDialog;
 import android.app.ListActivity;
 import android.content.Context;
-import android.content.DialogInterface;
 import android.content.Intent;
 import android.database.Cursor;
 import android.database.sqlite.SQLiteDatabase;
+import android.text.Editable;
 import android.text.InputType;
+import android.text.TextWatcher;
 import android.util.Log;
+import android.view.KeyEvent;
+import android.view.LayoutInflater;
 import android.view.Menu;
 import android.view.MenuItem;
 import android.view.View;
 import android.view.View.OnClickListener;
+import android.view.inputmethod.EditorInfo;
+import android.view.inputmethod.InputMethodManager;
+import android.view.ViewGroup;
 import android.widget.Button;
 import android.widget.EditText;
 import android.widget.ListView;
 import android.widget.SimpleCursorAdapter;
 import android.widget.Switch;
+import android.widget.TextView;
 
 public class SearchActivity extends ListActivity implements OnClickListener
 {
@@ -30,9 +39,10 @@ public class SearchActivity extends ListActivity implements OnClickListener
 	private Cursor m_cursor = null;
 	String user = null;
 	String password = null;
-	String function_name=null;
+	String function_name = null;
 	RecordsAdapter m_listadapter;
 	private ListView m_ListView = null;
+	HashMap<String, String> hashMap = new HashMap<String, String>();
 
 	public class RecordsAdapter extends SimpleCursorAdapter
 	{
@@ -44,29 +54,110 @@ public class SearchActivity extends ListActivity implements OnClickListener
 			// TODO Auto-generated constructor stub
 		}
 
+		// @Override
+		// public View getView(int position, View convertView, ViewGroup parent)
+		// {
+		// // if(true)
+		// // return super.getView(position, convertView, parent);
+		// if(convertView==null)
+		// convertView = LayoutInflater.from(getApplication()).inflate(
+		// R.layout.search_lvitem_edit, null);
+		// // holder = new ViewHolder();
+		// // holder.textView = (TextView)convertView.findViewById(R.id.text);
+		// // convertView.setTag(holder);
+		// final int pos=position;
+		// // convertView = LayoutInflater.from(getApplication()).inflate(
+		// // R.layout.search_lvitem_edit, null);
+		//
+		// EditText editText = (EditText) convertView
+		// .findViewById(R.id.edit_val);
+		// // editText.setText(str);
+		//
+		// // 涓篹ditText璁剧疆TextChangedListener锛屾瘡娆℃敼鍙樼殑鍊艰�缃�埌hashMap
+		// // 鎴戜滑瑕佹嬁鍒伴噷闈㈢殑鍊兼牴鎹畃osition鎷垮€�
+		// editText.addTextChangedListener(new TextWatcher()
+		// {
+		// @Override
+		// public void onTextChanged(CharSequence s, int start,
+		// int before, int count)
+		// {
+		//
+		// }
+		//
+		// @Override
+		// public void beforeTextChanged(CharSequence s, int start,
+		// int count, int after)
+		// {
+		//
+		// }
+		//
+		// @Override
+		// public void afterTextChanged(Editable s)
+		// {
+		// // int a = position;
+		// // 灏唀ditText涓�敼鍙樼殑鍊艰�缃�殑HashMap涓�
+		// hashMap.put(pos, s.toString());
+		// }
+		// });
+		//
+		// // // 濡傛灉hashMap涓嶄负绌猴紝灏辫�缃�殑editText
+		// // if (hashMap.get(position) != null)
+		// // {
+		// // editText.setText(hashMap.get(position));
+		// // }
+		// return convertView;
+		// }
+
 		@Override
 		public void bindView(View view, Context context, Cursor cursor)
 		{
-			// TODO Auto-generated method stub
-			super.bindView(view, context, cursor);
 			String field_type = cursor.getString(1);
+			final String name = cursor.getString(2);
 			EditText edit = (EditText) view.findViewById(R.id.edit_val);
+			edit.addTextChangedListener(new TextWatcher()
+			{
+				@Override
+				public void onTextChanged(CharSequence s, int start,
+						int before, int count)
+				{
+
+				}
+
+				@Override
+				public void beforeTextChanged(CharSequence s, int start,
+						int count, int after)
+				{
+
+				}
+
+				@Override
+				public void afterTextChanged(Editable s)
+				{
+					// 灏唀ditText涓�敼鍙樼殑鍊艰�缃�殑HashMap涓�
+					String val = s.toString();
+					val.trim();
+					if (val.length() > 0)
+						hashMap.put(name, val);
+				}
+			});
 			Switch switch_bool = (Switch) view.findViewById(R.id.switch_bool);
-			if(field_type.equals("boolean"))
+			if (field_type.equals("boolean"))
 			{
 				edit.setVisibility(View.GONE);
 				switch_bool.setVisibility(View.VISIBLE);
 			}
-			else {
+			else
+			{
 				edit.setVisibility(View.VISIBLE);
-				switch_bool.setVisibility(View.GONE);	
-				if(field_type.equals("time"))
+				switch_bool.setVisibility(View.GONE);
+				if (field_type.equals("time"))
 				{
-//					EditText edit1 = (EditText) view.findViewById(R.id.editText1);
-//					Log.e("!!!!!!!!!!!!!",edit1.getInputType()+"##########"+(InputType.TYPE_DATETIME_VARIATION_DATE|InputType.TYPE_CLASS_DATETIME));
-					edit.setInputType(InputType.TYPE_DATETIME_VARIATION_DATE|InputType.TYPE_CLASS_DATETIME);
+					edit.setInputType(InputType.TYPE_DATETIME_VARIATION_DATE
+							| InputType.TYPE_CLASS_DATETIME);
 				}
 			}
+			super.bindView(view, context, cursor);
+
 			// TextView tvname = (TextView) view.findViewById(R.id.name);
 			// TextView tvinfo = (TextView) view.findViewById(R.id.info);
 			// String sname = cursor.getString(1);
@@ -109,13 +200,14 @@ public class SearchActivity extends ListActivity implements OnClickListener
 		function_name = getIntent().getStringExtra("function_name");
 		setContentView(R.layout.activity_search);
 		m_db = dbUtil.OpenDB(this, null, true);
-//		m_TextView = (TextView) findViewById(R.id.summarytext);
-//		m_TextView.setText(getString(m_Activityinfo.TextViewValue));
+		// m_TextView = (TextView) findViewById(R.id.summarytext);
+		// m_TextView.setText(getString(m_Activityinfo.TextViewValue));
 		m_ListView = (ListView) findViewById(android.R.id.list);
-		m_cursor = m_db.query("fields_info",
-				new String[] { "aname","field_type", "name", "_id" },
-				"function_name='"+function_name+"' and user='"+user+"' and behavior="+Network.BEHAVIOR_SEARCH+" and show = 1",
-				 null, null, null, "priority , aname", null);
+		m_cursor = m_db.query("fields_info", new String[] { "aname",
+				"field_type", "name", "_id" }, "function_name='"
+				+ function_name + "' and user='" + user + "' and behavior="
+				+ Network.BEHAVIOR_SEARCH + " and show = 1", null, null, null,
+				"priority , aname", null);
 		startManagingCursor(m_cursor);
 		m_listadapter = new RecordsAdapter(this,
 		// Use a template that displays a text view
@@ -125,13 +217,13 @@ public class SearchActivity extends ListActivity implements OnClickListener
 				// Map the NAME column in the people database to...
 				new String[] { "aname", "field_type", "name" },
 				// The "text1" view defined in the XML template
-				new int[] {R.id.aliasName, R.id.tv_type });
-		setListAdapter(m_listadapter);	
-		Button btnok= (Button)findViewById(R.id.btnok);
+				new int[] { R.id.aliasName, R.id.tv_type });
+		setListAdapter(m_listadapter);
+		Button btnok = (Button) findViewById(R.id.btnok);
 		btnok.setOnClickListener(this);
-		Button btncancel= (Button)findViewById(R.id.btncancel);
-		btncancel.setOnClickListener(this);		
-//		initlist();
+		Button btncancel = (Button) findViewById(R.id.btncancel);
+		btncancel.setOnClickListener(this);
+		// initlist();
 
 		// m_ListView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
 
@@ -148,36 +240,40 @@ public class SearchActivity extends ListActivity implements OnClickListener
 		// m_iViewIDs);
 
 	}
+
 	private void RefreshList()
 	{
-//		if (dbUtil.isRecordExist(m_db, "user_numberlist","type = "+m_Activityinfo.NumberType))
-//		{
-//			m_TextView.setVisibility(ListView.INVISIBLE);
-//			m_ListView.setVisibility(ListView.VISIBLE);
-//
-//		}
-//		else
-//		{
-//			m_TextView.setVisibility(ListView.VISIBLE);
-//			m_ListView.setVisibility(ListView.INVISIBLE);
-//		}
-
+		// if (dbUtil.isRecordExist(m_db,
+		// "user_numberlist","type = "+m_Activityinfo.NumberType))
+		// {
+		// m_TextView.setVisibility(ListView.INVISIBLE);
+		// m_ListView.setVisibility(ListView.VISIBLE);
+		//
+		// }
+		// else
+		// {
+		// m_TextView.setVisibility(ListView.VISIBLE);
+		// m_ListView.setVisibility(ListView.INVISIBLE);
+		// }
+		hashMap.clear();
 		m_cursor.requery();
 	}
-//	private void initlist()
-//	{
-//		m_ListView = (ListView) findViewById(android.R.id.list);
-//		ArrayList<HashMap<String, Object>> list = new ArrayList<HashMap<String, Object>>();
-//		HashMap<String, Object> map = null;
-//
-//		String[] strings = { "alias", "type", "name" };// Map的key集合数组
-//		int[] ids = { R.id.aliasName, R.id.tv_type };// 对应布局文件的id
-//		SimpleAdapter simpleAdapter = new SimpleAdapter(this, list,
-//				R.layout.search_lvitem_edit, strings, ids);
-//
-//		// listView1.setAdapter(simpleAdapter);//绑定适配器
-//		setListAdapter(simpleAdapter);
-//	}
+
+	// private void initlist()
+	// {
+	// m_ListView = (ListView) findViewById(android.R.id.list);
+	// ArrayList<HashMap<String, Object>> list = new ArrayList<HashMap<String,
+	// Object>>();
+	// HashMap<String, Object> map = null;
+	//
+	// String[] strings = { "alias", "type", "name" };// Map鐨刱ey闆嗗悎鏁扮粍
+	// int[] ids = { R.id.aliasName, R.id.tv_type };// 瀵瑰簲甯冨眬鏂囦欢鐨刬d
+	// SimpleAdapter simpleAdapter = new SimpleAdapter(this, list,
+	// R.layout.search_lvitem_edit, strings, ids);
+	//
+	// // listView1.setAdapter(simpleAdapter);//缁戝畾閫傞厤鍣�
+	// setListAdapter(simpleAdapter);
+	// }
 
 	@Override
 	public boolean onCreateOptionsMenu(Menu menu)
@@ -196,10 +292,10 @@ public class SearchActivity extends ListActivity implements OnClickListener
 			Intent intent = new Intent();
 			intent.setClass(this, CustomizeFieldsActivity.class);
 			intent.putExtra("user", user);
-//			intent.putExtra("password", password);
+			// intent.putExtra("password", password);
 			intent.putExtra("function_name", function_name);
 			intent.putExtra("behavior", Network.BEHAVIOR_SEARCH);
-			startActivity(intent);		
+			startActivity(intent);
 			break;
 
 		default:
@@ -220,62 +316,20 @@ public class SearchActivity extends ListActivity implements OnClickListener
 			intent.putExtra("user", user);
 			intent.putExtra("password", password);
 			intent.putExtra("function_name", function_name);
-//			intent.putExtra("behavior", Network.be);
-			startActivity(intent);		
-//			DragListView dragListView = (DragListView) findViewById(R.id.drag_list);
-//			int count=0;
-//			for(int i=0;i<adapter.getCount();i++)
-//			{
-//				fieldedit fe=adapter.getItem(i);
-//				if(fe._id==-2||count>0)
-//					break;
-//				if(fe._id>=0)
-//					count++;
-//				
-//			}
-//			if(count==0)
-//			{
-//				new AlertDialog.Builder(CustomizeFieldsActivity.this)
-//				.setIcon(android.R.drawable.ic_dialog_info)
-//				.setTitle("Error!")
-//				.setMessage("You must set at least 1 field visiable!")
-//				.setPositiveButton("OK",
-//						new DialogInterface.OnClickListener()
-//						{
-//							public void onClick(
-//									DialogInterface dialog,
-//									int whichButton)
-//							{
-//
-////								finish();
-//								/* User clicked OK so do some stuff */
-//							}
-//						}).show();
-//				break;
-//				
-//			}
-//			
-//			int show = 1;
-//			SQLiteDatabase db= dbUtil.OpenDB(this, null, true);
-//			db.beginTransaction();
-//			for(int i=0;i<adapter.getCount();i++)
-//			{
-//				fieldedit fe=adapter.getItem(i);
-//				if(fe._id==-2)//hide group begin
-//				{
-//					show = 0;
-//				}
-//				if(show==1)
-//					db.execSQL("update fields_info set show="+show+" ,priority="+i+" where _id="+fe._id);
-//				else
-//					db.execSQL("update fields_info set show="+show+" where _id="+fe._id);
-//					
-//			}
-//			db.setTransactionSuccessful();
-//			db.endTransaction();
-//			dbUtil.CloseDB(db);
-//			finish();
-////			Log.d("fields",);
+			Bundle parms = new Bundle();
+			Iterator iter = hashMap.keySet().iterator();
+			while (iter.hasNext())
+			{
+				String field = (String) iter.next();
+				String val = (String) hashMap.get(field);
+				parms.putString(field, val);
+				// Cursor c = (Cursor) m_listadapter.getItem(key);
+				Log.d("@@@@@@@@@", field + " : " + val);
+			}
+			intent.putExtra("searchParms", parms);
+
+			startActivity(intent);
+
 			break;
 		}
 		case R.id.btncancel:
@@ -285,8 +339,6 @@ public class SearchActivity extends ListActivity implements OnClickListener
 			break;
 		}
 
-		
-		
 	}
 
 	// class FieldsAdapter extends SimpleAdapter

+ 279 - 145
Apex/src/com/usai/util/Network.java

@@ -61,7 +61,7 @@ public class Network
 {
 	public static final int BEHAVIOR_SEARCH = 0;
 	public static final int BEHAVIOR_RESULT = 1;
-	
+
 	private static final int REQUEST_TIMEOUT = 5 * 1000;// request time out 20
 														// secs
 	private static final int SO_TIMEOUT = 5 * 1000; // so time out 20 secs;
@@ -74,13 +74,14 @@ public class Network
 	public static int AP_UPLOAD_FAIL = 5;
 	//
 	public static final int RESULT_FALSE = 0;
-	public static final int RESULT_TRUE = 1;
-	public static final int RESULT_NET_ERROR = 3;
-	public static final int RESULT_NET_NOTAVAILABLE = 4;
-	public static final int RESULT_ERROR = 5;
-	public static final int RESULT_LOCALFILE_ERROR = 7;
-	public static final int RESULT_USERAUTH_ERROR = 9;
-	public static final int RESULT_UPDATE_USERAUTH_ERROR = 11;
+	public static final int RESULT_TRUE = -1;
+	public static final int RESULT_NET_ERROR = -3;
+	public static final int RESULT_NET_NOTAVAILABLE = -4;
+	public static final int RESULT_ERROR = -5;
+	public static final int RESULT_LOCALFILE_ERROR = -7;
+	public static final int RESULT_USERAUTH_ERROR = -9;
+	public static final int RESULT_UPDATE_USERAUTH_ERROR = -11;
+	public static final int RESULT_SESSION_EXPIRED = -13;
 	// public static final int RESULT_NOCONNECT = 2;
 	// public static final int RESULT_CONNECT = 3;
 	// public static final int RESULT_TIMEOUT = 4;
@@ -101,89 +102,93 @@ public class Network
 	// "http://192.168.1.10/xampp/verify_user.php";
 	// static String URL_UPLOAD_PHOTO =
 	// "http://192.168.1.10/xampp/save_upload_file.php";
-//	public static String URL_VERIFY_USER = "https://ra.apexshipping.com/login.php";
+	// public static String URL_VERIFY_USER =
+	// "https://ra.apexshipping.com/login.php";
 	public static String URL_UPDATE_AUTH = "https://ra.apexshipping.com/login.php";
 	public static String URL_REQUEST_COUNT = "https://ra.apexshipping.com/main.php";
-//	public static String FAKE_URL_UPDATE_AUTH = "https://192.168.23.1/xampp/auth.json";
-//	public static String FAKE_SEARCH = "https://192.168.23.1/xampp/recordset.json";
+	public static String URL_REQUEST_RECORDS = "https://ra.apexshipping.com/main.php";
+
+	// public static String FAKE_URL_UPDATE_AUTH =
+	// "https://192.168.23.1/xampp/auth.json";
+	// public static String FAKE_SEARCH =
+	// "https://192.168.23.1/xampp/recordset.json";
 
 	// static String URL_UPLOAD_PHOTO =
 	// "http://192.168.23.1/xampp/save_upload_file.php";
 	//
-//	 private static String fakegetJson(String url)
-//	 {
-//	 return download(url, 10000);
-//	 // return null;
-//	
-//	 }
-//
-//	public static String download(String urlStr, int timeout)
-//	{
-//		String TAG = "net_dbg@download";
-//
-//		Log.d(TAG, urlStr);
-//
-//		StringBuffer sb = new StringBuffer();
-//		String line = null;
-//		BufferedReader buffer = null;
-//		HttpURLConnection urlConn = null;
-//		try
-//		{
-//			// 创建一个URL对象
-//			URL url = new URL(urlStr);
-//			// 创建一个Http连接
-//			urlConn = (HttpURLConnection) url.openConnection();
-//
-//			urlConn.setConnectTimeout(timeout);
-//			urlConn.setReadTimeout(timeout);
-//			// urlConn.connect();
-//
-//			int irespon = urlConn.getResponseCode();
-//			if (irespon != HttpURLConnection.HTTP_OK)
-//			{
-//				Log.e(TAG, "HTTP ERROR CODE " + irespon + " url: " + urlStr);
-//				urlConn.disconnect();
-//				return null;
-//			}
-//
-//			// 使用IO流读取数据
-//			buffer = new BufferedReader(new InputStreamReader(
-//					urlConn.getInputStream()));
-//			while ((line = buffer.readLine()) != null)
-//			{
-//				sb.append(line);
-//			}
-//			Log.d(TAG, "download success @" + urlStr);
-//		}
-//		catch (MalformedURLException e)
-//		{
-//			// TODO Auto-generated catch block
-//			e.printStackTrace();
-//		}
-//		catch (IOException e)
-//		{
-//			// TODO Auto-generated catch block
-//			e.printStackTrace();
-//		}
-//
-//		finally
-//		{
-//			try
-//			{
-//				if (urlConn != null)
-//					urlConn.disconnect();
-//				if (buffer != null)
-//					buffer.close();
-//			}
-//			catch (Exception e)
-//			{
-//				e.printStackTrace();
-//			}
-//
-//		}
-//		return sb.toString();
-//	}
-	
+	// private static String fakegetJson(String url)
+	// {
+	// return download(url, 10000);
+	// // return null;
+	//
+	// }
+	//
+	// public static String download(String urlStr, int timeout)
+	// {
+	// String TAG = "net_dbg@download";
+	//
+	// Log.d(TAG, urlStr);
+	//
+	// StringBuffer sb = new StringBuffer();
+	// String line = null;
+	// BufferedReader buffer = null;
+	// HttpURLConnection urlConn = null;
+	// try
+	// {
+	// // 创建一个URL对象
+	// URL url = new URL(urlStr);
+	// // 创建一个Http连接
+	// urlConn = (HttpURLConnection) url.openConnection();
+	//
+	// urlConn.setConnectTimeout(timeout);
+	// urlConn.setReadTimeout(timeout);
+	// // urlConn.connect();
+	//
+	// int irespon = urlConn.getResponseCode();
+	// if (irespon != HttpURLConnection.HTTP_OK)
+	// {
+	// Log.e(TAG, "HTTP ERROR CODE " + irespon + " url: " + urlStr);
+	// urlConn.disconnect();
+	// return null;
+	// }
+	//
+	// // 使用IO流读取数据
+	// buffer = new BufferedReader(new InputStreamReader(
+	// urlConn.getInputStream()));
+	// while ((line = buffer.readLine()) != null)
+	// {
+	// sb.append(line);
+	// }
+	// Log.d(TAG, "download success @" + urlStr);
+	// }
+	// catch (MalformedURLException e)
+	// {
+	// // TODO Auto-generated catch block
+	// e.printStackTrace();
+	// }
+	// catch (IOException e)
+	// {
+	// // TODO Auto-generated catch block
+	// e.printStackTrace();
+	// }
+	//
+	// finally
+	// {
+	// try
+	// {
+	// if (urlConn != null)
+	// urlConn.disconnect();
+	// if (buffer != null)
+	// buffer.close();
+	// }
+	// catch (Exception e)
+	// {
+	// e.printStackTrace();
+	// }
+	//
+	// }
+	// return sb.toString();
+	// }
 
 	private static HttpClient getNewHttpClient()
 	{
@@ -273,8 +278,8 @@ public class Network
 		String TAG = "net_dbg@GetJson";
 		Log.d(TAG, "entry");
 
-//		 if (true)
-//		 return fakegetJson(url);
+		// if (true)
+		// return fakegetJson(url);
 		try
 		{
 			// BasicHttpParams httpParams = new BasicHttpParams();
@@ -825,30 +830,142 @@ public class Network
 	// // }
 	// // return 0;
 	// }
-	public static String get_count(String name,String password,Bundle parms)
+	public static int get_recordcount(String name, String password, Bundle parms)
 	{
-		String TAG = "net_dbg@get_count";
-//		parms.putString("user", name);
-//		parms.putString("password", password);
-		if (!Network.NetworkIsAvailable())
-		{
-			Log.d(TAG, "network not available!");
-			return "Network.RESULT_NET_NOTAVAILABLE"; // network not available
-		}		
+		String TAG = "net_dbg@get_recordcount";
+		// parms.putString("user", name);
+		// parms.putString("password", password);
+		// if (!Network.NetworkIsAvailable())
+		// {
+		// Log.d(TAG, "network not available!");
+		// return Network.RESULT_NET_NOTAVAILABLE; // network not available
+		// }
 		parms.putString("action", "handset_search_count");
+		parms.putString("sessionid", ApexTrackingApplication.get_sessionid());
 		String jstr = getJson(Network.URL_REQUEST_COUNT, parms);
 		if (jstr == null || jstr.length() <= 0)
 		{
 			Log.d(TAG, "json is wrong");
-			return "Network.RESULT_NET_ERROR";
+			return Network.RESULT_NET_ERROR;
 		}
-		return jstr;
+		JSONObject jsobj;
+
+		// array = new JSONArray(json);
+		try
+		{
+			jsobj = new JSONObject(jstr);
+			if (jsobj.length() > 0)
+			{
+				if (jsobj.getInt("result") != Network.AP_USER_AUTH)
+				{
+					// session expired
+					Log.d(TAG,
+							"USER NOT AUTHORIZED CODE="
+									+ jsobj.getInt("result"));
+					return RESULT_SESSION_EXPIRED;
+					// if (get_Auth(name, password) == RESULT_TRUE)
+					// {
+					// return get_recordcount(name, password, parms);
+					//
+					// }
+					// else
+					// {
+					//
+					// Log.d(TAG,
+					// "USER NOT AUTHORIZED CODE="
+					// + jsobj.getInt("result"));
+					// return RESULT_SESSION_EXPIRED;
+					// }
+				}
+				else
+				{
+					return jsobj.getInt("count");
+				}
+			}
+			else
+			{
+				Log.d(TAG, "json is wrong");
+				return Network.RESULT_NET_ERROR;
+			}
+		}
+		catch (JSONException e)
+		{
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+
+		return RESULT_ERROR;
+	}
+
+	public static String get_records(String name, String password, Bundle parms)
+	{
+		String TAG = "net_dbg@get_records";
+		// parms.putString("user", name);
+		// parms.putString("password", password);
+		// if (!Network.NetworkIsAvailable())
+		// {
+		// Log.d(TAG, "network not available!");
+		// return "Network.RESULT_NET_NOTAVAILABLE"; // network not available
+		// }
+		parms.putString("action", "handset_search");
+		parms.putString("sessionid", ApexTrackingApplication.get_sessionid());
+		String jstr = getJson(Network.URL_REQUEST_RECORDS, parms);
+		if (jstr == null || jstr.length() <= 0)
+		{
+			Log.d(TAG, "json is wrong");
+			return null;
+		}
+		JSONObject jsobj;
+		//
+		// array = new JSONArray(json);
+		try
+		{
+			jsobj = new JSONObject(jstr);
+			if (jsobj.length() > 0)
+			{
+				if (jsobj.getInt("result") != Network.AP_USER_AUTH)
+				{
+					// session expired
+					if (get_Auth(name, password) == RESULT_TRUE)
+					{
+						return get_records(name, password, parms);
+
+					}
+					else
+					{
+
+						Log.d(TAG,
+								"USER NOT AUTHORIZED CODE="
+										+ jsobj.getInt("result"));
+						return null;
+					}
+				}
+				else
+				{
+					return jstr;
+				}
+			}
+			else
+			{
+				Log.d(TAG, "json is wrong");
+				return null;
+			}
+		}
+		catch (JSONException e)
+		{
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+		return null;
+
+		// return RESULT_ERROR;
 	}
+
 	public static int get_Auth(String name, String password)
 	{
 
 		String TAG = "net_dbg@get_Auth";
-		Log.d(TAG,"u:"+name+";p:"+password);
+		Log.d(TAG, "u:" + name + ";p:" + password);
 		if (!Network.NetworkIsAvailable())
 		{
 			Log.d(TAG, "network not available!");
@@ -873,13 +990,13 @@ public class Network
 			return Network.RESULT_NET_ERROR;
 		}
 
-		return parse_authinfo(jstr,name);
+		return parse_authinfo(jstr, name);
 	}
 
-	private static int parse_authinfo(String json,String user)
+	private static int parse_authinfo(String json, String user)
 	{
 		String TAG = "net_dbg@parse_authinfo";
-		Log.d(TAG,json);
+		Log.d(TAG, json);
 		// JSONArray array;
 		JSONObject jsobj;
 		SQLiteDatabase db = null;
@@ -911,6 +1028,7 @@ public class Network
 				// server;
 				ApexTrackingApplication.put_sessionid(objheader
 						.getString("sessionid"));
+				Log.d(TAG, "sessionid=" + objheader.getString("sessionid"));
 				// JSONObject objupdate = array.getJSONObject(3); // whether
 				// need
 				// update ;
@@ -931,78 +1049,94 @@ public class Network
 				editor.putInt("AuthInfoVer", objheader.getInt("ver"));
 				JSONObject objfuncs = jsobj.getJSONObject("functions");
 				Iterator it = objfuncs.keys();
-				db = dbUtil.OpenDB(ApexTrackingApplication
-						.get_instance(), null, true);
+				db = dbUtil.OpenDB(ApexTrackingApplication.get_instance(),
+						null, true);
 				String sql = "insert into fields_info(name,aname,field_type,function_name,behavior,priority,show,user) values(?,?,?,?,?,?,?,?)";
-				db.execSQL("update fields_info set abandon = 1 where user ='"+user+"'");
-		        SQLiteStatement stat = db.compileStatement(sql);
+				db.execSQL("update fields_info set abandon = 1 where user ='"
+						+ user + "'");
+				SQLiteStatement stat = db.compileStatement(sql);
 				db.beginTransaction();
-				String field_name,field_type,alias_name;
+				String field_name, field_type, alias_name;
 				while (it.hasNext()) // loop for each function
 				{
 					String func_name = (String) it.next();
-					 
+
 					// Set<String> funset = new HashSet<String>();
 					JSONObject objfun = objfuncs.getJSONObject(func_name);
-					int behavior,priority=999;
+					int behavior, priority = 999;
 					int show = 1;
 					JSONObject objbehavior = objfun.getJSONObject("search");
 					Iterator itbehavior = objbehavior.keys();
 					behavior = BEHAVIOR_SEARCH;
-					while(itbehavior.hasNext()) //loop for search fields in certain function
+					while (itbehavior.hasNext()) // loop for search fields in
+													// certain function
 					{
 						String field = (String) itbehavior.next();
-						JSONObject field_info = objbehavior.getJSONObject(field);
+						JSONObject field_info = objbehavior
+								.getJSONObject(field);
 						field_name = field_info.getString("name");
 						field_type = field_info.getString("type");
 						alias_name = field_info.getString("alias");
-						int id=dbUtil.get_recordid(db, "fields_info", "name='"+field_name+"' and behavior="+behavior+" and function_name='"+func_name+"' and user='"+user+"'");
-						if(id>=0) // record exist;
+						int id = dbUtil.get_recordid(db, "fields_info",
+								"name='" + field_name + "' and behavior="
+										+ behavior + " and function_name='"
+										+ func_name + "' and user='" + user
+										+ "'");
+						if (id >= 0) // record exist;
 						{
-							db.execSQL("update fields_info set abandon = 0 where _id ="+id);
+							db.execSQL("update fields_info set abandon = 0 where _id ="
+									+ id);
 						}
-						else {
-				            stat.bindString(1, field_name);
-				            stat.bindString(2, alias_name);
-				            stat.bindString(3, field_type);
-				            stat.bindString(4, func_name);
-				            stat.bindLong(5, behavior);
-				            stat.bindLong(6, priority);
-				            stat.bindLong(7, show);
-				            stat.bindString(8, user);
-				            stat.executeInsert();
+						else
+						{
+							stat.bindString(1, field_name);
+							stat.bindString(2, alias_name);
+							stat.bindString(3, field_type);
+							stat.bindString(4, func_name);
+							stat.bindLong(5, behavior);
+							stat.bindLong(6, priority);
+							stat.bindLong(7, show);
+							stat.bindString(8, user);
+							stat.executeInsert();
 						}
 					}
-					
-					
+
 					objbehavior = objfun.getJSONObject("result");
 					Iterator itresult = objbehavior.keys();
 					behavior = BEHAVIOR_RESULT;
-					while(itresult.hasNext()) //loop for result fields in certain function
+					while (itresult.hasNext()) // loop for result fields in
+												// certain function
 					{
 						String field = (String) itresult.next();
-						JSONObject field_info = objbehavior.getJSONObject(field);
+						JSONObject field_info = objbehavior
+								.getJSONObject(field);
 						field_name = field_info.getString("name");
 						field_type = field_info.getString("type");
 						alias_name = field_info.getString("alias");
-						int id=dbUtil.get_recordid(db, "fields_info", "name='"+field_name+"' and behavior="+behavior+" and function_name='"+func_name+"' and user='"+user+"'");
-						if(id>=0) // record exist;
+						int id = dbUtil.get_recordid(db, "fields_info",
+								"name='" + field_name + "' and behavior="
+										+ behavior + " and function_name='"
+										+ func_name + "' and user='" + user
+										+ "'");
+						if (id >= 0) // record exist;
 						{
-							db.execSQL("update fields_info set abandon = 0 where _id ="+id);
+							db.execSQL("update fields_info set abandon = 0 where _id ="
+									+ id);
 						}
-						else {
-				            stat.bindString(1, field_name);
-				            stat.bindString(2, alias_name);
-				            stat.bindString(3, field_type);
-				            stat.bindString(4, func_name);
-				            stat.bindLong(5, behavior);
-				            stat.bindLong(6, priority);
-				            stat.bindLong(7, show);
-				            stat.bindString(8, user);
-				            stat.executeInsert();
+						else
+						{
+							stat.bindString(1, field_name);
+							stat.bindString(2, alias_name);
+							stat.bindString(3, field_type);
+							stat.bindString(4, func_name);
+							stat.bindLong(5, behavior);
+							stat.bindLong(6, priority);
+							stat.bindLong(7, show);
+							stat.bindString(8, user);
+							stat.executeInsert();
 						}
 					}
-//					editor.putString(func_name, objfun.toString());
+					// editor.putString(func_name, objfun.toString());
 					// JSONArray arrfun = jsobj.get(i);
 					// JSONObject objname = arrfun.getJSONObject(0);
 					//
@@ -1022,9 +1156,9 @@ public class Network
 					// }
 				}
 				db.execSQL("delete from fields_info where abandon = 1");
-		        db.setTransactionSuccessful();
-		        db.endTransaction();
-		        editor.commit();
+				db.setTransactionSuccessful();
+				db.endTransaction();
+				editor.commit();
 				return RESULT_TRUE;
 			}
 			Log.d(TAG, "json is wrong");