Exemplo n.º 1
0
        public override Android.Views.View GetView(int position, Android.Views.View convertView, ViewGroup parent)
        {
            ViewHolder holder;

            if (convertView == null)
            {
                convertView = inflater.Inflate(Resource.Layout.PostItem, parent, false);
                holder = new ViewHolder();

                
                holder.avatar = (ImageView)convertView
                    .FindViewById(Resource.Id.user_photo);
                holder.userNick = (TextView)convertView
                        .FindViewById(Resource.Id.user_nick);
                holder.postDate = (TextView)convertView
                        .FindViewById(Resource.Id.post_date);
                holder.postContent = (TextView)convertView
                        .FindViewById(Resource.Id.post_content);
                
                convertView.SetTag(Resource.String.view_holder_tag, holder);
            }

            else 
            {
                holder = (ViewHolder)convertView.GetTag(Resource.String.view_holder_tag);
            }

            Post postAtPosition = posts[position];
            holder.postContent.Text = postAtPosition.content;
            holder.userNick.Text = postAtPosition.userName;
            holder.postDate.Text = HttpUtils.postDateToShowFormat(postAtPosition.updatedAt);
            Color backgroundColor = postAtPosition.marked ? context.Resources.GetColor(Resource.Color.post_selected) : context.Resources.GetColor(Resource.Color.post_idle);
            convertView.SetBackgroundColor(backgroundColor);
            return convertView;
        }
