Android Open Source - BrokenDisplay Item Detail Fragment






From Project

Back to project page BrokenDisplay.

License

The source code is released under:

Apache License

If you think the Android project BrokenDisplay listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.foolish.brokendisplay;
//  w  w  w.j  a v a  2s .  c o  m
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentTransaction;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.foolish.brokendisplay.dummy.DummyContent;

/**
 * A fragment representing a single Item detail screen. This fragment is either
 * contained in a {@link ItemListActivity} in two-pane mode (on tablets) or a
 * {@link ItemDetailActivity} on handsets.
 */
public class ItemDetailFragment extends Fragment {
  /**
   * The fragment argument representing the item ID that this fragment
   * represents.
   */
  public static final String ARG_ITEM_ID = "item_id";

  /**
   * The dummy content this fragment is presenting.
   */
  private DummyContent.DummyItem mItem;

  /**
   * Mandatory empty constructor for the fragment manager to instantiate the
   * fragment (e.g. upon screen orientation changes).
   */
  public ItemDetailFragment() {
  }

  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    if (getArguments().containsKey(ARG_ITEM_ID)) {
      // Load the dummy content specified by the fragment
      // arguments. In a real-world scenario, use a Loader
      // to load content from a content provider.
      mItem = DummyContent.ITEM_MAP.get(getArguments().getString(
          ARG_ITEM_ID));
    }
  }

  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container,
      Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_item_detail,
        container, false);

    // Show the dummy content as text in a TextView.
    if (mItem != null) {
      ((TextView) rootView.findViewById(R.id.item_detail))
          .setText(mItem.content);
    }
    if (mItem.id.equals("1")) {
      ((TextView) rootView.findViewById(R.id.item_detail))
          .setVisibility(View.GONE);
      Fragment gridViewFragment = new OverviewFragment();
      FragmentTransaction transaction = getChildFragmentManager()
          .beginTransaction();
      transaction.add(R.id.fragment_item_detail_container,
          gridViewFragment);
      transaction.addToBackStack(null);
      transaction.commit();

    }
    return rootView;

  }
}




Java Source Code List

com.foolish.brokendisplay.BrokenDisplayActivity.java
com.foolish.brokendisplay.BrokenGlassService.java
com.foolish.brokendisplay.ItemDetailActivity.java
com.foolish.brokendisplay.ItemDetailFragment.java
com.foolish.brokendisplay.ItemListActivity.java
com.foolish.brokendisplay.ItemListFragment.java
com.foolish.brokendisplay.MyImageView.java
com.foolish.brokendisplay.OnSwipeTouchListener.java
com.foolish.brokendisplay.OverlayEditorActivity.java
com.foolish.brokendisplay.OverlayEditorFragment.java
com.foolish.brokendisplay.OverviewFragment.java
com.foolish.brokendisplay.dummy.DummyContent.java
com.foolish.brokendisplay.picturedialog.BitmapWorkerTask.java
com.foolish.brokendisplay.picturedialog.IOnSelectPictureDialog.java
com.foolish.brokendisplay.picturedialog.Picture_GridAdapter.java
com.foolish.brokendisplay.picturedialog.SelectPictureDialog.java