protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            try
            {
                SetContentView(Resource.Layout.AnswerFeedback);
                back_button          = FindViewById <ImageButton>(Resource.Id.back_button);
                backRelativeLayout   = FindViewById <RelativeLayout>(Resource.Id.backRelativeLayout);
                expert_data_layoutRL = FindViewById <RelativeLayout>(Resource.Id.expert_data_layoutRL);
                tintLL            = (RelativeLayout)FindViewById(Resource.Id.tintLL);
                expert_nameTV     = (TextView)FindViewById(Resource.Id.expert_nameTV);
                activityIndicator = (ProgressBar)FindViewById(Resource.Id.activityIndicator);
                activityIndicator.IndeterminateDrawable.SetColorFilter(Resources.GetColor(Resource.Color.buttonBackgroundColor), Android.Graphics.PorterDuff.Mode.Multiply);

                star1IV        = (ImageView)FindViewById(Resource.Id.star1IV);
                star2IV        = (ImageView)FindViewById(Resource.Id.star2IV);
                star3IV        = (ImageView)FindViewById(Resource.Id.star3IV);
                star4IV        = (ImageView)FindViewById(Resource.Id.star4IV);
                star5IV        = (ImageView)FindViewById(Resource.Id.star5IV);
                onlineIV       = (ImageView)FindViewById(Resource.Id.onlineIV);
                rating_valueTV = (TextView)FindViewById(Resource.Id.rating_value_TV);
                expert_imageIV = (ImageView)FindViewById(Resource.Id.expert_imageIV);
                reviewTextTV   = (TextView)FindViewById(Resource.Id.reviewTextTV);
                dateTV         = (TextView)FindViewById(Resource.Id.dateTV);
                yesTV          = (TextView)FindViewById(Resource.Id.yesTV);
                noTV           = (TextView)FindViewById(Resource.Id.noTV);
                sendBn         = (Button)FindViewById(Resource.Id.sendBn);
                feedbackET     = (EditText)FindViewById(Resource.Id.feedbackET);

                expert_nameTV.Text = Intent.GetStringExtra("review_name");
                star1IV.SetBackgroundResource(Resource.Drawable.disabled_star);
                star2IV.SetBackgroundResource(Resource.Drawable.disabled_star);
                star3IV.SetBackgroundResource(Resource.Drawable.disabled_star);
                star4IV.SetBackgroundResource(Resource.Drawable.disabled_star);
                star5IV.SetBackgroundResource(Resource.Drawable.disabled_star);

                rating_valueTV.Text = Intent.GetStringExtra("review_rating");
                dateTV.Text         = Intent.GetStringExtra("review_date");

                Typeface tf = Typeface.CreateFromAsset(Assets, "Roboto-Regular.ttf");
                FindViewById <TextView>(Resource.Id.headerTV).SetTypeface(tf, TypefaceStyle.Bold);
                expert_nameTV.SetTypeface(tf, TypefaceStyle.Bold);
                FindViewById <TextView>(Resource.Id.count_specs).SetTypeface(tf, TypefaceStyle.Normal);
                FindViewById <TextView>(Resource.Id.rating_value_TV).SetTypeface(tf, TypefaceStyle.Normal);
                dateTV.SetTypeface(tf, TypefaceStyle.Normal);
                FindViewById <TextView>(Resource.Id.distanceTV).SetTypeface(tf, TypefaceStyle.Normal);
                reviewTextTV.SetTypeface(tf, TypefaceStyle.Normal);
                FindViewById <TextView>(Resource.Id.textVssiew1).SetTypeface(tf, TypefaceStyle.Normal);
                FindViewById <TextView>(Resource.Id.textView5).SetTypeface(tf, TypefaceStyle.Normal);
                feedbackET.SetTypeface(tf, TypefaceStyle.Normal);
                sendBn.SetTypeface(tf, TypefaceStyle.Normal);
                FindViewById <TextView>(Resource.Id.your_city_valueTV).SetTypeface(tf, TypefaceStyle.Normal);
                yesTV.SetTypeface(tf, TypefaceStyle.Normal);
                noTV.SetTypeface(tf, TypefaceStyle.Normal);


                back_button.Click += (s, e) =>
                {
                    OnBackPressed();
                };
                backRelativeLayout.Click += (s, e) =>
                {
                    OnBackPressed();
                };

                if (Intent.GetStringExtra("review_online") == "true")
                {
                    onlineIV.Visibility = ViewStates.Visible;
                }
                else
                {
                    onlineIV.Visibility = ViewStates.Gone;
                }

                reviewTextTV.Text = Intent.GetStringExtra("review_text");

                Thread backgroundThread = new Thread(new ThreadStart(() =>
                {
                    Glide.Get(Application.Context).ClearDiskCache();
                }));
                backgroundThread.IsBackground = true;
                backgroundThread.Start();
                Glide.Get(this).ClearMemory();
                if (!Intent.GetStringExtra("review_image_url").Contains("iamn"))
                {
                    Glide.With(Application.Context)
                    .Load("https://api.iamnearby.net/" + Intent.GetStringExtra("review_image_url"))
                    .Apply(new Com.Bumptech.Glide.Request.RequestOptions()
                           .SkipMemoryCache(true))
                    //.Placeholder(Resource.Drawable.specialization_imageIV)
                    .Into(expert_imageIV);
                }
                else
                {
                    Glide.With(Application.Context)
                    .Load(Intent.GetStringExtra("review_image_url"))
                    .Apply(new Com.Bumptech.Glide.Request.RequestOptions()
                           .SkipMemoryCache(true))
                    //.Placeholder(Resource.Drawable.specialization_imageIV)
                    .Into(expert_imageIV);
                }
                double rating_value = 0;
                try
                {
                    rating_value = Convert.ToDouble(Intent.GetStringExtra("review_rating"), (CultureInfo.InvariantCulture));
                    if (rating_value >= 1)
                    {
                        star1IV.SetBackgroundResource(Resource.Drawable.active_star);
                        if (rating_value >= 2)
                        {
                            star2IV.SetBackgroundResource(Resource.Drawable.active_star);
                            if (rating_value >= 3)
                            {
                                star3IV.SetBackgroundResource(Resource.Drawable.active_star);
                                if (rating_value >= 4)
                                {
                                    star4IV.SetBackgroundResource(Resource.Drawable.active_star);
                                    if (rating_value >= 5)
                                    {
                                        star5IV.SetBackgroundResource(Resource.Drawable.active_star);
                                    }
                                }
                            }
                        }
                    }
                }
                catch { }

                sendBn.Click += (s, e) =>
                {
                    if (!String.IsNullOrEmpty(feedbackET.Text))
                    {
                        tintLL.Visibility = ViewStates.Visible;
                    }
                };

                yesTV.Click += async(s, e) =>
                {
                    if (!String.IsNullOrEmpty(feedbackET.Text))
                    {
                        tintLL.Visibility            = ViewStates.Gone;
                        activityIndicator.Visibility = ViewStates.Visible;
                        sendBn.Visibility            = ViewStates.Gone;
                        var res = await feedbacks.ReplyReview(userMethods.GetUsersAuthToken(), Intent.GetStringExtra("review_id"), feedbackET.Text);

                        activityIndicator.Visibility = ViewStates.Gone;
                        sendBn.Visibility            = ViewStates.Visible;
                        if (checkInternetConnection())
                        {
                            StartActivity(typeof(MyReviewsListActivity));
                        }
                        else
                        {
                            Toast.MakeText(this, Resource.String.turn_internet_on, ToastLength.Long).Show();
                        }
                    }
                };
                noTV.Click += (s, e) =>
                {
                    tintLL.Visibility = ViewStates.Gone;
                };
                tintLL.Click += (s, e) =>
                {
                    tintLL.Visibility = ViewStates.Gone;
                };
                expert_data_layoutRL.Click += (s, e) =>
                {
                    edit_expert = expert_data.Edit();
                    edit_expert.PutString("expert_id", Intent.GetStringExtra("expertId"));
                    edit_expert.Apply();
                    StartActivity(typeof(ThreeLevelExpertProfileActivity));
                };
            }
            catch
            {
                StartActivity(typeof(MainActivity));
            }
        }
Beispiel #2
0
 public RequestBuilder GetPreloadRequestBuilder(Object p0)
 {
     return(Glide.With(ActivityContext).Load(p0.ToString())
            .Apply(new RequestOptions().CircleCrop()));
 }
