private void ShowBadgeSheet() { _progressDialog.Hide(); _fadeAnimation = AnimationUtils.LoadAnimation(this, global::Android.Resource.Animation.FadeIn); SetContentView(Resource.Layout.firstbadgeactivitylayout); _badgeSheetUserNameTextView = FindViewById <TextView>(Resource.Id.firstbadgewin_usernameTextView); _badgeSheetDescrTextView = FindViewById <TextView>(Resource.Id.firstbadgewin_wonderdescrTextView); _badgeSheetAnounceTextView = FindViewById <TextView>(Resource.Id.firstbadgewin_howTextView); _badgeSheetBadgeImageView = FindViewById <ImageView>(Resource.Id.firstbadgewin_BadgeImageView); _badgeSheetCloseImageButton = FindViewById <ImageButton>(Resource.Id.firstbadgewin_CloseImageButton); _badgeSheetCloseFakeImageButton = FindViewById <ImageButton>(Resource.Id.firstbadgewin_CloseImageButtonFake); _badgeSheetBonusListLinearLayout = FindViewById <LinearLayout>(Resource.Id.bonuspaperlist_linearLayout); _badgeSheetUserNameTextView.SetTypeface(_robotoLightFont, TypefaceStyle.Normal); _badgeSheetDescrTextView.SetTypeface(_robotoLightFont, TypefaceStyle.Normal); _badgeSheetAnounceTextView.SetTypeface(_robotoLightFont, TypefaceStyle.Normal); if (!AppInfo.IsLocaleRu) { _badgeSheetAnounceTextView.Text = "You got a new Badge"; } if (AppInfo._user.Fullname != null) { _badgeSheetUserNameTextView.Text = AppInfo._user.Fullname; } Achieves.ParentCategory.ParentProject.Achieve _achieve = new Achieves.ParentCategory.ParentProject.Achieve(); foreach (var category in AppInfo._achievesInfo.CategoryArray) { foreach (var project in category.Projects) { foreach (var achieve in project.Achievements) { if (achieve.FbId == ServiceItsBeta.PostOnFBBadgeFbId) { _achieve = achieve; } } } } using (var d = BitmapFactory.DecodeFile(@"/data/data/ru.hintsolutions.itsbeta/cache/pictures/" + "achive" + _achieve.ApiName + ".PNG")) { _badgeSheetBadgeImageView.SetImageBitmap(d); } _badgeSheetDescrTextView.Text = _achieve.Description; _badgeSheetCloseImageButton.Click += delegate { _vibe.Vibrate(50); _badgeSheetCloseFakeImageButton.StartAnimation(_fadeAnimation); Finish(); StartActivity(typeof(MainScreenActivity)); }; //Не показываем лист с бонусами if (_achieve.Bonuses.Count() == 0) { _badgeSheetBonusListLinearLayout.Visibility = ViewStates.Gone; } #region Показываем лист с 1 бонусом if (_achieve.Bonuses.Count() == 1) { var bonus = _achieve.Bonuses.First(); _badgeSheetBonusView = _baseLayoutInflater.Inflate(Resource.Layout.bonusonlistrowlayout, null); _badgeSheetBonusView.LayoutParameters = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.FillParent, RelativeLayout.LayoutParams.FillParent); _badgeSheetBonusLineImageView = (ImageView)_badgeSheetBonusView.FindViewById(Resource.Id.badgewin_GreenBonusImageView); _badgeSheetDiscountLineImageView = (ImageView)_badgeSheetBonusView.FindViewById(Resource.Id.badgewin_BlueBonusImageView); _badgeSheetPresentLineImageView = (ImageView)_badgeSheetBonusView.FindViewById(Resource.Id.badgewin_VioletBonusImageView); _badgeSheetBonusDescrBackgroundImageView = (ImageView)_badgeSheetBonusView.FindViewById(Resource.Id.badgewin_greendescbackgroundImageView); _badgeSheetDiscountDescrBackgroundImageView = (ImageView)_badgeSheetBonusView.FindViewById(Resource.Id.badgewin_bluedescbackgroundImageView); _badgeSheetPresentDescrBackgroundImageView = (ImageView)_badgeSheetBonusView.FindViewById(Resource.Id.badgewin_violetdescbackgroundImageView); _badgeSheetBonusNameTextView = (TextView)_badgeSheetBonusView.FindViewById(Resource.Id.badgewin_bonusTextView); _badgeSheetBonusDescrTextView = (TextView)_badgeSheetBonusView.FindViewById(Resource.Id.badgewin_bonusdescrTextView); _badgeSheetBonusNameTextView.SetTypeface(_robotoLightFont, TypefaceStyle.Normal); _badgeSheetBonusDescrTextView.SetTypeface(_robotoLightFont, TypefaceStyle.Normal); _badgeSheetBonusDescrTextView.MovementMethod = Android.Text.Method.LinkMovementMethod.Instance; _badgeSheetBonusLineImageView.Visibility = ViewStates.Invisible; _badgeSheetDiscountLineImageView.Visibility = ViewStates.Invisible; _badgeSheetPresentLineImageView.Visibility = ViewStates.Invisible; _badgeSheetBonusDescrBackgroundImageView.Visibility = ViewStates.Invisible; _badgeSheetDiscountDescrBackgroundImageView.Visibility = ViewStates.Invisible; _badgeSheetPresentDescrBackgroundImageView.Visibility = ViewStates.Invisible; _badgeSheetBonusDescrTextView.Visibility = ViewStates.Invisible; _badgeSheetBonusNameTextView.Visibility = ViewStates.Invisible; if (bonus.Type == "discount") { _badgeSheetBonusLineImageView.Visibility = ViewStates.Invisible; _badgeSheetDiscountLineImageView.Visibility = ViewStates.Visible; _badgeSheetPresentLineImageView.Visibility = ViewStates.Invisible; _badgeSheetBonusListLinearLayout.SetBackgroundColor(new Color(201, 238, 255, 86)); _badgeSheetBonusDescrTextView.Visibility = ViewStates.Visible; _badgeSheetBonusNameTextView.Visibility = ViewStates.Visible; _badgeSheetBonusNameTextView.Text = "Скидка"; if (!AppInfo.IsLocaleRu) { _badgeSheetBonusNameTextView.Text = "Discount"; } _badgeSheetBonusDescrTextView.SetText(Android.Text.Html.FromHtml(bonus.Description), TextView.BufferType.Spannable); _badgeSheetBonusListLinearLayout.AddView(_badgeSheetBonusView); } if (bonus.Type == "bonus") { _badgeSheetBonusLineImageView.Visibility = ViewStates.Visible; _badgeSheetDiscountLineImageView.Visibility = ViewStates.Invisible; _badgeSheetPresentLineImageView.Visibility = ViewStates.Invisible; _badgeSheetBonusListLinearLayout.SetBackgroundColor(new Color(189, 255, 185, 120)); _badgeSheetBonusDescrTextView.Visibility = ViewStates.Visible; _badgeSheetBonusNameTextView.Visibility = ViewStates.Visible; _badgeSheetBonusNameTextView.Text = "Бонус"; if (!AppInfo.IsLocaleRu) { _badgeSheetBonusNameTextView.Text = "Bonus"; } _badgeSheetBonusDescrTextView.SetText(Android.Text.Html.FromHtml(bonus.Description), TextView.BufferType.Spannable); _badgeSheetBonusListLinearLayout.AddView(_badgeSheetBonusView); } if (bonus.Type == "present") { _badgeSheetBonusLineImageView.Visibility = ViewStates.Invisible; _badgeSheetDiscountLineImageView.Visibility = ViewStates.Invisible; _badgeSheetPresentLineImageView.Visibility = ViewStates.Visible; _badgeSheetBonusListLinearLayout.SetBackgroundColor(new Color(255, 185, 245, 120)); _badgeSheetBonusDescrTextView.Visibility = ViewStates.Visible; _badgeSheetBonusNameTextView.Visibility = ViewStates.Visible; _badgeSheetBonusNameTextView.Text = "Подарок"; if (!AppInfo.IsLocaleRu) { _badgeSheetBonusNameTextView.Text = "Present"; } _badgeSheetBonusDescrTextView.SetText(Android.Text.Html.FromHtml(bonus.Description), TextView.BufferType.Spannable); _badgeSheetBonusListLinearLayout.AddView(_badgeSheetBonusView); } } #endregion if (_achieve.Bonuses.Count() > 1) { foreach (var bonus in _achieve.Bonuses) { _badgeSheetBonusView = _baseLayoutInflater.Inflate(Resource.Layout.bonusonlistrowlayout, null); _badgeSheetBonusView.LayoutParameters = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.FillParent, RelativeLayout.LayoutParams.FillParent); _badgeSheetBonusLineImageView = (ImageView)_badgeSheetBonusView.FindViewById(Resource.Id.badgewin_GreenBonusImageView); _badgeSheetDiscountLineImageView = (ImageView)_badgeSheetBonusView.FindViewById(Resource.Id.badgewin_BlueBonusImageView); _badgeSheetPresentLineImageView = (ImageView)_badgeSheetBonusView.FindViewById(Resource.Id.badgewin_VioletBonusImageView); _badgeSheetBonusDescrBackgroundImageView = (ImageView)_badgeSheetBonusView.FindViewById(Resource.Id.badgewin_greendescbackgroundImageView); _badgeSheetDiscountDescrBackgroundImageView = (ImageView)_badgeSheetBonusView.FindViewById(Resource.Id.badgewin_bluedescbackgroundImageView); _badgeSheetPresentDescrBackgroundImageView = (ImageView)_badgeSheetBonusView.FindViewById(Resource.Id.badgewin_violetdescbackgroundImageView); _badgeSheetBonusNameTextView = (TextView)_badgeSheetBonusView.FindViewById(Resource.Id.badgewin_bonusTextView); _badgeSheetBonusDescrTextView = (TextView)_badgeSheetBonusView.FindViewById(Resource.Id.badgewin_bonusdescrTextView); _badgeSheetBonusNameTextView.SetTypeface(_robotoLightFont, TypefaceStyle.Normal); _badgeSheetBonusDescrTextView.SetTypeface(_robotoLightFont, TypefaceStyle.Normal); _badgeSheetBonusDescrTextView.MovementMethod = Android.Text.Method.LinkMovementMethod.Instance; _badgeSheetBonusLineImageView.Visibility = ViewStates.Invisible; _badgeSheetDiscountLineImageView.Visibility = ViewStates.Invisible; _badgeSheetPresentLineImageView.Visibility = ViewStates.Invisible; _badgeSheetBonusDescrBackgroundImageView.Visibility = ViewStates.Invisible; _badgeSheetDiscountDescrBackgroundImageView.Visibility = ViewStates.Invisible; _badgeSheetPresentDescrBackgroundImageView.Visibility = ViewStates.Invisible; _badgeSheetBonusDescrTextView.Visibility = ViewStates.Invisible; _badgeSheetBonusNameTextView.Visibility = ViewStates.Invisible; if (bonus.Type == "discount") { _badgeSheetBonusLineImageView.Visibility = ViewStates.Invisible; _badgeSheetDiscountLineImageView.Visibility = ViewStates.Visible; _badgeSheetPresentLineImageView.Visibility = ViewStates.Invisible; _badgeSheetBonusDescrTextView.Visibility = ViewStates.Visible; _badgeSheetBonusNameTextView.Visibility = ViewStates.Visible; _badgeSheetBonusNameTextView.Text = "Скидка"; if (!AppInfo.IsLocaleRu) { _badgeSheetBonusNameTextView.Text = "Discount"; } _badgeSheetBonusDescrTextView.SetText(Android.Text.Html.FromHtml(bonus.Description), TextView.BufferType.Spannable); _badgeSheetBonusListLinearLayout.AddView(_badgeSheetBonusView); } if (bonus.Type == "bonus") { _badgeSheetBonusLineImageView.Visibility = ViewStates.Visible; _badgeSheetDiscountLineImageView.Visibility = ViewStates.Invisible; _badgeSheetPresentLineImageView.Visibility = ViewStates.Invisible; _badgeSheetBonusDescrTextView.Visibility = ViewStates.Visible; _badgeSheetBonusNameTextView.Visibility = ViewStates.Visible; _badgeSheetBonusNameTextView.Text = "Бонус"; if (!AppInfo.IsLocaleRu) { _badgeSheetBonusNameTextView.Text = "Bonus"; } _badgeSheetBonusDescrTextView.SetText(Android.Text.Html.FromHtml(bonus.Description), TextView.BufferType.Spannable); _badgeSheetBonusListLinearLayout.AddView(_badgeSheetBonusView); } if (bonus.Type == "present") { _badgeSheetBonusLineImageView.Visibility = ViewStates.Invisible; _badgeSheetDiscountLineImageView.Visibility = ViewStates.Invisible; _badgeSheetPresentLineImageView.Visibility = ViewStates.Visible; _badgeSheetBonusDescrTextView.Visibility = ViewStates.Visible; _badgeSheetBonusNameTextView.Visibility = ViewStates.Visible; _badgeSheetBonusNameTextView.Text = "Подарок"; if (!AppInfo.IsLocaleRu) { _badgeSheetBonusNameTextView.Text = "Present"; } _badgeSheetBonusDescrTextView.SetText(Android.Text.Html.FromHtml(bonus.Description), TextView.BufferType.Spannable); _badgeSheetBonusListLinearLayout.AddView(_badgeSheetBonusView); } } } }
public void AsyncActivizationViaEntering() { ItsBeta.Core.Achieves.ParentCategory.ParentProject.Achieve activatedAchieve; string response = "null"; try { response = _serviceItsBeta.ActivateBadge(_codeCompleteTextView.Text, AppInfo._appaccess_token, AppInfo._user.FacebookUserID); } catch { } if (response.StartsWith("badgefbId=")) { activatedBadgeFbId = response.Replace("badgefbId=", ""); try { AppInfo._achievesInfo = new Achieves(AppInfo._access_token, AppInfo._user.ItsBetaUserId, AppInfo.IsLocaleRu); } catch { response = "null"; return; } activatedAchieve = new Achieves.ParentCategory.ParentProject.Achieve(); foreach (var category in AppInfo._achievesInfo.CategoryArray) { foreach (var project in category.Projects) { foreach (var achieve in project.Achievements) { if (achieve.FbId == activatedBadgeFbId) { activatedAchieve = achieve; } } } } FileStream fs = new FileStream(@"/data/data/ru.hintsolutions.itsbeta/cache/pictures/" + activatedAchieve.ApiName + ".PNG", FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite ); if (!System.IO.File.Exists(@"/data/data/ru.hintsolutions.itsbeta/cache/pictures/" + "achive" + activatedAchieve.ApiName + ".PNG")) { Bitmap bitmap = GetImageBitmap(activatedAchieve.PicUrl); bitmap.Compress( Bitmap.CompressFormat.Png, 10, fs); bitmap.Dispose(); fs.Flush(); fs.Close(); System.IO.File.Copy(@"/data/data/ru.hintsolutions.itsbeta/cache/pictures/" + activatedAchieve.ApiName + ".PNG", @"/data/data/ru.hintsolutions.itsbeta/cache/pictures/" + "achive" + activatedAchieve.ApiName + ".PNG"); System.IO.File.Delete(@"/data/data/ru.hintsolutions.itsbeta/cache/pictures/" + activatedAchieve.ApiName + ".PNG"); } RunOnUiThread(() => CompleteActivation(activatedAchieve)); } if (response.StartsWith("error=")) { errorDescr = response.Replace("error=", ""); RunOnUiThread(() => _progressDialog.Dismiss()); //RunOnUiThread(() =>CreateAchievementsViewObject()); if (errorDescr == "obj not found") { errorDescr = "Неверный код активации"; if (!AppInfo.IsLocaleRu) { errorDescr = "Wrong activation code"; } } if (errorDescr == "activation code is used") { errorDescr = "Код уже активирован"; if (!AppInfo.IsLocaleRu) { errorDescr = "Code is already activated"; } } _wrongCodeDialogTitle.Text = "Информация"; if (!AppInfo.IsLocaleRu) { _wrongCodeDialogTitle.Text = "Information"; } _wrongCodeDialogMessage.Text = errorDescr; RunOnUiThread(() => _wrongCodeDialog.Show()); return; } if (response == "null") { RunOnUiThread(() => _progressDialog.Dismiss()); errorDescr = "Неудалось активировать. Проверьте настройки интернет соединения"; _wrongCodeDialogTitle.Text = "Ошибка"; if (!AppInfo.IsLocaleRu) { errorDescr = "Activation error. Internet connection is missing"; _wrongCodeDialogTitle.Text = "Error"; } _wrongCodeDialogMessage.Text = errorDescr; RunOnUiThread(() => _wrongCodeDialog.Show()); } }