Skip to content

Commit

Permalink
Whitespace: tabs to spaces, as per Android guidelines
Browse files Browse the repository at this point in the history
  • Loading branch information
Chainfire committed Feb 5, 2014
1 parent 9104bab commit 185868f
Show file tree
Hide file tree
Showing 10 changed files with 1,807 additions and 1,807 deletions.
102 changes: 51 additions & 51 deletions libsuperuser/src/eu/chainfire/libsuperuser/Application.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,55 +25,55 @@
* toasts and AsyncTasks you are likely to run into
*/
public class Application extends android.app.Application {
/**
* Shows a toast message
*
* @param context Any context belonging to this application
* @param message The message to show
*/
public static void toast(Context context, String message) {
// this is a static method so it is easier to call,
// as the context checking and casting is done for you
if (context == null) return;
if (!(context instanceof Application)) {
context = context.getApplicationContext();
}
if (context instanceof Application) {
final Context c = context;
final String m = message;
((Application)context).runInApplicationThread(new Runnable() {
@Override
public void run() {
Toast.makeText(c, m, Toast.LENGTH_LONG).show();
}
});
}
}
private static Handler mApplicationHandler = new Handler();
/**
* Run a runnable in the main application thread
*
* @param r Runnable to run
*/
public void runInApplicationThread(Runnable r) {
mApplicationHandler.post(r);
}
@Override
public void onCreate() {
super.onCreate();
try {
// workaround bug in AsyncTask, can show up (for example) when you toast from a service
// this makes sure AsyncTask's internal handler is created from the right (main) thread
Class.forName("android.os.AsyncTask");
} catch (ClassNotFoundException e) {
}
}
/**
* Shows a toast message
*
* @param context Any context belonging to this application
* @param message The message to show
*/
public static void toast(Context context, String message) {
// this is a static method so it is easier to call,
// as the context checking and casting is done for you

if (context == null) return;

if (!(context instanceof Application)) {
context = context.getApplicationContext();
}

if (context instanceof Application) {
final Context c = context;
final String m = message;

((Application)context).runInApplicationThread(new Runnable() {
@Override
public void run() {
Toast.makeText(c, m, Toast.LENGTH_LONG).show();
}
});
}
}

private static Handler mApplicationHandler = new Handler();

/**
* Run a runnable in the main application thread
*
* @param r Runnable to run
*/
public void runInApplicationThread(Runnable r) {
mApplicationHandler.post(r);
}

@Override
public void onCreate() {
super.onCreate();

try {
// workaround bug in AsyncTask, can show up (for example) when you toast from a service
// this makes sure AsyncTask's internal handler is created from the right (main) thread
Class.forName("android.os.AsyncTask");
} catch (ClassNotFoundException e) {
}
}
}
Loading

0 comments on commit 185868f

Please sign in to comment.