예제 #1
0
  private void handleIntent(Intent intent) {
    // Special processing of the incoming intent only occurs if the action specified
    // by the intent is ACTION_SEARCH.
    if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
      String query = intent.getStringExtra(SearchManager.QUERY);

      SearchRecentSuggestions suggestions =
          new SearchRecentSuggestions(
              this,
              SearchRecentSuggestionsProviderImpl.AUTHORITY,
              SearchRecentSuggestionsProviderImpl.MODE);
      suggestions.saveRecentQuery(query, null);

      if (mTwoPane) {
        TopTracksActivityFragment fragment = new TopTracksActivityFragment();
        mUserLeaveHintCallback = fragment;
        getSupportFragmentManager()
            .beginTransaction()
            .replace(R.id.activity_fragment_top_tracks, fragment, TOPTRACKS_FRAGMENT_TAG)
            .commit();
      }

      // do the actual search on the fragment
      MainActivityFragment mainActivityFragment =
          (MainActivityFragment)
              getSupportFragmentManager().findFragmentById(R.id.activity_fragment_main);

      mainActivityFragment.searchArtists(query);
    }
  }
예제 #2
0
  @Override
  protected void onResume() {
    super.onResume();

    if (Utility.getPreferredLocation(this) != mlocation) {
      MainActivityFragment ff = new MainActivityFragment();
      ff.onLocationChanged();
      mlocation = Utility.getPreferredLocation(this);
    }
  }
 @Override
 public void onResume() {
   super.onResume();
   String location = Utility.getPreferredLocation(this);
   // update the location in our second pane using the fragment manager
   if (location != null && !location.equals(mLocation)) {
     MainActivityFragment ff =
         (MainActivityFragment) getFragmentManager().findFragmentByTag(FORECASTFRAGMENT_TAG);
     if (null != ff) {
       ff.onLocationChanged();
     }
     mLocation = location;
   }
 }