private void startMainActivity() { VolunteerOpportunity upcomingActivity = VolunteerOpportunity.getUpcomingOpportunity(); SharedPreferences sharedPref = this.getSharedPreferences(Constants.PREF_FILE_NAME, Context.MODE_PRIVATE); SharedPreferences.Editor editor = sharedPref.edit(); editor.putString(Constants.ANNOUNCEMENTS_KEY, mCurrentAnnouncements); // Overall with %s points and %s hours you are ranked %s out of %s volunteers! editor.putString( Constants.POINTS_RANK_KEY, String.format( getString(R.string.main_points_rank), mUserPoints, mUserHours, mUserRank, mTotalUsers)); // Our %s volunteers have put in %s hours! editor.putString( Constants.SG_STATS_KEY, String.format(getString(R.string.total_sg_users_hours), mTotalUsers, mTotalUserHours)); editor.putString( Constants.UPCOMING_KEY, String.format(getString(R.string.upcoming_event), upcomingActivity.getTitle())); editor.putString( Constants.STATS_LAST_UPDATE_DATE, DateUtils.formattedDateString(new LocalDate().toDate()).toString()); editor.apply(); Intent mainIntent = new Intent(this, MainActivity.class); mainIntent.putExtra(Constants.INTENT_SENDER, "intro"); mainIntent.putExtra(Constants.INTERNET_AVAILABLE, true); startActivity(mainIntent); }
private void populateEventList(List<VolunteerOpportunity> objects) { if (objects.isEmpty()) { mEmptyUserList.setText(R.string.no_opportunities_available); mEmptyUserList.setVisibility(View.VISIBLE); mUsersRecyclerView.setVisibility(View.GONE); } else { mUserListHeaderText.setText(R.string.nav_opportunity); for (VolunteerOpportunity opportunity : objects) { mResourceList.add(opportunity.convertToResourceModel()); } } mUserResourceAdapter.notifyDataSetChanged(); }
private void loadOrganizationEvents(String orgName) { initializeUserRecyclerView(); VolunteerOpportunity.getOpportunitiesForOrganization( orgName, false, new FindCallback<VolunteerOpportunity>() { @Override public void done(List<VolunteerOpportunity> objects, ParseException e) { populateEventList(objects); } }); }
private void initializeRecognitionOpportunitySpinner() { final List<VolunteerOpportunity> availableOpportunities = Lists.newArrayList(); final ArrayAdapter<VolunteerOpportunity> dataAdapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, availableOpportunities); VolunteerOpportunity.getActiveOpportunities( new FindCallback<VolunteerOpportunity>() { @Override public void done(List<VolunteerOpportunity> objects, ParseException e) { if (e == null) { for (VolunteerOpportunity opportunity : objects) { availableOpportunities.add(opportunity); } } dataAdapter.notifyDataSetChanged(); } }); dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); mRecognitionActivitySpinner.setPromptId(R.string.recog_activity_hint); mRecognitionActivitySpinner.setAdapter( new SelectorHintAdapter(dataAdapter, R.layout.action_selector_hint_row, this)); }