Compare commits

..
Author SHA1 Message Date
r-ca 0c59c85b28 addNewPageBeforeIndex実装 2024-01-09 17:12:13 +09:00
r-ca e3a5dee36c addNewPageAfterIndex実装 2024-01-09 17:07:37 +09:00
r-ca 1805cd7d73 WIP 2024-01-09 17:05:25 +09:00
r-ca 513a91b41e throws追加 2024-01-09 17:04:42 +09:00
ろむねこ 3f2534b1eb Merge pull request #30 from lacerta-doc/improve/improve_file_manager
FileManagerの修正
2024-01-09 16:26:20 +09:00
r-ca af836ed486 修正 2024-01-09 16:18:02 +09:00
r-ca fe3d332a36 修正 2024-01-09 15:56:47 +09:00
r-ca 5fb938c263 リファクタリング 2024-01-09 15:54:14 +09:00
r-ca 3cafa05b27 修正 WIP 2024-01-09 15:53:20 +09:00
r-ca 9065ee1e1f ログ追加, 保存場所が異常になる問題を修正 2024-01-09 15:52:47 +09:00
r-ca 36ecb3ab13 新しいインスタンスを生成できるようにした 2024-01-09 15:30:18 +09:00
r-ca 01e111bdd5 必要に応じてインスタンスを生成するようにした 2024-01-09 15:27:42 +09:00
r-ca 65a25ad228 Revert "Revert "WIP""
This reverts commit 1b676f8368.
2024-01-09 15:18:31 +09:00
r-ca 1efac1ffb6 Revert "Revert "新しいインスタンスを作成するメソッドを作った""
This reverts commit 27aa6a2f15.
2024-01-09 15:18:30 +09:00
r-ca c05d45afdd fix 2024-01-09 15:11:15 +09:00
r-ca 27aa6a2f15 Revert "新しいインスタンスを作成するメソッドを作った"
This reverts commit 943ca1daf5.
2024-01-09 15:10:27 +09:00
r-ca 1b676f8368 Revert "WIP"
This reverts commit 30ed65079b.
2024-01-09 15:10:27 +09:00
r-ca 30ed65079b WIP 2024-01-09 15:10:19 +09:00
r-ca 943ca1daf5 新しいインスタンスを作成するメソッドを作った 2024-01-09 15:05:28 +09:00
r-ca 8913f8118d ファイルが存在しない場合に作成するメソッドを追加 2024-01-09 14:31:01 +09:00
r-ca 4cf3ff5f3c createFileの場合でも親ディレクトリを生成するように 2024-01-09 14:24:43 +09:00
r-ca 360580eff2 自動でパス解決させる 2024-01-09 14:20:06 +09:00
r-ca 730640425f 暫定)エラーハンドリング 2024-01-09 14:09:27 +09:00
r-ca 69b60944b4 暫定)エラーハンドリング 2024-01-09 14:09:05 +09:00
r-ca e8804e8f84 close処理修正 2024-01-09 14:03:29 +09:00
r-ca 7951bef6e0 保存処理 2024-01-09 14:02:07 +09:00
r-ca fbde892f40 ifNotExist実装 2024-01-09 13:52:00 +09:00
r-ca 022e7e278a fix 2024-01-09 13:51:19 +09:00
r-ca d88c9c2030 isExistを引数なしでも実行できるように 2024-01-09 13:50:47 +09:00
r-ca e055f8fe9e ディレクトリがない場合だけ新規作成するメソッド追加 WIP 2024-01-09 13:49:46 +09:00
r-ca 1af344a6d3 throws追加, 実装WIP 2024-01-09 13:47:58 +09:00
r-ca f3ac07e633 throws追加 2024-01-09 13:45:27 +09:00
r-ca a887446d21 isExistの実装を変更 2024-01-09 13:44:28 +09:00
r-ca b3a4207762 アンコメント 2024-01-09 13:42:36 +09:00
r-ca 0439a998e3 createDirectory実装 fix 2024-01-09 12:53:18 +09:00
r-ca a2eb04e96b createDirectory実装 WIP 2024-01-09 12:52:39 +09:00
r-ca b0c97da382 createFile実装 2024-01-09 12:52:18 +09:00
r-ca 3a9053e987 impl 2024-01-09 12:50:01 +09:00
r-ca 7cdb005ebb ファイル/ディレクトリを作成するメソッドを定義 2024-01-09 12:49:51 +09:00
r-ca 3a270cdc9f loggerをfinalに 2024-01-09 12:48:32 +09:00
r-ca f380e7eef8 不要なimportを削除 2024-01-09 12:48:11 +09:00
r-ca 8ca642c7f4 getFileRef実装 2024-01-09 12:46:20 +09:00
r-ca c28d94e417 loadBitmapInternal, loadBitmap実装 2024-01-09 12:44:40 +09:00
r-ca 8587c6a707 リファクタリング 2024-01-09 12:42:16 +09:00
r-ca f3465bcf81 loadXml, loadXmlInternal実装 2024-01-09 12:42:03 +09:00
r-ca 3e2a295a22 重複したメソッドを削除 2024-01-09 12:40:07 +09:00
r-ca f36dc05db1 リファクタリング 2024-01-09 12:39:36 +09:00
r-ca 78525d634a saveBitmap実装 2024-01-09 12:39:05 +09:00
r-ca 0736a7326a saveBitmapInternal実装 2024-01-09 12:38:48 +09:00
r-ca 76f4a6c228 saveXml実装 2024-01-09 12:37:23 +09:00
r-ca 3a41c4e105 Save系のメソッドからチェーンできる必要はなさそうなので戻り値をvoidに fix 2024-01-09 12:36:55 +09:00
r-ca 301678658c Save系のメソッドからチェーンできる必要はなさそうなので戻り値をvoidに 2024-01-09 12:36:35 +09:00
r-ca e20b3f4a35 修正 2024-01-09 12:34:42 +09:00
r-ca e0a344bb48 Xmlを保存するInternalメソッド実装 2024-01-09 12:34:10 +09:00
r-ca a2eda32183 getCurrentInstance実装 2024-01-09 12:32:50 +09:00
r-ca 0f8b71e739 Impl生成 2024-01-09 12:31:57 +09:00
r-ca 91fe39d141 読み書きのインタフェースを実装 2024-01-09 12:31:31 +09:00
r-ca 0dced5d0dc ディレクトリ/ファイルの判定メソッドを実装 2024-01-09 12:25:25 +09:00
r-ca 9e5b2dad46 読み書きの確認の前にファイルの存在を確認するように 2024-01-09 12:24:56 +09:00
r-ca 5c931ece3f ファイルの存在確認を実装 2024-01-09 12:23:59 +09:00
r-ca 3b861e3a07 読み込み/書き込み権限の確認を実装 WIP 2024-01-09 12:23:37 +09:00
r-ca 37497cb1ea configの書き込みを実装 2024-01-09 12:22:09 +09:00
r-ca 3efaf30b95 configの書き込みを実装 2024-01-09 12:20:15 +09:00
r-ca 9142696fac resolve実装 2024-01-09 12:19:40 +09:00
r-ca d5cf2f31d6 resolve実装 2024-01-09 12:18:03 +09:00
r-ca fcda369a2e resolveと競合するのでStringのsetPathを廃止 2024-01-09 12:15:12 +09:00
r-ca 9faf5c9055 実装 WIP 2024-01-09 12:14:43 +09:00
r-ca 0d78f9fa7c rootの合致チェックをフラグで切り替えるように 2024-01-09 12:00:26 +09:00
r-ca 8ebc96fa98 rootの合致チェックをフラグで切り替えるように 2024-01-09 12:00:16 +09:00
r-ca 2b8766db0a 自動でディレクトリを作成するかを切り替えるフラグを追加 2024-01-09 11:58:21 +09:00
r-ca 2233bb1a35 Impl WIP 2024-01-09 11:56:50 +09:00
r-ca c513b44e8d Impl WIP 2024-01-09 11:55:37 +09:00
r-ca cc35d8a5ea Impl WIP 2024-01-09 11:55:24 +09:00
r-ca 16ac36dd4f 既存の実装を削除 2024-01-09 11:48:46 +09:00
r-ca eadd65a334 WIP 2024-01-09 11:48:06 +09:00
r-ca 3ed835ef2f 既存の実装を削除 2024-01-09 11:34:12 +09:00
r-ca 4a66ed786d コメントアウト(エラーを減らすため) 2024-01-08 16:49:11 +09:00
r-ca 89e2f15a29 コメントアウト(エラーを減らすため) 2024-01-08 16:47:42 +09:00
ろむねこ 717b8e9637 Merge pull request #23 from lacerta-doc/source/add_files
画像ファイルの追加(保存), メタデータの管理
2024-01-08 16:18:36 +09:00
ろむねこ 3e24896bd1 Merge pull request #11 from lacerta-doc/feature/library/add_document_list
Feature/library/add document list
2024-01-08 16:14:10 +09:00
ろむねこ 94943184c4 Merge pull request #20 from lacerta-doc/r-ca-patch-1
Update issue templates
2024-01-08 15:58:17 +09:00
ろむねこ 30f2dc39ae Update issue templates 2024-01-08 15:57:51 +09:00
ろむねこ 4621025e62 Merge pull request #18 from lacerta-doc/r-ca-issue-template-1
Update issue templates
2024-01-08 15:56:18 +09:00
ろむねこ 164527d41a Merge pull request #19 from lacerta-doc/r-ca-pr-1
PRテンプレート追加
2024-01-08 15:56:01 +09:00
ろむねこ d770ac76aa Create general.md 2024-01-08 15:55:46 +09:00
ろむねこ 642f306ad6 Update issue templates 2024-01-08 15:45:01 +09:00
ろむねこ 930b48af2f Merge pull request #15 from lacerta-doc/common/improve_logger
Loggerの機能を強化
2024-01-08 15:36:24 +09:00
r-ca 3205923eb5 修正 2024-01-08 15:15:12 +09:00
r-ca 441479d9b9 デバッグ実装 2024-01-08 15:13:58 +09:00
r-ca 099d900ffd close処理を実装 2024-01-08 15:11:54 +09:00
r-ca 080e86d05d デバッグ処理実装 2024-01-08 15:11:28 +09:00
r-ca 6d6f4790a0 ページを修正 2024-01-08 15:09:48 +09:00
r-ca 1a31d63786 Currentの確認処理を修正 2024-01-08 15:09:17 +09:00
r-ca ce834a7cfd Currentを確認するメソッド追加 2024-01-08 15:06:33 +09:00
r-ca f7b8006fa4 保存ロジック修正 2024-01-08 14:42:29 +09:00
r-ca 5bb2f0d387 修正漏れ 2024-01-08 14:37:50 +09:00
r-ca e54cc07e9d ファイルマネージャーを共用するように 2024-01-08 14:37:10 +09:00
nero 54f2076eda ArrayListを削除(使ってなかったので) 2023-12-22 10:50:23 +09:00
nero c31a590ce3 例外時に出力するメッセージを変更 2023-12-22 10:29:57 +09:00
nero 2402936a19 重複事項を削除 2023-12-21 16:25:10 +09:00
nero ba87fb283e コメント追加 2023-12-21 16:19:34 +09:00
nero c35c4e829e コメントと例外が起こった際の処理を入れた 2023-12-21 16:16:07 +09:00
nero 017748b4a6 保存されたデータを一覧表示できるようにした 2023-12-21 16:03:49 +09:00
nero c2ee49d274 保存されているデータ件数を表示する機能 2023-12-21 14:54:58 +09:00
nero dd98602309 コメント追加 2023-12-21 14:54:06 +09:00
16 changed files with 547 additions and 379 deletions

