Skip to content

Commit

Permalink
Merge pull request #5 from krishandroiddev/dev
Browse files Browse the repository at this point in the history
Delay in file saving when added new file
  • Loading branch information
SyntaxGalaxy authored Dec 12, 2023
2 parents f4f0b36 + d81b076 commit b44ad10
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ public void showSection(int section) {
}
}

public void saveFileList() {
public void saveFileList(TaskListener listener) {
Executor executor = Executors.newSingleThreadExecutor();
executor.execute(
() -> {
Expand All @@ -226,14 +226,17 @@ public void saveFileList() {
} catch (Exception e) {
}
}
if (listener != null) {
listener.onSuccess(null);
}
});
}

@Override
protected void onPause() {
super.onPause();
if (isLoaded) {
saveFileList();
saveFileList(null);
}
}

Expand All @@ -242,7 +245,13 @@ protected void onPause() {
public void onBackPressed() {
super.onBackPressed();
if (isLoaded) {
saveFileList();
saveFileList(
new TaskListener() {
@Override
public void onSuccess(Object result) {
finish();
}
});
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import com.dragon.ide.R;
import com.dragon.ide.databinding.LayoutFileListItemBinding;
import com.dragon.ide.listeners.ProjectBuildListener;
import com.dragon.ide.listeners.TaskListener;
import com.dragon.ide.objects.WebFile;
import com.dragon.ide.ui.activities.EventListActivity;
import com.dragon.ide.ui.activities.FileManagerActivity;
Expand Down Expand Up @@ -112,25 +113,37 @@ public void onBindViewHolder(ViewHolder _holder, int _position) {
.getAbsolutePath());
activity.startActivity(i);
} else {
Intent i = new Intent();
i.setClass(activity, EventListActivity.class);
i.putExtra("projectName", projectName);
i.putExtra("projectPath", projectPath);
i.putExtra("fileName", _data.get(_position).getFilePath());
i.putExtra("fileType", _data.get(_position).getFileType());
i.putExtra("webFile", filePathList.get(_position));
i.putExtra(
"fileOutputPath",
new File(
new File(((FileManagerActivity) activity).getOutputDirectory()),
_data
.get(_position)
.getFilePath()
.concat(
WebFile.getSupportedFileSuffix(
_data.get(_position).getFileType())))
.getAbsolutePath());
activity.startActivity(i);
((FileManagerActivity)activity).saveFileList(
new TaskListener() {

@Override
public void onSuccess(Object result) {
activity.runOnUiThread(
() -> {
Intent i = new Intent();
i.setClass(activity, EventListActivity.class);
i.putExtra("projectName", projectName);
i.putExtra("projectPath", projectPath);
i.putExtra("fileName", _data.get(_position).getFilePath());
i.putExtra("fileType", _data.get(_position).getFileType());
i.putExtra("webFile", filePathList.get(_position));
i.putExtra(
"fileOutputPath",
new File(
new File(
((FileManagerActivity) activity)
.getOutputDirectory()),
_data
.get(_position)
.getFilePath()
.concat(
WebFile.getSupportedFileSuffix(
_data.get(_position).getFileType())))
.getAbsolutePath());
activity.startActivity(i);
});
}
});
}
});
binding.execute.setOnClickListener(
Expand Down

0 comments on commit b44ad10

Please sign in to comment.