Exemplo n.º 2
0
		public void GetToolbarItem(ToolbarItem tbi, Android.Views.View view){
			int res = 0;
			int imgRes = 0;
			if (tbi.Icon == null) {
				if (tbi.Priority == 0)
					res = Resource.Id.btn_textLeft;
				else
					res = Resource.Id.btn_textRight;
				var btn = (Android.Widget.Button)view.FindViewById(res);
				btn.Text = "  " + tbi.Text;
				btn.TextSize =  (float)Device.GetNamedSize (NamedSize.Small, typeof(Label));
				btn.Visibility = Android.Views.ViewStates.Visible;
				btn.SetTextColor(Color.FromHex("218DFF").ToAndroid ());
				btn.Click +=  (sender, ee) => { 
					if (tbi.Command != null)
						tbi.Command.Execute(tbi.CommandParameter);
				};
			} else {
				if (tbi.Priority == 0)
					res = Resource.Id.btn_imageLeft;
				else
					res = Resource.Id.btn_imageRight;

				imgRes = Resources.GetIdentifier(tbi.Icon.File.Split('.')[0], "drawable", MainActivity.Activity.PackageName);
				var imBtn = (Android.Widget.ImageButton)view.FindViewById(res);
				imBtn.SetImageResource(imgRes);
				imBtn.Visibility = Android.Views.ViewStates.Visible;
				imBtn.Click +=  (sender, ee) => { 
					if (tbi.Command != null)
						tbi.Command.Execute(tbi.CommandParameter);
				};
			}
		}
 /// <summary>
 /// 
 /// </summary>
 /// <param name="view"></param>
 private void BindUI(Android.Views.View view)
 {
     try
     {
         var chart = view.FindViewById<BarChartView>(Resource.Id.barChart1);
         var usageByResource = (from userDetail in UserHomeViewModel.UsageDetails
                                where userDetail.MeterCategory == SelectedResource.MeterId
                                orderby userDetail.Cost descending
                                group userDetail by userDetail.ResourceName into grps
                                select new BarModel
                                {
                                    Legend = grps.Key,
                                    Value = (float)grps.Sum(c => c.Cost),
                                    //ValueCaptionHidden = true,
                                    Color = Android.Graphics.Color.White
                                }).ToList();
         view.FindViewById<TextView>(Resource.Id.selectedMeterCategory).Text = SelectedResource.MeterId;
         chart.MinimumValue = 0;
         chart.BarWidth = 120;
         chart.BarClick += chart_BarClick;
         chart.LegendHidden = true;
         chart.ItemsSource = usageByResource;
     }
     catch (Exception ex)
     {
         ExceptionHandler.HandleException(ex, this.Activity);
     }
 }
        public override Android.Views.View GetView(int position, Android.Views.View convertView, Android.Views.ViewGroup parent)
        {
            if (convertView == null)
            {
                convertView = _activity.LayoutInflater.Inflate(Resource.Layout.list_item, parent, false);
            }

            Product product = _products[position];

            AQuery aq = new AQuery(convertView);

            TextView txtProductName = convertView.FindViewById<TextView>(Resource.Id.txtProductName);
            txtProductName.Text = product.Name;

            Bitmap imgLoading = aq.GetCachedImage(Resource.Drawable.img_loading);

            if (aq.ShouldDelay(position, convertView, parent, product.ImageUrl))
            {
                ((AQuery)aq.Id(Resource.Id.imgProduct)).Image(imgLoading, 0.75f);
            }
            else
            {
                ((AQuery)aq.Id(Resource.Id.imgProduct)).Image(product.ImageUrl, true, true, 0, 0, imgLoading, 0, 0.75f);
            }

            return convertView;
        }
 /// <summary>
 /// 
 /// </summary>
 /// <param name="view"></param>
 private void BindUI(Android.Views.View view)
 {
     var chart = view.FindViewById<BarChartView>(Resource.Id.dailyBarChart);
     var dailyUsageDetails = new List<BarModel>();
     foreach(var usageDetail in UserHomeViewModel.UsageDetails)
     {
         var usageDate = DateTime.Parse(usageDetail.UsageEndTime);
         var key = CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(usageDate.Month) + "-" + usageDate.Year;
         if(key == SelectedMonth.Month)
         {
             if (dailyUsageDetails.Any(d => d.Legend == usageDate.ToShortDateString()))
             {
                 var existingDailyUsage = dailyUsageDetails.FirstOrDefault(d => d.Legend == usageDate.ToShortDateString());
                 existingDailyUsage.Value += (float)usageDetail.Cost;
             }
             else
             {
                 dailyUsageDetails.Add(new BarModel()
                 {
                     Legend = usageDate.ToShortDateString(),
                     Value = (float)usageDetail.Cost,
                     Color = Android.Graphics.Color.White
                     //ValueCaptionHidden = true
                 });
             }
         }
     }
     view.FindViewById<TextView>(Resource.Id.selectedMonth).Text = SelectedMonth.Month;
     chart.MinimumValue = 0;
     chart.BarWidth = 120;
     chart.BarClick += chart_BarClick;
     chart.LegendHidden = true;
     chart.ItemsSource = dailyUsageDetails;
 }
 public override void OnViewCreated(Android.Views.View view, Android.OS.Bundle savedInstanceState)
 {
     EmojiconRecentsManager.Context =view.Context;
     mAdapter = new EmojiAdapter(view.Context, EmojiconRecentsManager.Recents);
     GridView gridView = (GridView) view.FindViewById(Resource.Id.Emoji_GridView);
     gridView.Adapter = mAdapter;
     gridView.ItemClick += OnItemClick;
 }
 public void OnHeaderClick(AdapterView parent, Android.Views.View view, long id)
 {
     string text = "Header " + ((TextView)view.FindViewById(Android.Resource.Id.Text1)).Text + " was tapped.";
     if (toast == null)
     {
         toast = Toast.MakeText(Activity, text, ToastLength.Short);
     }
     else
     {
         toast.SetText(text);
     }
     toast.Show();
 }
			public void OnClick(Android.Views.View v){
				CheckBox checkBox =(CheckBox) v.FindViewById<CheckBox>(Resource.Id.check);
				int position = int.Parse((string) v.Tag);
				Items[position].Checked = checkBox.Checked;
				if(checkBox.Checked){
					SelectedItems.Add(Items[position]);
				}
				else{
					SelectedItems.Remove(Items[position]);
				}
				ItemCheckedChanged(Items[position], checkBox.Checked);

			}
        protected override void OnBindView(Android.Views.View view)
        {
            base.OnBindView (view);

            try {
                // move our seekbar to the new view we've been given
                var oldContainer = seekBar.Parent;
                var newContainer = view.FindViewById<ViewGroup> (Resource.Id.seekBarPrefBarContainer);

                if (oldContainer != newContainer) {
                    // remove the seekbar from the old view
                    if (oldContainer != null) {
                        ((ViewGroup) oldContainer).RemoveView (seekBar);
                    }
                    // remove the existing seekbar (there may not be one) and add ours
                    newContainer.RemoveAllViews ();
                    newContainer.AddView (seekBar, ViewGroup.LayoutParams.FillParent,
                        ViewGroup.LayoutParams.WrapContent);
                }
            }
            catch(Exception ex) {
                Console.WriteLine ("Error Binding View: " + ex);
            }

            //if dependency is false from the beginning, disable the seek bar
            if (view != null && !view.Enabled)
            {
                seekBar.Enabled = false;
            }

            UpdateView (view);
        }
Exemplo n.º 10
0
        private static void SetDefaultVals(Android.Views.View dialogView, bool isWorkshop)
        {
            now = DateTime.Now;
            var currentStartDate = (startDate > DateTime.MinValue) ? startDate : now.AddMinutes(now.Minute * -1);
            var currentEndDate = (endDate > DateTime.MinValue) ? endDate : now.AddDays(7).AddMinutes(now.Minute * -1);

            dialogView.FindViewById<TextView>(Resource.Id.startDate).Text = currentStartDate.ToString(dateFormat);
            dialogView.FindViewById<TextView>(Resource.Id.endDate).Text = currentEndDate.ToString(dateFormat);
            dialogView.FindViewById<TextView>(Resource.Id.startTime).Text = currentStartDate.ToString(timeFormat);
            dialogView.FindViewById<TextView>(Resource.Id.endTime).Text = currentEndDate.ToString(timeFormat);
            dialogView.FindViewById<EditText>(Resource.Id.txtFilter_name).Text = name;
            dialogView.FindViewById<EditText>(Resource.Id.txtFilter_name).Hint = (isWorkshop) ? "Workshop Name" : "Tutor Name";
            dialogView.FindViewById<EditText>(Resource.Id.txtFilter_location).Text = location;
        }
Exemplo n.º 11
0
        private void InitElements(Android.Views.View view, Android.Views.LayoutInflater inflater)
        {
            listAdapter = new BookingsListAdapter(inflater, Resources, true);
            listView = view.FindViewById<ListView>(GetListView());
            listView.Adapter = listAdapter;

            refresher = view.FindViewById<SwipeRefreshLayout>(Resource.Id.swipeRefresh);
            refresher.Refresh += async (sender, e) =>
            {
                await Task.Factory.StartNew(() => LoadData(view, false, true));
                NotifyListUpdate();
                refresher.Refreshing = false;
            };
        }
Exemplo n.º 12
0
			public override void BindView (Android.Views.View view, Context context, ICursor cursor)
			{
				view.FindViewById<TextView> (Resource.Id.session_title).Text = cursor.GetString (SearchQuery.TITLE);
	
				String snippet = cursor.GetString (SearchQuery.SEARCH_SNIPPET);
	
				ISpannable styledSnippet = UIUtils.BuildStyledSnippet (new Java.Lang.String (snippet));
				view.FindViewById<TextView> (Resource.Id.session_subtitle).TextFormatted = styledSnippet;
	
				bool starred = cursor.GetInt (SearchQuery.STARRED) != 0;
				view.FindViewById (Resource.Id.star_button).Visibility = starred ? ViewStates.Visible : ViewStates.Invisible;
			}
Exemplo n.º 13
0
			public override void BindView (Android.Views.View view, Context context, ICursor cursor)
			{
				TextView titleView = view.FindViewById<TextView> (Resource.Id.session_title);
				TextView subtitleView = view.FindViewById<TextView> (Resource.Id.session_subtitle);
	
				titleView.Text = cursor.GetString (SessionsQuery.TITLE);
	
				// Format time block this session occupies
				long blockStart = cursor.GetLong (SessionsQuery.BLOCK_START);
				long blockEnd = cursor.GetLong (SessionsQuery.BLOCK_END);
				string roomName = cursor.GetString (SessionsQuery.ROOM_NAME);
				string subtitle = UIUtils.FormatSessionSubtitle (blockStart, blockEnd, roomName, context);
	
				subtitleView.Text = subtitle;
				
				bool starred = cursor.GetInt (SessionsQuery.STARRED) != 0;
				view.FindViewById (Resource.Id.star_button).Visibility = starred ? ViewStates.Visible : ViewStates.Invisible;
	
				// Possibly indicate that the session has occurred in the past.
				UIUtils.SetSessionTitleColor (blockStart, blockEnd, titleView, subtitleView);
			}
Exemplo n.º 14
0
			public override void BindView (Android.Views.View view, Context context, ICursor cursor)
			{
				view.FindViewById<TextView> (Resource.Id.vendor_name).Text = cursor.GetString (VendorsQuery.NAME);
				bool starred = cursor.GetInt (VendorsQuery.STARRED) != 0;
				view.FindViewById (Resource.Id.star_button).Visibility = starred ? ViewStates.Visible : ViewStates.Invisible;
			}