@Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_detail);

    if (savedInstanceState == null) {
      // Create the detail fragment and add it to the activity
      // using a fragment transaction.

      Bundle arguments = new Bundle();
      arguments.putParcelable(DetailFragment.DETAIL_URI, getIntent().getData());
      arguments.putBoolean(DetailFragment.DETAIL_TRANSITION_ANIMATION, true);

      DetailFragment fragment = new DetailFragment();
      fragment.setArguments(arguments);

      getSupportFragmentManager()
          .beginTransaction()
          .add(R.id.weather_detail_container, fragment)
          .commit();

      // Being here means we are in animation mode
      supportPostponeEnterTransition();
    }
  }
Ejemplo n.º 2
0
 @Override
 protected 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)) {
     ForecastFragment ff =
         (ForecastFragment) getSupportFragmentManager().findFragmentById(R.id.fragment_forecast);
     if (null != ff) {
       ff.onLocationChanged();
     }
     DetailFragment df =
         (DetailFragment) getSupportFragmentManager().findFragmentByTag(DETAILFRAGMENT_TAG);
     if (null != df) {
       df.onLocationChanged(location);
     }
     mLocation = location;
   }
 }
Ejemplo n.º 3
0
  @Override
  public void onItemSelected(Uri contentUri) {
    if (mTwoPane) {
      // In two-pane mode, show the detail view in this activity by
      // adding or replacing the detail fragment using a
      // fragment transaction.
      Bundle args = new Bundle();
      args.putParcelable(DetailFragment.DETAIL_URI, contentUri);

      DetailFragment fragment = new DetailFragment();
      fragment.setArguments(args);

      getSupportFragmentManager()
          .beginTransaction()
          .replace(R.id.weather_detail_container, fragment, DETAILFRAGMENT_TAG)
          .commit();
    } else {
      Intent intent = new Intent(this, DetailActivity.class).setData(contentUri);
      startActivity(intent);
    }
  }
Ejemplo n.º 4
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_detail);

    // Invoke fragment class.
    if (savedInstanceState == null) {
      // Create the detail fragment and add it to the activity
      // using a fragment transaction.

      Bundle arguments = new Bundle();
      arguments.putParcelable(DetailFragment.DETAIL_URI, getIntent().getData());

      DetailFragment fragment = new DetailFragment();
      fragment.setArguments(arguments);

      getSupportFragmentManager()
          .beginTransaction()
          .add(R.id.weather_detail_container, fragment)
          .commit();
    }
  }