mirror of
https://github.com/samuelclay/NewsBlur.git
synced 2025-08-31 21:41:33 +00:00
Rework app launch to ensure DB isn't accessed before ready.
This commit is contained in:
parent
8dff7b1b6e
commit
d171caa7a2
4 changed files with 63 additions and 26 deletions
|
@ -1,8 +1,8 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.newsblur"
|
||||
android:versionCode="108"
|
||||
android:versionName="4.6.0b2" >
|
||||
android:versionCode="109"
|
||||
android:versionName="4.6.0b3" >
|
||||
|
||||
<uses-sdk
|
||||
android:minSdkVersion="14"
|
||||
|
@ -22,15 +22,21 @@
|
|||
android:fullBackupContent="@xml/backupscheme" >
|
||||
|
||||
<activity
|
||||
android:name=".activity.Login"
|
||||
android:name=".activity.InitActivity"
|
||||
android:label="@string/newsblur"
|
||||
android:noHistory="true"
|
||||
android:windowSoftInputMode="adjustResize">
|
||||
android:noHistory="true">
|
||||
<intent-filter>
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
android:name=".activity.Login"
|
||||
android:label="@string/newsblur"
|
||||
android:noHistory="true"
|
||||
android:windowSoftInputMode="adjustResize">
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
android:name=".activity.LoginProgress"
|
||||
|
|
6
clients/android/NewsBlur/res/layout/activity_init.xml
Normal file
6
clients/android/NewsBlur/res/layout/activity_init.xml
Normal file
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
</LinearLayout>
|
|
@ -0,0 +1,46 @@
|
|||
package com.newsblur.activity;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.app.Activity;
|
||||
import android.view.Window;
|
||||
|
||||
import com.newsblur.R;
|
||||
import com.newsblur.util.FeedUtils;
|
||||
import com.newsblur.util.PrefConstants;
|
||||
import com.newsblur.util.PrefsUtils;
|
||||
|
||||
/**
|
||||
* The very first activity we launch. Checks to see if there is a user logged in yet and then
|
||||
* either loads the Main UI or a Login screen as needed. Also responsible for warming up the
|
||||
* DB connection used by all other Activities.
|
||||
*/
|
||||
public class InitActivity extends Activity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_init);
|
||||
|
||||
// this is the first Activity launched; use it to init the global singletons in FeedUtils
|
||||
FeedUtils.offerInitContext(this);
|
||||
|
||||
// see if a user is already logged in; if so, jump to the Main activity
|
||||
preferenceCheck();
|
||||
}
|
||||
|
||||
private void preferenceCheck() {
|
||||
final SharedPreferences preferences = getSharedPreferences(PrefConstants.PREFERENCES, Context.MODE_PRIVATE);
|
||||
if (preferences.getString(PrefConstants.PREF_COOKIE, null) != null) {
|
||||
Intent mainIntent = new Intent(this, Main.class);
|
||||
startActivity(mainIntent);
|
||||
} else {
|
||||
Intent loginIntent = new Intent(this, Login.class);
|
||||
startActivity(loginIntent);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -1,8 +1,5 @@
|
|||
package com.newsblur.activity;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.app.Activity;
|
||||
import android.app.FragmentManager;
|
||||
|
@ -11,9 +8,6 @@ import android.view.Window;
|
|||
|
||||
import com.newsblur.R;
|
||||
import com.newsblur.fragment.LoginRegisterFragment;
|
||||
import com.newsblur.util.FeedUtils;
|
||||
import com.newsblur.util.PrefConstants;
|
||||
import com.newsblur.util.PrefsUtils;
|
||||
|
||||
public class Login extends Activity {
|
||||
|
||||
|
@ -21,12 +15,6 @@ public class Login extends Activity {
|
|||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
// this is the first Activity launched; use it to init the global singletons in FeedUtils
|
||||
FeedUtils.offerInitContext(this);
|
||||
|
||||
// see if a user is already logged in; if so, jump to the Main activity
|
||||
preferenceCheck();
|
||||
|
||||
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
setContentView(R.layout.activity_login);
|
||||
FragmentManager fragmentManager = getFragmentManager();
|
||||
|
@ -39,13 +27,4 @@ public class Login extends Activity {
|
|||
}
|
||||
}
|
||||
|
||||
private void preferenceCheck() {
|
||||
final SharedPreferences preferences = getSharedPreferences(PrefConstants.PREFERENCES, Context.MODE_PRIVATE);
|
||||
if (preferences.getString(PrefConstants.PREF_COOKIE, null) != null) {
|
||||
final Intent mainIntent = new Intent(this, Main.class);
|
||||
startActivity(mainIntent);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue