private void loadPageContent() { if (!CheckNetworkConnection.isInternetAvailable(this)) { showToastLong(R.string.internet_connection_unavailable); VolunteerUser userFromDataStore = VolunteerUser.getCurrentUserInformationFromLocalStore(); if (userFromDataStore == null) { Intent errorIntent = new Intent(this, ErrorMessageActivity.class); errorIntent.putExtra( Constants.ERROR_ITEM_KEY, getResources().getString(R.string.internet_connection_unavailable)); startActivity(errorIntent); return; } // User available from local datastore if (!userFromDataStore.isEmailVerified()) { displayError(userFromDataStore.getEmail()); return; } if (!userFromDataStore.isProfileComplete()) { Intent errorIntent = new Intent(this, ErrorMessageActivity.class); String errorMessage = getResources().getString(R.string.incomplete_profile_no_internet); errorIntent.putExtra(Constants.ERROR_ITEM_KEY, errorMessage); startActivity(errorIntent); return; } // Start Main Activity Intent mainIntent = new Intent(this, MainActivity.class); mainIntent.putExtra(Constants.INTENT_SENDER, "intro"); mainIntent.putExtra(Constants.INTERNET_AVAILABLE, false); startActivity(mainIntent); } // currentUser final ParseUser currentParseUser = ParseUser.getCurrentUser(); if (currentParseUser == null) { startActivity(DispatchActivity.class); return; } final VolunteerUser currentUser = VolunteerUser.getCurrentUserInformation(currentParseUser); currentUser.pinInBackground(); if (!currentUser.isEmailVerified()) { displayError(currentUser.getEmail()); return; } if (!currentUser.isProfileComplete()) { showToastLong(R.string.help_us_know_you); startActivity(ProfileActivitySimple.class); } else { try { UserCategoryPoints.unpinAll(Constants.CURRENT_USER_POINTS); Category.unpinAll(Constants.CATEGORY_RESOURCE); } catch (ParseException e) { e.printStackTrace(); } Category.pinAllInBackground(Constants.CATEGORY_RESOURCE, Category.getAllCategories(true)); mUserPoints = 0; mUserHours = 0; mUserRank = 5; mCurrentAnnouncements = Joiner.on("|").join(Announcement.getAllAnnouncementText()); mTotalUsers = VolunteerUser.getTotalUserCount(); mTotalUserHours = DateUtils.minutesToHoursRepresentation( CommonUtils.sum(UserCategoryPoints.findMinutesForAllUsers(), 0)); try { List<VolunteerUser> rankedUsers = VolunteerUser.findUsersRanked(); mUserRank = rankedUsers.indexOf(currentUser); } catch (ParseException e) { e.printStackTrace(); } UserCategoryPoints.findCurrentUserPointsInBackground( currentParseUser, 0, new FindCallback<UserCategoryPoints>() { @Override public void done(List<UserCategoryPoints> list, ParseException e) { if (e == null) { UserCategoryPoints.pinAllInBackground(Constants.CURRENT_USER_POINTS, list); for (UserCategoryPoints item : list) { mUserPoints += item.getCategoryPoints(); mUserHours += item.getCategoryMinutes(); } } else { e.getMessage(); } startMainActivity(); } }); } }