Android Open Source - trivial-lists Item Fragment






From Project

Back to project page trivial-lists.

License

The source code is released under:

MIT License

If you think the Android project trivial-lists 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 org.hbabcock.triviallists;
//from   w  ww . ja v  a 2  s.c o  m
import java.util.UUID;

import android.annotation.TargetApi;
import android.os.Build;
import android.os.Bundle;
import android.support.v4.app.ListFragment;
import android.support.v4.app.NavUtils;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;

public class ItemFragment extends ListFragment {
  private static final String TAG = "ItemFragment";

  public static final String EXTRA_CATEGORY_ID = "org.hbabcock.triviallist.category_id";

  private Category mCategory;

  // Classes.  
  protected Category getCategory(){
    return mCategory;
  }
      
  @Override
  public void onCreate(Bundle savedInstanceState){
    super.onCreate(savedInstanceState);
    Log.i(TAG, "onCreate");
    
    setHasOptionsMenu(true);

    mCategory = CategoryItemManager.get(getActivity()).getCategory((UUID)getArguments().getSerializable(EXTRA_CATEGORY_ID));
    getActivity().setTitle(mCategory.getName());    
  }

  @TargetApi(11)
  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup parent, Bundle savedInstanceState){
    Log.i(TAG, "onCreateView");
    View v = inflater.inflate(R.layout.item_fragment, parent, false);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB){
      if (NavUtils.getParentActivityName(getActivity()) != null){
        getActivity().getActionBar().setDisplayHomeAsUpEnabled(true);
      }
    }
    
    return v;
  }

  @Override
  public boolean onOptionsItemSelected(MenuItem item){
    switch (item.getItemId()){
    case android.R.id.home:
      if (NavUtils.getParentActivityName(getActivity()) != null){
        NavUtils.navigateUpFromSameTask(getActivity());
      }
      return true;
    default:
      return super.onOptionsItemSelected(item);      
    }
  }

  public static Bundle setBundle(UUID categoryId){
    Bundle args = new Bundle();
    args.putSerializable(EXTRA_CATEGORY_ID, categoryId);
    return args;
  }

}




Java Source Code List

org.hbabcock.triviallists.CategoryActivity.java
org.hbabcock.triviallists.CategoryDeleteDialog.java
org.hbabcock.triviallists.CategoryFragment.java
org.hbabcock.triviallists.CategoryItemManager.java
org.hbabcock.triviallists.Category.java
org.hbabcock.triviallists.GenericEditorDialogFragment.java
org.hbabcock.triviallists.ItemFragmentEdit.java
org.hbabcock.triviallists.ItemFragmentShop.java
org.hbabcock.triviallists.ItemFragment.java
org.hbabcock.triviallists.ItemPagerActivity.java
org.hbabcock.triviallists.Item.java
org.hbabcock.triviallists.SingleFragmentActivity.java
org.hbabcock.triviallists.TrivialListJSONSerializer.java