Skip to content

Commit

Permalink
save current_file
Browse files Browse the repository at this point in the history
  • Loading branch information
PangBaiWork committed Feb 28, 2024
1 parent ae452f8 commit 9fee161
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
Binary file modified app/src/main/assets/libexec.so
Binary file not shown.
26 changes: 18 additions & 8 deletions app/src/main/java/com/pangbai/weblog/activity/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,22 @@ protected void onCreate(Bundle savedInstanceState) {
setLayout();
setRecycleView();
setTabLayout();
binding.editor.setText("No file be Displayed\n" + getString(R.string.how_to_open_terminal));

setEditor();
setNavigation();

String path = PrefManager.getString(PrefManager.Keys.current_file, "");
File file = new File(path);

if (file.exists()){
setCodeText(file);
currentFile=file;
filesListAdapter.setList(currentFile.getParentFile());

} else {
binding.editor.setText("No file be Displayed\n" + getString(R.string.how_to_open_terminal));

}
// setCodeText(new File(project.getProjectPath()));


Expand Down Expand Up @@ -158,6 +171,7 @@ void setCodeText(File file) {
try {
editorText = ContentIO.createFrom(new FileReader(file));
currentFile = file;
PrefManager.putString(PrefManager.Keys.current_file, currentFile.getAbsolutePath());
runOnUiThread(() -> {
binding.editor.setText(editorText, true, null);
if (IO.isMdFile(currentFile)) markdown.loadMarkdownFromFile(currentFile);
Expand All @@ -181,8 +195,8 @@ void setLayout() {


/// SearchHandle search= (SearchHandle) ((MenuItem) binding.toolbar.findViewById(R.id.menu_search)).getActionView();
handle= new SearchHandle(binding.editor.getSearcher());
handle.bind(binding.searchBar);
handle = new SearchHandle(binding.editor.getSearcher());
handle.bind(binding.searchBar);

binding.toolbar.setOnMenuItemClickListener(item -> {

Expand Down Expand Up @@ -440,9 +454,5 @@ void checkProcess(MenuItem item) {

}

@Override
protected void onDestroy() {
binding.editor.release();
super.onDestroy();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public enum Keys {
tags,
category,
current_project,
current_file,
first_launch,
bl_interface_undo_button_display,
bl_artical_title_to_md5
Expand Down

0 comments on commit 9fee161

Please sign in to comment.