Example #1
0
 protected override void OnDestroy()
 {
     MediaStoreCompat.Destroy();
     albumCollection.OnDestroy();
     mPhotoCollection.OnDestroy();
     base.OnDestroy();
 }
Example #2
0
        public override Object LoadInBackground()
        {
            var data = base.LoadInBackground();

            if (!mEnableCapture || !MediaStoreCompat.HasCameraFeature(Context))
            {
                return(data);
            }

            var          result = data as Cursor;
            MatrixCursor dummy  = new MatrixCursor(PROJECTION);

            dummy.AddRow(new Object[] { Picture.ITEM_ID_CAPTURE, Picture.ITEM_DISPLAY_NAME_CAPTURE });
            return(new MergeCursor(new Cursor[] { dummy, result }));
        }
Example #3
0
 protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
 {
     base.OnActivityResult(requestCode, resultCode, data);
     if (requestCode == REQUEST_CODE_CAPTURE && resultCode == Result.Ok)
     {
         Uri captured = MediaStoreCompat.GetCapturedPhotoUri(data, mCapturePhotoUriHolder);
         if (captured != null)
         {
             UriSelecteds.Add(captured);
             MediaStoreCompat.CleanUp(mCapturePhotoUriHolder);
             if (UriSelecteds.IsSingleChoose)
             {
                 SetResult();
             }
         }
     }
 }
Example #4
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.ImageSelect);

            mOnClickFoldName = new AnonymousOnClickListener((v) => {
                if (mListViewGroup.Visibility == ViewStates.Visible)
                {
                    HideFolderList();
                }
                else
                {
                    ShowFolderList();
                }
            });

            mCapturePhotoUriHolder = savedInstanceState != null?savedInstanceState.GetString(STATE_CAPTURE_PHOTO_URI) : "";

            var Extra_selection = Intent.GetParcelableExtra(ImageSelectActivity.EXTRA_SELECTION_SPEC);

            selectionSpec = Extra_selection as SelectionSpec;
            //  selectionSpec = (SelectionSpec)Intent.GetParcelableExtra(ImageSelectActivity.EXTRA_SELECTION_SPEC);
            MediaStoreCompat = new MediaStoreCompat(this, new Handler(Looper.MainLooper));

            UriSelecteds.OnCreate(savedInstanceState);
            UriSelecteds.PrepareSelectionSpec(selectionSpec);

            var Extra_uris = Intent.GetParcelableArrayListExtra(EXTRA_RESUME_LIST);
            var uris       = Extra_uris as IEnumerable <Uri>;

            if (uris != null)
            {
                UriSelecteds.AddRange(uris);
            }

            UriSelecteds.SetOnSelectionChange(new SelectionChange(commit));

            mGridView      = (GridView)FindViewById(Resource.Id.gridView);
            mListView      = (ListView)FindViewById(Resource.Id.listView);
            btnBack        = (ImageView)FindViewById(Resource.Id.btn_back);
            mListViewGroup = FindViewById(Resource.Id.listViewParent);
            mListViewGroup.SetOnClickListener(mOnClickFoldName);
            mFoldName  = (TextView)FindViewById(Resource.Id.foldName);
            galleryTip = (ImageView)FindViewById(Resource.Id.gallery_tip);
            LinearLayout selectFold = (LinearLayout)FindViewById(Resource.Id.selectFold);

            commit = (Button)FindViewById(Resource.Id.commit);
            commit.SetText("确定(0/" + selectionSpec.MaxSelectable + ")", TextView.BufferType.Normal);
            if (selectionSpec.IsSingleChoose)
            {
                commit.Visibility = ViewStates.Gone;
            }
            mFoldName.SetText("最近图片", TextView.BufferType.Normal);
            selectFold.SetOnClickListener(mOnClickFoldName);

            albumCollection.OnCreate(this, this, selectionSpec, mListView);
            albumCollection.LoadAlbums();
            mPhotoCollection.OnCreate(this, mGridView, UriSelecteds, selectionSpec);
            mPhotoCollection.LoadAllPhoto();

            commit.SetOnClickListener(new AnonymousOnClickListener((v) =>
            {
                if (UriSelecteds.IsEmpty)
                {
                    Toast.MakeText(ApplicationContext, "未选择图片", ToastLength.Long).Show();
                }
                else
                {
                    SetResult();
                }
            }));

            btnBack.SetOnClickListener(new AnonymousOnClickListener((v) => this.Finish()));

            if (selectionSpec.WillStartCamera())
            {
                ShowCameraAction();
            }
        }
Example #5
0
 /**
  * 选择相机
  */
 public void ShowCameraAction()
 {
     mCapturePhotoUriHolder = MediaStoreCompat.InvokeCameraCapture(this, ImageSelectActivity.REQUEST_CODE_CAPTURE);
 }