public EffectsAdapter(Context context)
        {
            MInflater = LayoutInflater.From(context);

            Resources res = context.Resources;

            MTitles = res.GetStringArray(Resource.Array.effects_name);

            string[] actionsHtml = res.GetStringArray(Resource.Array.effects_actions_html);
            string[] contentHtml = res.GetStringArray(Resource.Array.effects_content_html);

            MHtmls = new string[][] { actionsHtml, contentHtml };

            TypedArray layoutsArray = res.ObtainTypedArray(Resource.Array.effect_layouts);

            int count = layoutsArray.Length();

            MLayouts = new int[count];

            for (int i = 0; i < count; ++i)
            {
                MLayouts[i] = layoutsArray.GetResourceId(i, 0);
            }

            layoutsArray.Recycle();
        }
Ejemplo n.º 2
0
        public void SetEffects(Context context, int resId)
        {
            string resourceType = context.Resources.GetResourceTypeName(resId);

            if (!resourceType.Equals("array"))
            {
                Animation anim = AnimationUtils.LoadAnimation(context, resId);
                SetEffects(anim);

                return;
            }

            TypedArray effects = context.Resources.ObtainTypedArray(resId);

            int count = effects.Length();
            int size  = System.Math.Min(EFFECTS_COUNT, count);

            for (int i = 0; i < size; ++i)
            {
                int id = effects.GetResourceId(i, -1);
                if (id > 0)
                {
                    Animation anim = AnimationUtils.LoadAnimation(context, id);
                    mEffects[i] = new Effect(anim);
                }
            }
            effects.Recycle();
        }
Ejemplo n.º 3
0
        private void InitView()
        {
            parentLayout = FindViewById <RelativeLayout>(Resource.Id.demo_parent);
            imageView    = FindViewById <ImageView>(Resource.Id.demo_image);
            listView     = FindViewById <ListView>(Resource.Id.demo_list);
            myView       = FindViewById <MyView>(Resource.Id.demo_myview);
            button       = FindViewById <Button>(Resource.Id.demo_button);

            button.Click += delegate
            { Toast.MakeText(this, "Button onClick", ToastLength.Short).Show(); };
            TypedArray ar  = Resources.ObtainTypedArray(Resource.Array.imgArray);
            int        len = ar.Length();

            resids = new List <int>();
            for (int i = 0; i < len; i++)
            {
                resids.Add(ar.GetResourceId(i, 0));
            }

            InitSeekBar();
            InitToggleButton();
            InitToolbar();
            InitDrawerLayout();
            RefreshDate();
        }
        private Drawable[] LoadScreenIcons()
        {
            TypedArray ta = Resources.ObtainTypedArray(Resource.Array.ld_activityScreenIcons);

            Drawable[] icons = new Drawable[ta.Length()];

            for (int i = 0; i < ta.Length(); i++)
            {
                int id = ta.GetResourceId(i, 0);

                if (id != 0)
                {
                    icons[i] = ContextCompat.GetDrawable(this, id);
                }
            }

            ta.Recycle();

            return(icons);
        }
Ejemplo n.º 5
0
        int[] GetResourceIdArray(int arrayResId)
        {
            TypedArray ar  = Context.Resources.ObtainTypedArray(arrayResId);
            int        len = ar.Length();

            int[] resIds = new int[len];
            for (int i = 0; i < len; i++)
            {
                resIds[i] = ar.GetResourceId(i, 0);
            }
            ar.Recycle();
            return(resIds);
        }
        public override Dialog OnCreateDialog(Bundle savedInstanceState)
        {
            MaterialDialog dialog = (new MaterialDialog.Builder(Activity)).SetTitle(Resource.String.color_chooser).SetAutoDismiss(false).SetCustomView(Resource.Layout.dialog_color_chooser, false).Build();

            TypedArray ta = Activity.Resources.ObtainTypedArray(Resource.Array.colors);

            mColors = new Color[ta.Length()];
            for (int i = 0; i < ta.Length(); i++)
            {
                mColors[i] = ta.GetColor(i, 0);
            }
            ta.Recycle();
            GridLayout list      = (GridLayout)dialog.CustomView.FindViewById(Resource.Id.grid);
            int        preselect = Arguments.GetInt("preselect", -1);

            for (int i = 0; i < list.ChildCount; i++)
            {
                FrameLayout child = (FrameLayout)list.GetChildAt(i);
                child.Tag = i;
                child.SetOnClickListener(this);
                child.GetChildAt(0).Visibility = preselect == i ? ViewStates.Visible : ViewStates.Gone;

                Drawable selector = CreateSelector(mColors[i]);
                if (Build.VERSION.SdkInt >= BuildVersionCodes.Lollipop)
                {
                    int[][]        states       = new int[][] { new int[] { -Android.Resource.Attribute.StatePressed }, new int[] { Android.Resource.Attribute.StatePressed } };
                    int[]          colors       = new int[] { ShiftColor(mColors[i]), mColors[i] };
                    ColorStateList rippleColors = new ColorStateList(states, colors);
                    SetBackgroundCompat(child, new RippleDrawable(rippleColors, selector, null));
                }
                else
                {
                    SetBackgroundCompat(child, selector);
                }
            }
            return(dialog);
        }
        public ActionsAdapter(Context context)
        {
            MInflater = LayoutInflater.From(context);

            Resources res = context.Resources;

            MTitles = res.GetStringArray(Resource.Array.actions_names);
            MUrls   = res.GetStringArray(Resource.Array.actions_links);

            TypedArray iconsArray = res.ObtainTypedArray(Resource.Array.actions_icons);
            int        count      = iconsArray.Length();

            MIcons = new int[count];
            for (int i = 0; i < count; ++i)
            {
                MIcons[i] = iconsArray.GetResourceId(i, 0);
            }
            iconsArray.Recycle();
        }
