Пример #1
0
        internal void HandleFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY)
        {
            if (categoryListRect.Contains((int)e1.GetX(), (int)e1.GetY()))
            {
                if (categoriesReady)
                {
                    if (Math.Abs(velocityY) > Math.Abs(velocityX) && Math.Abs(velocityY) > 2000)
                    {
                        Log.Info(TAG, "vertical fling inside category list, vy=" + velocityY + ", state=" + categoryListState);

                        // vertical fling, so valid
                        if (velocityY < 0 && categoryListState == categoryListStates.Hidden)
                        {
                            Log.Info(TAG, "show category list");
                            RefreshCategories(false);
                            categoryListState = categoryListStates.Showing;
                            categoryListAnimator.SetIntValues(mContext.Resources.DisplayMetrics.HeightPixels, 0);
                            categoryListAnimator.Start();
                        }
                        if (velocityY > 0 && categoryListState == categoryListStates.Shown)
                        {
                            Log.Info(TAG, "hide category list");
                            currentCategoryIndex    = -1;
                            oldCurrentCategoryIndex = -1;
                            currentCategoryRect     = null;
                            categoryListState       = categoryListStates.Hiding;
                            categoryListAnimator.SetIntValues(0, mContext.Resources.DisplayMetrics.HeightPixels);
                            categoryListAnimator.Start();
                        }
                    }
                }
                else
                {
                    Log.Info(TAG, "ignore category action, categories not ready");
                }
            }
            else
            {
                Log.Info(TAG, "fling outside category list " + categoryListRect);
                PrepareCurrentBitmap(velocityX > 0 ? -1 : 1);
                //AdjustButton(e1, e2, velocityX, velocityY);
            }
        }
Пример #2
0
        private void init(Context ctx)
        {
            mContext = ctx;

            LoadPreferences();

            displayWidth     = ctx.Resources.DisplayMetrics.WidthPixels;
            displayHeight    = ctx.Resources.DisplayMetrics.HeightPixels;
            categoryListRect = new Rect(0, 0, (int)(displayWidth * categoryListProportion), displayHeight);
            tagWheelRect     = new Rect(categoryListRect.Width(), 0, displayWidth, displayWidth - categoryListRect.Width());
            categoryRects    = new List <Rect>();
            tagRects         = new List <Rect>();

            // create animators
            {
                categoryListAnimator = new ValueAnimator();
                categoryListAnimator.SetDuration(categoryListAnimationPeriod);
                categoryListAnimator.SetInterpolator(new DecelerateInterpolator());
                categoryListAnimator.SetIntValues(0, ctx.Resources.DisplayMetrics.HeightPixels);
                categoryListAnimator.Update += (sender, e) => {
                    categoryListTop = (int)e.Animation.AnimatedValue;
                    Invalidate();
                };
                categoryListAnimator.AnimationEnd += (sender, e) => {
                    categoryListState = categoryListState == categoryListStates.Hiding
                        ? categoryListStates.Hidden
                        : categoryListStates.Shown;
                };

                currentCategoryXAnimator = new ValueAnimator();
                currentCategoryXAnimator.SetDuration(categorySelectionAnimationPeriod);
                currentCategoryXAnimator.SetInterpolator(new DecelerateInterpolator());
                currentCategoryXAnimator.Update += (sender, e) => {
                    currentCategoryX = (int)e.Animation.AnimatedValue;
                    Invalidate();
                };

                currentCategoryYAnimator = new ValueAnimator();
                currentCategoryYAnimator.SetDuration(categorySelectionAnimationPeriod);
                currentCategoryYAnimator.SetInterpolator(new DecelerateInterpolator());
                currentCategoryYAnimator.Update += (sender, e) => {
                    currentCategoryY = (int)e.Animation.AnimatedValue;
                    Invalidate();
                };

                oldCurrentCategoryXAnimator = new ValueAnimator();
                oldCurrentCategoryXAnimator.SetDuration(categorySelectionAnimationPeriod);
                oldCurrentCategoryXAnimator.SetInterpolator(new DecelerateInterpolator());
                oldCurrentCategoryXAnimator.Update += (sender, e) => {
                    oldCurrentCategoryX = (int)e.Animation.AnimatedValue;
                    Invalidate();
                };
                oldCurrentCategoryXAnimator.AnimationEnd += (sender, e) => {
                    oldCurrentCategoryIndex = -1;
                };

                oldCurrentCategoryYAnimator = new ValueAnimator();
                oldCurrentCategoryYAnimator.SetDuration(categorySelectionAnimationPeriod);
                oldCurrentCategoryYAnimator.SetInterpolator(new DecelerateInterpolator());
                oldCurrentCategoryYAnimator.Update += (sender, e) => {
                    oldCurrentCategoryY = (int)e.Animation.AnimatedValue;
                };

                tagLabelRadiusAnimator = new ValueAnimator();
                tagLabelRadiusAnimator.SetDuration(categorySelectionAnimationPeriod);
                tagLabelRadiusAnimator.SetInterpolator(new DecelerateInterpolator());
                tagLabelRadiusAnimator.Update += (sender, e) => {
                    tagLabelRadius = (int)e.Animation.AnimatedValue;
                };

                tagStartAngleAnimator = new ValueAnimator();
                tagStartAngleAnimator.SetDuration(categorySelectionAnimationPeriod);
                tagStartAngleAnimator.SetInterpolator(new DecelerateInterpolator());
                tagStartAngleAnimator.SetFloatValues((float)Math.PI / 2, 0);
                tagStartAngleAnimator.Update += (sender, e) => {
                    tagStartAngle = (float)e.Animation.AnimatedValue;
                };
            }

            displayScale = ctx.Resources.DisplayMetrics.Density;

            // prepare the current directory, if any
            PrepareDirectory();

            //if (!PrepareCurrentBitmap(0)) {

            /*
             *  var file_activity = new Intent(mContext, typeof(SelectFileActivity));
             *  file_activity.PutExtra("directoriesOnly", true);
             *
             *  // load will trigger if dir chosen
             *  ((MainActivity)mContext).StartActivityForResult(file_activity, MainActivity.directorySelection);
             */

            //}
        }