Beispiel #3
0
        public override StartCommandResult OnStartCommand(Intent intent, StartCommandFlags flags, int startId)
        {
            try
            {
                if (MFloatingViewManager == null)
                {
                    RunService = true;

                    DisplayMetrics metrics = new DisplayMetrics();
                    //DisplayMetrics metrics = Resources.DisplayMetrics;
                    var windowManager = GetSystemService(WindowService).JavaCast <IWindowManager>();
                    windowManager?.DefaultDisplay?.GetRealMetrics(metrics);

                    if (Inflater == null)
                    {
                        Inflater = LayoutInflater.From(Application.Context);
                    }

                    var iconView = Inflater?.Inflate(Resource.Layout.WidgetChatHeadLayout, null, false);

                    Image = iconView?.FindViewById <ImageView>(Resource.Id.imageFloating);
                    Image?.SetOnClickListener(this);
                    try
                    {
                        DataUser = JsonConvert.DeserializeObject <FloatingObject>(intent.GetStringExtra("UserData"));
                        if (DataUser != null)
                        {
                            Glide.With(Application.Context).Load(DataUser.Avatar).Apply(new RequestOptions().CircleCrop().Placeholder(Resource.Drawable.no_profile_image_circle)).Into(Image);

                            if (!string.IsNullOrEmpty(DataUser.MessageCount) || DataUser.MessageCount != "0")
                            {
                                ShowOrHideBadgeView(Convert.ToInt32(DataUser.MessageCount), true);
                            }
                        }
                    }
                    catch (Exception e)
                    {
                        Methods.DisplayReportResultTrack(e);
                    }

                    MFloatingViewManager = new FloatingViewManager(Application.Context, this);
                    MFloatingViewManager.SetFixedTrashIconImage(Application.Context.GetDrawable(Resource.Drawable.ic_trash_fixed));
                    MFloatingViewManager.SetActionTrashIconImage(Application.Context.GetDrawable(Resource.Drawable.ic_trash_action));
                    MFloatingViewManager.SetSafeInsetRect((Rect)intent.GetParcelableExtra(ExtraCutoutSafeArea));

                    // Setting Options(you can change options at any time)
                    FloatingViewManager.Options options = LoadDynamicOptions(metrics);

                    switch (AppSettings.DisplayModeSettings)
                    {
                    case "Always":
                        MFloatingViewManager.SetDisplayMode(FloatingViewManager.DisplayModeShowAlways);
                        break;

                    case "FullScreen":
                        MFloatingViewManager.SetDisplayMode(FloatingViewManager.DisplayModeHideFullscreen);
                        break;

                    case "Hide":
                        MFloatingViewManager.SetDisplayMode(FloatingViewManager.DisplayModeHideAlways);
                        break;
                    }

                    MFloatingViewManager.AddViewToWindow(iconView, options);
                    return(StartCommandResult.Sticky);
                }
                else
                {
                    if (Image != null)
                    {
                        if (!string.IsNullOrEmpty(DataUser.MessageCount) || DataUser.MessageCount != "0")
                        {
                            var x = Convert.ToInt32(DataUser.MessageCount);

                            if (x >= 1 && AppSettings.LastChatSystem == SystemApiGetLastChat.Old)
                            {
                                x++;
                            }

                            ShowOrHideBadgeView(x, true);
                        }
                    }
                }

                return(StartCommandResult.NotSticky);
            }
            catch (Exception e)
            {
                Methods.DisplayReportResultTrack(e);
                return(StartCommandResult.NotSticky);
            }
        }
        private void LoadPassedData(GroupClass result)
        {
            try
            {
                GlideImageLoader.LoadImage(this, result.Avatar, UserProfileImage, ImageStyle.CenterCrop, ImagePlaceholders.Color);
                Glide.With(this).Load(result.Cover.Replace(" ", "")).Apply(new RequestOptions().Placeholder(Resource.Drawable.Cover_image).Error(Resource.Drawable.Cover_image)).Into(CoverImage);

                TxtGroupUsername.Text = "@" + result.Username;
                TxtGroupName.Text     = Methods.FunString.DecodeString(result.Name);
                CategoryText.Text     = Methods.FunString.DecodeString(result.Category);

                if (result.UserId == UserDetails.UserId)
                {
                    result.IsOwner = true;
                }

                if (result.IsOwner)
                {
                    BtnJoin.BackgroundTintList = ColorStateList.ValueOf(Color.ParseColor(AppSettings.MainColor));
                    BtnJoin.Text = GetText(Resource.String.Lbl_Edit);
                    BtnJoin.SetTextColor(Color.White);
                    BtnJoin.Tag = "MyGroup";
                    BtnMore.BackgroundTintList = ColorStateList.ValueOf(Color.ParseColor(AppSettings.MainColor));
                    BtnMore.ImageTintList      = ColorStateList.ValueOf(Color.White);
                }
                else
                {
                    BtnJoin.BackgroundTintList = result.IsJoined == "yes" || result.IsJoined == "true" ? ColorStateList.ValueOf(Color.ParseColor("#efefef")) : ColorStateList.ValueOf(Color.ParseColor(AppSettings.MainColor));
                    BtnJoin.Text = GetText(result.IsJoined == "yes" || result.IsJoined == "true" ? Resource.String.Btn_Joined : Resource.String.Btn_Join_Group);
                    BtnJoin.SetTextColor(result.IsJoined == "yes" || result.IsJoined == "true" ? Color.Black : Color.White);
                    BtnMore.BackgroundTintList = result.IsJoined == "yes" || result.IsJoined == "true" ? ColorStateList.ValueOf(Color.ParseColor("#efefef")) : ColorStateList.ValueOf(Color.ParseColor(AppSettings.MainColor));
                    BtnMore.ImageTintList      = result.IsJoined == "yes" || result.IsJoined == "true" ? ColorStateList.ValueOf(Color.Black) : ColorStateList.ValueOf(Color.White);
                    BtnJoin.Tag = "UserGroup";
                }

                if (result.IsOwner || result.IsJoined == "yes" || result.IsJoined == "true")
                {
                    var checkSection = PostFeedAdapter.ListDiffer.FirstOrDefault(a => a.TypeView == PostModelType.AddPostBox);
                    if (checkSection == null)
                    {
                        Combiner.AddPostDivider();

                        Combiner.AddPostBoxPostView("Group", -1, new PostDataObject()
                        {
                            GroupRecipient = result
                        });

                        if (AppSettings.ShowSearchForPosts)
                        {
                            Combiner.SearchForPostsView("Group", new PostDataObject()
                            {
                                GroupRecipient = result
                            });
                        }

                        PostFeedAdapter.NotifyItemInserted(PostFeedAdapter.ListDiffer.Count - 1);
                    }
                }

                PrivacyText.Text = GetText(result.Privacy == "1" ? Resource.String.Radio_Public : Resource.String.Radio_Private);

                if (result.Privacy != "1")
                {
                    IconPrivacy.SetImageResource(Resource.Drawable.ic_private);
                }

                if (result.IsOwner)
                {
                    EditAvatarImageGroup.Visibility = ViewStates.Visible;
                    TxtEditGroupInfo.Visibility     = ViewStates.Visible;
                }
                else
                {
                    EditAvatarImageGroup.Visibility = ViewStates.Gone;
                    TxtEditGroupInfo.Visibility     = ViewStates.Gone;
                }

                if (result.Privacy == "1" || result.IsOwner)
                {
                    PollyController.RunRetryPolicyFunction(new List <Func <Task> > {
                        () => MainRecyclerView.FetchNewsFeedApiPosts()
                    });
                }
                else
                {
                    if (PostFeedAdapter.ListDiffer.FirstOrDefault(a => a.IsDefaultFeedPost) != null)
                    {
                        var emptyStateChecker = PostFeedAdapter.ListDiffer.FirstOrDefault(a => a.TypeView == PostModelType.EmptyState);
                        if (emptyStateChecker != null && PostFeedAdapter.ListDiffer.Count > 1)
                        {
                            PostFeedAdapter.ListDiffer.Remove(emptyStateChecker);
                        }
                    }
                    else
                    {
                        var emptyStateChecker = PostFeedAdapter.ListDiffer.FirstOrDefault(a => a.TypeView == PostModelType.EmptyState);
                        if (emptyStateChecker == null)
                        {
                            PostFeedAdapter.ListDiffer.Add(new AdapterModelsClass {
                                TypeView = PostModelType.EmptyState, Id = 744747447
                            });
                        }
                    }
                    PostFeedAdapter.NotifyDataSetChanged();
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Beispiel #5
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SetContentView(RecyclerViewSample.Resource.Layout.EditProfile);

            var     image     = FindViewById <ImageView>(RecyclerViewSample.Resource.Id.myImageView);
            var     name      = FindViewById <EditText>(RecyclerViewSample.Resource.Id.name);
            var     birthdate = FindViewById <EditText>(RecyclerViewSample.Resource.Id.birth_date);
            var     email     = FindViewById <EditText>(RecyclerViewSample.Resource.Id.email);
            var     phone_num = FindViewById <EditText>(RecyclerViewSample.Resource.Id.phone_num);
            var     bio       = FindViewById <EditText>(RecyclerViewSample.Resource.Id.bio);
            Button  uploadImageFromGalleryBn = FindViewById <Button>(RecyclerViewSample.Resource.Id.uploadImageFromGalleryBn);
            Button  uploadImageFromCameraBn  = FindViewById <Button>(RecyclerViewSample.Resource.Id.uploadImageFromCameraBn);
            Button  applyChangesBn           = FindViewById <Button>(RecyclerViewSample.Resource.Id.applyChangesBn);
            Button  cancelBn      = FindViewById <Button>(RecyclerViewSample.Resource.Id.cancelBn);
            Spinner genderSpinner = FindViewById <Spinner>(RecyclerViewSample.Resource.Id.gender_spinner);

            activityIndicator = FindViewById <ProgressBar>(RecyclerViewSample.Resource.Id.activityIndicator);

            string   path = "fonts/HelveticaNeueLight.ttf";
            Typeface tf   = Typeface.CreateFromAsset(Assets, path);

            name.Typeface      = tf;
            birthdate.Typeface = tf;
            email.Typeface     = tf;
            phone_num.Typeface = tf;
            bio.Typeface       = tf;
            uploadImageFromGalleryBn.Typeface = tf;
            uploadImageFromCameraBn.Typeface  = tf;
            applyChangesBn.Typeface           = tf;
            cancelBn.Typeface = tf;

            if (IsThereAnAppToTakePictures())
            {
                CreateDirectoryForPictures();

                var imageView =
                    FindViewById <ImageView>(RecyclerViewSample.Resource.Id.myImageView);
                uploadImageFromCameraBn.Click += TakeAPicture;
            }

            uploadImageFromGalleryBn.Click += delegate
            {
                cameraOrGalleryIndicator = "gallery";
                var imageIntent = new Intent();
                imageIntent.SetType("image/*");
                imageIntent.SetAction(Intent.ActionGetContent);
                StartActivityForResult(
                    Intent.CreateChooser(imageIntent, "Select photo"), 0);
            };
            cancelBn.Click += delegate
            {
                StartActivity(typeof(RecyclerViewSample.Profile));
            };
            string dbPath     = System.IO.Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), "ormdemo.db3");
            var    db         = new SQLiteConnection(dbPath);
            var    user_table = db.Table <RecyclerViewSample.ORM.UsersDataTable>();

            foreach (var item in user_table)
            {
                RecyclerViewSample.Login.name            = item.name;
                RecyclerViewSample.Login.birth_date      = item.birth_date;
                RecyclerViewSample.Login.email_          = item.email;
                RecyclerViewSample.Login.phone_num       = item.phone_num;
                RecyclerViewSample.Login.interests       = item.biography;
                RecyclerViewSample.Login.gender          = item.gender;
                RecyclerViewSample.Login.token           = item.api_token;
                RecyclerViewSample.Login.user_country_id = item.country_id;
                RecyclerViewSample.Login.user_id         = item.user_id;
                Glide.With(Application.Context)
                .Load(item.avatar)
                .Into(image);
                RecyclerViewSample.Login.password = item.password;
            }

            name.Text      = RecyclerViewSample.Login.name;
            birthdate.Text = RecyclerViewSample.Login.birth_date;
            email.Text     = RecyclerViewSample.Login.email_;
            phone_num.Text = RecyclerViewSample.Login.phone_num;
            bio.Text       = RecyclerViewSample.Login.interests;
            try
            {
                Glide.With(Application.Context)
                .Load(RecyclerViewSample.Login.avatar)
                .Into(image);
            }catch { }

            genderList.Clear();
            genderList.Add("Male");
            genderList.Add("Female");
            ArrayAdapter adapter = new ArrayAdapter <string>(this, Android.Resource.Layout.SimpleListItem1, genderList);

            genderSpinner.Adapter       = adapter;
            genderSpinner.ItemSelected += GenderSpinner_ItemSelected;

            //setting position to spinner
            if (RecyclerViewSample.Login.gender == "1")
            {
                genderSpinner.SetSelection(0);
            }
            else if (RecyclerViewSample.Login.gender == "2")
            {
                genderSpinner.SetSelection(1);
            }
            //setting position to spinner ENDED

            applyChangesBn.Click += async delegate
            {
                activityIndicator.Visibility = ViewStates.Visible;
                applyChangesBn.Visibility    = ViewStates.Gone;
                promptMessage = "";
                if (name.Text == "" || name.Text == null || name.Text == " " || name.Text == "  " || name.Text == "   ")
                {
                    promptMessage += "Name is empty. \n";
                }
                if (birthdate.Text == "" || birthdate.Text == null || birthdate.Text == " " || birthdate.Text == "  " || birthdate.Text == "   ")
                {
                    promptMessage += "Birthdate is empty. \n";
                }
                if (email.Text == "" || email.Text == null || email.Text == " " || email.Text == "  " || email.Text == "   ")
                {
                    promptMessage += "E-mail is empty. \n";
                }
                if (phone_num.Text == "" || phone_num.Text == null || phone_num.Text == " " || phone_num.Text == "  " || phone_num.Text == "   ")
                {
                    promptMessage += "Phone number is empty. \n";
                }
                if (bio.Text.Length < 30)
                {
                    promptMessage += "Your interests must have at least 30 characters. \n";
                }

                if (promptMessage != "")
                {
                    Toast.MakeText(this, promptMessage, ToastLength.Long).Show();
                    applyChangesBn.Visibility    = ViewStates.Visible;
                    activityIndicator.Visibility = ViewStates.Gone;
                }
                else
                {
                    bal = "";
                    //WE NEED ALL OF THIS TO WRITE IMAGE TO DATABASE
                    image.BuildDrawingCache(true);
                    Bitmap bitmap = image.GetDrawingCache(true);
                    if (bitmap != null)
                    {
                        image.SetImageBitmap(bitmap);
                        Bitmap       b         = Bitmap.CreateBitmap(image.GetDrawingCache(true));
                        MemoryStream memStream = new MemoryStream();
                        b.Compress(Bitmap.CompressFormat.Png, 0, memStream);
                        //memStream.ToArray();
                        //WE NEED ALL OF THIS TO WRITE IMAGE TO DATABASE ENDED

                        byte[] ba = memStream.ToArray();
                        bal = Base64.EncodeToString(ba, Base64.Default);
                    }


                    var client  = new RestClient("http://api.xplorpal.com/profile/" + RecyclerViewSample.Login.user_id);
                    var request = new RestRequest("/guide_update", Method.POST);
                    request.AddParameter("name", name.Text);
                    request.AddParameter("gender", maleOrFemale);
                    request.AddParameter("birth_date", birthdate.Text);
                    request.AddParameter("email", email.Text);
                    request.AddParameter("phone_num", phone_num.Text);
                    request.AddParameter("bio", bio.Text);
                    request.AddParameter("profile_img[]", "data:image/jpeg;base64," + bal);
                    //request.AddParameter("profile_image", "data:image/png;base64," + bal);
                    request.AddParameter("api_token", RecyclerViewSample.Login.token);
                    IRestResponse response = await client.ExecuteTaskAsync(request);

                    var content = response.Content;
                    try
                    {
                        var    myContent     = JObject.Parse(content);
                        string response_code = myContent["response_code"].ToString();
                        if (response_code == "200")
                        {
                            //NOW WE NEED TO GET IMAGE URL TO WRITE IT TO DATABASE
                            var image_retrieving_client  = new RestClient("http://api.xplorpal.com");
                            var image_retrieving_request = new RestRequest("/login", Method.POST);
                            image_retrieving_request.AddParameter("email", email.Text);
                            image_retrieving_request.AddParameter("password", RecyclerViewSample.Login.password);

                            IRestResponse image_retrieving_response = await image_retrieving_client.ExecuteTaskAsync(image_retrieving_request);

                            var image_retrieving_content = image_retrieving_response.Content;

                            if (image_retrieving_content.Length > 100)//response.StatusCode == System.Net.HttpStatusCode.OK)
                            {
                                try
                                {
                                    var usr  = JsonConvert.DeserializeObject <List <User> >(image_retrieving_content);
                                    var usr_ = usr[0];
                                    //removing this part of the content
                                    RecyclerViewSample.Login.avatar = Convert.FromBase64String(usr_.avatar_base64.Replace("data:image/jpeg;base64,", ""));
                                }
                                catch { }
                            }
                            else
                            {
                                Toast.MakeText(this, "Check your Password", ToastLength.Long).Show();
                                StartActivity(typeof(EditProfileActivity));
                            }
                            //NOW WE NEED TO GET IMAGE URL TO WRITE IT TO DATABASE ENDED

                            // clearing table
                            foreach (var item in user_table)
                            {
                                dbr.RemoveUsersData(item.Id);
                            }

                            //setting variables
                            RecyclerViewSample.Login.gender     = maleOrFemale.ToString();
                            RecyclerViewSample.Login.name       = name.Text;
                            RecyclerViewSample.Login.birth_date = birthdate.Text;
                            RecyclerViewSample.Login.email_     = email.Text;
                            RecyclerViewSample.Login.phone_num  = phone_num.Text;
                            RecyclerViewSample.Login.interests  = bio.Text;
                            RecyclerViewSample.Login.gender     = maleOrFemale.ToString();
                            //setting variables ENDED

                            //inserting to users table
                            dbr.InsertRecord(name.Text, email.Text, RecyclerViewSample.Login.avatar, RecyclerViewSample.Login.token,
                                             birthdate.Text, RecyclerViewSample.Login.gender,
                                             phone_num.Text, bio.Text, RecyclerViewSample.Login.user_country_id, RecyclerViewSample.Login.user_id, RecyclerViewSample.Login.password);

                            Toast.MakeText(this, "Changes adopted", ToastLength.Long).Show();

                            StartActivity(typeof(RecyclerViewSample.MainActivity));
                        }
                        else
                        {
                            applyChangesBn.Visibility    = ViewStates.Visible;
                            activityIndicator.Visibility = ViewStates.Gone;
                            Toast.MakeText(this, "Changes not accepted", ToastLength.Long).Show();
                        }
                    }
                    catch { }
                }
            };
        }
