]> git.ktnx.net Git - mobile-ledger.git/blob - app/src/main/java/net/ktnx/mobileledger/ui/activity/SplashActivity.java
add splash on startup
[mobile-ledger.git] / app / src / main / java / net / ktnx / mobileledger / ui / activity / SplashActivity.java
1 /*
2  * Copyright © 2020 Damyan Ivanov.
3  * This file is part of MoLe.
4  * MoLe is free software: you can distribute it and/or modify it
5  * under the term of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your opinion), any later version.
8  *
9  * MoLe is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License terms for details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with MoLe. If not, see <https://www.gnu.org/licenses/>.
16  */
17
18 package net.ktnx.mobileledger.ui.activity;
19
20 import android.app.Activity;
21 import android.content.Intent;
22 import android.os.Bundle;
23 import android.os.Handler;
24
25 import androidx.annotation.Nullable;
26
27 import net.ktnx.mobileledger.R;
28 import net.ktnx.mobileledger.model.Data;
29 import net.ktnx.mobileledger.model.MobileLedgerProfile;
30 import net.ktnx.mobileledger.utils.MLDB;
31
32 public class SplashActivity extends Activity {
33     @Override
34     protected void onCreate(@Nullable Bundle savedInstanceState) {
35         super.onCreate(savedInstanceState);
36         setTheme(R.style.AppTheme_default);
37         setContentView(R.layout.splash_activity_layout);
38     }
39     @Override
40     protected void onStart() {
41         super.onStart();
42
43         MobileLedgerProfile.loadAllFromDB(null);
44
45         String profileUUID = MLDB.getOption(MLDB.OPT_PROFILE_UUID, null);
46         MobileLedgerProfile startupProfile = Data.getProfile(profileUUID);
47         if (startupProfile != null)
48             Data.setCurrentProfile(startupProfile);
49
50         new Handler().postDelayed(() -> {
51             Intent intent = new Intent(this, MainActivity.class);
52             intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NO_USER_ACTION |
53                             Intent.FLAG_ACTIVITY_NEW_TASK);
54             startActivity(intent);
55             overridePendingTransition(R.anim.fade_in, R.anim.dummy);
56         }, 250);
57     }
58 }