Commit 62397df1 by Kim Jinsung

ベースシーンとシーン登録処理追加

parent cc209be0
......@@ -616,21 +616,19 @@ public class AcmsClient implements AcmsClientResponseListener {
/**
* パノラマで使用するシーンを登録
* @param sid
* @param contentId
* @param FormFile シーンで使用する画像
* @return
* @throws IOException
* @throws AcmsException
*/
public SceneEntryJSON sceneEntry(String sid, Long contentId, File FormFile) throws IOException, AcmsException, NetworkDisconnectedException {
public SceneEntryJSON sceneEntry(String sid, File FormFile) throws IOException, AcmsException, NetworkDisconnectedException {
if (networkAdapter != null && !networkAdapter.isNetworkConnected()) { // NWのチェック
throw new NetworkDisconnectedException();
}
String apiUrl = AcmsApis.getApiUrl(env.acmsAddress, urlPath, AcmsApis.ApiSceneEntry);
HttpMultipart part1 = new HttpMultipart(ABookKeys.SID, sid);
HttpMultipart part2 = new HttpMultipart(ABookKeys.CONTENT_ID, StringUtil.toString(contentId));
HttpMultipart part3 = new HttpMultipart(ABookKeys.FORM_FILE, FormFile);
HttpResponse result = HttpRequestSender.post(apiUrl, new HttpMultipart[]{part1, part2, part3});
HttpMultipart part2 = new HttpMultipart(ABookKeys.FORM_FILE, FormFile);
HttpResponse result = HttpRequestSender.post(apiUrl, new HttpMultipart[]{part1, part2});
SceneEntryJSON json = new SceneEntryJSON(result.httpResponseBody);
if (json.httpStatus != 200) {
if (json.errorMessage != null) {
......
......@@ -129,6 +129,7 @@ public class ABookKeys {
public static final String EDITABLE = "editable"; //commonAttachedDataUrl()で編集可否を判別するパラメタをWebからもらう。
public static final String FILE_PATH = "filePath"; //再編集する場合、クリックしたイマージのパスのパラメタ
public static final String BASE_CONTENT_REGISTER = "BaseContentRegister";
//THETA端末関連
public static final String THETA_FILE_ID = "OBJECT_ID";
public static final String THETA_THUMBNAIL = "THUMBNAIL";
......
......@@ -1380,12 +1380,11 @@ public class OperationLogic extends AbstractLogic {
/**
* シーンの登録
* @param file
* @param contentId
* @throws IOException
* @throws AcmsException
*/
public Integer sendScene(File file, Long contentId) throws IOException, AcmsException, NetworkDisconnectedException {
SceneEntryJSON json = AcmsClient.getInstance(cache.getUrlPath(), networkAdapter).sceneEntry(cache.getMemberInfo().sid, contentId, file);
public Integer sendScene(File file) throws IOException, AcmsException, NetworkDisconnectedException {
SceneEntryJSON json = AcmsClient.getInstance(cache.getUrlPath(), networkAdapter).sceneEntry(cache.getMemberInfo().sid, file);
return json.resourceId;
}
......
......@@ -44,6 +44,21 @@ public class AlertDialogUtil {
}
/**
* 共通ダイアログ表示用(OKボタンコールバック、CANCELボタンコールバック)
* @param context コンテキスト
* @param title タイトル
* @param message メッセージ
* @param okOnClick OKボタンコールバック
* @param okOnClick CANCELボタンコールバック
*/
public static void showAlertDialog(Context context, int title, int message, DialogInterface.OnClickListener okOnClick, DialogInterface.OnClickListener canOnClick) {
ABookAlertDialog alertDialog = createAlertDialog(context, context.getResources().getString(title), context.getResources().getString(message));
alertDialog.setNegativeButton(R.string.cancel, canOnClick);
alertDialog.setPositiveButton(R.string.ok, okOnClick);
alertDialog.show();
}
/**
* 共通ダイアログ表示用(Cancel表示・非表示、OKボタンコールバック)
* @param context コンテキスト
* @param title タイトル
......
......@@ -102,10 +102,12 @@ import jp.agentec.abook.abv.ui.common.view.ABVListDialog;
import jp.agentec.abook.abv.ui.common.view.ABVPopupListWindow;
import jp.agentec.abook.abv.ui.home.adapter.HierarchyOperationGroupListAdapter;
import jp.agentec.abook.abv.ui.home.helper.ABookCheckWebViewHelper;
import jp.agentec.abook.abv.ui.home.helper.ABookPermissionHelper;
import jp.agentec.abook.abv.ui.home.helper.ActivityHandlingHelper;
import jp.agentec.abook.abv.ui.home.helper.HomeOperationListHelper;
import jp.agentec.abook.abv.ui.home.helper.OperationGroupMasterListHelper;
import jp.agentec.abook.abv.ui.home.helper.OperationListHelper;
import jp.agentec.abook.abv.ui.viewer.activity.DeviceImageListActivity;
import jp.agentec.abook.abv.ui.viewer.activity.HTMLXWalkWebViewActivity;
import jp.agentec.adf.util.DateTimeFormat;
import jp.agentec.adf.util.DateTimeUtil;
......@@ -170,6 +172,10 @@ public class OperationListActivity extends ABVUIActivity {
// 作業種別のサービスオプション値を保持用フラグ
private boolean mOperationGroupMasterServiceOperationFlg;
//シーン画像選択画面からベース画像登録後に閉じたときに処理追加のため、
private static final int SUB_DIVICE_IMAGE_LIST_ACTIVITY = 1001;
private Long mSelectedOperationId;
// ビューの作成
private class ReloadHandler implements Runnable {
@Override
......@@ -1152,185 +1158,229 @@ public class OperationListActivity extends ABVUIActivity {
*/
public void showPanoEntryDialog(final OperationDto operationDto) {
Logger.d(TAG, "*****************showPanoEntryDialog");
if (contentRefresher != null && contentRefresher.isRefreshing()) {
// 新着更新処理が行っていれば、止める
contentRefresher.stopRefresh();
}
if (mPanoEntryDialog == null) {
mPanoEntryDialog = new Dialog(OperationListActivity.this);
mPanoEntryDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
mPanoEntryDialog.setCanceledOnTouchOutside(false);
mPanoEntryDialog.setContentView(R.layout.operation_pano_entry_dialog);
}
mPanoCotnentImageView = (ImageView) mPanoEntryDialog.findViewById(R.id.pano_image_view);
mPanoContentNameTextView = (TextView) mPanoEntryDialog.findViewById(R.id.operation_name);
mPanoContentNameTextView.setText(operationDto.operationName);
mPanoCotnentImageView.setImageBitmap(null);
FileUtil.delete(ABVEnvironment.getInstance().getCacheTempAttachedImageDirPath());
// 閉じるボタン
mPanoEntryDialog.findViewById(R.id.closeBtn).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mPanoCotnentImageView.setImageBitmap(null);
mSelectPanoContentUri = null;
mPanoEntryDialog.dismiss();
FileUtil.delete(ABVEnvironment.getInstance().getCacheTempAttachedImageDirPath());
}
});
// 画像選択ボタン
mPanoEntryDialog.findViewById(R.id.select_image).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startCameraIntent(ABOOK_CHECK_OPERATION_PANO_CONTENT_IMAGE, "Camera", ABookKeys.IMAGE, false);
//パーミッションチェック
ABookPermissionHelper helper = new ABookPermissionHelper(this, Constant.ABookPermissionType.ReadExternalStorage, null);
if (helper.checkMultiPermissions(true)) {
mSelectedOperationId = operationDto.operationId;
//シーン画像選択画面表示
Intent intent = new Intent();
intent.putExtra(ABookKeys.BASE_CONTENT_REGISTER, true);
intent.putExtra(ABookKeys.OPERATION_ID, mSelectedOperationId);
intent.putExtra(ABookKeys.OPERATION_NAME, operationDto.operationName);
String className = DeviceImageListActivity.class.getName();
if (isNormalSize() == false) {
className += "Dialog";
}
});
// 登録ボタン
mPanoEntryDialog.findViewById(R.id.btn_entry).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (!ABVEnvironment.getInstance().networkAdapter.isNetworkConnected()) {
ABVToastUtil.showMakeText(OperationListActivity.this, R.string.msg_network_offline, Toast.LENGTH_SHORT);
return;
}
if (mSelectPanoContentUri == null) {
ABVToastUtil.showMakeText(OperationListActivity.this, PatternStringUtil.patternToInt(getApplicationContext(),
R.string.msg_pano_image_no_selected,
getUserPref(AppDefType.UserPrefKey.RESOURCE_PATTERN_TYPE, 0)), Toast.LENGTH_SHORT);
return;
}
// リソースパターンの適用
showProgressView(PatternStringUtil.patternToString(getApplicationContext(),
R.string.msg_common_processing,
getUserPref(AppDefType.UserPrefKey.RESOURCE_PATTERN_TYPE, 0)));
CommonExecutor.execute(new Runnable() {
@Override
public void run() {
boolean isError = true;
String[] projection = {MediaStore.MediaColumns.DATA};
Cursor cursor = getContentResolver().query(mSelectPanoContentUri, projection, null, null, null);
String scenePath = null;
if (mSelectPanoContentUri.toString().contains("file")) { //アプリ内に臨時保存した画像ファイル
scenePath = mSelectPanoContentUri.getPath();
} else {
if (cursor != null) {
if (cursor.moveToFirst()) {
scenePath = cursor.getString(0);
}
cursor.close();
}
}
if (scenePath != null) {
File file = new File(scenePath);
isError = true;
try {
mOperationLogic.sendPanoContent(operationDto.operationId, operationDto.operationName, file);
isError = false;
} catch (ABVException e) {
//noinspection EnumSwitchStatementWhichMissesCases
switch (e.getCode()) {
case P_E_ACMS_P001:
showSimpleAlertDialog(R.string.app_name,
PatternStringUtil.patternToInt(getApplicationContext(),
R.string.P001,
getUserPref(AppDefType.UserPrefKey.RESOURCE_PATTERN_TYPE, 0)));
break;
case P_E_ACMS_P002:
showSimpleAlertDialog(R.string.app_name,
PatternStringUtil.patternToInt(getApplicationContext(),
R.string.P002,
getUserPref(AppDefType.UserPrefKey.RESOURCE_PATTERN_TYPE, 0)));
break;
case S_E_ACMS_0500:
handleErrorMessageToast(ABVExceptionCode.S_E_ACMS_0500);
break;
default:
Logger.e(TAG, "PanoContent send error", e);
handleErrorMessageToast(ErrorCode.E107);
break;
}
} catch (Exception e) {
Logger.e(TAG, e);
ErrorMessage.showErrorMessageToast(OperationListActivity.this, ErrorCode.E107);
}
}
if (isError) {
closeProgressPopup();
} else {
handler.post(new Runnable() {
@Override
public void run() {
progressDialogHorizontal.setProgress(20);
mOperationLogic.setContentCreatingFlg(operationDto.operationId);
refreshOperationList();
}
});
//10秒後に新着更新させる
handler.postDelayed(new Runnable() {
@Override
public void run() {
int progress = progressDialogHorizontal.getProgress();
progressDialogHorizontal.setProgress(progress + 8);
if (progress >= 100) {
closeProgressPopup();
mPanoEntryDialog.dismiss();
mPanoCotnentImageView.setImageBitmap(null);
dataRefresh(true);
} else {
handler.postDelayed(this, 1000);
}
}
}, 1000);
}
}
});
}
});
intent.setClassName(getPackageName(), className);
startActivityForResult(intent, SUB_DIVICE_IMAGE_LIST_ACTIVITY);
if (mPanoEntryDialog != null) {
mPanoEntryDialog.show();
} else {
Logger.w(TAG, "ReadExternalStorage checkMultiPermissions false");
}
// if (contentRefresher != null && contentRefresher.isRefreshing()) {
// // 新着更新処理が行っていれば、止める
// contentRefresher.stopRefresh();
// }
// if (mPanoEntryDialog == null) {
// mPanoEntryDialog = new Dialog(OperationListActivity.this);
// mPanoEntryDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
// mPanoEntryDialog.setCanceledOnTouchOutside(false);
// mPanoEntryDialog.setContentView(R.layout.operation_pano_entry_dialog);
// }
// mPanoCotnentImageView = (ImageView) mPanoEntryDialog.findViewById(R.id.pano_image_view);
// mPanoContentNameTextView = (TextView) mPanoEntryDialog.findViewById(R.id.operation_name);
//
// mPanoContentNameTextView.setText(operationDto.operationName);
// mPanoCotnentImageView.setImageBitmap(null);
// FileUtil.delete(ABVEnvironment.getInstance().getCacheTempAttachedImageDirPath());
//
// // 閉じるボタン
// mPanoEntryDialog.findViewById(R.id.closeBtn).setOnClickListener(new View.OnClickListener() {
//
// @Override
// public void onClick(View v) {
// mPanoCotnentImageView.setImageBitmap(null);
// mSelectPanoContentUri = null;
// mPanoEntryDialog.dismiss();
// FileUtil.delete(ABVEnvironment.getInstance().getCacheTempAttachedImageDirPath());
// }
// });
//
//
// // 画像選択ボタン
// mPanoEntryDialog.findViewById(R.id.select_image).setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(View v) {
// startCameraIntent(ABOOK_CHECK_OPERATION_PANO_CONTENT_IMAGE, "Camera", ABookKeys.IMAGE, false);
// }
// });
//
//
// // 登録ボタン
// mPanoEntryDialog.findViewById(R.id.btn_entry).setOnClickListener(new View.OnClickListener() {
//
// @Override
// public void onClick(View v) {
// if (!ABVEnvironment.getInstance().networkAdapter.isNetworkConnected()) {
// ABVToastUtil.showMakeText(OperationListActivity.this, R.string.msg_network_offline, Toast.LENGTH_SHORT);
// return;
// }
// if (mSelectPanoContentUri == null) {
// ABVToastUtil.showMakeText(OperationListActivity.this, PatternStringUtil.patternToInt(getApplicationContext(),
// R.string.msg_pano_image_no_selected,
// getUserPref(AppDefType.UserPrefKey.RESOURCE_PATTERN_TYPE, 0)), Toast.LENGTH_SHORT);
// return;
// }
// // リソースパターンの適用
// showProgressView(PatternStringUtil.patternToString(getApplicationContext(),
// R.string.msg_common_processing,
// getUserPref(AppDefType.UserPrefKey.RESOURCE_PATTERN_TYPE, 0)));
// CommonExecutor.execute(new Runnable() {
// @Override
// public void run() {
// boolean isError = true;
// String[] projection = {MediaStore.MediaColumns.DATA};
// Cursor cursor = getContentResolver().query(mSelectPanoContentUri, projection, null, null, null);
//
// String scenePath = null;
// if (mSelectPanoContentUri.toString().contains("file")) { //アプリ内に臨時保存した画像ファイル
// scenePath = mSelectPanoContentUri.getPath();
// } else {
// if (cursor != null) {
// if (cursor.moveToFirst()) {
// scenePath = cursor.getString(0);
// }
// cursor.close();
// }
//
// }
// if (scenePath != null) {
// File file = new File(scenePath);
// isError = true;
// try {
// mOperationLogic.sendPanoContent(operationDto.operationId, operationDto.operationName, file);
// isError = false;
// } catch (ABVException e) {
// //noinspection EnumSwitchStatementWhichMissesCases
// switch (e.getCode()) {
// case P_E_ACMS_P001:
// showSimpleAlertDialog(R.string.app_name,
// PatternStringUtil.patternToInt(getApplicationContext(),
// R.string.P001,
// getUserPref(AppDefType.UserPrefKey.RESOURCE_PATTERN_TYPE, 0)));
// break;
// case P_E_ACMS_P002:
// showSimpleAlertDialog(R.string.app_name,
// PatternStringUtil.patternToInt(getApplicationContext(),
// R.string.P002,
// getUserPref(AppDefType.UserPrefKey.RESOURCE_PATTERN_TYPE, 0)));
// break;
// case S_E_ACMS_0500:
// handleErrorMessageToast(ABVExceptionCode.S_E_ACMS_0500);
// break;
// default:
// Logger.e(TAG, "PanoContent send error", e);
// handleErrorMessageToast(ErrorCode.E107);
// break;
// }
// } catch (Exception e) {
// Logger.e(TAG, e);
// ErrorMessage.showErrorMessageToast(OperationListActivity.this, ErrorCode.E107);
// }
// }
// if (isError) {
// closeProgressPopup();
// } else {
// handler.post(new Runnable() {
// @Override
// public void run() {
// progressDialogHorizontal.setProgress(20);
// mOperationLogic.setContentCreatingFlg(operationDto.operationId);
// refreshOperationList();
// }
// });
//
// //10秒後に新着更新させる
// handler.postDelayed(new Runnable() {
// @Override
// public void run() {
// int progress = progressDialogHorizontal.getProgress();
// progressDialogHorizontal.setProgress(progress + 8);
// if (progress >= 100) {
// closeProgressPopup();
// mPanoEntryDialog.dismiss();
// mPanoCotnentImageView.setImageBitmap(null);
// dataRefresh(true);
// } else {
// handler.postDelayed(this, 1000);
// }
// }
// }, 1000);
// }
// }
// });
// }
// });
//
// if (mPanoEntryDialog != null) {
// mPanoEntryDialog.show();
// }
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
activityResultFlg = true;
Uri result = (intent == null || resultCode != RESULT_OK) ? null : intent.getData();
if (requestCode == ABOOK_CHECK_OPERATION_PANO_CONTENT_IMAGE) {
if (result != null) {
mSelectPanoContentUri = result;
try {
String[] projection = {MediaStore.MediaColumns.DATA};
Cursor cursor = getContentResolver().query(mSelectPanoContentUri, projection, null, null, null);
String photoFilePath = ABookCheckWebViewHelper.getInstance().contentSchemeUriToFilePath(cursor);
int rotationAngle = ABookCheckWebViewHelper.getInstance().rotateBitmapOrientation(photoFilePath);
if (rotationAngle != 0) {
mLocalFile = ABookCheckWebViewHelper.getInstance().rotateBitmapToImageFile(rotationAngle, photoFilePath, ABVEnvironment.getInstance().getCacheTempAttachedImageDirPath());
mSelectPanoContentUri = Uri.fromFile(mLocalFile);
}
if (mSelectPanoContentUri != null) {
InputStream stream = getContentResolver().openInputStream(mSelectPanoContentUri);
Bitmap bitmap = BitmapFactory.decodeStream(stream);
mPanoCotnentImageView.setImageBitmap(bitmap);
}
//ベースファイル登録した後にシーン画像選択画面閉じた後に呼ばれる
if (requestCode == SUB_DIVICE_IMAGE_LIST_ACTIVITY) {
mOperationLogic.setContentCreatingFlg(mSelectedOperationId);
refreshOperationList();
} catch (FileNotFoundException e) {
Logger.e(TAG, "panoImageContent is not found", e);
} catch (IOException e) {
Logger.e(TAG, "IOException = ", e);
//10秒(コンテンツ作成し、公開までの時間)に新着更新させる。
showProgressView(getString(R.string.msg_common_processing));
handler.postDelayed(new Runnable() {
@Override
public void run() {
int progress = progressDialogHorizontal.getProgress();
progressDialogHorizontal.setProgress(progress + 10);
if (progress >= 100) {
closeProgressPopup();
//新着更新
dataRefresh(true);
} else {
handler.postDelayed(this, 1000);
}
}
}
}, 1000);
}
// if (requestCode == ABOOK_CHECK_OPERATION_PANO_CONTENT_IMAGE) {
// if (result != null) {
// mSelectPanoContentUri = result;
// try {
// String[] projection = {MediaStore.MediaColumns.DATA};
// Cursor cursor = getContentResolver().query(mSelectPanoContentUri, projection, null, null, null);
// String photoFilePath = ABookCheckWebViewHelper.getInstance().contentSchemeUriToFilePath(cursor);
// int rotationAngle = ABookCheckWebViewHelper.getInstance().rotateBitmapOrientation(photoFilePath);
// if (rotationAngle != 0) {
// mLocalFile = ABookCheckWebViewHelper.getInstance().rotateBitmapToImageFile(rotationAngle, photoFilePath, ABVEnvironment.getInstance().getCacheTempAttachedImageDirPath());
// mSelectPanoContentUri = Uri.fromFile(mLocalFile);
// }
// if (mSelectPanoContentUri != null) {
// InputStream stream = getContentResolver().openInputStream(mSelectPanoContentUri);
// Bitmap bitmap = BitmapFactory.decodeStream(stream);
// mPanoCotnentImageView.setImageBitmap(bitmap);
// }
//
// } catch (FileNotFoundException e) {
// Logger.e(TAG, "panoImageContent is not found", e);
// } catch (IOException e) {
// Logger.e(TAG, "IOException = ", e);
// }
// }
// }
}
/**
......
......@@ -22,7 +22,6 @@ import com.imagepicker.ImageInternalFetcher;
import com.theta.helper.ThetaHelper;
import com.theta.network.ThetaDeviceInfo;
import java.io.File;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
......@@ -30,15 +29,10 @@ import java.util.List;
import java.util.Set;
import jp.agentec.abook.abv.bl.common.Callback;
import jp.agentec.abook.abv.bl.common.CommonExecutor;
import jp.agentec.abook.abv.bl.common.Constant;
import jp.agentec.abook.abv.bl.common.constant.ABookKeys;
import jp.agentec.abook.abv.bl.common.constant.ABookValues;
import jp.agentec.abook.abv.bl.common.exception.ABVExceptionCode;
import jp.agentec.abook.abv.bl.common.exception.AcmsException;
import jp.agentec.abook.abv.bl.common.log.Logger;
import jp.agentec.abook.abv.bl.logic.AbstractLogic;
import jp.agentec.abook.abv.bl.logic.OperationLogic;
import jp.agentec.abook.abv.cl.environment.DeviceInfo;
import jp.agentec.abook.abv.launcher.android.R;
import jp.agentec.abook.abv.ui.common.activity.ABVUIActivity;
......@@ -50,6 +44,7 @@ import jp.agentec.abook.abv.ui.viewer.activity.theta.ThetaCameraActivity;
import jp.agentec.abook.abv.ui.viewer.activity.theta.task.DeviceInfoTask;
import jp.agentec.abook.abv.ui.viewer.adapter.ImageGalleryAdapter;
import jp.agentec.abook.abv.ui.viewer.adapter.WifiThetaConnectAdapter;
import jp.agentec.abook.abv.ui.viewer.helper.SceneSendHelper;
import jp.agentec.abook.abv.ui.viewer.view.CustomImage;
public class DeviceImageListActivity extends ABVUIActivity {
......@@ -78,7 +73,7 @@ public class DeviceImageListActivity extends ABVUIActivity {
GridView mGalleryGridView;
ImageGalleryAdapter mGalleryAdapter;
private Set<String> mSelectedImages;
private ArrayList<String> mSelectedImages;
private List<CustomImage>mLocalImageList;
private Set<String>mLocalImageUriList;
public ImageInternalFetcher mImageFetcher;
......@@ -87,12 +82,16 @@ public class DeviceImageListActivity extends ABVUIActivity {
private int mGridViewRowHeight;
private boolean mIsOnResume;
private Long mContentId;
private Long mOperationId;
private String mOperationName;
private Dialog mThetaDeviceConnectDialog;
private ListView notSavedListView;
private ListView savedListView;
private boolean isBaseSceneUpload = false;
private boolean mIsBaseSceneUpload = false;
private boolean mIsBaseSceneUploadSuccess = true;
private ThetaHelper mThetaHelper = new ThetaHelper(this);
private SceneSendHelper mSceneSendHelper = new SceneSendHelper(this);
@Override
public void onCreate(Bundle savedInstanceState) {
......@@ -101,20 +100,19 @@ public class DeviceImageListActivity extends ABVUIActivity {
setContentView(R.layout.ac_device_image_list);
Intent intent = getIntent();
mContentId = intent.getLongExtra(ABookKeys.CONTENT_ID, -1);
if (mContentId == -1) {
isBaseSceneUpload = true;
}
mSelectedImages = new HashSet<>();
mIsBaseSceneUpload = intent.getBooleanExtra(ABookKeys.BASE_CONTENT_REGISTER, false);
mOperationId = intent.getLongExtra(ABookKeys.OPERATION_ID, -1);
mOperationName = intent.getStringExtra(ABookKeys.OPERATION_NAME);
mSelectedImages = new ArrayList<>();
mLocalImageList = new ArrayList<>();
mLocalImageUriList = new HashSet<>();
mIsOnResume = false;
mIsBaseSceneUploadSuccess = false;
mImageFetcher = new ImageInternalFetcher(this, THUMBNALE_SIZE);
mImageFetcher.addImageCache(this, THUMB_IMAGE_CACHE_DIRECTORY_NAME);
mImageFetcher.clearCache();
mIsOnResume = false;
mGalleryGridView = findViewById(R.id.gallery_grid);
Button closeBtn = findViewById(R.id.close); // 閉じるボタン
closeBtn.setOnClickListener(new View.OnClickListener() {
......@@ -123,9 +121,10 @@ public class DeviceImageListActivity extends ABVUIActivity {
Logger.v(TAG, "CloseBtn.onClick");
//キャッシュをクリア
mImageFetcher.clearCache();
finish();
activityClose();
}
});
mRegistBtn = findViewById(R.id.regist);
mRegistBtn.setOnClickListener(new View.OnClickListener() {
@Override
......@@ -142,7 +141,6 @@ public class DeviceImageListActivity extends ABVUIActivity {
}
});
}
}
});
mRegistBtn.setEnabled(false);
......@@ -289,7 +287,7 @@ public class DeviceImageListActivity extends ABVUIActivity {
* 端末のギャラリーから画像情報を元にして、GridViewビューア描画
*/
private void displayGalleryGridView() {
mGalleryAdapter = new ImageGalleryAdapter(this, mLocalImageList, mGridViewRowHeight);
mGalleryAdapter = new ImageGalleryAdapter(this, mLocalImageList, mGridViewRowHeight, mIsBaseSceneUpload);
mGalleryGridView.setAdapter(mGalleryAdapter);
mGalleryGridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
private boolean isClicked = false;
......@@ -297,7 +295,16 @@ public class DeviceImageListActivity extends ABVUIActivity {
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
CustomImage customImage = mGalleryAdapter.getItem(i);
if (containsCustomImageUri(customImage.mUri)) {
boolean isFirst = firstCustomImageUri(customImage.mUri);
mSelectedImages.remove(customImage.mUri.toString());
//ベースシーンが削除された場合、2番目に選択された画像がベースシーン選択状態にする
if (mIsBaseSceneUpload) {
if (isFirst) {
mGalleryAdapter.notifyDataSetChanged();
mRegistBtn.setEnabled(mSelectedImages.size() != 0);
return;
}
}
} else {
//最大選択画像をチェック
if (mSelectedImages.size() + 1 > IMAGE_SELECT_MAX_COUNT) {
......@@ -336,100 +343,122 @@ public class DeviceImageListActivity extends ABVUIActivity {
}
/**
* 選択画像配列から1番目かチェック
* @param imageUri 画像ファイル情報
* @return true:1番目、false:2番目以上
*/
public boolean firstCustomImageUri(Uri imageUri){
if (mIsBaseSceneUpload && mIsBaseSceneUploadSuccess) {
return false;
}
return mSelectedImages.indexOf(imageUri.toString()) == 0;
}
/**
* 選択されている画像をサーバ側に送信する。
*/
private void sendImageList(final Set<String> sendImages) {
private void sendImageList(final List<String> sendImages) {
showProgressView(PatternStringUtil.patternToString(getApplicationContext(),
R.string.msg_access_registing,
getUserPref(AppDefType.UserPrefKey.RESOURCE_PATTERN_TYPE, 0)));
CommonExecutor.execute(new Runnable() {
mSceneSendHelper.setListener(new SceneSendHelper.DeviceImageListSendListener() {
/**
* シーン登録成功した後、ダイアログ表示
*/
@Override
public void run() {
final Set<String> needSendImages = new HashSet<>(sendImages);
for(String filePath : sendImages){
File file = new File(filePath);
try {
AbstractLogic.getLogic(OperationLogic.class).sendScene(file, mContentId);
needSendImages.remove(filePath);
//プログレスバー進捗
final int progress = (int) (((float)(sendImages.size() - needSendImages.size()) / sendImages.size()) * 100);
runOnUiThread(new Runnable() {
public void sceneSendfinish() {
handler.postDelayed(new Runnable() {
@Override
public void run() {
//プログレスバー非表示
closeProgressPopup();
//成功ダイアログ表示
AlertDialogUtil.showAlertDialog(DeviceImageListActivity.this, R.string.app_name, R.string.msg_image_select_send_success, true, new DialogInterface.OnClickListener() {
@Override
public void run() {
progressDialogHorizontal.setProgress(progress);
public void onClick(DialogInterface dialog, int which) {
activityClose();
}
});
}
}, SEND_FINISH_DIALOG_DELAY_MILLIS);
}
/**
* インジケーターのプログレスバー更新
* @param progress プログレスバー設定値
*/
@Override
public void changeProgress(final int progress) {
runOnUiThread(new Runnable() {
@Override
public void run() {
if (mIsBaseSceneUpload) {
mIsBaseSceneUploadSuccess = true;
}
progressDialogHorizontal.setProgress(progress);
}
});
}
/**
* サーバ通信失敗時に再度送信要求しない。
* @param errorMessage エラーメッセージ
*/
@Override
public void sceneSendFail(final String errorMessage) {
// シーン追加時、ロック状態である場合
runOnUiThread(new Runnable() {
@Override
public void run() {
closeProgressPopup();
showSimpleAlertDialog(errorMessage);
}
});
}
//送信終了
if (needSendImages.size() == 0) {
//プログレスバーを100%を表示してから非表示するため、ディレーする。
handler.postDelayed(new Runnable() {
/**
* サーバ通信失敗時に再度送信要求する
* @param sendImages 再送信画像FilePath配列
*/
@Override
public void sceneSendFailRetry(final List<String> sendImages) {
handler.post(new Runnable() {
@Override
public void run() {
closeProgressPopup();
//ベースシーンアップロード時、ベースシーン登録完了の場合、Cancelでシーン画像選択画面非表示
if (mIsBaseSceneUpload && mIsBaseSceneUploadSuccess) {
AlertDialogUtil.showAlertDialog(DeviceImageListActivity.this, R.string.app_name, R.string.msg_image_select_send_fail_retry, new DialogInterface.OnClickListener() {
@Override
public void run() {
//プログレスバー非表示
closeProgressPopup();
//成功ダイアログ表示
AlertDialogUtil.showAlertDialog(DeviceImageListActivity.this, R.string.app_name, R.string.msg_image_select_send_success, true, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
finish();
}
});
public void onClick(DialogInterface dialog, int which) { //OKボタン
if (checkNetworkConnected()) {
sendImageList(sendImages);
}
}
}, SEND_FINISH_DIALOG_DELAY_MILLIS);
}
} catch (AcmsException ex) {
Logger.e(TAG, ex);
if (ex.getCode() == ABVExceptionCode.P_E_ACMS_P007) {
// シーン追加時、ロック状態である場合
runOnUiThread(new Runnable() {
}, new DialogInterface.OnClickListener() { //Cancelボタン
@Override
public void run() {
closeProgressPopup();
showSimpleAlertDialog(R.string.app_name, R.string.error_msg_open_pano_edit);
public void onClick(DialogInterface dialog, int which) {
activityClose();
}
});
} else {
handler.post(new Runnable() {
AlertDialogUtil.showAlertDialog(DeviceImageListActivity.this, R.string.app_name, R.string.msg_image_select_send_fail_retry, false, new DialogInterface.OnClickListener() {
@Override
public void run() {
sendImageFailDialog(needSendImages);
public void onClick(DialogInterface dialog, int which) { //OKボタン
//インターネット非接続チェック
if (checkNetworkConnected()) {
sendImageList(sendImages);
}
}
});
}
break;
} catch (Exception e) {
Logger.e(TAG, e);
handler.post(new Runnable() {
@Override
public void run() {
sendImageFailDialog(needSendImages);
}
});
break;
}
}
});
}
});
mSceneSendHelper.sendSceneImages(sendImages, mOperationId, mOperationName, mIsBaseSceneUpload);
}
/**
* サーバ側通信時、失敗の時の再登録ダイアログ表示
* @param needSendImages 登録必要な画像URI配列
*/
private void sendImageFailDialog(final Set<String> needSendImages) {
closeProgressPopup();
AlertDialogUtil.showAlertDialog(this, R.string.app_name, R.string.msg_image_select_send_fail_retry, false, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
//インターネット非接続チェック
if (checkNetworkConnected()) {
sendImageList(needSendImages);
}
}
});
}
/**
* THETAカメラ接続ダイアログを表示
......@@ -541,6 +570,33 @@ public class DeviceImageListActivity extends ABVUIActivity {
}
}
/**
* デバイスのWifi有効・無効チェックし
* 無効の場合、ダイアログ表示
* @return true:有効, false:無効
*/
private boolean deviceWifiEnable() {
if (DeviceInfo.isDeviceWifiEnabled(DeviceImageListActivity.this)) {
return true;
} else {
showSimpleAlertDialog(R.string.msg_error_device_wifi_off);
return false;
}
}
/**
* ActivityをFinishする
*/
private void activityClose() {
//ベースシーン登録成功後、新着更新させるため
if (mIsBaseSceneUpload) {
if (mIsBaseSceneUploadSuccess) {
Intent data = new Intent();
setResult(RESULT_OK);
}
}
finish();
}
/**
* THETAカメラ情報取得完了後、呼ばれる
......@@ -575,18 +631,4 @@ public class DeviceImageListActivity extends ABVUIActivity {
}
}
}
/**
* デバイスのWifi有効・無効チェックし
* 無効の場合、ダイアログ表示
* @return true:有効, false:無効
*/
private boolean deviceWifiEnable() {
if (DeviceInfo.isDeviceWifiEnabled(DeviceImageListActivity.this)) {
return true;
} else {
showSimpleAlertDialog(R.string.msg_error_device_wifi_off);
return false;
}
}
}
......@@ -94,7 +94,7 @@ public class ParentWebViewActivity extends ABVContentViewActivity {
if (helper.checkMultiPermissions(true)) {
//シーン画像選択画面表示
Intent intent = new Intent();
intent.putExtra(ABookKeys.CONTENT_ID, contentId);
intent.putExtra(ABookKeys.BASE_CONTENT_REGISTER, false);
String className = DeviceImageListActivity.class.getName();
if (isNormalSize() == false) {
className += "Dialog";
......
......@@ -18,11 +18,12 @@ public class ImageGalleryAdapter extends BaseAdapter {
LayoutInflater inflater;
List<CustomImage> imageUriList;
int mRowHeight;
public ImageGalleryAdapter(Context context, List<CustomImage> imageUriList, int rowHeight) {
boolean isBaseSceneUpload;
public ImageGalleryAdapter(Context context, List<CustomImage> imageUriList, int rowHeight, boolean isBaseSceneUpload) {
this.context = context;
this.imageUriList = imageUriList;
this.mRowHeight = rowHeight;
this.isBaseSceneUpload = isBaseSceneUpload;
inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
......@@ -59,10 +60,19 @@ public class ImageGalleryAdapter extends BaseAdapter {
CustomImage customImage = getItem(position);
boolean isSelected = ((DeviceImageListActivity)context).containsCustomImageUri(customImage.mUri);
holder.mThumbnailSelected.setImageResource(R.drawable.check_mark);
holder.mThumbnailSelected.setVisibility(View.INVISIBLE);
//ベースシーンチェック画像設定
if (isBaseSceneUpload) {
boolean isFirstImage = ((DeviceImageListActivity)context).firstCustomImageUri(customImage.mUri);
if (isFirstImage) {
holder.mThumbnailSelected.setImageResource(R.drawable.icon_base_content_check);
}
}
if (isSelected) {
holder.mThumbnailSelected.setVisibility(View.VISIBLE);
} else {
holder.mThumbnailSelected.setVisibility(View.INVISIBLE);
}
if (holder.customImage == null || !holder.customImage.mUri.equals(customImage.mUri)) {
......
package jp.agentec.abook.abv.ui.viewer.helper;
import android.content.Context;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import jp.agentec.abook.abv.bl.common.CommonExecutor;
import jp.agentec.abook.abv.bl.common.exception.ABVExceptionCode;
import jp.agentec.abook.abv.bl.common.exception.AcmsException;
import jp.agentec.abook.abv.bl.common.log.Logger;
import jp.agentec.abook.abv.bl.logic.AbstractLogic;
import jp.agentec.abook.abv.bl.logic.OperationLogic;
import jp.agentec.abook.abv.launcher.android.R;
/**
* シーン画像ファイルをサーバへ登録する処理クラス
*/
public class SceneSendHelper {
private static final String TAG = "DeviceImageListHelper";
private SceneSendHelper.DeviceImageListSendListener listener;
private Context mContext;
public SceneSendHelper(Context context) {
mContext = context;
}
public void setListener(SceneSendHelper.DeviceImageListSendListener listener) {
this.listener = listener;
}
public interface DeviceImageListSendListener {
void sceneSendfinish();
void changeProgress(final int progress);
void sceneSendFail(final String errorMessage);
void sceneSendFailRetry(List<String> retrySendImages);
}
/**
* シーン画像をサーバへ送信
* @param sendImages シーン画像ファイルPath配列
* @param operationId 作業ID
* @param OperationName 作業名
* @param isBaseSceneUpload ベースシーン登録フラグ(true:登録、false:登録しない)
*/
public void sendSceneImages(final List<String> sendImages, final Long operationId, final String OperationName, final boolean isBaseSceneUpload) {
CommonExecutor.execute(new Runnable() {
@Override
public void run() {
String firstFilePath = sendImages.get(0);
final List<String> needSendImages = new ArrayList<>(sendImages);
for(String filePath : sendImages){
File file = new File(filePath);
try {
if (isBaseSceneUpload && firstFilePath.equals(filePath)) {
AbstractLogic.getLogic(OperationLogic.class).sendPanoContent(operationId, OperationName, file);
} else {
AbstractLogic.getLogic(OperationLogic.class).sendScene(file);
}
needSendImages.remove(filePath);
//プログレスバー進捗
int progress = (int) (((float)(sendImages.size() - needSendImages.size()) / sendImages.size()) * 100);
listener.changeProgress(progress);
//送信終了
if (needSendImages.size() == 0) {
listener.sceneSendfinish();
}
} catch (AcmsException ex) {
Logger.e(TAG, ex);
if (ex.getCode() == ABVExceptionCode.P_E_ACMS_P007) {
listener.sceneSendFail(mContext.getString(R.string.error_msg_open_pano_edit));
} else {
listener.sceneSendFailRetry(needSendImages);
}
break;
} catch (Exception e) {
Logger.e(TAG, e);
listener.sceneSendFailRetry(needSendImages);
break;
}
}
}
});
}
}
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