Android Open Source - BrokenDisplay Select Picture Dialog






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.picturedialog;
/*w  ww.j ava2  s . c o m*/
import java.util.ArrayList;
import java.util.List;

import com.foolish.brokendisplay.R;

import android.content.res.Configuration;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.view.WindowManager.LayoutParams;
import android.widget.AdapterView;
import android.widget.GridView;
import android.widget.LinearLayout;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;

public class SelectPictureDialog extends DialogFragment {

  private List<Integer> pictureList;
  private IOnSelectPictureDialog mCallback;
  private GridView gridView;

  @Override
  public void onCreate(Bundle savedInstanceState) {
    if (getActivity() instanceof IOnSelectPictureDialog) {
      mCallback = (IOnSelectPictureDialog) getActivity();
    }
    super.onCreate(savedInstanceState);

  }

  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container,
      Bundle savedInstanceState) {
    // remove title bar
    getDialog().setTitle(getResources().getString(R.string.select_picture));

    LinearLayout rootView = new LinearLayout(getActivity());
    rootView.setOrientation(LinearLayout.VERTICAL);
    gridView = new GridView(getActivity());
    Configuration config = getResources().getConfiguration();
    if (config.orientation == Configuration.ORIENTATION_LANDSCAPE) {
      gridView.setNumColumns(3);
    } else {
      gridView.setNumColumns(2);
    }

    rootView.addView(gridView);
    pictureList = new ArrayList<Integer>();
    pictureList.add(R.drawable.glass1);
    pictureList.add(R.drawable.glass2);
    pictureList.add(R.drawable.glass3);
    pictureList.add(R.drawable.glass4);
    pictureList.add(R.drawable.glass5);
    pictureList.add(R.drawable.glass6);

    gridView.setAdapter(new Picture_GridAdapter(getActivity(),
        R.layout.fragment_picture_main, pictureList));

    gridView.setOnItemClickListener(new OnItemClickListener() {

      @Override
      public void onItemClick(AdapterView<?> arg0, View arg1,
          final int position, long id) {
        mCallback.onPicture(pictureList.get(position));
        getDialog().cancel();
      }

    });

    return rootView;
  }

  @Override
  public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    getDialog().getWindow().setSoftInputMode(
        WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);

    // set dialog to fill whole screen (minus padding)
    getDialog().getWindow().getAttributes().height = LayoutParams.MATCH_PARENT;
    getDialog().getWindow().getAttributes().width = LayoutParams.MATCH_PARENT;
  }

}




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