@Override public boolean onOptionsItemSelected(MenuItem item) { int id = item.getItemId(); switch (id) { case R.id.map_all_classes: // check to see if we're done loading the schedules (the // ScheduleClassAdapter is initialized in onPostExecute) if (adapter != null) { // populate an array with the buildings IDs of all of the user's classtimes ArrayList<String> buildings = new ArrayList<String>(); for (UTClass clz : classList) { for (Classtime clt : clz.getClassTimes()) { if (!buildings.contains(clt.getBuilding().getId())) { buildings.add(clt.getBuilding().getId()); } } } Intent map = new Intent( getString(R.string.building_intent), null, parentAct, CampusMapActivity.class); map.putStringArrayListExtra("buildings", buildings); startActivity(map); break; } case R.id.export_schedule: // version-gate handled by xml, but just to make sure... if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { // check to see if we're done loading the schedules (the // ScheduleClassAdapter is initialized in onPostExecute) if (adapter != null) { FragmentManager fm = parentAct.getSupportFragmentManager(); DoubleDatePickerDialogFragment ddpDlg = DoubleDatePickerDialogFragment.newInstance(classList); ddpDlg.show(fm, "fragment_double_date_picker"); } } else { Toast.makeText( parentAct, "Export to calendar is not supported on this version of Android", Toast.LENGTH_SHORT) .show(); } break; default: return super.onOptionsItemSelected(item); } return true; }
@Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { slidingDrawer.close(); currentClasstime = (Classtime) parent.getItemAtPosition(position); if (currentClasstime != null) { mode = parentAct.startActionMode(new ScheduleActionMode()); slidingDrawer.setVisibility(View.VISIBLE); String text = " "; text += currentClasstime.getCourseId() + " - " + currentClasstime.getName() + " "; String daytext = "\n\t"; String building = currentClasstime.getBuilding().getId() + " " + currentClasstime.getBuilding().getRoom(); String unique = currentClasstime.getUnique(); String time = currentClasstime.getStartTime(); String end = currentClasstime.getEndTime(); if (currentClasstime.getDay() == 'H') { daytext += "TH"; } else { daytext += currentClasstime.getDay(); } // TODO: stringbuilder text += (daytext + " from " + time + "-" + end + " in " + building) + "\n"; text += "\tUnique: " + unique + "\n"; classInfoImageView.setBackgroundColor(Color.parseColor("#" + currentClasstime.getColor())); classInfoImageView.setMinimumHeight(10); classInfoImageView.setMinimumWidth(10); classInfoTextView.setTextColor(Color.BLACK); classInfoTextView.setTextSize(14f); classInfoTextView.setBackgroundColor(TRANSLUCENT_GRAY); classInfoTextView.setText(text); slidingDrawer.open(); } // they clicked an empty cell else { if (mode != null) { mode.finish(); } slidingDrawer.setVisibility(View.INVISIBLE); } }