Added Android code
[wl-app.git] / Android / app / src / main / java / com / moiseum / wolnelektury / view / splash / SplashActivity.java
1 package com.moiseum.wolnelektury.view.splash;
2
3 import android.os.Bundle;
4 import android.os.Handler;
5 import android.view.View;
6
7 import com.moiseum.wolnelektury.R;
8 import com.moiseum.wolnelektury.base.AbstractActivity;
9 import com.moiseum.wolnelektury.view.main.MainActivity;
10
11 import butterknife.BindView;
12
13 /**
14  * Created by piotrostrowski on 09.12.2017.
15  */
16
17 public class SplashActivity extends AbstractActivity {
18
19         @BindView(R.id.rlMainView)
20         View rlMainView;
21
22         private Handler launchHandler;
23         private Runnable launchRunnable = new Runnable() {
24                 @Override
25                 public void run() {
26                         launchDashboard();
27                 }
28         };
29
30         @Override
31         public int getLayoutResourceId() {
32                 return R.layout.activity_splash;
33         }
34
35         @Override
36         public void prepareView(Bundle savedInstanceState) {
37                 rlMainView.setOnClickListener(new View.OnClickListener() {
38                         @Override
39                         public void onClick(View v) {
40                                 launchDashboard();
41                         }
42                 });
43                 launchHandler = new Handler();
44                 launchHandler.postDelayed(launchRunnable, 1500);
45         }
46
47         @Override
48         public void onDestroy() {
49                 super.onDestroy();
50                 launchHandler.removeCallbacks(launchRunnable);
51         }
52
53         private void launchDashboard() {
54                 MainActivity.MainIntent intent = new MainActivity.MainIntent(this);
55                 startActivity(intent);
56                 finish();
57         }
58 }