aboutsummaryrefslogtreecommitdiff
path: root/src/org/slcl/Main.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/org/slcl/Main.java')
-rw-r--r--src/org/slcl/Main.java65
1 files changed, 20 insertions, 45 deletions
diff --git a/src/org/slcl/Main.java b/src/org/slcl/Main.java
index 8ac8c55..34a3b92 100644
--- a/src/org/slcl/Main.java
+++ b/src/org/slcl/Main.java
@@ -35,59 +35,34 @@ public final class Main extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState)
{
- final LoadTask t = new LoadTask();
-
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
- t.execute();
- }
-
- private final class LoadTask extends AsyncTask<String, String, Cookie>
- {
- ProgressDialog dialog;
-
- @Override
- protected void onPreExecute()
- {
- dialog = dialog.show(Main.this, "ProgressDialog",
- "Retrieving credentials");
- }
-
- @Override
- protected Cookie doInBackground(final String... args)
- {
- try {
- final InternalFile f = new InternalFile(
- getApplicationContext(), "login");
- final Cookie c = new Cookie(f.getFile());
- return c;
- } catch (final IOException e) {
- System.out.println(e.getMessage());
- return null;
- }
- }
+ final Cookie c = getLogin();
+ final Intent intent;
- @Override
- protected void onProgressUpdate(final String... params)
- {
+ if (c == null) {
+ intent = new Intent(Main.this, LoginActivity.class);
+ } else {
+ intent = new Intent(Main.this, Directory.class);
+ // TODO: split cookie with ';' (expiration date, etc.).
+ intent.putExtra(Directory.EXTRA_ID, c.getCookie());
}
- @Override
- protected void onPostExecute(final Cookie cookie)
- {
- final Intent intent;
+ startActivity(intent);
+ }
- if (cookie == null) {
- intent = new Intent(Main.this, LoginActivity.class);
- } else {
- intent = new Intent(Main.this, Directory.class);
- // TODO: split cookie with ';' (expiration date, etc.).
- intent.putExtra(Directory.EXTRA_ID, cookie.getCookie());
- }
+ private Cookie getLogin()
+ {
+ try {
+ final Context context = getApplicationContext();
+ final InternalFile f = new InternalFile(context, "login");
+ final Cookie cookie = new Cookie(f.getFile());
- dialog.dismiss();
- startActivity(intent);
+ return cookie;
+ } catch (final IOException e) {
+ System.out.println(e.getMessage());
+ return null;
}
}
}