Exemple #1
0
        public override async void OnBindViewHolder(RecyclerView.ViewHolder viewHolder, int position)
        {
            var auth = _authSource.Get(position);

            if (auth == null)
            {
                return;
            }

            var holder = (AuthenticatorListHolder)viewHolder;

            holder.Issuer.Text   = auth.Issuer;
            holder.Username.Text = auth.Username;

            if (auth.Icon.StartsWith(CustomIconCache.Prefix))
            {
                var id         = auth.Icon.Substring(1);
                var customIcon = await _customIconCache.GetBitmap(id);

                if (customIcon != null)
                {
                    holder.Icon.SetImageBitmap(customIcon);
                }
                else
                {
                    holder.Icon.SetImageResource(Icon.GetService(Icon.Default, true));
                }
            }
            else
            {
                holder.Icon.SetImageResource(Icon.GetService(auth.Icon, true));
            }
        }
        public override async void OnBindViewHolder(RecyclerView.ViewHolder viewHolder, int position)
        {
            var auth = _authSource.Get(position);

            if (auth == null)
            {
                return;
            }

            var holder = (AuthenticatorListHolder)viewHolder;

            holder.Issuer.Text = auth.Issuer;

            holder.DefaultImage.Visibility = DefaultAuth != null && auth.Secret.GetHashCode() == DefaultAuth
                ? ViewStates.Visible
                : ViewStates.Gone;

            if (String.IsNullOrEmpty(auth.Username))
            {
                holder.Username.Visibility = ViewStates.Gone;
            }
            else
            {
                holder.Username.Visibility = ViewStates.Visible;
                holder.Username.Text       = auth.Username;
            }

            if (!String.IsNullOrEmpty(auth.Icon))
            {
                if (auth.Icon.StartsWith(CustomIconCache.Prefix))
                {
                    var id         = auth.Icon.Substring(1);
                    var customIcon = await _customIconCache.GetBitmap(id);

                    if (customIcon != null)
                    {
                        holder.Icon.SetImageBitmap(customIcon);
                    }
                    else
                    {
                        holder.Icon.SetImageResource(IconResolver.GetService(IconResolver.Default, true));
                    }
                }
                else
                {
                    holder.Icon.SetImageResource(IconResolver.GetService(auth.Icon, true));
                }
            }
            else
            {
                holder.Icon.SetImageResource(IconResolver.GetService(IconResolver.Default, true));
            }
        }
        private async void ItemClick(object sender, int position)
        {
            var item = _authListAdapter.Items.ElementAtOrDefault(position);

            if (item == null)
            {
                return;
            }

            var intent = new Intent(this, typeof(CodeActivity));
            var bundle = new Bundle();

            bundle.PutInt("position", position);
            bundle.PutString("nodeId", _serverNode.Id);

            bundle.PutInt("type", (int)item.Type);
            bundle.PutString("username", item.Username);
            bundle.PutString("issuer", item.Issuer);
            bundle.PutInt("period", item.Period);
            bundle.PutInt("digits", item.Digits);

            var hasCustomIcon = item.Icon.StartsWith(CustomIconCache.Prefix);

            bundle.PutBoolean("hasCustomIcon", hasCustomIcon);

            if (hasCustomIcon)
            {
                var id     = item.Icon.Substring(1);
                var bitmap = await _customIconCache.GetBitmap(id);

                bundle.PutParcelable("icon", bitmap);
            }
            else
            {
                bundle.PutString("icon", item.Icon);
            }

            intent.PutExtras(bundle);
            StartActivity(intent);
        }
Exemple #4
0
        private async void OnItemClick(object sender, int position)
        {
            var item = _authSource.Get(position);

            if (item == null)
            {
                return;
            }

            var intent = new Intent(this, typeof(CodeActivity));
            var bundle = new Bundle();

            bundle.PutInt("type", (int)item.Type);
            bundle.PutString("issuer", item.Issuer);
            bundle.PutString("username", item.Username);
            bundle.PutString("issuer", item.Issuer);
            bundle.PutInt("period", item.Period);
            bundle.PutInt("digits", item.Digits);
            bundle.PutString("secret", item.Secret);
            bundle.PutInt("algorithm", (int)item.Algorithm);

            var hasCustomIcon = !String.IsNullOrEmpty(item.Icon) && item.Icon.StartsWith(CustomIconCache.Prefix);

            bundle.PutBoolean("hasCustomIcon", hasCustomIcon);

            if (hasCustomIcon)
            {
                var id     = item.Icon.Substring(1);
                var bitmap = await _customIconCache.GetBitmap(id);

                bundle.PutParcelable("icon", bitmap);
            }
            else
            {
                bundle.PutString("icon", item.Icon);
            }

            intent.PutExtras(bundle);
            StartActivity(intent);
        }