Last active
June 6, 2016 12:54
-
-
Save HammadNasir/6abfc58534c358eda21153907d8bfd3e to your computer and use it in GitHub Desktop.
This file contains 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
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_main); | |
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); | |
setSupportActionBar(toolbar); | |
mAuth = FirebaseAuth.getInstance(); | |
databaseReference = FirebaseDatabase.getInstance().getReference(); | |
hRequestAdapter = new HRequestAdapter(hRequestsList); | |
recyclerView = (RecyclerView) findViewById(R.id.recycler_view); | |
recyclerView.setHasFixedSize(true); | |
recyclerView.setAdapter(helpRequestAdapter); | |
recyclerView.setLayoutManager(new LinearLayoutManager(this)); | |
recyclerView.setItemAnimator(new DefaultItemAnimator()); | |
checkAuthState(); | |
} | |
here's checkAuthState(): | |
public void checkAuthState() { | |
mAuthListener = new FirebaseAuth.AuthStateListener() { | |
@Override | |
public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth) { | |
FirebaseUser user = firebaseAuth.getCurrentUser(); | |
if (user != null) { | |
// User is signed in | |
Log.d("signedIn", "onAuthStateChanged:signed_in:" + user.getUid()); | |
retrieveUserInfo(); | |
retrieveHRequests(); | |
} else { | |
// User is signed out | |
Log.d("signedOut", "onAuthStateChanged:signed_out"); | |
Intent signUpActivityIntent = new Intent(MainActivity.this, SignupActivity.class); | |
signUpActivityIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); | |
signUpActivityIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK); | |
startActivity(signUpActivityIntent); | |
} | |
// ... | |
} | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment