|
@@ -1,594 +0,0 @@
|
|
|
-package com.usai.apex.apexResult;
|
|
|
|
|
-
|
|
|
|
|
-import android.app.Activity;
|
|
|
|
|
-import android.app.ProgressDialog;
|
|
|
|
|
-import android.content.Context;
|
|
|
|
|
-import android.content.DialogInterface;
|
|
|
|
|
-import android.content.Intent;
|
|
|
|
|
-import android.database.sqlite.SQLiteDatabase;
|
|
|
|
|
-import android.graphics.Color;
|
|
|
|
|
-import android.support.v4.view.MenuItemCompat;
|
|
|
|
|
-import android.support.v4.widget.SwipeRefreshLayout;
|
|
|
|
|
-import android.support.v7.app.AlertDialog;
|
|
|
|
|
-import android.support.v7.app.AppCompatActivity;
|
|
|
|
|
-import android.os.Bundle;
|
|
|
|
|
-import android.text.TextUtils;
|
|
|
|
|
-import android.view.Gravity;
|
|
|
|
|
-import android.view.Menu;
|
|
|
|
|
-import android.view.MenuItem;
|
|
|
|
|
-import android.view.View;
|
|
|
|
|
-import android.view.ViewGroup;
|
|
|
|
|
-import android.widget.AbsListView;
|
|
|
|
|
-import android.widget.AdapterView;
|
|
|
|
|
-import android.widget.EditText;
|
|
|
|
|
-import android.widget.ListView;
|
|
|
|
|
-import android.widget.ProgressBar;
|
|
|
|
|
-import android.widget.TextView;
|
|
|
|
|
-
|
|
|
|
|
-import com.usai.apex.ApexTrackingApplication;
|
|
|
|
|
-import com.usai.apex.CustomizeFieldsActivity;
|
|
|
|
|
-import com.usai.apex.R;
|
|
|
|
|
-import com.usai.apex.Result.AMResultActivity;
|
|
|
|
|
-import com.usai.apex.actionSheet.ActionSheet;
|
|
|
|
|
-import com.usai.apex.mainframe.NewDetailActivity;
|
|
|
|
|
-import com.usai.apex.pdf.PDFPreviewActivity;
|
|
|
|
|
-import com.usai.util.Network;
|
|
|
|
|
-import com.usai.util.commonUtil;
|
|
|
|
|
-
|
|
|
|
|
-import org.json.JSONArray;
|
|
|
|
|
-import org.json.JSONException;
|
|
|
|
|
-import org.json.JSONObject;
|
|
|
|
|
-
|
|
|
|
|
-import java.util.Iterator;
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-public class ApexResultActivity extends AppCompatActivity implements ApexResultPresenter.ApexResultProtocol {
|
|
|
|
|
-
|
|
|
|
|
- // region Build
|
|
|
|
|
-
|
|
|
|
|
- private static final String ParametersKey = "Apex_Result_Parameters_Key";
|
|
|
|
|
-
|
|
|
|
|
- public static void startResultActivity(Activity activity, Bundle params) {
|
|
|
|
|
-
|
|
|
|
|
- if (activity != null) {
|
|
|
|
|
-
|
|
|
|
|
- Intent intent = new Intent(activity, ApexResultActivity.class);
|
|
|
|
|
- if (params != null) {
|
|
|
|
|
- intent.putExtra(ParametersKey, params);
|
|
|
|
|
- }
|
|
|
|
|
- activity.startActivity(intent);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- // endregion
|
|
|
|
|
-
|
|
|
|
|
- // region Request Code
|
|
|
|
|
-
|
|
|
|
|
- private static class RequestCode {
|
|
|
|
|
-
|
|
|
|
|
- static final int Field_Setting = 1010;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- // endregion
|
|
|
|
|
-
|
|
|
|
|
- // region Property
|
|
|
|
|
-
|
|
|
|
|
- private Context mCtx = this;
|
|
|
|
|
-
|
|
|
|
|
- private ListView mListView;
|
|
|
|
|
- private SwipeRefreshLayout mRefreshLayout;
|
|
|
|
|
- private ProgressBar mProgressBar;
|
|
|
|
|
- private TextView mListFooterView;
|
|
|
|
|
-
|
|
|
|
|
- private ScrollListener mScrollListener;
|
|
|
|
|
-
|
|
|
|
|
- private ApexResultPresenter mPresenter;
|
|
|
|
|
- private ApexResultAdapter mAdapter;
|
|
|
|
|
- private Bundle mParams;
|
|
|
|
|
-
|
|
|
|
|
- // endregion
|
|
|
|
|
-
|
|
|
|
|
- // region Override
|
|
|
|
|
-
|
|
|
|
|
- @Override
|
|
|
|
|
- protected void onCreate(Bundle savedInstanceState) {
|
|
|
|
|
- super.onCreate(savedInstanceState);
|
|
|
|
|
- setContentView(R.layout.activity_apex_result);
|
|
|
|
|
-
|
|
|
|
|
- //
|
|
|
|
|
- if (savedInstanceState != null) {
|
|
|
|
|
- mParams = savedInstanceState.getBundle(ParametersKey);
|
|
|
|
|
- } else {
|
|
|
|
|
- mParams = getIntent().getBundleExtra(ParametersKey);
|
|
|
|
|
- }
|
|
|
|
|
- if (mParams == null) {
|
|
|
|
|
- mParams = new Bundle();
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- setup();
|
|
|
|
|
-
|
|
|
|
|
- if (savedInstanceState != null) {
|
|
|
|
|
- mPresenter.onRestoreInstanceState(savedInstanceState);
|
|
|
|
|
- } else {
|
|
|
|
|
- mPresenter.loadData();
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- @Override
|
|
|
|
|
- public boolean onOptionsItemSelected(MenuItem item) {
|
|
|
|
|
-
|
|
|
|
|
- if (item.getItemId() == android.R.id.home) {
|
|
|
|
|
- finish();
|
|
|
|
|
- return true;
|
|
|
|
|
- } else if (item.getItemId() == R.id.apex_result_menu) {
|
|
|
|
|
- menuItemClick();
|
|
|
|
|
- return true;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- return super.onOptionsItemSelected(item);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- @Override
|
|
|
|
|
- public boolean onCreateOptionsMenu(Menu menu) {
|
|
|
|
|
- getMenuInflater().inflate(R.menu.apex_result_menu, menu);
|
|
|
|
|
- return true;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- @Override
|
|
|
|
|
- protected void onSaveInstanceState(Bundle outState) {
|
|
|
|
|
- super.onSaveInstanceState(outState);
|
|
|
|
|
-
|
|
|
|
|
- outState.putBundle(ParametersKey, mParams);
|
|
|
|
|
- mPresenter.onSaveInstanceState(outState);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- @Override
|
|
|
|
|
- protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
|
|
|
|
- super.onActivityResult(requestCode, resultCode, data);
|
|
|
|
|
-
|
|
|
|
|
- if (requestCode == RequestCode.Field_Setting) {
|
|
|
|
|
- mPresenter.dirty = true;
|
|
|
|
|
- loadData();
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- // endregion
|
|
|
|
|
-
|
|
|
|
|
- // region Setting
|
|
|
|
|
-
|
|
|
|
|
- private void setup() {
|
|
|
|
|
-
|
|
|
|
|
- mPresenter = new ApexResultPresenter(this, mParams);
|
|
|
|
|
- mAdapter = new ApexResultAdapter(mCtx, mPresenter);
|
|
|
|
|
-
|
|
|
|
|
- setupActionBar();
|
|
|
|
|
- setupRefreshLayout();
|
|
|
|
|
- setupListView();
|
|
|
|
|
-
|
|
|
|
|
- mProgressBar = findViewById(R.id.apex_result_progress_bar);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- private void setupListView() {
|
|
|
|
|
-
|
|
|
|
|
- mListView = findViewById(R.id.apex_result_list_view);
|
|
|
|
|
- mListView.setAdapter(mAdapter);
|
|
|
|
|
-
|
|
|
|
|
- setupListFooterView();
|
|
|
|
|
- AbsListView.LayoutParams footerLayoutParams = new AbsListView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,ViewGroup.LayoutParams.WRAP_CONTENT);
|
|
|
|
|
- mListFooterView.setLayoutParams(footerLayoutParams);
|
|
|
|
|
- mListView.addFooterView(mListFooterView);
|
|
|
|
|
-
|
|
|
|
|
- mScrollListener = new ScrollListener();
|
|
|
|
|
- mListView.setOnScrollListener(mScrollListener);
|
|
|
|
|
-
|
|
|
|
|
- mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
|
|
|
|
- @Override
|
|
|
|
|
- public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
|
|
|
|
- clickItemCell(view, position);
|
|
|
|
|
- }
|
|
|
|
|
- });
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- private void setupListFooterView() {
|
|
|
|
|
- mListFooterView = new TextView(mCtx);
|
|
|
|
|
- mListFooterView.setBackgroundColor(Color.WHITE);
|
|
|
|
|
- mListFooterView.setGravity(Gravity.CENTER);
|
|
|
|
|
- mListFooterView.setText("loading more...");
|
|
|
|
|
- mListFooterView.setTextSize(commonUtil.sp2px(mCtx,8));
|
|
|
|
|
- mListFooterView.setVisibility(View.INVISIBLE);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- private void setupRefreshLayout() {
|
|
|
|
|
-
|
|
|
|
|
- mRefreshLayout = findViewById(R.id.apex_result_refresh_layout);
|
|
|
|
|
- mRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
|
|
|
|
|
- @Override
|
|
|
|
|
- public void onRefresh() {
|
|
|
|
|
- refresh();
|
|
|
|
|
- }
|
|
|
|
|
- });
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- private void setupActionBar() {
|
|
|
|
|
-
|
|
|
|
|
- android.support.v7.app.ActionBar actionBar = getSupportActionBar();
|
|
|
|
|
- if(actionBar != null){
|
|
|
|
|
- actionBar.setHomeButtonEnabled(true);
|
|
|
|
|
- actionBar.setDisplayHomeAsUpEnabled(true);
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- // endregion
|
|
|
|
|
-
|
|
|
|
|
- // region Action
|
|
|
|
|
- private void loadData() {
|
|
|
|
|
- mPresenter.loadData();
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- private void refresh() {
|
|
|
|
|
- mPresenter.refreshData();
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- private void loadMore() {
|
|
|
|
|
- mPresenter.loadMoreData();
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- private void clickItemCell(View cell, int position) {
|
|
|
|
|
-
|
|
|
|
|
- handleRowAction(position);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- // endregion
|
|
|
|
|
-
|
|
|
|
|
- // region ProgressBar
|
|
|
|
|
-
|
|
|
|
|
- public void showProgressBar() {
|
|
|
|
|
- mProgressBar.setVisibility(View.VISIBLE);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- public void dismissProgressBar() {
|
|
|
|
|
- mProgressBar.setVisibility(View.GONE);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- // endregion
|
|
|
|
|
-
|
|
|
|
|
- // region Alert
|
|
|
|
|
-
|
|
|
|
|
- private void showAlertMessage(String msg) {
|
|
|
|
|
- new AlertDialog.Builder(mCtx)
|
|
|
|
|
- .setTitle("Warning")
|
|
|
|
|
- .setMessage(msg)
|
|
|
|
|
- .setPositiveButton("OK",null)
|
|
|
|
|
- .show();
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- // endregion
|
|
|
|
|
-
|
|
|
|
|
- // region Presenter Delegate
|
|
|
|
|
- @Override
|
|
|
|
|
- public void onStartLoading() {
|
|
|
|
|
- isLoading = true;
|
|
|
|
|
- showProgressBar();
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- @Override
|
|
|
|
|
- public void onStopLoading() {
|
|
|
|
|
- if (mRefreshLayout.isRefreshing()) {
|
|
|
|
|
- mRefreshLayout.setRefreshing(false);
|
|
|
|
|
- }
|
|
|
|
|
- mListFooterView.setVisibility(View.INVISIBLE);
|
|
|
|
|
- dismissProgressBar();
|
|
|
|
|
-
|
|
|
|
|
- isLoading = false;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- @Override
|
|
|
|
|
- public void onSuccess(String title) {
|
|
|
|
|
- setTitle(title);
|
|
|
|
|
- mAdapter.notifyDataSetChanged();
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- @Override
|
|
|
|
|
- public void onFailed(String errMsg) {
|
|
|
|
|
- if (errMsg == null) {
|
|
|
|
|
- errMsg = "Sorry, something is wrong.";
|
|
|
|
|
- }
|
|
|
|
|
- showAlertMessage(errMsg);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- @Override
|
|
|
|
|
- public void onNoMoreData() {
|
|
|
|
|
- showAlertMessage("No More Data");
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- @Override
|
|
|
|
|
- public void onDownloadFile(String path, Bundle params) {
|
|
|
|
|
-
|
|
|
|
|
- String email = params.getString("email");
|
|
|
|
|
- String email_subject = params.getString("email_subject");
|
|
|
|
|
- String email_content = params.getString("email_content");
|
|
|
|
|
-
|
|
|
|
|
- previewPDF(path, email, email_subject, email_content);
|
|
|
|
|
- }
|
|
|
|
|
- // endregion
|
|
|
|
|
-
|
|
|
|
|
- // region Menu Action
|
|
|
|
|
-
|
|
|
|
|
- private void menuItemClick() {
|
|
|
|
|
-
|
|
|
|
|
- ActionSheet actionSheet = new ActionSheet(mCtx);
|
|
|
|
|
-
|
|
|
|
|
- actionSheet.addAction("Setting", ActionSheet.ActionType.ActionTypeDefault, new View.OnClickListener() {
|
|
|
|
|
- @Override
|
|
|
|
|
- public void onClick(View v) {
|
|
|
|
|
- showFieldsSetting();
|
|
|
|
|
- }
|
|
|
|
|
- });
|
|
|
|
|
-
|
|
|
|
|
- actionSheet.addAction("Save", ActionSheet.ActionType.ActionTypeDefault, new View.OnClickListener() {
|
|
|
|
|
- @Override
|
|
|
|
|
- public void onClick(View v) {
|
|
|
|
|
- saveSearchParameters();
|
|
|
|
|
- }
|
|
|
|
|
- });
|
|
|
|
|
-
|
|
|
|
|
- actionSheet.addAction("Cancel", ActionSheet.ActionType.ACtionTypeCancel, new View.OnClickListener() {
|
|
|
|
|
- @Override
|
|
|
|
|
- public void onClick(View v) {
|
|
|
|
|
-
|
|
|
|
|
- }
|
|
|
|
|
- });
|
|
|
|
|
-
|
|
|
|
|
- actionSheet.show();
|
|
|
|
|
-
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- private void saveSearchParameters() {
|
|
|
|
|
-
|
|
|
|
|
- final View edit = new EditText(mCtx);
|
|
|
|
|
- new android.app.AlertDialog.Builder(mCtx)
|
|
|
|
|
- .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(mCtx)
|
|
|
|
|
- .setTitle("Warning")
|
|
|
|
|
- .setMessage("Name can not be empty.")
|
|
|
|
|
- .setPositiveButton("OK", new DialogInterface.OnClickListener() {
|
|
|
|
|
- @Override
|
|
|
|
|
- public void onClick(DialogInterface dialog, int which) {
|
|
|
|
|
-
|
|
|
|
|
- }
|
|
|
|
|
- })
|
|
|
|
|
- .show();
|
|
|
|
|
- return;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- mPresenter.saveSearchParametersWithName(getIntent().toUri(0), name);
|
|
|
|
|
-
|
|
|
|
|
- }
|
|
|
|
|
- })
|
|
|
|
|
- .setNegativeButton(android.R.string.cancel, null)
|
|
|
|
|
- .create()
|
|
|
|
|
- .show();
|
|
|
|
|
-
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- private void showFieldsSetting() {
|
|
|
|
|
-
|
|
|
|
|
- Intent intent = new Intent();
|
|
|
|
|
- intent.setClass(this, CustomizeFieldsActivity.class);
|
|
|
|
|
- intent.putExtra("user", ApexTrackingApplication.get_user());
|
|
|
|
|
- intent.putExtra("function_name", mParams.getString("module_name"));
|
|
|
|
|
- intent.putExtra("behavior", Network.BEHAVIOR_RESULT);
|
|
|
|
|
- startActivityForResult(intent,RequestCode.Field_Setting);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- // endregion
|
|
|
|
|
-
|
|
|
|
|
- // region Scroll Listener
|
|
|
|
|
-
|
|
|
|
|
- private boolean isLoading = false;
|
|
|
|
|
- private class ScrollListener implements AbsListView.OnScrollListener {
|
|
|
|
|
-
|
|
|
|
|
- private int last_index, total_index;
|
|
|
|
|
-
|
|
|
|
|
- @Override
|
|
|
|
|
- public void onScrollStateChanged(AbsListView view, int scrollState) {
|
|
|
|
|
- if (last_index == total_index && (scrollState == SCROLL_STATE_IDLE)) {
|
|
|
|
|
- if (!isLoading) {
|
|
|
|
|
-
|
|
|
|
|
- mListFooterView.setVisibility(View.VISIBLE);
|
|
|
|
|
- loadMore();
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- @Override
|
|
|
|
|
- public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
|
|
|
|
|
- last_index = firstVisibleItem + visibleItemCount;
|
|
|
|
|
- total_index = totalItemCount;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- // endregion
|
|
|
|
|
-
|
|
|
|
|
- // region Row Action
|
|
|
|
|
-
|
|
|
|
|
- private Bundle paramsForIndex(int position, JSONObject action) {
|
|
|
|
|
-
|
|
|
|
|
- JSONArray parameters = mPresenter.rowActionParametersForIndex(position);
|
|
|
|
|
- Bundle params = new Bundle();
|
|
|
|
|
- JSONObject actionParams = action.optJSONObject("params");
|
|
|
|
|
- if (actionParams != null) {
|
|
|
|
|
-
|
|
|
|
|
- Iterator<String> keys = actionParams.keys();
|
|
|
|
|
- while (keys.hasNext()) {
|
|
|
|
|
- String key = keys.next();
|
|
|
|
|
- try {
|
|
|
|
|
-
|
|
|
|
|
- int idx = actionParams.getInt(key);
|
|
|
|
|
- String value = parameters.getString(idx);
|
|
|
|
|
- params.putString(key, value);
|
|
|
|
|
-
|
|
|
|
|
- } catch (Exception e) {
|
|
|
|
|
- e.printStackTrace();
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- }
|
|
|
|
|
- return params;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- private void handleRowAction(int position) {
|
|
|
|
|
-
|
|
|
|
|
- JSONArray rowActions = mPresenter.getRowActions();
|
|
|
|
|
- if (rowActions != null) {
|
|
|
|
|
-
|
|
|
|
|
- if (rowActions.length() == 1) {
|
|
|
|
|
-
|
|
|
|
|
- JSONObject action = rowActions.optJSONObject(0);
|
|
|
|
|
- if (action != null) {
|
|
|
|
|
-
|
|
|
|
|
- Bundle params = paramsForIndex(position, action);
|
|
|
|
|
- String module = action.optString("module");
|
|
|
|
|
- if (module != null) {
|
|
|
|
|
- if (module.equals("quick_look")) {
|
|
|
|
|
-
|
|
|
|
|
- showQuickLookForActionWithParams(action, params);
|
|
|
|
|
-
|
|
|
|
|
- } else if (module.equals("detail")) {
|
|
|
|
|
-
|
|
|
|
|
- showDetailForActionWithParams(action, params);
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- } else {
|
|
|
|
|
-
|
|
|
|
|
- ActionSheet actionSheet = new ActionSheet(mCtx);
|
|
|
|
|
-
|
|
|
|
|
- for (int i = 0; i < rowActions.length(); i++) {
|
|
|
|
|
-
|
|
|
|
|
- try {
|
|
|
|
|
-
|
|
|
|
|
- final JSONObject json = rowActions.getJSONObject(i);
|
|
|
|
|
- final Bundle params = paramsForIndex(position, json);
|
|
|
|
|
-
|
|
|
|
|
- String title = json.getString("title");
|
|
|
|
|
- final String module = json.getString("module");
|
|
|
|
|
-
|
|
|
|
|
- actionSheet.addAction(title, ActionSheet.ActionType.ActionTypeDefault, new View.OnClickListener() {
|
|
|
|
|
- @Override
|
|
|
|
|
- public void onClick(View v) {
|
|
|
|
|
-
|
|
|
|
|
- if (module.equals("quick_look")) {
|
|
|
|
|
-
|
|
|
|
|
- showQuickLookForActionWithParams(json, params);
|
|
|
|
|
-
|
|
|
|
|
- } else if (module.equals("detail")) {
|
|
|
|
|
-
|
|
|
|
|
- showDetailForActionWithParams(json, params);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- }
|
|
|
|
|
- });
|
|
|
|
|
-
|
|
|
|
|
- } catch (JSONException e) {
|
|
|
|
|
- e.printStackTrace();
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- } // for
|
|
|
|
|
-
|
|
|
|
|
- actionSheet.addAction("Cancel", ActionSheet.ActionType.ACtionTypeCancel, new View.OnClickListener() {
|
|
|
|
|
- @Override
|
|
|
|
|
- public void onClick(View v) {
|
|
|
|
|
-
|
|
|
|
|
- }
|
|
|
|
|
- });
|
|
|
|
|
-
|
|
|
|
|
- actionSheet.show();
|
|
|
|
|
-
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- private void showQuickLookForActionWithParams(JSONObject action, Bundle params) {
|
|
|
|
|
-
|
|
|
|
|
- try {
|
|
|
|
|
-
|
|
|
|
|
- String url = action.getString("url");
|
|
|
|
|
- mPresenter.downloadFile(url, params);
|
|
|
|
|
-
|
|
|
|
|
- } catch (JSONException e) {
|
|
|
|
|
- e.printStackTrace();
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- private void showDetailForActionWithParams(JSONObject action, Bundle params) {
|
|
|
|
|
-
|
|
|
|
|
- String module_name = mPresenter.getParams().getString("module_name");
|
|
|
|
|
- String detail_id = params.getString("id");
|
|
|
|
|
- JSONArray actions = mPresenter.getActions();
|
|
|
|
|
- if (actions == null) {
|
|
|
|
|
- actions = new JSONArray();
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- Intent intent = new Intent(mCtx, NewDetailActivity.class);
|
|
|
|
|
- intent.putExtra("function_name", module_name);
|
|
|
|
|
- intent.putExtra("actions_count", actions.length());
|
|
|
|
|
- intent.putExtra("_id",detail_id);
|
|
|
|
|
-
|
|
|
|
|
- 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);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- // endregion
|
|
|
|
|
-
|
|
|
|
|
- // region PDF
|
|
|
|
|
-
|
|
|
|
|
- private void previewPDF(String file,String email,String subject,String content) {
|
|
|
|
|
-
|
|
|
|
|
- Intent myIntent = new Intent(mCtx, PDFPreviewActivity.class);
|
|
|
|
|
- myIntent.putExtra("file",file);
|
|
|
|
|
- myIntent.putExtra("iscache",true);
|
|
|
|
|
-
|
|
|
|
|
- try {
|
|
|
|
|
- JSONObject json = new JSONObject();
|
|
|
|
|
-
|
|
|
|
|
- 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);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- // endregion
|
|
|
|
|
-}
|
|
|