|
|
@@ -1,8 +1,11 @@
|
|
|
package com.usai.apex.mainframe;
|
|
|
|
|
|
//import android.app.Fragment;
|
|
|
+import android.app.AlertDialog;
|
|
|
import android.content.BroadcastReceiver;
|
|
|
+import android.content.DialogInterface;
|
|
|
import android.content.Intent;
|
|
|
+import android.database.sqlite.SQLiteDatabase;
|
|
|
import android.os.Bundle;
|
|
|
import android.support.annotation.NonNull;
|
|
|
import android.support.design.widget.BottomNavigationView;
|
|
|
@@ -10,19 +13,22 @@ import android.support.v4.app.Fragment;
|
|
|
import android.support.v4.view.ViewPager;
|
|
|
import android.support.v7.app.ActionBar;
|
|
|
import android.support.v7.app.AppCompatActivity;
|
|
|
+import android.text.TextUtils;
|
|
|
import android.view.Gravity;
|
|
|
import android.view.LayoutInflater;
|
|
|
import android.view.Menu;
|
|
|
import android.view.MenuItem;
|
|
|
import android.view.View;
|
|
|
+import android.widget.EditText;
|
|
|
import android.widget.TextView;
|
|
|
|
|
|
import com.usai.apex.ApexTrackingApplication;
|
|
|
-import com.usai.apex.ContainerSearchActivity;
|
|
|
import com.usai.apex.DetailFragment;
|
|
|
import com.usai.apex.R;
|
|
|
+import com.usai.apex.Result.AMResultActivity;
|
|
|
import com.usai.apex.ViewPagerAdapter;
|
|
|
import com.usai.util.commonUtil;
|
|
|
+import com.usai.util.dbUtil;
|
|
|
|
|
|
import org.json.JSONException;
|
|
|
import org.json.JSONObject;
|
|
|
@@ -32,7 +38,7 @@ import java.util.HashMap;
|
|
|
public class NewDetailActivity extends AppCompatActivity {
|
|
|
|
|
|
|
|
|
-
|
|
|
+ HashMap<String,String> contentmap = new HashMap<String ,String>();
|
|
|
HashMap<Integer, Integer> menu_map = new HashMap<Integer, Integer>();
|
|
|
|
|
|
String function_name;
|
|
|
@@ -50,7 +56,7 @@ public class NewDetailActivity extends AppCompatActivity {
|
|
|
// boolean login=false;
|
|
|
BroadcastReceiver br;
|
|
|
|
|
|
- Menu actionbutton;
|
|
|
+// Menu actionbutton;
|
|
|
|
|
|
private void setCustomActionBar() {
|
|
|
ActionBar.LayoutParams lp =new ActionBar.LayoutParams(ActionBar.LayoutParams.MATCH_PARENT, ActionBar.LayoutParams.MATCH_PARENT, Gravity.CENTER);
|
|
|
@@ -86,53 +92,169 @@ public class NewDetailActivity extends AppCompatActivity {
|
|
|
actionBar.setDisplayShowTitleEnabled(true);
|
|
|
}
|
|
|
@Override
|
|
|
- public boolean onCreateOptionsMenu(Menu menu) {
|
|
|
- actionbutton = menu;
|
|
|
- getMenuInflater().inflate(R.menu.quick_search,menu);
|
|
|
- return true;
|
|
|
+ public boolean onCreateOptionsMenu(Menu menu)
|
|
|
+ {
|
|
|
+ // Inflate the menu; this adds items to the action bar if it is present.
|
|
|
+
|
|
|
+ if (function_name.equals("Cargo Tracking")) {
|
|
|
+ getMenuInflater().inflate(R.menu.cargo_menu, menu);
|
|
|
+ } else {
|
|
|
+ getMenuInflater().inflate(R.menu.detail, menu);
|
|
|
+ }
|
|
|
+ return true;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
@Override
|
|
|
public boolean onOptionsItemSelected(MenuItem item) {
|
|
|
- switch (item.getItemId()) {
|
|
|
- case android.R.id.home:
|
|
|
+ switch (item.getItemId())
|
|
|
+ {
|
|
|
+ case R.id.action_close:
|
|
|
+
|
|
|
finish();
|
|
|
-// Toast.makeText(this, "switch mode", Toast.LENGTH_SHORT).show();
|
|
|
+// if (SearchResultActivity.instance != null) {
|
|
|
+// SearchResultActivity.instance.finish();
|
|
|
+// }
|
|
|
+// if (SearchListActivity.instance != null) {
|
|
|
+// SearchListActivity.instance.finish();
|
|
|
+// }
|
|
|
+ Intent intent = new Intent(this, RootActivity.class);
|
|
|
|
|
|
-// if (login && (viewPager.getCurrentItem() == 0 || viewPager.getCurrentItem() == 1)) {
|
|
|
-// boolean personMode = ApexTrackingApplication.get_instance().getPersonMode();
|
|
|
-// personMode = !personMode;
|
|
|
-// ApexTrackingApplication.get_instance().setPersonMode(personMode);
|
|
|
-//
|
|
|
-// if (personMode) {
|
|
|
-// getSupportActionBar().setHomeAsUpIndicator(R.drawable.apexlogo_p);
|
|
|
-// } else {
|
|
|
-// getSupportActionBar().setHomeAsUpIndicator(R.drawable.apexlogo);
|
|
|
-// }
|
|
|
-//
|
|
|
-// Intent intent = new Intent("com.apex.broadcast.person_mode");
|
|
|
-// LocalBroadcastManager.getInstance(getApplicationContext()).sendBroadcast(intent);
|
|
|
-// }
|
|
|
+// Intent intent = new Intent(context, LoginView.class);
|
|
|
+ intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
|
|
|
|
|
- break;
|
|
|
- case R.id.quick_search:
|
|
|
|
|
|
- Intent intent = new Intent();
|
|
|
- intent.setClass(NewDetailActivity.this,ContainerSearchActivity.class);
|
|
|
startActivity(intent);
|
|
|
-
|
|
|
-// Toast.makeText(this,"跳转至container search activity",Toast.LENGTH_LONG).show();
|
|
|
break;
|
|
|
+ case android.R.id.home:
|
|
|
+ finish();
|
|
|
+ break;
|
|
|
+ case R.id.action_addto_favorite:
|
|
|
+// LayoutInflater factory = LayoutInflater.from(this);
|
|
|
+// final View textEntryView = factory.inflate(R.layout.alert_dialog_text_entry, null);
|
|
|
+ final View edit = new EditText(this);
|
|
|
+ new AlertDialog.Builder(this)
|
|
|
+ .setIconAttribute(android.R.attr.alertDialogIcon)
|
|
|
+ .setTitle(R.string.str_createname)
|
|
|
+ .setView(edit)
|
|
|
+ .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
|
|
|
+ public void onClick(DialogInterface dialog, int whichButton) {
|
|
|
+ String name = ((EditText)edit).getText().toString();
|
|
|
+ if(TextUtils.isEmpty(name))
|
|
|
+ {
|
|
|
+ new android.app.AlertDialog.Builder(NewDetailActivity.this)
|
|
|
+ .setTitle("Warning")
|
|
|
+ .setMessage("Name can not be empty.")
|
|
|
+
|
|
|
+ .setPositiveButton("OK", new DialogInterface.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(DialogInterface dialog, int which) {
|
|
|
+
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .show();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ String param = getIntent().toUri(0);
|
|
|
+
|
|
|
+ SQLiteDatabase db = dbUtil.OpenDB(
|
|
|
+ ApexTrackingApplication.get_instance(), null, true);
|
|
|
+ db.execSQL("insert into favorites(name,params,user,create_time,module_name) values('"
|
|
|
+ + name
|
|
|
+ + "','"
|
|
|
+ + param
|
|
|
+ + "','"
|
|
|
+ + ApexTrackingApplication.get_user()
|
|
|
+ + "',"
|
|
|
+ + System.currentTimeMillis()
|
|
|
+ + ",'"
|
|
|
+ +getIntent().getStringExtra("function_name")+ "')");
|
|
|
+ dbUtil.CloseDB(db);
|
|
|
+
|
|
|
+ /* User clicked OK so do some stuff */
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
|
|
|
+ public void onClick(DialogInterface dialog, int whichButton) {
|
|
|
+
|
|
|
+ /* User clicked cancel so do some stuff */
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .create().show();
|
|
|
+ return true;
|
|
|
+
|
|
|
+ case R.id.action_search_document: {
|
|
|
+ String cargo_str = contentmap.get("Tracking");
|
|
|
+ try {
|
|
|
+ JSONObject cargo_json = new JSONObject(cargo_str);
|
|
|
+ String hbol = cargo_json.optString("hbol");
|
|
|
+ if (hbol != null && hbol.length() > 0) {
|
|
|
+
|
|
|
+ Bundle parms = new Bundle();
|
|
|
+ parms.putString("bol",hbol);
|
|
|
+ parms.putString("module_name","Download Document");
|
|
|
+ Intent resultIntent = new Intent(this, AMResultActivity.class);
|
|
|
+ resultIntent.putExtra("query_params",parms);
|
|
|
+ startActivity(resultIntent);
|
|
|
+
|
|
|
+ } else {
|
|
|
+ showAlter("There is no hbol to search");
|
|
|
+ }
|
|
|
+
|
|
|
+ } catch (JSONException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ showAlter("There is no hbol to search");
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ break;
|
|
|
+
|
|
|
+ case R.id.action_share_detail: {
|
|
|
+
|
|
|
+ Intent share = new Intent();
|
|
|
+ share.setAction(Intent.ACTION_SEND);
|
|
|
+// share.putExtra(Intent.EXTRA_STREAM, uri);
|
|
|
+ share.setType("text/plain");
|
|
|
|
|
|
- }
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+ if (email_content != null) {
|
|
|
+ share.putExtra(Intent.EXTRA_TEXT, email_content); //附带的说明信息
|
|
|
+ }
|
|
|
+ if (email_subject != null) {
|
|
|
+ share.putExtra(Intent.EXTRA_SUBJECT, email_subject);
|
|
|
+ }
|
|
|
+ if (email_to != null) {
|
|
|
+ share.putExtra(Intent.EXTRA_EMAIL, email_to.split(","));
|
|
|
+ }
|
|
|
+
|
|
|
+// share.putExtra(Intent.EXTRA_CC, new String[]{"ray.zhang@united-cn.net"});
|
|
|
+// startActivity(Intent.createChooser(share,getString(R.string.str_sendto)));
|
|
|
+ startActivity(Intent.createChooser(share, "Share"));
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
return super.onOptionsItemSelected(item);
|
|
|
}
|
|
|
|
|
|
+ public void showAlter(String msg) {
|
|
|
+ new AlertDialog.Builder(this)
|
|
|
+ .setMessage(msg)
|
|
|
+ .setPositiveButton("Ok", new DialogInterface.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(DialogInterface dialogInterface, int i) {
|
|
|
+
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .show();
|
|
|
+ }
|
|
|
@Override
|
|
|
protected void onSaveInstanceState(Bundle outState) {
|
|
|
super.onSaveInstanceState(outState);
|
|
|
-
|
|
|
+ outState.putSerializable("menu_map", menu_map);
|
|
|
+ outState.putSerializable("contentmap", contentmap);
|
|
|
// outState.putBoolean("login",login);
|
|
|
}
|
|
|
|
|
|
@@ -176,6 +298,25 @@ public class NewDetailActivity extends AppCompatActivity {
|
|
|
setCustomActionBar();
|
|
|
|
|
|
|
|
|
+ if (savedInstanceState != null)
|
|
|
+ {
|
|
|
+ menu_map = (HashMap<Integer, Integer>) savedInstanceState
|
|
|
+ .getSerializable("menu_map");
|
|
|
+// tabmap = (LinkedHashMap<String, Integer>) savedInstanceState
|
|
|
+// .getSerializable("tabmap");
|
|
|
+ contentmap = (HashMap<String, String>) savedInstanceState.getSerializable("contentmap");
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ 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("Ocean Booking"))
|
|
|
@@ -238,7 +379,7 @@ public class NewDetailActivity extends AppCompatActivity {
|
|
|
new BottomNavigationView.OnNavigationItemSelectedListener() {
|
|
|
@Override
|
|
|
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
|
|
|
- actionbutton.getItem(0).setVisible(false);
|
|
|
+// actionbutton.getItem(0).setVisible(false);
|
|
|
// getSupportActionBar().setHomeAsUpIndicator(R.drawable.apexlogo);
|
|
|
// getSupportActionBar().setDisplayShowTitleEnabled(false);
|
|
|
|
|
|
@@ -596,8 +737,8 @@ public class NewDetailActivity extends AppCompatActivity {
|
|
|
|
|
|
if(true)
|
|
|
{
|
|
|
- if(actionbutton!=null)
|
|
|
- actionbutton.getItem(0).setVisible(true);
|
|
|
+// if(actionbutton!=null)
|
|
|
+// actionbutton.getItem(0).setVisible(true);
|
|
|
|
|
|
bottomNavigationView.getChildAt(0).setSelected(true);
|
|
|
bottomNavigationView.getMenu().clear();
|
|
|
@@ -638,6 +779,7 @@ public class NewDetailActivity extends AppCompatActivity {
|
|
|
|
|
|
Fragment f;
|
|
|
f= new DetailFragment();
|
|
|
+ ((DetailFragment)f).set_content( contentmap.get(title));
|
|
|
f.setArguments(bundle);
|
|
|
|
|
|
adapter.addFragment(f);
|
|
|
@@ -755,7 +897,7 @@ public class NewDetailActivity extends AppCompatActivity {
|
|
|
}
|
|
|
public void save_content(String which,String content)
|
|
|
{
|
|
|
-// contentmap.put(which, content);
|
|
|
+ contentmap.put(which, content);
|
|
|
|
|
|
try {
|
|
|
|