└── app └── src └── main └── java └── com └── moeid └── framework └── mvp └── ui └── Activity_Splash └── Splash.java /app/src/main/java/com/moeid/framework/mvp/ui/Activity_Splash/Splash.java: -------------------------------------------------------------------------------- 1 | package com.moeid.framework.mvp.ui.Activity_Splash; 2 | 3 | import android.content.Context; 4 | import android.content.Intent; 5 | import android.os.Bundle; 6 | 7 | import com.moeid.framework.mvp.R; 8 | import com.moeid.framework.mvp.ui.Activity_Login.Login; 9 | import com.moeid.framework.mvp.ui.base.BaseActivity; 10 | import com.rbddevs.splashy.Splashy; 11 | 12 | import java.net.URISyntaxException; 13 | 14 | import javax.inject.Inject; 15 | 16 | import butterknife.ButterKnife; 17 | 18 | /** 19 | * @author MoeidTopcoder 20 | * @version 1.0 21 | */ 22 | 23 | public class Splash extends BaseActivity implements SplashMvpView { 24 | /** 25 | * @author MoeidTopcoder 26 | * inject a presenter of this activity for business logic purpose 27 | */ 28 | @Inject 29 | SplashMvpPresenter mPresenter; 30 | /** 31 | * @param context 32 | * @return static Intent 33 | * @author MoeidTopcoder 34 | * get an instance of this activity by this static function when ever creating an intent with this activity will be needed 35 | */ 36 | public static Intent getStartIntent(Context context) { 37 | Intent intent = new Intent(context, Splash.class); 38 | return intent; 39 | } 40 | /** 41 | * everything in this activity start here as an entry point 42 | * 43 | * @param savedInstanceState 44 | */ 45 | @Override 46 | protected void onCreate(Bundle savedInstanceState) { 47 | super.onCreate(savedInstanceState); 48 | setContentView(R.layout.activity_splash); 49 | 50 | getActivityComponent().inject(this); 51 | 52 | setUnBinder(ButterKnife.bind(this)); 53 | 54 | mPresenter.onAttach(Splash.this); 55 | 56 | try { 57 | setUp(); 58 | } catch (URISyntaxException e) { 59 | e.printStackTrace(); 60 | } 61 | } 62 | /** 63 | * @throws URISyntaxException 64 | * @author MoeidTopcoder 65 | * entry point of this activity after onCreate function 66 | */ 67 | @Override 68 | protected void setUp() throws URISyntaxException { 69 | // Initialize the splash onject to be represented in the center of the screen 70 | new Splashy(this) 71 | .setBackgroundColor("#B50540") 72 | .setTitle("سنه آگرین") 73 | .setTitleColor("#FFFFFF") 74 | .setSubTitle("اپلیکیشن جامع مکان یابی") 75 | .setSubTitleColor("#FFFFFF") 76 | .setFullScreen(true) 77 | .setAnimation(Splashy.Animation.SLIDE_IN_TOP_BOTTOM, 200) 78 | .setLogo(R.drawable.snaagrin_icon) 79 | .setTime(5000) 80 | .show(); 81 | //start the new activity after the splash ends with this listener 82 | Splashy.Companion.onComplete(new Splashy.OnComplete() { 83 | @Override 84 | public void onComplete() { 85 | startLoginPage(); 86 | } 87 | }); 88 | 89 | 90 | } 91 | 92 | /** 93 | * @author MoeidTopcoder 94 | * to start the login activity after the duration of splash 95 | */ 96 | public void startLoginPage() { 97 | startActivity(Login.getStartIntent(Splash.this)); 98 | 99 | 100 | } 101 | } --------------------------------------------------------------------------------