Skip to content

Commit

Permalink
Fixed edited-new-page-disappearing bug.
Browse files Browse the repository at this point in the history
Tmp. patched adding image to new page bug.
  • Loading branch information
aiman-al-masoud committed Aug 3, 2021
1 parent e4a554c commit 5ddf4d6
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -342,11 +342,25 @@ public void setSelected(boolean selected) {
@Override
public void addImage(String path, int position) {

//prepare a new file in this Page's imgDir
File imageCopy = new File(imageDir.getPath()+File.separator+System.currentTimeMillis());

//copy provided image to this Page's imgDir
FileIO.copyFile(path, imageCopy.getPath());

//get this page's raw html code
String text = getText();

String openImgTag = "<img src=\'";
String closeImgTag = "\' />";

//if current length of the html code is 0, add the image at position 0.
if(text.length()==0){
text+=openImgTag+imageCopy.getPath()+closeImgTag;
setText(text);
return;
}

String partBefore = text.substring(0, position);
String partAfter = text.substring(position, text.length()-1);
String tag = "<img src=\'"+imageCopy.getPath()+"\' />";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -372,17 +372,19 @@ public void onBackPressed() {
@Override
public void onCreated(Page page) {

//run on ui thread if onCreated gets called from a different thread.
runOnUiThread(new Runnable() {
@Override
public void run() {
//if in foreground simply add page
if(isInForeground()){
//if in foreground, just add the page fragment.
if(isInForeground()) {

//run on ui thread if onCreated gets called from a different thread.
runOnUiThread(new Runnable() {
@Override
public void run() {
addPage(page, true);
return;
}
}
});
});

return;
}


//else you're in background, stash in changes
Expand Down

0 comments on commit 5ddf4d6

Please sign in to comment.