Animated splash screen (mind: preview for the circular loader seems broken in Android Studio, but works in app)
This commit is contained in:
parent
0822c62eb8
commit
34c4951241
|
@ -34,4 +34,5 @@ dependencies {
|
|||
compile 'com.pkmmte.view:circularimageview:1.1'
|
||||
compile 'com.github.peter9870:sparkbutton:master'
|
||||
testCompile 'junit:junit:4.12'
|
||||
compile 'com.mikhaellopez:circularfillableloaders:1.2.0'
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
android:theme="@style/AppTheme">
|
||||
<activity
|
||||
android:name=".SplashActivity"
|
||||
android:theme="@style/SplashTheme">
|
||||
android:theme="@android:style/Theme.Black.NoTitleBar">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
|
|
|
@ -15,29 +15,43 @@
|
|||
|
||||
package com.keylesspalace.tusky;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
|
||||
public class SplashActivity extends AppCompatActivity {
|
||||
public class SplashActivity extends Activity {
|
||||
private static int SPLASH_TIME_OUT = 2000;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_splash);
|
||||
/* Determine whether the user is currently logged in, and if so go ahead and load the
|
||||
* timeline. Otherwise, start the activity_login screen. */
|
||||
SharedPreferences preferences = getSharedPreferences(
|
||||
getString(R.string.preferences_file_key), Context.MODE_PRIVATE);
|
||||
String domain = preferences.getString("domain", null);
|
||||
String accessToken = preferences.getString("accessToken", null);
|
||||
Intent intent;
|
||||
|
||||
|
||||
final Intent intent;
|
||||
|
||||
if (domain != null && accessToken != null) {
|
||||
intent = new Intent(this, MainActivity.class);
|
||||
} else {
|
||||
intent = new Intent(this, LoginActivity.class);
|
||||
}
|
||||
startActivity(intent);
|
||||
finish();
|
||||
|
||||
new Handler().postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
startActivity(intent);
|
||||
finish();
|
||||
}
|
||||
}, SPLASH_TIME_OUT);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:drawable="@color/splash_background" />
|
||||
<item>
|
||||
<bitmap
|
||||
android:src="@mipmap/ic_logo"
|
||||
android:gravity="center"/>
|
||||
</item>
|
||||
</layer-list>
|
|
@ -0,0 +1,27 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical"
|
||||
android:background="@color/color_background_dark"
|
||||
android:layout_height="match_parent">
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:gravity="center"
|
||||
android:layout_weight="1"
|
||||
android:layout_height="0dp">
|
||||
|
||||
<com.mikhaellopez.circularfillableloaders.CircularFillableLoaders
|
||||
android:id="@+id/circularFillableLoaders"
|
||||
android:layout_width="200dp"
|
||||
android:layout_height="200dp"
|
||||
android:src="@mipmap/ic_logo"
|
||||
app:cfl_border="true"
|
||||
app:cfl_border_width="4dp"
|
||||
app:cfl_progress="80"
|
||||
app:cfl_wave_amplitude="0.08"
|
||||
app:cfl_wave_color="@color/color_primary_dark" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
|
@ -1,9 +1,5 @@
|
|||
<resources>
|
||||
|
||||
<style name="SplashTheme" parent="Theme.AppCompat.NoActionBar">
|
||||
<item name="android:windowBackground">@drawable/splash_background</item>
|
||||
</style>
|
||||
|
||||
<style name="TabLayoutTextStyle" parent="TextAppearance.Design.Tab">
|
||||
<item name="android:textStyle">normal|bold</item>
|
||||
</style>
|
||||
|
|
Loading…
Reference in New Issue