@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); ViewPager vpPager = (ViewPager) findViewById(R.id.vpPager); adapterViewPager = new MyPagerAdapter(getSupportFragmentManager(),getApplicationContext()); vpPager.setAdapter(adapterViewPager); ParseUser currentUser = ParseUser.getCurrentUser(); if (ParseAnonymousUtils.isLinked(currentUser) || currentUser==null) { // If user is anonymous, send the user to LoginSignupActivity.class Intent intent = new Intent(HomeActivity.this, LoginSignupActivity.class); startActivity(intent); finish(); } }
/** Swaps fragments in the main content view */ private void selectItem(int position) { mDrawerList.setItemChecked(position, true); mDrawerLayout.closeDrawers(); setTitle(mDrawerItems[position]); switch (position) { case 0: show(new BrowseFragment()); break; case 1: if (ParseAnonymousUtils.isLinked(ParseUser.getCurrentUser())) { show(new SignUpFragment()); } else { show(new ShareFragment()); } break; } }
@NonNull @CheckReturnValue public static Single<ParseUser> anonymousLogIn() { return RxTask.single(() -> ParseAnonymousUtils.logInInBackground()); }