-
Notifications
You must be signed in to change notification settings - Fork 393
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
More asynchronous, add Snackbar and optimizations
- Loading branch information
1 parent
6add0cc
commit c5d433c
Showing
9 changed files
with
183 additions
and
155 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
app/src/main/java/com/javiersantos/mlmanager/async/DeleteDataInBackground.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package com.javiersantos.mlmanager.async; | ||
|
||
import android.content.Context; | ||
import android.os.AsyncTask; | ||
|
||
import com.afollestad.materialdialogs.MaterialDialog; | ||
import com.javiersantos.mlmanager.R; | ||
import com.javiersantos.mlmanager.utils.UtilsDialog; | ||
import com.javiersantos.mlmanager.utils.UtilsRoot; | ||
|
||
public class DeleteDataInBackground extends AsyncTask<Void, String, Boolean> { | ||
private Context context; | ||
private MaterialDialog dialog; | ||
private String directory; | ||
private String successTitle; | ||
private String successDescription; | ||
|
||
public DeleteDataInBackground(Context context, MaterialDialog dialog, String directory, String successTitle, String successDescription) { | ||
this.context = context; | ||
this.dialog = dialog; | ||
this.directory = directory; | ||
this.successTitle = successTitle; | ||
this.successDescription = successDescription; | ||
} | ||
|
||
@Override | ||
protected Boolean doInBackground(Void... voids) { | ||
boolean status = UtilsRoot.removeWithRootPermission(directory); | ||
return status; | ||
} | ||
|
||
@Override | ||
protected void onPostExecute(Boolean status) { | ||
super.onPostExecute(status); | ||
dialog.dismiss(); | ||
if (status) { | ||
UtilsDialog.showTitleContent(context, successTitle, successDescription); | ||
} else { | ||
UtilsDialog.showTitleContent(context, context.getResources().getString(R.string.dialog_cache_and_data_error), context.getResources().getString(R.string.dialog_cache_and_data_error_description)); | ||
} | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
app/src/main/java/com/javiersantos/mlmanager/async/ExtractFileInBackground.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package com.javiersantos.mlmanager.async; | ||
|
||
import android.app.Activity; | ||
import android.content.Context; | ||
import android.os.AsyncTask; | ||
|
||
import com.afollestad.materialdialogs.MaterialDialog; | ||
import com.javiersantos.mlmanager.AppInfo; | ||
import com.javiersantos.mlmanager.R; | ||
import com.javiersantos.mlmanager.utils.UtilsApp; | ||
import com.javiersantos.mlmanager.utils.UtilsDialog; | ||
|
||
public class ExtractFileInBackground extends AsyncTask<Void, String, Boolean> { | ||
private Context context; | ||
private Activity activity; | ||
private MaterialDialog dialog; | ||
private AppInfo appInfo; | ||
|
||
public ExtractFileInBackground(Activity activity, Context context, MaterialDialog dialog, AppInfo appInfo) { | ||
this.activity = activity; | ||
this.context = context; | ||
this.dialog = dialog; | ||
this.appInfo = appInfo; | ||
} | ||
|
||
@Override | ||
protected Boolean doInBackground(Void... voids) { | ||
Boolean status = UtilsApp.copyFile(appInfo); | ||
return status; | ||
} | ||
|
||
@Override | ||
protected void onPostExecute(Boolean status) { | ||
super.onPostExecute(status); | ||
dialog.dismiss(); | ||
if (status) { | ||
UtilsDialog.showExtractedSnackbar(activity, String.format(context.getResources().getString(R.string.dialog_saved_description), appInfo.getName(), UtilsApp.getAPKFilename(appInfo)), context.getResources().getString(R.string.button_undo), UtilsApp.getOutputFilename(appInfo)).show(); | ||
} else { | ||
UtilsDialog.showTitleContent(context, context.getResources().getString(R.string.dialog_extract_fail), context.getResources().getString(R.string.dialog_extract_fail_description)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.