Beispiel #6
0
        //Result
        protected override async void OnActivityResult(int requestCode, Result resultCode, Intent data)
        {
            try
            {
                base.OnActivityResult(requestCode, resultCode, data);
                if (requestCode == 503 && resultCode == Result.Ok) // Add image using camera
                {
                    if (string.IsNullOrEmpty(IntentController.CurrentPhotoPath))
                    {
                        var filepath = Methods.AttachmentFiles.GetActualPathFromFile(this, data.Data);
                        if (filepath != null)
                        {
                            var type = Methods.AttachmentFiles.Check_FileExtension(filepath);
                            if (type == "Image")
                            {
                                SendFile(filepath, filepath, "Image");
                            }
                        }
                    }
                    else
                    {
                        if (Methods.MultiMedia.CheckFileIfExits(IntentController.CurrentPhotoPath) != "File Dont Exists")
                        {
                            SendFile(IntentController.CurrentPhotoPath, IntentController.CurrentPhotoPath, "Image");
                        }
                    }
                }
                else if (requestCode == 501 && resultCode == Result.Ok) // Add video
                {
                    var filepath = Methods.AttachmentFiles.GetActualPathFromFile(this, data.Data);
                    if (filepath != null)
                    {
                        var type = Methods.AttachmentFiles.Check_FileExtension(filepath);
                        if (type == "Video")
                        {
                            var fileName = filepath.Split('/').Last();
                            var fileNameWithoutExtension = fileName.Split('.').First();

                            var path = Methods.Path.FolderDcimVideo + "/" + fileNameWithoutExtension + ".png";

                            var videoPlaceHolderImage = Methods.MultiMedia.GetMediaFrom_Gallery(Methods.Path.FolderDcimVideo, fileNameWithoutExtension + ".png");
                            if (videoPlaceHolderImage == "File Dont Exists")
                            {
                                var bitmapImage = Methods.MultiMedia.Retrieve_VideoFrame_AsBitmap(this, data.Data.ToString());
                                if (bitmapImage != null)
                                {
                                    Methods.MultiMedia.Export_Bitmap_As_Image(bitmapImage, fileNameWithoutExtension, Methods.Path.FolderDcimVideo);
                                }
                                else
                                {
                                    File file2    = new File(filepath);
                                    var  photoUri = FileProvider.GetUriForFile(this, PackageName + ".fileprovider", file2);

                                    Glide.With(this)
                                    .AsBitmap()
                                    .Load(photoUri)                      // or URI/path
                                    .Into(new MySimpleTarget(filepath)); //image view to set thumbnail to

                                    await Task.Delay(500);
                                }
                            }

                            SendFile(filepath, path, "Video");
                        }
                    }
                }
                else if (requestCode == 513 && resultCode == Result.Ok) // Add video Camera
                {
                    var filepath = Methods.AttachmentFiles.GetActualPathFromFile(this, data.Data);
                    if (filepath != null)
                    {
                        var type = Methods.AttachmentFiles.Check_FileExtension(filepath);
                        if (type == "Video")
                        {
                            var fileName = filepath.Split('/').Last();
                            var fileNameWithoutExtension = fileName.Split('.').First();
                            var path = Methods.Path.FolderDcimVideo + "/" + fileNameWithoutExtension + ".png";

                            var videoPlaceHolderImage = Methods.MultiMedia.GetMediaFrom_Gallery(Methods.Path.FolderDcimVideo, fileNameWithoutExtension + ".png");
                            if (videoPlaceHolderImage == "File Dont Exists")
                            {
                                var bitmapImage = Methods.MultiMedia.Retrieve_VideoFrame_AsBitmap(this, data.Data.ToString());
                                if (bitmapImage != null)
                                {
                                    Methods.MultiMedia.Export_Bitmap_As_Image(bitmapImage, fileNameWithoutExtension, Methods.Path.FolderDcimVideo);
                                }
                                else
                                {
                                    File file2    = new File(filepath);
                                    var  photoUri = FileProvider.GetUriForFile(this, PackageName + ".fileprovider", file2);

                                    Glide.With(this)
                                    .AsBitmap()
                                    .Load(photoUri)                      // or URI/path
                                    .Into(new MySimpleTarget(filepath)); //image view to set thumbnail to

                                    await Task.Delay(500);
                                }
                            }
                            SendFile(filepath, path, "Video");
                        }
                    }
                }
                else if (requestCode == CropImage.CropImageActivityRequestCode)
                {
                    var result = CropImage.GetActivityResult(data);
                    if (result.IsSuccessful)
                    {
                        var resultPathImage = result.Uri.Path;
                        if (!string.IsNullOrEmpty(resultPathImage))
                        {
                            SendFile(resultPathImage, resultPathImage, "Image");
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Beispiel #7
0
        private void Initialize(Holders.LastMessagesViewHolder holder, GetUsersListObject.User item)
        {
            try
            {
                var image = !string.IsNullOrEmpty(item.OldAvatar) ? item.OldAvatar : item.Avatar ?? "";
                if (!string.IsNullOrEmpty(image))
                {
                    var avatarSplit    = image.Split('/').Last();
                    var getImageAvatar = Methods.MultiMedia.GetMediaFrom_Disk(Methods.Path.FolderDiskImage, avatarSplit);
                    if (getImageAvatar != "File Dont Exists")
                    {
                        var file = Uri.FromFile(new File(getImageAvatar));
                        Glide.With(ActivityContext).Load(file.Path).Apply(Options).Into(holder.ImageAvatar);
                    }
                    else
                    {
                        Methods.MultiMedia.DownloadMediaTo_DiskAsync(Methods.Path.FolderDiskImage, image);
                        GlideImageLoader.LoadImage(ActivityContext, image, holder.ImageAvatar, ImageStyle.CircleCrop, ImagePlaceholders.Drawable);
                    }
                }

                holder.TxtUsername.Text = WoWonderTools.GetNameFinal(item);

                holder.TxtUsername.SetCompoundDrawablesWithIntrinsicBounds(0, 0, item.Verified == "1" ? Resource.Drawable.icon_checkmark_small_vector : 0, 0);

                if (item.LastMessage.Stickers != null)
                {
                    item.LastMessage.Stickers = item.LastMessage.Stickers.Replace(".mp4", ".gif");
                }

                //If message contains Media files
                if (!string.IsNullOrEmpty(item.LastMessage.Media) && item.LastMessage.Media.Contains("image"))
                {
                    holder.LastMessagesIcon.Visibility = ViewStates.Visible;
                    Glide.With(ActivityContext).Load(Resource.Drawable.ic_image_vector).Into(holder.LastMessagesIcon);
                    holder.TxtLastMessages.Text = ActivityContext.GetText(Resource.String.Lbl_SendImageFile);
                }
                else if (!string.IsNullOrEmpty(item.LastMessage.Media) && item.LastMessage.Media.Contains("video"))
                {
                    holder.LastMessagesIcon.Visibility = ViewStates.Visible;
                    Glide.With(ActivityContext).Load(Resource.Drawable.ic_video_player_vector).Into(holder.LastMessagesIcon);
                    holder.TxtLastMessages.Text = ActivityContext.GetText(Resource.String.Lbl_SendVideoFile);
                }
                else if (!string.IsNullOrEmpty(item.LastMessage.Media) && item.LastMessage.Media.Contains("sticker"))
                {
                    holder.LastMessagesIcon.Visibility = ViewStates.Visible;
                    Glide.With(ActivityContext).Load(Resource.Drawable.ic_sticker_vector).Into(holder.LastMessagesIcon);
                    holder.TxtLastMessages.Text = ActivityContext.GetText(Resource.String.Lbl_SendStickerFile);
                }
                else if (!string.IsNullOrEmpty(item.LastMessage.Media) && item.LastMessage.Media.Contains("sounds"))
                {
                    holder.LastMessagesIcon.Visibility = ViewStates.Visible;
                    Glide.With(ActivityContext).Load(Resource.Drawable.ic_radios_vector).Into(holder.LastMessagesIcon);
                    holder.TxtLastMessages.Text = ActivityContext.GetText(Resource.String.Lbl_SendAudioFile);
                }
                else if (!string.IsNullOrEmpty(item.LastMessage.Media) && item.LastMessage.Media.Contains("file"))
                {
                    holder.LastMessagesIcon.Visibility = ViewStates.Visible;
                    Glide.With(ActivityContext).Load(Resource.Drawable.ic_document_vector).Into(holder.LastMessagesIcon);
                    holder.TxtLastMessages.Text = ActivityContext.GetText(Resource.String.Lbl_SendFile);
                }
                else if (!string.IsNullOrEmpty(item.LastMessage.Stickers) && item.LastMessage.Stickers.Contains(".gif"))
                {
                    holder.LastMessagesIcon.Visibility = ViewStates.Visible;
                    Glide.With(ActivityContext).Load(Resource.Drawable.ic_gif_vector).Into(holder.LastMessagesIcon);
                    holder.TxtLastMessages.Text = ActivityContext.GetText(Resource.String.Lbl_SendGifFile);
                }
                else if (!string.IsNullOrEmpty(item.LastMessage.ProductId) && item.LastMessage.ProductId != "0")
                {
                    holder.TxtLastMessages.Text = ActivityContext.GetText(Resource.String.Lbl_SendProductFile);
                }
                else if (!string.IsNullOrEmpty(item.LastMessage.Lat) && !string.IsNullOrEmpty(item.LastMessage.Lng) && item.LastMessage.Lat != "0" && item.LastMessage.Lng != "0")
                {
                    holder.LastMessagesIcon.Visibility = ViewStates.Visible;
                    Glide.With(ActivityContext).Load(Resource.Drawable.icon_search_location_vector).Into(holder.LastMessagesIcon);
                    holder.TxtLastMessages.Text = ActivityContext.GetText(Resource.String.Lbl_SendLocationFile);
                }
                else
                {
                    holder.LastMessagesIcon.Visibility = ViewStates.Gone;
                    //if (!string.IsNullOrEmpty(LastMessage.Text) && LastMessage.Text.Contains("http"))
                    //{
                    //    holder.TxtLastMessages.Text = Methods.FunString.SubStringCutOf(LastMessage.Text, 30);
                    //}
                    //else
                    if (!string.IsNullOrEmpty(item.LastMessage.Text) && (item.LastMessage.Text.Contains("{&quot;Key&quot;") || item.LastMessage.Text.Contains("{key:^qu") || item.LastMessage.Text.Contains("{^key:^qu") || item.LastMessage.Text.Contains("{key:")))
                    {
                        holder.TxtLastMessages.Text = ActivityContext.GetText(Resource.String.Lbl_SendContactnumber);
                    }
                    else if (!string.IsNullOrEmpty(item.LastMessage.Text))
                    {
                        holder.TxtLastMessages.Text = Methods.FunString.DecodeString(Methods.FunString.SubStringCutOf(item.LastMessage.Text, 30));
                    }
                }

                //last seen time
                holder.TxtTimestamp.Text = Methods.Time.TimeAgo(int.Parse(item.LastseenUnixTime), true);

                //Online Or offline
                if (item.Lastseen == "on" && OnlineUsers.Equals(true))
                {
                    holder.TxtTimestamp.Text = ActivityContext.GetText(Resource.String.Lbl_Online);
                    holder.ImageLastseen.SetImageResource(Resource.Drawable.Green_Color);


                    if (AppSettings.ShowOnlineOfflineMessage)
                    {
                        var data = ListOnline.Contains(item.Name);
                        if (data == false)
                        {
                            ListOnline.Add(item.Name);

                            Toast toast = Toast.MakeText(ActivityContext, item.Name + " " + ActivityContext.GetText(Resource.String.Lbl_Online), ToastLength.Short);
                            toast.SetGravity(GravityFlags.Center, 0, 0);
                            toast.Show();
                        }
                    }
                }
                else
                {
                    holder.ImageLastseen.SetImageResource(Resource.Drawable.Grey_Offline);
                }

                //Check read message
                if (item.LastMessage.FromId != null && (item.LastMessage.ToId != null && (item.LastMessage.ToId != UserDetails.UserId && item.LastMessage.FromId == UserDetails.UserId)))
                {
                    if (item.LastMessage.Seen == "0")
                    {
                        holder.IconCheckCountMessages.Visibility = ViewStates.Invisible;
                        holder.TxtUsername.SetTypeface(Typeface.Default, TypefaceStyle.Normal);
                        holder.TxtLastMessages.SetTypeface(Typeface.Default, TypefaceStyle.Normal);
                    }
                    else
                    {
                        holder.IconCheckCountMessages.Visibility = ViewStates.Visible;
                        holder.TxtUsername.SetTypeface(Typeface.Default, TypefaceStyle.Normal);
                        holder.TxtLastMessages.SetTypeface(Typeface.Default, TypefaceStyle.Normal);
                        Glide.With(ActivityContext).Load(Resource.Drawable.ic_tick_vector).Into(holder.IconCheckCountMessages);
                    }
                }
                else if (item.LastMessage.FromId != null && (item.LastMessage.ToId != null && (item.LastMessage.ToId == UserDetails.UserId && item.LastMessage.FromId != UserDetails.UserId)))
                {
                    if (item.LastMessage.Seen == "0")
                    {
                        holder.TxtUsername.SetTypeface(Typeface.Default, TypefaceStyle.Bold);
                        holder.TxtLastMessages.SetTypeface(Typeface.Default, TypefaceStyle.Bold);

                        //var drawable = new TextDrawable.Builder().BeginConfig().FontSize(25).EndConfig().BuildRound("N", Color.ParseColor(AppSettings.MainColor));
                        //holder.IconCheckCountMessages.SetImageDrawable(drawable);
                        holder.IconCheckCountMessages.Visibility = ViewStates.Invisible;
                    }
                    else
                    {
                        holder.IconCheckCountMessages.Visibility = ViewStates.Invisible;
                        holder.TxtUsername.SetTypeface(Typeface.Default, TypefaceStyle.Normal);
                        holder.TxtLastMessages.SetTypeface(Typeface.Default, TypefaceStyle.Normal);
                    }
                }
            }
            catch (Exception e)
            {
                Methods.DisplayReportResultTrack(e);
            }
        }
Beispiel #8
0
 internal static void Clear(Context context, View view)
 {
     Glide.With(context).Clear(view);
 }
Beispiel #9
0
        protected override async void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.ViewOnlineTournaments);

            // Adding views
            circular_progress = FindViewById <ProgressBar>(Resource.Id.circularProgressOnlineTournaments);
            Button    gameTitle          = FindViewById <Button>(Resource.Id.gameTitleOnline);
            ImageView profilePicture     = FindViewById <ImageView>(Resource.Id.profilePictureOnlineTournament);
            Button    adminName          = FindViewById <Button>(Resource.Id.AdminNameOnlineTournament);
            Button    tourneyTitle       = FindViewById <Button>(Resource.Id.TitleOnlineTournament);
            Button    registrationStatus = FindViewById <Button>(Resource.Id.LiveStatusOnlineTournament);
            Button    finishedStatus     = FindViewById <Button>(Resource.Id.FinishedStatusOnlineTournament);
            Button    description        = FindViewById <Button>(Resource.Id.DescriptionOnlineTournament);
            Button    previous           = FindViewById <Button>(Resource.Id.previousTourneyOnline);
            Button    next            = FindViewById <Button>(Resource.Id.nextTourneyOnline);
            Button    eventPageButton = FindViewById <Button>(Resource.Id.ViewEventPageButtonOnlineTournament);

            circular_progress.Visibility = ViewStates.Visible;
            eventPageButton.Enabled      = false;
            // Loading tournaments
            var firebase = new FirebaseClient("https://fir-test-1bdb3.firebaseio.com/");
            var items    = await firebase
                           .Child("tournaments")
                           .OnceAsync <TournamentViewModel>();

            List <TournamentViewModel> query = new List <TournamentViewModel>();


            // Filtering
            foreach (var item in items)
            {
                if (item.Object.online.Equals("true"))
                {
                    query.Add(item.Object);
                }
            }

            query.Reverse();

            // Loading users' data to get profile pictures
            var users = await firebase.Child("users").OnceAsync <UserViewModel>();

            // Loading first item
            int tourneyCounter = 0; // To keep track of opened tournament

            gameTitle.Text = query[0].Game;

            foreach (var item in users)
            {
                if (item.Object.Email.Equals(query[tourneyCounter].AdminID))
                {
                    if (!item.Object.PhotoURL.Equals(string.Empty))
                    {
                        Glide.With(this).Load(item.Object.PhotoURL).Apply(RequestOptions.CircleCropTransform()).Into(profilePicture);
                    }
                    adminName.Text = item.Object.FirstName + " " + item.Object.LastName ?? "";
                }
            }

            tourneyTitle.Text = query[0].Title;

            if (query[0].Live.Equals("false"))
            {
                registrationStatus.Text = "Registrations Open!";
            }
            else
            {
                registrationStatus.Text = "Registrations Closed!";
            }

            if (query[0].Finished.Equals("true"))
            {
                finishedStatus.Text = "Tournament is Over..";
            }
            else
            {
                finishedStatus.Text = "Tournament is still going on!";
            }

            description.Text = "Description:\n\n" + query[0].Description;

            eventPageButton.Enabled      = true;
            circular_progress.Visibility = ViewStates.Invisible;

            next.Click += (sender, e) =>
            {
                if (query.Count() - 1 == tourneyCounter)
                {
                    // No new Tournaments
                    Toast.MakeText(ApplicationContext, "No more tournaments", ToastLength.Short).Show();
                }
                else
                {
                    tourneyCounter++;

                    gameTitle.Text = query[tourneyCounter].Game;

                    foreach (var item in users)
                    {
                        if (item.Object.Email.Equals(query[tourneyCounter].AdminID))
                        {
                            if (!item.Object.PhotoURL.Equals(string.Empty))
                            {
                                Glide.With(this).Load(item.Object.PhotoURL).Apply(RequestOptions.CircleCropTransform()).Into(profilePicture);
                            }
                            adminName.Text = item.Object.FirstName + " " + item.Object.LastName ?? "";
                        }
                    }

                    tourneyTitle.Text = query[tourneyCounter].Title;

                    if (query[tourneyCounter].Live.Equals("false"))
                    {
                        registrationStatus.Text = "Registrations Open!";
                    }
                    else
                    {
                        registrationStatus.Text = "Registrations Closed!";
                    }

                    if (query[tourneyCounter].Finished.Equals("true"))
                    {
                        finishedStatus.Text = "Tournament is Over..";
                    }
                    else
                    {
                        finishedStatus.Text = "Tournament is still going on!";
                    }

                    description.Text = "Description:\n\n" + query[tourneyCounter].Description;
                }
            };

            previous.Click += (sender, e) =>
            {
                if (0 == tourneyCounter)
                {
                    // No new Tournaments
                    Toast.MakeText(ApplicationContext, "No more tournaments", ToastLength.Short).Show();
                }
                else
                {
                    tourneyCounter--;

                    gameTitle.Text = query[0].Game;

                    foreach (var item in users)
                    {
                        if (item.Object.Email.Equals(query[tourneyCounter].AdminID))
                        {
                            if (!item.Object.PhotoURL.Equals(string.Empty))
                            {
                                Glide.With(this).Load(item.Object.PhotoURL).Apply(RequestOptions.CircleCropTransform()).Into(profilePicture);
                            }
                            adminName.Text = item.Object.FirstName + " " + item.Object.LastName ?? "";
                        }
                    }

                    tourneyTitle.Text = query[tourneyCounter].Title;

                    if (query[tourneyCounter].Live.Equals("false"))
                    {
                        registrationStatus.Text = "Registrations Open!";
                    }
                    else
                    {
                        registrationStatus.Text = "Registrations Closed!";
                    }

                    if (query[tourneyCounter].Finished.Equals("true"))
                    {
                        finishedStatus.Text = "Tournament is Over..";
                    }
                    else
                    {
                        finishedStatus.Text = "Tournament is still going on!";
                    }

                    description.Text = "Description:\n\n" + query[tourneyCounter].Description;
                }
            };

            eventPageButton.Click += (sender, e) =>
            {
                Intent viewEventPageActivity = new Intent(ApplicationContext, typeof(ViewEventPageActivity));
                viewEventPageActivity.PutExtra("tourneyID", query[tourneyCounter].TournamentID);
                StartActivity(viewEventPageActivity);
            };

            /*
             * string[] events = new string[query.Count()];
             *
             * for (int i = 0; i < query.Count(); i++)
             * {
             *  events[i] = query.ToList().ElementAt(i).Title + "\n  Tournament ID -  " + query.ToList().ElementAt(i).TournamentID;
             * }
             * ListAdapter = new ArrayAdapter<string>(this, Resource.Layout.ViewOnlineTournaments, events);
             *
             * ListView.ItemClick += (sender, e) =>
             * {
             *  string tourneyID = string.Empty;
             *  tourneyID = ((TextView)e.View).Text;
             *  string[] temps = tourneyID.Split(' ');
             *  tourneyID = temps[temps.Length - 1];
             *  Intent viewEventPageActivity = new Intent(ApplicationContext, typeof(ViewEventPageActivity));
             *  viewEventPageActivity.PutExtra("tourneyID", tourneyID);
             *  StartActivity(viewEventPageActivity);
             * };
             */
        }
        private void LoadStickerOfChatItem(StickerViewHolder holder, int position, GetChatConversationsObject.Messages message)
        {
            try
            {
                string imageUrl = message.Sticker;
                string fileSavedPath;

                try
                {
                    DateTime time = Methods.Time.UnixTimeStampToDateTime(int.Parse(message.CreatedAt));
                    holder.Time.Text = time.ToShortTimeString();
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                }

                if (imageUrl.Contains("http://") || imageUrl.Contains("https://"))
                {
                    var    fileName  = imageUrl.Split('_').Last();
                    string imageFile = Methods.MultiMedia.GetMediaFrom_Disk(Methods.Path.FolderDiskSticker, fileName);
                    if (imageFile == "File Dont Exists")
                    {
                        holder.LoadingProgressView.Indeterminate = false;
                        holder.LoadingProgressView.Visibility    = ViewStates.Visible;

                        var url = imageUrl.Contains("media3.giphy.com/");
                        if (url)
                        {
                            imageUrl = imageUrl.Replace(Client.WebsiteUrl, "");
                        }

                        Methods.MultiMedia.DownloadMediaTo_DiskAsync(Methods.Path.FolderDiskSticker, imageUrl);

                        Glide.With(ActivityContext).Load(imageUrl).Apply(new RequestOptions().Placeholder(Resource.Drawable.ImagePlacholder)).Into(holder.ImageView);

                        //GlideImageLoader.LoadImage(ActivityContext,imageUrl, holder.ImageView, ImageStyle.CenterCrop, ImagePlaceholders.Drawable);

                        holder.LoadingProgressView.Indeterminate = false;
                        holder.LoadingProgressView.Visibility    = ViewStates.Gone;
                    }
                    else
                    {
                        fileSavedPath = imageFile;

                        Glide.With(ActivityContext).Load(fileSavedPath).Apply(new RequestOptions().Placeholder(Resource.Drawable.ImagePlacholder)).Into(holder.ImageView);

                        //GlideImageLoader.LoadImage(ActivityContext,fileSavedPath, holder.ImageView, ImageStyle.CenterCrop, ImagePlaceholders.Drawable);

                        holder.LoadingProgressView.Indeterminate = false;
                        holder.LoadingProgressView.Visibility    = ViewStates.Gone;
                    }
                }
                else
                {
                    fileSavedPath = imageUrl;

                    Glide.With(ActivityContext).Load(fileSavedPath).Apply(new RequestOptions().Placeholder(Resource.Drawable.ImagePlacholder)).Into(holder.ImageView);

                    //GlideImageLoader.LoadImage(ActivityContext,fileSavedPath, holder.ImageView, ImageStyle.CenterCrop, ImagePlaceholders.Drawable);

                    holder.LoadingProgressView.Indeterminate = false;
                    holder.LoadingProgressView.Visibility    = ViewStates.Gone;
                }


                holder.LytParent.Activated = SelectedItems.Get(position, false);
                if (!holder.LytParent.HasOnClickListeners)
                {
                    holder.LytParent.Click += delegate
                    {
                        try
                        {
                            if (ClickListener == null)
                            {
                                return;
                            }

                            ClickListener.ItemClick(holder.LytParent, message, position);
                        }
                        catch (Exception e)
                        {
                            Console.WriteLine(e);
                        }
                    };

                    holder.LytParent.LongClick += delegate
                    {
                        try
                        {
                            if (ClickListener == null)
                            {
                                return;
                            }

                            ClickListener.ItemLongClick(holder.LytParent, message, position);
                        }
                        catch (Exception e)
                        {
                            Console.WriteLine(e);
                        }
                    };
                }
                ToggleCheckedBackground(holder, position);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Beispiel #11
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            //MobileAds.Initialize(this, "ca-app-pub-8471384010278314~5446313310");
            SetContentView(Resource.Layout.game_activity);

            textViewFigure     = FindViewById <TextView>(Resource.Id.textViewPlayerFigure);
            textViewPlayerTurn = FindViewById <TextView>(Resource.Id.textViewPlayerTurn);

            //Init cells
            a1 = FindViewById <ImageButton>(Resource.Id.buttonA1);
            a2 = FindViewById <ImageButton>(Resource.Id.buttonA2);
            a3 = FindViewById <ImageButton>(Resource.Id.buttonA3);
            b1 = FindViewById <ImageButton>(Resource.Id.buttonB1);
            b2 = FindViewById <ImageButton>(Resource.Id.buttonB2);
            b3 = FindViewById <ImageButton>(Resource.Id.buttonB3);
            c1 = FindViewById <ImageButton>(Resource.Id.buttonC1);
            c2 = FindViewById <ImageButton>(Resource.Id.buttonC2);
            c3 = FindViewById <ImageButton>(Resource.Id.buttonC3);

            //Add init
            adView = FindViewById <AdView>(Resource.Id.adView);
            var adRequest = new AdRequest.Builder().Build();

            adView.LoadAd(adRequest);

            //Init rows
            rowA       = new[] { a1, a2, a3 };
            rowB       = new[] { b1, b2, b3 };
            rowC       = new[] { c1, c2, c3 };
            boardTiles = new ImageButton[][] { rowA, rowB, rowC };
            allButtons = new[] { a1, a2, a3, b1, b2, b3, c1, c2, c3 };

            // Initialize Game
            selectedFigure = (Figures)Intent.GetIntExtra(StringConstants.FIGURE, (int)Figures.X);
            Settings.Set(StringConstants.FIGURE, (int)selectedFigure);

            //This is not memory leak cuase game activity is always on activity stack
            for (int y = 0; y < boardTiles.Length; y++)        //row
            {
                for (int x = 0; x < boardTiles[y].Length; x++) //column
                {
                    int tileNumberY = y;
                    int tileNumberX = x;
                    boardTiles[y][x].Click += (o, e) =>
                    {
                        textViewPlayerTurn.Text = $"{gameLogicController.GetTurn()}{StringConstants.TURN}";
                        Move playerMove = gameLogicController.MakeMove(tileNumberY, tileNumberX);

                        if (playerMove.Figure == Figures.X)
                        {
                            //Get X image from cache and set to ImageButton
                            Glide.With(this).Load(StringConstants.X_URL).Into(boardTiles[playerMove.Y][playerMove.X]);

                            //Add current gamestate to array
                            gameState.Add(boardTiles[playerMove.Y][playerMove.X].Id, (int)Figures.X);
                        }
                        else
                        {
                            //Get O image from cache and set to ImageButton
                            Glide.With(this).Load(StringConstants.O_URL).Into(boardTiles[playerMove.Y][playerMove.X]);

                            //Add current gamestate to array
                            gameState.Add(boardTiles[playerMove.Y][playerMove.X].Id, (int)Figures.O);
                        }
                        //Save gamestate to persistent storage
                        //Not the best and most performant way but for small amout of data it is ok
                        // It could be replaced with SQLite or some other persistent storage
                        Settings.Set(StringConstants.GAME_STATE, JsonSerializer.ToJsonString(gameState));
                        boardTiles[playerMove.Y][playerMove.X].Enabled = false;

                        if (playerMove.IsEndingMove())
                        {
                            gameState.Clear();
                            Settings.Set(StringConstants.GAME_STATE, JsonSerializer.ToJsonString(gameState));
                            ToEndingScreen(playerMove.EndingMessage);
                            return;
                        }
                    };
                }
            }

            bool initFromState = Intent.GetBooleanExtra(StringConstants.INIT_FROM_STATE, false);

            InitGameBoard(initFromState);
        }
        private void LoadGifOfChatItem(GifViewHolder holder, int position, GetChatConversationsObject.Messages item)
        {
            try
            {
                if (string.IsNullOrEmpty(item.Sticker))
                {
                    return;
                }

                string imageUrl = item.Sticker;
                string fileSavedPath;

                // G_fixed_height_small_url, // UrlGif - view  >>  mediaFileName
                // G_fixed_height_small_mp4, //MediaGif - sent >>  media

                if (imageUrl.Contains("http://") || imageUrl.Contains("https://"))
                {
                    var    fileName  = imageUrl.Split('_').Last();
                    string imageFile = Methods.MultiMedia.GetMediaFrom_Disk(Methods.Path.FolderDiskGif, fileName);
                    if (imageFile == "File Dont Exists")
                    {
                        holder.LoadingProgressView.Indeterminate = false;
                        holder.LoadingProgressView.Visibility    = ViewStates.Visible;

                        string filePath  = Path.Combine(Methods.Path.FolderDiskGif);
                        string mediaFile = filePath + "/" + fileName;
                        fileSavedPath = mediaFile;

                        var url = imageUrl.Contains("media3.giphy.com/");
                        if (url)
                        {
                            imageUrl = imageUrl.Replace(Client.WebsiteUrl, "");
                        }

                        WebClient webClient = new WebClient();

                        webClient.DownloadDataAsync(new System.Uri(imageUrl));
                        webClient.DownloadProgressChanged += (sender, args) =>
                        {
                            var progress = args.ProgressPercentage;
                        };

                        webClient.DownloadDataCompleted += (s, e) =>
                        {
                            try
                            {
                                if (!Directory.Exists(filePath))
                                {
                                    Directory.CreateDirectory(filePath);
                                }

                                File.WriteAllBytes(mediaFile, e.Result);

                                //var mediaScanIntent = new Intent(Intent.ActionMediaScannerScanFile);
                                //mediaScanIntent.SetData(Android.Net.Uri.FromFile(new Java.IO.File(mediaFile)));
                                //ActivityContext.SendBroadcast(mediaScanIntent);

                                // Tell the media scanner about the new file so that it is
                                // immediately available to the user.
                                MediaScannerConnection.ScanFile(Application.Context, new[] { mediaFile }, null, null);

                                var file = Android.Net.Uri.FromFile(new Java.IO.File(mediaFile));
                                Glide.With(ActivityContext).Load(file.Path).Apply(new RequestOptions().Placeholder(Resource.Drawable.ImagePlacholder)).Into(holder.ImageGifView);

                                holder.LoadingProgressView.Indeterminate = false;
                                holder.LoadingProgressView.Visibility    = ViewStates.Gone;
                            }
                            catch (Exception ex)
                            {
                                Console.WriteLine(ex);
                            }
                        };
                    }
                    else
                    {
                        fileSavedPath = imageFile;

                        Glide.With(ActivityContext).Load(fileSavedPath).Apply(new RequestOptions().Placeholder(Resource.Drawable.ImagePlacholder)).Into(holder.ImageGifView);

                        //GlideImageLoader.LoadImage(ActivityContext,fileSavedPath, holder.ImageView, ImageStyle.CenterCrop, ImagePlaceholders.Drawable);

                        holder.LoadingProgressView.Indeterminate = false;
                        holder.LoadingProgressView.Visibility    = ViewStates.Gone;
                    }
                }
                else
                {
                    fileSavedPath = imageUrl;

                    Glide.With(ActivityContext).Load(fileSavedPath).Apply(new RequestOptions().Placeholder(Resource.Drawable.ImagePlacholder)).Into(holder.ImageGifView);

                    //GlideImageLoader.LoadImage(ActivityContext,fileSavedPath, holder.ImageView, ImageStyle.CenterCrop, ImagePlaceholders.Drawable);

                    holder.LoadingProgressView.Indeterminate = false;
                    holder.LoadingProgressView.Visibility    = ViewStates.Gone;
                }

                if (!holder.ImageGifView.HasOnClickListeners)
                {
                    holder.ImageGifView.Click += (sender, args) =>
                    {
                        try
                        {
                            string imageFile = Methods.MultiMedia.CheckFileIfExits(fileSavedPath);
                            if (imageFile != "File Dont Exists")
                            {
                                Java.IO.File file2    = new Java.IO.File(fileSavedPath);
                                var          photoUri = FileProvider.GetUriForFile(ActivityContext, ActivityContext.PackageName + ".fileprovider", file2);
                                Intent       intent   = new Intent();
                                intent.SetAction(Intent.ActionView);
                                intent.AddFlags(ActivityFlags.GrantReadUriPermission);
                                intent.SetDataAndType(photoUri, "image/*");
                                ActivityContext.StartActivity(intent);
                            }
                            else
                            {
                                Intent intent = new Intent(Intent.ActionView, Uri.Parse(imageUrl));
                                ActivityContext.StartActivity(intent);
                            }
                        }
                        catch (Exception e)
                        {
                            Console.WriteLine(e);
                        }
                    };
                }

                holder.LytParent.Activated = SelectedItems.Get(position, false);
                if (!holder.LytParent.HasOnClickListeners)
                {
                    holder.LytParent.Click += delegate
                    {
                        try
                        {
                            if (ClickListener == null)
                            {
                                return;
                            }

                            ClickListener.ItemClick(holder.LytParent, item, position);
                        }
                        catch (Exception e)
                        {
                            Console.WriteLine(e);
                        }
                    };

                    holder.LytParent.LongClick += delegate
                    {
                        try
                        {
                            if (ClickListener == null)
                            {
                                return;
                            }

                            ClickListener.ItemLongClick(holder.LytParent, item, position);
                        }
                        catch (Exception e)
                        {
                            Console.WriteLine(e);
                        }
                    };
                }

                ToggleCheckedBackground(holder, position);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
        private void LoadImageOfChatItem(ImageViewHolder holder, int position, GetChatConversationsObject.Messages message)
        {
            try
            {
                string imageUrl = message.Media.Contains("upload/chat/") && !message.Media.Contains(Client.WebsiteUrl) ? Client.WebsiteUrl + "/" + message.Media : message.Media;

                string fileSavedPath;

                try
                {
                    DateTime time = Methods.Time.UnixTimeStampToDateTime(int.Parse(message.CreatedAt));
                    holder.Time.Text = time.ToShortTimeString();
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                }

                if (imageUrl.Contains("http://") || imageUrl.Contains("https://"))
                {
                    var    fileName  = imageUrl.Split('/').Last();
                    string imageFile = Methods.MultiMedia.GetMediaFrom_Gallery(Methods.Path.FolderDcimImage, fileName);
                    if (imageFile == "File Dont Exists")
                    {
                        holder.LoadingProgressView.Indeterminate = false;
                        holder.LoadingProgressView.Visibility    = ViewStates.Visible;

                        string filePath  = Path.Combine(Methods.Path.FolderDcimImage);
                        string mediaFile = filePath + "/" + fileName;
                        fileSavedPath = mediaFile;

                        WebClient webClient = new WebClient();

                        webClient.DownloadDataAsync(new System.Uri(imageUrl));
                        webClient.DownloadProgressChanged += (sender, args) =>
                        {
                            var progress = args.ProgressPercentage;
                        };

                        webClient.DownloadDataCompleted += (s, e) =>
                        {
                            try
                            {
                                if (!Directory.Exists(filePath))
                                {
                                    Directory.CreateDirectory(filePath);
                                }

                                File.WriteAllBytes(mediaFile, e.Result);

                                //var mediaScanIntent = new Intent(Intent.ActionMediaScannerScanFile);
                                //mediaScanIntent.SetData(Android.Net.Uri.FromFile(new Java.IO.File(mediaFile)));
                                //ActivityContext.SendBroadcast(mediaScanIntent);

                                // Tell the media scanner about the new file so that it is
                                // immediately available to the user.
                                MediaScannerConnection.ScanFile(Application.Context, new[] { mediaFile }, null, null);

                                var file = Android.Net.Uri.FromFile(new Java.IO.File(mediaFile));
                                Glide.With(ActivityContext).Load(file.Path).Apply(Options).Into(holder.ImageView);

                                holder.LoadingProgressView.Indeterminate = false;
                                holder.LoadingProgressView.Visibility    = ViewStates.Gone;
                            }
                            catch (Exception ex)
                            {
                                Console.WriteLine(ex);
                            }
                        };
                    }
                    else
                    {
                        fileSavedPath = imageFile;

                        var file = Android.Net.Uri.FromFile(new Java.IO.File(imageFile));
                        Glide.With(ActivityContext).Load(file.Path).Apply(Options).Into(holder.ImageView);

                        holder.LoadingProgressView.Indeterminate = false;
                        holder.LoadingProgressView.Visibility    = ViewStates.Gone;
                    }
                }
                else
                {
                    fileSavedPath = imageUrl;

                    var file = Android.Net.Uri.FromFile(new Java.IO.File(imageUrl));
                    Glide.With(ActivityContext).Load(file.Path).Apply(Options).Into(holder.ImageView);

                    //GlideImageLoader.LoadImage(ActivityContext, imageUrl, holder.ImageView, ImageStyle.CenterCrop, ImagePlaceholders.Drawable);

                    holder.LoadingProgressView.Indeterminate = false;
                    holder.LoadingProgressView.Visibility    = ViewStates.Gone;
                }

                if (!holder.ImageView.HasOnClickListeners)
                {
                    holder.ImageView.Click += (sender, args) =>
                    {
                        try
                        {
                            string imageFile = Methods.MultiMedia.CheckFileIfExits(fileSavedPath);
                            if (imageFile != "File Dont Exists")
                            {
                                Java.IO.File file2    = new Java.IO.File(fileSavedPath);
                                var          photoUri = FileProvider.GetUriForFile(ActivityContext, ActivityContext.PackageName + ".fileprovider", file2);
                                Intent       intent   = new Intent();
                                intent.SetAction(Intent.ActionView);
                                intent.AddFlags(ActivityFlags.GrantReadUriPermission);
                                intent.SetDataAndType(photoUri, "image/*");
                                ActivityContext.StartActivity(intent);
                            }
                            else
                            {
                                Intent intent = new Intent(Intent.ActionView, Uri.Parse(imageUrl));
                                ActivityContext.StartActivity(intent);
                            }
                        }
                        catch (Exception e)
                        {
                            Console.WriteLine(e);
                        }
                    };
                }

                holder.LytParent.Activated = SelectedItems.Get(position, false);
                if (!holder.LytParent.HasOnClickListeners)
                {
                    holder.LytParent.Click += delegate
                    {
                        try
                        {
                            if (ClickListener == null)
                            {
                                return;
                            }

                            ClickListener.ItemClick(holder.LytParent, message, position);
                        }
                        catch (Exception e)
                        {
                            Console.WriteLine(e);
                        }
                    };

                    holder.LytParent.LongClick += delegate
                    {
                        try
                        {
                            if (ClickListener == null)
                            {
                                return;
                            }

                            ClickListener.ItemLongClick(holder.LytParent, message, position);
                        }
                        catch (Exception e)
                        {
                            Console.WriteLine(e);
                        }
                    };
                }


                ToggleCheckedBackground(holder, position);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
        /// <summary>
        /// Views the formulario user.
        /// </summary>
        /// <param name="activity">Activity.</param>
        public static void viewFormularioUser(Activity activity)
        {
            customDialog = new Dialog(activity, Resource.Style.Theme_Dialog_Translucent);
            var ha = (HomeAgregaProductoActivity)activity;

            customDialog.SetCancelable(false);
            customDialog.SetContentView(Resource.Layout.ingreso_usuarioresponsable_dialog);
            EditText     txtNombreUsuario          = customDialog.FindViewById <EditText>(Resource.Id.txtUser);
            ImageView    imgLoadingBtnIngresarUser = customDialog.FindViewById <ImageView>(Resource.Id.imgLoadingBtnIngresarUser);
            TextView     lblMensajeError           = customDialog.FindViewById <TextView>(Resource.Id.lblMensajeError);
            TextView     lblBtnIngresarUser        = customDialog.FindViewById <TextView>(Resource.Id.lblBtnIngresarUser);
            LinearLayout llBtnIngresarUser         = customDialog.FindViewById <LinearLayout>(Resource.Id.llBtnIngresarUser);

            Glide.With(activity).Load(Resource.Drawable.cargando).Into(imgLoadingBtnIngresarUser);

            txtNombreUsuario.ImeOptions = Android.Views.InputMethods.ImeAction.Done;
            if (!string.IsNullOrEmpty(DataManager.nombreUsuario))
            {
                txtNombreUsuario.Text     = DataManager.nombreUsuario;
                llBtnIngresarUser.Enabled = true;
                llBtnIngresarUser.SetBackgroundResource(Resource.Drawable.cssBotonAgregarProducto);
            }
            else
            {
                txtNombreUsuario.Text     = string.Empty;
                llBtnIngresarUser.Enabled = false;
                llBtnIngresarUser.SetBackgroundResource(Resource.Drawable.cssBotonBloqueado);
            }

            txtNombreUsuario.TextChanged += delegate
            {
                if (txtNombreUsuario.Text.Trim().Length >= 5 || txtNombreUsuario.Text.Trim().Length == 0)
                {
                    lblMensajeError.Text = string.Empty;
                }
                if (!string.IsNullOrEmpty(txtNombreUsuario.Text))
                {
                    llBtnIngresarUser.Enabled = true;
                    llBtnIngresarUser.SetBackgroundResource(Resource.Drawable.cssBotonAgregarProducto);
                }
                else
                {
                    llBtnIngresarUser.Enabled = false;
                    llBtnIngresarUser.SetBackgroundResource(Resource.Drawable.cssBotonBloqueado);
                }
            };

            llBtnIngresarUser.Click += delegate
            {
                imgLoadingBtnIngresarUser.Visibility = ViewStates.Visible;
                lblBtnIngresarUser.Visibility        = ViewStates.Gone;
                if (txtNombreUsuario.Text.Trim().Length >= 5)
                {
                    DataManager.nombreUsuario            = txtNombreUsuario.Text.Trim();
                    imgLoadingBtnIngresarUser.Visibility = ViewStates.Gone;
                    lblBtnIngresarUser.Visibility        = ViewStates.Visible;
                    ha.nombreUsuarioToolbar();
                    customDialog.Dismiss();
                    AnalyticService.TrackAnalytics("Ingreso Usuario", new Dictionary <string, string> {
                        { "Category", "Usuario " + DataManager.nombreUsuario + " agregado, el dia " + DateTime.Now },
                        { "Action", "click llBtnIngresarUser" }
                    });
                }
                else
                {
                    lblMensajeError.Text = "Error al ingresar los datos";
                    AnalyticService.TrackAnalytics("Error ngreso Usuario", new Dictionary <string, string> {
                        { "Category", "Usuario " + txtNombreUsuario.Text + " agregado, el dia " + DateTime.Now },
                        { "Action", "click llBtnIngresarUser" }
                    });
                    imgLoadingBtnIngresarUser.Visibility = ViewStates.Gone;
                    lblBtnIngresarUser.Visibility        = ViewStates.Visible;
                }
            };
            customDialog.Window.SetStatusBarColor(Android.Graphics.Color.Transparent);
            customDialog.Show();
        }
Beispiel #15
0
        private void Get_Data_Event()
        {
            try
            {
                if (EventData != null)
                {
                    Glide.With(this).Load(EventData.Cover).Apply(new RequestOptions()).Into(ImageEventCover);

                    Name = Methods.FunString.DecodeString(EventData.Name);

                    TxtName.Text           = Name;
                    ToolbarLayout.Title    = Name;
                    SupportActionBar.Title = Name;

                    if (string.IsNullOrEmpty(EventData.GoingCount))
                    {
                        EventData.GoingCount = "0";
                    }

                    if (string.IsNullOrEmpty(EventData.InterestedCount))
                    {
                        EventData.InterestedCount = "0";
                    }

                    TxtGoing.Text      = EventData.GoingCount + " " + GetText(Resource.String.Lbl_GoingPeople);
                    TxtInterested.Text = EventData.InterestedCount + " " + GetText(Resource.String.Lbl_InterestedPeople);
                    TxtLocation.Text   = EventData.Location;

                    TxtStartDate.Text = EventData.StartDate;
                    TxtEndDate.Text   = EventData.EndDate;


                    if (!string.IsNullOrEmpty(EventData.Description))
                    {
                        var description    = Methods.FunString.DecodeString(EventData.Description);
                        var readMoreOption = new StReadMoreOption.Builder()
                                             .TextLength(250, StReadMoreOption.TypeCharacter)
                                             .MoreLabel(GetText(Resource.String.Lbl_ReadMore))
                                             .LessLabel(GetText(Resource.String.Lbl_ReadLess))
                                             .MoreLabelColor(Color.ParseColor(AppSettings.MainColor))
                                             .LessLabelColor(Color.ParseColor(AppSettings.MainColor))
                                             .LabelUnderLine(true)
                                             .Build();
                        readMoreOption.AddReadMoreTo(TxtDescriptionText, new String(description));
                    }
                    else
                    {
                        TxtDescription.Visibility     = ViewStates.Gone;
                        TxtDescriptionText.Visibility = ViewStates.Gone;
                    }

                    if (EventData.IsGoing != null && EventData.IsGoing.Value)
                    {
                        BtnGo.SetBackgroundResource(Resource.Drawable.follow_button_profile_friends_pressed);
                        BtnGo.SetTextColor(Color.ParseColor("#ffffff"));
                        BtnGo.Text = GetText(Resource.String.Lbl_Going);
                        BtnGo.Tag  = "true";
                    }
                    else
                    {
                        BtnGo.SetBackgroundResource(Resource.Drawable.follow_button_profile_friends);
                        BtnGo.SetTextColor(Color.ParseColor(AppSettings.MainColor));
                        BtnGo.Text = GetText(Resource.String.Lbl_Go);
                        BtnGo.Tag  = "false";
                    }

                    if (EventData.IsInterested != null && EventData.IsInterested.Value)
                    {
                        BtnInterested.SetBackgroundResource(Resource.Drawable.follow_button_profile_friends_pressed);
                        BtnInterested.SetTextColor(Color.ParseColor("#ffffff"));
                        BtnInterested.Text = GetText(Resource.String.Lbl_Interested);
                        BtnInterested.Tag  = "true";
                    }
                    else
                    {
                        BtnInterested.SetBackgroundResource(Resource.Drawable.follow_button_profile_friends);
                        BtnInterested.SetTextColor(Color.ParseColor(AppSettings.MainColor));
                        BtnInterested.Text = GetText(Resource.String.Lbl_Interested);
                        BtnInterested.Tag  = "false";
                    }

                    //add post
                    var checkSection = PostFeedAdapter.ListDiffer.FirstOrDefault(a => a.TypeView == PostModelType.AddPostBox);
                    if (checkSection == null)
                    {
                        Combiner.AddPostBoxPostView("Event", -1, new PostDataObject()
                        {
                            Event = new EventUnion()
                            {
                                EventClass = EventData
                            }
                        });

                        PostFeedAdapter.NotifyItemInserted(PostFeedAdapter.ListDiffer.Count - 1);
                    }

                    StartApiService();
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Beispiel #16
0
        public static void LoadImage(Activity activity, string imageUri, ImageView image, ImageStyle style, ImagePlaceholders imagePlaceholders, bool compress = false, RequestOptions options = null)
        {
            try
            {
                if (string.IsNullOrEmpty(imageUri) || string.IsNullOrWhiteSpace(imageUri) || image == null || activity?.IsDestroyed != false)
                {
                    return;
                }

                imageUri = imageUri.Replace(" ", "");

                var newImage = Glide.With(activity);

                options ??= GetOptions(style, imagePlaceholders);

                if (compress && style != ImageStyle.RoundedCrop)
                {
                    if (imageUri.Contains("avatar") || imageUri.Contains("Avatar"))
                    {
                        options.Override(AppSettings.AvatarPostSize);
                    }
                    else if (imageUri.Contains("gif"))
                    {
                        options.Override(AppSettings.ImagePostSize);
                    }
                    else
                    {
                        options.Override(AppSettings.ImagePostSize);
                    }
                }

                if (compress)
                {
                    options.Override(AppSettings.ImagePostSize);
                }

                if (imageUri.Contains("no_profile_image") || imageUri.Contains("blackdefault") || imageUri.Contains("no_profile_image_circle") ||
                    imageUri.Contains("ImagePlacholder") || imageUri.Contains("ImagePlacholder_circle") || imageUri.Contains("Grey_Offline") ||
                    imageUri.Contains("Image_File") || imageUri.Contains("Audio_File") || imageUri.Contains("addImage") || imageUri.Contains("d-group") ||
                    imageUri.Contains("d-cover") || imageUri.Contains("d-avatar") || imageUri.Contains("user_anonymous"))
                {
                    if (imageUri.Contains("no_profile_image_circle"))
                    {
                        newImage.Load(Resource.Drawable.no_profile_image_circle).Apply(options).Into(image);
                    }
                    else if (imageUri.Contains("no_profile_image") || imageUri.Contains("d-avatar"))
                    {
                        newImage.Load(Resource.Drawable.no_profile_image).Apply(options).Into(image);
                    }
                    else if (imageUri.Contains("ImagePlacholder"))
                    {
                        newImage.Load(Resource.Drawable.ImagePlacholder).Apply(options).Into(image);
                    }
                    else if (imageUri.Contains("ImagePlacholder_circle"))
                    {
                        newImage.Load(Resource.Drawable.ImagePlacholder_circle).Apply(options).Into(image);
                    }
                    else if (imageUri.Contains("blackdefault"))
                    {
                        newImage.Load(Resource.Drawable.blackdefault).Apply(options).Into(image);
                    }
                    else if (imageUri.Contains("Grey_Offline"))
                    {
                        newImage.Load(Resource.Drawable.Grey_Offline).Apply(options).Into(image);
                    }
                    else if (imageUri.Contains("Image_File"))
                    {
                        newImage.Load(Resource.Drawable.Image_File).Apply(options).Into(image);
                    }
                    else if (imageUri.Contains("Audio_File"))
                    {
                        newImage.Load(Resource.Drawable.Audio_File).Apply(options).Into(image);
                    }
                    else if (imageUri.Contains("addImage"))
                    {
                        newImage.Load(Resource.Drawable.addImage).Apply(options).Into(image);
                    }
                    else if (imageUri.Contains("d-group"))
                    {
                        newImage.Load(Resource.Drawable.default_group).Apply(options).Into(image);
                    }
                    else if (imageUri.Contains("d-page"))
                    {
                        newImage.Load(Resource.Drawable.default_page).Apply(options).Into(image);
                    }
                    else if (imageUri.Contains("d-cover"))
                    {
                        newImage.Load(Resource.Drawable.Cover_image).Apply(options).Into(image);
                    }
                    else if (imageUri.Contains("user_anonymous"))
                    {
                        newImage.Load(Resource.Drawable.user_anonymous).Apply(options).Into(image);
                    }
                }
                else if (!string.IsNullOrEmpty(imageUri) && imageUri.Contains("http"))
                {
                    newImage.Load(imageUri).Apply(options).Into(image);
                }
                else if (!string.IsNullOrEmpty(imageUri) && (imageUri.Contains("file://") || imageUri.Contains("content://") || imageUri.Contains("storage") || imageUri.Contains("/data/user/0/")))
                {
                    File           file2    = new File(imageUri);
                    var            photoUri = FileProvider.GetUriForFile(activity, activity.PackageName + ".fileprovider", file2);
                    RequestOptions option   = style == ImageStyle.CircleCrop ? new RequestOptions().CircleCrop() : new RequestOptions();
                    Glide.With(activity).Load(photoUri).Apply(option).Into(image);
                }
                else
                {
                    newImage.Load(Resource.Drawable.no_profile_image).Apply(options).Into(image);
                }
            }
            catch (Exception e)
            {
                Methods.DisplayReportResultTrack(e);
            }
        }
Beispiel #17
0
        // Replace the contents of a view (invoked by the layout manager)
        public override void OnBindViewHolder(RecyclerView.ViewHolder viewHolder, int position)
        {
            try
            {
                if (viewHolder is JobsAdapterViewHolder holder)
                {
                    var item = JobList[position];
                    if (item != null)
                    {
                        if (item.Image.Contains("http"))
                        {
                            var image = item.Image.Replace(Client.WebsiteUrl + "/", "");
                            if (!image.Contains("http"))
                            {
                                item.Image = Client.WebsiteUrl + "/" + image;
                            }
                            else
                            {
                                item.Image = image;
                            }

                            GlideImageLoader.LoadImage(ActivityContext, item.Image, holder.Image, ImageStyle.FitCenter, ImagePlaceholders.Drawable);
                        }
                        else
                        {
                            File file2    = new File(item.Image);
                            var  photoUri = FileProvider.GetUriForFile(ActivityContext, ActivityContext.PackageName + ".fileprovider", file2);
                            Glide.With(ActivityContext).Load(photoUri).Apply(new RequestOptions()).Into(holder.Image);
                        }

                        holder.Title.Text = Methods.FunString.DecodeString(item.Title);

                        var(currency, currencyIcon) = WoWonderTools.GetCurrency(item.Currency);
                        var categoryName = CategoriesController.ListCategoriesJob.FirstOrDefault(categories => categories.CategoriesId == item.Category)?.CategoriesName;
                        Console.WriteLine(currency);
                        if (string.IsNullOrEmpty(categoryName))
                        {
                            categoryName = Application.Context.GetText(Resource.String.Lbl_Unknown);
                        }

                        holder.Salary.Text = currencyIcon + " " + item.Minimum + " - " + currencyIcon + " " + item.Maximum + " . " + categoryName;

                        holder.Description.Text = Methods.FunString.SubStringCutOf(Methods.FunString.DecodeString(item.Description), 100);

                        if (item.IsOwner != null && item.IsOwner.Value)
                        {
                            holder.IconMore.Visibility = ViewStates.Visible;
                            holder.Button.Text         = ActivityContext.GetString(Resource.String.Lbl_show_applies) + " (" + item.ApplyCount + ")";
                            holder.Button.Tag          = "ShowApply";
                        }
                        else
                        {
                            holder.IconMore.Visibility = ViewStates.Gone;
                        }

                        //Set Button if its applied
                        if (item.Apply == "true")
                        {
                            holder.Button.Text    = ActivityContext.GetString(Resource.String.Lbl_already_applied);
                            holder.Button.Enabled = false;
                        }
                    }
                }
            }
            catch (Exception exception)
            {
                Methods.DisplayReportResultTrack(exception);
            }
        }
Beispiel #18
0
        //Result
        protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
        {
            try
            {
                base.OnActivityResult(requestCode, resultCode, data);
                switch (requestCode)
                {
                //If its from Camera or Gallery
                case CropImage.CropImageActivityRequestCode when resultCode == Result.Ok:
                {
                    var result = CropImage.GetActivityResult(data);

                    if (resultCode == Result.Ok)
                    {
                        if (result.IsSuccessful)
                        {
                            var resultUri = result.Uri;

                            if (!string.IsNullOrEmpty(resultUri.Path))
                            {
                                GroupPathImage = resultUri.Path;
                                File file2    = new File(resultUri.Path);
                                var  photoUri = FileProvider.GetUriForFile(this, PackageName + ".fileprovider", file2);
                                Glide.With(this).Load(photoUri).Apply(new RequestOptions()).Into(ImageGroup);
                            }
                            else
                            {
                                Toast.MakeText(this, GetText(Resource.String.Lbl_something_went_wrong), ToastLength.Long)?.Show();
                            }
                        }
                    }

                    break;
                }

                case 3:
                {
                    UserList = MentionActivity.MAdapter.MentionList.Where(a => a.Selected).ToList();

                    UsersIds = "";
                    foreach (var user in UserList)
                    {
                        UsersIds += user.UserId + ",";

                        var dataUser = MAdapter.UserList.FirstOrDefault(attachments => attachments.UserId == user.UserId);
                        if (dataUser == null)
                        {
                            MAdapter.UserList.Insert(1, user);
                        }
                    }
                    UsersIds = UsersIds.Remove(UsersIds.Length - 1, 1);

                    MAdapter.NotifyDataSetChanged();
                    break;
                }
                }
            }
            catch (Exception e)
            {
                Methods.DisplayReportResultTrack(e);
            }
        }
Beispiel #19
0
        public override void OnBindViewHolder(RecyclerView.ViewHolder holder, int position)
        {
            var dialogsListViewHolder = (DialogsListViewHolder)holder;

            dialogsListViewHolder.messageCountTV.SetTypeface(tf, TypefaceStyle.Normal);
            dialogsListViewHolder.timeTV.SetTypeface(tf, TypefaceStyle.Normal);
            dialogsListViewHolder.expert_nameTV.SetTypeface(tf, TypefaceStyle.Bold);
            dialogsListViewHolder.specializationTV.SetTypeface(tf, TypefaceStyle.Normal);
            dialogsListViewHolder.messageTV.SetTypeface(tf, TypefaceStyle.Normal);

            try
            {
                dialogsListViewHolder.expert_nameTV.Text = dialogs_list[position].expert.name;//split[0];
            }
            catch
            {
                dialogsListViewHolder.expert_nameTV.Text = dialogs_list[position].expert.name;
            }


            if (!String.IsNullOrEmpty(dialogs_list[position].expert.categoryName))
            {
                dialogsListViewHolder.specializationTV.Text = dialogs_list[position].expert.categoryName;
            }
            else
            {
                if (dialogs_list[position].expert.is_expert)
                {
                    dialogsListViewHolder.specializationTV.Text = _context.GetString(Resource.String.expert);
                }
            }

            if (dialogs_list[position].shorttext != "message_text_empty")
            {
                dialogsListViewHolder.messageTV.Text = dialogs_list[position].shorttext;
            }
            else
            {
                dialogsListViewHolder.messageTV.Text = _context.GetString(Resource.String.file);
            }

            var lp = (RelativeLayout.LayoutParams)dialogsListViewHolder.linearLayout3112.LayoutParameters;

            if (dialogs_list[position].timestamp.Substring(0, 10) != date_now)
            {
                dialogsListViewHolder.timeTV.Text = dialogs_list[position].timestamp;
                var par          = (RelativeLayout.LayoutParams)dialogsListViewHolder.timeTV.LayoutParameters;
                int right_margin = par.Width + par.RightMargin + 5;
                lp.SetMargins(lp.LeftMargin, lp.TopMargin, lp.RightMargin, lp.BottomMargin);
                dialogsListViewHolder.linearLayout3112.LayoutParameters = lp;
            }
            else
            {
                dialogsListViewHolder.timeTV.Text = dialogs_list[position].timestamp.Substring(11);
                var par          = (RelativeLayout.LayoutParams)dialogsListViewHolder.timeTV.LayoutParameters;
                int right_margin = par.Width + par.RightMargin + 5;
                lp.SetMargins(lp.LeftMargin, lp.TopMargin, lp.RightMargin / 2, lp.BottomMargin);
                dialogsListViewHolder.linearLayout3112.LayoutParameters = lp;
            }
            if (dialogs_list[position].unread != "0")
            {
                dialogsListViewHolder.messageCountTV.Visibility   = ViewStates.Visible;
                dialogsListViewHolder.messages_countRL.Visibility = ViewStates.Visible;
                dialogsListViewHolder.messageCountTV.Text         = dialogs_list[position].unread;
            }
            else
            {
                dialogsListViewHolder.messageCountTV.Visibility   = ViewStates.Gone;
                dialogsListViewHolder.messages_countRL.Visibility = ViewStates.Gone;
            }
            if (dialogs_list[position].expert.online)
            {
                dialogsListViewHolder.onlineIV.Visibility = ViewStates.Visible;
            }
            else
            {
                dialogsListViewHolder.onlineIV.Visibility = ViewStates.Gone;
            }

            if (!System.String.IsNullOrEmpty(dialogs_list[position].expert.photo))
            {
                Glide.With(_context)
                .Load("https://api.iamnearby.net/" + dialogs_list[position].expert.photo)
                .Into(dialogsListViewHolder.expert_imageIV);
            }
            else
            {
                Glide.With(_context)
                .Load(null)
                .Into(dialogsListViewHolder.expert_imageIV);
            }
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            ISharedPreferences app = Application.Context.GetSharedPreferences("AppData", FileCreationMode.Private);

            _lang     = app.GetString("Language", "en");
            Thumbnail = app.GetString("Payment", string.Empty);
            ChangeLanguage(_lang);

            base.OnCreate(savedInstanceState);

            // Create your application here
            SetContentView(Resource.Layout.order_done);

            Button    mFAQ     = FindViewById <Button>(Resource.Id.btnfaq);
            Button    mInfo    = FindViewById <Button>(Resource.Id.btnInfo);
            ImageView mPayInfo = FindViewById <ImageView>(Resource.Id.imageView);
            Button    mMore    = FindViewById <Button>(Resource.Id.btnReadMore);

            mMore.Click += MMore_Click;
            Glide.With(this).Load(Thumbnail)
            .Apply(RequestOptions.OverrideOf(400, 400).FitCenter())
            .Apply(RequestOptions.PlaceholderOf(Resource.Drawable.placeholder).FitCenter())
            .Transition(DrawableTransitionOptions.WithCrossFade())
            .Into(mPayInfo);

            mFAQ.Click += (o, s) =>
            {
                FAQ();
            };
            mInfo.Click += (o, s) =>
            {
                Information();
            };

            CircleImageView mPesa     = FindViewById <CircleImageView>(Resource.Id.mpesa);
            CircleImageView mTigoPesa = FindViewById <CircleImageView>(Resource.Id.tigopesa);
            CircleImageView mHalopesa = FindViewById <CircleImageView>(Resource.Id.halopesa);
            CircleImageView mAirtel   = FindViewById <CircleImageView>(Resource.Id.airtelmoney);
            CircleImageView mTpesa    = FindViewById <CircleImageView>(Resource.Id.tpesa);
            CircleImageView mZantel   = FindViewById <CircleImageView>(Resource.Id.zantel);

            Glide.With(this).Load(Resource.Drawable.mpesa).Apply(RequestOptions.OverrideOf(90, 90).CenterInside()).Into(mPesa);
            Glide.With(this).Load(Resource.Drawable.tigopesa).Apply(RequestOptions.OverrideOf(90, 90).CenterInside()).Into(mTigoPesa);
            Glide.With(this).Load(Resource.Drawable.halopesa).Apply(RequestOptions.OverrideOf(90, 90).CenterInside()).Into(mHalopesa);
            Glide.With(this).Load(Resource.Drawable.airtelmoney).Apply(RequestOptions.OverrideOf(90, 90).CenterInside()).Into(mAirtel);
            Glide.With(this).Load(Resource.Drawable.tpesa).Apply(RequestOptions.OverrideOf(90, 90).CenterInside()).Into(mTpesa);
            Glide.With(this).Load(Resource.Drawable.easymoney).Apply(RequestOptions.OverrideOf(90, 150).CenterInside()).Into(mZantel);

            mPesa.Click += (o, s) =>
            {
                string telephone = "*150*00#";
                var    phone     = new Intent(Intent.ActionView,
                                              Android.Net.Uri.Parse(string.Format("tel:{0}", telephone)));
                StartActivity(phone);
            };
            mTigoPesa.Click += (o, s) =>
            {
                string telephone = "*150*00#";
                var    phone     = new Intent(Intent.ActionView,
                                              Android.Net.Uri.Parse(string.Format("tel:{0}", telephone)));
                StartActivity(phone);
            };
            mHalopesa.Click += (o, s) =>
            {
                string telephone = "*150*00#";
                var    phone     = new Intent(Intent.ActionView,
                                              Android.Net.Uri.Parse(string.Format("tel:{0}", telephone)));
                StartActivity(phone);
            };
            mAirtel.Click += (o, s) =>
            {
                string telephone = "*150*00#";
                var    phone     = new Intent(Intent.ActionView,
                                              Android.Net.Uri.Parse(string.Format("tel:{0}", telephone)));
                StartActivity(phone);
            };
            mTpesa.Click += (o, s) =>
            {
                string telephone = "*150*00#";
                var    phone     = new Intent(Intent.ActionView,
                                              Android.Net.Uri.Parse(string.Format("tel:{0}", telephone)));
                StartActivity(phone);
            };
            mZantel.Click += (o, s) =>
            {
                string telephone = "*150*00#";
                var    phone     = new Intent(Intent.ActionView,
                                              Android.Net.Uri.Parse(string.Format("tel:{0}", telephone)));
                StartActivity(phone);
            };
        }
        // Function Update Image Group : Avatar && Cover
        private async void UpdateImageGroup_Api(string type, string path)
        {
            try
            {
                if (!Methods.CheckConnectivity())
                {
                    Toast.MakeText(this, GetString(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short).Show();
                }
                else
                {
                    if (type == "Avatar")
                    {
                        var(apiStatus, respond) = await RequestsAsync.Group.Update_Group_Avatar(GroupId, path);

                        if (apiStatus == 200)
                        {
                            if (respond is MessageObject result)
                            {
                                Toast.MakeText(this, result.Message, ToastLength.Short).Show();

                                //Set image
                                File file2    = new File(path);
                                var  photoUri = FileProvider.GetUriForFile(this, PackageName + ".fileprovider", file2);
                                Glide.With(this).Load(photoUri).Apply(new RequestOptions()).Into(UserProfileImage);

                                //GlideImageLoader.LoadImage(this, file.Path, UserProfileImage, ImageStyle.RoundedCrop, ImagePlaceholders.Color);
                            }
                        }
                        else
                        {
                            Methods.DisplayReportResult(this, respond);
                        }
                    }
                    else if (type == "Cover")
                    {
                        var(apiStatus, respond) = await RequestsAsync.Group.Update_Group_Cover(GroupId, path);

                        if (apiStatus == 200)
                        {
                            if (!(respond is MessageObject result))
                            {
                                return;
                            }

                            Toast.MakeText(this, result.Message, ToastLength.Short).Show();

                            //Set image
                            File file2    = new File(path);
                            var  photoUri = FileProvider.GetUriForFile(this, PackageName + ".fileprovider", file2);
                            Glide.With(this).Load(photoUri).Apply(new RequestOptions()).Into(CoverImage);


                            //GlideImageLoader.LoadImage(this, file.Path, CoverImage, ImageStyle.CenterCrop, ImagePlaceholders.Color);
                        }
                        else
                        {
                            Methods.DisplayReportResult(this, respond);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
        //Result
        protected override async void OnActivityResult(int requestCode, Result resultCode, Intent data)
        {
            try
            {
                base.OnActivityResult(requestCode, resultCode, data);
                //If its from Camera or Gallery
                if (requestCode == CropImage.CropImageActivityRequestCode)
                {
                    var result = CropImage.GetActivityResult(data);

                    if (resultCode == Result.Ok)
                    {
                        if (result.IsSuccessful)
                        {
                            var resultUri = result.Uri;

                            if (!string.IsNullOrEmpty(resultUri.Path))
                            {
                                GroupPathImage = resultUri.Path;
                                File file2    = new File(resultUri.Path);
                                var  photoUri =
                                    FileProvider.GetUriForFile(this, PackageName + ".fileprovider", file2);
                                Glide.With(this).Load(photoUri).Apply(new RequestOptions()).Into(ImageGroup);

                                //GlideImageLoader.LoadImage(this, resultUri.Path, ImageGroup, ImageStyle.RoundedCrop, ImagePlaceholders.Drawable);
                            }
                            else
                            {
                                Toast.MakeText(this, GetText(Resource.String.Lbl_Something_went_wrong),
                                               ToastLength.Long).Show();
                            }
                        }
                    }
                }
                else if (requestCode == 3)
                {
                    var users = data.GetStringExtra("Users") ?? "";
                    NewUserList = JsonConvert.DeserializeObject <List <UserDataObject> >(users);

                    UsersIds = "";
                    foreach (var user in NewUserList)
                    {
                        UsersIds += user.UserId + ",";

                        var dataUser =
                            MAdapter.UserList.FirstOrDefault(attachments => attachments.UserId == user.UserId);
                        if (dataUser == null)
                        {
                            MAdapter.UserList.Add(user);
                        }
                    }

                    UsersIds = UsersIds.Remove(UsersIds.Length - 1, 1);

                    MAdapter.NotifyDataSetChanged();

                    var(apiStatus, respond) = await RequestsAsync.GroupChat
                                              .AddOrRemoveUserToGroup(GroupData.GroupId, UsersIds, "add_user").ConfigureAwait(false);

                    if (apiStatus == 200)
                    {
                    }
                    else
                    {
                        Methods.DisplayReportResult(this, respond);
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
        //Get Data
        private void Get_DataImage()
        {
            try
            {
                PostData = JsonConvert.DeserializeObject <PostDataObject>(Intent?.GetStringExtra("AlbumObject") ?? "");
                if (PostData != null)
                {
                    string index = Intent?.GetStringExtra("itemIndex") ?? "0";
                    if (index == "00")
                    {
                        if (PostData.PhotoAlbum?.Count > 0)
                        {
                            var imagesList = PostData.PhotoAlbum;
                            ImageUrl = imagesList[0].Image;
                        }
                        else
                        {
                            ImageUrl = !string.IsNullOrEmpty(PostData.PostSticker) ? PostData.PostSticker : PostData.PostFileFull;
                        }

                        //var bit = drawable_from_url(new Uri(ImageUrl));
                        //PageImage.SetImageBitmap(bit);
                        if (ImageUrl.Contains(".gif"))
                        {
                            Glide.With(this).Load(ImageUrl).Apply(new RequestOptions().Placeholder(Resource.Drawable.ImagePlacholder).FitCenter()).Into(PageImage);
                        }
                        else
                        {
                            Glide.With(this).Load(ImageUrl).Apply(new RequestOptions()).Into(PageImage);
                        }
                    }
                    else
                    {
                        var imageData = PostData.PhotoAlbum[Convert.ToInt32(index)];
                        if (imageData != null)
                        {
                            ImageUrl = imageData.Image;
                            //var bit = drawable_from_url(new Uri(imageData.Image));
                            //PageImage.SetImageBitmap(bit);

                            if (ImageUrl.Contains(".gif"))
                            {
                                Glide.With(this).Load(ImageUrl).Apply(new RequestOptions().Placeholder(Resource.Drawable.ImagePlacholder).FitCenter()).Into(PageImage);
                            }
                            else
                            {
                                Glide.With(this).Load(ImageUrl).Apply(new RequestOptions()).Into(PageImage);
                            }
                        }
                    }

                    if (string.IsNullOrEmpty(PostData.Orginaltext) || string.IsNullOrWhiteSpace(PostData.Orginaltext))
                    {
                        TxtDescription.Visibility = ViewStates.Gone;
                    }
                    else
                    {
                        var description    = Methods.FunString.DecodeString(PostData.Orginaltext);
                        var readMoreOption = new StReadMoreOption.Builder()
                                             .TextLength(250, StReadMoreOption.TypeCharacter)
                                             .MoreLabel(GetText(Resource.String.Lbl_ReadMore))
                                             .LessLabel(GetText(Resource.String.Lbl_ReadLess))
                                             .MoreLabelColor(Color.ParseColor(AppSettings.MainColor))
                                             .LessLabelColor(Color.ParseColor(AppSettings.MainColor))
                                             .LabelUnderLine(true)
                                             .Build();
                        readMoreOption.AddReadMoreTo(TxtDescription, new Java.Lang.String(description));
                    }

                    if (AppSettings.PostButton == PostButtonSystem.ReactionDefault || AppSettings.PostButton == PostButtonSystem.ReactionSubShine)
                    {
                        PostData.Reaction ??= new WoWonderClient.Classes.Posts.Reaction();

                        TxtCountLike.Text = Methods.FunString.FormatPriceValue(PostData.Reaction.Count);

                        if (PostData.Reaction.IsReacted != null && PostData.Reaction.IsReacted.Value)
                        {
                            if (!string.IsNullOrEmpty(PostData.Reaction.Type))
                            {
                                var react = ListUtils.SettingsSiteList?.PostReactionsTypes?.FirstOrDefault(a => a.Value?.Id == PostData.Reaction.Type).Value?.Id ?? "";
                                switch (react)
                                {
                                case "1":
                                    LikeButton.SetReactionPack(ReactConstants.Like);
                                    ImgLike.SetImageResource(Resource.Drawable.emoji_like);
                                    break;

                                case "2":
                                    LikeButton.SetReactionPack(ReactConstants.Love);
                                    ImgLike.SetImageResource(Resource.Drawable.emoji_love);
                                    break;

                                case "3":
                                    LikeButton.SetReactionPack(ReactConstants.HaHa);
                                    ImgLike.SetImageResource(Resource.Drawable.emoji_haha);
                                    break;

                                case "4":
                                    LikeButton.SetReactionPack(ReactConstants.Wow);
                                    ImgLike.SetImageResource(Resource.Drawable.emoji_wow);
                                    break;

                                case "5":
                                    LikeButton.SetReactionPack(ReactConstants.Sad);
                                    ImgLike.SetImageResource(Resource.Drawable.emoji_sad);
                                    break;

                                case "6":
                                    LikeButton.SetReactionPack(ReactConstants.Angry);
                                    ImgLike.SetImageResource(Resource.Drawable.emoji_angry);
                                    break;

                                default:
                                    LikeButton.SetReactionPack(ReactConstants.Default);
                                    ImgLike.SetImageResource(PostData.Reaction.Count > 0 ? Resource.Drawable.emoji_like : Resource.Drawable.icon_post_like_vector);
                                    break;
                                }
                            }
                        }
                        else
                        {
                            LikeButton.SetReactionPack(ReactConstants.Default);
                            LikeButton.SetTextColor(Color.White);

                            ImgLike.SetImageResource(PostData.Reaction.Count > 0 ? Resource.Drawable.emoji_like : Resource.Drawable.icon_post_like_vector);
                        }
                    }
                    else
                    {
                        ImgLike.SetImageResource(Resource.Drawable.icon_post_like_vector);

                        TxtCountLike.Text = Methods.FunString.FormatPriceValue(Convert.ToInt32(PostData.PostLikes));

                        if (AppSettings.PostButton == PostButtonSystem.Wonder || AppSettings.PostButton == PostButtonSystem.DisLike)
                        {
                            TxtCountWoWonder.Text = Methods.FunString.FormatPriceValue(Convert.ToInt32(PostData.PostWonders));
                        }

                        switch (AppSettings.PostButton)
                        {
                        case PostButtonSystem.Wonder when PostData.IsWondered != null && PostData.IsWondered.Value:

                            BtnWonder.Tag = "true";
                            ImgWoWonder.SetColorFilter(Color.ParseColor(AppSettings.MainColor));

                            ImgWonder.SetImageResource(Resource.Drawable.ic_action_wowonder);
                            ImgWonder.SetColorFilter(Color.ParseColor(AppSettings.MainColor));

                            TxtWonder.Text = GetString(Resource.String.Lbl_wondered);
                            TxtWonder.SetTextColor(Color.ParseColor(AppSettings.MainColor));
                            break;

                        case PostButtonSystem.Wonder:

                            BtnWonder.Tag = "false";
                            ImgWoWonder.SetColorFilter(Color.White);

                            ImgWonder.SetImageResource(Resource.Drawable.ic_action_wowonder);
                            ImgWonder.SetColorFilter(Color.White);

                            TxtWonder.Text = GetString(Resource.String.Btn_Wonder);
                            TxtWonder.SetTextColor(Color.ParseColor("#444444"));
                            break;

                        case PostButtonSystem.DisLike when PostData.IsWondered != null && PostData.IsWondered.Value:

                            BtnWonder.Tag = "true";
                            ImgWoWonder.SetColorFilter(Color.ParseColor(AppSettings.MainColor));

                            ImgWonder.SetImageResource(Resource.Drawable.ic_action_dislike);
                            ImgWonder.SetColorFilter(Color.ParseColor(AppSettings.MainColor));

                            TxtWonder.Text = GetString(Resource.String.Lbl_disliked);
                            TxtWonder.SetTextColor(Color.ParseColor(AppSettings.MainColor));

                            break;

                        case PostButtonSystem.DisLike:

                            BtnWonder.Tag = "false";
                            ImgWoWonder.SetColorFilter(Color.White);

                            ImgWonder.SetImageResource(Resource.Drawable.ic_action_dislike);
                            ImgWonder.SetColorFilter(Color.White);

                            TxtWonder.Text = GetString(Resource.String.Btn_Dislike);
                            TxtWonder.SetTextColor(Color.ParseColor("#444444"));
                            break;

                        case PostButtonSystem.Like when PostData.IsLiked != null && PostData.IsLiked.Value:

                            BtnLike.Tag = "true";
                            ImgLike.SetColorFilter(Color.ParseColor(AppSettings.MainColor));

                            break;

                        case PostButtonSystem.Like:

                            BtnLike.Tag = "false";
                            ImgLike.SetColorFilter(Color.White);

                            break;
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Methods.DisplayReportResultTrack(e);
            }
        }
Beispiel #24
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.activity_main);
            Android.Support.V7.Widget.Toolbar toolbar = FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar);
            SetSupportActionBar(toolbar);


            prefs       = PreferenceManager.GetDefaultSharedPreferences(ApplicationContext);
            db          = new DbHelper();
            geo         = new Geolocation();
            restService = new ServiceHelper();
            ic          = new InternetConnection();
            login_data  = new List <LoginModel>();

            version = Android.App.Application.Context.ApplicationContext.PackageManager.GetPackageInfo(Android.App.Application.Context.ApplicationContext.PackageName, 0).VersionName;
            DrawerLayout          drawer = FindViewById <DrawerLayout>(Resource.Id.drawer_layout);
            ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar, Resource.String.navigation_drawer_open, Resource.String.navigation_drawer_close);

            drawer.AddDrawerListener(toggle);
            toggle.SyncState();

            NavigationView navigationView = FindViewById <NavigationView>(Resource.Id.nav_view);

            navigationView.SetNavigationItemSelectedListener(this);
            List <LoginModel> loginModel = db.getDetail();

            if (loginModel.Count <= 1)
            {
                IMenu nav_Menu = navigationView.Menu;
                nav_Menu.FindItem(Resource.Id.switchuser).SetVisible(false);
            }

            location = geo.GetGeoLocation(this);
            SupportFragmentManager.BeginTransaction().Replace(Resource.Id.container, new MainFrag(), "MainFrag").Commit();

            ManualSyncData();

            View   header   = navigationView.GetHeaderView(0);
            string userName = prefs.GetString("UserName", "");
            string number   = prefs.GetString("MobileNumber", "");
            string propic   = prefs.GetString("NPPhoto", "");
            string org      = prefs.GetString("Organization", "");
            string desig    = prefs.GetString("Designation", "");

            identity = prefs.GetString("LoginIdentity", "");

            TextView  name1   = (TextView)header.FindViewById(Resource.Id.user);
            TextView  mobile1 = (TextView)header.FindViewById(Resource.Id.number);
            ImageView image   = (ImageView)header.FindViewById(Resource.Id.propic);
            TextView  desig1  = (TextView)header.FindViewById(Resource.Id.desig);
            TextView  org1    = (TextView)header.FindViewById(Resource.Id.org);

            name1.Text   = userName;
            mobile1.Text = number;
            desig1.Text  = desig;
            org1.Text    = org;

            if (propic != "" && propic != null)
            {
                Glide.With(this).Load(propic).Into(image);
            }
        }
Beispiel #25
0
 public void LoadImage(Android.Net.Uri imageUri, ImageView ivImage)
 {
     // Glide is just an example. You can use any image loading library you want;
     // This callback is to make sure the library has the flexibility to allow user to choose their own image loading method.
     Glide.With(CrossCurrentActivity.Current.Activity).Load(imageUri).Into(ivImage);
 }
Beispiel #26
0
        public override View GetView(int position, View convertView, ViewGroup parent)
        {
            var view = convertView;
            adaptadorromsdownloadedViewHolder holder = null;

            if (view != null)
            {
                holder = view.Tag as adaptadorromsdownloadedViewHolder;
            }

            if (holder == null)
            {
                holder = new adaptadorromsdownloadedViewHolder();
                var inflater = context.GetSystemService(Context.LayoutInflaterService).JavaCast <LayoutInflater>();
                //replace with your item and your holder items
                //comment back in
                view            = inflater.Inflate(Resource.Layout.layoutbuscadorconmenu, parent, false);
                holder.Title    = view.FindViewById <TextView>(Resource.Id.textView);
                holder.Title2   = view.FindViewById <TextView>(Resource.Id.textView2);
                holder.portrait = view.FindViewById <ImageView>(Resource.Id.imageView);
                holder.menutool = view.FindViewById <ImageView>(Resource.Id.imageView2);
                miselaneousmethods.ponerfuente(context.Assets, holder.Title);
                miselaneousmethods.ponerfuente(context.Assets, holder.Title2);
                int idd = 0;
                if (consolesources != null)
                {
                    idd = consolesources[position];
                }
                else
                {
                    idd = src;
                }
                holder.menutool.Click += (aax, asdd) =>
                {
                    PopupMenu menu = new PopupMenu(context, holder.menutool);
                    menu.Inflate(Resource.Menu.menupopup);
                    menu.Show();

                    menu.MenuItemClick += (s1, arg1) =>
                    {
                        pos = (int)(((ImageView)aax).GetTag(Resource.Id.imageView2));

                        /*   intentsend.PutExtra(Intent.ExtraTitle, "Link de descarga para el rom:" + nombre);
                         * intentsend.PutExtra(Intent.ExtraSubject, "Link de descarga para el rom:" + nombre);*/

                        AlertDialog.Builder ad = new AlertDialog.Builder(context);
                        ad.SetCancelable(false);
                        ad.SetTitle("Que desea compartir?");
                        ad.SetMessage("Desea compartir el archivo descargado o el link de descarga");
                        ad.SetPositiveButton("Archivo", ok);
                        ad.SetNegativeButton("Link", no);
                        ad.Show();
                    };
                };
                Glide.With(context)
                .Load(lista[position].Portrait)
                .Apply(RequestOptions.NoTransformation().SkipMemoryCache(true).Override(75, 75).Placeholder(idd))
                .Into(holder.portrait);
                holder.portrait.SetTag(Resource.Id.imageView, lista[position].Portrait);
                view.Tag = holder;
            }
            else
            {
                holder.animar3(view);
            }



            if (holder.portrait.GetTag(Resource.Id.imageView).ToString() != lista[position].Portrait)
            {
                try
                {
                    int idd = 0;
                    if (consolesources != null)
                    {
                        idd = consolesources[position];
                    }
                    else
                    {
                        idd = src;
                    }
                    Glide.With(context)
                    .Load(lista[position].Portrait)


                    .Apply(RequestOptions.NoTransformation().SkipMemoryCache(true).Override(75, 75)

                           .Placeholder(idd))

                    .Into(holder.portrait);
                }
                catch (Exception) { }
            }



            //fill in your items
            //holder.Title.Text = "new text here";
            holder.Title.Text  = lista[position].Name;
            holder.Title2.Text = lista[position].Region;
            holder.portrait.SetTag(Resource.Id.imageView, lista[position].Portrait);
            holder.menutool.SetTag(Resource.Id.imageView2, position);
            return(view);
        }
        // Replace the contents of a view (invoked by the layout manager)
        public override void OnBindViewHolder(RecyclerView.ViewHolder viewHolder, int position)
        {
            try
            {
                if (viewHolder.ItemViewType == 666)
                {
                    if (!(viewHolder is MainHolders.EmptyStateAdapterViewHolder emptyHolder))
                    {
                        return;
                    }

                    emptyHolder.EmptyText.Text = "No Replies to be displayed";
                    return;
                }

                if (!(viewHolder is ReplyCommentAdapterViewHolder holder))
                {
                    return;
                }

                var item = ReplyCommentList[position];
                if (item == null)
                {
                    return;
                }

                if (AppSettings.FlowDirectionRightToLeft)
                {
                    holder.BubbleLayout.LayoutDirection = LayoutDirection.Rtl;
                }

                if (!string.IsNullOrEmpty(item.Text) || !string.IsNullOrWhiteSpace(item.Text))
                {
                    var changer = new TextSanitizer(holder.CommentText, ActivityContext);
                    changer.Load(Methods.FunString.DecodeString(item.Text));
                }
                else
                {
                    holder.CommentText.Visibility = ViewStates.Gone;
                }

                if (holder.TimeTextView.Tag?.ToString() == "true")
                {
                    return;
                }

                holder.TimeTextView.Text = Methods.Time.TimeAgo(int.Parse(item.Time));
                holder.UserName.Text     = item.Publisher.Name;
                GlideImageLoader.LoadImage(ActivityContext, item.Publisher.Avatar, holder.Image, ImageStyle.CircleCrop, ImagePlaceholders.Color);

                var textHighLighter = item.Publisher.Name;
                var textIsPro       = string.Empty;

                if (item.Publisher.Verified == "1")
                {
                    textHighLighter += " " + IonIconsFonts.CheckmarkCircled;
                }

                if (item.Publisher.IsPro == "1")
                {
                    textIsPro        = " " + IonIconsFonts.Flash;
                    textHighLighter += textIsPro;
                }

                var decorator = TextDecorator.Decorate(holder.UserName, textHighLighter)
                                .SetTextStyle((int)TypefaceStyle.Bold, 0, item.Publisher.Name.Length);

                if (item.Publisher.Verified == "1")
                {
                    decorator.SetTextColor(Resource.Color.Post_IsVerified, IonIconsFonts.CheckmarkCircled);
                }

                if (item.Publisher.IsPro == "1")
                {
                    decorator.SetTextColor(Resource.Color.text_color_in_between, textIsPro);
                }

                decorator.Build();

                if (holder.ItemViewType == 1)
                {
                    if (!string.IsNullOrEmpty(item.CFile) && (item.CFile.Contains("file://") || item.CFile.Contains("content://") || item.CFile.Contains("storage") || item.CFile.Contains("/data/user/0/")))
                    {
                        File file2    = new File(item.CFile);
                        var  photoUri = FileProvider.GetUriForFile(ActivityContext, ActivityContext.PackageName + ".fileprovider", file2);
                        Glide.With(ActivityContext).Load(photoUri).Apply(new RequestOptions()).Into(holder.CommentImage);

                        //GlideImageLoader.LoadImage(ActivityContext, item.CFile, holder.CommentImage, ImageStyle.CenterCrop, ImagePlaceholders.Color);
                    }
                    else
                    {
                        GlideImageLoader.LoadImage(ActivityContext, Client.WebsiteUrl + "/" + item.CFile, holder.CommentImage, ImageStyle.CenterCrop, ImagePlaceholders.Color);
                    }
                }

                if (item.IsCommentLiked)
                {
                    holder.LikeTextView.Text = ActivityContext.GetText(Resource.String.Btn_Liked);
                    holder.LikeTextView.SetTextColor(Color.ParseColor(AppSettings.MainColor));
                    holder.LikeTextView.Tag = "Liked";
                }
                else
                {
                    holder.LikeTextView.Text = ActivityContext.GetText(Resource.String.Btn_Like);
                    if (AppSettings.SetTabDarkTheme)
                    {
                        holder.LikeTextView.SetTextColor(Color.ParseColor("#ffffff"));
                    }
                    else
                    {
                        holder.LikeTextView.SetTextColor(Color.ParseColor("#000000"));
                    }
                    holder.LikeTextView.Tag = "Like";
                }

                holder.TimeTextView.Tag = "true";

                if (holder.Image.HasOnClickListeners)
                {
                    return;
                }

                var postEventListener = new CommentClickListener(ActivityContext, "Reply");

                //Create an Event
                holder.MainView.LongClick += (sender, e) => postEventListener.MoreCommentReplyPostClick(new CommentReplyClickEventArgs {
                    CommentObject = item, Position = position, View = holder.MainView
                });

                holder.Image.Click += (sender, args) => postEventListener.ProfilePostClick(new ProfileClickEventArgs {
                    Holder = holder, CommentClass = item, Position = position, View = holder.MainView
                });

                holder.ReplyTextView.Click += (sender, args) =>
                {
                    try
                    {
                        ActivityContext.TxtComment.Text = "";
                        ActivityContext.TxtComment.Text = "@" + item.Publisher.Username + " ";
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e);
                    }
                };

                holder.LikeTextView.Click += delegate
                {
                    try
                    {
                        if (holder.LikeTextView.Tag.ToString() == "Liked")
                        {
                            item.IsCommentLiked = false;

                            holder.LikeTextView.Text = ActivityContext.GetText(Resource.String.Btn_Like);
                            if (AppSettings.SetTabDarkTheme)
                            {
                                holder.LikeTextView.SetTextColor(Color.ParseColor("#ffffff"));
                            }
                            else
                            {
                                holder.LikeTextView.SetTextColor(Color.ParseColor("#000000"));
                            }
                            holder.LikeTextView.Tag = "Like";

                            //sent api Dislike comment
                            PollyController.RunRetryPolicyFunction(new List <Func <Task> > {
                                () => RequestsAsync.Comment.LikeUnLikeCommentAsync(item.Id, false)
                            });
                        }
                        else
                        {
                            item.IsCommentLiked = true;

                            holder.LikeTextView.Text = ActivityContext.GetText(Resource.String.Btn_Liked);
                            holder.LikeTextView.SetTextColor(Color.ParseColor(AppSettings.MainColor));
                            holder.LikeTextView.Tag = "Liked";

                            //sent api like comment
                            PollyController.RunRetryPolicyFunction(new List <Func <Task> > {
                                () => RequestsAsync.Comment.LikeUnLikeCommentAsync(item.Id, true)
                            });
                        }
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e);
                    }
                };

                holder.CommentImage.Click += (sender, args) => postEventListener.OpenImageLightBox(item);
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception);
            }
        }
        // Replace the contents of a view (invoked by the layout manager)
        public override void OnBindViewHolder(RecyclerView.ViewHolder viewHolder, int position)
        {
            try
            {
                if (viewHolder.ItemViewType == 666)
                {
                    if (!(viewHolder is AdapterHolders.EmptyStateAdapterViewHolder emptyHolder))
                    {
                        return;
                    }

                    emptyHolder.EmptyText.Text = "No Replies to be displayed";
                    return;
                }

                if (!(viewHolder is CommentAdapterViewHolder holder))
                {
                    return;
                }

                var item = ReplyCommentList[position];
                if (item == null)
                {
                    return;
                }

                if (AppSettings.FlowDirectionRightToLeft)
                {
                    holder.BubbleLayout.LayoutDirection = LayoutDirection.Rtl;
                }

                if (!string.IsNullOrEmpty(item.Orginaltext) || !string.IsNullOrWhiteSpace(item.Orginaltext))
                {
                    var text = Methods.FunString.DecodeString(item.Orginaltext);
                    ReadMoreOption.AddReadMoreTo(holder.CommentText, new Java.Lang.String(text));
                }
                else
                {
                    holder.CommentText.Visibility = ViewStates.Gone;
                }

                if (holder.TimeTextView.Tag?.ToString() == "true")
                {
                    return;
                }

                holder.TimeTextView.Text = Methods.Time.TimeAgo(Convert.ToInt32(item.Time), false);
                holder.UserName.Text     = item.Publisher.Name;
                GlideImageLoader.LoadImage(ActivityContext, item.Publisher.Avatar, holder.Image, ImageStyle.CircleCrop, ImagePlaceholders.Color);

                var textHighLighter = item.Publisher.Name;
                var textIsPro       = string.Empty;

                if (item.Publisher.Verified == "1")
                {
                    textHighLighter += " " + IonIconsFonts.CheckmarkCircle;
                }

                if (item.Publisher.IsPro == "1")
                {
                    textIsPro        = " " + IonIconsFonts.Flash;
                    textHighLighter += textIsPro;
                }

                var decorator = TextDecorator.Decorate(holder.UserName, textHighLighter)
                                .SetTextStyle((int)TypefaceStyle.Bold, 0, item.Publisher.Name.Length);

                if (item.Publisher.Verified == "1")
                {
                    decorator.SetTextColor(Resource.Color.Post_IsVerified, IonIconsFonts.CheckmarkCircle);
                }

                if (item.Publisher.IsPro == "1")
                {
                    decorator.SetTextColor(Resource.Color.text_color_in_between, textIsPro);
                }

                decorator.Build();

                if (holder.ItemViewType == 1)
                {
                    if (!string.IsNullOrEmpty(item.CFile) && (item.CFile.Contains("file://") || item.CFile.Contains("content://") || item.CFile.Contains("storage") || item.CFile.Contains("/data/user/0/")))
                    {
                        File file2    = new File(item.CFile);
                        var  photoUri = FileProvider.GetUriForFile(ActivityContext, ActivityContext.PackageName + ".fileprovider", file2);
                        Glide.With(ActivityContext).Load(photoUri).Apply(new RequestOptions()).Into(holder.CommentImage);

                        //GlideImageLoader.LoadImage(ActivityContext, item.CFile, holder.CommentImage, ImageStyle.CenterCrop, ImagePlaceholders.Color);
                    }
                    else
                    {
                        GlideImageLoader.LoadImage(ActivityContext, Client.WebsiteUrl + "/" + item.CFile, holder.CommentImage, ImageStyle.CenterCrop, ImagePlaceholders.Color);
                    }
                }

                if (AppSettings.PostButton == PostButtonSystem.ReactionDefault || AppSettings.PostButton == PostButtonSystem.ReactionSubShine)
                {
                    item.Reaction ??= new WoWonderClient.Classes.Posts.Reaction();

                    holder.CountRating.Text = item.Reaction.Count + " " + ActivityContext.GetString(Resource.String.Lbl_Reactions);
                    holder.RatingBar.Rating = (float)Convert.ToDouble(item.Reaction.Type);
                    if (holder.RatingBar.Rating > 0)
                    {
                        holder.RatingText.Text = item.Reaction.Type;
                    }
                    else
                    {
                        holder.RatingText.Text = "0.0";
                    }

                    //if (item.Reaction.Count > 0)
                    //{
                    //    holder.CountLikeSection.Visibility = ViewStates.Visible;
                    //    holder.CountLike.Text = Methods.FunString.FormatPriceValue(item.Reaction.Count);
                    //}
                    //else
                    //{
                    //    holder.CountLikeSection.Visibility = ViewStates.Gone;
                    //}

                    if (item.Reaction.IsReacted != null && item.Reaction.IsReacted.Value)
                    {
                        if (!string.IsNullOrEmpty(item.Reaction.Type))
                        {
                            var react = ListUtils.SettingsSiteList?.PostReactionsTypes?.FirstOrDefault(a => a.Value?.Id == item.Reaction.Type).Value?.Id ?? "";
                            switch (react)
                            {
                            case "1":
                                ReactionComment.SetReactionPack(holder, ReactConstants.Like);
                                holder.LikeTextView.Tag = "Liked";
                                holder.ImageCountLike.SetImageResource(Resource.Drawable.emoji_like);
                                break;

                            case "2":
                                ReactionComment.SetReactionPack(holder, ReactConstants.Love);
                                holder.LikeTextView.Tag = "Liked";
                                holder.ImageCountLike.SetImageResource(Resource.Drawable.emoji_love);
                                break;

                            case "3":
                                ReactionComment.SetReactionPack(holder, ReactConstants.HaHa);
                                holder.LikeTextView.Tag = "Liked";
                                holder.ImageCountLike.SetImageResource(Resource.Drawable.emoji_haha);
                                break;

                            case "4":
                                ReactionComment.SetReactionPack(holder, ReactConstants.Wow);
                                holder.LikeTextView.Tag = "Liked";
                                holder.ImageCountLike.SetImageResource(Resource.Drawable.emoji_wow);
                                break;

                            case "5":
                                ReactionComment.SetReactionPack(holder, ReactConstants.Sad);
                                holder.LikeTextView.Tag = "Liked";
                                holder.ImageCountLike.SetImageResource(Resource.Drawable.emoji_sad);
                                break;

                            case "6":
                                ReactionComment.SetReactionPack(holder, ReactConstants.Angry);
                                holder.LikeTextView.Tag = "Liked";
                                holder.ImageCountLike.SetImageResource(Resource.Drawable.emoji_angry);
                                break;

                            default:
                                holder.LikeTextView.Text = ActivityContext.GetText(Resource.String.Btn_Like);
                                holder.LikeTextView.SetTextColor(AppSettings.SetTabDarkTheme ? Color.White : Color.Black);
                                holder.LikeTextView.Tag = "Like";

                                if (item.Reaction.Count > 0)
                                {
                                    holder.ImageCountLike.SetImageResource(Resource.Drawable.emoji_like);
                                }
                                break;
                            }
                        }
                    }
                    else
                    {
                        holder.LikeTextView.Text = ActivityContext.GetText(Resource.String.Btn_Like);
                        holder.LikeTextView.SetTextColor(AppSettings.SetTabDarkTheme ? Color.White : Color.Black);
                        holder.LikeTextView.Tag = "Like";

                        if (item.Reaction.Count > 0)
                        {
                            holder.ImageCountLike.SetImageResource(Resource.Drawable.emoji_like);
                        }
                    }
                }
                else if (AppSettings.PostButton == PostButtonSystem.Wonder || AppSettings.PostButton == PostButtonSystem.DisLike)
                {
                    if (item.Reaction.IsReacted != null && !item.Reaction.IsReacted.Value)
                    {
                        ReactionComment.SetReactionPack(holder, ReactConstants.Default);
                    }

                    if (item.IsCommentLiked)
                    {
                        holder.LikeTextView.Text = ActivityContext.GetText(Resource.String.Btn_Liked);
                        holder.LikeTextView.SetTextColor(Color.ParseColor(AppSettings.MainColor));
                        holder.LikeTextView.Tag = "Liked";
                    }

                    switch (AppSettings.PostButton)
                    {
                    case PostButtonSystem.Wonder when item.IsCommentWondered:
                    {
                        holder.DislikeTextView.Text = ActivityContext.GetString(Resource.String.Lbl_wondered);
                        holder.DislikeTextView.SetTextColor(Color.ParseColor(AppSettings.MainColor));
                        holder.DislikeTextView.Tag = "Disliked";
                        break;
                    }

                    case PostButtonSystem.Wonder:
                    {
                        holder.DislikeTextView.Text = ActivityContext.GetString(Resource.String.Btn_Wonder);
                        holder.DislikeTextView.SetTextColor(AppSettings.SetTabDarkTheme ? Color.White : Color.Black);
                        holder.DislikeTextView.Tag = "Dislike";
                        break;
                    }

                    case PostButtonSystem.DisLike when item.IsCommentWondered:
                    {
                        holder.DislikeTextView.Text = ActivityContext.GetString(Resource.String.Lbl_disliked);
                        holder.DislikeTextView.SetTextColor(Color.ParseColor("#f89823"));
                        holder.DislikeTextView.Tag = "Disliked";
                        break;
                    }

                    case PostButtonSystem.DisLike:
                    {
                        holder.DislikeTextView.Text = ActivityContext.GetString(Resource.String.Btn_Dislike);
                        holder.DislikeTextView.SetTextColor(AppSettings.SetTabDarkTheme ? Color.White : Color.Black);
                        holder.DislikeTextView.Tag = "Dislike";
                        break;
                    }
                    }
                }
                else
                {
                    if (item.IsCommentLiked)
                    {
                        holder.LikeTextView.Text = ActivityContext.GetText(Resource.String.Btn_Liked);
                        holder.LikeTextView.SetTextColor(Color.ParseColor(AppSettings.MainColor));
                        holder.LikeTextView.Tag = "Liked";
                    }
                    else
                    {
                        holder.LikeTextView.Text = ActivityContext.GetText(Resource.String.Btn_Like);
                        holder.LikeTextView.SetTextColor(AppSettings.SetTabDarkTheme ? Color.White : Color.Black);
                        holder.LikeTextView.Tag = "Like";
                    }
                }


                holder.TimeTextView.Tag = "true";
            }
            catch (Exception exception)
            {
                Methods.DisplayReportResultTrack(exception);
            }
        }
 public RequestBuilder GetPreloadRequestBuilder(Object p0)
 {
     return(Glide.With(ActivityContext).Load(p0.ToString())
            .Apply(new RequestOptions().CenterCrop().SetDiskCacheStrategy(DiskCacheStrategy.All)));
 }
        // Replace the contents of a view (invoked by the layout manager)
        public override void OnBindViewHolder(RecyclerView.ViewHolder viewHolder, int position)
        {
            try
            {
                if (viewHolder is Holders.LastMessagesViewHolder holder)
                {
                    var item = ChatList[position];
                    if (item != null)
                    {
                        var image = item.Avatar;
                        if (!string.IsNullOrEmpty(image))
                        {
                            var avatarSplit    = image.Split('/').Last();
                            var getImageAvatar = Methods.MultiMedia.GetMediaFrom_Disk(Methods.Path.FolderDiskImage, avatarSplit);
                            if (getImageAvatar != "File Dont Exists")
                            {
                                var file = Uri.FromFile(new File(getImageAvatar));
                                Glide.With(ActivityContext).Load(file.Path).Apply(Options).Into(holder.ImageAvatar);
                            }
                            else
                            {
                                Methods.MultiMedia.DownloadMediaTo_DiskAsync(Methods.Path.FolderDiskImage, image);
                                GlideImageLoader.LoadImage(ActivityContext, image, holder.ImageAvatar, ImageStyle.CircleCrop, ImagePlaceholders.Drawable);
                            }
                        }

                        item.LastMessage.LastMessageClass.Stickers = item.LastMessage.LastMessageClass.Stickers?.Replace(".mp4", ".gif") ?? "";

                        //If message contains Media files
                        if (item.LastMessage.LastMessageClass.Media.Contains("image"))
                        {
                            holder.LastMessagesIcon.Visibility = ViewStates.Visible;
                            Glide.With(ActivityContext).Load(Resource.Drawable.ic_image_vector).Into(holder.LastMessagesIcon);
                            holder.TxtLastMessages.Text = ActivityContext.GetText(Resource.String.Lbl_SendImageFile);
                        }
                        else if (item.LastMessage.LastMessageClass.Media.Contains("video"))
                        {
                            holder.LastMessagesIcon.Visibility = ViewStates.Visible;
                            Glide.With(ActivityContext).Load(Resource.Drawable.ic_video_player_vector).Into(holder.LastMessagesIcon);
                            holder.TxtLastMessages.Text = ActivityContext.GetText(Resource.String.Lbl_SendVideoFile);
                        }
                        else if (item.LastMessage.LastMessageClass.Media.Contains("sticker"))
                        {
                            holder.LastMessagesIcon.Visibility = ViewStates.Visible;
                            Glide.With(ActivityContext).Load(Resource.Drawable.ic_sticker_vector).Into(holder.LastMessagesIcon);
                            holder.TxtLastMessages.Text = ActivityContext.GetText(Resource.String.Lbl_SendStickerFile);
                        }
                        else if (item.LastMessage.LastMessageClass.Media.Contains("sounds"))
                        {
                            holder.LastMessagesIcon.Visibility = ViewStates.Visible;
                            Glide.With(ActivityContext).Load(Resource.Drawable.ic_radios_vector).Into(holder.LastMessagesIcon);
                            holder.TxtLastMessages.Text = ActivityContext.GetText(Resource.String.Lbl_SendAudioFile);
                        }
                        else if (item.LastMessage.LastMessageClass.Media.Contains("file"))
                        {
                            holder.LastMessagesIcon.Visibility = ViewStates.Visible;
                            Glide.With(ActivityContext).Load(Resource.Drawable.ic_document_vector).Into(holder.LastMessagesIcon);
                            holder.TxtLastMessages.Text = ActivityContext.GetText(Resource.String.Lbl_SendFile);
                        }
                        else if (item.LastMessage.LastMessageClass?.Stickers != null && item.LastMessage.LastMessageClass.Stickers.Contains(".gif"))
                        {
                            holder.LastMessagesIcon.Visibility = ViewStates.Visible;
                            Glide.With(ActivityContext).Load(Resource.Drawable.ic_gif_vector).Into(holder.LastMessagesIcon);
                            holder.TxtLastMessages.Text = ActivityContext.GetText(Resource.String.Lbl_SendGifFile);
                        }
                        else if (!string.IsNullOrEmpty(item.LastMessage.LastMessageClass.ProductId) && item.LastMessage.LastMessageClass.ProductId != "0")
                        {
                            holder.TxtLastMessages.Text = ActivityContext.GetText(Resource.String.Lbl_SendProductFile);
                        }
                        else
                        {
                            // holder.LastMessagesIcon.Visibility = ViewStates.Gone;

                            if (item.LastMessage.LastMessageClass.Text.Contains("http"))
                            {
                                holder.TxtLastMessages.Text = Methods.FunString.SubStringCutOf(item.LastMessage.LastMessageClass.Text, 30);
                            }
                            else if (item.LastMessage.LastMessageClass.Text.Contains("{&quot;Key&quot;") || item.LastMessage.LastMessageClass.Text.Contains("{key:^qu") || item.LastMessage.LastMessageClass.Text.Contains("{^key:^qu") || item.LastMessage.LastMessageClass.Text.Contains("{key:"))
                            {
                                holder.TxtLastMessages.Text = ActivityContext.GetText(Resource.String.Lbl_SendContactnumber);
                            }
                            else
                            {
                                holder.TxtLastMessages.Text = Methods.FunString.DecodeString(Methods.FunString.SubStringCutOf(item.LastMessage.LastMessageClass.Text, 30));
                            }
                        }

                        //last seen time
                        holder.TxtTimestamp.Text = Methods.Time.TimeAgo(int.Parse(item.ChatTime), true);

                        //Check read message
                        if (item.LastMessage.LastMessageClass.FromId != null && (item.LastMessage.LastMessageClass.ToId != null && (item.LastMessage.LastMessageClass.ToId != UserDetails.UserId && item.LastMessage.LastMessageClass.FromId == UserDetails.UserId)))
                        {
                            if (item.LastMessage.LastMessageClass.Seen == "0")
                            {
                                holder.IconCheckCountMessages.Visibility = ViewStates.Invisible;
                                holder.TxtUsername.SetTypeface(Typeface.Default, TypefaceStyle.Normal);
                                holder.TxtLastMessages.SetTypeface(Typeface.Default, TypefaceStyle.Normal);
                            }
                            else
                            {
                                holder.IconCheckCountMessages.Visibility = ViewStates.Visible;
                                holder.TxtUsername.SetTypeface(Typeface.Default, TypefaceStyle.Normal);
                                holder.TxtLastMessages.SetTypeface(Typeface.Default, TypefaceStyle.Normal);
                                Glide.With(ActivityContext).Load(Resource.Drawable.ic_tick_vector).Into(holder.IconCheckCountMessages);
                            }
                        }
                        else if (item.LastMessage.LastMessageClass.FromId != null && (item.LastMessage.LastMessageClass.ToId != null && (item.LastMessage.LastMessageClass.ToId == UserDetails.UserId && item.LastMessage.LastMessageClass.FromId != UserDetails.UserId)))
                        {
                            if (item.LastMessage.LastMessageClass.Seen == "0")
                            {
                                holder.TxtUsername.SetTypeface(Typeface.Default, TypefaceStyle.Bold);
                                holder.TxtLastMessages.SetTypeface(Typeface.Default, TypefaceStyle.Bold);

                                holder.IconCheckCountMessages.Visibility = ViewStates.Visible;
                                if (item.ChatType == "user")
                                {
                                    if (!string.IsNullOrEmpty(item.MessageCount))
                                    {
                                        var drawable = new TextDrawable.Builder().BeginConfig().FontSize(25).EndConfig().BuildRound(item.MessageCount, Color.ParseColor(AppSettings.MainColor));
                                        holder.IconCheckCountMessages.SetImageDrawable(drawable);
                                        holder.IconCheckCountMessages.Visibility = ViewStates.Visible;
                                    }
                                    else
                                    {
                                        var drawable = new TextDrawable.Builder().BeginConfig().FontSize(25).EndConfig().BuildRound("N", Color.ParseColor(AppSettings.MainColor));
                                        holder.IconCheckCountMessages.SetImageDrawable(drawable);
                                        holder.IconCheckCountMessages.Visibility = ViewStates.Visible;
                                    }
                                }
                            }
                            else
                            {
                                holder.IconCheckCountMessages.Visibility = ViewStates.Invisible;
                                holder.TxtUsername.SetTypeface(Typeface.Default, TypefaceStyle.Normal);
                                holder.TxtLastMessages.SetTypeface(Typeface.Default, TypefaceStyle.Normal);
                            }
                        }

                        switch (item.ChatType)
                        {
                        case "user":
                            InitializeUser(holder, item);
                            break;

                        case "page":
                            InitializePage(holder, item);
                            break;

                        case "group":
                            InitializeGroup(holder, item);
                            break;
                        }

                        holder.RelativeLayoutMain.Visibility = item.Swiped ? ViewStates.Gone : ViewStates.Visible;
                        holder.MainSwipe.Visibility          = item.Swiped ? ViewStates.Visible : ViewStates.Gone;
                    }
                }
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception);
            }
        }