No files matched your search

@@ -0,0 +1,17 @@
---
name: 不具合用テンプレート
about: 不具合用テンプレート
title: "[BUG]: "
labels: バグ
assignees: ''
---
# 概要
<!-- Issueの概要 -->
# 詳細
<!-- バグの詳細 -->
# 影響箇所
<!-- 予想される影響箇所(省略可) -->
@@ -0,0 +1,17 @@
---
name: 改善用テンプレート
about: 改善用テンプレート
title: "[IMPROVE]"
labels: ''
assignees: ''
---
# 概要
<!-- Issueの概要 -->
# 詳細
<!-- 改善内容の詳細 -->
# 影響箇所
<!-- 予想される影響箇所(省略可) -->
@@ -1,10 +1,20 @@
---
name: 新機能用テンプレート
about: 新規開発Issue用テンプレート
about: 新規能用テンプレート
title: ''
labels: ''
labels: 新機能
assignees: ''
---
WIP
# 概要
<!-- Issueの概要 -->
# 詳細
<!-- 機能の詳細 -->
# 関連Issue
<!-- 関連するIssueがあれば -->
# 影響箇所
<!-- 予想される影響箇所(省略可) -->
+18
View File
@@ -0,0 +1,18 @@
# 概要
<!-- PRの概要 -->
# 関連Issue
- #000 <!-- 関連するIssueを指定(なければ省略可) -->
# 詳細
<!-- 詳細 -->
# 影響箇所
<!-- 予想される影響箇所 -->
# チェック
<!-- 参考用, 全てにチェックがついている必要があるわけではありません -->
- [ ] 機能として完成している
- [ ] WIP(Work in progress: 作業中)
- [ ] 正常にビルド/起動ができる
- [ ] 既存の機能を壊していない
-17
View File
@@ -1,17 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="deploymentTargetDropDown">
<runningDeviceTargetSelectedWithDropDown>
<Target>
<type value="RUNNING_DEVICE_TARGET" />
<deviceKey>
<Key>
<type value="SERIAL_NUMBER" />
<value value="ZY227DCBHN" />
</Key>
</deviceKey>
</Target>
</runningDeviceTargetSelectedWithDropDown>
<timeTargetWasSelectedWithDropDown value="2023-12-21T04:53:14.729902700Z" />
</component>
</project>
@@ -169,7 +169,12 @@ public class ScannerDataManagerStubFragment extends Fragment {
}
this.documentProcessor = documentProcessorFactory.create(this.documentDetail);
Toast.makeText(getActivity(), "documentProcessor created", Toast.LENGTH_LONG).show();
this.documentProcessor.init();
try {
this.documentProcessor.init();
} catch (Exception e) {
Toast.makeText(getActivity(), "Error occurred while initializing documentProcessor", Toast.LENGTH_LONG).show();
Log.e("ScannerDataManagerStubFragment", "Error occurred while initializing documentProcessor", e);
}
Toast.makeText(getActivity(), "documentProcessor initialized", Toast.LENGTH_LONG).show();
});
@@ -180,9 +185,25 @@ public class ScannerDataManagerStubFragment extends Fragment {
Toast.makeText(getActivity(), "documentProcessor is null", Toast.LENGTH_LONG).show();
return;
}
Bitmap[] bitmaps = new Bitmap[results.size()];
for (int i = 0; i < results.size(); i++) {
bitmaps[i] = results.get(i).getBitmap();
}
for (CapturedData capturedData : this.results) {
this.documentProcessor.addNewPageToLast(capturedData.getBitmap());
try {
this.documentProcessor.addNewPagesToLast(bitmaps);
} catch (Exception e) {
Toast.makeText(getActivity(), "Error occurred while adding pages", Toast.LENGTH_LONG).show();
Log.e("ScannerDataManagerStubFragment", "Error occurred while adding pages", e);
}
Toast.makeText(getActivity(), "pages added", Toast.LENGTH_LONG).show();
try {
this.documentProcessor.close();
} catch (Exception e) {
Toast.makeText(getActivity(), "Error occurred while closing documentProcessor", Toast.LENGTH_LONG).show();
Log.e("ScannerDataManagerStubFragment", "Error occurred while closing documentProcessor", e);
}
});
}
@@ -63,46 +63,46 @@ public class DebugMenuFileManagerTesterFragment extends Fragment {
EditText editText = view.findViewById(R.id.edit_text_dir_name);
String dirName = editText.getText().toString();
FileManager fileManager = fileManagerFactory.create(deviceInfoUtils.getExternalStorageDirectory());
fileManager.createDir(dirName);
// FileManager fileManager = fileManagerFactory.create(deviceInfoUtils.getExternalStorageDirectory());
// fileManager.createDir(dirName);
});
view.findViewById(R.id.button_save_item).setOnClickListener(v -> {
FileManager fileManager = fileManagerFactory.create(deviceInfoUtils.getExternalStorageDirectory());
fileManager.createDir("test");
fileManager.changeDir("test");
Bitmap bitmap = Bitmap.createBitmap(1000, 1000, Bitmap.Config.ARGB_8888);
// Bitmapに描画処理を行う
Canvas canvas = new Canvas(bitmap);
// 大きな山の形状を作成
android.graphics.Path bigMountainPath = new android.graphics.Path();
bigMountainPath.moveTo(100, 800); // 左下の開始点
bigMountainPath.lineTo(500, 300); // 頂点
bigMountainPath.lineTo(900, 800); // 右下
bigMountainPath.close(); // パスを閉じる
// 山の描画設定
Paint mountainPaint = new Paint();
mountainPaint.setColor(Color.GREEN);
mountainPaint.setStyle(Paint.Style.FILL);
// 大きな山を描画
canvas.drawPath(bigMountainPath, mountainPaint);
// 小さな山の形状を作成
android.graphics.Path smallMountainPath = new android.graphics.Path();
smallMountainPath.moveTo(400, 800); // 左下の開始点
smallMountainPath.lineTo(650, 400); // 頂点
smallMountainPath.lineTo(900, 800); // 右下
smallMountainPath.close(); // パスを閉じる
Paint smallMountainPaint = new Paint();
smallMountainPaint.setColor(Color.parseColor("#006e54"));
smallMountainPaint.setStyle(Paint.Style.FILL);
// 小さな山を描画
canvas.drawPath(smallMountainPath, smallMountainPaint);
fileManager.saveBitmapAtCurrent(bitmap, "test.png");
// FileManager fileManager = fileManagerFactory.create(deviceInfoUtils.getExternalStorageDirectory());
// fileManager.createDir("test");
// fileManager.changeDir("test");
// Bitmap bitmap = Bitmap.createBitmap(1000, 1000, Bitmap.Config.ARGB_8888);
// // Bitmapに描画処理を行う
// Canvas canvas = new Canvas(bitmap);
// // 大きな山の形状を作成
// android.graphics.Path bigMountainPath = new android.graphics.Path();
// bigMountainPath.moveTo(100, 800); // 左下の開始点
// bigMountainPath.lineTo(500, 300); // 頂点
// bigMountainPath.lineTo(900, 800); // 右下
// bigMountainPath.close(); // パスを閉じる
//
// // 山の描画設定
// Paint mountainPaint = new Paint();
// mountainPaint.setColor(Color.GREEN);
// mountainPaint.setStyle(Paint.Style.FILL);
//
// // 大きな山を描画
// canvas.drawPath(bigMountainPath, mountainPaint);
//
// // 小さな山の形状を作成
// android.graphics.Path smallMountainPath = new android.graphics.Path();
// smallMountainPath.moveTo(400, 800); // 左下の開始点
// smallMountainPath.lineTo(650, 400); // 頂点
// smallMountainPath.lineTo(900, 800); // 右下
// smallMountainPath.close(); // パスを閉じる
//
// Paint smallMountainPaint = new Paint();
// smallMountainPaint.setColor(Color.parseColor("#006e54"));
// smallMountainPaint.setStyle(Paint.Style.FILL);
//
// // 小さな山を描画
// canvas.drawPath(smallMountainPath, smallMountainPaint);
// fileManager.saveBitmapAtCurrent(bitmap, "test.png");
});
return view;
+5
View File
@@ -1,5 +1,6 @@
plugins {
id 'com.android.library'
id 'com.google.dagger.hilt.android'
}
android {
@@ -46,5 +47,9 @@ dependencies {
implementation project(':shared:ui')
implementation project(':model')
implementation project(':data')
}
@@ -10,12 +10,18 @@ import androidx.recyclerview.widget.RecyclerView;
import java.util.List;
import one.nem.lacerta.model.document.DocumentMeta;
public class DocumentAdapter extends RecyclerView.Adapter<DocumentAdapter.DocumentViewHolder> {
private List<String> documentList;
private List<DocumentMeta> documentMetas;
public DocumentAdapter(List<String> documentList) {
this.documentList = documentList;
public DocumentAdapter(List<DocumentMeta> documentMetas) {
// nullの場合に例外を発生させる
if (documentMetas == null) {
throw new IllegalArgumentException("DocumentMetas list cannot be null or empty");
}
this.documentMetas = documentMetas;
}
@NonNull
@@ -27,12 +33,15 @@ public class DocumentAdapter extends RecyclerView.Adapter<DocumentAdapter.Docume
@Override
public void onBindViewHolder(@NonNull DocumentViewHolder holder, int position) {
holder.title.setText(documentList.get(position));
DocumentMeta documentMeta = documentMetas.get(position);
if (documentMeta != null) {
holder.title.setText(documentMeta.getTitle());
}
}
@Override
public int getItemCount() {
return documentList.size();
return documentMetas.size();
}
class DocumentViewHolder extends RecyclerView.ViewHolder {
@@ -40,7 +49,7 @@ public class DocumentAdapter extends RecyclerView.Adapter<DocumentAdapter.Docume
DocumentViewHolder(View itemView) {
super(itemView);
title = itemView.findViewById(R.id.debug_menu_item_title);
title = itemView.findViewById(R.id.debug_menu_item_title); // 適切な id に変更する
}
}
}
}
@@ -8,6 +8,9 @@ import android.widget.TextView;
import androidx.appcompat.app.AppCompatActivity;
// LibraryArchiveFragment.java
//画面変移用のコード
//Fragmentへのデータの受け渡し機能
public class LibraryArchiveFragment extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -8,6 +8,7 @@ import android.widget.TextView;
import androidx.fragment.app.Fragment;
//Fragmentにデータを受け渡す機能
public class LibraryDocFragment extends Fragment {
private TextView textView; // フィールドとして TextView を定義
@@ -13,17 +13,29 @@ import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
import java.util.ArrayList;
import java.util.List;
import javax.inject.Inject;
import dagger.hilt.android.AndroidEntryPoint;
import one.nem.lacerta.data.Document;
import one.nem.lacerta.model.document.DocumentMeta;
import one.nem.lacerta.model.document.tag.DocumentTag;
/**
* A simple {@link Fragment} subclass.
* Use the {@link LibraryTopFragment#newInstance} factory method to
* create an instance of this fragment.
*/
@AndroidEntryPoint
public class LibraryTopFragment extends Fragment {
@Inject
Document document;
// TODO: Rename parameter arguments, choose names that match
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
private static final String ARG_PARAM1 = "param1";
@@ -76,13 +88,14 @@ public class LibraryTopFragment extends Fragment {
LinearLayoutManager layoutManager = new LinearLayoutManager(getContext());
documentRecyclerView.setLayoutManager(layoutManager);
List<String> documentList = new ArrayList<>();
documentList.add("Document A");
documentList.add("Document B");
documentList.add("Document C");
//データを取得
List<DocumentMeta> metas = document.getAllDocumentMetas(100);
Toast.makeText(getContext(), "Documents: " + Integer.toString(metas.size()), Toast.LENGTH_LONG).show();
// Create and set the adapter
DocumentAdapter adapter = new DocumentAdapter(documentList);
DocumentAdapter adapter = new DocumentAdapter(metas);
documentRecyclerView.setAdapter(adapter);
// Use a LinearLayoutManager to specify the layout
@@ -5,11 +5,11 @@ import android.graphics.Bitmap;
public interface DocumentProcessor {
// ページ操作
void addNewPageToLast(Bitmap bitmap);
void addNewPagesToLast(Bitmap[] bitmaps);
void addNewPageAfterIndex(Bitmap bitmap, int index);
void addNewPageBeforeIndex(Bitmap bitmap, int index);
void removePageAtIndex(int index);
void addNewPageToLast(Bitmap bitmap) throws Exception;
void addNewPagesToLast(Bitmap[] bitmaps) throws Exception;
void addNewPageAfterIndex(Bitmap bitmap, int index) throws Exception;
void addNewPageBeforeIndex(Bitmap bitmap, int index) throws Exception;
void removePageAtIndex(int index) throws Exception;
// 更新
void updatePageAtIndex(Bitmap bitmap, int index);
@@ -18,7 +18,7 @@ public interface DocumentProcessor {
Bitmap getPageAtIndex(int index);
int getPageCount();
void close();
void init();
void close() throws Exception;
void init() throws Exception; // TODO-rca: 例外処理
}
@@ -8,6 +8,7 @@ import java.util.UUID;
import dagger.assisted.Assisted;
import dagger.assisted.AssistedInject;
import one.nem.lacerta.model.document.internal.XmlMetaPageModel;
import one.nem.lacerta.processor.DocumentProcessor;
import one.nem.lacerta.model.document.DocumentDetail;
@@ -25,9 +26,12 @@ public class DocumentProcessorImpl implements DocumentProcessor{
// Magic Numbers
private static final String DEFAULT_SAVE_DIR = "raw";
// Variables
private final DocumentDetail documentDetail;
private XmlMetaModel xmlMetaModel;
private Path documentRootPath;
private FileManager fileManager;
// Injection
private final FileManagerFactory fileManagerFactory;
@@ -45,25 +49,24 @@ public class DocumentProcessorImpl implements DocumentProcessor{
}
@Override
public void init() {
public void init() throws Exception{
logger.debug("init", "called");
// Init Variables
this.documentRootPath = documentDetail.getPath().getFullPath();
this.documentRootPath = this.documentDetail.getPath().getFullPath();
logger.debug("init", "documentRootPath: " + this.documentRootPath);
FileManager fileManager = fileManagerFactory.create(this.documentRootPath); //Initialize FileManager
this.fileManager = fileManagerFactory.create(this.documentRootPath).enableAutoCreateParent(); //Initialize FileManager
FileManager initFileManager = this.fileManager.getNewInstance();
logger.debug("init", "fileManager created");
fileManager.autoCreateDir(this.documentRootPath);
// rawディレクトリInit
fileManager.autoCreateDir(DEFAULT_SAVE_DIR);
// xmlファイルの読み込み
if (fileManager.isExist("meta.xml")) {
if (initFileManager.isExist("meta.xml")) {
logger.debug("init", "meta.xml found");
try {
xmlMetaModel = xmlMetaParser.deserialize(fileManager.loadDocument("meta.xml"));
this.xmlMetaModel = xmlMetaParser.deserialize(this.fileManager.loadXml("meta.xml"));
logger.debug("init", "meta.xml parsed");
} catch (Exception e) {
logger.debug("init", "meta.xml parse failed");
logger.trace("init", e.getMessage());
@@ -72,14 +75,14 @@ public class DocumentProcessorImpl implements DocumentProcessor{
logger.debug("init", "meta.xml not found");
xmlMetaModel = new XmlMetaModel();
xmlMetaModel.setTitle(documentDetail.getMeta().getTitle());
xmlMetaModel.setAuthor(documentDetail.getAuthor());
xmlMetaModel.setTitle(this.documentDetail.getMeta().getTitle());
xmlMetaModel.setAuthor(this.documentDetail.getAuthor());
xmlMetaModel.setDescription(""); // FIXME-rca:
xmlMetaModel.setDefaultBranch(documentDetail.getDefaultBranch());
xmlMetaModel.setDefaultBranch(this.documentDetail.getDefaultBranch());
xmlMetaModel.setPages(new ArrayList<>());
try {
fileManager.saveDocument(xmlMetaParser.serialize(xmlMetaModel), "meta.xml");
initFileManager.createFileIfNotExist("meta.xml").saveXml(xmlMetaParser.serialize(xmlMetaModel), "meta.xml");
logger.debug("init", "meta.xml saved");
} catch (Exception e) {
logger.error("init", "meta.xml save failed");
@@ -91,38 +94,69 @@ public class DocumentProcessorImpl implements DocumentProcessor{
}
@Override
public void addNewPageToLast(Bitmap bitmap) {
public void addNewPageToLast(Bitmap bitmap) throws Exception{
logger.debug("addNewPageToLast", "called");
String fileName = String.format(UUID.randomUUID().toString() + ".png"); // TODO-rca: 対応表をもたせる
logger.debug("addNewPageToLast", "fileName: " + fileName);
FileManager fileManager = fileManagerFactory.create(this.documentRootPath);
if(fileManager.getList().contains(this.documentRootPath.resolve(DEFAULT_SAVE_DIR))) {
logger.debug("addNewPageToLast", "raw dir found");
fileManager.changeDir(DEFAULT_SAVE_DIR);
} else {
logger.debug("addNewPageToLast", "raw dir not found");
fileManager.createDir(DEFAULT_SAVE_DIR);
fileManager.changeDir(DEFAULT_SAVE_DIR);
}
fileManager.saveBitmapAtCurrent(bitmap, fileName);
String filename = UUID.randomUUID().toString() + ".png"; // TODO-rca: 拡張子を動的にする
this.fileManager.getNewInstance().createDirectoryIfNotExist(DEFAULT_SAVE_DIR).resolve(DEFAULT_SAVE_DIR).saveBitmap(bitmap, filename);
XmlMetaPageModel xmlMetaPageModel = new XmlMetaPageModel();
xmlMetaPageModel.setFilename(filename);
xmlMetaPageModel.setIndex(xmlMetaModel.getPages().size() + 1);
xmlMetaModel.getPages().add(xmlMetaPageModel);
logger.info("addNewPageToLast", "finished");
logger.info("addNewPageToLast", "filename: " + filename + ", index: " + xmlMetaPageModel.getIndex());
}
@Override
public void addNewPagesToLast(Bitmap[] bitmaps) {
logger.debug("addNewPagesToLast(List)", "called");
for(Bitmap bitmap : bitmaps) {
public void addNewPagesToLast(Bitmap[] bitmaps) throws Exception{
logger.debug("addNewPagesToLast", "called");
for (Bitmap bitmap : bitmaps) {
addNewPageToLast(bitmap);
} // TODO-rca: 保存処理をまとめて行う?
} // TODO-rca: 効率悪いので改善する
}
// Internal
// Indexを振り直す
private ArrayList<XmlMetaPageModel> reIndexPages(ArrayList<XmlMetaPageModel> pages) {
logger.debug("reIndexPages", "called"); // TODO-rca: 効率化
ArrayList<XmlMetaPageModel> newPages = new ArrayList<>();
for (int i = 0; i < pages.size(); i++) {
XmlMetaPageModel xmlMetaPageModel = pages.get(i);
xmlMetaPageModel.setIndex(i + 1);
newPages.add(xmlMetaPageModel);
}
return newPages;
}
@Override
public void addNewPageAfterIndex(Bitmap bitmap, int index) {
public void addNewPageAfterIndex(Bitmap bitmap, int index) throws Exception {
logger.debug("addNewPageAfterIndex", "called");
String filename = UUID.randomUUID().toString() + ".png"; // TODO-rca: 拡張子を動的にする
this.fileManager.getNewInstance().createDirectoryIfNotExist(DEFAULT_SAVE_DIR).resolve(DEFAULT_SAVE_DIR).saveBitmap(bitmap, filename);
XmlMetaPageModel xmlMetaPageModel = new XmlMetaPageModel();
xmlMetaPageModel.setFilename(filename);
xmlMetaPageModel.setIndex(index + 1);
xmlMetaModel.getPages().add(index, xmlMetaPageModel);
xmlMetaModel.setPages(reIndexPages(xmlMetaModel.getPages()));
}
@Override
public void addNewPageBeforeIndex(Bitmap bitmap, int index) {
public void addNewPageBeforeIndex(Bitmap bitmap, int index) throws Exception {
logger.debug("addNewPageBeforeIndex", "called");
String filename = UUID.randomUUID().toString() + ".png"; // TODO-rca: 拡張子を動的にする
this.fileManager.getNewInstance().createDirectoryIfNotExist(DEFAULT_SAVE_DIR).resolve(DEFAULT_SAVE_DIR).saveBitmap(bitmap, filename);
XmlMetaPageModel xmlMetaPageModel = new XmlMetaPageModel();
xmlMetaPageModel.setFilename(filename);
xmlMetaPageModel.setIndex(index);
xmlMetaModel.getPages().add(index - 1, xmlMetaPageModel);
xmlMetaModel.setPages(reIndexPages(xmlMetaModel.getPages()));
}
@Override
@@ -146,7 +180,14 @@ public class DocumentProcessorImpl implements DocumentProcessor{
}
@Override
public void close() {
public void close() throws Exception{
logger.debug("close", "called");
try {
this.fileManager.getNewInstance().createFileIfNotExist("meta.xml").saveXml(xmlMetaParser.serialize(xmlMetaModel), "meta.xml");
logger.debug("close", "meta.xml saved");
} catch (Exception e) {
logger.error("close", "meta.xml save failed");
logger.trace("close", e.getMessage());
}
}
}
@@ -5,6 +5,8 @@ import android.graphics.Bitmap;
import org.w3c.dom.Document;
import java.io.File;
import java.io.IOException;
import java.lang.reflect.Field;
import java.nio.file.Path;
import java.util.List;
@@ -12,46 +14,52 @@ import java.util.List;
/** @noinspection unused*/
public interface FileManager {
Path getRootDir();
void changeDir(String dirName); //cd
void changeDir(Path path); //cd
void backDir(); //cd ..
void backRootDir(); //cd /
List<Path> getList();
void createDir(String dirName);
void createDir(Path path);
void removeDir(String dirName);
void removeDir(Path path);
File getFileRef();
boolean isExist(String name) throws IOException;
boolean isExist();
boolean isDirectory();
boolean isFile();
boolean isWritable();
boolean isReadable();
// Get current instance
FileManager getCurrentInstance();
FileManager getNewInstance();
File createFile(String fileName);
void removeFile(String fileName);
// Configure
FileManager enableAutoCreateParent();
FileManager disableRootDirCheck();
File getFile(String fileName);
File getFile(Path path);
FileManager setRootDir(Path rootDir);
FileManager setPath(Path path);
FileManager resolve(String path) throws IOException;
String loadText(String fileName);
String loadText(Path path);
// Create
FileManager createFile() throws IOException;
FileManager createFile(String fileName) throws IOException;
FileManager createFileIfNotExist() throws IOException;
FileManager createFileIfNotExist(String fileName) throws IOException;
FileManager createDirectory() throws IOException;
FileManager createDirectory(String directoryName) throws IOException;
FileManager createDirectoryIfNotExist() throws IOException;
FileManager createDirectoryIfNotExist(String directoryName) throws IOException;
void saveText(String text, String fileName);
void saveText(String text, Path path);
// Save
// XML
void saveXml(Document document, String fileName) throws IOException;
void saveXml(Document document) throws IOException;
void saveDocument(Document document, String fileName);
void saveDocument(Document document, Path path);
Document loadDocument(String fileName);
Document loadDocument(Path path);
// Bitmap
void saveBitmap(Bitmap bitmap, String fileName) throws IOException; // TODO-rca: パラメータに対応させる
void saveBitmap(Bitmap bitmap) throws IOException; // TODO-rca: パラメータに対応させる
boolean isExist(Path path);
boolean isExist(String fileName);
// Load
// XML
Document loadXml(String fileName) throws IOException;
Document loadXml() throws IOException;
void autoCreateDir(Path path);
void autoCreateDir(String dirName);
void autoCreateToCurrentDir();
void saveBitmapAtCurrent(Bitmap bitmap, String fileName);
Bitmap loadBitmap(Path path);
void removeBitmap(Path path);
// Bitmap
Bitmap loadBitmap(String fileName) throws IOException;
Bitmap loadBitmap() throws IOException;
}
@@ -1,17 +1,14 @@
package one.nem.lacerta.source.file.impl;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import org.w3c.dom.Document;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.nio.file.DirectoryStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
@@ -28,315 +25,340 @@ import one.nem.lacerta.utils.LacertaLogger;
public class FileManagerImpl implements FileManager {
// RootDir
// variables
private Path rootDir;
private Path path;
private boolean autoCreateParent = false;
private boolean disableRootDirCheck = false;
// CurrentDir
private Path currentDir;
// Internal Methods
private Path convertPath(String path) {
Path convertedPath = currentDir.resolve(path);
if (convertedPath.startsWith(rootDir)) { // 異常なパスの場合はnullを返す // TODO-rca: エラーハンドリング
return convertedPath;
// Injection
private final LacertaLogger logger;
@AssistedInject
public FileManagerImpl(LacertaLogger logger, @Assisted Path rootDir) {
this.logger = logger;
this.rootDir = rootDir;
}
// for generate new instance
public FileManagerImpl(LacertaLogger logger, Path rootDir, Path path, boolean autoCreateParent, boolean disableRootDirCheck) {
this.logger = logger;
this.rootDir = rootDir;
this.path = path;
this.autoCreateParent = autoCreateParent;
this.disableRootDirCheck = disableRootDirCheck;
}
// Internal
private Path resolveStringPath(String path) throws IOException{
String[] pathArray = path.split("/");
Path resolvedPath = this.path;
for (String pathPart : pathArray) {
if (pathPart.equals("..")) {
resolvedPath = resolvedPath.getParent();
continue;
}
try {
resolvedPath = resolvedPath.resolve(pathPart);
} catch (Exception e) {
throw new IOException("Invalid path: " + path);
}
}
logger.debug("resolveStringPath", "resolvedPath: " + resolvedPath);
return resolvedPath;
}
private FileManager newInstance(Path rootDir, Path path, boolean autoCreateParent, boolean disableRootDirCheck) {
logger.debug("newInstance", "Generating new instance");
logger.debug("newInstance", "Path: " + path);
return new FileManagerImpl(this.logger, rootDir, path, autoCreateParent, disableRootDirCheck);
}
@Override
public File getFileRef() {
if (this.isExist()) {
return this.path.toFile();
} else {
return null;
}
}
// Injection
private LacertaLogger logger;
@AssistedInject
public FileManagerImpl(LacertaLogger logger, @Assisted Path rootDir) {
this.logger = logger;
this.rootDir = rootDir;
this.currentDir = rootDir;
@Override
public boolean isExist(String name) throws IOException {
Path resolvedPath = this.resolveStringPath(name);
return Files.exists(resolvedPath);
}
@Override
public Path getRootDir() {
return rootDir;
public boolean isExist(){
return Files.exists(this.path);
}
@Override
public void changeDir(String dirName) {
this.currentDir = rootDir.resolve(dirName);
}
@Override
public void changeDir(Path path) {
if (path.startsWith(rootDir)) {
this.currentDir = path;
}
else {
logger.debug("changeDir", "invalid path: " + path);
// TODO-rca: 例外を投げる
public boolean isDirectory() {
if (this.isExist()) {
File file = this.path.toFile();
return file.isDirectory();
} else {
return false;
}
}
@Override
public void backDir() {
this.currentDir = currentDir.getParent();
public boolean isFile() {
if (this.isExist()) {
File file = this.path.toFile();
return file.isFile();
} else {
return false;
}
}
@Override
public void backRootDir() {
this.currentDir = rootDir;
public boolean isReadable() {
if (this.isExist()) {
File file = this.path.toFile();
return file.canRead();
} else {
return false;
}
}
@Override
public List<Path> getList() {
List<Path> list = new ArrayList<>();
try (DirectoryStream<Path> stream = Files.newDirectoryStream(currentDir)) {
for (Path entry : stream) { // TODO-rca: エラーハンドリング, 効率化
list.add(entry);
public boolean isWritable() {
if (this.isExist()) {
File file = this.path.toFile();
return file.canWrite();
} else {
return false;
}
}
@Override
public FileManager getCurrentInstance() {
return this;
}
@Override
public FileManager getNewInstance() {
return this.newInstance(this.rootDir, this.rootDir, this.autoCreateParent, this.disableRootDirCheck);
}
@Override
public FileManager enableAutoCreateParent() {
this.autoCreateParent = true;
return this;
}
@Override
public FileManager disableRootDirCheck() {
this.disableRootDirCheck = true;
return this;
}
@Override
public FileManager setRootDir(Path rootDir) {
return this.newInstance(rootDir, this.path, this.autoCreateParent, this.disableRootDirCheck);
}
@Override
public FileManager setPath(Path path) {
Path resolvedPath;
if (this.disableRootDirCheck) {
resolvedPath = path;
} else {
if (path.startsWith(this.rootDir)) {
resolvedPath = path;
} else {
throw new IllegalArgumentException("path must be in rootDir");
}
} catch (IOException e) {
e.printStackTrace();
}
return list;
logger.debug("setPath", "resolvedPath: " + resolvedPath);
return this.newInstance(this.rootDir, resolvedPath, this.autoCreateParent, this.disableRootDirCheck);
}
@Override
public void createDir(String dirName) {
//ディレクトリ作成
logger.debug("createDir", "called");
Path path = currentDir.resolve(dirName);
logger.debug("createDir", "path: " + path);
public FileManager resolve(String path) throws IOException{
Path resolvedPath;
try {
Files.createDirectory(path);
resolvedPath = resolveStringPath(path);
} catch (IOException e) {
e.printStackTrace();
logger.error("resolve", e.getMessage());
throw new IOException("Invalid path: " + path);
}
return this.setPath(resolvedPath);
}
@Override
public void createDir(Path path) {
logger.debug("createDir", "called");
// Internal
private void createFileInternal(Path path) throws IOException {
try {
if (this.autoCreateParent) {
if (!path.getParent().toFile().exists()) {
Files.createDirectories(path.getParent());
}
}
Files.createFile(path);
} catch (Exception e) {
logger.error("createFileInternal", e.getMessage());
throw new IOException("Failed to create file");
}
}
@Override
public FileManager createFile() throws IOException {
this.createFileInternal(this.path);
return this;
}
@Override
public FileManager createFile(String fileName) throws IOException { // pathが書き換わってしまうのは想像できない挙動かも?
this.createFileInternal(this.resolveStringPath(fileName));
return this;
}
@Override
public FileManager createFileIfNotExist() throws IOException {
if (!this.isExist()) {
this.createFile();
}
return this;
}
@Override
public FileManager createFileIfNotExist(String fileName) throws IOException {
if (!this.isExist(fileName)) {
this.createFile(fileName);
}
return this;
}
// Internal
private void createDirectoryInternal(Path path) throws IOException {
try {
if (this.autoCreateParent) {
if (!path.getParent().toFile().exists()) {
Files.createDirectories(path.getParent());
}
}
Files.createDirectory(path);
} catch (IOException e) {
e.printStackTrace();
} catch (Exception e) {
logger.error("createDirectoryInternal", e.getMessage());
throw new IOException("Failed to create directory");
}
}
@Override
public void removeDir(String dirName) {
logger.debug("removeDir", "called");
currentDir.resolve(dirName).toFile().delete(); // TODO-rca: エラーハンドリング
public FileManager createDirectory() throws IOException {
this.createDirectoryInternal(this.path);
return this;
}
@Override
public void removeDir(Path path) {
logger.debug("removeDir", "called");
path.toFile().delete(); // TODO-rca: エラーハンドリング
}
@Override
public File createFile(String fileName) {
logger.debug("createFile", "called");
return currentDir.resolve(fileName).toFile();
public FileManager createDirectory(String directoryName) throws IOException {
this.createDirectoryInternal(this.resolveStringPath(directoryName));
return this;
}
@Override
public void removeFile(String fileName) {
logger.debug("removeFile", "called");
currentDir.resolve(fileName).toFile().delete(); // TODO-rca: エラーハンドリング
}
@Override
public File getFile(String fileName) {
logger.debug("getFile", "called");
return currentDir.resolve(fileName).toFile();
}
@Override
public File getFile(Path path) {
logger.debug("getFile", "called");
return path.toFile();
}
@Override
public String loadText(String fileName) { // TODO-rca: 統合
try(FileInputStream fileInputStream = new FileInputStream(currentDir.resolve(fileName).toFile())) {
byte[] bytes = new byte[fileInputStream.available()];
fileInputStream.read(bytes); // TODO-rca: エラーハンドリング
return new String(bytes);
} catch (IOException e) {
e.printStackTrace();
return null;
public FileManager createDirectoryIfNotExist() throws IOException {
if (!this.isExist()) {
this.createDirectory();
}
return this;
}
@Override
public String loadText(Path path) {
try(FileInputStream fileInputStream = new FileInputStream(path.toFile())) {
byte[] bytes = new byte[fileInputStream.available()];
fileInputStream.read(bytes); // TODO-rca: エラーハンドリング
return new String(bytes);
} catch (IOException e) {
e.printStackTrace();
return null;
public FileManager createDirectoryIfNotExist(String directoryName) throws IOException {
if (!this.isExist(directoryName)) {
this.createDirectory(directoryName);
}
return this;
}
@Override
public void saveText(String text, String fileName) { // TODO-rca: リファクタリング // TODO-rca: 統合
if (isExist(fileName)) {
logger.debug("saveText", "file already exists");
// Overwrite
try {
Files.write(currentDir.resolve(fileName), text.getBytes());
} catch (IOException e) {
e.printStackTrace();
}
}
else {
try {
Files.createFile(currentDir.resolve(fileName));
Files.write(currentDir.resolve(fileName), text.getBytes());
} catch (IOException e) {
e.printStackTrace();
}
}
}
@Override
public void saveText(String text, Path path) {
if (isExist(path)) {
logger.debug("saveText", "file already exists");
// Overwrite
try {
Files.write(path, text.getBytes());
} catch (IOException e) {
e.printStackTrace();
}
}
else {
try {
Files.createFile(path);
Files.write(path, text.getBytes());
} catch (IOException e) {
e.printStackTrace();
}
}
}
@Override
public void saveDocument(Document document, String fileName) {
// Internal
private void saveXmlInternal(Document document, Path path) throws IOException {
try {
TransformerFactory transformerFactory = TransformerFactory.newInstance();
Transformer transformer = transformerFactory.newTransformer();
DOMSource source = new DOMSource(document);
File file = createFile(fileName);
StreamResult result = new StreamResult(file);
StreamResult result = new StreamResult(path.toFile());
transformer.transform(source, result);
} catch (Exception e) {
logger.error("saveXmlInternal", e.getMessage());
e.printStackTrace();
throw new IOException("Failed to save xml");
}
}
private void saveBitmapInternal(Bitmap bitmap, Path path) throws IOException {
try {
logger.debug("saveBitmapInternal", "path: " + path);
bitmap.compress(Bitmap.CompressFormat.PNG, 100, Files.newOutputStream(path));
} catch (Exception e) {
logger.error("saveBitmapInternal", e.getMessage());
throw new IOException("Failed to save bitmap");
}
}
@Override
public void saveDocument(Document document, Path path) {
// TODO-rca 実装する
public void saveXml(Document document, String fileName) throws IOException {
this.saveXmlInternal(document, this.resolveStringPath(fileName));
}
@Override
public Document loadDocument(String fileName) {
public void saveXml(Document document) throws IOException {
this.saveXmlInternal(document, this.path);
}
@Override
public void saveBitmap(Bitmap bitmap, String fileName) throws IOException {
this.saveBitmapInternal(bitmap, this.resolveStringPath(fileName));
}
@Override
public void saveBitmap(Bitmap bitmap) throws IOException {
this.saveBitmapInternal(bitmap, this.path);
}
// Internal
private Document loadXmlInternal(Path path) throws IOException {
try {
File file = getFile(fileName);
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
Document document = builder.parse(file);
return document;
return builder.parse(Files.newInputStream(path));
} catch (Exception e) {
e.printStackTrace();
return null;
logger.error("loadXmlInternal", e.getMessage());
throw new IOException("Failed to load xml");
}
}
@Override
public Document loadDocument(Path path) {
// TODO-rca 実装する
return null;
}
@Override
public boolean isExist(Path path) {
logger.debug("isExist", "called");
return Files.exists(path);
}
@Override
public boolean isExist(String fileName) {
logger.debug("isExist", "called");
return Files.exists(currentDir.resolve(fileName));
}
@Override
public void autoCreateDir(Path path) {
logger.debug("autoCreateDir", "called");
if (!Files.exists(path)) {
try {
Files.createDirectories(path);
} catch (IOException e) {
e.printStackTrace();
}
}
}
@Override
public void autoCreateDir(String dirName) {
logger.debug("autoCreateDir", "called");
if (!Files.exists(currentDir.resolve(dirName))) {
try {
Files.createDirectories(currentDir.resolve(dirName));
} catch (IOException e) {
e.printStackTrace();
}
}
}
@Override
public void autoCreateToCurrentDir() {
logger.debug("autoGenerateToCurrentDir", "called");
if (isExist(currentDir)) {
logger.debug("autoGenerateToCurrentDir", "currentDir already exists");
return;
}
else {
try {
Files.createDirectories(currentDir);
} catch (IOException e) {
e.printStackTrace();
}
}
}
@Override
public void saveBitmapAtCurrent(Bitmap bitmap, String fileName) { // TODO-rca: ファイル形式を変更できるようにする?
logger.debug("saveBitmapAtCurrent", "called");
private Bitmap loadBitmapInternal(Path path) throws IOException {
try {
File file = currentDir.resolve(fileName).toFile();
bitmap.compress(Bitmap.CompressFormat.PNG, 100, Files.newOutputStream(file.toPath()));
} catch (IOException e) {
e.printStackTrace();
return BitmapFactory.decodeFile(path.toString());
} catch (Exception e) {
logger.error("loadBitmapInternal", e.getMessage());
throw new IOException("Failed to load bitmap");
}
}
@Override
public Bitmap loadBitmap(Path path) {
return null;
public Document loadXml(String fileName) throws IOException {
return this.loadXmlInternal(this.resolveStringPath(fileName));
}
@Override
public void removeBitmap(Path path) {
public Document loadXml() throws IOException {
return this.loadXmlInternal(this.path);
}
@Override
public Bitmap loadBitmap(String fileName) throws IOException {
return this.loadBitmapInternal(this.resolveStringPath(fileName));
}
@Override
public Bitmap loadBitmap() throws IOException {
return this.loadBitmapInternal(this.path);
}
}