Skip to content

Commit

Permalink
Add another way to start Mitobi
Browse files Browse the repository at this point in the history
  • Loading branch information
AozoraDev committed Nov 10, 2023
1 parent 89006b5 commit 53795ff
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/src/main/java/com/harubyte/mitobi/Configs.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ public class Configs {
public static final String NAME = "Mitobi";
public static final String VERSION = "1.0";
public static final String TITLE = String.format("%s (v%s)", NAME, VERSION);
public static final String ACTION = "com.harubyte.mitobi.action.MAIN";
}
7 changes: 7 additions & 0 deletions lib/src/main/java/com/harubyte/mitobi/Interface.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.harubyte.mitobi;

public class Interface {
public interface OnDialogClosed {
void onClose();
}
}
12 changes: 12 additions & 0 deletions lib/src/main/java/com/harubyte/mitobi/Mitobi.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
public class Mitobi {
private ExecutorService executor = Executors.newSingleThreadExecutor();

private Interface.OnDialogClosed callback;
private Context context;
private Handler handler;
private File data, externalData;
Expand Down Expand Up @@ -75,6 +76,7 @@ public void start(Boolean back) {
Log.i(Configs.NAME, "Handler and Executor terminated!");
}

if (callback != null) callback.onClose();
Log.i(Configs.NAME, "Terminated!");
})
.setCancelable(false)
Expand All @@ -91,6 +93,16 @@ public void kill() {
handler = null;
}

/*
* Set callback for closed dialog
*
* @param callback Callback
*/
public Mitobi setOnDialogClosed(Interface.OnDialogClosed callback) {
this.callback = callback;
return this;
}

/////////////
// Dialogs //
/////////////
Expand Down
20 changes: 20 additions & 0 deletions lib/src/main/java/com/harubyte/mitobi/MitobiActivity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.harubyte.mitobi;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;

public class MitobiActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(new View(this));

new Mitobi(this)
.setOnDialogClosed(() -> {
Intent intent = new Intent(Configs.ACTION);
startActivity(intent);
});
}
}

0 comments on commit 53795ff

Please sign in to comment.