예제 #1
0
  private boolean setMediaList(MediaList value) {

    // check instance
    if (m_MediaList == value) return false;

    // detach from previous media list
    if (m_MediaList != null) {
      m_MediaList.removeHandler(MediaList.EVENT_MEDIA_ADDED, m_MediaAddedHandler);
      m_MediaList.removeHandler(MediaList.EVENT_MEDIA_REMOVED, m_MediaRemovedHandler);
    }

    // attach to new media list
    m_MediaList = value;
    if (m_MediaList == null) Log.d(TAG, "m_MediaList value null");
    else {
      Log.d(TAG, "m_MediaList value");
      m_MediaList.addHandler(MediaList.EVENT_MEDIA_ADDED, m_MediaAddedHandler);
      m_MediaList.addHandler(MediaList.EVENT_MEDIA_REMOVED, m_MediaRemovedHandler);
    }

    // update UI
    if (m_GridViewItemAdapter != null) m_GridViewItemAdapter.notifyDataSetChanged();
    if (value != null && !value.isEmpty()) this.showGridView();
    else this.showNoMedia();

    // complete
    return true;
  }
예제 #2
0
  // Create view.
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    Log.d(TAG, "onCreateView");
    View view = inflater.inflate(R.layout.fragment_gridview, container, false);
    m_GridView = (GridView) view.findViewById(R.id.gridview);
    if (m_GridViewItemAdapter == null)
      m_GridViewItemAdapter = new GridViewItemAdapter(this.getActivity());
    m_GridView.setAdapter(m_GridViewItemAdapter);
    m_GridView.setOnItemClickListener(
        new OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            Log.d(TAG, "gridview onItemClick event item position:" + position);
            Toast.makeText(GridViewFragment.this.getActivity(), "" + position, Toast.LENGTH_SHORT)
                .show();
            onItemClicked(position, view);
          }
        });

    m_NoMediaView = view.findViewById(R.id.no_photo);
    m_NoMediaView.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            Intent intent = new Intent("android.media.action.STILL_IMAGE_CAMERA");
            startActivity(intent);
          }
        });

    if (m_MediaList != null && !m_MediaList.isEmpty()) this.showGridView();
    else this.showNoMedia();

    return view;
  }
예제 #3
0
 public Object getItem(int position) {
   Log.d(TAG, "getItem position: " + position);
   if (m_MediaList != null) {
     if (get(PROP_IS_CAMERA_ROLL)) {
       if (position == 0) return null;
       return m_MediaList.get(position - 1);
     }
     return m_MediaList.get(position);
   }
   return null;
 }
예제 #4
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    Log.d(TAG, "onCreate");
    m_GridviewItemHeight = this.getResources().getDimensionPixelSize(R.dimen.gridview_item_height);
    m_GridviewItemWidth = this.getResources().getDimensionPixelSize(R.dimen.gridview_item_width);

    // Prepare greySquare
    m_GreySquare = new SquareDrawable(m_GridviewItemWidth, m_GridviewItemHeight);
  }
예제 #5
0
 @Override
 public void onDestroyView() {
   Log.d(TAG, "onDestroyView");
   // clear references
   if (m_GridView != null) {
     m_GridView.setAdapter(null);
     m_GridView = null;
   }
   m_NoMediaView = null;
   // call super
   super.onDestroyView();
 }
예제 #6
0
 public long getItemId(int position) {
   Log.d(TAG, "getItemId position: " + position);
   return position;
 }
예제 #7
0
 @Override
 public void onActivityCreated(Bundle savedInstanceState) {
   super.onActivityCreated(savedInstanceState);
   Log.d(TAG, "onActivityCreated");
 }
예제 #8
0
 @Override
 public void onAttach(Activity activity) {
   super.onAttach(activity);
   Log.d(TAG, "onAttach");
 }
예제 #9
0
 private void onInitialize() {
   Log.d(TAG, "onInitialize");
 }
예제 #10
0
 @Override
 public void onResume() {
   // TODO Auto-generated method stub
   super.onResume();
   Log.d(TAG, "onResume");
 }