Commit f87bac92 by Kazuyuki Hida

ダッシュボードの件数表示と一覧表示の不具合を修正

parent f6eef977
Subproject commit 8f1954b9979d4a4f494c8f6a04ab454732e7208b
Subproject commit 39a8f243e91a4a70143ef6cfe7ba33807de9cdfb
......@@ -2,7 +2,6 @@ package jp.agentec.abook.abv.ui.home.activity;
import android.annotation.SuppressLint;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.view.inputmethod.EditorInfo;
......@@ -19,11 +18,12 @@ import android.widget.ProgressBar;
import org.json.adf.JSONArray;
import org.json.adf.JSONObject;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import jp.agentec.abook.abv.bl.acms.type.OperationType;
import jp.agentec.abook.abv.bl.common.ABVEnvironment;
......@@ -74,11 +74,10 @@ import static jp.agentec.abook.abv.bl.common.constant.ABookKeys.CMD_UNLOCK_REPOR
public class DashboardActivity extends OperationActivity {
private static final String TAG = "DashboardActivity";
private static final String DASHBOARD_URL = "file:///android_asset/dashboard/app/index.html";
private static final String DASHBOARD_URL = "file:///android_asset/dashboard/app/index.html?app=android";
private WebView webView;
private ProgressBar progress;
private boolean countInitialized = false;
@Override
protected void onCreate(Bundle savedInstanceState) {
......@@ -106,6 +105,16 @@ public class DashboardActivity extends OperationActivity {
}
@Override
protected void onResume() {
super.onResume();
try {
getReportStatusCount();
} catch (IOException e) {
e.printStackTrace();
}
}
@Override
protected void onStop() {
super.onStop();
if (webView != null) {
......@@ -145,6 +154,8 @@ public class DashboardActivity extends OperationActivity {
webView.setWebViewClient(new ViewClient());
webView.addJavascriptInterface(new JsInf(), "android");
webView.getSettings().setJavaScriptEnabled(true); // JavaScriptを有効にする
Logger.d(TAG, "loadUrl: " + DASHBOARD_URL);
}
......@@ -155,7 +166,7 @@ public class DashboardActivity extends OperationActivity {
settings.setLoadsImagesAutomatically(true); // イメージを自動的にロードする
settings.setBuiltInZoomControls(true); // ズーム機能を有効にする
settings.setSupportZoom(true); // ズーム機能を有効にする
settings.setJavaScriptEnabled(true); // JavaScriptを有効にする
//settings.setJavaScriptEnabled(true); // JavaScriptを有効にする
settings.setLoadWithOverviewMode(true); // 画面の横幅にページの横幅を合わせる
settings.setUseWideViewPort(true); // 画面の横幅にページの横幅を合わせる
//noinspection deprecation(API18から非推奨になった。無視)
......@@ -218,12 +229,28 @@ public class DashboardActivity extends OperationActivity {
}
@JavascriptInterface
public void getAttachedDataUrl(String taskKey, String data) {
//commonAttachedDataUrl(taskKey, data);
public String getCachePath() {
return getCacheDir().getAbsolutePath();
}
@JavascriptInterface
public void sendParam(String param) {
Logger.i(TAG, "sendParam: %s", param);
final JSONObject json = new JSONObject(param);
runOnUiThread(new Runnable() {
@Override
public void run() {
checkApiLoading(json);
}
});
}
private class ViewClient extends WebViewClient {
@JavascriptInterface
public void getAttachedDataUrl(String taskKey, String data) {}
}
private static class ViewClient extends WebViewClient {
@SuppressWarnings("deprecation")
@Override
......@@ -234,86 +261,60 @@ public class DashboardActivity extends OperationActivity {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
Logger.v(TAG, "shouldOverrideUrlLoading: %s", url);
if (url.startsWith("abook")) {
final Uri uri = Uri.parse(url);
// AndroidOSが5以下のPANO_SERVER処理のため、置き換える必要がある。
url = "/" + url;
if (url.contains(ABookKeys.ABOOK_CHECK_API)) {
return checkApiLoding(uri);
}
return true;
}
return false;
}
}
private boolean checkApiLoding(Uri uri) {
Map<String, String> param = new HashMap<>();
for (String key : uri.getQueryParameterNames()) {
param.put(key, uri.getQueryParameter(key));
}
private void checkApiLoading(JSONObject json) {
String cmd = param.get(ABookKeys.CMD);
String cmd = json.getString(ABookKeys.CMD);
if (cmd == null) {
return false;
return;
}
try {
switch (cmd) {
case CMD_GET_REPORT_STATUS_COUNT: {
countInitialized = true;
return getReportStatusCount();
}
case CMD_GET_REPORT_LIST: {
if (! countInitialized) {
countInitialized = true;
getReportStatusCount();
break;
}
String reportStatusId = param.get(ReportStatusId);
if (reportStatusId != null) {
return getReportList(Integer.parseInt(reportStatusId));
} else {
return false;
}
case CMD_GET_REPORT_LIST: {
int reportStatusId = json.getInt(ReportStatusId);
getReportList(reportStatusId);
break;
}
case CMD_GO_REPORT_DETAIL: {
Long operationId = getLongOrNull(param.get(OperationId));
if (operationId == null) {
return true;
} else {
return goReportDetail(operationId);
}
long operationId = json.getLong(OperationId);
goReportDetail(operationId);
break;
}
case CMD_LOCK_REPORT: {
String taskKey = param.get(TaskKey);
Long taskReportId = getLongOrNull(param.get(TaskReportId));
Date reportStartDate = getDateOrNull(param.get(ReportStartDate));
return lockReport(taskKey, taskReportId, reportStartDate);
String taskKey = json.getString(TaskKey);
long taskReportId = json.getLong(TaskReportId);
Date reportStartDate = getDateOrNull(json.getString(ReportStartDate));
lockReport(taskKey, taskReportId, reportStartDate);
break;
}
case CMD_UNLOCK_REPORT: {
String taskKey = param.get(TaskKey);
Long taskReportId = getLongOrNull(param.get(TaskReportId));
Date reportStartDate = getDateOrNull(param.get(ReportStartDate));
return unlockReport(taskKey, taskReportId, reportStartDate);
String taskKey = json.getString(TaskKey);
long taskReportId = json.getLong(TaskReportId);
Date reportStartDate = getDateOrNull(json.getString(ReportStartDate));
unlockReport(taskKey, taskReportId, reportStartDate);
break;
}
}
} catch (Throwable e) {
Logger.e(TAG, e.getLocalizedMessage());
return false;
Logger.e(TAG, e);
}
return false;
}
private boolean getReportStatusCount() {
private void getReportStatusCount() throws IOException {
ReportStatusDao dao = AbstractDao.getDao(ReportStatusDao.class);
JSONObject extParam = dao.getReportStatusCountJson();
afterABookCheckApi(CMD_GET_REPORT_STATUS_COUNT, "", 0,"", extParam.toString());
return true;
saveCounts(extParam);
}
private boolean getReportList(int reportStatusId) {
private void getReportList(int reportStatusId) {
ReportStatusDao dao = AbstractDao.getDao(ReportStatusDao.class);
List<ReportStatusDto> reports = null;
switch (reportStatusId) {
......@@ -353,9 +354,6 @@ public class DashboardActivity extends OperationActivity {
JSONObject param = makeReportTree(reportStatusId, reports);
String script = "javascript:CHK_Dashboard.reportListCallback(" + reportStatusId + "," + param.toString() + ")";
webView.loadUrl(script);
return true;
} else {
return false;
}
}
......@@ -395,9 +393,9 @@ public class DashboardActivity extends OperationActivity {
return tree;
}
private boolean goReportDetail(long operationId) {
private void goReportDetail(long operationId) {
if (ActivityHandlingHelper.getInstance().isMeetingConnected()) {
return true;
return;
}
// 新着更新を止める
contentRefresher.stopRefresh();
......@@ -442,7 +440,6 @@ public class DashboardActivity extends OperationActivity {
intent.setClass(this, HTMLXWalkWebViewActivity.class);
ActivityHandlingHelper.getInstance().startHTMLXWalkWebActivity(this, intent, "file://" + path, contentDto.contentId, -1, -1, -1, -1, -1);
}
return true;
} else {
Logger.w(TAG, "content is not download");
}
......@@ -450,11 +447,9 @@ public class DashboardActivity extends OperationActivity {
Logger.e(TAG, e);
handleErrorMessageToast(ErrorCode.E107);
}
return false;
}
private boolean lockReport(String taskKey, Long taskReportId, Date reportStartDate) {
private void lockReport(String taskKey, Long taskReportId, Date reportStartDate) {
try {
LockReportLogic.Result r = LockReportLogic.newInstance().lock(taskKey, taskReportId, reportStartDate);
// JSコールバック
......@@ -465,14 +460,12 @@ public class DashboardActivity extends OperationActivity {
r.getMessage(),
r.getExtParam().json()
);
return true;
} catch (Throwable e) {
e.printStackTrace();
return false;
}
}
private boolean unlockReport(String taskKey, Long taskReportId, Date reportStartDate) {
private void unlockReport(String taskKey, Long taskReportId, Date reportStartDate) {
try {
UnlockReportLogic.Result r = UnlockReportLogic.newInstance().unlock(taskKey, taskReportId, reportStartDate);
// JSコールバック
......@@ -483,10 +476,8 @@ public class DashboardActivity extends OperationActivity {
r.getMessage(),
r.getExtParam().json()
);
return true;
} catch (Throwable e) {
e.printStackTrace();
return false;
}
}
......@@ -502,21 +493,28 @@ public class DashboardActivity extends OperationActivity {
});
}
private Long getLongOrNull(String s) {
private Date getDateOrNull(String s) {
try {
return Long.parseLong(s);
return DateTimeUtil.toDate(s, "UTC", DateTimeFormat.yyyyMMddHHmmss_hyphen);
} catch (Exception e) {
Logger.e(TAG, e.getLocalizedMessage());
return null;
}
}
private Date getDateOrNull(String s) {
try {
return DateTimeUtil.toDate(s, "UTC", DateTimeFormat.yyyyMMddHHmmss_hyphen);
} catch (Exception e) {
Logger.e(TAG, e.getLocalizedMessage());
return null;
public String getCachePath() {
return getCacheDir().getAbsolutePath();
}
private void saveCounts(JSONObject counts) throws IOException {
File dir = new File(getCachePath());
File file = new File(dir, "getReportStatusCount.json");
try(FileWriter writer = new FileWriter(file)) {
writer.write(counts.toString());
} catch (Throwable e) {
Logger.e(TAG, e);
throw e;
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment