|
@@ -0,0 +1,1709 @@
|
|
|
|
|
+package com.usai.ratradefiling.detail;
|
|
|
|
|
+
|
|
|
|
|
+import android.animation.Animator;
|
|
|
|
|
+import android.animation.AnimatorListenerAdapter;
|
|
|
|
|
+import android.app.AlertDialog;
|
|
|
|
|
+import android.app.ProgressDialog;
|
|
|
|
|
+import android.content.ClipboardManager;
|
|
|
|
|
+import android.content.Context;
|
|
|
|
|
+import android.content.DialogInterface;
|
|
|
|
|
+import android.content.Intent;
|
|
|
|
|
+import android.database.Cursor;
|
|
|
|
|
+import android.graphics.Bitmap;
|
|
|
|
|
+import android.graphics.Color;
|
|
|
|
|
+import android.net.Uri;
|
|
|
|
|
+import android.os.AsyncTask;
|
|
|
|
|
+import android.os.Build;
|
|
|
|
|
+import android.os.Bundle;
|
|
|
|
|
+import android.provider.ContactsContract;
|
|
|
|
|
+import android.text.Editable;
|
|
|
|
|
+import android.text.Html;
|
|
|
|
|
+import android.text.TextWatcher;
|
|
|
|
|
+import android.util.Log;
|
|
|
|
|
+import android.util.SparseIntArray;
|
|
|
|
|
+import android.view.GestureDetector;
|
|
|
|
|
+import android.view.Gravity;
|
|
|
|
|
+import android.view.LayoutInflater;
|
|
|
|
|
+import android.view.MotionEvent;
|
|
|
|
|
+import android.view.View;
|
|
|
|
|
+import android.view.View.OnClickListener;
|
|
|
|
|
+import android.view.ViewGroup;
|
|
|
|
|
+import android.webkit.WebResourceRequest;
|
|
|
|
|
+import android.webkit.WebResourceResponse;
|
|
|
|
|
+import android.webkit.WebView;
|
|
|
|
|
+import android.webkit.WebViewClient;
|
|
|
|
|
+import android.widget.Button;
|
|
|
|
|
+import android.widget.EditText;
|
|
|
|
|
+import android.widget.ImageButton;
|
|
|
|
|
+import android.widget.ImageView;
|
|
|
|
|
+import android.widget.LinearLayout;
|
|
|
|
|
+import android.widget.RelativeLayout;
|
|
|
|
|
+import android.widget.ScrollView;
|
|
|
|
|
+import android.widget.TextView;
|
|
|
|
|
+import android.widget.Toast;
|
|
|
|
|
+
|
|
|
|
|
+import androidx.constraintlayout.widget.ConstraintLayout;
|
|
|
|
|
+import androidx.fragment.app.Fragment;
|
|
|
|
|
+//
|
|
|
|
|
+//import com.usai.apex.pdf.PDFPreviewActivity;
|
|
|
|
|
+//import com.usai.apex.shipmap.ShipMap;
|
|
|
|
|
+//import com.usai.util.Network;
|
|
|
|
|
+//import com.usai.util.RAUtil;
|
|
|
|
|
+//import com.usai.util.RAUtil;
|
|
|
|
|
+//import com.usai.util.dbUtil;
|
|
|
|
|
+//
|
|
|
|
|
+//import org.apache.http.util.EncodingUtils;
|
|
|
|
|
+import com.redant.usai.rapdflib.preview.RAPDFPreviewActivity;
|
|
|
|
|
+import com.usai.ratradefiling.R;
|
|
|
|
|
+import com.usai.ratradefiling.TradeFilingApplication;
|
|
|
|
|
+import com.usai.ratradefiling.dataprovider.OnlineDataProvider;
|
|
|
|
|
+import com.usai.ratradefiling.dataprovider.RADataProvider;
|
|
|
|
|
+import com.usai.redant.rautils.utils.RAUtil;
|
|
|
|
|
+
|
|
|
|
|
+import org.json.JSONArray;
|
|
|
|
|
+import org.json.JSONException;
|
|
|
|
|
+import org.json.JSONObject;
|
|
|
|
|
+
|
|
|
|
|
+import java.io.ByteArrayInputStream;
|
|
|
|
|
+import java.io.File;
|
|
|
|
|
+import java.util.regex.Pattern;
|
|
|
|
|
+
|
|
|
|
|
+public class DetailFragment extends Fragment implements OnClickListener /*
|
|
|
|
|
+ * ,
|
|
|
|
|
+ * OnGestureListener
|
|
|
|
|
+ */
|
|
|
|
|
+{
|
|
|
|
|
+
|
|
|
|
|
+ private static final int People_Pick_Code = 1357;
|
|
|
|
|
+
|
|
|
|
|
+ private String copiedKey;
|
|
|
|
|
+ private String copiedVal;
|
|
|
|
|
+ private String containerID;
|
|
|
|
|
+ private View touchedView;
|
|
|
|
|
+
|
|
|
|
|
+// @Override
|
|
|
|
|
+// public void shipMapTryToZoomIn(ShipMap shipMap, boolean zoomIn) {
|
|
|
|
|
+//
|
|
|
|
|
+// if (zoomIn) {
|
|
|
|
|
+//
|
|
|
|
|
+// LinearLayout.LayoutParams lfLayoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 0);
|
|
|
|
|
+// mDetailContainer.setLayoutParams(lfLayoutParams);
|
|
|
|
|
+//
|
|
|
|
|
+// } else {
|
|
|
|
|
+//
|
|
|
|
|
+// LinearLayout.LayoutParams lfLayoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 0,2.0f);
|
|
|
|
|
+// mDetailContainer.setLayoutParams(lfLayoutParams);
|
|
|
|
|
+// }
|
|
|
|
|
+//
|
|
|
|
|
+// mMapZoomIn = zoomIn;
|
|
|
|
|
+//
|
|
|
|
|
+// }
|
|
|
|
|
+
|
|
|
|
|
+ private class GestureListener extends GestureDetector.SimpleOnGestureListener {
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public boolean onDoubleTapEvent(MotionEvent e) {
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ if (e.getAction() == MotionEvent.ACTION_UP) {
|
|
|
|
|
+
|
|
|
|
|
+ if (touchedView == null) {
|
|
|
|
|
+
|
|
|
|
|
+ ClipboardManager cm = (ClipboardManager) getActivity().getSystemService(Context.CLIPBOARD_SERVICE);
|
|
|
|
|
+ cm.setText(copiedVal);
|
|
|
|
|
+
|
|
|
|
|
+ Toast.makeText(mContext, "Copied " + copiedKey, Toast.LENGTH_LONG).show();
|
|
|
|
|
+ } else {
|
|
|
|
|
+
|
|
|
|
|
+ String type = (String) touchedView.getTag();
|
|
|
|
|
+ if (type.equals("tracking")) {
|
|
|
|
|
+
|
|
|
|
|
+ TextView tvgroup = (TextView) touchedView.findViewById(R.id.tv_group);
|
|
|
|
|
+
|
|
|
|
|
+ if (tvgroup != null) {
|
|
|
|
|
+
|
|
|
|
|
+ String val = tvgroup.getText().toString();
|
|
|
|
|
+ ClipboardManager cm = (ClipboardManager) getActivity().getSystemService(Context.CLIPBOARD_SERVICE);
|
|
|
|
|
+ cm.setText(val);
|
|
|
|
|
+
|
|
|
|
|
+ Toast.makeText(mContext, "Copied " + val, Toast.LENGTH_LONG).show();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ copiedKey = null;
|
|
|
|
|
+ copiedVal = null;
|
|
|
|
|
+ touchedView = null;
|
|
|
|
|
+
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public boolean onSingleTapConfirmed(MotionEvent e) {
|
|
|
|
|
+
|
|
|
|
|
+ if (touchedView != null) {
|
|
|
|
|
+ onClick(touchedView);
|
|
|
|
|
+ }
|
|
|
|
|
+ touchedView = null;
|
|
|
|
|
+
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private static final int REQUEST_LOGINACTIVITY = 1;
|
|
|
|
|
+
|
|
|
|
|
+ // DataFragment mdataFragment;
|
|
|
|
|
+
|
|
|
|
|
+ Context mContext;
|
|
|
|
|
+ ProgressDialog progressDialog;
|
|
|
|
|
+ private GestureDetector detector;
|
|
|
|
|
+
|
|
|
|
|
+ protected void showProgressDialog(final String title, final String msg) {
|
|
|
|
|
+
|
|
|
|
|
+ getActivity().runOnUiThread(new Runnable() {
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void run() {
|
|
|
|
|
+ try {
|
|
|
|
|
+ progressDialog.setTitle(title);
|
|
|
|
|
+ progressDialog.setMessage(msg);
|
|
|
|
|
+ progressDialog.show();
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /* private GestureDetector mGestureDetector; */
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void onCreate(Bundle savedInstanceState)
|
|
|
|
|
+ {
|
|
|
|
|
+ // TODO Auto-generated method stub
|
|
|
|
|
+ super.onCreate(savedInstanceState);
|
|
|
|
|
+
|
|
|
|
|
+ if (progressDialog == null) {
|
|
|
|
|
+ progressDialog = new ProgressDialog(mContext);
|
|
|
|
|
+ progressDialog.setCancelable(false);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (detector == null) {
|
|
|
|
|
+ detector = new GestureDetector(mContext, new GestureListener());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+// @Override
|
|
|
|
|
+// public void onActivityCreated(@Nullable Bundle savedInstanceState) {
|
|
|
|
|
+// super.onActivityCreated(savedInstanceState);
|
|
|
|
|
+//
|
|
|
|
|
+// progressDialog = new ProgressDialog(mContext);
|
|
|
|
|
+// progressDialog.setCancelable(false);
|
|
|
|
|
+// }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void onAttach(Context context) {
|
|
|
|
|
+ super.onAttach(context);
|
|
|
|
|
+ mContext = context;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void onDestroyView()
|
|
|
|
|
+ {
|
|
|
|
|
+ Log.d("DetailFragment", "onDestroyView()");
|
|
|
|
|
+ super.onDestroyView();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // public String get_content()
|
|
|
|
|
+ // {
|
|
|
|
|
+ // return fragment_content;
|
|
|
|
|
+ // }
|
|
|
|
|
+
|
|
|
|
|
+ LinearLayout ll_root;
|
|
|
|
|
+ ScrollView sl_root;
|
|
|
|
|
+ String mimeType = "text/html";
|
|
|
|
|
+ private SearchTask m_task = null;
|
|
|
|
|
+ SparseIntArray control = new SparseIntArray();
|
|
|
|
|
+ // private TextView mStatusMessageView;
|
|
|
|
|
+ private View mStatusView;
|
|
|
|
|
+
|
|
|
|
|
+ String fragment_content = null;
|
|
|
|
|
+
|
|
|
|
|
+ public void requestdata()
|
|
|
|
|
+ {
|
|
|
|
|
+
|
|
|
|
|
+ if (m_task != null)
|
|
|
|
|
+ {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (fragment_content != null)
|
|
|
|
|
+ {
|
|
|
|
|
+ LayoutInflater inflater = (LayoutInflater) TradeFilingApplication
|
|
|
|
|
+ .get_instance().getSystemService(
|
|
|
|
|
+ Context.LAYOUT_INFLATER_SERVICE);
|
|
|
|
|
+ init(fragment_content, inflater);
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ // if (mdataFragment.get_result() != null) {
|
|
|
|
|
+ // LayoutInflater inflater = (LayoutInflater) TradeFilingApplication
|
|
|
|
|
+ // .get_instance().getSystemService(
|
|
|
|
|
+ // Context.LAYOUT_INFLATER_SERVICE);
|
|
|
|
|
+ // init(mdataFragment.get_result(), inflater);
|
|
|
|
|
+ // }
|
|
|
|
|
+ // if (fragment_content != null)
|
|
|
|
|
+ // return;
|
|
|
|
|
+ // mStatusMessageView.setText("Loading");
|
|
|
|
|
+ showProgress(true);
|
|
|
|
|
+ m_task = new SearchTask();
|
|
|
|
|
+ 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
|
|
|
|
|
+ // 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 = TradeFilingApplication.get_instance()
|
|
|
|
|
+ .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);
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ ll_root.setVisibility(View.VISIBLE);
|
|
|
|
|
+ ll_root.animate().setDuration(shortAnimTime).alpha(show ? 0 : 1)
|
|
|
|
|
+ .setListener(new AnimatorListenerAdapter()
|
|
|
|
|
+ {
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void onAnimationEnd(Animator animation)
|
|
|
|
|
+ {
|
|
|
|
|
+ ll_root.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);
|
|
|
|
|
+ ll_root.setVisibility(show ? View.INVISIBLE : View.VISIBLE);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // @Override
|
|
|
|
|
+ // public void onActivityCreated(Bundle savedInstanceState)
|
|
|
|
|
+ // {
|
|
|
|
|
+ // FragmentManager fm = getFragmentManager();
|
|
|
|
|
+ //
|
|
|
|
|
+ // // Check to see if we have retained the worker fragment.
|
|
|
|
|
+ // mdataFragment = (DataFragment)fm.findFragmentByTag("work");
|
|
|
|
|
+ //
|
|
|
|
|
+ // // If not retained (or first time running), we need to create it.
|
|
|
|
|
+ // if (mdataFragment == null) {
|
|
|
|
|
+ // mdataFragment = new DataFragment();
|
|
|
|
|
+ // // Tell it who it is working with.
|
|
|
|
|
+ // mdataFragment.setTargetFragment(this, 0);
|
|
|
|
|
+ // fm.beginTransaction().add(mdataFragment, "work").commit();
|
|
|
|
|
+ // }
|
|
|
|
|
+ // super.onActivityCreated(savedInstanceState);
|
|
|
|
|
+ // }
|
|
|
|
|
+
|
|
|
|
|
+// private ShipMap mTrackingMap;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void onSaveInstanceState(Bundle outState) {
|
|
|
|
|
+ super.onSaveInstanceState(outState);
|
|
|
|
|
+
|
|
|
|
|
+ if (mContent != null) {
|
|
|
|
|
+ outState.putString("content",mContent.toString());
|
|
|
|
|
+ }
|
|
|
|
|
+ outState.putInt("selectContactPosition",mSelectContactPosition);
|
|
|
|
|
+ outState.putInt("selectTrackingPosition",mSelectTrackingPosition);
|
|
|
|
|
+ outState.putInt("selectTrackingChild",mSelectTrackingChild);
|
|
|
|
|
+ outState.putBoolean("mapZoomIn",mMapZoomIn);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+// private void configureMap(ShipMap map) {
|
|
|
|
|
+// if (map == null) {
|
|
|
|
|
+// return;
|
|
|
|
|
+// }
|
|
|
|
|
+//
|
|
|
|
|
+// map.setShowCurrent(true);
|
|
|
|
|
+// map.setShowDestination(true);
|
|
|
|
|
+// map.setShowOrigin(true);
|
|
|
|
|
+// map.setShowPor(true);
|
|
|
|
|
+// map.setShowPoe(true);
|
|
|
|
|
+// map.setShowPod(true);
|
|
|
|
|
+// map.setShowPol(true);
|
|
|
|
|
+//
|
|
|
|
|
+// map.setShipMapListener(this);
|
|
|
|
|
+// }
|
|
|
|
|
+
|
|
|
|
|
+ private RelativeLayout mDetailContainer;
|
|
|
|
|
+ private boolean mMapZoomIn = false;
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
|
|
|
|
+ Bundle savedInstanceState)
|
|
|
|
|
+ {
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ final Context context = getContext();
|
|
|
|
|
+ /* mGestureDetector = new GestureDetector(this); */
|
|
|
|
|
+
|
|
|
|
|
+ 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, null);
|
|
|
|
|
+//// mTrackingMap = view.findViewById(R.id.tracking_map);
|
|
|
|
|
+//// configureMap(mTrackingMap);
|
|
|
|
|
+// mDetailContainer = view.findViewById(R.id.detail_list_container);
|
|
|
|
|
+// } else {
|
|
|
|
|
+ view = inflater.inflate(R.layout.detail_fragment, null);
|
|
|
|
|
+// mTrackingMap = null;
|
|
|
|
|
+// }
|
|
|
|
|
+
|
|
|
|
|
+ if (savedInstanceState != null) {
|
|
|
|
|
+ fragment_content = savedInstanceState.getString("content");
|
|
|
|
|
+ mSelectContactPosition = savedInstanceState.getInt("selectContactPosition");
|
|
|
|
|
+ mSelectTrackingPosition = savedInstanceState.getInt("selectTrackingPosition");
|
|
|
|
|
+ mSelectTrackingChild = savedInstanceState.getInt("selectTrackingChild");
|
|
|
|
|
+ mMapZoomIn = savedInstanceState.getBoolean("mapZoomIn");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+// if (mTrackingMap != null) {
|
|
|
|
|
+// mTrackingMap.setZoomIn(mMapZoomIn);
|
|
|
|
|
+// }
|
|
|
|
|
+
|
|
|
|
|
+// if(this.getArguments().getString("action_type").equals("Tracing"))
|
|
|
|
|
+// {
|
|
|
|
|
+// LinearLayout ll1 = view.findViewById(R.id.detail_linear);
|
|
|
|
|
+//
|
|
|
|
|
+// ShipMap shipMap = new ShipMap(context);
|
|
|
|
|
+//// mShipMap = shipMap;
|
|
|
|
|
+//
|
|
|
|
|
+//
|
|
|
|
|
+// LinearLayout.LayoutParams mapLayoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 0,1.0f);
|
|
|
|
|
+// mapLayoutParams.setMargins(RAUtil.dp2px(context,5),RAUtil.dp2px(context,2),RAUtil.dp2px(context,5),RAUtil.dp2px(context,2));
|
|
|
|
|
+//
|
|
|
|
|
+// ll1.addView(shipMap,mapLayoutParams);
|
|
|
|
|
+//
|
|
|
|
|
+// }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ sl_root = (ScrollView) view.findViewById(R.id.sl_root);
|
|
|
|
|
+ /*
|
|
|
|
|
+ * sl_root.setOnTouchListener(new View.OnTouchListener() {
|
|
|
|
|
+ *
|
|
|
|
|
+ * @Override public boolean onTouch(View v, MotionEvent event) { return
|
|
|
|
|
+ * mGestureDetector.onTouchEvent(event); } });
|
|
|
|
|
+ */
|
|
|
|
|
+ ll_root = (LinearLayout) view.findViewById(R.id.ll_root);
|
|
|
|
|
+ mStatusView = view.findViewById(R.id.status);
|
|
|
|
|
+ LinearLayout ll = (LinearLayout) view.findViewById(R.id.ll_refresh);
|
|
|
|
|
+ Button btn_refresh = (Button) ll.findViewById(R.id.btn_refresh);
|
|
|
|
|
+ btn_refresh.setOnClickListener(new OnClickListener()
|
|
|
|
|
+ {
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void onClick(View v)
|
|
|
|
|
+ {
|
|
|
|
|
+ LinearLayout ll = (LinearLayout) ll_root
|
|
|
|
|
+ .findViewById(R.id.ll_refresh);
|
|
|
|
|
+ ll.setVisibility(View.GONE);
|
|
|
|
|
+
|
|
|
|
|
+ requestdata();
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ // 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;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+// protected JSONObject loadfakecontent(int rawid)
|
|
|
|
|
+// {
|
|
|
|
|
+//
|
|
|
|
|
+// String jstring = "";
|
|
|
|
|
+// try
|
|
|
|
|
+// {
|
|
|
|
|
+// InputStream in = getResources().openRawResource(rawid);
|
|
|
|
|
+// // 获取文件的字节数
|
|
|
|
|
+// int lenght = in.available();
|
|
|
|
|
+// // 创建byte数组
|
|
|
|
|
+// byte[] buffer = new byte[lenght];
|
|
|
|
|
+// // 将文件中的数据读到byte数组中
|
|
|
|
|
+// in.read(buffer);
|
|
|
|
|
+// jstring = EncodingUtils.getString(buffer, "UTF-8");
|
|
|
|
|
+// JSONObject jsobj = new JSONObject(jstring);
|
|
|
|
|
+// return jsobj;
|
|
|
|
|
+//// JSONObject objrecords = jsobj.getJSONObject("records");
|
|
|
|
|
+// }
|
|
|
|
|
+// catch (Exception e)
|
|
|
|
|
+// {
|
|
|
|
|
+// e.printStackTrace();
|
|
|
|
|
+// }
|
|
|
|
|
+// return null;
|
|
|
|
|
+//
|
|
|
|
|
+// }
|
|
|
|
|
+
|
|
|
|
|
+ public JSONObject mContent;
|
|
|
|
|
+
|
|
|
|
|
+ private int mSelectContactPosition = -1;
|
|
|
|
|
+ private int mSelectTrackingPosition = -1;
|
|
|
|
|
+ private int mSelectTrackingChild = -1;
|
|
|
|
|
+ private View mSelectedTrackingCell = null;
|
|
|
|
|
+
|
|
|
|
|
+ private void selectLocation(View view,int group,int child,JSONObject location) {
|
|
|
|
|
+
|
|
|
|
|
+ if (mSelectedTrackingCell != null) {
|
|
|
|
|
+ mSelectedTrackingCell.setBackgroundColor(Color.WHITE);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ mSelectTrackingPosition = group;
|
|
|
|
|
+ mSelectTrackingChild = child;
|
|
|
|
|
+ mSelectedTrackingCell = view;
|
|
|
|
|
+
|
|
|
|
|
+ if (mSelectedTrackingCell != null) {
|
|
|
|
|
+ mSelectedTrackingCell.setBackgroundColor(Color.LTGRAY);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+// if (mTrackingMap != null && location != null) {
|
|
|
|
|
+//
|
|
|
|
|
+// String backup_port=this.mContent.optString("backup_port");
|
|
|
|
|
+//
|
|
|
|
|
+// mTrackingMap.showShipAnnotation(location,backup_port);
|
|
|
|
|
+// }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ void init(String jstr, LayoutInflater inflater)
|
|
|
|
|
+ {
|
|
|
|
|
+// LayoutInflater inflater = (LayoutInflater) TradeFilingApplication
|
|
|
|
|
+// .get_instance().getSystemService(
|
|
|
|
|
+// Context.LAYOUT_INFLATER_SERVICE);
|
|
|
|
|
+
|
|
|
|
|
+ inflater=getActivity().getLayoutInflater();
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ String TAG = "init@DetailFragment";
|
|
|
|
|
+ Log.d(TAG, jstr);
|
|
|
|
|
+ try
|
|
|
|
|
+ {
|
|
|
|
|
+ JSONObject jsonObj = new JSONObject(jstr);
|
|
|
|
|
+
|
|
|
|
|
+ int group_count = jsonObj.getInt("count");
|
|
|
|
|
+
|
|
|
|
|
+// if (getArguments().getString("action_type").equals("Detail")) {
|
|
|
|
|
+// JSONObject commObj = loadfakecontent(R.raw.fake_comm);
|
|
|
|
|
+// jsonObj.put("group" + group_count++,commObj);
|
|
|
|
|
+// jsonObj.put("count",group_count);
|
|
|
|
|
+// }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ mContent = jsonObj;
|
|
|
|
|
+
|
|
|
|
|
+ if (group_count == 0)
|
|
|
|
|
+ {
|
|
|
|
|
+
|
|
|
|
|
+ TextView tv_empty = (TextView) ll_root
|
|
|
|
|
+ .findViewById(R.id.tv_empty);
|
|
|
|
|
+ tv_empty.setVisibility(View.VISIBLE);
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ NewDetailActivity activity = (NewDetailActivity) getActivity();
|
|
|
|
|
+ int tabCount = activity.getTabCount();
|
|
|
|
|
+
|
|
|
|
|
+ if(tabCount==1)
|
|
|
|
|
+ {
|
|
|
|
|
+ new AlertDialog.Builder(getContext())
|
|
|
|
|
+ .setTitle("Warning")
|
|
|
|
|
+ .setCancelable(false)
|
|
|
|
|
+ .setMessage("No Search Result.")
|
|
|
|
|
+ .setPositiveButton("Back", new DialogInterface.OnClickListener() {
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void onClick(DialogInterface dialog, int which) {
|
|
|
|
|
+ getActivity().finish();
|
|
|
|
|
+// checkAllPermission();
|
|
|
|
|
+// if (finalRequest)
|
|
|
|
|
+// checkAllPermission();
|
|
|
|
|
+// else
|
|
|
|
|
+// finish();
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+// .setNegativeButton("No", new DialogInterface.OnClickListener() {
|
|
|
|
|
+// @Override
|
|
|
|
|
+// public void onClick(DialogInterface dialog, int which) {
|
|
|
|
|
+// finish();
|
|
|
|
|
+// }
|
|
|
|
|
+// })
|
|
|
|
|
+ .show();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ for (int i = 0; i < group_count; i++)
|
|
|
|
|
+ {
|
|
|
|
|
+ // String key = (String) it.next();
|
|
|
|
|
+ // if (key.equals("result"))
|
|
|
|
|
+ // continue;
|
|
|
|
|
+ final JSONObject groupobj = jsonObj.getJSONObject("group" + i);
|
|
|
|
|
+ View v = inflater.inflate(R.layout.detail_group_tag, null);
|
|
|
|
|
+// v.setOnClickListener(this);
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ TextView tvgroup = (TextView) v.findViewById(R.id.tv_group);
|
|
|
|
|
+ String group_name = groupobj.getString("_name");
|
|
|
|
|
+ tvgroup.setText(group_name);
|
|
|
|
|
+ v.setId(RAUtil.generateViewId());
|
|
|
|
|
+ ll_root.addView(v);
|
|
|
|
|
+ String grouptype = groupobj.getString("_type");
|
|
|
|
|
+
|
|
|
|
|
+ v.setTag(grouptype);
|
|
|
|
|
+// v.setOnTouchListener(new View.OnTouchListener() {
|
|
|
|
|
+// @Override
|
|
|
|
|
+// public boolean onTouch(View view, MotionEvent motionEvent) {
|
|
|
|
|
+//
|
|
|
|
|
+// touchedView = view;
|
|
|
|
|
+// detector.onTouchEvent(motionEvent);
|
|
|
|
|
+//
|
|
|
|
|
+// return true;
|
|
|
|
|
+// }
|
|
|
|
|
+// });
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ // groupobj.remove("_type");
|
|
|
|
|
+ if (grouptype.equals("mapping"))
|
|
|
|
|
+ {
|
|
|
|
|
+ LinearLayout mappingview = (LinearLayout) inflater.inflate(
|
|
|
|
|
+ R.layout.detail_container_kv, null);
|
|
|
|
|
+ mappingview.setId(RAUtil.generateViewId());
|
|
|
|
|
+ control.put(v.getId(), mappingview.getId());
|
|
|
|
|
+ ll_root.addView(mappingview);
|
|
|
|
|
+
|
|
|
|
|
+ int map_count = groupobj.getInt("count");
|
|
|
|
|
+ for (int j = 0; j < map_count; j++)
|
|
|
|
|
+ {
|
|
|
|
|
+ // String keygroup = (String) itgroup.next();
|
|
|
|
|
+ JSONObject itemobj = groupobj.getJSONObject("item" + j);
|
|
|
|
|
+ final String key = (String) itemobj.keys().next();
|
|
|
|
|
+ final String val = itemobj.getString(key);
|
|
|
|
|
+ LinearLayout mappingitem = (LinearLayout) inflater
|
|
|
|
|
+ .inflate(R.layout.detail_cell_kv, null);
|
|
|
|
|
+ TextView tvkey = (TextView) mappingitem
|
|
|
|
|
+ .findViewById(R.id.tv_key);
|
|
|
|
|
+ tvkey.setText(key);
|
|
|
|
|
+ // tvkey.setBackgroundResource(R.drawable.detail_item);
|
|
|
|
|
+ TextView tvval = (TextView) mappingitem
|
|
|
|
|
+ .findViewById(R.id.tv_value);
|
|
|
|
|
+ tvval.setText(Html.fromHtml(val));
|
|
|
|
|
+ // tvval.setBackgroundResource(R.drawable.detail_item);
|
|
|
|
|
+
|
|
|
|
|
+ tvval.setOnTouchListener(new View.OnTouchListener() {
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public boolean onTouch(View view, MotionEvent motionEvent) {
|
|
|
|
|
+
|
|
|
|
|
+ copiedKey = key;
|
|
|
|
|
+ copiedVal = val;
|
|
|
|
|
+ detector.onTouchEvent(motionEvent);
|
|
|
|
|
+
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ mappingview.addView(mappingitem);
|
|
|
|
|
+ }
|
|
|
|
|
+ // Iterator itgroup = groupobj.keys();
|
|
|
|
|
+ // while (itgroup.hasNext())
|
|
|
|
|
+ // {
|
|
|
|
|
+ //
|
|
|
|
|
+ //
|
|
|
|
|
+ // }
|
|
|
|
|
+ }
|
|
|
|
|
+// else if (grouptype.equals("table"))
|
|
|
|
|
+// {
|
|
|
|
|
+// String content = groupobj.getString("content");
|
|
|
|
|
+// WebView wv;
|
|
|
|
|
+//
|
|
|
|
|
+// wv = (WebView) inflater.inflate(R.layout.web_content, null);
|
|
|
|
|
+//
|
|
|
|
|
+// wv.getSettings().setDefaultTextEncodingName("UTF-8");
|
|
|
|
|
+// wv.setId(RAUtil.generateViewId());
|
|
|
|
|
+// wv.setWebViewClient(new MyWebViewClient());
|
|
|
|
|
+//// wv.setDownloadListener(new DownloadListener()
|
|
|
|
|
+//// {
|
|
|
|
|
+////
|
|
|
|
|
+//// @Override
|
|
|
|
|
+//// public void onDownloadStart(String url,
|
|
|
|
|
+//// String userAgent, String contentDisposition,
|
|
|
|
|
+//// String mimetype, long contentLength)
|
|
|
|
|
+//// {
|
|
|
|
|
+//// if(!RAUtil.localdirExist())
|
|
|
|
|
+//// {
|
|
|
|
|
+////
|
|
|
|
|
+//// new AlertDialog.Builder(getActivity())
|
|
|
|
|
+//// .setIconAttribute(android.R.attr.alertDialogIcon)
|
|
|
|
|
+//// .setTitle(R.string.str_localdir_error)
|
|
|
|
|
+//// .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
|
|
|
|
|
+//// public void onClick(DialogInterface dialog, int whichButton) {
|
|
|
|
|
+////
|
|
|
|
|
+//// /* User clicked OK so do some stuff */
|
|
|
|
|
+//// }
|
|
|
|
|
+//// })
|
|
|
|
|
+//// .create().show();
|
|
|
|
|
+//// return;
|
|
|
|
|
+//// }
|
|
|
|
|
+////// String filename = contentDisposition.replace("attachment;filename=\"", "");
|
|
|
|
|
+////// filename = filename.replace("\"", "");
|
|
|
|
|
+//////
|
|
|
|
|
+////// Log.d("WebView", "Download Action");
|
|
|
|
|
+////// Log.d("tag", "url=" + url);
|
|
|
|
|
+////// // Log.i("tag", "userAgent="+userAgent);
|
|
|
|
|
+////// // Log.i("tag",
|
|
|
|
|
+////// // "contentDisposition="+contentDisposition);
|
|
|
|
|
+////// // Log.i("tag", "mimetype="+mimetype);
|
|
|
|
|
+////// // Log.i("tag", "contentLength="+contentLength);
|
|
|
|
|
+////// // Uri uri = Uri.parse(url);
|
|
|
|
|
+////// // Intent intent = new Intent(Intent.ACTION_VIEW,
|
|
|
|
|
+////// // uri);
|
|
|
|
|
+////// // startActivity(intent);
|
|
|
|
|
+//////
|
|
|
|
|
+////// final DownloadManager downloadManager = (DownloadManager) TradeFilingApplication
|
|
|
|
|
+////// .get_instance().getSystemService(
|
|
|
|
|
+////// Context.DOWNLOAD_SERVICE);
|
|
|
|
|
+//////
|
|
|
|
|
+////// Uri uri = Uri.parse(url);
|
|
|
|
|
+////// final Request request = new Request(uri);
|
|
|
|
|
+//////
|
|
|
|
|
+////// // 设置允许使用的网络类型,这里是移动网络和wifi都可以
|
|
|
|
|
+////// request.setAllowedNetworkTypes(DownloadManager.Request.NETWORK_MOBILE
|
|
|
|
|
+////// | DownloadManager.Request.NETWORK_WIFI);
|
|
|
|
|
+//////
|
|
|
|
|
+//////
|
|
|
|
|
+//////
|
|
|
|
|
+////// request.setDestinationInExternalPublicDir("Apex Mobile",filename);
|
|
|
|
|
+//////
|
|
|
|
|
+////// // 禁止发出通知,既后台下载,如果要使用这一句必须声明一个权限:android.permission.DOWNLOAD_WITHOUT_NOTIFICATION
|
|
|
|
|
+////// // request.setShowRunningNotification(false);
|
|
|
|
|
+//////
|
|
|
|
|
+////// // 不显示下载界面
|
|
|
|
|
+////// request.setVisibleInDownloadsUi(false);
|
|
|
|
|
+////// request.setNotificationVisibility(Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
|
|
|
|
|
+//////
|
|
|
|
|
+////// /*
|
|
|
|
|
+////// * 设置下载后文件存放的位置,如果sdcard不可用,那么设置这个将报错,
|
|
|
|
|
+////// * 因此最好不设置如果sdcard可用,下载后的文件 在/mnt/sdcard/Android/
|
|
|
|
|
+////// * data/packageName/files目录下面
|
|
|
|
|
+////// * ,如果sdcard不可用,设置了下面这个将报错,不设置,下载后的文件在/cache这个 目录下面
|
|
|
|
|
+////// */
|
|
|
|
|
+////// // request.setDestinationInExternalFilesDir(this,
|
|
|
|
|
+////// // null, "tar.apk");
|
|
|
|
|
+//////
|
|
|
|
|
+//////// getActivity();
|
|
|
|
|
+////// AlertDialog.Builder builder = new Builder(
|
|
|
|
|
+////// getActivity());
|
|
|
|
|
+////// builder.setMessage(getString(R.string.str_downloadmessage));
|
|
|
|
|
+//////
|
|
|
|
|
+////// builder.setTitle(getString(R.string.str_confirmdownload));
|
|
|
|
|
+//////
|
|
|
|
|
+////// builder.setPositiveButton(
|
|
|
|
|
+////// getString(R.string.str_download),
|
|
|
|
|
+////// new Dialog.OnClickListener()
|
|
|
|
|
+////// {
|
|
|
|
|
+//////
|
|
|
|
|
+////// @Override
|
|
|
|
|
+////// public void onClick(
|
|
|
|
|
+////// DialogInterface dialog,
|
|
|
|
|
+////// int which)
|
|
|
|
|
+////// {
|
|
|
|
|
+////// downloadManager.enqueue(request);
|
|
|
|
|
+////// dialog.dismiss();
|
|
|
|
|
+//////
|
|
|
|
|
+////// }
|
|
|
|
|
+////// });
|
|
|
|
|
+//////
|
|
|
|
|
+////// builder.setNegativeButton(
|
|
|
|
|
+////// getString(R.string.str_cancel),
|
|
|
|
|
+////// new Dialog.OnClickListener()
|
|
|
|
|
+////// {
|
|
|
|
|
+//////
|
|
|
|
|
+////// @Override
|
|
|
|
|
+////// public void onClick(
|
|
|
|
|
+////// DialogInterface dialog,
|
|
|
|
|
+////// int which)
|
|
|
|
|
+////// {
|
|
|
|
|
+////// dialog.dismiss();
|
|
|
|
|
+////// }
|
|
|
|
|
+////// });
|
|
|
|
|
+//////
|
|
|
|
|
+////// builder.create().show();
|
|
|
|
|
+////
|
|
|
|
|
+//// }
|
|
|
|
|
+////
|
|
|
|
|
+//// });
|
|
|
|
|
+// wv.setTag(i);
|
|
|
|
|
+// control.put(v.getId(), wv.getId());
|
|
|
|
|
+//
|
|
|
|
|
+// String encodedHtml = Base64.encodeToString(content.getBytes(), Base64.NO_PADDING);
|
|
|
|
|
+// wv.loadData(encodedHtml, mimeType, "base64");
|
|
|
|
|
+//// wv.loadData(content, mimeType, null);
|
|
|
|
|
+//
|
|
|
|
|
+// // wv.setOnTouchListener(new OnTouchListener()
|
|
|
|
|
+// // {
|
|
|
|
|
+// // @Override
|
|
|
|
|
+// // public boolean onTouch(View v, MotionEvent event)
|
|
|
|
|
+// // {
|
|
|
|
|
+// //
|
|
|
|
|
+// // if (event.getAction() == MotionEvent.ACTION_UP)
|
|
|
|
|
+// // sl_root.requestDisallowInterceptTouchEvent(false);
|
|
|
|
|
+// // else
|
|
|
|
|
+// // sl_root.requestDisallowInterceptTouchEvent(true);
|
|
|
|
|
+// //
|
|
|
|
|
+// // return false;
|
|
|
|
|
+// // }
|
|
|
|
|
+// // });
|
|
|
|
|
+// ll_root.addView(wv);
|
|
|
|
|
+// Log.d("table content", content);
|
|
|
|
|
+//
|
|
|
|
|
+// }
|
|
|
|
|
+// if (grouptype.equals("tracking"))
|
|
|
|
|
+// {
|
|
|
|
|
+// LinearLayout listview = (LinearLayout) inflater.inflate(
|
|
|
|
|
+// R.layout.list_content, null);
|
|
|
|
|
+//
|
|
|
|
|
+// listview.setId(RAUtil.generateViewId());
|
|
|
|
|
+//
|
|
|
|
|
+//
|
|
|
|
|
+// ViewGroup.LayoutParams lp=listview.getLayoutParams();
|
|
|
|
|
+// control.put(v.getId(), listview.getId());
|
|
|
|
|
+// ll_root.addView(listview);
|
|
|
|
|
+// long list_count = groupobj.getInt("count");
|
|
|
|
|
+// for (int j = 0; j < list_count; j++)
|
|
|
|
|
+// {
|
|
|
|
|
+// final JSONObject itemobj = groupobj.getJSONObject("item" + j);
|
|
|
|
|
+//
|
|
|
|
|
+// ConstraintLayout listitem = (ConstraintLayout) inflater
|
|
|
|
|
+// .inflate(R.layout.detail_tracking_cell, null);
|
|
|
|
|
+//
|
|
|
|
|
+//
|
|
|
|
|
+// ImageView icon = (ImageView) listitem
|
|
|
|
|
+// .findViewById(R.id.iv_thumb);
|
|
|
|
|
+//
|
|
|
|
|
+// String iconname = itemobj.getString("icon");
|
|
|
|
|
+// int rid = RAUtil.iconName2Rid(getActivity(),iconname);
|
|
|
|
|
+// icon.setImageResource(rid);
|
|
|
|
|
+// if(j!=0)
|
|
|
|
|
+// {
|
|
|
|
|
+// icon.setColorFilter(Color.GRAY);
|
|
|
|
|
+//// ColorMatrix matrix = new ColorMatrix();
|
|
|
|
|
+//// matrix.setSaturation(0);
|
|
|
|
|
+//// ColorMatrixColorFilter filter = new ColorMatrixColorFilter(matrix);
|
|
|
|
|
+//// icon..image.setColorFilter(filter);
|
|
|
|
|
+// }
|
|
|
|
|
+//
|
|
|
|
|
+// TextView tvitem = (TextView) listitem
|
|
|
|
|
+// .findViewById(R.id.tv_title);
|
|
|
|
|
+// String val = itemobj.getString("msg");
|
|
|
|
|
+// tvitem.setText(val);
|
|
|
|
|
+//
|
|
|
|
|
+// // tvitem.setBackgroundResource(R.drawable.detail_item);
|
|
|
|
|
+// // listitem.removeView(tvitem);
|
|
|
|
|
+//
|
|
|
|
|
+// int px=RAUtil.dp2px(getActivity(),56);
|
|
|
|
|
+// listitem.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, px, 1));
|
|
|
|
|
+// listview.addView(listitem);
|
|
|
|
|
+//// ViewGroup.LayoutParams lp1=listitem.getLayoutParams();
|
|
|
|
|
+//
|
|
|
|
|
+// final int selectIndex = i;
|
|
|
|
|
+// final int child = j;
|
|
|
|
|
+// final JSONObject location = groupobj.optJSONObject("location");
|
|
|
|
|
+//
|
|
|
|
|
+// listitem.setOnClickListener(new OnClickListener() {
|
|
|
|
|
+// @Override
|
|
|
|
|
+// public void onClick(View v) {
|
|
|
|
|
+//
|
|
|
|
|
+//// if (mTrackingMap != null) {
|
|
|
|
|
+//// JSONObject location = groupobj.optJSONObject("location");
|
|
|
|
|
+//// if (location != null) {
|
|
|
|
|
+//// mTrackingMap.showShipAnnotation(location);
|
|
|
|
|
+//// }
|
|
|
|
|
+//// mSelectTrackingPosition = selectIndex;
|
|
|
|
|
+//// }
|
|
|
|
|
+//
|
|
|
|
|
+// selectLocation(v,selectIndex,child,location);
|
|
|
|
|
+//
|
|
|
|
|
+// }
|
|
|
|
|
+// });
|
|
|
|
|
+//
|
|
|
|
|
+// if (mSelectTrackingPosition == -1) {
|
|
|
|
|
+// mSelectTrackingPosition = selectIndex;
|
|
|
|
|
+// }
|
|
|
|
|
+// if (mSelectTrackingChild == -1) {
|
|
|
|
|
+// mSelectTrackingChild = 0;
|
|
|
|
|
+// }
|
|
|
|
|
+//
|
|
|
|
|
+// if (mSelectTrackingPosition == selectIndex && mSelectTrackingChild == child) {
|
|
|
|
|
+//
|
|
|
|
|
+//// if (mTrackingMap != null) {
|
|
|
|
|
+//// JSONObject location = groupobj.optJSONObject("location");
|
|
|
|
|
+//// if (location != null) {
|
|
|
|
|
+//// mTrackingMap.showShipAnnotation(location);
|
|
|
|
|
+//// }
|
|
|
|
|
+//// }
|
|
|
|
|
+//
|
|
|
|
|
+// selectLocation(listitem,selectIndex,child,location);
|
|
|
|
|
+// }
|
|
|
|
|
+//
|
|
|
|
|
+// }
|
|
|
|
|
+//
|
|
|
|
|
+// }
|
|
|
|
|
+ if (grouptype.equals("container"))
|
|
|
|
|
+ {
|
|
|
|
|
+ LinearLayout containerview = (LinearLayout) inflater.inflate(
|
|
|
|
|
+ R.layout.detail_container_container, null);
|
|
|
|
|
+ containerview.setId(RAUtil.generateViewId());
|
|
|
|
|
+ control.put(v.getId(), containerview.getId());
|
|
|
|
|
+ ll_root.addView(containerview);
|
|
|
|
|
+ long container_count = groupobj.getInt("count");
|
|
|
|
|
+ for (int j = 0; j < container_count; j++)
|
|
|
|
|
+ {
|
|
|
|
|
+ ConstraintLayout containeritem = (ConstraintLayout) inflater
|
|
|
|
|
+ .inflate(R.layout.detail_cell_container, null);
|
|
|
|
|
+
|
|
|
|
|
+ JSONObject item=groupobj.getJSONObject("item"+j);
|
|
|
|
|
+ String container_no = item.optString("container#");
|
|
|
|
|
+ String size = item.optString("size");
|
|
|
|
|
+ String seal_no = item.optString("seal_no");
|
|
|
|
|
+ String qty = item.optString("qty");
|
|
|
|
|
+ String service = item.optString("service");
|
|
|
|
|
+ String weight = item.optString("weight");
|
|
|
|
|
+
|
|
|
|
|
+ TextView tv_container = (TextView) containeritem
|
|
|
|
|
+ .findViewById(R.id.tv_container_no);
|
|
|
|
|
+ tv_container.setText(container_no);
|
|
|
|
|
+
|
|
|
|
|
+ TextView tv_size = (TextView) containeritem
|
|
|
|
|
+ .findViewById(R.id.tv_size);
|
|
|
|
|
+ tv_size.setText(size);
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ TextView tv_seal_no = (TextView) containeritem
|
|
|
|
|
+ .findViewById(R.id.tv_seal_no);
|
|
|
|
|
+ tv_seal_no.setText(seal_no);
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ TextView tv_qty = (TextView) containeritem
|
|
|
|
|
+ .findViewById(R.id.tv_qty);
|
|
|
|
|
+ tv_qty.setText(qty);
|
|
|
|
|
+
|
|
|
|
|
+ TextView tv_service = (TextView) containeritem
|
|
|
|
|
+ .findViewById(R.id.tv_service);
|
|
|
|
|
+ tv_service.setText(service);
|
|
|
|
|
+
|
|
|
|
|
+ TextView tv_weight = (TextView) containeritem
|
|
|
|
|
+ .findViewById(R.id.tv_weight);
|
|
|
|
|
+ tv_weight.setText(weight);
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+//// String val = groupobj.getString("item" + j);
|
|
|
|
|
+//
|
|
|
|
|
+// String val = item.getString("text");
|
|
|
|
|
+// boolean bgcolor=item.getBoolean("bg");
|
|
|
|
|
+// tvitem.setText(val);
|
|
|
|
|
+// // tvitem.setBackgroundResource(R.drawable.detail_item);
|
|
|
|
|
+// listitem.removeView(tvitem);
|
|
|
|
|
+
|
|
|
|
|
+ containerview.addView(containeritem);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if (grouptype.equals("container_ca"))
|
|
|
|
|
+ {
|
|
|
|
|
+ LinearLayout containerview = (LinearLayout) inflater.inflate(
|
|
|
|
|
+ R.layout.detail_container_container_ca, null);
|
|
|
|
|
+ containerview.setId(RAUtil.generateViewId());
|
|
|
|
|
+ control.put(v.getId(), containerview.getId());
|
|
|
|
|
+ ll_root.addView(containerview);
|
|
|
|
|
+ long container_count = groupobj.getInt("count");
|
|
|
|
|
+ for (int j = 0; j < container_count; j++)
|
|
|
|
|
+ {
|
|
|
|
|
+ ConstraintLayout containeritem = (ConstraintLayout) inflater
|
|
|
|
|
+ .inflate(R.layout.detail_cell_container_ca, null);
|
|
|
|
|
+
|
|
|
|
|
+ final JSONObject item=groupobj.getJSONObject("item"+j);
|
|
|
|
|
+ String container_no = item.optString("container#");
|
|
|
|
|
+// String size = item.optString("size");
|
|
|
|
|
+ String seal_no = item.optString("seal_no");
|
|
|
|
|
+// String qty = item.optString("qty");
|
|
|
|
|
+// String service = item.optString("service");
|
|
|
|
|
+// String weight = item.optString("weight");
|
|
|
|
|
+
|
|
|
|
|
+ TextView tv_container = (TextView) containeritem
|
|
|
|
|
+ .findViewById(R.id.tv_container_no);
|
|
|
|
|
+ tv_container.setText(container_no);
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ TextView tv_seal_no = (TextView) containeritem
|
|
|
|
|
+ .findViewById(R.id.tv_seal_no);
|
|
|
|
|
+ tv_seal_no.setText(seal_no);
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+//// String val = groupobj.getString("item" + j);
|
|
|
|
|
+//
|
|
|
|
|
+// String val = item.getString("text");
|
|
|
|
|
+// boolean bgcolor=item.getBoolean("bg");
|
|
|
|
|
+// tvitem.setText(val);
|
|
|
|
|
+// // tvitem.setBackgroundResource(R.drawable.detail_item);
|
|
|
|
|
+// listitem.removeView(tvitem);
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ containeritem.setOnTouchListener(new View.OnTouchListener() {
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public boolean onTouch(View view, MotionEvent motionEvent) {
|
|
|
|
|
+
|
|
|
|
|
+ containerID=item.optString("id");
|
|
|
|
|
+ touchedView = view;
|
|
|
|
|
+ detector.onTouchEvent(motionEvent);
|
|
|
|
|
+
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ containerview.addView(containeritem);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if (grouptype.equals("log"))
|
|
|
|
|
+ {
|
|
|
|
|
+ LinearLayout listview = (LinearLayout) inflater.inflate(
|
|
|
|
|
+ R.layout.detail_container_list, null);
|
|
|
|
|
+ listview.setId(RAUtil.generateViewId());
|
|
|
|
|
+ control.put(v.getId(), listview.getId());
|
|
|
|
|
+ ll_root.addView(listview);
|
|
|
|
|
+ long list_count = groupobj.getInt("count");
|
|
|
|
|
+ for (int j = 0; j < list_count; j++)
|
|
|
|
|
+ {
|
|
|
|
|
+ RelativeLayout listitem = (RelativeLayout) inflater
|
|
|
|
|
+ .inflate(R.layout.detail_cell_list, null);
|
|
|
|
|
+
|
|
|
|
|
+ TextView tvitem = (TextView) listitem
|
|
|
|
|
+ .findViewById(R.id.tv_item);
|
|
|
|
|
+// String val = groupobj.getString("item" + j);
|
|
|
|
|
+ JSONObject item=groupobj.getJSONObject("item"+j);
|
|
|
|
|
+ String val = item.getString("text");
|
|
|
|
|
+ boolean bgcolor=item.getBoolean("bg");
|
|
|
|
|
+ tvitem.setText(val);
|
|
|
|
|
+ // tvitem.setBackgroundResource(R.drawable.detail_item);
|
|
|
|
|
+ listitem.removeView(tvitem);
|
|
|
|
|
+
|
|
|
|
|
+ listview.addView(tvitem);
|
|
|
|
|
+ }
|
|
|
|
|
+ // Iterator itgroup = groupobj.keys();
|
|
|
|
|
+ // while (itgroup.hasNext())
|
|
|
|
|
+ // {
|
|
|
|
|
+ // String keygroup = (String) itgroup.next();
|
|
|
|
|
+ //
|
|
|
|
|
+ // }
|
|
|
|
|
+ }
|
|
|
|
|
+ if (grouptype.equals("list"))
|
|
|
|
|
+ {
|
|
|
|
|
+ LinearLayout listview = (LinearLayout) inflater.inflate(
|
|
|
|
|
+ R.layout.detail_container_list, null);
|
|
|
|
|
+ listview.setId(RAUtil.generateViewId());
|
|
|
|
|
+ control.put(v.getId(), listview.getId());
|
|
|
|
|
+ ll_root.addView(listview);
|
|
|
|
|
+ long list_count = groupobj.getInt("count");
|
|
|
|
|
+ for (int j = 0; j < list_count; j++)
|
|
|
|
|
+ {
|
|
|
|
|
+ RelativeLayout listitem = (RelativeLayout) inflater
|
|
|
|
|
+ .inflate(R.layout.detail_cell_list, null);
|
|
|
|
|
+
|
|
|
|
|
+ TextView tvitem = (TextView) listitem
|
|
|
|
|
+ .findViewById(R.id.tv_item);
|
|
|
|
|
+ String val = groupobj.getString("line" + j);
|
|
|
|
|
+ tvitem.setText(val);
|
|
|
|
|
+ // tvitem.setBackgroundResource(R.drawable.detail_item);
|
|
|
|
|
+ listitem.removeView(tvitem);
|
|
|
|
|
+
|
|
|
|
|
+ listview.addView(tvitem);
|
|
|
|
|
+ }
|
|
|
|
|
+ // Iterator itgroup = groupobj.keys();
|
|
|
|
|
+ // while (itgroup.hasNext())
|
|
|
|
|
+ // {
|
|
|
|
|
+ // String keygroup = (String) itgroup.next();
|
|
|
|
|
+ //
|
|
|
|
|
+ // }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ // String value = obj.getString(key);
|
|
|
|
|
+ // JSONArray array = obj.getJSONArray(key);
|
|
|
|
|
+ // for(int i=0;i<array.length();i++){
|
|
|
|
|
+ // JSONObject jsonobject = array.getJSONObject(i);
|
|
|
|
|
+ // jsonobject.put("name", key);
|
|
|
|
|
+ // jsonobject.put("exp", key+"="+jsonobject.getString("value"));
|
|
|
|
|
+ // newArray.put(jsonobject);
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ // Iterator it = jsonObj.keys();
|
|
|
|
|
+ // while (it.hasNext())
|
|
|
|
|
+ // {
|
|
|
|
|
+ //
|
|
|
|
|
+ // }
|
|
|
|
|
+ }
|
|
|
|
|
+ catch (JSONException e)
|
|
|
|
|
+ {
|
|
|
|
|
+ // TODO Auto-generated catch block
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private JSONObject getGroup(int group) {
|
|
|
|
|
+ if (mContent != null) {
|
|
|
|
|
+ JSONObject groupobj = mContent.optJSONObject("group" + group);
|
|
|
|
|
+ return groupobj;
|
|
|
|
|
+ }
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private boolean validateEmail(String email) {
|
|
|
|
|
+
|
|
|
|
|
+ String emailRegex = "[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,4}";
|
|
|
|
|
+
|
|
|
|
|
+ return Pattern.matches(emailRegex,email);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void onClick(View v)
|
|
|
|
|
+ {
|
|
|
|
|
+
|
|
|
|
|
+// JSONArray actions = mPresenter.getActions();
|
|
|
|
|
+// if (actions == null) {
|
|
|
|
|
+// actions = new JSONArray();
|
|
|
|
|
+// }
|
|
|
|
|
+
|
|
|
|
|
+ Intent intent = new Intent(getContext(), NewDetailActivity.class);
|
|
|
|
|
+
|
|
|
|
|
+// NSString* cid=[item[@"id"] stringValue];
|
|
|
|
|
+ intent.putExtra("sub_type", "container");
|
|
|
|
|
+ intent.putExtra("action_type", "Container Detail");
|
|
|
|
|
+ intent.putExtra("action", "detail");
|
|
|
|
|
+ intent.putExtra("action0", "Container Detail");
|
|
|
|
|
+ intent.putExtra("actions_count", 1);
|
|
|
|
|
+
|
|
|
|
|
+ Bundle params = new Bundle();
|
|
|
|
|
+ params.putString("id",containerID);
|
|
|
|
|
+ intent.putExtra("bundle_params",params);
|
|
|
|
|
+// intent.putExtra("_id",detail_id);
|
|
|
|
|
+// if(_schema!=null)
|
|
|
|
|
+// intent.putExtra("_schema",_schema);
|
|
|
|
|
+
|
|
|
|
|
+// for (int i = 0; i < actions.length(); i++) {
|
|
|
|
|
+// try {
|
|
|
|
|
+// String name = actions.getString(i);
|
|
|
|
|
+// intent.putExtra("action" + i, name);
|
|
|
|
|
+// } catch (JSONException e) {
|
|
|
|
|
+// e.printStackTrace();
|
|
|
|
|
+// }
|
|
|
|
|
+// }
|
|
|
|
|
+
|
|
|
|
|
+ startActivity(intent);
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+// View view = ll_root.findViewById(control.get(v.getId()));
|
|
|
|
|
+// ImageView expand_iv = v.findViewById(R.id.group_expand_indicator);
|
|
|
|
|
+// if (view.getVisibility() == View.VISIBLE) {
|
|
|
|
|
+// expand_iv.setImageResource(R.drawable.ic_expand_less);
|
|
|
|
|
+// view.setVisibility(View.GONE);
|
|
|
|
|
+// }
|
|
|
|
|
+// else {
|
|
|
|
|
+// expand_iv.setImageResource(R.drawable.ic_expand_more);
|
|
|
|
|
+// view.setVisibility(View.VISIBLE);
|
|
|
|
|
+// }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void onDestroy()
|
|
|
|
|
+ {
|
|
|
|
|
+ if (m_task != null)
|
|
|
|
|
+ m_task.cancel(true);
|
|
|
|
|
+ super.onDestroy();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void onActivityResult(int requestCode, int resultCode, Intent data)
|
|
|
|
|
+ {
|
|
|
|
|
+// ((NewDetailActivity) getActivity()).showlogin = false;
|
|
|
|
|
+ super.onActivityResult(requestCode, resultCode, data);
|
|
|
|
|
+
|
|
|
|
|
+// if (requestCode == People_Pick_Code && data != null) {
|
|
|
|
|
+// Uri contactData = data.getData();
|
|
|
|
|
+// if (contactData == null) {
|
|
|
|
|
+// return;
|
|
|
|
|
+// }
|
|
|
|
|
+// Cursor c = mContext.getContentResolver().query(contactData, null, null, null, null);
|
|
|
|
|
+//
|
|
|
|
|
+//
|
|
|
|
|
+// if (c.moveToFirst()) {
|
|
|
|
|
+// String contactId = c.getString(c.getColumnIndex(ContactsContract.Contacts._ID));
|
|
|
|
|
+//
|
|
|
|
|
+// Cursor cursor = mContext.getContentResolver().query(
|
|
|
|
|
+// ContactsContract.CommonDataKinds.Email.CONTENT_URI,
|
|
|
|
|
+// new String[]{ContactsContract.CommonDataKinds.Email.DATA, ContactsContract.CommonDataKinds.Email.TYPE}, ContactsContract.Data.CONTACT_ID + "='" + contactId + "'", null, null);
|
|
|
|
|
+//
|
|
|
|
|
+// while(cursor.moveToNext()) {
|
|
|
|
|
+// String email = cursor.getString(cursor.getColumnIndex(ContactsContract.CommonDataKinds.Email.DATA));
|
|
|
|
|
+// String emailType = cursor.getString(cursor.getColumnIndex(ContactsContract.CommonDataKinds.Email.TYPE));
|
|
|
|
|
+//
|
|
|
|
|
+// email = email.replace("\r\n",";");
|
|
|
|
|
+// email = email.replace("\r",";");
|
|
|
|
|
+// email = email.replace("\n",";");
|
|
|
|
|
+//
|
|
|
|
|
+// String[] emailArr = email.split(";");
|
|
|
|
|
+// for (int i = 0; i < emailArr.length; i++) {
|
|
|
|
|
+// email = emailArr[i];
|
|
|
|
|
+// if (email.length() > 0) {
|
|
|
|
|
+// if (emailType != null && Integer.valueOf(emailType) == ContactsContract.CommonDataKinds.Email.TYPE_WORK) {
|
|
|
|
|
+// appendContactEmail(email,mSelectContactPosition);
|
|
|
|
|
+// dbUtil.CloseCursor(c);
|
|
|
|
|
+// dbUtil.CloseCursor(cursor);
|
|
|
|
|
+// return;
|
|
|
|
|
+// }
|
|
|
|
|
+// }
|
|
|
|
|
+// }
|
|
|
|
|
+//
|
|
|
|
|
+//
|
|
|
|
|
+// }
|
|
|
|
|
+//
|
|
|
|
|
+// dbUtil.CloseCursor(cursor);
|
|
|
|
|
+//
|
|
|
|
|
+// }
|
|
|
|
|
+// dbUtil.CloseCursor(c);
|
|
|
|
|
+// mSelectContactPosition = -1;
|
|
|
|
|
+// }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void onDetach()
|
|
|
|
|
+ {
|
|
|
|
|
+ if (m_task != null)
|
|
|
|
|
+ m_task.cancel(false);
|
|
|
|
|
+ super.onDetach();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ class SearchTask extends AsyncTask<Void, Void, Boolean>
|
|
|
|
|
+ {
|
|
|
|
|
+ int errorcode;
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ protected Boolean doInBackground(Void... params)
|
|
|
|
|
+ {
|
|
|
|
|
+ Log.d("SearchTask", "doInBackground");
|
|
|
|
|
+ if (!OnlineDataProvider.NetworkIsAvailable())
|
|
|
|
|
+
|
|
|
|
|
+ {
|
|
|
|
|
+ errorcode = OnlineDataProvider.RESULT_NET_NOTAVAILABLE;
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ JSONObject jsonResult = RADataProvider.TabDetail(getArguments());
|
|
|
|
|
+ String jstr=jsonResult.toString();
|
|
|
|
|
+ if (jstr == null || jstr.length() <= 0)
|
|
|
|
|
+ {
|
|
|
|
|
+ // Log.d(TAG, "json is wrong");
|
|
|
|
|
+
|
|
|
|
|
+ errorcode = OnlineDataProvider.RESULT_NET_ERROR;
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // mdataFragment.put_result(jstr);
|
|
|
|
|
+ fragment_content = jstr;
|
|
|
|
|
+ NewDetailActivity activity = (NewDetailActivity) getActivity();
|
|
|
|
|
+ activity.save_content(getArguments().getString("action_type"), jstr);
|
|
|
|
|
+
|
|
|
|
|
+ errorcode = OnlineDataProvider.RESULT_TRUE;
|
|
|
|
|
+
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ protected void onPostExecute(Boolean success)
|
|
|
|
|
+ {
|
|
|
|
|
+ Log.i("onPostExecute", "entry");
|
|
|
|
|
+ m_task = null;
|
|
|
|
|
+ showProgress(false);
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ switch (errorcode)
|
|
|
|
|
+ {
|
|
|
|
|
+ case OnlineDataProvider.RESULT_NET_NOTAVAILABLE:
|
|
|
|
|
+ {
|
|
|
|
|
+ Toast toast = Toast.makeText(
|
|
|
|
|
+ TradeFilingApplication.get_instance(),
|
|
|
|
|
+ getText(R.string.msg_connection_none),
|
|
|
|
|
+ Toast.LENGTH_LONG);
|
|
|
|
|
+ toast.setGravity(Gravity.CENTER, 0, 0);
|
|
|
|
|
+ toast.show();
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ case OnlineDataProvider.RESULT_NET_ERROR:
|
|
|
|
|
+ {
|
|
|
|
|
+ Toast toast = Toast.makeText(
|
|
|
|
|
+ TradeFilingApplication.get_instance(),
|
|
|
|
|
+ getText(R.string.msg_net_error), Toast.LENGTH_LONG);
|
|
|
|
|
+ toast.setGravity(Gravity.CENTER, 0, 0);
|
|
|
|
|
+ toast.show();
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ case OnlineDataProvider.RESULT_ERROR:
|
|
|
|
|
+ // case Network.RESULT_RESPONSE_NULL:
|
|
|
|
|
+ {
|
|
|
|
|
+
|
|
|
|
|
+ Toast toast = Toast.makeText(
|
|
|
|
|
+ TradeFilingApplication.get_instance(),
|
|
|
|
|
+ getText(R.string.msg_net_resulterror) + ":"
|
|
|
|
|
+ + errorcode, Toast.LENGTH_LONG);
|
|
|
|
|
+ toast.setGravity(Gravity.CENTER, 0, 0);
|
|
|
|
|
+ toast.show();
|
|
|
|
|
+
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ default:
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (success)
|
|
|
|
|
+ {
|
|
|
|
|
+ LayoutInflater inflater = (LayoutInflater) TradeFilingApplication
|
|
|
|
|
+ .get_instance().getSystemService(
|
|
|
|
|
+ Context.LAYOUT_INFLATER_SERVICE);
|
|
|
|
|
+
|
|
|
|
|
+ init(fragment_content, inflater/*
|
|
|
|
|
+ * getActivity().
|
|
|
|
|
+ * getLayoutInflater()
|
|
|
|
|
+ */);
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ LinearLayout ll = (LinearLayout) ll_root
|
|
|
|
|
+ .findViewById(R.id.ll_refresh);
|
|
|
|
|
+ ll.setVisibility(View.VISIBLE);
|
|
|
|
|
+ }
|
|
|
|
|
+ super.onPostExecute(success);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ protected void onCancelled()
|
|
|
|
|
+ {
|
|
|
|
|
+ m_task = null;
|
|
|
|
|
+ showProgress(false);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ private void showQuickLook(final String url) {
|
|
|
|
|
+
|
|
|
|
|
+ showProgressDialog("Please wait","Downloading...");
|
|
|
|
|
+ new Thread(new Runnable() {
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void run() {
|
|
|
|
|
+
|
|
|
|
|
+ String cacheDir = TradeFilingApplication.getInstance().getExternalCacheDir().getAbsolutePath();//TradeFilingApplication.getInstance().getDocumentDir();
|
|
|
|
|
+
|
|
|
|
|
+ final Bundle param = new Bundle();
|
|
|
|
|
+ // 下载文件
|
|
|
|
|
+ final File downloadFile = OnlineDataProvider.downloadFile(param,url,cacheDir);
|
|
|
|
|
+
|
|
|
|
|
+ getActivity().runOnUiThread(new Runnable() {
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void run() {
|
|
|
|
|
+ progressDialog.dismiss();
|
|
|
|
|
+ if (downloadFile != null && downloadFile.exists()) {
|
|
|
|
|
+ String email = null,email_subject = null,email_content = null;
|
|
|
|
|
+ //此处需要新增保存文档的本地表
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ try {
|
|
|
|
|
+ email = mContent.getString("email");
|
|
|
|
|
+ email_subject = mContent.getString("email_subject");
|
|
|
|
|
+ email_content = mContent.getString("email_content");
|
|
|
|
|
+
|
|
|
|
|
+ } catch (JSONException e) {
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+// email=param.getString("email");
|
|
|
|
|
+// email_subject=param.getString("email_subject");
|
|
|
|
|
+// email_content=param.getString("email_content");
|
|
|
|
|
+
|
|
|
|
|
+ previewPDF(downloadFile.getAbsolutePath(),email,email_subject,email_content);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ showAlert("Sorry,there is a wrong.");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ }).start();
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 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 void showAlert(String msg) {
|
|
|
|
|
+ if (msg == null || msg.isEmpty()) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ new androidx.appcompat.app.AlertDialog.Builder(mContext)
|
|
|
|
|
+ .setMessage(msg)
|
|
|
|
|
+ .show();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ protected void previewPDF(String file,String email,String subject,String content) {
|
|
|
|
|
+ Intent myIntent = new Intent();
|
|
|
|
|
+ myIntent = new Intent(getActivity(), RAPDFPreviewActivity.class);
|
|
|
|
|
+
|
|
|
|
|
+ myIntent.putExtra("file",file);
|
|
|
|
|
+ myIntent.putExtra("iscache",true);
|
|
|
|
|
+
|
|
|
|
|
+ try {
|
|
|
|
|
+ JSONObject json = new JSONObject();
|
|
|
|
|
+// email = "66666@qq.com";
|
|
|
|
|
+// subject = "test subject";
|
|
|
|
|
+// content = "test body";
|
|
|
|
|
+ if (email != null) {
|
|
|
|
|
+ json.put("email",email);
|
|
|
|
|
+ }
|
|
|
|
|
+ if (subject != null) {
|
|
|
|
|
+ json.put("subject",subject);
|
|
|
|
|
+ }
|
|
|
|
|
+ if (content != null) {
|
|
|
|
|
+ json.put("content",content);
|
|
|
|
|
+ }
|
|
|
|
|
+ myIntent.putExtra("email",json.toString());
|
|
|
|
|
+ } catch (JSONException e) {
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ startActivity(myIntent);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ public void download(String url) {
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+//
|
|
|
|
|
+// final String download_url = url;
|
|
|
|
|
+//
|
|
|
|
|
+// showQuickLook(url);
|
|
|
|
|
+// if(true)
|
|
|
|
|
+// return;
|
|
|
|
|
+//
|
|
|
|
|
+// showProgressDialog("Please wait","Downloading...");
|
|
|
|
|
+// new Thread(new Runnable() {
|
|
|
|
|
+// @Override
|
|
|
|
|
+// public void run() {
|
|
|
|
|
+//
|
|
|
|
|
+//// String cacheDir = TradeFilingApplication.getInstance().getDocumentDir();
|
|
|
|
|
+// // 下载文件
|
|
|
|
|
+// final File downloadFile = OnlineDataProvider.downloadFile(null,download_url,null);
|
|
|
|
|
+//
|
|
|
|
|
+// getActivity().runOnUiThread(new Runnable() {
|
|
|
|
|
+// @Override
|
|
|
|
|
+// public void run() {
|
|
|
|
|
+// progressDialog.dismiss();
|
|
|
|
|
+// RAUtil.openFile(getActivity(),downloadFile);
|
|
|
|
|
+// }
|
|
|
|
|
+// });
|
|
|
|
|
+//
|
|
|
|
|
+// }
|
|
|
|
|
+// }).start();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public class MyWebViewClient extends WebViewClient
|
|
|
|
|
+ {
|
|
|
|
|
+ // 如果页面中链接,如果希望点击链接继续在当前browser中响应,
|
|
|
|
|
+ // 而不是新开Android的系统browser中响应该链接,必须覆盖 webview的WebViewClient对象。
|
|
|
|
|
+ public boolean shouldOverviewUrlLoading(WebView view, String url)
|
|
|
|
|
+ {
|
|
|
|
|
+ Log.d("Web Client", "shouldOverviewUrlLoading: " + url);
|
|
|
|
|
+ // L.i("shouldOverviewUrlLoading");
|
|
|
|
|
+ view.loadUrl(url);
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) {
|
|
|
|
|
+ Log.d("Web Client", "shouldOverrideUrlLoading: " + request);
|
|
|
|
|
+ return super.shouldOverrideUrlLoading(view, request);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public void onPageStarted(WebView view, String url, Bitmap favicon)
|
|
|
|
|
+ {
|
|
|
|
|
+ // L.i("onPageStarted");
|
|
|
|
|
+ // showProgress();
|
|
|
|
|
+ Log.d("Web Client", "onPageStarted: ");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public void onPageFinished(WebView view, String url)
|
|
|
|
|
+ {
|
|
|
|
|
+ // L.i("onPageFinished");
|
|
|
|
|
+ // closeProgress();
|
|
|
|
|
+ Log.d("Web Client", "onPageFinished: ");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public void onReceivedError(WebView view, int errorCode,
|
|
|
|
|
+ String description, String failingUrl)
|
|
|
|
|
+ {
|
|
|
|
|
+ // L.i("onReceivedError");
|
|
|
|
|
+ // closeProgress();
|
|
|
|
|
+ Log.d("Web Client", "onReceivedError: ");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public WebResourceResponse shouldInterceptRequest(WebView view, String url) {
|
|
|
|
|
+
|
|
|
|
|
+ Log.d("Web Client", "shouldInterceptRequest: " + url);
|
|
|
|
|
+ if (url.startsWith("http") && url.contains("action_type=download_doc")) {
|
|
|
|
|
+ download(url);
|
|
|
|
|
+
|
|
|
|
|
+ String content = contentOfWebView(view);
|
|
|
|
|
+ WebResourceResponse response = new WebResourceResponse("text/html",
|
|
|
|
|
+ "utf-8",
|
|
|
|
|
+ new ByteArrayInputStream(content.getBytes()));
|
|
|
|
|
+ return response;
|
|
|
|
|
+
|
|
|
|
|
+ } else {
|
|
|
|
|
+ return super.shouldInterceptRequest(view,url);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ String contentOfWebView(WebView webView) {
|
|
|
|
|
+
|
|
|
|
|
+ int i = (int)webView.getTag();
|
|
|
|
|
+ try {
|
|
|
|
|
+
|
|
|
|
|
+ JSONObject groupobj = mContent.getJSONObject("group" + i);
|
|
|
|
|
+ String content = groupobj.getString("content");
|
|
|
|
|
+ return content;
|
|
|
|
|
+ } catch (JSONException e) {
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+// @Override
|
|
|
|
|
+// public WebResourceResponse shouldInterceptRequest(WebView view, WebResourceRequest request) {
|
|
|
|
|
+// Log.d("Web Client", "shouldInterceptRequest: " + request);
|
|
|
|
|
+//
|
|
|
|
|
+// if (request.getUrl().toString().contains("action_type=download_doc")) {
|
|
|
|
|
+// return null;
|
|
|
|
|
+// } else {
|
|
|
|
|
+// return super.shouldInterceptRequest(view,request);
|
|
|
|
|
+// }
|
|
|
|
|
+//
|
|
|
|
|
+//
|
|
|
|
|
+// }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private void appendContactEmail(String email,int group) {
|
|
|
|
|
+
|
|
|
|
|
+ try {
|
|
|
|
|
+
|
|
|
|
|
+ String groupKey = "group" + group;
|
|
|
|
|
+
|
|
|
|
|
+ JSONObject groupObj = mContent.getJSONObject(groupKey);
|
|
|
|
|
+ String groupType = groupObj.getString("_type");
|
|
|
|
|
+
|
|
|
|
|
+ if (groupType.equals("communication")) {
|
|
|
|
|
+
|
|
|
|
|
+ String oldCC = groupObj.optString("cc");
|
|
|
|
|
+ if (oldCC == null || oldCC.length() == 0) {
|
|
|
|
|
+ oldCC = email + ";";
|
|
|
|
|
+ } else {
|
|
|
|
|
+ if (oldCC.substring(oldCC.length() - 1).equals(";")) {
|
|
|
|
|
+ oldCC = oldCC + email + ";";
|
|
|
|
|
+ } else {
|
|
|
|
|
+ oldCC = oldCC + ";" + email + ";";
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ commContentChange(oldCC,group,0);
|
|
|
|
|
+
|
|
|
|
|
+ EditText ccTv = ll_root.findViewWithTag("group_" + group + "_cc");
|
|
|
|
|
+ if (ccTv != null) {
|
|
|
|
|
+ ccTv.setText(oldCC);
|
|
|
|
|
+ ccTv.requestFocus();
|
|
|
|
|
+ ccTv.setSelection(oldCC.length());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ } catch (JSONException e) {
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private void commContentChange(String content,int group,int child) {
|
|
|
|
|
+
|
|
|
|
|
+ try {
|
|
|
|
|
+
|
|
|
|
|
+ String groupKey = "group" + group;
|
|
|
|
|
+
|
|
|
|
|
+ JSONObject groupObj = mContent.getJSONObject(groupKey);
|
|
|
|
|
+ String groupType = groupObj.getString("_type");
|
|
|
|
|
+
|
|
|
|
|
+ if (groupType.equals("communication")) {
|
|
|
|
|
+
|
|
|
|
|
+ if (child == 0) {
|
|
|
|
|
+ groupObj.put("cc",content);
|
|
|
|
|
+ } else if (child == 1) {
|
|
|
|
|
+ groupObj.put("edit_content",content);
|
|
|
|
|
+ }
|
|
|
|
|
+ mContent.put(groupKey,groupObj);
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ } catch (JSONException e) {
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ public class TextFieldTextWatcher implements TextWatcher {
|
|
|
|
|
+
|
|
|
|
|
+ Context mCtx;
|
|
|
|
|
+ int group;
|
|
|
|
|
+ int child;
|
|
|
|
|
+ EditText textView;
|
|
|
|
|
+
|
|
|
|
|
+ public TextFieldTextWatcher(Context ctx,EditText textView,int group,int child) {
|
|
|
|
|
+ this.mCtx = ctx;
|
|
|
|
|
+ this.textView = textView;
|
|
|
|
|
+ this.group = group;
|
|
|
|
|
+ this.child = child;
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ String origin_text;
|
|
|
|
|
+ String string;
|
|
|
|
|
+ int start_position;
|
|
|
|
|
+ int change_length; // 修改原文长度
|
|
|
|
|
+ int new_string_length;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * s 改变前的内容
|
|
|
|
|
+ * start 增加内容前光标位置,删除内容后光标位置 (起始位置)
|
|
|
|
|
+ * count 选中s中的内容长度(发生改变的原内容长度),未选中为0
|
|
|
|
|
+ * after 新添加的内容长度,删除为0
|
|
|
|
|
+ * */
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
|
|
|
|
+// Log.d("TextChange", "before Text Changed: " + s + " Start: " + start + " Count: " + count + " After: " + after);
|
|
|
|
|
+
|
|
|
|
|
+ origin_text = s.toString();
|
|
|
|
|
+ start_position = start;
|
|
|
|
|
+ change_length = count;
|
|
|
|
|
+ new_string_length = after;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * s 改变后的内容
|
|
|
|
|
+ * start 增加内容前光标位置,删除内容后光标位置 (起始位置)
|
|
|
|
|
+ * before 选中s中的内容长度(发生改变的原内容长度),未选中为0
|
|
|
|
|
+ * count 增加内容长度,删除内容为0
|
|
|
|
|
+ * */
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void onTextChanged(CharSequence s, int start, int before, int count) {
|
|
|
|
|
+// Log.d("TextChange", "on Text Changed: " + s + " Start: " + start + " Before: " + before + " Count: " + count);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void afterTextChanged(Editable s) {
|
|
|
|
|
+
|
|
|
|
|
+ commContentChange(s.toString(),group,child);
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+}
|