Ray Zhang %!s(int64=12) %!d(string=hai) anos
pai
achega
900efcd59d

+ 5 - 4
Apex/AndroidManifest.xml

@@ -2,7 +2,7 @@
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
     package="com.usai.apex"
     android:versionCode="1"
-    android:versionName="A140218" >
+    android:versionName="A140219" >
 
     <!-- Copied from Google Maps Library/AndroidManifest.xml. -->
     <uses-sdk
@@ -40,11 +40,11 @@
             android:name="com.usai.apex.DetailActivity"
             android:label="@string/title_activity_detail"
             android:screenOrientation="landscape" >
-            <meta-data
+      <!--       <meta-data
                 android:name="android.support.PARENT_ACTIVITY"
                 android:value="android.support.v4.app.FragmentActivity" />
 
-            <!--
+           
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
 
@@ -130,7 +130,8 @@
         </activity>
         <activity
             android:name="com.usai.apex.AboutActivity"
-            android:label="@string/title_activity_about" >
+            android:label="@string/title_activity_about" 
+            >
         </activity>
     </application>
 

+ 1 - 1
Apex/res/layout/drag_list_item.xml

@@ -20,6 +20,6 @@
         android:layout_height="wrap_content"
         android:layout_alignParentRight="true"
         android:layout_centerVertical="true"
-        android:src="@drawable/ic_launcher" />
+        android:src="@drawable/ic_drag" />
 
 </RelativeLayout>

+ 10 - 0
Apex/res/layout/dropdown_item.xml

@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<TextView xmlns:android="http://schemas.android.com/apk/res/android" 
+    android:id="@+id/drop_item"
+    style="?android:attr/dropDownItemStyle"
+    android:textAppearance="?android:attr/textAppearanceLargePopupMenu"
+    android:singleLine="true"
+    android:layout_width="match_parent"
+    android:layout_height="?android:attr/listPreferredItemHeight"
+    android:ellipsize="marquee" />

+ 3 - 4
Apex/res/layout/new_function_select.xml

@@ -40,8 +40,8 @@
                />
     </RadioGroup>
 
-    <EditText
-        android:id="@+id/et_criterion"
+    <AutoCompleteTextView
+        android:id="@+id/atv_criterion"
         android:layout_width="fill_parent"
         android:layout_height="wrap_content"
         android:hint="@string/prompt_search_criterion"
@@ -50,8 +50,7 @@
         android:singleLine="true" 
         >
 
-        <requestFocus />
-    </EditText>
+    </AutoCompleteTextView>
 
     <Button
         android:id="@+id/btn_search"

+ 2 - 0
Apex/src/com/usai/apex/AboutActivity.java

