/** {@inheritDoc} */
  public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
    final Cursor cursor = (Cursor) mAdapter.getItem(position);
    loadTrack(cursor, true);

    if (cursor != null) {
      UIUtils.setLastUsedTrackID(
          getActivity(), cursor.getString(TracksAdapter.TracksQuery.TRACK_ID));
    } else {
      UIUtils.setLastUsedTrackID(getActivity(), ScheduleContract.Tracks.ALL_TRACK_ID);
    }

    if (mListPopupWindow != null) {
      mListPopupWindow.dismiss();
    }
  }
  /** {@inheritDoc} */
  public void onQueryComplete(int token, Object cookie, Cursor cursor) {
    if (getActivity() == null || cursor == null) {
      return;
    }

    mCursor = cursor;
    getActivity().startManagingCursor(mCursor);

    // If there was a last-opened track, load it. Otherwise load the first track.
    cursor.moveToFirst();
    String lastTrackID = UIUtils.getLastUsedTrackID(getActivity());
    if (lastTrackID != null) {
      while (!cursor.isAfterLast()) {
        if (lastTrackID.equals(cursor.getString(TracksAdapter.TracksQuery.TRACK_ID))) {
          break;
        }
        cursor.moveToNext();
      }

      if (cursor.isAfterLast()) {
        loadTrack(null, mAutoloadTarget);
      } else {
        loadTrack(cursor, mAutoloadTarget);
      }
    } else {
      loadTrack(null, mAutoloadTarget);
    }

    mAdapter.setHasAllItem(true);
    mAdapter.setIsSessions(TracksFragment.NEXT_TYPE_SESSIONS.equals(mNextType));
    mAdapter.changeCursor(mCursor);
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    UIUtils.tryTranslateHttpIntent(this);
    BeamUtils.tryUpdateIntentFromBeam(this);

    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_sessions_sandbox);

    final FragmentManager fm = getSupportFragmentManager();
    mTracksDropdownFragment =
        (TracksDropdownFragment) fm.findFragmentById(R.id.fragment_tracks_dropdown);

    mSlidingPaneLayout = (SlidingPaneLayout) findViewById(R.id.sliding_pane_layout);

    // Offset the left pane by its full width and left margin when collapsed
    // (ViewPager-like presentation)
    mSlidingPaneLayout.setParallaxDistance(
        getResources().getDimensionPixelSize(R.dimen.sliding_pane_width)
            + getResources().getDimensionPixelSize(R.dimen.multipane_padding));
    mSlidingPaneLayout.setSliderFadeColor(
        getResources().getColor(R.color.sliding_pane_content_fade));

    routeIntent(getIntent(), savedInstanceState != null);

    if (savedInstanceState != null) {
      if (mFullUI) {
        int viewType = savedInstanceState.getInt(STATE_VIEW_TYPE);
        getSupportActionBar().setSelectedNavigationItem(viewType);
      }

      mDetailFragment = fm.findFragmentById(R.id.fragment_container_detail);
      updateDetailBackground();
    }

    // This flag prevents onTabSelected from triggering extra master pane reloads
    // unless it's actually being triggered by the user (and not automatically by
    // the system)
    mInitialTabSelect = false;

    mImageLoader =
        new ImageLoader(this, R.drawable.person_image_empty)
            .setMaxImageSize(getResources().getDimensionPixelSize(R.dimen.speaker_image_size))
            .setFadeInImage(UIUtils.hasHoneycombMR1());

    EasyTracker.getInstance().setContext(this);
  }
Esempio n. 4
0
 @TargetApi(Build.VERSION_CODES.HONEYCOMB)
 private void setupSearchMenuItem(Menu menu) {
   MenuItem searchItem = menu.findItem(R.id.menu_search);
   if (searchItem != null && UIUtils.hasHoneycomb()) {
     SearchView searchView = (SearchView) searchItem.getActionView();
     if (searchView != null) {
       SearchManager searchManager = (SearchManager) getSystemService(SEARCH_SERVICE);
       searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
     }
   }
 }
Esempio n. 5
0
 @Override
 public boolean onOptionsItemSelected(MenuItem item) {
   switch (item.getItemId()) {
     case R.id.menu_search:
       if (!UIUtils.hasHoneycomb()) {
         startSearch(null, false, Bundle.EMPTY, false);
         return true;
       }
       break;
   }
   return super.onOptionsItemSelected(item);
 }
 @Override
 public boolean onCreateOptionsMenu(Menu menu) {
   super.onCreateOptionsMenu(menu);
   getMenuInflater().inflate(R.menu.search, menu);
   MenuItem searchItem = menu.findItem(R.id.menu_search);
   if (searchItem != null && UIUtils.hasHoneycomb()) {
     SearchView searchView = (SearchView) searchItem.getActionView();
     if (searchView != null) {
       SearchManager searchManager = (SearchManager) getSystemService(SEARCH_SERVICE);
       searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
       searchView.setQueryRefinementEnabled(true);
     }
   }
   return true;
 }
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
      case android.R.id.home:
        if (mSlidingPaneLayout.isSlideable() && !mSlidingPaneLayout.isOpen()) {
          // If showing the detail view, pressing Up should show the master pane.
          mSlidingPaneLayout.openPane();
          return true;
        }
        break;

      case R.id.menu_search:
        if (!UIUtils.hasHoneycomb()) {
          startSearch(null, false, Bundle.EMPTY, false);
          return true;
        }
        break;
    }
    return super.onOptionsItemSelected(item);
  }
  public void loadTrack(Cursor cursor, boolean loadTargetFragment) {
    final String trackId;
    final int trackColor;
    final Resources res = getResources();

    if (cursor != null) {
      trackColor = cursor.getInt(TracksAdapter.TracksQuery.TRACK_COLOR);
      trackId = cursor.getString(TracksAdapter.TracksQuery.TRACK_ID);

      mTitle.setText(cursor.getString(TracksAdapter.TracksQuery.TRACK_NAME));
      mAbstract.setText(cursor.getString(TracksAdapter.TracksQuery.TRACK_ABSTRACT));

    } else {
      trackColor = res.getColor(R.color.all_track_color);
      trackId = ScheduleContract.Tracks.ALL_TRACK_ID;

      mTitle.setText(
          TracksFragment.NEXT_TYPE_SESSIONS.equals(mNextType)
              ? R.string.all_sessions_title
              : R.string.all_sandbox_title);
      mAbstract.setText(
          TracksFragment.NEXT_TYPE_SESSIONS.equals(mNextType)
              ? R.string.all_sessions_subtitle
              : R.string.all_sandbox_subtitle);
    }

    boolean isDark = UIUtils.isColorDark(trackColor);
    mRootView.setBackgroundColor(trackColor);

    if (isDark) {
      mTitle.setTextColor(res.getColor(R.color.body_text_1_inverse));
      mAbstract.setTextColor(res.getColor(R.color.body_text_2_inverse));
      mRootView
          .findViewById(R.id.track_dropdown_arrow)
          .setBackgroundResource(R.drawable.track_dropdown_arrow_light);
    } else {
      mTitle.setTextColor(res.getColor(R.color.body_text_1));
      mAbstract.setTextColor(res.getColor(R.color.body_text_2));
      mRootView
          .findViewById(R.id.track_dropdown_arrow)
          .setBackgroundResource(R.drawable.track_dropdown_arrow_dark);
    }

    if (loadTargetFragment) {
      final Intent intent = new Intent(Intent.ACTION_VIEW);
      final Uri trackUri = ScheduleContract.Tracks.buildTrackUri(trackId);
      intent.putExtra(SessionDetailFragment.EXTRA_TRACK, trackUri);

      if (NEXT_TYPE_SESSIONS.equals(mNextType)) {
        if (cursor == null) {
          intent.setData(ScheduleContract.Sessions.CONTENT_URI);
        } else {
          intent.setData(ScheduleContract.Tracks.buildSessionsUri(trackId));
        }
      } else if (NEXT_TYPE_VENDORS.equals(mNextType)) {
        if (cursor == null) {
          intent.setData(ScheduleContract.Vendors.CONTENT_URI);
        } else {
          intent.setData(ScheduleContract.Tracks.buildVendorsUri(trackId));
        }
      }

      ((BaseActivity) getActivity()).openActivityOrFragment(intent);
    }
  }
Esempio n. 9
0
 /** Handle "search" title-bar action. */
 public void onSearchClick(View v) {
   UIUtils.goSearch(this);
 }
Esempio n. 10
0
 /** Handle "home" title-bar action. */
 public void onHomeClick(View v) {
   UIUtils.goHome(this);
 }