Commit 61a5de98 by onuma

Merge branch 'features/1.2.363_41332' into 'features/1.2.363'

Bug #41332 「イメージプレビュー」を設定したアクションボタンをタップしても反応がない

See merge request !113
parents fd6a2268 090132ea
......@@ -3747,6 +3747,8 @@ public class ContentViewActivity extends ABVContentViewActivity {
for (int i = 0; i < imagefile.size(); i++) {
intent_.putExtra("FILEPATH" + (i + 1), mContentDir + "/" + imagefile.get(i));
}
intent_.putExtra("imageSize", imagefile.size());
intent_.putExtra("Position", 0);
intent_.putExtra(ABookKeys.CONTENT_ID, getContentId());
intent_.putExtra("pageNumber", mCurrentPageNumber);
......
......@@ -8,6 +8,7 @@ import jp.agentec.abook.abv.cl.util.ContentLogUtil;
import jp.agentec.abook.abv.launcher.android.R;
import jp.agentec.abook.abv.ui.common.activity.ABVContentViewActivity;
import jp.agentec.abook.abv.ui.common.util.ABVToastUtil;
import jp.agentec.abook.abv.ui.common.util.DisplayUtil;
import jp.agentec.abook.abv.ui.home.helper.ActivityHandlingHelper;
import jp.agentec.abook.abv.ui.viewer.view.ActionZoomLayout;
......@@ -16,7 +17,8 @@ import org.json.adf.JSONObject;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.Bitmap.Config;
import android.net.Uri;
import android.graphics.BitmapFactory;
import android.graphics.Point;
import android.os.Bundle;
import android.view.Gravity;
import android.view.KeyEvent;
......@@ -47,6 +49,10 @@ public class PreviewActivity extends ABVContentViewActivity {
private int mHistoryImageIndex[] = new int[2];
private int objectLogId;
// 実際に描画するBitmap
// Androidの仕様で100MB以上のBitmapは扱えないため、アスペクト比を保存した状態でリサイズしたもの)
private Bitmap FripperBitmap[];
@Override
public void onCreate(Bundle savedInstanceState) {
Logger.i(TAG, "onCreate");
......@@ -61,7 +67,6 @@ public class PreviewActivity extends ABVContentViewActivity {
mZoomLayout.addView(getLayoutInflater().inflate(R.layout.ac_preview, null), paramMain);
setContentView(mZoomLayout);
mMaxImg = 0;
// 画像数の取得
Intent intent = getIntent();
if (objectId != -1 || ABVEnvironment.getInstance().disableLogSend) {
......@@ -70,14 +75,7 @@ public class PreviewActivity extends ABVContentViewActivity {
}
objectLogId = intent.getIntExtra("objectLogId", -1);
mPosition = intent.getIntExtra("Position", 0);
for (int i = 0; i < 8; i++) {
if (intent.getStringExtra("FILEPATH" + (i + 1)) == null) {
break;
} else {
mMaxImg++;
}
}
mMaxImg = intent.getIntExtra("imageSize", 0);
mViewFlipper = (ViewFlipper) findViewById(R.id.viewFlipperPreview);
mLayoutThumbnail = (LinearLayout)findViewById(R.id.layoutThumbnail);
......@@ -96,6 +94,7 @@ public class PreviewActivity extends ABVContentViewActivity {
finishActivity();
return;
} else {
// 画面下の画像ボタン作成
float tmpDensity = getResources().getDisplayMetrics().density;
Bitmap resized = BitmapUtil.getResizedBitmap(mFilePath[i], (int)(50 * tmpDensity + 0.5f), (int)(50 * tmpDensity + 0.5f), Config.RGB_565, false);
imgBtn[i].setImageBitmap(resized);
......@@ -109,10 +108,13 @@ public class PreviewActivity extends ABVContentViewActivity {
mLayoutThumbnail.addView(imgBtn[i], paramThumbnail);
setBtnClick(imgBtn[i], i);
}
// 数が多い可能性もあるので、最初の1枚目のみBitmap作成してViewに追加する
ImageView flipperImageView = new ImageView(this);
flipperImageView.setScaleType(ScaleType.CENTER_INSIDE);
flipperImageView.setAdjustViewBounds(true);
flipperImageView.setImageURI(Uri.parse(mFilePath[0]));
FripperBitmap = new Bitmap[mMaxImg];
FripperBitmap[0] = resizeBitmap(mFilePath[0]);
flipperImageView.setImageBitmap(FripperBitmap[0]);
LinearLayout.LayoutParams param = new LinearLayout.LayoutParams(wrapContent, wrapContent);
mFlipperLayout[0].addView(flipperImageView, param);
mHistoryImageIndex[0] = 1;
......@@ -228,7 +230,11 @@ public class PreviewActivity extends ABVContentViewActivity {
ImageView flipperImageView = new ImageView(this);
flipperImageView.setScaleType(ScaleType.FIT_CENTER); //CENTER_INSIDE
flipperImageView.setAdjustViewBounds(true);
flipperImageView.setImageURI(Uri.parse(mFilePath[index]));
if (FripperBitmap[index] == null) {
// 表示用Bitmapがない時は作成。
FripperBitmap[index] = resizeBitmap(mFilePath[index]);
}
flipperImageView.setImageBitmap(FripperBitmap[index]);
int MP = ViewGroup.LayoutParams.MATCH_PARENT;
LinearLayout.LayoutParams param = new LinearLayout.LayoutParams(MP, MP);
mFlipperLayout[index].removeAllViews();
......@@ -318,4 +324,42 @@ public class PreviewActivity extends ABVContentViewActivity {
super.onStop();
ContentLogUtil.getInstance().endObjectLog(getContentId(), objectLogId);
}
/**
* アスペクト比を維持して、横に引き延ばしたBitmapを作成する
* @param filePath ファイルパス
* @return リサイズしたBitmap
*/
private Bitmap resizeBitmap(String filePath) {
// ディスプレイ情報取得
Point point = DisplayUtil.getDisplaySize(this);
int dispWidth = point.x;
int dispHeight = point.y;
// Bitmap情報取得
BitmapFactory.Options options = BitmapUtil.getBitmapDimensions(filePath);
int bitmapWidth = options.outWidth;
int bitmpaHeight = options.outHeight;
// 変更するサイズを計算
int targetW;
int targetH;
if (bitmapWidth > bitmpaHeight) {
targetW = dispWidth;
targetH = (int) ((float) bitmpaHeight * (float) dispWidth / (float) bitmapWidth);
if (targetH > dispHeight) {
targetH = dispHeight;
targetW = (int) ((float) bitmapWidth * (float) dispHeight / (float) bitmpaHeight);
}
} else {
targetH = dispHeight;
targetW = (int) ((float) bitmapWidth * (float) dispHeight / (float) bitmpaHeight);
if (targetW > dispWidth) {
targetW = dispWidth;
targetH = (int) ((float) bitmpaHeight * (float) dispWidth / (float) bitmapWidth);
}
}
return BitmapUtil.getResizedBitmap(filePath, targetW, targetH, Config.RGB_565, true);
}
}
\ No newline at end of file
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