Initial commit
[mustard2:mustard2.git] / src / org / mustard2 / android / activity / Mustard.java
1 package org.mustard2.android.activity;
2
3 import org.mustard2.android.Account;
4 import org.mustard2.android.MustardApp;
5 import org.mustard2.manager.DbManager;
6
7 import android.app.Activity;
8 import android.content.Context;
9 import android.net.ConnectivityManager;
10 import android.net.NetworkInfo;
11 import android.os.Bundle;
12
13 public class Mustard extends Activity {
14
15         private static final int MAX_RETRY = 3;
16         private static final int TIMEOUT_RETRY = 30;
17         
18     @Override
19     public void onCreate(Bundle savedInstanceState) {
20         super.onCreate(savedInstanceState);
21         
22                 ConnectivityManager connectivityManager =  (ConnectivityManager)getSystemService(Context.CONNECTIVITY_SERVICE);
23
24                 for (int i=0;i<MAX_RETRY;i++) {
25                         NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo();
26                         if (networkInfo != null && networkInfo.getState() == NetworkInfo.State.CONNECTED) {
27                                 Account[] account = ((MustardApp)getApplication()).getAccountManager().getEnabledAccounts();
28                                 if (account == null) {
29                                         Accounts.actionShowAccounts(this);
30                                 } else {
31                                         Timeline.actionHandleTimeline(this,DbManager.ROWTYPE_FRIENDS,null);
32                                 }
33                                 finish();
34                         } else {
35                                 
36                         }
37                 }
38
39     }
40     
41         
42 }