-
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.
- Loading branch information
1 parent
aaf66ae
commit ecd0435
Showing
6 changed files
with
115 additions
and
9 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
44 changes: 44 additions & 0 deletions
44
app/src/main/java/com/javiersantos/mlmanager/async/UninstallInBackground.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,44 @@ | ||
package com.javiersantos.mlmanager.async; | ||
|
||
import android.app.Activity; | ||
import android.content.Context; | ||
import android.content.Intent; | ||
import android.os.AsyncTask; | ||
|
||
import com.afollestad.materialdialogs.MaterialDialog; | ||
import com.javiersantos.mlmanager.AppInfo; | ||
import com.javiersantos.mlmanager.R; | ||
import com.javiersantos.mlmanager.activities.MainActivity; | ||
import com.javiersantos.mlmanager.utils.UtilsDialog; | ||
import com.javiersantos.mlmanager.utils.UtilsRoot; | ||
|
||
public class UninstallInBackground extends AsyncTask<Void, String, Boolean> { | ||
private Context context; | ||
private Activity activity; | ||
private MaterialDialog dialog; | ||
private AppInfo appInfo; | ||
|
||
public UninstallInBackground(Context context, MaterialDialog dialog, AppInfo appInfo) { | ||
this.context = context; | ||
this.activity = (Activity) context; | ||
this.dialog = dialog; | ||
this.appInfo = appInfo; | ||
} | ||
|
||
@Override | ||
protected Boolean doInBackground(Void... voids) { | ||
return UtilsRoot.uninstallWithRootPermission(appInfo.getSource()); | ||
} | ||
|
||
@Override | ||
protected void onPostExecute(Boolean status) { | ||
super.onPostExecute(status); | ||
dialog.dismiss(); | ||
if (status) { | ||
activity.finish(); | ||
context.startActivity(new Intent(context, MainActivity.class)); | ||
} else { | ||
UtilsDialog.showTitleContent(context, context.getResources().getString(R.string.dialog_root_required), context.getResources().getString(R.string.dialog_root_required_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
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