@Override
  public void onItemSelected(String ean) {
    if (IS_TABLET) {
      // Replace right container fragment for larger devices.
      Bundle args = new Bundle();
      args.putString(BookDetail.EAN_KEY, ean);

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

      int id = R.id.container;
      if (findViewById(R.id.right_container) != null) {
        id = R.id.right_container;
      }

      getSupportFragmentManager()
          .beginTransaction()
          .replace(id, fragment)
          .addToBackStack("Book Detail")
          .commit();
    } else {
      // Start new activity for smaller devices.
      Intent intent = new Intent(this, BookDetailActivity.class);
      intent.putExtra(BookDetail.EAN_KEY, ean);
      startActivity(intent);
    }
  }
Example #2
0
 private void initBookDetailFragment() {
   String ean = getIntent().getStringExtra(BookDetail.EAN_KEY);
   Bundle args = new Bundle();
   args.putString(BookDetail.EAN_KEY, ean);
   BookDetail bookDetail = new BookDetail();
   bookDetail.setArguments(args);
   getSupportFragmentManager().beginTransaction().replace(R.id.container1, bookDetail).commit();
 }
Example #3
0
  @Override
  public void onItemSelected(String ean) {
    Bundle args = new Bundle();
    args.putString(BookDetail.EAN_KEY, ean);

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

    int id = R.id.container;
    if (findViewById(R.id.right_container) != null) {
      id = R.id.right_container;
    }
    getSupportFragmentManager()
        .beginTransaction()
        .replace(id, fragment)
        .addToBackStack("Book Detail")
        .commit();
  }
Example #4
0
  @Override
  public void onItemSelected(String ean) {
    Bundle args = new Bundle();
    args.putString(BookDetail.EAN_KEY, ean);

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

    // AlexSt: used 'add' instead of 'replace' to allow fast return to the 'ListOfBooks'
    // fragment. When using 'replace' fragment 'ListOfBooks' needs to be recreated which takes
    // longer time. Changed background of BookDetails to be non-transparent to not overlap
    // 'ListOfBooks' fragment.
    FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
    String fragmentTag = BookDetail.class.getSimpleName();
    if (findViewById(R.id.right_container) != null) {
      args.putBoolean(BookDetail.BACK_BUTTON_VISIBLE, false);
      transaction = transaction.replace(R.id.right_container, fragment, fragmentTag);
    } else {
      transaction = transaction.add(R.id.container, fragment, fragmentTag).addToBackStack(null);
    }
    transaction.commit();
  }