|
|
@@ -1,17 +1,22 @@
|
|
|
package com.usai.apex;
|
|
|
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
import org.json.JSONException;
|
|
|
import org.json.JSONObject;
|
|
|
|
|
|
import com.usai.util.Network;
|
|
|
import com.usai.util.commonUtil;
|
|
|
|
|
|
+import android.R.integer;
|
|
|
import android.animation.Animator;
|
|
|
import android.animation.AnimatorListenerAdapter;
|
|
|
+import android.content.Context;
|
|
|
import android.os.AsyncTask;
|
|
|
import android.os.Build;
|
|
|
import android.os.Bundle;
|
|
|
import android.support.v4.app.Fragment;
|
|
|
+import android.support.v4.app.FragmentManager;
|
|
|
import android.text.Html;
|
|
|
import android.util.Log;
|
|
|
import android.util.SparseIntArray;
|
|
|
@@ -33,6 +38,8 @@ public class DetailFragment extends Fragment implements OnClickListener /*
|
|
|
* OnGestureListener
|
|
|
*/
|
|
|
{
|
|
|
+ DataFragment mdataFragment;
|
|
|
+
|
|
|
/* private GestureDetector mGestureDetector; */
|
|
|
@Override
|
|
|
public void onCreate(Bundle savedInstanceState)
|
|
|
@@ -49,10 +56,10 @@ public class DetailFragment extends Fragment implements OnClickListener /*
|
|
|
super.onDestroyView();
|
|
|
}
|
|
|
|
|
|
- public String get_content()
|
|
|
- {
|
|
|
- return fragment_content;
|
|
|
- }
|
|
|
+ // public String get_content()
|
|
|
+ // {
|
|
|
+ // return fragment_content;
|
|
|
+ // }
|
|
|
|
|
|
LinearLayout ll_root;
|
|
|
ScrollView sl_root;
|
|
|
@@ -61,7 +68,8 @@ public class DetailFragment extends Fragment implements OnClickListener /*
|
|
|
SparseIntArray control = new SparseIntArray();
|
|
|
// private TextView mStatusMessageView;
|
|
|
private View mStatusView;
|
|
|
- String fragment_content = null;
|
|
|
+
|
|
|
+ // String fragment_content = null;
|
|
|
|
|
|
public void requestdata()
|
|
|
{
|
|
|
@@ -70,8 +78,15 @@ public class DetailFragment extends Fragment implements OnClickListener /*
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
- if (fragment_content != null)
|
|
|
- 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");
|
|
|
showProgress(true);
|
|
|
m_task = new SearchTask();
|
|
|
@@ -86,8 +101,9 @@ public class DetailFragment extends Fragment implements OnClickListener /*
|
|
|
// the progress spinner.
|
|
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2)
|
|
|
{
|
|
|
- int shortAnimTime = getResources().getInteger(
|
|
|
- android.R.integer.config_shortAnimTime);
|
|
|
+ int shortAnimTime = ApexTrackingApplication.get_instance()
|
|
|
+ .getResources()
|
|
|
+ .getInteger(android.R.integer.config_shortAnimTime);
|
|
|
|
|
|
mStatusView.setVisibility(View.VISIBLE);
|
|
|
mStatusView.animate().setDuration(shortAnimTime)
|
|
|
@@ -123,6 +139,24 @@ public class DetailFragment extends Fragment implements OnClickListener /*
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ // @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);
|
|
|
+ // }
|
|
|
+
|
|
|
@Override
|
|
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
|
|
Bundle savedInstanceState)
|
|
|
@@ -138,63 +172,6 @@ public class DetailFragment extends Fragment implements OnClickListener /*
|
|
|
*/
|
|
|
ll_root = (LinearLayout) view.findViewById(R.id.ll_root);
|
|
|
mStatusView = view.findViewById(R.id.status);
|
|
|
- // TextView tv= new TextView(getActivity());
|
|
|
- // tv.setText("test12345");
|
|
|
- //
|
|
|
- // ll_root.addView(tv);
|
|
|
-
|
|
|
- // String jstr = null;
|
|
|
- // AssetManager am = null;
|
|
|
- // am = getActivity().getAssets();
|
|
|
- // try
|
|
|
- // {
|
|
|
- // String TAG = "DetailFragment fake json";
|
|
|
- // InputStream is = am.open("detail.json");
|
|
|
- //
|
|
|
- // BufferedReader br = new BufferedReader(new InputStreamReader(is,
|
|
|
- // "utf-8"), 8);
|
|
|
- // StringBuilder sb = new StringBuilder();
|
|
|
- // String line = null;
|
|
|
- // while ((line = br.readLine()) != null)
|
|
|
- // {
|
|
|
- // sb.append(line + "\n");
|
|
|
- // }
|
|
|
- //
|
|
|
- // Log.d(TAG, "Response: content begin");
|
|
|
- // Log.d(TAG, sb.toString());
|
|
|
- // Log.d(TAG, "Response: content end");
|
|
|
- //
|
|
|
- // if (sb.length() <= 0)
|
|
|
- // {
|
|
|
- //
|
|
|
- // jstr = null;
|
|
|
- // }
|
|
|
- // jstr = sb.toString();
|
|
|
- // }
|
|
|
- // catch (IOException e)
|
|
|
- // {
|
|
|
- // // TODO Auto-generated catch block
|
|
|
- // e.printStackTrace();
|
|
|
- // }
|
|
|
- //
|
|
|
- // init(jstr, inflater);
|
|
|
- // String url = "<a href='http://www.google.com'>A1401330351H.pdf</a>";
|
|
|
-
|
|
|
- // String
|
|
|
- // url1="<table border=1><tr><th>Test A</th><th>Test b</th></tr><tr><td>a</td><td>b</td></tr></table>";
|
|
|
- // TextView t2 = (TextView) view.findViewById(R.id.text2);
|
|
|
- // t2.setMovementMethod(LinkMovementMethod.getInstance());
|
|
|
- // TextView t1 = (TextView) view.findViewById(R.id.textView1);
|
|
|
- //
|
|
|
- // t1.setText(Html.fromHtml(url1));
|
|
|
- // t1.setMovementMethod(LinkMovementMethod.getInstance());
|
|
|
- //
|
|
|
- //
|
|
|
- // final
|
|
|
- // WebView wv;
|
|
|
- //
|
|
|
- // wv = (WebView) view.findViewById(R.id.webView1);
|
|
|
- // wv.loadData(url1, mimeType, null);
|
|
|
LinearLayout ll = (LinearLayout) view.findViewById(R.id.ll_refresh);
|
|
|
Button btn_refresh = (Button) ll.findViewById(R.id.btn_refresh);
|
|
|
btn_refresh.setOnClickListener(new View.OnClickListener()
|
|
|
@@ -211,6 +188,28 @@ 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();
|
|
|
+ }
|
|
|
requestdata();
|
|
|
return view;
|
|
|
}
|
|
|
@@ -381,6 +380,7 @@ public class DetailFragment extends Fragment implements OnClickListener /*
|
|
|
@Override
|
|
|
protected Boolean doInBackground(Void... params)
|
|
|
{
|
|
|
+ Log.e("SearchTask", "doInBackground");
|
|
|
if (!Network.NetworkIsAvailable())
|
|
|
|
|
|
{
|
|
|
@@ -396,7 +396,7 @@ public class DetailFragment extends Fragment implements OnClickListener /*
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
- fragment_content = jstr;
|
|
|
+ mdataFragment.put_result(jstr);
|
|
|
errorcode = Network.RESULT_TRUE;
|
|
|
|
|
|
return true;
|
|
|
@@ -448,12 +448,19 @@ public class DetailFragment extends Fragment implements OnClickListener /*
|
|
|
|
|
|
if (success)
|
|
|
{
|
|
|
-
|
|
|
- init(fragment_content, getActivity().getLayoutInflater());
|
|
|
+ LayoutInflater inflater = (LayoutInflater) ApexTrackingApplication
|
|
|
+ .get_instance().getSystemService(
|
|
|
+ Context.LAYOUT_INFLATER_SERVICE);
|
|
|
+
|
|
|
+ init(mdataFragment.get_result(), inflater/*
|
|
|
+ * getActivity().
|
|
|
+ * getLayoutInflater()
|
|
|
+ */);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- LinearLayout ll = (LinearLayout) ll_root.findViewById(R.id.ll_refresh);
|
|
|
+ LinearLayout ll = (LinearLayout) ll_root
|
|
|
+ .findViewById(R.id.ll_refresh);
|
|
|
ll.setVisibility(View.VISIBLE);
|
|
|
}
|
|
|
super.onPostExecute(success);
|
|
|
@@ -466,51 +473,29 @@ public class DetailFragment extends Fragment implements OnClickListener /*
|
|
|
showProgress(false);
|
|
|
}
|
|
|
}
|
|
|
- //
|
|
|
- // @Override
|
|
|
- // public boolean onDown(MotionEvent e)
|
|
|
- // {
|
|
|
- // // TODO Auto-generated method stub
|
|
|
- // return false;
|
|
|
- // }
|
|
|
- //
|
|
|
- // @Override
|
|
|
- // public void onShowPress(MotionEvent e)
|
|
|
- // {
|
|
|
- // // TODO Auto-generated method stub
|
|
|
- //
|
|
|
- // }
|
|
|
- //
|
|
|
- // @Override
|
|
|
- // public boolean onSingleTapUp(MotionEvent e)
|
|
|
- // {
|
|
|
- // // TODO Auto-generated method stub
|
|
|
- // return false;
|
|
|
- // }
|
|
|
- //
|
|
|
- // @Override
|
|
|
- // public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX,
|
|
|
- // float distanceY)
|
|
|
- // {
|
|
|
- // Log.e("onScroll",".................");
|
|
|
- // Log.d("onScroll","dx:"+(e1.getX()-e2.getX()));
|
|
|
- // Log.d("onScroll","dy:"+(e1.getY()-e2.getY()));
|
|
|
- //
|
|
|
- // return false;
|
|
|
- // }
|
|
|
- //
|
|
|
- // @Override
|
|
|
- // public void onLongPress(MotionEvent e)
|
|
|
- // {
|
|
|
- // // TODO Auto-generated method stub
|
|
|
- //
|
|
|
- // }
|
|
|
- //
|
|
|
- // @Override
|
|
|
- // public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX,
|
|
|
- // float velocityY)
|
|
|
- // {
|
|
|
- // Log.e("onFling",".................");
|
|
|
- // return false;
|
|
|
- // }
|
|
|
+
|
|
|
+ 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;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
}
|