Created
January 15, 2017 17:27
-
-
Save cliffgr/4605e176965bb76015a6aad45e6a8402 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package velti.privacy.flag.ui.splash; | |
import android.content.SharedPreferences; | |
import android.os.Handler; | |
import android.util.Log; | |
import javax.inject.Inject; | |
import velti.privacy.flag.app.App; | |
import velti.privacy.flag.base.BasePresenter; | |
import velti.privacy.flag.ui.poll.PollActivity; | |
/** | |
* Created by cliff on 15/1/2017. | |
*/ | |
public class SplashScreenPresenter extends BasePresenter<SplashScreenMVP.View> implements SplashScreenMVP.Presenter { | |
private static int SPLASH_DELAY = 5 * 1000; | |
@Inject | |
SharedPreferences sharedPreferences; | |
public SplashScreenPresenter() { | |
App.getAppComponent().inject(this); | |
} | |
@Override | |
public void splashTimerThread() { | |
new Handler().postDelayed(new Runnable() { | |
@Override | |
public void run() { | |
if(firstTimeChecker()) { | |
getView().gotoActivity(PollActivity.class); | |
} | |
} | |
}, SPLASH_DELAY); | |
} | |
private Boolean firstTimeChecker() { | |
if (sharedPreferences.getBoolean("firstRun", true)) { | |
//You can perform anything over here. This will call only first time | |
SharedPreferences.Editor editor = sharedPreferences.edit(); | |
editor.putBoolean("firstRun", false); | |
editor.apply(); | |
return true; | |
} | |
return false; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment