public override MKAnnotationView GetViewForAnnotation(MKMapView mapView, IMKAnnotation annotation)
        {
            if (annotation is ProfileAnnotation) //profile image
            {
                MKAnnotationView imageView = mapView.DequeueReusableAnnotation(iId);
                if (imageView == null)
                {
                    imageView = new MKAnnotationView(annotation, iId);
                }

                ImageCache im = new ImageCache(context);
                im.LoadImage(imageView, ((ProfileAnnotation)annotation).UserID.ToString(), ((ProfileAnnotation)annotation).image);

                //draws border inside, as opposed to Android where it is outside
                imageView.Layer.BorderColor = UIColor.FromName("PrimaryDark").CGColor;
                imageView.Layer.BorderWidth = 0.5f;
                imageView.Frame             = new CoreGraphics.CGRect(0, 0, (double)Settings.MapIconSize, (double)Settings.MapIconSize);

                return(imageView);
            }
            else if (annotation is MKPointAnnotation) //list view circle center / profile view position marker
            {
                if (context is LocationActivity)
                {
                    MKAnnotationView imageView = mapView.DequeueReusableAnnotation(iId);
                    if (imageView == null)
                    {
                        imageView = new MKAnnotationView(annotation, iId);
                    }

                    imageView.Image = UIImage.FromBundle("IcMapmarker");
                    imageView.Frame = new CoreGraphics.CGRect(0, 0, 30, 30);

                    return(imageView);
                }
                else
                {
                    MKPinAnnotationView pinView = (MKPinAnnotationView)mapView.DequeueReusableAnnotation(pId);
                    if (pinView == null)
                    {
                        pinView = new MKPinAnnotationView(annotation, pId);
                    }

                    pinView.PinColor       = MKPinAnnotationColor.Red;
                    pinView.CanShowCallout = false;

                    return(pinView);
                }
            }
            else //user location. Class = MapKit.MKAnnotationWrapper, title = My Location
            {
                return(null);
            }
        }
        public void SetImage(BaseActivity context, string userID, string picture, bool temp = false)
        {
            NSBundle.MainBundle.LoadNib("UploadedItem", this, null);

            Frame          = Bounds;
            MainView.Frame = Bounds;

            AddSubview(MainView);

            ImageCache im = new ImageCache(context);

            im.LoadImage(UploadedImage, userID, picture, false, temp);
        }
        public void AddPicture(string picture, int pos)
        {
            View UploadedImageContainer;

            if (Settings.DisplaySize == 1)
            {
                UploadedImageContainer = context.LayoutInflater.Inflate(Resource.Layout.uploaded_item_normal, this, false);
            }
            else
            {
                UploadedImageContainer = context.LayoutInflater.Inflate(Resource.Layout.uploaded_item_small, this, false);
            }
            ImageView   UploadedImage       = UploadedImageContainer.FindViewById <ImageView>(Resource.Id.UploadedImage);
            ImageButton DeleteUploadedImage = UploadedImageContainer.FindViewById <ImageButton>(Resource.Id.DeleteUploadedImage);

            DeleteUploadedImage.Click += DeleteUploadedImage_Click;
            DeleteUploadedImage.Touch += DeleteUploadedImage_Touch;

            ImageCache im = new ImageCache(context);

            Task.Run(async() => {
                if (context is ProfileEditActivity)
                {
                    await im.LoadImage(UploadedImage, Session.ID.ToString(), picture);
                }
                else
                {
                    await im.LoadImage(UploadedImage, RegisterActivity.regsessionid, picture, false, true);
                }
            });

            LayoutParams p0 = new LayoutParams((int)tileSize, (int)tileSize);

            UploadedImageContainer.LayoutParameters = p0;
            UploadedImageContainer.SetX(GetPosX(pos));
            UploadedImageContainer.SetY(GetPosY(pos));

            AddView(UploadedImageContainer);
            drawOrder.Add(pos);

            LayoutParameters.Width  = (int)(BaseActivity.screenWidth - 20 * BaseActivity.pixelDensity);
            LayoutParameters.Height = (int)((pos - pos % numColumns) / numColumns * (tileSize + tileSpacing * BaseActivity.pixelDensity) + tileSize);
        }
示例#4
0
        public override UICollectionViewCell GetCell(UICollectionView collectionView, NSIndexPath indexPath)
        {
            var cell = (UICollectionViewCell)collectionView.DequeueReusableCell("UserSearchListCell", indexPath);

            try             //error once on simulator when entering MainActivity, indexPath.row is out of bounds
            {
                UIImageView imageView = (UIImageView)cell.Subviews[0].Subviews[0];
                imageView.Frame = new CGRect(new CGPoint(0, 0), new CGSize(itemWidth, itemWidth));

                Profile item = items[indexPath.Row];

                ImageCache im = new ImageCache(this);
                im.LoadImage(imageView, item.ID.ToString(), item.Pictures[0]);
            }
            catch (Exception ex)
            {
                context.c.ReportErrorSilent(ex.Message + Environment.NewLine + ex.StackTrace + Environment.NewLine + " index: " + indexPath.Row);
            }

            return(cell);
        }
        public override View GetView(int position, View convertView, ViewGroup parent)
        {
            View view = convertView;

            if (view == null)
            {
                if (Settings.DisplaySize == 1)
                {
                    view = context.LayoutInflater.Inflate(Resource.Layout.chat_userlist_normal, null);
                }
                else
                {
                    view = context.LayoutInflater.Inflate(Resource.Layout.chat_userlist_small, null);
                }
            }

            ConstraintLayout ItemMainLayout = view.FindViewById <ConstraintLayout>(Resource.Id.ItemMainLayout);
            ImageView        Image          = view.FindViewById <ImageView>(Resource.Id.Image);
            TextView         Name           = view.FindViewById <TextView>(Resource.Id.Name);
            LinearLayout     ChatItems      = view.FindViewById <LinearLayout>(Resource.Id.ChatItems);

            if ((bool)items[position].Active)
            {
                ItemMainLayout.SetBackgroundResource(Resource.Drawable.backgroundSelectorActive);
            }
            else
            {
                ItemMainLayout.SetBackgroundResource(Resource.Drawable.backgroundSelectorPassive);
            }

            Name.Text = items[position].TargetName;

            for (int i = 0; i < ChatItems.ChildCount; i++)           //when inserting a match item to first place, chat lines of the next item will be shown if we don't clear it out.
            {
                ((LinearLayout)ChatItems.GetChildAt(i)).RemoveAllViews();
            }

            int j = 0;

            for (int i = items[position].Chat.Length - 1; i >= 0; i--)
            {
                string messageItem = items[position].Chat[i];
                int    sep1Pos     = messageItem.IndexOf('|');
                int    sep2Pos     = messageItem.IndexOf('|', sep1Pos + 1);
                int    sep3Pos     = messageItem.IndexOf('|', sep2Pos + 1);
                int    sep4Pos     = messageItem.IndexOf('|', sep3Pos + 1);
                int    sep5Pos     = messageItem.IndexOf('|', sep4Pos + 1);
                int    senderID    = int.Parse(messageItem.Substring(sep1Pos + 1, sep2Pos - sep1Pos - 1));
                long   readTime    = long.Parse(messageItem.Substring(sep4Pos + 1, sep5Pos - sep4Pos - 1));
                string message     = messageItem.Substring(sep5Pos + 1);

                TextView t = new TextView(context);
                t.SetSingleLine();
                t.Ellipsize        = Android.Text.TextUtils.TruncateAt.End;
                t.LayoutParameters = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent);
                t.Text             = message.Replace(System.Environment.NewLine, " ");
                LinearLayout lin = (LinearLayout)ChatItems.GetChildAt(j);
                j++;
                t.SetTextColor(Color.Black);

                if (Settings.DisplaySize == 1)
                {
                    t.SetTextAppearance(Resource.Style.TextSmallNormal);
                }
                else
                {
                    t.SetTextAppearance(Resource.Style.TextSmallSmall);
                }

                if (senderID != Session.ID)
                {
                    t.SetTypeface(null, TypefaceStyle.Bold);
                    //t.Typeface = Typeface.Create("<FONT FAMILY NAME>", Android.Graphics.TypefaceStyle.Bold);
                    if (readTime == 0)
                    {
                        lin.SetBackgroundColor(Color.ParseColor("#809dd7fb"));
                    }
                }

                lin.AddView(t);
            }

            ImageCache im = new ImageCache(context);

            //im.LoadImage(Image, items[position].TargetID.ToString(), items[position].TargetPicture, false);
            Task.Run(async() => {
                await im.LoadImage(Image, items[position].TargetID.ToString(), items[position].TargetPicture, false);
            });

            //Requires Xamarin.FFImageLoading. Not perfect, sometimes image is not found.

            /*string url;
             * url = Constants.HostName + Constants.UploadFolder + "/" + items[position].TargetID + "/" + Constants.SmallImageSize + "/" + items[position].TargetPicture;
             *
             * ImageService im = new ImageService();
             * im.LoadUrl(url).LoadingPlaceholder(Constants.loadingImage, FFImageLoading.Work.ImageSource.CompiledResource).ErrorPlaceholder(Constants.noImage, FFImageLoading.Work.ImageSource.CompiledResource).Into(Image);
             */
            return(view);
        }
示例#6
0
        public override UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath)
        {
            ChatUserListCell cell = (ChatUserListCell)tableView.DequeueReusableCell("ChatUserListCell");
            MatchItem        item = items[indexPath.Row];

            cell.SeparatorInset = new UIEdgeInsets(0, 0, 0, 0);

            if ((bool)item.Active)
            {
                cell.ContentView.BackgroundColor = UIColor.FromName("ChatTarget");
                cell.activeCell = true;
            }
            else
            {
                cell.ContentView.BackgroundColor = UIColor.FromName("ChatPassive");
                cell.activeCell = false;
            }

            UIImageView imageView = cell.ChatUserListImage;

            ImageCache im = new ImageCache(this);

            im.LoadImage(imageView, item.TargetID.ToString(), item.TargetPicture);

            cell.ChatUserListName.Text = item.TargetName;

            foreach (UILabel label in cell.ChatUserListItems.Subviews)
            {
                label.Text = "";
            }

            int j = 0;

            for (int i = item.Chat.Length - 1; i >= 0; i--)
            {
                string messageItem = item.Chat[i];
                int    sep1Pos     = messageItem.IndexOf('|');
                int    sep2Pos     = messageItem.IndexOf('|', sep1Pos + 1);
                int    sep3Pos     = messageItem.IndexOf('|', sep2Pos + 1);
                int    sep4Pos     = messageItem.IndexOf('|', sep3Pos + 1);
                int    sep5Pos     = messageItem.IndexOf('|', sep4Pos + 1);
                int    senderID    = int.Parse(messageItem.Substring(sep1Pos + 1, sep2Pos - sep1Pos - 1));
                long   readTime    = long.Parse(messageItem.Substring(sep4Pos + 1, sep5Pos - sep4Pos - 1));
                string message     = messageItem.Substring(sep5Pos + 1);

                UILabel label = (UILabel)cell.ChatUserListItems.Subviews[j];
                label.Text = message.Replace(Environment.NewLine, " ");
                j++;
                label.TextColor = UIColor.FromName("PrimaryDark");
                if (senderID != Session.ID)
                {
                    label.Font = UIFont.BoldSystemFontOfSize(14);
                    if (readTime == 0)
                    {
                        label.BackgroundColor = UIColor.FromName("ChatHighlight");
                    }
                    else
                    {
                        label.BackgroundColor = UIColor.FromRGBA(0, 0, 0, 0); //label may remain blue after list reload
                    }
                }
                else
                {
                    label.Font            = UIFont.SystemFontOfSize(14);
                    label.BackgroundColor = UIColor.FromRGBA(0, 0, 0, 0);
                }
            }

            return(cell);
        }