Ejemplo n.º 8
0
        public override void OnBindViewHolder(Android.Support.V7.Preferences.PreferenceViewHolder holder)
        {
            base.OnBindViewHolder(holder);

            if (Build.VERSION.SdkInt >= BuildVersionCodes.Lollipop)
            {
                return;
            }

            var titleView = (TextView)holder.FindViewById(Android.Resource.Id.Title);

            if (titleView == null)
            {
                return;
            }

            TypedArray typedArray = null;

            try
            {
                //http://stackoverflow.com/questions/27611173/how-to-get-accent-color-programmatically
                var colorAttrId = Context.Resources.GetIdentifier("colorAccent", "attr", Context.PackageName);
                if (colorAttrId <= 0)
                {
                    return;
                }

                typedArray = Context.ObtainStyledAttributes(new[] { colorAttrId });
                if (typedArray == null || typedArray.Length() <= 0)
                {
                    return;
                }

                var accentColor = typedArray.GetColor(0, 0xff4081); // defaults to pink
                titleView.SetTextColor(accentColor);
            }
            finally
            {
                typedArray?.Recycle();
            }
        }
Ejemplo n.º 9
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            mRootView = (RelativeLayout)inflater.Inflate(Resource.Layout.fragment_bloom, container, false);

            mCircles = new View[6];

            float diameter = TypedValue.ApplyDimension(ComplexUnitType.Dip, DIAMETER, Resources.DisplayMetrics);

            TypedArray circles = Resources.ObtainTypedArray(Resource.Array.circles);

            // layout params
            RelativeLayout.LayoutParams paramss = new RelativeLayout.LayoutParams((int)diameter, (int)diameter);
            paramss.AddRule(LayoutRules.CenterInParent);

            // create the circle views
            int colorIndex = 0;

            for (int i = 0; i < mCircles.Length; i++)
            {
                mCircles[i] = new View(Activity);

                mCircles[i].LayoutParameters = paramss;

                mCircles[i].SetBackgroundDrawable(Resources.GetDrawable(circles.GetResourceId(colorIndex, -1)));

                colorIndex++;
                if (colorIndex >= circles.Length())
                {
                    colorIndex = 0;
                }

                mRootView.AddView(mCircles[i]);
            }

            circles.Recycle();

            /* Animations! */

            SpringSystem springSystem = SpringSystem.Create();

            // create spring
            Spring spring = springSystem.CreateSpring();

            // add listeners along arc
            double arc = 2 * Math.PI / mCircles.Length;

            for (int i = 0; i < mCircles.Length; i++)
            {
                View view = mCircles[i];

                // map spring to a line segment from the center to the edge of the ring
                spring.AddListener(new MapPerformer(view, ViewHelper.TranslationX, 0, 1, 0, (float)(RING_DIAMETER * Math.Cos(i * arc))));

                spring.AddListener(new MapPerformer(view, ViewHelper.TranslationY, 0, 1, 0, (float)(RING_DIAMETER * Math.Sin(i * arc))));

                spring.SetEndValue(CLOSED);
            }

            mRootView.SetOnTouchListener(new ToggleImitator(spring, CLOSED, OPEN));

            return(mRootView);
        }