コード例 #1
0
        public override RecyclerView.ViewHolder OnCreateViewHolder(ViewGroup parent, int viewType)
        {
            // Inflate the CardView for the photo:
            View itemView = LayoutInflater.From(parent.Context).Inflate(Resource.Layout.custom_service_item, parent, false);
            // Create a ViewHolder to hold view references inside the CardView:
            ServiceViewHolder vh = new ServiceViewHolder(itemView);

            return(vh);
        }
コード例 #2
0
        public override void OnBindViewHolder(RecyclerView.ViewHolder holder, int position)
        {
            ServiceViewHolder vh = holder as ServiceViewHolder;

            Picasso.Get()
            .Load(serviceList[position].image_url)
            //.Placeholder(Resource.Drawable.body_service)
            .Error(Resource.Drawable.body_service)
            .Into(vh);
            vh.serviceNameTxtView.Text = serviceList[position].serviceName;
            vh.durationTxtView.Text    = serviceList[position].duration.ToString();
        }
コード例 #3
0
        public override void OnBindViewHolder(RecyclerView.ViewHolder holder, int position)
        {
            ServiceViewHolder vh = holder as ServiceViewHolder;

            if (!string.IsNullOrEmpty(serviceList[position].image_url))
            {
                Picasso.Get().Load(serviceList[position].image_url)
                //.Placeholder(R    esource.Drawable.body_service)
                .Error(Resource.Drawable.body_service).Into(vh.imageBackground);
            }

            vh.serviceNameTxtView.Text = serviceList[position].serviceName;
            vh.durationTxtView.Text    = serviceList[position].duration.ToString();
            vh.serviceID = serviceList[position].id;
            vh.presenter = this.presenter;
        }
        /*    public override string this[int position]
         *  {
         *      get
         *      {
         *          return nItems[position];
         *      }
         *
         *  }*/
        public override View GetView(int position, View convertView, ViewGroup parent)
        {
            ServiceViewHolder holder = null;

            var view = convertView;

            if (view == null)

            {
                view                = LayoutInflater.From(nContext).Inflate(Resource.Layout.CustomRow, null, false);
                holder              = new ServiceViewHolder();
                holder.Text         = view.FindViewById <TextView>(Resource.Id.wordtext);
                holder.Type         = view.FindViewById <TextView>(Resource.Id.wordtype);
                holder.Tone         = view.FindViewById <TextView>(Resource.Id.wordtone1);
                holder.EditButton   = view.FindViewById <ImageButton>(Resource.Id.Editbutton1);
                holder.DeleteButton = view.FindViewById <ImageButton>(Resource.Id.deletebutton1);


                holder.PlayButton = view.FindViewById <ImageButton>(Resource.Id.playbutton1);
                view.Tag          = holder;
            }
            else
            {
                holder = view.Tag as ServiceViewHolder;
            }
            worditem = nItems[position];
            var item = nItems[position];

            holder.Text.Text           = "   " + worditem.Text;
            holder.Type.Text           = "   " + "(" + (worditem.Type).ToString() + ".)";
            holder.Tone.Text           = "    " + "[" + worditem.Tone + " Tone" + "]";
            holder.DeleteButton.Click += (object sender, EventArgs e) =>
            {
                DataRepository.Words.Delete(item);
                //  await DataRepository.Words.Delete(item);
                nItems.RemoveAt(position);
                NotifyDataSetChanged();
                Toast.MakeText(this.nContext, item.Text.ToString() + "     " + "Deleted", ToastLength.Short).Show();
            };


            //   holder.DeleteButton.Click += remove_word;
            holder.EditButton.Click += (object sender, EventArgs e) =>
            {
                holder.Text.SetText("   " + item.Text, TextView.BufferType.Normal);
                holder.Type.SetText(("   " + "(" + item.Type).ToString() + ".)", TextView.BufferType.Normal);
                holder.Tone.SetText("    " + "[" + item.Tone + " Tone" + "]", TextView.BufferType.Normal);
                holder.EditButton.Focusable            = false;
                holder.EditButton.FocusableInTouchMode = false;
                holder.EditButton.Clickable            = true;
                var    word  = new Intent(this.nContext, typeof(Audio3));
                string alpha = item.Id.ToString();
                word.PutExtra("Id", alpha);

                // a.DataRepository.Words.Update(worditem);
                nContext.StartActivity(word);
                //Todo - implement edit Service
            };
            holder.PlayButton.Click += (object sender, EventArgs e) =>
            {
                string      a       = item.Audio; //getting  path from database
                MediaPlayer _player = new MediaPlayer();
                _player.SetDataSource(a);         //paassng a path to play

                _player.Prepare();
                _player.Start();
                //Todo - implement edit Service
            };
            // }


            return(view);
        }
        /*    public override string this[int position]
         *  {
         *      get
         *      {
         *          return nItems[position];
         *      }
         *
         *  }*/
        public override View GetView(int position, View convertView, ViewGroup parent)
        {
            ServiceViewHolder holder = null;

            var view = convertView;

            if (view == null)

            {
                view        = LayoutInflater.From(nContext).Inflate(Resource.Layout.CustomRow2, null, false);
                holder      = new ServiceViewHolder();
                holder.Text = view.FindViewById <TextView>(Resource.Id.stext);

                holder.EditButton   = view.FindViewById <ImageButton>(Resource.Id.Editbutton2);
                holder.DeleteButton = view.FindViewById <ImageButton>(Resource.Id.deletebutton2);


                holder.PlayButton = view.FindViewById <ImageButton>(Resource.Id.playbutton2);
                view.Tag          = holder;
            }
            else
            {
                holder = view.Tag as ServiceViewHolder;
            }
            sentenceitem = nItems[position];
            var item = nItems[position];

            holder.Text.Text = "   " + sentenceitem.Text;

            holder.DeleteButton.Click += async(object sender, EventArgs e) =>
            {
                if (position >= 0)
                {
                    //s.DataRepository.Sentences.Delete(item);
                    await DataRepository.Sentences.Delete(item);

                    nItems.RemoveAt(position);
                    NotifyDataSetChanged();
                }
            };


            //   holder.DeleteButton.Click += remove_word;
            holder.EditButton.Click += (object sender, EventArgs e) =>
            {
                holder.Text.SetText(item.Text, TextView.BufferType.Normal);

                holder.EditButton.Focusable            = false;
                holder.EditButton.FocusableInTouchMode = false;
                holder.EditButton.Clickable            = true;
                var    sentence = new Intent(this.nContext, typeof(STE3_edit));
                string alpha    = item.Id.ToString();

                sentence.PutExtra("Id", alpha);
                nContext.StartActivity(sentence);
                //   s.DataRepository.Words.Update(sentence);
                // a.StartActivity(word);
                // StartActivity(typeof(Audio1));
                //Todo - implement edit Service
            };
            holder.PlayButton.Click += (object sender, EventArgs e) =>
            {
                string      a       = item.Audio; //getting  path from database
                MediaPlayer _player = new MediaPlayer();
                _player.SetDataSource(a);         //paassng a path to play

                _player.Prepare();
                _player.Start();
            };
            // }


            return(view);
        }
コード例 #6
0
 private void ServiceDataTemplate(DeviceServiceViewModel item, ServiceViewHolder holder, int position)
 {
     holder.ServiceNameLabel.Text = item.Service.Name;
     holder.ServiceUuidLabel.Text = item.Service.Id.ToString();
 }