Commit e8610a8a by Lee Munkyeong

コードレビュー対応。

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