Created
October 17, 2017 01:28
-
-
Save ZaelAndrew11/b1681a5ffda7714c90bcc807fe112ddf to your computer and use it in GitHub Desktop.
Start Service splash activity
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 com.desafiolatam.desafioface.views.splash; | |
import android.content.BroadcastReceiver; | |
import android.content.Context; | |
import android.content.Intent; | |
import android.content.IntentFilter; | |
import android.os.Handler; | |
import android.support.v4.content.LocalBroadcastManager; | |
import android.support.v7.app.AppCompatActivity; | |
import android.os.Bundle; | |
import android.view.View; | |
import com.desafiolatam.desafioface.R; | |
import com.desafiolatam.desafioface.background.RecentUsersService; | |
import com.desafiolatam.desafioface.views.main.MainActivity; | |
import com.desafiolatam.desafioface.views.login.LoginActivity; | |
public class SplashActivity extends AppCompatActivity implements LoginCallback{ | |
private IntentFilter intentFilter; | |
private BroadcastReceiver broadcastReceiver; | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_splash); | |
View view = findViewById(R.id.root); | |
view.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE | |
| View.SYSTEM_UI_FLAG_FULLSCREEN | |
| View.SYSTEM_UI_FLAG_LAYOUT_STABLE | |
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY | |
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | |
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION); | |
new LoginValidation(this).init(); | |
intentFilter = new IntentFilter(); | |
intentFilter.addAction(RecentUsersService.USERS_FINISH); | |
broadcastReceiver = new BroadcastReceiver() { | |
@Override | |
public void onReceive(Context context, Intent intent) { | |
String actions = intent.getAction(); | |
if (RecentUsersService.USERS_FINISH.equals(actions)) { | |
startActivity(new Intent(SplashActivity.this, MainActivity.class)); | |
finish(); | |
} | |
} | |
}; | |
} | |
@Override | |
protected void onResume() { | |
super.onResume(); | |
LocalBroadcastManager.getInstance(this).registerReceiver(broadcastReceiver, intentFilter); | |
} | |
@Override | |
protected void onPause() { | |
super.onPause(); | |
LocalBroadcastManager.getInstance(this).unregisterReceiver(broadcastReceiver); | |
} | |
@Override | |
public void signed() { | |
RecentUsersService.startActionRecentUsers(this); | |
} | |
@Override | |
public void sigUp() { | |
new Handler().postDelayed(new Runnable() { | |
@Override | |
public void run() { | |
startActivity(new Intent(SplashActivity.this, LoginActivity.class)); | |
finish(); | |
} | |
},1200); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment