예제 #1
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            var view = inflater.Inflate(Resource.Layout.ParticipantSelectionLayout, container, false);

            view.FindViewById <LinearLayout> (Resource.Id.animatedLayout).LayoutTransition = new Android.Animation.LayoutTransition();

            selfFace              = view.FindViewById <ImageView> (Resource.Id.selfFace);
            otherFace             = view.FindViewById <ImageView> (Resource.Id.otherFace);
            faceLayout            = view.FindViewById <LinearLayout> (Resource.Id.userFacesLayout);
            selfFaceLayout        = view.FindViewById <FrameLayout> (Resource.Id.selfFaceLayout);
            otherFaceLayout       = view.FindViewById <FrameLayout> (Resource.Id.otherFaceLayout);
            selfFaceLayout.Drag  += HandleDrag;
            otherFaceLayout.Drag += HandleDrag;
            arrowWay              = view.FindViewById <Arrow> (Resource.Id.arrowWay);
            statsSpinner          = view.FindViewById <ProgressBar> (Resource.Id.StatsLoadSpinner);
            whatEntry             = view.FindViewById <LinearLayout> (Resource.Id.whatEntry);
            whatLayout            = view.FindViewById <LinearLayout> (Resource.Id.whatLayout);

            userDropZone = view.FindViewById <LinearLayout> (Resource.Id.whoLayout);

            var inset = view.FindViewById <InsetTextView> (Resource.Id.testInset);

            inset.Text   = "Drag Us";
            karmaBar     = view.FindViewById <KarmaMeter> (Resource.Id.karmaBar);
            flashBarCtrl = new FlashBarController(view.FindViewById(Resource.Id.flashbar));

            Task.Factory.StartNew(() => {
                var contactData = ContactsContract.Profile.ContentUri;
                var stream      = ContactsContract.Contacts.OpenContactPhotoInputStream(Activity.ContentResolver,
                                                                                        contactData,
                                                                                        false);
                if (stream != null)
                {
                    var options = new BitmapFactory.Options {
                        InPreferQualityOverSpeed = true,
                        InPreferredConfig        = Bitmap.Config.Argb8888,
                    };
                    var bmp = BitmapFactory.DecodeStream(stream, null, options);
                    Activity.RunOnUiThread(() => selfFace.SetImageBitmap(bmp));
                }
            });

            userBadge = (TapUserBadge)FragmentManager.FindFragmentById(Resource.Id.userBadge);
            CategoryBadge.StartDragValidate = () => userBadge.SelectedUser != null;
            userBadge.SelectedUserChanged  += HandleSelectedUserChanged;

            categoryPlaceholder = view.FindViewById <LinearLayout> (Resource.Id.categoryPlaceholder);
            TabTypes.GetTabTypes().ContinueWith(types => {
                var badges = types.Result
                             .Select(t => Tuple.Create(t, SvgUtils.GetBitmapFromSvgString(t.SvgImage,
                                                                                          40.ToPixels (),
                                                                                          40.ToPixels ())))
                             .ToArray();
                Activity.RunOnUiThread(() => AddTabTypeBadges(badges, inflater));
            });

            if (lastSelectedUser != null)
            {
                userBadge.RestoreSelectedUserInfo(lastSelectedUser);
            }

            return(view);
        }
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            var view = inflater.Inflate (Resource.Layout.ParticipantSelectionLayout, container, false);

            view.FindViewById<LinearLayout> (Resource.Id.animatedLayout).LayoutTransition = new Android.Animation.LayoutTransition ();

            selfFace = view.FindViewById<ImageView> (Resource.Id.selfFace);
            otherFace = view.FindViewById<ImageView> (Resource.Id.otherFace);
            faceLayout = view.FindViewById<LinearLayout> (Resource.Id.userFacesLayout);
            selfFaceLayout = view.FindViewById<FrameLayout> (Resource.Id.selfFaceLayout);
            otherFaceLayout = view.FindViewById<FrameLayout> (Resource.Id.otherFaceLayout);
            selfFaceLayout.Drag += HandleDrag;
            otherFaceLayout.Drag += HandleDrag;
            arrowWay = view.FindViewById<Arrow> (Resource.Id.arrowWay);
            statsSpinner = view.FindViewById<ProgressBar> (Resource.Id.StatsLoadSpinner);
            whatEntry = view.FindViewById<LinearLayout> (Resource.Id.whatEntry);
            whatLayout = view.FindViewById<LinearLayout> (Resource.Id.whatLayout);

            userDropZone = view.FindViewById<LinearLayout> (Resource.Id.whoLayout);

            var inset = view.FindViewById<InsetTextView> (Resource.Id.testInset);
            inset.Text = "Drag Us";
            karmaBar = view.FindViewById<KarmaMeter> (Resource.Id.karmaBar);
            flashBarCtrl = new FlashBarController (view.FindViewById (Resource.Id.flashbar));

            Task.Factory.StartNew (() => {
                var contactData = ContactsContract.Profile.ContentUri;
                var stream = ContactsContract.Contacts.OpenContactPhotoInputStream (Activity.ContentResolver,
                                                                                    contactData,
                                                                                    false);
                if (stream != null) {
                    var options = new BitmapFactory.Options {
                        InPreferQualityOverSpeed = true,
                        InPreferredConfig = Bitmap.Config.Argb8888,
                    };
                    var bmp = BitmapFactory.DecodeStream (stream, null, options);
                    Activity.RunOnUiThread (() => selfFace.SetImageBitmap (bmp));
                }
            });

            userBadge = (TapUserBadge)FragmentManager.FindFragmentById (Resource.Id.userBadge);
            CategoryBadge.StartDragValidate = () => userBadge.SelectedUser != null;
            userBadge.SelectedUserChanged += HandleSelectedUserChanged;

            categoryPlaceholder = view.FindViewById<LinearLayout> (Resource.Id.categoryPlaceholder);
            TabTypes.GetTabTypes ().ContinueWith (types => {
                var badges = types.Result
                    .Select (t => Tuple.Create (t, SvgUtils.GetBitmapFromSvgString (t.SvgImage,
                                                                                    40.ToPixels (),
                                                                                    40.ToPixels ())))
                    .ToArray ();
                Activity.RunOnUiThread (() => AddTabTypeBadges (badges, inflater));
            });

            if (lastSelectedUser != null)
                userBadge.RestoreSelectedUserInfo (lastSelectedUser);

            return view;
        }