1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137
| import org.apache.commons.httpclient.Credentials;
import org.apache.commons.httpclient.HostConfiguration;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager;
import org.apache.commons.httpclient.UsernamePasswordCredentials;
import org.apache.commons.httpclient.auth.AuthScope;
import org.apache.commons.httpclient.params.HttpConnectionManagerParams;
import org.apache.jackrabbit.webdav.MultiStatus;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.util.Log;
import org.apache.commons.httpclient.Credentials;
import org.apache.commons.httpclient.HostConfiguration;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager;
import org.apache.commons.httpclient.UsernamePasswordCredentials;
import org.apache.commons.httpclient.auth.AuthScope;
import org.apache.commons.httpclient.params.HttpConnectionManagerParams;
import org.apache.jackrabbit.webdav.MultiStatus;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.util.Log;
public class SplashActivity extends WebdavMethodImpl {
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.splash);
new Handler().postDelayed(new Runnable() {
public void run() {
if (isOnline()) {
try {
if ((!(pref.getString(PREF_USERNAME, null) == null))
&& (!(pref.getString(PREF_PASSWORD, null) == null))
&& (!(pref.getString(PREF_SERVERURL, null) == null))
&& (!(pref.getString(PREF_BASEURL, null) == null))
&& (!(pref.getString(PREF_UNLINK, null) == null))) {
if (!pref.getString(PREF_UNLINK, null)
.equals("true")) {
url = pref.getString(PREF_SERVERURL, null);
baseUrl = pref.getString(PREF_BASEURL, null);
HostConfiguration config = new HostConfiguration();
config.setHost(url);
MultiThreadedHttpConnectionManager manager = new MultiThreadedHttpConnectionManager();
HttpConnectionManagerParams params = new HttpConnectionManagerParams();
params.setMaxConnectionsPerHost(config, 5);
httpClient = new HttpClient(manager);
httpClient.setHostConfiguration(config);
Credentials cred = new UsernamePasswordCredentials(
pref.getString(PREF_USERNAME, null),
pref.getString(PREF_PASSWORD, null));
httpClient.getState().setCredentials(
AuthScope.ANY, cred);
MultiStatus ms = null;
try {
ms = listAll(url, httpClient);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
if (ms != null) {
if ((!(pref.getString(PREF_PASSCODE, null) == null))
&& (pref.getString(PREF_PASSCODE,
null).equals("true"))) {
startActivity(new Intent(
getApplicationContext(),
PassCodeActivity.class)
.putExtra("From", "splash"));
finish();
} else {
startActivity(new Intent(
getApplicationContext(),
SplashActivity.class)
.putExtra("From", "PassCodeOff"));
finish();
}
} else {
webServerAlert();
}
} else {
startActivity(new Intent(
getApplicationContext(),
SelectionActivity.class));
finish();
}
} else {
startActivity(new Intent(getApplicationContext(),
SelectionActivity.class));
finish();
}
} catch (Exception w) {
// TODO Auto-generated catch block
w.printStackTrace();
Log.i("Splash Exception === > ", w.toString());
Intent it = new Intent(getApplicationContext(),
SelectionActivity.class).putExtra("From",
"Splash");
startActivity(it);
finish();
}
} else {
WebNetworkAlert();
}
// startActivity(new
// Intent(getApplicationContext(),LoginSelectionActivity.class));
// finish();
}
}, 800);
}
@Override
protected void onDestroy() {
// TODO Auto-generated method stub
finish();
super.onDestroy();
}
} |
Partager