Commit e8610a8a by Lee Munkyeong

コードレビュー対応。

parent 4a769161
......@@ -36,7 +36,7 @@ public class CommunicationLogic extends AbstractLogic {
private ChatMessageDao chatMessageDao = AbstractDao.getDao(ChatMessageDao.class);
private ShopMemberDao shopMemberDao = AbstractDao.getDao(ShopMemberDao.class);
private ChatGroupDao chatGroupDao = AbstractDao.getDao(ChatGroupDao.class);
private String localFilePath;
/**
* {@link CommunicationLogic} クラスのインスタンスを初期化します。
* context Androidとの互換性の為のプロパティです。Androidの android.content.Context のインスタンスを指定します。<br>
......@@ -781,7 +781,7 @@ public class CommunicationLogic extends AbstractLogic {
}
String[] filePaths = profileUrl.split("/");
String fileName = filePaths[filePaths.length-1];
String filePath = ABookCommConstants.FILE_SAVE_PATH + fileName;
String filePath = localFilePath + fileName;
File file = new File(filePath);
if (file.exists()) {
String uri = file.toURI().toString();
......@@ -796,13 +796,13 @@ public class CommunicationLogic extends AbstractLogic {
return fileUrlPath;
}
String fileName = fileUrlPath.split("fileName=")[1].split("&amp;")[0];
String filePath = ABookCommConstants.FILE_SAVE_PATH + fileName;
String filePath = localFilePath + fileName;
File file = new File(filePath);
if (file.exists()) {
String replaceTarget = "https" + fileUrlPath.split("https")[1].split("\"")[0];
String uri = file.toURI().toString();
String resultPath = fileUrlPath;
while(resultPath.contains(replaceTarget)) {
while (resultPath.contains(replaceTarget)) {
resultPath = resultPath.replace(replaceTarget, uri);
}
return resultPath;
......@@ -810,4 +810,8 @@ public class CommunicationLogic extends AbstractLogic {
return fileUrlPath;
}
};
public void setPackagePath(String localFilePath) {
this.localFilePath = localFilePath;
}
}
......@@ -436,8 +436,7 @@ public class BitmapUtil {
return bitmapList;
}
public static Bitmap convert(String base64Str) throws IllegalArgumentException
{
public static Bitmap convert(String base64Str) throws IllegalArgumentException {
byte[] decodedBytes = Base64.decode(
base64Str.substring(base64Str.indexOf(",") + 1),
Base64.DEFAULT
......@@ -446,8 +445,7 @@ public class BitmapUtil {
return BitmapFactory.decodeByteArray(decodedBytes, 0, decodedBytes.length);
}
public static String convert(Bitmap bitmap)
{
public static String convert(Bitmap bitmap) {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.PNG, 100, outputStream);
......
......@@ -135,7 +135,7 @@ public class ChatWebviewActivity extends ParentWebViewActivity {
}
setContentView(R.layout.chat_webview);
Intent intent = getIntent();
communicationLogic.setPackagePath(getFilesDir().getAbsolutePath() + "/");
sid = intent.getStringExtra("sid");
roomId = intent.getLongExtra("roomId", 0);
roomName = intent.getStringExtra("roomName");
......@@ -388,11 +388,11 @@ public class ChatWebviewActivity extends ParentWebViewActivity {
@Override
public void onLoadResource(WebView view, String url) {
if(url.contains("profileFileName")) {
if (url.contains("profileFileName")) {
Uri uri = Uri.parse(url);
String fileName = uri.getQueryParameter("profileFileName");
String filePath = getFilesDir().getAbsolutePath() + "/" + fileName;
Logger.i(TAG, filePath);
Logger.d(TAG, filePath);
File file = new File(filePath);
NetworkTask networkTask = new NetworkTask(url, filePath);
......@@ -401,7 +401,7 @@ public class ChatWebviewActivity extends ParentWebViewActivity {
Uri uri = Uri.parse(url);
String fileName = uri.getQueryParameter("fileName");
String filePath = getFilesDir().getAbsolutePath() + "/" + fileName;
Logger.i(TAG, filePath);
Logger.d(TAG, filePath);
File file = new File(filePath);
NetworkTask networkTask = new NetworkTask(url, filePath);
......@@ -1237,7 +1237,7 @@ public class ChatWebviewActivity extends ParentWebViewActivity {
@Override
protected Bitmap doInBackground(Void... params) {
try {
mBitmap =BitmapFactory.decodeStream((InputStream) new URL(url).getContent());
mBitmap =BitmapFactory.decodeStream((InputStream) new URL(url).getContent());
} catch (IOException e) {
e.printStackTrace();
}
......@@ -1258,11 +1258,11 @@ public class ChatWebviewActivity extends ParentWebViewActivity {
Bitmap bitmap = resultBitmap;
ByteArrayOutputStream bos = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.PNG, 0 , bos);
byte[] bitmapdata = bos.toByteArray();
bitmap.compress(Bitmap.CompressFormat.PNG, 0, bos);
byte[] bitmapData = bos.toByteArray();
FileOutputStream fos = new FileOutputStream(f);
fos.write(bitmapdata);
fos.write(bitmapData);
fos.flush();
fos.close();
} catch (IOException 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