use of com.polito.mad17.madmax.activities.login.LoginSignUpActivity in project MadMax by deviz92.
the class MainActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Log.i(TAG, "onCreate");
FirebaseUtils.getInstance().setUp();
firebaseDatabase = FirebaseUtils.getFirebaseDatabase();
databaseReference = FirebaseUtils.getDatabaseReference();
usersRef = databaseReference.child("users");
groupRef = databaseReference.child("groups");
auth = FirebaseAuth.getInstance();
/*
// getting Intent from invitation
Intent intent = getIntent();
String action = intent.getAction();
Log.d(TAG, "action " + action);
// retrieving data from the intent inviterUID & groupToBeAddedID as the group ID where to add the current user
Uri data = intent.getData();
if(data != null) {
// to be used to set the current user as friend of the inviter
Log.d(TAG, "there is an invite");
inviterUID = data.getQueryParameter("inviterUID");
groupToBeAddedID = data.getQueryParameter("groupToBeAddedID");
}
else {
inviterUID = null;
groupToBeAddedID = null;
Log.d(TAG, "there is not an invite");
}*/
// getting currentUID from Intent (from LoginSignUpActivity or EmailVerificationActivity)
startingIntent = getIntent();
Uri data = startingIntent.getData();
if (data != null) {
inviterID = data.getQueryParameter("inviterID");
groupToBeAddedID = data.getQueryParameter("groupToBeAddedID");
} else {
// retrieving data from the intent inviterID & groupToBeAddedID as the group ID where to add the current user
if (startingIntent.hasExtra("inviterID")) {
// to be used to set the current user as friend of the inviter
Log.d(TAG, "there is an invite");
inviterID = startingIntent.getStringExtra("inviterID");
startingIntent.removeExtra("inviterID");
} else
inviterID = null;
if (startingIntent.hasExtra("groupToBeAddedID")) {
groupToBeAddedID = startingIntent.getStringExtra("groupToBeAddedID");
startingIntent.removeExtra("groupToBeAddedID");
} else
groupToBeAddedID = null;
}
//todo a cosa serve?
currentFragment = startingIntent.getIntExtra("currentFragment", 1);
if ((auth.getCurrentUser() == null) || (!auth.getCurrentUser().isEmailVerified())) {
if (auth.getCurrentUser() != null) {
auth.signOut();
}
Intent doLogin = new Intent(getApplicationContext(), LoginSignUpActivity.class).setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
if (inviterID != null)
doLogin.putExtra("inviterID", inviterID);
if (groupToBeAddedID != null)
doLogin.putExtra("groupToBeAddedID", groupToBeAddedID);
startActivity(doLogin);
//0 for no animation
overridePendingTransition(0, 0);
finish();
}
// insert tabs and current fragment in the main layout
mainView.addView(getLayoutInflater().inflate(R.layout.skeleton_tab, null));
tabLayout = (TabLayout) findViewById(R.id.tab_layout);
tabLayout.addTab(tabLayout.newTab().setText(friends));
tabLayout.addTab(tabLayout.newTab().setText(R.string.groups));
tabLayout.addTab(tabLayout.newTab().setText(R.string.pending));
tabLayout.setTabGravity(TabLayout.GRAVITY_FILL);
viewPager = (ViewPager) findViewById(R.id.main_view_pager);
viewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout));
tabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
@Override
public void onTabSelected(TabLayout.Tab tab) {
Log.d(TAG, String.valueOf(tab.getPosition()));
updateFab(tab.getPosition());
viewPager.setCurrentItem(tab.getPosition());
}
@Override
public void onTabUnselected(TabLayout.Tab tab) {
}
@Override
public void onTabReselected(TabLayout.Tab tab) {
}
});
// in the main we don't want an expansible bar
AppBarLayout appBarLayout = (AppBarLayout) findViewById(R.id.app_bar);
appBarLayout.setExpanded(false);
//todo: capire come bloccare la barra nel main
progressDialog = new ProgressDialog(this);
}
Aggregations