@@ -20,6 +20,8 @@ public class AboutActivity extends Activity {
 
 	@Override
 	protected void onCreate(Bundle savedInstanceState) {
+		Log.e("AboutActivity", "onCreate");
+
 		super.onCreate(savedInstanceState);
 		setContentView(R.layout.activity_about);
 		final TextView tv_ver = (TextView)findViewById(R.id.tv_version);

+ 6 - 0
Apex/src/com/usai/apex/ApexActivity.java

@@ -2,6 +2,8 @@ package com.usai.apex;
 
 //import com.google.android.gms.maps.SupportMapFragment;
 
+import java.util.List;
+
 import android.app.ActionBar;
 import android.content.Intent;
 import android.os.Bundle;
@@ -10,6 +12,7 @@ import android.os.Bundle;
 import android.support.v4.app.Fragment;
 import android.support.v4.app.FragmentActivity;
 import android.support.v4.app.FragmentTransaction;
+import android.util.Log;
 import android.view.KeyEvent;
 import android.view.Menu;
 import android.view.MenuItem;
@@ -37,11 +40,14 @@ public class ApexActivity extends FragmentActivity /*
 
 	@Override
 	protected void onCreate(Bundle savedInstanceState) {
+		Log.e("ApexActivity", "onCreate");
 		super.onCreate(savedInstanceState);
 		setContentView(R.layout.activity_apex);
 		ActionBar bar = getActionBar();
 		bar.setTitle("");
 		setupTabs();
+		
+		
 	}
 
 //	@Override

+ 80 - 46
Apex/src/com/usai/apex/DetailActivity.java

@@ -26,16 +26,22 @@ public class DetailActivity extends FragmentActivity implements
 		TabHost.TabContentFactory
 {
 	// int radomid = 1 + (int) (Math.random() * 15);
-	TabHost mTabHost;
-	LinkedHashMap<String, Integer> tabmap = new LinkedHashMap<String, Integer>();
+	TabHost							mTabHost;
+	LinkedHashMap<String, Integer>	tabmap	= new LinkedHashMap<String, Integer>();
+	HashMap<String,String> contentmap = new HashMap<String ,String>();
 
 	// HashMap<String, DetailFragment> fragments = new HashMap<String,
 	// DetailFragment>();
-	String function_name;
-	String _id;
-	String cargo_criterion;
-	int criterion_type;
+	String							function_name;
+	String							_id;
+	String							cargo_criterion;
+	int								criterion_type;
 
+	public void save_content(String which,String content)
+	{
+		contentmap.put(which, content);
+		
+	}
 	@Override
 	protected void onCreate(Bundle savedInstanceState)
 	{
@@ -48,16 +54,27 @@ public class DetailActivity extends FragmentActivity implements
 		List<Fragment> fragments = getSupportFragmentManager().getFragments();
 		if (fragments != null)
 		{
-			Log.e("DetailFragment", "fragments count=" + fragments.size());
-			for (int i = 0; i < fragments.size(); i++)
-				Log.e("DetailFragment", "fragment name=" + fragments.get(i).getTag());
+			Log.e("DetailActivity", "fragments count=" + fragments.size());
+//			for (int i = 0; i < fragments.size(); i++)
+//				Log.e("DetailFragment", "fragment name="
+//						+ fragments.get(i).getTag());
 
 		}
-		int count = getIntent().getIntExtra("actions_count", 0);
-		for (int i = 0; i < count; i++)
+
+		if (savedInstanceState != null)
+		{
+			tabmap = (LinkedHashMap<String, Integer>) savedInstanceState
+					.getSerializable("tabmap");
+			contentmap = (HashMap<String, String>) savedInstanceState.getSerializable("contentmap");
+		}
+		else
 		{
-			tabmap.put(getIntent().getStringExtra("action" + i),
-					commonUtil.generateViewId());
+			int count = getIntent().getIntExtra("actions_count", 0);
+			for (int i = 0; i < count; i++)
+			{
+				int vid = commonUtil.generateViewId();
+				tabmap.put(getIntent().getStringExtra("action" + i), vid);
+			}
 		}
 		function_name = getIntent().getStringExtra("function_name");
 		if (function_name.equals("Cargo Tracking"))
@@ -123,10 +140,19 @@ public class DetailActivity extends FragmentActivity implements
 		bundle.putString("id", _id);
 		bundle.putString("module_name", function_name);
 
-		Log.d("createTabContent", "create fragment" + tag);
-		f = new DetailFragment();
+//		Log.e("findFragmentByTag", "tag=" + tag + ", isnull= "
+//				+ (getSupportFragmentManager().findFragmentByTag(tag) == null));
 
-		f.setArguments(bundle);
+		f = getSupportFragmentManager().findFragmentById(tabmap.get(tag));
+		if (f == null)
+		{
+			Log.e("createTabContent", "create fragment" + tag);
+			f = new DetailFragment();
+
+			
+			f.setArguments(bundle);
+		}
+		((DetailFragment)f).set_content( contentmap.get(tag));
 		FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
 		ft.replace(fl.getId(), f);
 		ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
@@ -135,6 +161,14 @@ public class DetailActivity extends FragmentActivity implements
 		return fl;
 	}
 
+	@Override
+	protected void onSaveInstanceState(Bundle outState)
+	{
+		outState.putSerializable("tabmap", tabmap);
+		outState.putSerializable("contentmap", contentmap);
+		super.onSaveInstanceState(outState);
+	}
+
 	// TabHost mTabHost;
 	// private FrameLayout mTabContent;
 	@Override
@@ -231,7 +265,7 @@ public class DetailActivity extends FragmentActivity implements
 		// // .setContent(Mytabfirst.this)); tabhost.setCurrentTab(i);
 		// // i++; tab = null;
 		//
-		// // // 生成底部自定义样式的按钮
+		// // // 锟斤拷傻撞锟斤拷远锟斤拷锟斤拷锟绞斤拷陌锟脚�
 		// // String[] title = new String[] { "Login", "Not login" };
 		// // int[] tabIds = new int[] { R.id.tab1, R.id.tab2 };
 		// mTabHost.addTab(mTabHost.newTabSpec("Login").setIndicator("Login")
@@ -277,7 +311,7 @@ public class DetailActivity extends FragmentActivity implements
 		// Button button = new Button(this);
 		// button.setText(title[i]);
 		// button.setBackgroundDrawable(this.getResources().getDrawable(
-		// R.drawable.tab_lable)); //自定义按钮样
+		// R.drawable.tab_lable)); //锟皆讹拷锟藉按钮锟斤拷
 		// mTabHost.addTab(mTabHost.newTabSpec(title[i]).setIndicator(button)
 		// .setContent(tabIds[i]));
 		// }
@@ -285,33 +319,33 @@ public class DetailActivity extends FragmentActivity implements
 		// mTabHost.setOnTabChangedListener(this);
 	}
 
-	@Override
-	public boolean onCreateOptionsMenu(Menu menu)
-	{
-		// Inflate the menu; this adds items to the action bar if it is present.
-		getMenuInflater().inflate(R.menu.detail, menu);
-		return true;
-	}
-
-	@Override
-	public boolean onOptionsItemSelected(MenuItem item)
-	{
-		switch (item.getItemId())
-		{
-		case android.R.id.home:
-			// This ID represents the Home or Up button. In the case of this
-			// activity, the Up button is shown. Use NavUtils to allow users
-			// to navigate up one level in the application structure. For
-			// more details, see the Navigation pattern on Android Design:
-			//
-			//
-			// http: //
-			// developer.android.com/design/patterns/navigation.html#up-vs-back
-			//
-			NavUtils.navigateUpFromSameTask(this);
-			return true;
-		}
-		return super.onOptionsItemSelected(item);
-	}
+	// @Override
+	// public boolean onCreateOptionsMenu(Menu menu)
+	// {
+	// // Inflate the menu; this adds items to the action bar if it is present.
+	// getMenuInflater().inflate(R.menu.detail, menu);
+	// return true;
+	// }
+	//
+	// @Override
+	// public boolean onOptionsItemSelected(MenuItem item)
+	// {
+	// switch (item.getItemId())
+	// {
+	// case android.R.id.home:
+	// // This ID represents the Home or Up button. In the case of this
+	// // activity, the Up button is shown. Use NavUtils to allow users
+	// // to navigate up one level in the application structure. For
+	// // more details, see the Navigation pattern on Android Design:
+	// //
+	// //
+	// // http: //
+	// // developer.android.com/design/patterns/navigation.html#up-vs-back
+	// //
+	// NavUtils.navigateUpFromSameTask(this);
+	// return true;
+	// }
+	// return super.onOptionsItemSelected(item);
+	// }
 
 }

+ 64 - 48
Apex/src/com/usai/apex/DetailFragment.java

@@ -50,7 +50,7 @@ public class DetailFragment extends Fragment implements OnClickListener /*
 																		 * OnGestureListener
 																		 */
 {
-	DataFragment mdataFragment;
+//	DataFragment mdataFragment;
 
 	/* private GestureDetector mGestureDetector; */
 	@Override
@@ -79,19 +79,27 @@ public class DetailFragment extends Fragment implements OnClickListener /*
 	// private TextView mStatusMessageView;
 	private View mStatusView;
 
-	// String fragment_content = null;
+	 String fragment_content = null;
 
 	public void requestdata() {
 
 		if (m_task != null) {
 			return;
 		}
-		if (mdataFragment.get_result() != null) {
+		if(fragment_content!=null)
+		{
 			LayoutInflater inflater = (LayoutInflater) ApexTrackingApplication
-					.get_instance().getSystemService(
-							Context.LAYOUT_INFLATER_SERVICE);
-			init(mdataFragment.get_result(), inflater);
+			.get_instance().getSystemService(
+					Context.LAYOUT_INFLATER_SERVICE);
+			init(fragment_content,inflater);
+			return;
 		}
+//		if (mdataFragment.get_result() != null) {
+//			LayoutInflater inflater = (LayoutInflater) ApexTrackingApplication
+//					.get_instance().getSystemService(
+//							Context.LAYOUT_INFLATER_SERVICE);
+//			init(mdataFragment.get_result(), inflater);
+//		}
 		// if (fragment_content != null)
 		// return;
 		// mStatusMessageView.setText("Loading");
@@ -100,6 +108,10 @@ public class DetailFragment extends Fragment implements OnClickListener /*
 		m_task.execute();
 
 	}
+	public void set_content(String content)
+	{
+		fragment_content=content;
+	}
 
 	private void showProgress(final boolean show) {
 		// On Honeycomb MR2 we have the ViewPropertyAnimator APIs, which allow
@@ -184,26 +196,27 @@ public class DetailFragment extends Fragment implements OnClickListener /*
 
 			}
 		});
-		FragmentManager fm = getActivity().getSupportFragmentManager();
-		List<Fragment> fragments = fm.getFragments();
-		if (fragments != null) {
-			Log.e("DetailFragment", "fragments count=" + fragments.size());
-			for (int i = 0; i < fragments.size(); i++)
-				Log.e("DetailFragment", "fragments name=" + fragments.size());
-
-		}
-		String tag = getArguments().getString("module_name");
-		// Check to see if we have retained the worker fragment.
-		mdataFragment = (DataFragment) fm.findFragmentByTag("data_" + tag);
-
-		// If not retained (or first time running), we need to create it.
-		if (mdataFragment == null) {
-			Log.e("dataFragment creaded ", "tag=data_" + tag);
-			mdataFragment = new DataFragment();
-			// Tell it who it is working with.
-			mdataFragment.setTargetFragment(this, 0);
-			fm.beginTransaction().add(mdataFragment, "data+" + tag).commit();
-		}
+//		FragmentManager fm = getFragmentManager();
+//		List<Fragment> fragments = fm.getFragments();
+//		if (fragments != null) {
+//			Log.e("DetailFragment", "fragments count=" + fragments.size());
+////			for (int i = 0; i < fragments.size(); i++)
+////				Log.e("DetailFragment", "fragments name=" + fragments.size());
+//
+//		}
+////		this.getFragmentManager();
+//		String tag = getArguments().getString("module_name");
+//		// Check to see if we have retained the worker fragment.
+//		mdataFragment = (DataFragment) fm.findFragmentById(12345);
+//
+//		// If not retained (or first time running), we need to create it.
+//		if (mdataFragment == null) {
+//			Log.e("dataFragment creaded ", "tag=data_" + tag);
+//			mdataFragment = new DataFragment();
+//			// Tell it who it is working with.
+//			mdataFragment.setTargetFragment(this, 0);
+//			fm.beginTransaction().add(12345,mdataFragment, "data+" + tag).commit();
+//		}
 		requestdata();
 		return view;
 	}
@@ -454,7 +467,10 @@ public class DetailFragment extends Fragment implements OnClickListener /*
 				return false;
 			}
 
-			mdataFragment.put_result(jstr);
+//			mdataFragment.put_result(jstr);
+			fragment_content=jstr;
+			((DetailActivity) getActivity()).save_content(getArguments().getString("action_type"),jstr);
+			;
 			errorcode = Network.RESULT_TRUE;
 
 			return true;
@@ -505,7 +521,7 @@ public class DetailFragment extends Fragment implements OnClickListener /*
 						.get_instance().getSystemService(
 								Context.LAYOUT_INFLATER_SERVICE);
 
-				init(mdataFragment.get_result(), inflater/*
+				init(fragment_content, inflater/*
 														 * getActivity().
 														 * getLayoutInflater()
 														 */);
@@ -524,26 +540,26 @@ public class DetailFragment extends Fragment implements OnClickListener /*
 		}
 	}
 
-	public class DataFragment extends Fragment {
-
-		String result = null;
-
-		@Override
-		public void onCreate(Bundle savedInstanceState) {
-			setRetainInstance(true);
-			super.onCreate(savedInstanceState);
-		}
-
-		public String get_result() {
-			return result;
-
-		}
-
-		public void put_result(String s) {
-			result = s;
-		}
-
-	}
+//	public class DataFragment extends Fragment {
+//
+//		String result = null;
+//
+//		@Override
+//		public void onCreate(Bundle savedInstanceState) {
+//			setRetainInstance(true);
+//			super.onCreate(savedInstanceState);
+//		}
+//
+//		public String get_result() {
+//			return result;
+//
+//		}
+//
+//		public void put_result(String s) {
+//			result = s;
+//		}
+//
+//	}
 
 	public class MyWebViewClient extends WebViewClient {
 		// 如果页面中链接,如果希望点击链接继续在当前browser中响应,

+ 28 - 28
Apex/src/com/usai/apex/DragListView.java

@@ -20,19 +20,19 @@ import android.widget.ListView;
 public class DragListView extends ListView
 {
 
-	private ImageView dragImageView;// 被拖拽的项,其实就是一个ImageView
-	private int dragSrcPosition;// 手指拖动项原始在列表中的位置
-	private int dragPosition;// 手指拖动的时候,当前拖动项在列表中的位置
+	private ImageView dragImageView;// 锟斤拷锟斤拷拽锟斤拷锟筋,锟斤拷实锟斤拷锟斤拷一锟斤拷ImageView
+	private int dragSrcPosition;// 锟斤拷指锟较讹拷锟斤拷原始锟斤拷锟叫憋拷锟叫碉拷位锟斤拷
+	private int dragPosition;// 锟斤拷指锟较讹拷锟斤拷时锟津,碉拷前锟较讹拷锟斤拷锟斤拷锟叫憋拷锟叫碉拷位锟斤拷
 
-	private int dragPoint;// 在当前数据项中的位置
-	private int dragOffset;// 当前视图和屏幕的距离(这里只使用了y方向上)
+	private int dragPoint;// 锟节碉拷前锟斤拷锟斤拷锟斤拷械锟轿伙拷锟�
+	private int dragOffset;// 锟斤拷前锟斤拷图锟斤拷锟斤拷幕锟侥撅拷锟斤拷(锟斤拷锟斤拷只使锟斤拷锟斤拷y锟斤拷锟斤拷锟斤拷)
 
-	private WindowManager windowManager;// windows窗口控制类
-	private WindowManager.LayoutParams windowParams;// 用于控制拖拽项的显示的参数
+	private WindowManager windowManager;// windows锟斤拷锟节匡拷锟斤拷锟斤拷
+	private WindowManager.LayoutParams windowParams;// 锟斤拷锟节匡拷锟斤拷锟斤拷拽锟斤拷锟斤拷锟绞撅拷牟锟斤拷锟�
 
-	private int scaledTouchSlop;// 判断滑动的一个距离
-	private int upScrollBounce;// 拖动的时候,开始向上滚动的边界
-	private int downScrollBounce;// 拖动的时候,开始向下滚动的边界
+	private int scaledTouchSlop;// 锟叫断伙拷锟斤拷锟斤拷一锟斤拷锟斤拷锟斤拷
+	private int upScrollBounce;// 锟较讹拷锟斤拷时锟津,匡拷始锟斤拷锟较癸拷锟斤拷锟侥边斤拷
+	private int downScrollBounce;// 锟较讹拷锟斤拷时锟津,匡拷始锟斤拷锟铰癸拷锟斤拷锟侥边斤拷
 
 	public DragListView(Context context, AttributeSet attrs)
 	{
@@ -56,7 +56,7 @@ public class DragListView extends ListView
 			fieldedit dclickitem = (fieldedit) ((ListView) parent).getAdapter()
 					.getItem(pos);
 
-			// 如果是双击,1秒内连续点击判断为双击
+			// 锟斤拷锟斤拷锟剿�拷锟�,1锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟叫讹拷为双锟斤拷
 			if (dclickitem._id == lastClickId
 					&& (Math.abs(lastClickTime - System.currentTimeMillis()) < 1000))
 			{
@@ -89,7 +89,7 @@ public class DragListView extends ListView
 		}
 	};
 
-	// 拦截touch事件,其实就是加一层控制
+	// 锟斤拷锟斤拷touch锟铰硷拷锟斤拷锟斤拷实锟斤拷锟角硷拷一锟斤拷锟斤拷锟�
 	@Override
 	public boolean onInterceptTouchEvent(MotionEvent ev)
 	{
@@ -127,7 +127,7 @@ public class DragListView extends ListView
 	}
 
 	/**
-	 * 触摸事件
+	 * 锟斤拷锟斤拷锟铰硷拷
 	 */
 	@Override
 	public boolean onTouchEvent(MotionEvent ev)
@@ -151,12 +151,12 @@ public class DragListView extends ListView
 			}
 			return true;
 		}
