|
@@ -1,20 +1,46 @@
|
|
|
package com.usai.apex.apexResult;
|
|
package com.usai.apex.apexResult;
|
|
|
|
|
|
|
|
import android.app.Activity;
|
|
import android.app.Activity;
|
|
|
|
|
+import android.app.ProgressDialog;
|
|
|
import android.content.Context;
|
|
import android.content.Context;
|
|
|
|
|
+import android.content.DialogInterface;
|
|
|
import android.content.Intent;
|
|
import android.content.Intent;
|
|
|
|
|
+import android.database.sqlite.SQLiteDatabase;
|
|
|
|
|
+import android.graphics.Color;
|
|
|
import android.support.v4.view.MenuItemCompat;
|
|
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.support.v7.app.AppCompatActivity;
|
|
|
import android.os.Bundle;
|
|
import android.os.Bundle;
|
|
|
|
|
+import android.text.TextUtils;
|
|
|
|
|
+import android.view.Gravity;
|
|
|
import android.view.Menu;
|
|
import android.view.Menu;
|
|
|
-import android.view.MenuInflater;
|
|
|
|
|
import android.view.MenuItem;
|
|
import android.view.MenuItem;
|
|
|
import android.view.View;
|
|
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.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.R;
|
|
|
|
|
+import com.usai.apex.Result.AMResultActivity;
|
|
|
import com.usai.apex.actionSheet.ActionSheet;
|
|
import com.usai.apex.actionSheet.ActionSheet;
|
|
|
-import com.usai.util.RAUtil;
|
|
|
|
|
|
|
+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 {
|
|
public class ApexResultActivity extends AppCompatActivity implements ApexResultPresenter.ApexResultProtocol {
|
|
|
|
|
|
|
@@ -37,10 +63,26 @@ public class ApexResultActivity extends AppCompatActivity implements ApexResultP
|
|
|
|
|
|
|
|
// endregion
|
|
// endregion
|
|
|
|
|
|
|
|
|
|
+ // region Request Code
|
|
|
|
|
+
|
|
|
|
|
+ private static class RequestCode {
|
|
|
|
|
+
|
|
|
|
|
+ static final int Field_Setting = 1010;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // endregion
|
|
|
|
|
+
|
|
|
// region Property
|
|
// region Property
|
|
|
|
|
|
|
|
private Context mCtx = this;
|
|
private Context mCtx = this;
|
|
|
|
|
+
|
|
|
private ListView mListView;
|
|
private ListView mListView;
|
|
|
|
|
+ private SwipeRefreshLayout mRefreshLayout;
|
|
|
|
|
+ private ProgressBar mProgressBar;
|
|
|
|
|
+ private TextView mListFooterView;
|
|
|
|
|
+
|
|
|
|
|
+ private ScrollListener mScrollListener;
|
|
|
|
|
+
|
|
|
private ApexResultPresenter mPresenter;
|
|
private ApexResultPresenter mPresenter;
|
|
|
private ApexResultAdapter mAdapter;
|
|
private ApexResultAdapter mAdapter;
|
|
|
private Bundle mParams;
|
|
private Bundle mParams;
|
|
@@ -64,7 +106,6 @@ public class ApexResultActivity extends AppCompatActivity implements ApexResultP
|
|
|
mParams = new Bundle();
|
|
mParams = new Bundle();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- setupActionBar();
|
|
|
|
|
setup();
|
|
setup();
|
|
|
|
|
|
|
|
if (savedInstanceState != null) {
|
|
if (savedInstanceState != null) {
|
|
@@ -79,8 +120,10 @@ public class ApexResultActivity extends AppCompatActivity implements ApexResultP
|
|
|
|
|
|
|
|
if (item.getItemId() == android.R.id.home) {
|
|
if (item.getItemId() == android.R.id.home) {
|
|
|
finish();
|
|
finish();
|
|
|
|
|
+ return true;
|
|
|
} else if (item.getItemId() == R.id.apex_result_menu) {
|
|
} else if (item.getItemId() == R.id.apex_result_menu) {
|
|
|
menuItemClick();
|
|
menuItemClick();
|
|
|
|
|
+ return true;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
return super.onOptionsItemSelected(item);
|
|
return super.onOptionsItemSelected(item);
|
|
@@ -88,7 +131,7 @@ public class ApexResultActivity extends AppCompatActivity implements ApexResultP
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public boolean onCreateOptionsMenu(Menu menu) {
|
|
public boolean onCreateOptionsMenu(Menu menu) {
|
|
|
- new MenuInflater(mCtx).inflate(R.menu.apex_result_menu, menu);
|
|
|
|
|
|
|
+ getMenuInflater().inflate(R.menu.apex_result_menu, menu);
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -100,18 +143,73 @@ public class ApexResultActivity extends AppCompatActivity implements ApexResultP
|
|
|
mPresenter.onSaveInstanceState(outState);
|
|
mPresenter.onSaveInstanceState(outState);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
|
+ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
|
|
|
|
+ super.onActivityResult(requestCode, resultCode, data);
|
|
|
|
|
+
|
|
|
|
|
+ if (requestCode == RequestCode.Field_Setting) {
|
|
|
|
|
+ refresh();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
// endregion
|
|
// endregion
|
|
|
|
|
|
|
|
// region Setting
|
|
// region Setting
|
|
|
|
|
|
|
|
private void setup() {
|
|
private void setup() {
|
|
|
|
|
|
|
|
- mListView = findViewById(R.id.apex_result_list_view);
|
|
|
|
|
mPresenter = new ApexResultPresenter(this, mParams);
|
|
mPresenter = new ApexResultPresenter(this, mParams);
|
|
|
mAdapter = new ApexResultAdapter(mCtx, mPresenter);
|
|
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);
|
|
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() {
|
|
private void setupActionBar() {
|
|
|
|
|
|
|
|
android.support.v7.app.ActionBar actionBar = getSupportActionBar();
|
|
android.support.v7.app.ActionBar actionBar = getSupportActionBar();
|
|
@@ -123,37 +221,92 @@ public class ApexResultActivity extends AppCompatActivity implements ApexResultP
|
|
|
|
|
|
|
|
// endregion
|
|
// endregion
|
|
|
|
|
|
|
|
|
|
+ // region Action
|
|
|
|
|
+
|
|
|
|
|
+ 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
|
|
// region Presenter Delegate
|
|
|
@Override
|
|
@Override
|
|
|
public void onStartLoading() {
|
|
public void onStartLoading() {
|
|
|
-
|
|
|
|
|
|
|
+ isLoading = true;
|
|
|
|
|
+ showProgressBar();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public void onStopLoading() {
|
|
public void onStopLoading() {
|
|
|
|
|
+ if (mRefreshLayout.isRefreshing()) {
|
|
|
|
|
+ mRefreshLayout.setRefreshing(false);
|
|
|
|
|
+ }
|
|
|
|
|
+ mListFooterView.setVisibility(View.INVISIBLE);
|
|
|
|
|
+ dismissProgressBar();
|
|
|
|
|
|
|
|
|
|
+ isLoading = false;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public void onSuccess(String title) {
|
|
public void onSuccess(String title) {
|
|
|
-
|
|
|
|
|
setTitle(title);
|
|
setTitle(title);
|
|
|
mAdapter.notifyDataSetChanged();
|
|
mAdapter.notifyDataSetChanged();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public void onFailed(String errMsg) {
|
|
public void onFailed(String errMsg) {
|
|
|
-
|
|
|
|
|
|
|
+ if (errMsg == null) {
|
|
|
|
|
+ errMsg = "Sorry, something is wrong.";
|
|
|
|
|
+ }
|
|
|
|
|
+ showAlertMessage(errMsg);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public void onNoMoreData() {
|
|
public void onNoMoreData() {
|
|
|
-
|
|
|
|
|
|
|
+ showAlertMessage("No More Data");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
- public void onDownloadFile(String path) {
|
|
|
|
|
|
|
+ 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
|
|
// endregion
|
|
|
|
|
|
|
@@ -190,10 +343,247 @@ public class ApexResultActivity extends AppCompatActivity implements ApexResultP
|
|
|
|
|
|
|
|
private void saveSearchParameters() {
|
|
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(name);
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+ .setNegativeButton(android.R.string.cancel, null)
|
|
|
|
|
+ .create()
|
|
|
|
|
+ .show();
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private void showFieldsSetting() {
|
|
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
|
|
// endregion
|