Quellcode durchsuchen

1.修改Android Apex Mobile Detail地图点击。

Pen Li vor 8 Jahren
Ursprung
Commit
f485f2d92d
1 geänderte Dateien mit 28 neuen und 6 gelöschten Zeilen
  1. 28 6
      Apex Mobile/app/src/main/java/com/usai/apex/DetailFragment.java

+ 28 - 6
Apex Mobile/app/src/main/java/com/usai/apex/DetailFragment.java

@@ -43,6 +43,7 @@ import android.widget.ScrollView;
 import android.widget.TextView;
 import android.widget.Toast;
 
+import com.usai.apex.ShipMap.ShipMap;
 import com.usai.apex.mainframe.NewDetailActivity;
 import com.usai.apex.pdf.PDFPreviewActivity;
 import com.usai.util.Network;
@@ -298,6 +299,8 @@ public class DetailFragment extends Fragment implements OnClickListener /*
 	// super.onActivityCreated(savedInstanceState);
 	// }
 
+	private ShipMap mTrackingMap;
+
 	@Override
 	public View onCreateView(LayoutInflater inflater, ViewGroup container,
 			Bundle savedInstanceState)
@@ -309,10 +312,13 @@ public class DetailFragment extends Fragment implements OnClickListener /*
 
 		View view = null;
 
-		if(this.getArguments().getString("action_type").equals("Tracing")||this.getArguments().getString("action_type").equals("Tracking"))
-			view=inflater.inflate(R.layout.detail_fragment_withmap, null);
-		else
-			view=inflater.inflate(R.layout.detail_fragment, null);
+		if(this.getArguments().getString("action_type").equals("Tracing")||this.getArguments().getString("action_type").equals("Tracking")) {
+			view = inflater.inflate(R.layout.detail_fragment_withmap, null);
+			mTrackingMap = view.findViewById(R.id.tracking_map);
+		} else {
+			view = inflater.inflate(R.layout.detail_fragment, null);
+			mTrackingMap = null;
+		}
 
 
 //		if(this.getArguments().getString("action_type").equals("Tracing"))
@@ -446,7 +452,7 @@ public class DetailFragment extends Fragment implements OnClickListener /*
 				// String key = (String) it.next();
 				// if (key.equals("result"))
 				// continue;
-				JSONObject groupobj = jsonObj.getJSONObject("group" + i);
+				final JSONObject groupobj = jsonObj.getJSONObject("group" + i);
 				View v = inflater.inflate(R.layout.group_tag, null);
 //				v.setOnClickListener(this);
 
@@ -676,7 +682,7 @@ public class DetailFragment extends Fragment implements OnClickListener /*
 					long list_count = groupobj.getInt("count");
 					for (int j = 0; j < list_count; j++)
 					{
-						JSONObject itemobj = groupobj.getJSONObject("item" + j);
+						final JSONObject itemobj = groupobj.getJSONObject("item" + j);
 
 						ConstraintLayout listitem = (ConstraintLayout) inflater
 								.inflate(R.layout.detail_tracking_cell, null);
@@ -709,6 +715,20 @@ public class DetailFragment extends Fragment implements OnClickListener /*
 						listitem.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, px, 1));
 						listview.addView(listitem);
 //						ViewGroup.LayoutParams lp1=listitem.getLayoutParams();
+
+						listitem.setOnClickListener(new OnClickListener() {
+							@Override
+							public void onClick(View v) {
+
+								if (mTrackingMap != null) {
+									JSONObject location = groupobj.optJSONObject("location");
+									if (location != null) {
+										mTrackingMap.showShipAnnotation(location);
+									}
+								}
+
+							}
+						});
 					}
 
 				}
@@ -1075,6 +1095,8 @@ public class DetailFragment extends Fragment implements OnClickListener /*
 				errorcode = Network.RESULT_NET_NOTAVAILABLE;
 				return false;
 			}
+
+
 			String jstr = Network.get_detail(getArguments());
 			if (jstr == null || jstr.length() <= 0)
 			{