-		// 也决定了选中的效果
+		// 也锟斤拷锟斤拷锟斤拷选锟叫碉拷效锟斤拷
 		return super.onTouchEvent(ev);
 	}
 
 	/**
-	 * 准备拖动,初始化拖动项的图像
+	 * 准锟斤拷锟较讹拷锟斤拷锟斤拷始锟斤拷锟较讹拷锟斤拷锟酵硷拷锟�
 	 * 
 	 * @param bm
 	 * @param y
@@ -186,7 +186,7 @@ public class DragListView extends ListView
 	}
 
 	/**
-	 * 停止拖动,去除拖动项的头像
+	 * 停止锟较讹拷锟斤拷去锟斤拷锟较讹拷锟斤拷锟酵凤拷锟�
 	 */
 	public void stopDrag()
 	{
@@ -198,7 +198,7 @@ public class DragListView extends ListView
 	}
 
 	/**
-	 * 拖动执行,在Move方法中执行
+	 * 锟较讹拷执锟叫o拷锟斤拷Move锟斤拷锟斤拷锟斤拷执锟斤拷
 	 * 
 	 * @param y
 	 */
@@ -210,28 +210,28 @@ public class DragListView extends ListView
 			windowParams.y = y - dragPoint + dragOffset;
 			windowManager.updateViewLayout(dragImageView, windowParams);
 		}
-		// 为了避免滑动到分割线的时候,返回-1的问题
+		// 为锟剿憋拷锟解滑锟斤拷锟斤拷锟街革拷锟竭碉拷时锟津,凤拷锟斤拷-1锟斤拷锟斤拷锟斤拷
 		int tempPosition = pointToPosition(0, y);
 		if (tempPosition != INVALID_POSITION)
 		{
 			dragPosition = tempPosition;
 		}
 
-		// 滚动
+		// 锟斤拷锟斤拷
 		int scrollHeight = 0;
 		if (y < upScrollBounce)
 		{
-			scrollHeight = 8;// 定义向上滚动8个像素,如果可以向上滚动的话
+			scrollHeight = 8;// 锟斤拷锟斤拷锟斤拷锟较癸拷锟斤拷8锟斤拷锟斤拷锟截o拷锟斤拷锟斤拷锟斤拷锟斤拷锟较癸拷锟斤拷锟侥伙拷
 		}
 		else
 			if (y > downScrollBounce)
 			{
-				scrollHeight = -8;// 定义向下滚动8个像素,,如果可以向上滚动的话
+				scrollHeight = -8;// 锟斤拷锟斤拷锟斤拷锟铰癸拷锟斤拷8锟斤拷锟斤拷锟截o拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟较癸拷锟斤拷锟侥伙拷
 			}
 
 		if (scrollHeight != 0)
 		{
-			// 真正滚动的方法setSelectionFromTop()
+			// 锟斤拷锟斤拷锟斤拷锟斤拷姆锟斤拷锟絪etSelectionFromTop()
 			setSelectionFromTop(dragPosition,
 					getChildAt(dragPosition - getFirstVisiblePosition())
 							.getTop() + scrollHeight);
@@ -239,34 +239,34 @@ public class DragListView extends ListView
 	}
 
 	/**
-	 * 拖动放下的时候
+	 * 锟较讹拷锟斤拷锟铰碉拷时锟斤拷
 	 * 
 	 * @param y
 	 */
 	public void onDrop(int y)
 	{
 
-		// 为了避免滑动到分割线的时候,返回-1的问题
+		// 为锟剿憋拷锟解滑锟斤拷锟斤拷锟街革拷锟竭碉拷时锟津,凤拷锟斤拷-1锟斤拷锟斤拷锟斤拷
 		int tempPosition = pointToPosition(0, y);
 		if (tempPosition != INVALID_POSITION)
 		{
 			dragPosition = tempPosition;
 		}
 
-		// 超出边界处理
+		// 锟斤拷锟斤拷锟竭界处锟斤拷
 		if (y < getChildAt(1).getTop())
 		{
-			// 超出上边界
+			// 锟斤拷锟斤拷锟较边斤拷
 			dragPosition = 1;
 		}
 		else
 			if (y > getChildAt(getChildCount() - 1).getBottom())
 			{
-				// 超出下边界
+				// 锟斤拷锟斤拷锟铰边斤拷
 				dragPosition = getAdapter().getCount() - 1;
 			}
 
-		// 数据交换
+		// 锟斤拷萁锟斤拷锟�
 		if (dragPosition > 0 && dragPosition < getAdapter().getCount())
 		{
 			/* @SuppressWarnings("unchecked") */

+ 222 - 112
Apex/src/com/usai/apex/FunctionSelectActivity.java

@@ -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
+	// }
+	//
+	// }
 
 }

+ 1 - 1
Apex/src/com/usai/apex/ServiceLocationFragment.java

@@ -180,7 +180,7 @@ public class ServiceLocationFragment extends Fragment implements
 //			Drawable da=getResources().getDrawable(R.drawable.ic_launcher);
 //			Bitmap bmp=BitmapFactory.decodeResource(getResources(), R.drawable.ic_map);
 //			Log.d("markersize",bmp.getWidth()+","+bmp.getHeight());
-			map.addMarker(new MarkerOptions().icon(BitmapDescriptorFactory.fromResource(R.drawable.ic_map))
+			map.addMarker(new MarkerOptions().icon(BitmapDescriptorFactory.fromResource(R.drawable.ic_marker))
 					.position(
 							new LatLng(Double.parseDouble(point[0]), Double
 									.parseDouble(point[1]))).title(markertext)

+ 21 - 0
Apex/src/com/usai/apex/TestFragment.java

@@ -0,0 +1,21 @@
+package com.usai.apex;
+
+import android.os.Bundle;
+import android.support.v4.app.Fragment;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+
+public class TestFragment extends Fragment
+{
+
+	@Override
+	public View onCreateView(LayoutInflater inflater, ViewGroup container,
+			Bundle savedInstanceState)
+	{
+		View view = inflater.inflate(R.layout.fragment_login, null);
+		return view;
+	}
+	
+
+}

+ 24 - 2
Apex/src/com/usai/util/dbUtil.java

@@ -1,6 +1,7 @@
 package com.usai.util;
 
 import com.usai.apex.ApexTrackingApplication;
+import com.usai.apex.ResultActivity;
 
 import android.content.ContentValues;
 import android.content.Context;
@@ -383,6 +384,10 @@ public class dbUtil
 				+ "_id INTEGER PRIMARY KEY," + "name VARCHAR(20),"
 				+ "function_name VARCHAR(20)," + "priority INTEGER,"
 				+ "abandon BOOLEAN," + "user VARCHAR(20))");
+		dbHelper.addInitSQL("CREATE TABLE search_history ("
+				+ "_id INTEGER PRIMARY KEY," + "h_val VARCHAR(20),"
+				+ "h_field VARCHAR(20)," + "h_time timestamp,"
+				+ "user VARCHAR(20))");
 		// dbHelper.addInitSQL("create table pics (" +
 		// "_id INTEGER PRIMARY KEY,"
 		// + "picker varchar(20)," + "err_code INTEGER ,"
@@ -535,15 +540,32 @@ public class dbUtil
 		CloseDB(db);
 		return ret;
 	}
+	public static int get_count(SQLiteDatabase db,String table,String where)
+	{
+		int ret=0;
+		Cursor cursor = db.query(table,
+				new String[] { "count(*)" }, where,
+				null, null, null, null, null);
+		if (cursor.moveToNext()) {
+			ret = cursor.getInt(0);
+		}
+
+		dbUtil.CloseCursor(cursor);
+		return ret;
+	}
 
-	public static int get_recordid(SQLiteDatabase db, String table, String where)
+	public static int get_recordid(SQLiteDatabase db, String table, String where )
+	{
+		return get_recordid(db,table,where,null);
+	}
+	public static int get_recordid(SQLiteDatabase db, String table, String where ,String Orderby)
 	{
 		int ret = -1;
 		Cursor cursor = null;
 		try
 		{
 
-			cursor = db.query(table, FIELD_ID, where, null, null, null, null,
+			cursor = db.query(table, FIELD_ID, where, null, null, null, Orderby,
 					null);
 			if (cursor.moveToNext())
 				ret = cursor.getInt(0);