1
0
Fork 0
mirror of https://github.com/gsantner/dandelion synced 2024-07-01 07:46:46 +02:00
dandelion/app/src/main/java/com/github/dfa/diaspora_android/activity/SplashActivity.java

68 lines
2.3 KiB
Java
Raw Normal View History

2016-03-03 17:46:31 +01:00
/*
This file is part of the Diaspora for Android.
2016-03-03 17:46:31 +01:00
Diaspora for Android is free software: you can redistribute it and/or modify
2016-03-03 17:46:31 +01:00
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Diaspora for Android is distributed in the hope that it will be useful,
2016-03-03 17:46:31 +01:00
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with the Diaspora for Android.
2016-03-03 17:46:31 +01:00
If not, see <http://www.gnu.org/licenses/>.
*/
2016-03-29 19:38:50 +02:00
package com.github.dfa.diaspora_android.activity;
2016-03-03 17:46:31 +01:00
import android.content.res.TypedArray;
import android.os.Bundle;
import android.os.Handler;
2016-03-03 17:46:31 +01:00
import android.support.v7.app.AppCompatActivity;
import android.widget.ImageView;
2016-03-29 19:38:50 +02:00
import com.github.dfa.diaspora_android.App;
import com.github.dfa.diaspora_android.R;
import com.github.dfa.diaspora_android.util.Helpers;
2016-03-29 19:38:50 +02:00
import butterknife.BindView;
import butterknife.ButterKnife;
2016-03-03 17:46:31 +01:00
public class SplashActivity extends AppCompatActivity {
private App app;
2016-03-03 17:46:31 +01:00
@BindView(R.id.splash__splashimage)
public ImageView imgSplash;
2016-03-03 17:46:31 +01:00
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
2016-06-04 11:11:51 +02:00
setContentView(R.layout.splash__activity);
ButterKnife.bind(this);
app = (App) getApplication();
2016-03-03 17:46:31 +01:00
TypedArray images = getResources().obtainTypedArray(R.array.splash_images);
int choice = (int) (Math.random() * images.length());
imgSplash.setImageResource(images.getResourceId(choice, R.drawable.splashscreen1));
images.recycle();
int delay = getResources().getInteger(R.integer.splash_delay);
new Handler().postDelayed(startActivityRunnable, delay);
2016-03-03 17:46:31 +01:00
}
final Runnable startActivityRunnable = new Runnable() {
public void run() {
boolean hasPodDomain = app.getSettings().hasPodDomain();
Helpers.animateToActivity(SplashActivity.this,
hasPodDomain ? MainActivity.class : PodSelectionActivity.class,
true
);
}
};
2016-03-03 17:46:31 +01:00
}