// create a new ImageView for each item referenced by the Adapter public override View GetView(int position, View convertView, ViewGroup parent) { //Button tagButton; TextView tagButton; if (convertView == null) { // if it's not recycled, initialize some attributes //tagButton = new Button(context); tagButton = new TextView(context); //tagButton.LayoutParameters = new GridView.LayoutParams(190, 190); tagButton.LayoutParameters = new GridView.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent); tagButton.SetTextColor(Color.Rgb(34, 191, 185)); //tagButton.SetPadding(5, 2, 5, 2);// ltrb tagButton.SetPadding(10, 4, 10, 4);// ltrb tagButton.SetBackgroundResource(Resource.Drawable.flame_style); //imageView.SetScaleType(ImageView.ScaleType.CenterCrop); } else { //tagButton = (Button)convertView; tagButton = (TextView)convertView; } // Bitmap bmp = MediaStore.Images.Thumbnails.GetThumbnail(cr, items[position].ImageId, ThumbnailKind.MicroKind, null); //imageView.SetImageBitmap(bmp); tagButton.Text = items[position].TagStr; return tagButton; }
/// <summary> /// Constructs a new representation as a visual ball with a number of string in its center. /// </summary> /// <param name="currentActivity">The activity on which the ball should be drawn.</param> /// <param name="note">The note that should be played correspondingly when visually arriving to the guitar's neck.</param> public NoteRepresentation(Activity currentActivity, Note note) { //Basic values. _currentActivity = currentActivity; _note = note; //The color of the ball. BallColor ballColor = (BallColor)note.Position.String; //note.Position.Fret; //Which string the number on the ball should represent. //GuitarString stringNum = note.Position.String; _noteCircle = new TextView(_currentActivity); //Select the ball's color. switch (ballColor) { case BallColor.Red: _noteCircle.SetBackgroundResource(Resource.Drawable.ball_red); break; case BallColor.Purple: _noteCircle.SetBackgroundResource(Resource.Drawable.ball_purple); break; case BallColor.Blue: _noteCircle.SetBackgroundResource(Resource.Drawable.ball_blue); break; case BallColor.Green: _noteCircle.SetBackgroundResource(Resource.Drawable.ball_green); break; case BallColor.Orange: _noteCircle.SetBackgroundResource(Resource.Drawable.ball_orange); break; case BallColor.Aqua: _noteCircle.SetBackgroundResource(Resource.Drawable.ball_aqua); break; case BallColor.Yellow: _noteCircle.SetBackgroundResource(Resource.Drawable.ball_yellow); break; } //Set dimensions. _noteCircle.Layout(0, 0, BUTTON_WIDTH, BUTTON_HEIGHT); //Center text. _noteCircle.Gravity = GravityFlags.Center; //Set text. //_noteCircle.SetText(((int)stringNum).ToString(), TextView.BufferType.Normal); //Refresh view. _noteCircle.RequestLayout(); //Add the newly created note circle to the current activity. _currentActivity.AddContentView(_noteCircle, new ViewGroup.LayoutParams(BUTTON_WIDTH, BUTTON_HEIGHT)); }
public static void SetTimeRemaining(Post post, TextView timeRemainingTextView, ImageView clockImageView) { if (post.IsExpired()) { timeRemainingTextView.Text = StringUtils.GetTopTime(post); timeRemainingTextView.SetTextColor(Color.White); timeRemainingTextView.SetBackgroundResource(Resource.Drawable.RoundedCorners5Black); clockImageView.Visibility = ViewStates.Invisible; } else { timeRemainingTextView.Text = StringUtils.GetPrettyDateAbs(post.expiration); timeRemainingTextView.SetTextColor(ViewUtils.GetTimeRemainingColor(post.expiration)); //timeRemainingTextView.SetBackgroundColor(Android.Graphics.Color.Transparent); clockImageView.Visibility = ViewStates.Visible; } }
public override View GetView(int position, View convertView, ViewGroup parent) { TextView button = new TextView(context); button.SetText(chapters[position], TextView.BufferType.Normal); button.TextSize = 32; button.SetTypeface(ThisApp.Font(context, "ionbold"), Android.Graphics.TypefaceStyle.Normal); button.SetHeight(84); button.SetBackgroundResource(Resource.Drawable.metro_button_style); button.Gravity = GravityFlags.Center; //button.SetPadding(0, 0, 0, 0); //button.SetTextColor(Resources.System.GetColorStateList(Resource.Color.metro_button_text_style)); //button.SetTextColor(Resources.System.GetColor(Resource.Color.metro_button_text_style)); button.Id = position; button.Click += button_Click; return button; }
/** * Creates a new view that will be used to display the specified pointer id on the touchpad * view. * * @param pointerId the id of the pointer that this finger trace view will represent; used to * determine its color and text * @return the {@code TextView} that was created */ private TextView createFingerTraceView(int pointerId) { var fingerTraceView = new TextView(Context); fingerTraceView.SetBackgroundResource(FINGER_RES_IDS[pointerId]); fingerTraceView.Text = pointerId.ToString(); fingerTraceView.Gravity = GravityFlags.Center; fingerTraceView.SetTextAppearance(Context, Android.Resource.Style.TextAppearanceDeviceDefaultSmall); fingerTraceView.Alpha = 0; var lp = new RelativeLayout.LayoutParams(FINGER_TRACE_SIZE, FINGER_TRACE_SIZE); lp.AddRule(LayoutRules.AlignParentTop); lp.AddRule(LayoutRules.AlignParentLeft); // The right and bottom margin here are required so that the view doesn't get "squished" // as it touches the right or bottom side of the touchpad view. lp.RightMargin = -2 * FINGER_TRACE_SIZE; lp.BottomMargin = -2 * FINGER_TRACE_SIZE; fingerTraceView.LayoutParameters = lp; return fingerTraceView; }
private void createUI(MessageDB message, UserDB contact) { #if DEBUG System.Diagnostics.Debug.WriteLine ("AccoundID (MC) = {0}", AndroidData.CurrentUser.AccountID.ToString ()); #endif int m = 0; string messager = ""; if (message != null && contact != null) { RunOnUiThread (delegate { ImageView random = null; LinearLayout layout = new LinearLayout (context); layout.Orientation = Android.Widget.Orientation.Horizontal; layout.SetGravity (GravityFlags.CenterVertical); layout.SetPadding ((int)ImageHelper.convertDpToPixel (10f, context), 0, (int)ImageHelper.convertDpToPixel (10f, context), (int)ImageHelper.convertDpToPixel (10f, context)); ImageView profilepic = new ImageView (context); profilepic.LayoutParameters = new ViewGroup.LayoutParams ((int)ImageHelper.convertDpToPixel (60f, context), (int)ImageHelper.convertDpToPixel (100f, context)); profilepic.Tag = new Java.Lang.String ("profilepic_" + m.ToString ()); if (contact == null) profilepic.SetImageDrawable (Application.Context.Resources.GetDrawable (Resource.Drawable.defaultuserimage)); else { if (contact.Picture.Length > 0) { //profilepic.SetImageDrawable(Android.Graphics.Drawables.Drawable.CreateFromStream(new MemoryStream(eachContact.ContactUser.Picture), "Profile")); loadProfilePicture (contact.AccountID); } else { profilepic.SetImageDrawable (Application.Context.Resources.GetDrawable (Resource.Drawable.defaultuserimage)); } //layout.AddView(profilepic); LinearLayout layout2 = new LinearLayout (context); layout2.Orientation = Orientation.Vertical; layout2.SetGravity (GravityFlags.Center); TextView name = new TextView (context); name.LayoutParameters = new ViewGroup.LayoutParams ((int)ImageHelper.convertDpToPixel (260f, context), (int)ImageHelper.convertDpToPixel (40f, context)); name.Gravity = GravityFlags.Center; name.SetTextColor (Color.White); name.TextSize = 16f; name.Text = contact.FirstName + " " + contact.LastName; layout2.AddView (name); TextView text = new TextView (context); text.LayoutParameters = new ViewGroup.LayoutParams ((int)ImageHelper.convertDpToPixel (240f, context), (int)ImageHelper.convertDpToPixel (60f, context)); text.SetPadding ((int)ImageHelper.convertDpToPixel (10f, context), 0, (int)ImageHelper.convertDpToPixel (10f, context), 0); text.Gravity = GravityFlags.CenterVertical; if (name.Text == isMe) text.SetBackgroundResource (Resource.Drawable.bubblesolidright); else text.SetBackgroundResource (Resource.Drawable.bubblesolidleft); text.TextSize = 16f; for (int e = 0; e < message.MessageStepDBList.Count; ++e) { if (!string.IsNullOrEmpty (message.MessageStepDBList [e].MessageText)) { messager = message.MessageStepDBList [e].MessageText; break; } } if (string.IsNullOrEmpty (messager)) messager = "No text message found"; int nolines = messager.Length / 27; text.SetHeight ((nolines + 1) * 20); text.SetTextColor (Android.Graphics.Color.Black); text.Text = messager; layout2.Clickable = true; layout2.AddView (text); if (message.MessageStepDBList.Count > 1) { LinearLayout layout3 = new LinearLayout (context); layout3.Orientation = Orientation.Horizontal; if (name.Text == isMe) layout3.SetGravity (GravityFlags.Right); else layout3.SetGravity (GravityFlags.Left); layout3.SetBackgroundResource (Resource.Drawable.attachmentspreviewbkgr); layout3.SetVerticalGravity (GravityFlags.CenterVertical); layout3.SetMinimumHeight (30); layout3.SetPadding ((int)ImageHelper.convertDpToPixel (10f, context), 0, (int)ImageHelper.convertDpToPixel (10f, context), 0); if (name.Text != isMe) { random = new ImageView (context); random.LayoutParameters = new ViewGroup.LayoutParams ((int)ImageHelper.convertDpToPixel (30f, context), (int)ImageHelper.convertDpToPixel (30f, context)); random.SetBackgroundResource (Resource.Drawable.playblack); //random.Click += delegate { PlayMessage(message); }; layout3.AddView (random); } for (int i = 1; i < message.MessageStepDBList.Count; ++i) { switch (message.MessageStepDBList [i].StepType) { case LOLMessageDelivery.MessageStep.StepTypes.Animation: random = new ImageView (context); random.LayoutParameters = new ViewGroup.LayoutParams ((int)ImageHelper.convertDpToPixel (30f, context), (int)ImageHelper.convertDpToPixel (30f, context)); random.SetBackgroundResource (Resource.Drawable.drawicon); layout3.AddView (random); break; case LOLMessageDelivery.MessageStep.StepTypes.Comicon: random = new ImageView (context); random.LayoutParameters = new ViewGroup.LayoutParams ((int)ImageHelper.convertDpToPixel (30f, context), (int)ImageHelper.convertDpToPixel (30f, context)); random.SetBackgroundResource (Resource.Drawable.comicon); layout3.AddView (random); break; case LOLMessageDelivery.MessageStep.StepTypes.Comix: random = new ImageView (context); random.LayoutParameters = new ViewGroup.LayoutParams ((int)ImageHelper.convertDpToPixel (30f, context), (int)ImageHelper.convertDpToPixel (30f, context)); random.SetBackgroundResource (Resource.Drawable.comicmsgs); layout3.AddView (random); break; case LOLMessageDelivery.MessageStep.StepTypes.Emoticon: random = new ImageView (context); random.LayoutParameters = new ViewGroup.LayoutParams ((int)ImageHelper.convertDpToPixel (30f, context), (int)ImageHelper.convertDpToPixel (30f, context)); random.SetBackgroundResource (Resource.Drawable.emoticonmsg); layout3.AddView (random); break; case LOLMessageDelivery.MessageStep.StepTypes.Polling: random = new ImageView (context); random.LayoutParameters = new ViewGroup.LayoutParams ((int)ImageHelper.convertDpToPixel (30f, context), (int)ImageHelper.convertDpToPixel (30f, context)); random.SetBackgroundResource (Resource.Drawable.pollmsg); layout3.AddView (random); break; case LOLMessageDelivery.MessageStep.StepTypes.SoundFX: random = new ImageView (context); random.LayoutParameters = new ViewGroup.LayoutParams ((int)ImageHelper.convertDpToPixel (30f, context), (int)ImageHelper.convertDpToPixel (30f, context)); random.SetBackgroundResource (Resource.Drawable.soundfxmsg); layout3.AddView (random); break; case LOLMessageDelivery.MessageStep.StepTypes.Video: random = new ImageView (context); random.LayoutParameters = new ViewGroup.LayoutParams ((int)ImageHelper.convertDpToPixel (30f, context), (int)ImageHelper.convertDpToPixel (30f, context)); random.SetBackgroundResource (Resource.Drawable.videomsg); layout3.AddView (random); break; case LOLMessageDelivery.MessageStep.StepTypes.Voice: random = new ImageView (context); random.LayoutParameters = new ViewGroup.LayoutParams ((int)ImageHelper.convertDpToPixel (30f, context), (int)ImageHelper.convertDpToPixel (30f, context)); random.SetBackgroundResource (Resource.Drawable.voicemsg); layout3.AddView (random); break; } } if (name.Text == isMe) { random = new ImageView (context); random.LayoutParameters = new ViewGroup.LayoutParams ((int)ImageHelper.convertDpToPixel (30f, context), (int)ImageHelper.convertDpToPixel (30f, context)); random.SetBackgroundResource (Resource.Drawable.playblack); //random.Click += delegate { PlayMessage(message); }; layout3.AddView (random); } layout2.AddView (layout3); } if (name.Text != isMe) { layout.AddView (profilepic); layout.AddView (layout2); } else { layout.AddView (layout2); layout.AddView (profilepic); } converse.AddView (layout); m++; } }); } }
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { view = (RelativeLayout)inflater.Inflate (Resource.Layout.raffledetail, container, false); bodypanel=(RelativeLayout)view.FindViewById (Resource.Id.raffledetail_bodypanel_relativelayout); invitecard=(RelativeLayout)view.FindViewById (Resource.Id.raffledetail_invitationpanel_relativelayout); scrollcontainer=(ScrollView)view.FindViewById (Resource.Id.raffledetail_scrollcontainer_scrollview); LinearLayout sociallayout = (LinearLayout)invitecard.FindViewById (Resource.Id.raffledetail_socialbar_linearlayout); sociallayout.SetGravity (GravityFlags.Center); LinearLayout itemscontainer = new LinearLayout (nn_activity); LinearLayout.LayoutParams param = new LinearLayout.LayoutParams (LinearLayout.LayoutParams.MatchParent,LinearLayout.LayoutParams.WrapContent); param.Gravity = GravityFlags.CenterHorizontal; itemscontainer.LayoutParameters = param; itemscontainer.Orientation = Orientation.Horizontal; toobaritemfacebook = new ToolBarButton (nn_activity,itemscontainer,Resource.Drawable.ic_facebook_70X70); toobaritemfacebook.Click+= (object sender, EventArgs e) => { ShowPostToFacebook(); }; toobaritemtwitter = new ToolBarButton (nn_activity,itemscontainer,Resource.Drawable.ic_twitter_70X70); toobaritemtwitter.Click+= (object sender, EventArgs e) => { if(this.eventcard.eventinfo.representative_needed.Equals("N")){ socialshareandroid.Twitter (RaffleDetailDate.c_twitterAPIKey, RaffleDetailDate.c_twitterSecret, String.Format(RaffleDetailDate.c_twitterMessageTemplate_WithLink,eventcard.eventinfo.organization), eventcard.eventinfo.sell_ticket_url); } else{ socialshareandroid.Twitter (RaffleDetailDate.c_twitterAPIKey, RaffleDetailDate.c_twitterSecret,String.Format(RaffleDetailDate.c_twitterMessageTemplate_NoLink,eventcard.eventinfo.organization),RaffleDetailDate.Tap5050WebPageLink); } }; toobaritemsms = new ToolBarButton (nn_activity,itemscontainer,Resource.Drawable.ic_sms_70X70); toobaritemsms.Click+= (object sender, EventArgs e) => { (nn_activity as HomeScreen).ShowContactListPicker(eventcard,eventcard.eventinfo.organization,eventcard.eventinfo.buy_ticket_url,eventcard.eventinfo.location_name); }; toobaritememail = new ToolBarButton (nn_activity,itemscontainer,Resource.Drawable.ic_email_70X70); toobaritememail.Click+= (object sender, EventArgs e) => { (nn_activity as HomeScreen).ShowEmailListPicker(eventcard,eventcard.eventinfo.organization,eventcard.eventinfo.buy_ticket_url,eventcard.eventinfo.location_name); }; itemscontainer.AddView (toobaritemfacebook); itemscontainer.AddView (toobaritemtwitter); itemscontainer.AddView (toobaritemsms); itemscontainer.AddView (toobaritememail); sociallayout.AddView (itemscontainer); TextView sendinvitationhint = (TextView)invitecard.FindViewById (Resource.Id.raffledetail_sendinvitationhint_textview); sendinvitationhint.Text = RaffleDetailDate.contactDescriptionText; invitationedittext = (EditText)invitecard.FindViewById (Resource.Id.raffledetail_sendinvitation_edittext); invitationedittext.Hint = RaffleDetailDate.ContactTextFieldPlaceholder; invitationedittext.SetSingleLine (); sendinvitationbutton=(Button)invitecard.FindViewById (Resource.Id.raffledetail_sendinvitation_button); sendinvitationbutton.Click+= (object sender, EventArgs e) =>{ string destination=invitationedittext.Text; //check if it is a canada phone if(FormatManager.chechinput(destination,FormatManager.FormatOption.Phone)){ string contactsstring="To:\n"+"<"+destination+">"; List<string> destinationlist=new List<string>(); destinationlist.Add(destination); string sendmessagestring=""; if (String.IsNullOrEmpty(eventcard.eventinfo.share_sms_body)) { if (eventcard.eventinfo.representative_needed.Equals("N")) { sendmessagestring = String.Format(RaffleDetailDate.c_smsMessageTemplate_WithLink, eventcard.eventinfo.organization, eventcard.eventinfo.buy_ticket_url, eventcard.eventinfo.location_name); } else { sendmessagestring = String.Format(RaffleDetailDate.c_smsMessageTemplate_NoLink, eventcard.eventinfo.organization, RaffleDetailDate.Tap5050WebPageLink); } } else { sendmessagestring = SharingString.Format(eventcard.eventinfo.share_sms_body, eventcard.eventinfo); } //for API>4.4 call system default app to send message if (global::Android.OS.Build.VERSION.SdkInt >= global::Android.OS.BuildVersionCodes.Kitkat) { SocialShareAndroid.Sms(sendmessagestring,destinationlist.ToArray()); } else { (nn_activity as HomeScreen).ShowSMSFragment(eventcard,sendmessagestring, contactsstring,destinationlist); } } else if(FormatManager.chechinput(destination,FormatManager.FormatOption.Email)){ List<string> destinationlist=new List<string>(); destinationlist.Add(destination); if (String.IsNullOrEmpty(eventcard.eventinfo.share_email_body) && String.IsNullOrEmpty(eventcard.eventinfo.share_email_subject)) { if (eventcard.eventinfo.representative_needed.Equals("N")) { SocialShareAndroid.Email(String.Format(RaffleDetailDate.c_emailMessageTemplate_WithLink, eventcard.eventinfo.organization, eventcard.eventinfo.buy_ticket_url, eventcard.eventinfo.location_name), String.Format(RaffleDetailDate.c_emailSubjectTemplate_WithLink, eventcard.eventinfo.organization), destinationlist.ToArray()); } else { SocialShareAndroid.Email(String.Format(RaffleDetailDate.c_emailMessageTemplate_NoLink, eventcard.eventinfo.organization, eventcard.eventinfo.location_name, RaffleDetailDate.Tap5050WebPageLink), string.Format(RaffleDetailDate.c_emailSubjectTemplate_NoLink, eventcard.eventinfo.organization), destinationlist.ToArray()); } } else { SocialShareAndroid.Email(SharingString.Format(eventcard.eventinfo.share_email_body, eventcard.eventinfo), SharingString.Format(eventcard.eventinfo.share_email_subject, eventcard.eventinfo), destinationlist.ToArray()); } } else{ nn_activity.ShowCustomAlterDialogFragment(RaffleDetailDate.AlertScreenFormatErrorTitle,RaffleDetailDate.AlertScreenFormatErrorMessage,GlobalScreenData.DefaultPositive,null,"exceptiondialog.raffledetail.invitationformat"); } }; leftindicator = (RelativeLayout)view.FindViewById (Resource.Id.raffledetail_toptableftindicator_relativelayout); middleindicator= (RelativeLayout)view.FindViewById (Resource.Id.raffledetail_toptabmiddleindicator_relativelayout); rightindicator= (RelativeLayout)view.FindViewById (Resource.Id.raffledetail_toptabrightindicator_relativelayout); leftbutton=(Button)view.FindViewById (Resource.Id.raffledetail_toptableft_button); leftbutton.Tag = 0; middlebutton=(Button)view.FindViewById (Resource.Id.raffledetail_toptabmiddle_button); middlebutton.Tag = 1; rightbutton=(Button)view.FindViewById (Resource.Id.raffledetail_toptabright_button); rightbutton.Tag = 2; leftbutton.Click-= onToptabClick; leftbutton.Click+= onToptabClick; middlebutton.Click-= onToptabClick; middlebutton.Click+= onToptabClick; rightbutton.Click-= onToptabClick; rightbutton.Click+= onToptabClick; //set indicator color of switches setIndicator(0); if (eventcard.eventinfo.has_jackpot.Equals ("Y") && eventcard.eventinfo.jackpot_description != null && eventcard.eventinfo.jackpot_total != null) { jackpotdescriptiontext = (TextView)view.FindViewById (Resource.Id.raffledetail_jackpotdescription_textview); jackpotdescriptiontext.Text = eventcard.eventinfo.jackpot_description; jackpottotaltext = (TextView)view.FindViewById (Resource.Id.raffledetail_jackpottotal_textview); jackpottotaltext.Text = "$"+eventcard.eventinfo.jackpot_total; } else { jackpotlinearlayout = (LinearLayout)view.FindViewById (Resource.Id.raffledetail_jackpot_linearlayout); jackpotlinearlayout.Visibility = ViewStates.Gone; } //set image if(eventcard.originalmap!=null){ rafflelogoimagview=(ImageView)view.FindViewById (Resource.Id.raffledetail_pic_imgview); rafflelogoimagview.SetImageBitmap(eventcard.originalmap); } //set licence licencetext=(TextView)view.FindViewById(Resource.Id.raffledetail_licence_textview); licencetext.Text = RaffleDetailDate.LicenseNumberLabelText +"\n"+ eventcard.eventinfo.licence_number; //setname and org nametext = (TextView)view.FindViewById (Resource.Id.raffledetail_name_textview); nametext.Text=eventcard.eventinfo.event_name; organizationtext = (TextView)view.FindViewById (Resource.Id.raffledetail_organization_textview); organizationtext.Text=eventcard.eventinfo.organization; //set description descriptiontext=(TextView)view.FindViewById(Resource.Id.raffledetail_description_textview); descriptiontext.Text = eventcard.eventinfo.description; seeprizebutton = (Button)view.FindViewById (Resource.Id.raffledetail_seeprize_button); seeprizebutton.Click+= (object sender, EventArgs e) => { if(!String.IsNullOrEmpty(eventcard.eventinfo.prize_url)){ (nn_activity as HomeScreen).ShowSeePrize(eventcard.eventinfo.prize_url); } }; seeprizebutton.Text = RaffleDetailDate.SeePrizeBtnTitle; if(string.IsNullOrEmpty(eventcard.eventinfo.prize_url)){ seeprizebutton.Visibility = ViewStates.Invisible; } sellticketbutton = (Button)view.FindViewById (Resource.Id.raffledetail_buyticket_button); if(eventcard.eventinfo.have_contract.Equals("N")){ sellticketbutton.Text=RaffleDetailDate.ApplyContractBtnTitle; sellticketbutton.Click += OnApplyContractButtonClick; } if (eventcard.eventinfo.have_contract.Equals ("Y")) { sellticketbutton.Text=RaffleDetailDate.SellTicketBtnTitle; sellticketbutton.Click += OnSellTicketButtonClick; } // //create menu // Tap5050MenuBuilder menubuilder=new Tap5050MenuBuilder(nn_activity,Resource.Drawable.bg_relativelayout_grayround); // menubuilder.SetCell (); // menubuilder.AddItem (Resource.Drawable.ic_invitation_75X75,"Quick Invitation",()=>{ // menucontainer.Visibility=ViewStates.Invisible; // if(invitecard.Visibility==ViewStates.Gone){ // invitecard.Visibility=ViewStates.Visible; // } // if(showgoal==0){ // var headerLayoutParams = (global::Android.Views.ViewGroup.MarginLayoutParams) invitecard.LayoutParameters; // headerLayoutParams.TopMargin = 0; // invitecard.LayoutParameters = headerLayoutParams; // } // }); // menubuilder.AddItem (Resource.Drawable.ic_facebook_70X70,"FaceBook Share",()=>{ // menucontainer.Visibility=ViewStates.Invisible; // ShowPostToFacebook(); // }); // menubuilder.AddItem (Resource.Drawable.ic_twitter_70X70,"Twiter Share",()=>{ // menucontainer.Visibility=ViewStates.Invisible; // if(this.eventcard.eventinfo.representative_needed.Equals("N")){ // socialshareandroid.Twitter (RaffleDetailDate.c_twitterAPIKey, RaffleDetailDate.c_twitterSecret, String.Format(RaffleDetailDate.c_twitterMessageTemplate_WithLink,eventcard.eventinfo.organization), eventcard.eventinfo.sell_ticket_url); // } // else{ // socialshareandroid.Twitter (RaffleDetailDate.c_twitterAPIKey, RaffleDetailDate.c_twitterSecret,String.Format(RaffleDetailDate.c_twitterMessageTemplate_NoLink,eventcard.eventinfo.organization),RaffleDetailDate.Tap5050WebPageLink); // } // // }); // menubuilder.AddItem (Resource.Drawable.ic_sms_70X70,"SMS Share",()=>{ // menucontainer.Visibility=ViewStates.Invisible; // (nn_activity as HomeScreen).ShowContactListPicker(eventcard,eventcard.eventinfo.organization,eventcard.eventinfo.buy_ticket_url,eventcard.eventinfo.location_name); // // }); // menubuilder.AddItem (Resource.Drawable.ic_email_70X70,"Email Share",()=>{ // menucontainer.Visibility=ViewStates.Invisible; // (nn_activity as HomeScreen).ShowEmailListPicker(eventcard,eventcard.eventinfo.organization,eventcard.eventinfo.buy_ticket_url,eventcard.eventinfo.location_name); // // }); // // //get container add to view // menucontainer=menubuilder.Build (); // RelativeLayout.LayoutParams menucontainerparam = new RelativeLayout.LayoutParams (TapUtil.dptodx(menubuilder.totalwidth),TapUtil.dptodx(menubuilder.totalheight)); // menucontainerparam.RightMargin=TapUtil.dptodx (60+35); // menucontainerparam.TopMargin=TapUtil.dptodx (5); // menucontainerparam.AddRule (LayoutRules.AlignParentRight); // menucontainer.LayoutParameters = menucontainerparam; // view.AddView (menucontainer); // menucontainer.Visibility = ViewStates.Invisible; //if have seller position if (!string.IsNullOrEmpty (eventcard.eventinfo.seller_position) && !string.IsNullOrEmpty (eventcard.eventinfo.seller_position)) { //if show personal LeaderBoardSelfCard selfcard = new LeaderBoardSelfCard (eventcard.eventinfo.seller_position, eventcard.eventinfo.gross_sales); List<LeaderBoardCard> boardcardlist = new List<LeaderBoardCard> (); bool havesetboardboardheader = false; for (int i = 0; i < eventcard.eventinfo.LeaderBoardList.Count; i++) { if (!havesetboardboardheader) { havesetboardboardheader = true; boardcardlist.Add (new LeaderBoardCard (eventcard.eventinfo.LeaderBoardList [i], 1)); } else { boardcardlist.Add (new LeaderBoardCard (eventcard.eventinfo.LeaderBoardList [i], 2)); } } leaderboardadapter = new LeaderBoardAdapter (nn_activity, boardcardlist, selfcard); } else { leaderboardadapter = new LeaderBoardAdapter (nn_activity, new List<LeaderBoardCard> (), new LeaderBoardSelfCard("0","0")); } if (!string.IsNullOrEmpty (eventcard.eventinfo.group_position) && !string.IsNullOrEmpty (eventcard.eventinfo.group_sales)) { //if show team LeaderBoardSelfCard selfcard = new LeaderBoardSelfCard (eventcard.eventinfo.group_position, eventcard.eventinfo.group_sales); List<TeamLeaderBoardCard> boardcardlist = new List<TeamLeaderBoardCard> (); bool havesetboardboardheader = false; for (int i = 0; i < eventcard.eventinfo.groupLeaderBoardList.Count; i++) { if (!havesetboardboardheader) { havesetboardboardheader = true; boardcardlist.Add (new TeamLeaderBoardCard (eventcard.eventinfo.groupLeaderBoardList[i], 1)); } else { boardcardlist.Add (new TeamLeaderBoardCard (eventcard.eventinfo.groupLeaderBoardList[i], 2)); } } leaderboardadapter = new LeaderBoardAdapter (nn_activity, boardcardlist, selfcard, true); }else { leaderboardadapter = new LeaderBoardAdapter (nn_activity, new List<TeamLeaderBoardCard> (), new LeaderBoardSelfCard("0","0"),true); } //GET CONTAINER goalscontainer=(RelativeLayout)view.FindViewById (Resource.Id.raffledetail_goalsbodycontainer_relativelayout); goalscontainer.Visibility = ViewStates.Invisible; //goalscontainer.SetBackgroundResource(Resource.Drawable.bg_relativelayout_grayround); RelativeLayout slideritemcontainer = new RelativeLayout (nn_activity); slideritemcontainer.LayoutParameters=new RelativeLayout.LayoutParams ( RelativeLayout.LayoutParams.MatchParent,RelativeLayout.LayoutParams.WrapContent); //slideritemcontainer.SetPadding (TapUtil.dptodx(30),TapUtil.dptodx(10),TapUtil.dptodx(30),TapUtil.dptodx(10)); try{ DateTime eventEndTime=DateTime.ParseExact (eventcard.eventinfo.event_end_time.Substring (0, 19), "yyyy-MM-ddTHH:mm:ss", null); hours=(eventEndTime-DateTime.Now).TotalHours; } catch{ hours = 0; } daybartextview = new TextView (nn_activity); int leftday = (int)hours / 24; int lefthours = (int)hours % 24; daybartextview.Text = string.Format (" "+leftday+" Days,"+" "+lefthours+" Hours"); daybartextview.Gravity = GravityFlags.Center; daybartextview.Typeface = Typeface.DefaultBold; daybartextview.SetBackgroundResource(Resource.Color.iosblue); daybartextview.TextSize = TapUtil.dptodx (8); daybartextview.SetTextColor (Color.White); daybartextview.Id = TapUtil.generateViewId (); RelativeLayout.LayoutParams daybartextviewparam=new RelativeLayout.LayoutParams (RelativeLayout.LayoutParams.MatchParent,RelativeLayout.LayoutParams.WrapContent); daybartextviewparam.TopMargin=TapUtil.dptodx (10); daybartextviewparam.LeftMargin=TapUtil.dptodx (5); daybartextviewparam.RightMargin=TapUtil.dptodx (5); daybartextview.LayoutParameters = daybartextviewparam; slideritemcontainer.AddView (daybartextview); circlepanelrealtivelayout = new RelativeLayout (nn_activity); //circlepanelrealtivelayout.SetBackgroundResource (Resource.Drawable.bg_relativelayout_grayround); circlepanelrealtivelayout.Id = TapUtil.generateViewId (); RelativeLayout.LayoutParams circlepanelparam=new RelativeLayout.LayoutParams (RelativeLayout.LayoutParams.MatchParent,RelativeLayout.LayoutParams.WrapContent); //circlepanelparam.TopMargin=TapUtil.dptodx(20); circlepanelparam.AddRule (LayoutRules.Below, daybartextview.Id); circlepanelrealtivelayout.LayoutParameters= circlepanelparam; circlepanelrealtivelayout.SetPadding (TapUtil.dptodx (5), TapUtil.dptodx (5), TapUtil.dptodx (5), TapUtil.dptodx (5)); personalprogresslabel = new TextView (nn_activity); personalprogresslabel.Text=GoalScreenData.personalProgressLabelText; RelativeLayout.LayoutParams personalprogresslabelparam=new RelativeLayout.LayoutParams (RelativeLayout.LayoutParams.MatchParent,RelativeLayout.LayoutParams.WrapContent); personalprogresslabel.LayoutParameters = personalprogresslabelparam; personalprogresslabel.Gravity = GravityFlags.Center; personalprogresslabel.Typeface = Typeface.DefaultBold; personalprogresslabel.Id = TapUtil.generateViewId (); goalslinearlayout = new LinearLayout (nn_activity); RelativeLayout.LayoutParams goalslayoutparam=new RelativeLayout.LayoutParams (RelativeLayout.LayoutParams.MatchParent,RelativeLayout.LayoutParams.WrapContent); goalslayoutparam.AddRule (LayoutRules.Below, personalprogresslabel.Id); goalslayoutparam.TopMargin = TapUtil.dptodx (10); goalslinearlayout.LayoutParameters = goalslayoutparam; goalslinearlayout.Orientation = Orientation.Horizontal; goalslinearlayout.Id = TapUtil.generateViewId (); int peronalrise = 0; int goalamount = 0; if (!string.IsNullOrEmpty(eventcard.eventinfo.gross_sales) ) { peronalrise = Int32.Parse(eventcard.eventinfo.gross_sales); } if(!string.IsNullOrEmpty(eventcard.eventinfo.seller_goal)){ goalamount = Int32.Parse(eventcard.eventinfo.seller_goal); } LinearLayout raisedlinearlayout = new LinearLayout (nn_activity); raisedlinearlayout.Orientation = Orientation.Vertical; LinearLayout.LayoutParams raisedlayoutparam = new LinearLayout.LayoutParams (LinearLayout.LayoutParams.MatchParent,TapUtil.dptodx(40)); raisedlayoutparam.Weight = 1; raisedlinearlayout.LayoutParameters = raisedlayoutparam; railedpricetextview = new TextView (nn_activity); railedpricetextview.Text = "$"+peronalrise; railedpricetextview.LayoutParameters =new RelativeLayout.LayoutParams (RelativeLayout.LayoutParams.MatchParent,TapUtil.dptodx(20)); railedpricetextview.Gravity = GravityFlags.Center; TextView railedpricelabel = new TextView (nn_activity); railedpricelabel.Text = GoalScreenData.raiseToDateText; railedpricelabel.LayoutParameters=new RelativeLayout.LayoutParams (RelativeLayout.LayoutParams.MatchParent,TapUtil.dptodx(20)); railedpricelabel.Gravity = GravityFlags.Center; raisedlinearlayout.AddView (railedpricetextview); raisedlinearlayout.AddView (railedpricelabel); //goals text section LinearLayout goalslinearlayoutseprater = new LinearLayout (nn_activity); goalslinearlayoutseprater.LayoutParameters=new LinearLayout.LayoutParams (TapUtil.dptodx(1),TapUtil.dptodx(40)); goalslinearlayoutseprater.SetBackgroundColor (Color.LightGray); LinearLayout goalamoutlinearlayout = new LinearLayout (nn_activity); goalamoutlinearlayout.Orientation = Orientation.Vertical; LinearLayout.LayoutParams goalnumlayoutparam = new LinearLayout.LayoutParams (LinearLayout.LayoutParams.MatchParent,TapUtil.dptodx(40)); goalnumlayoutparam.Weight = 1; goalamoutlinearlayout.LayoutParameters = goalnumlayoutparam; goalsamounttextview = new TextView (nn_activity); goalsamounttextview.Text = "$"+goalamount; goalsamounttextview.LayoutParameters=new RelativeLayout.LayoutParams (RelativeLayout.LayoutParams.MatchParent,TapUtil.dptodx(20)); goalsamounttextview.Gravity = GravityFlags.Center; TextView goalsamountlabel = new TextView (nn_activity); goalsamountlabel.Text = GoalScreenData.goalAmountText; goalsamountlabel.LayoutParameters=new RelativeLayout.LayoutParams (RelativeLayout.LayoutParams.MatchParent,TapUtil.dptodx(20)); goalsamountlabel.Gravity = GravityFlags.Center; goalamoutlinearlayout.AddView (goalsamounttextview); goalamoutlinearlayout.AddView (goalsamountlabel); goalslinearlayout.AddView (raisedlinearlayout); goalslinearlayout.AddView (goalslinearlayoutseprater); goalslinearlayout.AddView (goalamoutlinearlayout); //circle int circlewidthdp = 200; int progresswidthdp = 20; int stokewidth = 2; decimal percent=(decimal)0; if (!string.IsNullOrEmpty (eventcard.eventinfo.gross_sales) && !string.IsNullOrEmpty (eventcard.eventinfo.seller_goal)) { if (peronalrise < 0 | goalamount < 0) { percent = 0; } else if (peronalrise >= goalamount) { percent = 1; } else if (peronalrise < goalamount) { percent = (decimal)peronalrise / goalamount; } } //rounded layout circlecontainter = new RelativeLayout (nn_activity); RelativeLayout.LayoutParams circlecontainterlayoutparam=new RelativeLayout.LayoutParams (TapUtil.dptodx(circlewidthdp),TapUtil.dptodx(circlewidthdp)); circlecontainterlayoutparam.AddRule (LayoutRules.Below, goalslinearlayout.Id); circlecontainterlayoutparam.AddRule (LayoutRules.CenterHorizontal); circlecontainterlayoutparam.TopMargin = TapUtil.dptodx (20); circlecontainter.LayoutParameters = circlecontainterlayoutparam; stokerelativelayout = new AvatarProgressRelativeLayout (nn_activity,circlewidthdp,progresswidthdp,stokewidth,Convert.ToSingle(percent)); stokerelativelayout.Invalidate (); //content inside innercircle RelativeLayout imgtextcontainter = new RelativeLayout (nn_activity); RelativeLayout.LayoutParams imgtextcontainterlayoutparam=new RelativeLayout.LayoutParams (RelativeLayout.LayoutParams.MatchParent,RelativeLayout.LayoutParams.MatchParent); imgtextcontainterlayoutparam.AddRule(LayoutRules.CenterHorizontal); imgtextcontainter.LayoutParameters = imgtextcontainterlayoutparam; imgtextcontainter.SetPadding (TapUtil.dptodx (stokerelativelayout.progresswidthdp*2), TapUtil.dptodx (stokerelativelayout.progresswidthdp*2), TapUtil.dptodx (stokerelativelayout.progresswidthdp*2), TapUtil.dptodx (stokerelativelayout.progresswidthdp*2)); avatarimagview= new ImageView (nn_activity); avatarimagview.SetImageResource (Resource.Drawable.Goals_Avatar_Person); avatarimagview.LayoutParameters = new RelativeLayout.LayoutParams (RelativeLayout.LayoutParams.MatchParent,TapUtil.dptodx(Convert.ToSingle(circlewidthdp*0.4))); avatarimagview.Id = TapUtil.generateViewId (); textview = new TextView (nn_activity); RelativeLayout.LayoutParams textlayoutparam = new RelativeLayout.LayoutParams (RelativeLayout.LayoutParams.MatchParent, TapUtil.dptodx (Convert.ToSingle(circlewidthdp * 0.1))); textlayoutparam.AddRule (LayoutRules.Below, avatarimagview.Id); textview.Gravity = GravityFlags.Center; textview.LayoutParameters = textlayoutparam; textview.Id = TapUtil.generateViewId (); textview.Text=Math.Round(percent*100)+"%"; textview.Typeface=Typeface.DefaultBold; clicktoseeprizetextview = new TextView (nn_activity); RelativeLayout.LayoutParams clicktoseeprizetextviewlayoutparam = new RelativeLayout.LayoutParams (RelativeLayout.LayoutParams.MatchParent, TapUtil.dptodx (Convert.ToSingle(circlewidthdp * 0.1))); clicktoseeprizetextviewlayoutparam.AddRule (LayoutRules.Below, textview.Id); clicktoseeprizetextview.Gravity = GravityFlags.Center; clicktoseeprizetextview.LayoutParameters = clicktoseeprizetextviewlayoutparam; clicktoseeprizetextview.Id = TapUtil.generateViewId (); clicktoseeprizetextview.Text=GoalScreenData.clickToSeeGoalPrizeLabel; clicktoseeprizetextview.Typeface=Typeface.DefaultBold; clicktoseeprizetextview.TextSize = TapUtil.dptodx (3); clicktoseeprizetextview.SetTextColor (Resources.GetColor(Resource.Color.iosblue)); clicktoseeprizetextview.Visibility = ViewStates.Gone; imgtextcontainter.AddView (avatarimagview); imgtextcontainter.AddView (textview); imgtextcontainter.AddView (clicktoseeprizetextview); circlecontainter.AddView (stokerelativelayout); circlecontainter.AddView (imgtextcontainter); circlepanelrealtivelayout.AddView (personalprogresslabel); circlepanelrealtivelayout.AddView (goalslinearlayout); circlepanelrealtivelayout.AddView (circlecontainter); prizeinfocontainer = new RelativeLayout (nn_activity); prizeinfocontainer.LayoutParameters=new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MatchParent,RelativeLayout.LayoutParams.MatchParent); prizeinfocontainer.Visibility=ViewStates.Invisible; prizeinfocontainer.Tag=0; prizetextview = new TextView (nn_activity); RelativeLayout.LayoutParams prizelayoutparam=new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MatchParent,RelativeLayout.LayoutParams.WrapContent); prizelayoutparam.AddRule (LayoutRules.CenterHorizontal); prizelayoutparam.TopMargin = TapUtil.dptodx (10); prizetextview.Gravity = GravityFlags.Center; prizetextview.LayoutParameters = prizelayoutparam; prizetextview.Text = eventcard.eventinfo.seller_prize_description; prizetextview.Id = TapUtil.generateViewId (); prizeimage=new ImageView(nn_activity); RelativeLayout.LayoutParams prizeimageparam=new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MatchParent,RelativeLayout.LayoutParams.WrapContent); prizeimageparam.AddRule (LayoutRules.Below, prizetextview.Id); prizeimageparam.TopMargin = TapUtil.dptodx (5); prizeimage.LayoutParameters = prizeimageparam; prizelayoutparam.AddRule (LayoutRules.CenterHorizontal); prizeinfocontainer.AddView (prizetextview); prizeinfocontainer.AddView (prizeimage); circlepanelrealtivelayout.AddView (prizeinfocontainer); slideritemcontainer.AddView (circlepanelrealtivelayout); ViewTreeObserver observer = circlepanelrealtivelayout.ViewTreeObserver; observer.AddOnGlobalLayoutListener (this); //add leaderboard RelativeLayout leaderboardrelativelayout = new RelativeLayout (nn_activity); leaderboardrelativelayout.SetBackgroundResource (Resource.Drawable.bg_relativelayout_grayround); leaderboardrelativelayout.Id = TapUtil.generateViewId (); RelativeLayout.LayoutParams leaderboardparam=new RelativeLayout.LayoutParams (RelativeLayout.LayoutParams.MatchParent,RelativeLayout.LayoutParams.WrapContent); leaderboardparam.TopMargin=TapUtil.dptodx(20); leaderboardparam.AddRule (LayoutRules.Below, circlepanelrealtivelayout.Id); leaderboardrelativelayout.LayoutParameters= leaderboardparam; leaderboardrelativelayout.SetPadding (TapUtil.dptodx (5), TapUtil.dptodx (5), TapUtil.dptodx (5), TapUtil.dptodx (5)); leaderboardlistview = new ListView (nn_activity); leaderboardlistview.LayoutParameters=new RelativeLayout.LayoutParams (RelativeLayout.LayoutParams.MatchParent,0); leaderboardlistview.Adapter = leaderboardadapter; leaderboardrelativelayout.AddView (leaderboardlistview); setListViewHeightBasedOnItems (leaderboardlistview); slideritemcontainer.AddView (leaderboardrelativelayout); goalscontainer.AddView (slideritemcontainer); // if have prize tos show if (!string.IsNullOrEmpty (eventcard.eventinfo.seller_prize_image_id) && !eventcard.eventinfo.seller_prize_image_id.Equals ("0")) { clicktoseeprizetextview.Visibility = ViewStates.Visible; int defaultimageresourceid = TapUtil.getdefaultprizeresourceid (Int32.Parse (eventcard.eventinfo.seller_prize_image_id)); try { Bitmap imageBitmap = BitmapFactory.DecodeResource (Resources, defaultimageresourceid); Bitmap newbitmap = Bitmap.CreateScaledBitmap (imageBitmap, TapUtil.dptodx (200), TapUtil.dptodx (200), false); if (newbitmap != null) { prizebitmap = newbitmap; } } catch (Exception e) { Console.WriteLine (e); } prizeimage.SetImageBitmap (prizebitmap); prizeimage.SetScaleType (ImageView.ScaleType.CenterInside); prizeinfocontainer.SetBackgroundColor (Color.White); //prizeinfocontainer.LayoutParameters=new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MatchParent,RelativeLayout.LayoutParams.MatchParent); prizeinfocontainer.Visibility = ViewStates.Invisible; circlecontainter.Click -= OnCircleContainerClick; circlecontainter.Click += OnCircleContainerClick; } return view; }
private void CreateMessagesUI() { List<UserDB> participants = new List<UserDB> (); bool moreThanOne = false, isCurrentMe = false; if (MessageConversations.clearView) { listWrapper.RemoveAllViews (); MessageConversations.clearView = false; } if (Contacts.SelectContactsUtil.selectedContacts.Count != 0) Contacts.SelectContactsUtil.selectedContacts.Clear (); if (MessageConversations.currentConversationMessages [0].MessageRecipientDBList.Count > 1) { moreThanOne = true; for (int m = 0; m < MessageConversations.currentConversationMessages[0].MessageRecipientDBList.Count; ++m) { if (MessageConversations.currentConversationMessages [0].MessageRecipientDBList [m].AccountGuid != AndroidData.CurrentUser.AccountID.ToString ()) { UserDB userDetails = dbm.GetUserWithAccountID (MessageConversations.currentConversationMessages [0].MessageRecipientDBList [m].AccountGuid); participants.Add (userDetails); ContactDB contact = new ContactDB (); contact.ContactUser = new LOLAccountManagement.User (); contact.ContactUser.AccountID = userDetails.AccountID; Contacts.SelectContactsUtil.selectedContacts.Add (contact); } else { UserDB userDetails = UserDB.ConvertFromUser (AndroidData.CurrentUser); participants.Add (userDetails); } } } else { UserDB userDetails = dbm.GetUserWithAccountID (MessageConversations.currentConversationMessages [0].MessageRecipientDBList [0].AccountGuid); ContactDB contact = new ContactDB (); contact.ContactUser = new LOLAccountManagement.User (); contact.ContactUser.AccountID = userDetails.AccountID; Contacts.SelectContactsUtil.selectedContacts.Add (contact); } if (moreThanOne) { string toReturn = ""; List<UserDB> sortedList = new List<UserDB> (); sortedList = participants.OrderBy (s => s.LastName).OrderBy (s => s.FirstName).ToList (); foreach (UserDB eachItem in sortedList) toReturn += string.Format ("{0} {1}, ", eachItem.FirstName, eachItem.LastName); int last = toReturn.LastIndexOf (", "); toReturn = toReturn.Remove (last); using (LinearLayout btnlayout = new LinearLayout (context)) { btnlayout.Orientation = Android.Widget.Orientation.Vertical; btnlayout.SetGravity (GravityFlags.Center); btnlayout.LayoutParameters = new ViewGroup.LayoutParams (LinearLayout.LayoutParams.FillParent, LinearLayout.LayoutParams.WrapContent); btnlayout.SetPadding ((int)ImageHelper.convertDpToPixel (5f, context), 0, (int)ImageHelper.convertDpToPixel (5f, context), (int)ImageHelper.convertDpToPixel (10f, context)); using (TextView name = new TextView(context)) { name.Text = toReturn; name.SetTextSize (Android.Util.ComplexUnitType.Dip, 18f); name.SetTextColor (Color.Black); RunOnUiThread (() => btnlayout.AddView (name)); } using (Button showAll = new Button (context)) { showAll.Gravity = GravityFlags.CenterVertical; showAll.Text = Application.Context.Resources.GetString (Resource.String.messageShowAllInConversation); showAll.Click += (object sender, EventArgs e) => { showParticipants (sender, e, participants); }; showAll.SetWidth ((int)ImageHelper.convertDpToPixel (180f, context)); showAll.SetHeight ((int)ImageHelper.convertDpToPixel (30f, context)); showAll.SetBackgroundResource (Resource.Drawable.button); RunOnUiThread (() => btnlayout.AddView (showAll)); } RunOnUiThread (() => listWrapper.AddView (btnlayout)); } } foreach (MessageDB message in MessageConversations.currentConversationMessages) { isCurrentMe = message.FromAccountID != AndroidData.CurrentUser.AccountID ? false : true; LinearLayout shell = new LinearLayout (context); shell.LayoutParameters = new ViewGroup.LayoutParams (LinearLayout.LayoutParams.FillParent, (int)ImageHelper.convertDpToPixel (imageSize [0] + 50f, context)); shell.Orientation = Orientation.Horizontal; shell.SetPadding (0, 0, 0, (int)ImageHelper.convertDpToPixel (5f, context)); UserDB whoAmI = new UserDB (); whoAmI = message.FromAccountID != AndroidData.CurrentUser.AccountID ? dbm.GetUserWithAccountID (message.FromAccountGuid) : UserDB.ConvertFromUser (AndroidData.CurrentUser); LinearLayout imageViewLayout = new LinearLayout (context); imageViewLayout.LayoutParameters = new ViewGroup.LayoutParams (LinearLayout.LayoutParams.WrapContent, LinearLayout.LayoutParams.WrapContent); imageViewLayout.SetGravity (GravityFlags.CenterVertical); ImageView userImage = new ImageView (context); if (Contacts.ContactsUtil.contactFilenames.Contains (message.FromAccountGuid)) { using (Bitmap bm = BitmapFactory.DecodeFile (System.IO.Path.Combine (wowZapp.LaffOutOut.Singleton.ImageDirectory, message.FromAccountGuid))) { using (MemoryStream ms = new MemoryStream ()) { bm.Compress (Bitmap.CompressFormat.Jpeg, 80, ms); byte[] image = ms.ToArray (); using (Bitmap myBitmap = ImageHelper.CreateUserProfileImageForDisplay(image, (int)imageSize[0], (int)imageSize[1], this.Resources)) { RunOnUiThread (delegate { userImage.SetImageBitmap (myBitmap); }); } } } } else { userImage.LayoutParameters = new ViewGroup.LayoutParams ((int)ImageHelper.convertDpToPixel (imageSize [0], context), (int)ImageHelper.convertDpToPixel (imageSize [1], context)); userImage.SetScaleType (ImageView.ScaleType.FitXy); userImage.SetImageResource (Resource.Drawable.defaultuserimage); } RunOnUiThread (() => imageViewLayout.AddView (userImage)); LinearLayout messageShell = new LinearLayout (context); int left = (int)wowZapp.LaffOutOut.Singleton.ScreenXWidth - (int)ImageHelper.convertDpToPixel (imageSize [0] + 20f, context); int leftOver = (int)wowZapp.LaffOutOut.Singleton.ScreenXWidth - (int)ImageHelper.convertDpToPixel (imageSize [0] + 40f, context); messageShell.LayoutParameters = new ViewGroup.LayoutParams (!isCurrentMe ? LinearLayout.LayoutParams.FillParent : left, LinearLayout.LayoutParams.FillParent); messageShell.Orientation = Orientation.Vertical; LinearLayout from = new LinearLayout (context); using (LinearLayout.LayoutParams layParms = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FillParent, (int)ImageHelper.convertDpToPixel(24f, context))) { layParms.SetMargins (isCurrentMe ? 0 : (int)ImageHelper.convertDpToPixel (30f, context), 0, isCurrentMe ? (int)ImageHelper.convertDpToPixel (30f, context) : 0, 0); layParms.Weight = 10f; from.LayoutParameters = layParms; } TextView whoIsIt = new TextView (context); whoIsIt.SetTextColor (Color.Black); whoIsIt.SetTextSize (Android.Util.ComplexUnitType.Dip, 12f); whoIsIt.Gravity = !isCurrentMe ? GravityFlags.Left : GravityFlags.Right; whoIsIt.Text = whoAmI.FirstName + " " + whoAmI.LastName; RunOnUiThread (() => from.AddView (whoIsIt)); LinearLayout messageBox = new LinearLayout (context); using (LinearLayout.LayoutParams linParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FillParent, LinearLayout.LayoutParams.FillParent)) { messageBox.LayoutParameters = linParams; linParams.Weight = 60f; } for (int m = 0; m < message.MessageStepDBList.Count; ++m) { if (message.MessageStepDBList [m].StepType == LOLMessageDelivery.MessageStep.StepTypes.Text) { TextView messageText = new TextView (context); using (LinearLayout.LayoutParams layParam = new LinearLayout.LayoutParams (LinearLayout.LayoutParams.FillParent, LinearLayout.LayoutParams.FillParent)) { messageText.LayoutParameters = layParam; } messageText.SetBackgroundResource (message.FromAccountID != AndroidData.CurrentUser.AccountID ? Resource.Drawable.bubblesolidleft : Resource.Drawable.bubblesolidright); int lr = (int)ImageHelper.convertDpToPixel (20f, context); int tb = lr / 2; messageText.SetPadding (lr, tb, lr, tb); messageText.SetTextColor (Color.White); messageText.SetTextSize (Android.Util.ComplexUnitType.Dip, 14f); string messager = message.MessageStepDBList [m].MessageText; if (messager.Length > 40) messager = messager.Substring (0, 40) + "..."; messageText.Text = messager; messageText.ContentDescription = message.MessageGuid; RunOnUiThread (() => messageBox.AddView (messageText)); break; } } LinearLayout messageLay = new LinearLayout (context); using (LinearLayout.LayoutParams messParam = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FillParent, (int)ImageHelper.convertDpToPixel(24f, context))) { messParam.SetMargins (isCurrentMe ? 0 : (int)ImageHelper.convertDpToPixel (30f, context), 0, isCurrentMe ? (int)ImageHelper.convertDpToPixel (30f, context) : 0, 0); messParam.Weight = 10f; messageLay.LayoutParameters = messParam; } TextView messageDate = new TextView (context); messageDate.LayoutParameters = new ViewGroup.LayoutParams (LinearLayout.LayoutParams.FillParent, LinearLayout.LayoutParams.WrapContent); messageDate.SetTextColor (Color.Black); messageDate.SetTextSize (Android.Util.ComplexUnitType.Dip, 10f); messageDate.Gravity = message.FromAccountID != AndroidData.CurrentUser.AccountID ? GravityFlags.Left : GravityFlags.Right; messageDate.Text = message.MessageSent.ToShortTimeString () + ", " + message.MessageSent.ToShortDateString (); RunOnUiThread (() => messageLay.AddView (messageDate)); LinearLayout messageItems = new LinearLayout (context); messageItems.Orientation = Orientation.Horizontal; float messageBarSize = wowZapp.LaffOutOut.Singleton.resizeFonts == true ? ImageHelper.convertPixelToDp (((50f * imageSize [0]) / 100), context) : ImageHelper.convertDpToPixel (40f, context); using (LinearLayout.LayoutParams layParams = new LinearLayout.LayoutParams (LinearLayout.LayoutParams.FillParent, (int)messageBarSize)) { layParams.SetMargins ((int)ImageHelper.convertDpToPixel (14f, context), (int)ImageHelper.convertDpToPixel (3.3f, context), (int)ImageHelper.convertDpToPixel (12.7f, context), (int)ImageHelper.convertDpToPixel (4f, context)); messageItems.LayoutParameters = layParams; } messageItems.SetPadding ((int)ImageHelper.convertDpToPixel (10f, context), (int)ImageHelper.convertDpToPixel (3.3f, context), (int)ImageHelper.convertDpToPixel (10f, context), 0); messageItems.SetGravity (GravityFlags.Left); messageItems = createMessageBar (messageItems, message, leftOver); RunOnUiThread (delegate { messageShell.AddView (from); messageShell.AddView (messageBox); messageShell.AddView (messageLay); messageShell.AddView (messageItems); if (whoAmI.AccountID == AndroidData.CurrentUser.AccountID) { shell.AddView (messageShell); shell.AddView (imageViewLayout); } else { shell.AddView (imageViewLayout); shell.AddView (messageShell); } listWrapper.AddView (shell); }); } if (progress != null) RunOnUiThread (() => progress.Dismiss ()); }
private TextView CreateDefaultTabView(Android.Content.Context context) { TextView textView = new TextView(context); textView.LayoutParameters = new LinearLayout.LayoutParams (0, ViewGroup.LayoutParams.WrapContent, 1f); textView.Gravity = GravityFlags.Center; textView.SetTextSize(ComplexUnitType.Sp, TAB_VIEW_TEXT_SIZE_SP); textView.Typeface = Android.Graphics.Typeface.DefaultBold; if (Build.VERSION.SdkInt >= Android.OS.BuildVersionCodes.Honeycomb) { TypedValue outValue = new TypedValue(); Context.Theme.ResolveAttribute(Android.Resource.Attribute.SelectableItemBackground, outValue, false); textView.SetBackgroundResource(outValue.ResourceId); } if (Build.VERSION.SdkInt >= Android.OS.BuildVersionCodes.IceCreamSandwich) { textView.SetAllCaps(true); } int padding = (int)(TAB_VIEW_PADDING_DIPS * Resources.DisplayMetrics.Density); textView.SetPadding(padding, padding, padding, padding); return textView; }
private LinearLayout contactUserInterface(MessageDB message, UserDB contact, bool direction) { LinearLayout layout = new LinearLayout (context); layout.Orientation = Android.Widget.Orientation.Horizontal; layout.SetGravity (GravityFlags.CenterVertical); string messager = ""; layout.SetPadding ((int)ImageHelper.convertDpToPixel (5f, context), 0, (int)ImageHelper.convertDpToPixel (5f, context), (int)ImageHelper.convertDpToPixel (10f, context)); ImageView profilepic = new ImageView (context); if (!direction) { profilepic.LayoutParameters = new ViewGroup.LayoutParams ((int)ImageHelper.convertDpToPixel (55f, context), (int)ImageHelper.convertDpToPixel (100f, context)); if (contact == null) profilepic.SetImageDrawable (Application.Context.Resources.GetDrawable (Resource.Drawable.defaultuserimage)); else { profilepic.Tag = new Java.Lang.String ("profilepic_" + contact.AccountID); profilepic.SetImageResource (Resource.Drawable.defaultuserimage); layout.AddView (profilepic); if (contact.Picture.Length == 0 && contact.HasProfileImage) getGuid.Add (contact.AccountID); else { if (contact.Picture.Length > 0) LoadUserImage (contact, profilepic); else profilepic.SetImageDrawable (Application.Context.Resources.GetDrawable (Resource.Drawable.defaultuserimage)); } LinearLayout layout2 = new LinearLayout (context); layout2.Orientation = Orientation.Vertical; layout2.SetGravity (GravityFlags.Center); if (message.MessageStepDBList.Count == 1 && message.MessageStepDBList [0].StepType == MessageStep.StepTypes.Text) { TextView text = new TextView (context); text.LayoutParameters = new ViewGroup.LayoutParams ((int)ImageHelper.convertDpToPixel (220f, context), (int)ImageHelper.convertDpToPixel (60f, context)); text.SetPadding ((int)ImageHelper.convertDpToPixel (20f, context), 0, (int)ImageHelper.convertDpToPixel (10f, context), 0); text.Gravity = GravityFlags.CenterVertical; text.SetBackgroundResource (Resource.Drawable.bubblesolidright); text.TextSize = 16f; for (int e = 0; e < message.MessageStepDBList.Count; ++e) { if (!string.IsNullOrEmpty (message.MessageStepDBList [e].MessageText)) { messager = message.MessageStepDBList [e].MessageText; break; } } if (string.IsNullOrEmpty (messager)) messager = "No text message found"; int nolines = (int)(ImageHelper.convertDpToPixel ((messager.Length / 27f) * 12f, context)); text.SetHeight (nolines); text.SetTextColor (Android.Graphics.Color.Black); text.Text = messager; layout2.Clickable = true; layout2.AddView (text); } layout.AddView (layout2); } } else { LinearLayout layout2 = new LinearLayout (context); layout2.Orientation = Orientation.Vertical; layout2.SetGravity (GravityFlags.Center); if (message.MessageStepDBList.Count == 1 && message.MessageStepDBList [0].StepType == MessageStep.StepTypes.Text) { TextView text = new TextView (context); text.LayoutParameters = new ViewGroup.LayoutParams ((int)ImageHelper.convertDpToPixel (220f, context), (int)ImageHelper.convertDpToPixel (60f, context)); text.SetPadding ((int)ImageHelper.convertDpToPixel (20f, context), 0, (int)ImageHelper.convertDpToPixel (10f, context), 0); text.Gravity = GravityFlags.CenterVertical; text.SetBackgroundResource (Resource.Drawable.bubblesolidleft); text.TextSize = 16f; for (int e = 0; e < message.MessageStepDBList.Count; ++e) { if (!string.IsNullOrEmpty (message.MessageStepDBList [e].MessageText)) { messager = message.MessageStepDBList [e].MessageText; break; } } if (string.IsNullOrEmpty (messager)) messager = "No text message found"; int nolines = (int)(ImageHelper.convertDpToPixel ((messager.Length / 27f) * 12f, context)); text.SetHeight (nolines); text.SetTextColor (Android.Graphics.Color.Black); text.Text = messager; layout2.Clickable = true; layout2.AddView (text); } profilepic.LayoutParameters = new ViewGroup.LayoutParams ((int)ImageHelper.convertDpToPixel (55f, context), (int)ImageHelper.convertDpToPixel (100f, context)); layout.AddView (layout2); if (contact == null) profilepic.SetImageDrawable (Application.Context.Resources.GetDrawable (Resource.Drawable.defaultuserimage)); else { profilepic.Tag = new Java.Lang.String ("profilepic_" + contact.AccountID); profilepic.SetImageResource (Resource.Drawable.defaultuserimage); layout.AddView (profilepic); if (contact.Picture.Length == 0 && contact.HasProfileImage) getGuid.Add (contact.AccountID); else { if (contact.Picture.Length > 0) LoadUserImage (contact, profilepic); else profilepic.SetImageDrawable (Application.Context.Resources.GetDrawable (Resource.Drawable.defaultuserimage)); } } } return layout; }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.Details); // Create your application here try { _mMapView = FindViewById<MapView>(Resource.Id.bmapView); var txtHotelName = FindViewById<TextView>(Resource.Id.txtHotelName); var txtHotelCoordinate = FindViewById<TextView>(Resource.Id.txtHotelCoordinate); _btnReserve = FindViewById<Button>(Resource.Id.btnReserve); #region 数据初始化 //var hotelEntity =(HotelEntity) Intent.GetSerializableExtra("HOTELENTITY"); var name = Intent.GetStringExtra("Name"); var latitude = Intent.GetDoubleExtra("Latitude", 0.00); var longitude = Intent.GetDoubleExtra("Longitude", 0.00); _hotelEntity = new HotelEntity() { Name = name, Latitude = latitude, Longitude = longitude }; txtHotelName.Text = _hotelEntity.Name; txtHotelCoordinate.Text = string.Format("({0}, {1})", _hotelEntity.Longitude.ToString("0.0000"), _hotelEntity.Latitude.ToString("0.0000")); #endregion 数据初始化 _mBaiduMap = _mMapView.Map; #region 标记酒店位置 InitOverlay(); #endregion 标记酒店位置 #region 添加事件 // _mBaiduMap.SetOnMarkerClickListener(new OnMarkerClickListener(this)); _mBaiduMap.MarkerClick += (sender, args) => { var marker = args.P0; try { HotelEntity entity = marker.ExtraInfo.GetSerializable("info") as HotelEntity; TextView location = new TextView(ApplicationContext); location.SetBackgroundResource(Resource.Drawable.infowindow_bg); location.SetPadding(30, 20, 30, 50); if (entity != null) location.Text = entity.Name; var latlng = marker.Position; var point = _mBaiduMap.Projection.ToScreenLocation(latlng); Log.Info(Tag, "--!" + point.X + " , " + point.Y); point.Y -= 47; var pointInfo = _mBaiduMap.Projection.FromScreenLocation(point); var window = new InfoWindow(location, pointInfo, 0); _mBaiduMap.ShowInfoWindow(window); } catch (Exception ex) { Log.Error(Tag, "MarkerClick Excetipn :" + ex.Message); } }; //_mBaiduMap.SetOnMapClickListener(new OnMapClickListener(this)); _mBaiduMap.MapClick += (sender, args) => { _mBaiduMap.HideInfoWindow(); }; _btnReserve.Click += (sender, args) => { StartActivity(new Intent(this, typeof(PayLayout))); }; #endregion } catch (Exception ex) { Log.Error(Tag, ex.StackTrace); } }
/** * 节点浏览示例 * @param v */ public void NodeClick(View v) { viewCache = LayoutInflater.Inflate(Resource.Layout.custom_text_view, null); popupText = viewCache.FindViewById<TextView>(Resource.Id.textcache); if (searchType == 0 || searchType == 2) { //驾车、步行使用的数据结构相同,因此类型为驾车或步行,节点浏览方法相同 if (nodeIndex < -1 || route == null || nodeIndex >= route.NumSteps) return; //上一个节点 if (mBtnPre.Equals(v) && nodeIndex > 0) { //索引减 nodeIndex--; //移动到指定索引的坐标 mMapView.Controller.AnimateTo(route.GetStep(nodeIndex).Point); //弹出泡泡 popupText.SetBackgroundResource(Resource.Drawable.popup); popupText.Text = route.GetStep(nodeIndex).Content; pop.ShowPopup(BMapUtil.GetBitmapFromView(popupText), route.GetStep(nodeIndex).Point, 5); } //下一个节点 if (mBtnNext.Equals(v) && nodeIndex < (route.NumSteps - 1)) { //索引加 nodeIndex++; //移动到指定索引的坐标 mMapView.Controller.AnimateTo(route.GetStep(nodeIndex).Point); //弹出泡泡 popupText.SetBackgroundResource(Resource.Drawable.popup); popupText.Text = route.GetStep(nodeIndex).Content; pop.ShowPopup(BMapUtil.GetBitmapFromView(popupText), route.GetStep(nodeIndex).Point, 5); } } if (searchType == 1) { //公交换乘使用的数据结构与其他不同,因此单独处理节点浏览 if (nodeIndex < -1 || transitOverlay == null || nodeIndex >= transitOverlay.AllItem.Count) return; //上一个节点 if (mBtnPre.Equals(v) && nodeIndex > 1) { //索引减 nodeIndex--; //移动到指定索引的坐标 mMapView.Controller.AnimateTo(transitOverlay.GetItem(nodeIndex).Point); //弹出泡泡 popupText.SetBackgroundResource(Resource.Drawable.popup); popupText.Text = transitOverlay.GetItem(nodeIndex).Title; pop.ShowPopup(BMapUtil.GetBitmapFromView(popupText), transitOverlay.GetItem(nodeIndex).Point, 5); } //下一个节点 if (mBtnNext.Equals(v) && nodeIndex < (transitOverlay.AllItem.Count - 2)) { //索引加 nodeIndex++; //移动到指定索引的坐标 mMapView.Controller.AnimateTo(transitOverlay.GetItem(nodeIndex).Point); //弹出泡泡 popupText.SetBackgroundResource(Resource.Drawable.popup); popupText.Text = transitOverlay.GetItem(nodeIndex).Title; pop.ShowPopup(BMapUtil.GetBitmapFromView(popupText), transitOverlay.GetItem(nodeIndex).Point, 5); } } }
private TextView CreateDefaultTabView(Context context) { var textView = new TextView(context); textView.Gravity = GravityFlags.Center; textView.SetTextSize(ComplexUnitType.Sp, TabViewTextSizeSp); textView.Typeface = Typeface.DefaultBold; if (Build.VERSION.SdkInt >= BuildVersionCodes.Honeycomb) { var outValue = new TypedValue(); Context.Theme.ResolveAttribute(Resource.Attribute.SelectableItemBackground, outValue, false); textView.SetBackgroundResource(outValue.ResourceId); } if (Build.VERSION.SdkInt >= BuildVersionCodes.IceCreamSandwich) { textView.SetAllCaps(true); } var padding = (int) (TabViewPaddingDips*Resources.DisplayMetrics.Density); textView.SetPadding(padding, padding, padding, padding); return textView; }
/** * 节点浏览示例 * @param v */ public void NodeClick(View v) { if (nodeIndex < -1 || route == null || nodeIndex >= route.NumSteps) return; viewCache = LayoutInflater.Inflate(Resource.Layout.custom_text_view, null); popupText = viewCache.FindViewById<TextView>(Resource.Id.textcache); //上一个节点 if (mBtnPre.Equals(v) && nodeIndex > 0) { //索引减 nodeIndex--; //移动到指定索引的坐标 mMapView.Controller.AnimateTo(route.GetStep(nodeIndex).Point); //弹出泡泡 popupText.Text = route.GetStep(nodeIndex).Content; popupText.SetBackgroundResource(Resource.Drawable.popup); pop.ShowPopup(BMapUtil.GetBitmapFromView(popupText), route.GetStep(nodeIndex).Point, 5); } //下一个节点 if (mBtnNext.Equals(v) && nodeIndex < (route.NumSteps - 1)) { //索引加 nodeIndex++; //移动到指定索引的坐标 mMapView.Controller.AnimateTo(route.GetStep(nodeIndex).Point); //弹出泡泡 popupText.Text = route.GetStep(nodeIndex).Content; popupText.SetBackgroundDrawable(Resources.GetDrawable(Resource.Drawable.popup)); pop.ShowPopup(BMapUtil.GetBitmapFromView(popupText), route.GetStep(nodeIndex).Point, 5); } }
private void SetTimeRemaining(NotificationFeedFragment master, int containerId, Notification notification, TextView timeRemainingTextView, ImageView clockImageView) { if ( notification.type == Strings.notification_type_post_expired || notification.type == Strings.notification_type_following || notification.type == Strings.notification_type_follow || notification.type == Strings.notification_type_friend_request) { clockImageView.Visibility = ViewStates.Invisible; timeRemainingTextView.Visibility = ViewStates.Invisible; } else { clockImageView.Visibility = ViewStates.Visible; timeRemainingTextView.Visibility = ViewStates.Visible; if (notification.post != null) { if (notification.post.IsExpired()) { string timeRemaining = StringUtils.GetTopTime(notification.post); timeRemainingTextView.Text = timeRemaining; timeRemainingTextView.SetTextColor(Color.White); timeRemainingTextView.SetBackgroundResource(Resource.Drawable.RoundedCorners5Black); clockImageView.Visibility = ViewStates.Invisible; } else { string timeRemaining = StringUtils.GetPrettyDateAbs(notification.post.expiration); timeRemainingTextView.Text = timeRemaining; Color timeRemainingColor = ViewUtils.GetTimeRemainingColor(notification.post.expiration); timeRemainingTextView.SetTextColor(timeRemainingColor); timeRemainingTextView.SetBackgroundColor(Color.Transparent); clockImageView.Visibility = ViewStates.Visible; } } if (!clockImageView.HasOnClickListeners) { clockImageView.Click += (sender, e) => { TenServiceHelper.GoToListOf(master.FragmentManager, containerId, notification.post.idPost, FeedTypeEnum.FeedType.LikersListOfFeed); }; } if (!timeRemainingTextView.HasOnClickListeners) { timeRemainingTextView.Click += (sender, e) => { TenServiceHelper.GoToListOf(master.FragmentManager, containerId, notification.post.idPost, FeedTypeEnum.FeedType.LikersListOfFeed); }; } } }
protected TextView CreateDefaultTabView(Context context) { TextView textView = new TextView(context); textView.Gravity = GravityFlags.Center; textView.SetTextSize(ComplexUnitType.Sp, TAB_VIEW_TEXT_SIZE_SP); textView.Typeface = Typeface.DefaultBold; if (Build.VERSION.SdkInt >= Build.VERSION_CODES.Honeycomb) { TypedValue outValue = new TypedValue(); Context.Theme.ResolveAttribute(Android.Resource.Attribute.SelectableItemBackground, outValue, true); textView.SetBackgroundResource(outValue.ResourceId); } if (Build.VERSION.SdkInt >= Build.VERSION_CODES.IceCreamSandwich) { textView.SetAllCaps(true); } int padding = (int)(TAB_VIEW_PADDING_DIPS * Resources.DisplayMetrics.Density); textView.SetPadding(padding, padding, padding, padding); return textView; }
private void generateMessageBarAndAnimate(string message, MessageDB msgList, UserDB contact, bool shutUp = false) { //RunOnUiThread (delegate { bool rpong = false; if (shutUp != true) { AudioPlayer ap = new AudioPlayer (context); Android.Content.Res.AssetManager am = this.Assets; ap.playFromAssets (am, "incoming.mp3"); } Guid grabGuid = Guid.Empty; RunOnUiThread (() => messageBar.SetPadding ((int)ImageHelper.convertDpToPixel (5f, context), 0, (int)ImageHelper.convertDpToPixel (5f, context), (int)ImageHelper.convertDpToPixel (10f, context))); int leftOver = Convert.ToInt32 (wowZapp.LaffOutOut.Singleton.ScreenXWidth - (picSize + 40)); LinearLayout.LayoutParams layParams; if (contact == null) throw new Exception ("Contact is null in generateMessageBarAndAnimate"); ImageView profilePic = new ImageView (context); using (layParams = new LinearLayout.LayoutParams (picSize, picSize)) { layParams.SetMargins ((int)ImageHelper.convertDpToPixel (15f, context), (int)ImageHelper.convertDpToPixel (20f, context), 0, 0); profilePic.LayoutParameters = layParams; } profilePic.SetBackgroundResource (Resource.Drawable.defaultuserimage); profilePic.Tag = new Java.Lang.String ("profilepic_" + contact.AccountID); RunOnUiThread (() => messageBar.AddView (profilePic)); if (Contacts.ContactsUtil.contactFilenames.Contains (contact.AccountGuid)) { rpong = true; using (Bitmap bm = BitmapFactory.DecodeFile (System.IO.Path.Combine (wowZapp.LaffOutOut.Singleton.ImageDirectory, contact.AccountGuid))) { using (MemoryStream ms = new MemoryStream ()) { bm.Compress (Bitmap.CompressFormat.Jpeg, 80, ms); byte[] image = ms.ToArray (); displayImage (image, profilePic); } } } else { if (contact.Picture.Length == 0) grabGuid = contact.AccountID; else { if (contact.Picture.Length > 0) loadProfilePicture (contact, profilePic); } } LinearLayout fromTVH = new LinearLayout (context); fromTVH.Orientation = Orientation.Vertical; fromTVH.LayoutParameters = new ViewGroup.LayoutParams (LinearLayout.LayoutParams.FillParent, LinearLayout.LayoutParams.FillParent); float textNameSize = wowZapp.LaffOutOut.Singleton.resizeFonts == true ? (int)ImageHelper.convertPixelToDp (((25 * picSize) / 100), context) : 16f; TextView textFrom = new TextView (context); using (layParams = new LinearLayout.LayoutParams (leftOver, (int)textNameSize)) { layParams.SetMargins ((int)ImageHelper.convertDpToPixel (9.3f, context), (int)ImageHelper.convertPixelToDp (textNameSize - 1, context), 0, 0); textFrom.LayoutParameters = layParams; } float fontSize = wowZapp.LaffOutOut.Singleton.resizeFonts == true ? ImageHelper.convertPixelToDp (((12 * picSize) / 100), context) : ImageHelper.convertPixelToDp (14f, context); textFrom.SetTextSize (Android.Util.ComplexUnitType.Dip, fontSize); textFrom.SetTextColor (Color.Black); if (contact != null) textFrom.Text = contact.FirstName + " " + contact.LastName; else textFrom.Text = "Ann Onymouse"; RunOnUiThread (() => fromTVH.AddView (textFrom)); float textMessageSize = wowZapp.LaffOutOut.Singleton.resizeFonts == true ? ImageHelper.convertPixelToDp (((70 * picSize) / 100), context) : ImageHelper.convertDpToPixel (39f, context); TextView textMessage = new TextView (context); using (layParams = new LinearLayout.LayoutParams (leftOver, (int)textMessageSize)) { layParams.SetMargins ((int)ImageHelper.convertDpToPixel (10f, context), 0, (int)ImageHelper.convertDpToPixel (10, context), 0); textMessage.LayoutParameters = layParams; } float fontSize2 = wowZapp.LaffOutOut.Singleton.resizeFonts == true ? ImageHelper.convertPixelToDp (((12 * picSize) / 100), context) : ImageHelper.convertPixelToDp (16f, context); textMessage.SetTextSize (Android.Util.ComplexUnitType.Dip, fontSize2); textMessage.SetTextColor (Color.White); textMessage.SetPadding ((int)ImageHelper.convertDpToPixel (20f, context), 0, (int)ImageHelper.convertDpToPixel (10f, context), 0); if (!string.IsNullOrEmpty (message)) textMessage.SetBackgroundResource (Resource.Drawable.bubblesolidleft); textMessage.Text = message != string.Empty ? message : ""; textMessage.ContentDescription = msgList.MessageGuid; textMessage.Click += new EventHandler (textMessage_Click); RunOnUiThread (() => fromTVH.AddView (textMessage)); //} if (msgList != null) { LinearLayout messageItems = new LinearLayout (context); messageItems.Orientation = Orientation.Horizontal; float messageBarSize = wowZapp.LaffOutOut.Singleton.resizeFonts == true ? ImageHelper.convertPixelToDp (((35 * picSize) / 100), context) : ImageHelper.convertDpToPixel (40f, context); using (layParams = new LinearLayout.LayoutParams (leftOver, (int)messageBarSize)) { layParams.SetMargins ((int)ImageHelper.convertDpToPixel (14f, context), (int)ImageHelper.convertDpToPixel (3.3f, context), (int)ImageHelper.convertDpToPixel (12.7f, context), (int)ImageHelper.convertDpToPixel (4f, context)); messageItems.LayoutParameters = layParams; } messageItems.SetPadding ((int)ImageHelper.convertDpToPixel (10f, context), (int)ImageHelper.convertDpToPixel (3.3f, context), (int)ImageHelper.convertDpToPixel (10f, context), 0); messageItems.SetGravity (GravityFlags.Left); messageItems = createMessageBar (messageItems, msgList, leftOver); RunOnUiThread (() => fromTVH.AddView (messageItems)); } RunOnUiThread (() => messageBar.AddView (fromTVH)); RunOnUiThread (delegate { hsv.RemoveAllViews (); hsv.AddView (messageBar); }); if (grabGuid != null) { LOLConnectClient service = new LOLConnectClient (LOLConstants.DefaultHttpBinding, LOLConstants.LOLConnectEndpoint); service.UserGetImageDataCompleted += Service_UserGetImageDataCompleted; service.UserGetImageDataAsync (AndroidData.CurrentUser.AccountID, grabGuid, new Guid (AndroidData.ServiceAuthToken)); } //}); RunOnUiThread (delegate { Handler handler = new Handler (); handler.PostDelayed (new Action (() => { hsv.SmoothScrollTo (newX, 0); }), 2000); }); }
private void CreatePreviewUI() { int m = 0; isConversation = false; header = FindViewById<TextView> (Resource.Id.txtFirstScreenHeader); Header.headertext = Application.Context.Resources.GetString (Resource.String.messageListHeaderViewTitle); Header.fontsize = 36f; ImageHelper.fontSizeInfo (header.Context); header.SetTextSize (Android.Util.ComplexUnitType.Dip, Header.fontsize); header.Text = Header.headertext; listWrapper.RemoveAllViewsInLayout (); Dictionary<string, MessageInfo> latestMessages = new Dictionary<string, MessageInfo> (); Dictionary<string, string> unreadMessageCounts = new Dictionary<string, string> (); string ownerAccountId = AndroidData.CurrentUser.AccountID.ToString (); foreach (ConversationInfo eachConversationInfo in this.conversationItems.Values) { MessageInfo latestMessage = eachConversationInfo.GetLatestMessage (); string messageCountStr = eachConversationInfo.Messages .Count (s => s.Value.Message.MessageRecipientDBList.Count (t => t.AccountGuid == ownerAccountId && !t.IsRead) > 0) .ToString (); latestMessages.Add (eachConversationInfo.ConversationID, latestMessage); unreadMessageCounts.Add (eachConversationInfo.ConversationID, messageCountStr); } if (getGuid != null) getGuid.Clear (); RunOnUiThread (delegate { foreach (KeyValuePair<string, MessageInfo> eachMessage in latestMessages) { eachMessage.Value.Message.MessageRecipientDBList = eachMessage.Value.Message.MessageRecipientDBList.Where (x => x != null).ToList (); string messager = string.Empty; string tmpName = string.Empty; ImageView random = null; LinearLayout.LayoutParams randomParams = null; LinearLayout layout = new LinearLayout (context); LinearLayout.LayoutParams layoutparams = new LinearLayout.LayoutParams (LinearLayout.LayoutParams.FillParent, LinearLayout.LayoutParams.WrapContent); layoutparams.SetMargins (0, 0, 0, (int)ImageHelper.convertDpToPixel (10f, context)); layout.LayoutParameters = layoutparams; layout.Orientation = Android.Widget.Orientation.Horizontal; layout.SetGravity (GravityFlags.Center); layout.SetPadding ((int)ImageHelper.convertDpToPixel (5f, context), 0, (int)ImageHelper.convertDpToPixel (10f, context), (int)ImageHelper.convertDpToPixel (10f, context)); ImageView profilepic = new ImageView (context); profilepic.LayoutParameters = new ViewGroup.LayoutParams ((int)ImageHelper.convertDpToPixel (55f, context), (int)ImageHelper.convertDpToPixel (100f, context)); if (eachMessage.Key != null) { UserDB who = null; if (eachMessage.Value.MessageUser != null) who = eachMessage.Value.MessageUser; else who = null; if (who.AccountGuid == AndroidData.CurrentUser.AccountID.ToString ()) who = dbm.GetUserWithAccountID (eachMessage.Value.Message.MessageRecipientDBList [0].AccountGuid); if (who == null) { #if DEBUG System.Diagnostics.Debug.WriteLine ("UserDB = null for {0}, bugging out", latestMessages); #endif m++; } else { profilepic.Tag = new Java.Lang.String ("profilepic_" + who.AccountID); profilepic.SetImageResource (Resource.Drawable.defaultuserimage); layout.AddView (profilepic); if (eachMessage.Value.Message.MessageRecipientDBList.Count > 1) { List<UserDB> imageList = new List<UserDB> (); foreach (MessageRecipientDB human in eachMessage.Value.Message.MessageRecipientDBList) { imageList.Add (dbm.GetUserWithAccountID (human.AccountGuid)); } RunOnUiThread (delegate { createMultipleForContact (imageList); if (multipleContact != null) profilepic.SetImageBitmap (multipleContact); else profilepic.SetImageResource (Resource.Drawable.defaultuserimage); }); } else { if (who.Picture.Length == 0 && who.HasProfileImage) getGuid.Add (who.AccountID); else { if (who.Picture.Length > 0) this.LoadUserImage (who, profilepic); else profilepic.SetImageResource (Resource.Drawable.defaultuserimage); } } LinearLayout layout2 = new LinearLayout (context); layout2.Orientation = Orientation.Vertical; layout2.SetGravity (GravityFlags.Left); using (TextView name = new TextView (context)) { name.LayoutParameters = new ViewGroup.LayoutParams ((int)ImageHelper.convertDpToPixel (240f, context), (int)ImageHelper.convertDpToPixel (25f, context)); name.SetPadding ((int)ImageHelper.convertDpToPixel (20f, context), 0, (int)ImageHelper.convertDpToPixel (20f, context), 0); name.Gravity = GravityFlags.Left; name.SetTextColor (Color.White); name.TextSize = 16f; tmpName = who.FirstName + " " + who.LastName; if (eachMessage.Value.Message.MessageRecipientDBList.Count > 1) { if (eachMessage.Value.Message.MessageRecipientDBList.Count == 1 || eachMessage.Value.Message.MessageRecipientDBList.Count - 1 == 1) tmpName += " 1 other"; else tmpName += " " + string.Format ("{0} others", eachMessage.Value.Message.MessageRecipientDBList.Count - 1); } name.Text = tmpName; layout2.AddView (name); } if (eachMessage.Value.Message.MessageStepDBList.Count == 1 && eachMessage.Value.Message.MessageStepDBList [0].StepType == MessageStep.StepTypes.Text) { using (TextView txtMessage = new TextView (context)) { using (LinearLayout.LayoutParams txtMessageParams = new LinearLayout.LayoutParams ((int)ImageHelper.convertDpToPixel (220f, context), (int)ImageHelper.convertDpToPixel (60f, context))) { txtMessageParams.SetMargins ((int)ImageHelper.convertDpToPixel (10f, context), 0, 0, 0); txtMessage.LayoutParameters = txtMessageParams; } txtMessage.SetPadding ((int)ImageHelper.convertDpToPixel (20f, context), (int)ImageHelper.convertDpToPixel (10f, context), (int)ImageHelper.convertDpToPixel (20f, context), (int)ImageHelper.convertDpToPixel (10f, context)); txtMessage.Gravity = GravityFlags.CenterVertical; if (eachMessage.Value.Message.FromAccountID == AndroidData.CurrentUser.AccountID) txtMessage.SetBackgroundResource (Resource.Drawable.bubblesolidright); else txtMessage.SetBackgroundResource (Resource.Drawable.bubblesolidleft); txtMessage.TextSize = 16f; for (int e = 0; e < eachMessage.Value.Message.MessageStepDBList.Count; ++e) { if (!string.IsNullOrEmpty (eachMessage.Value.Message.MessageStepDBList [e].MessageText)) { messager = eachMessage.Value.Message.MessageStepDBList [e].MessageText; break; } } if (string.IsNullOrEmpty (messager)) messager = ""; int nolines = (int)(ImageHelper.convertDpToPixel ((messager.Length / 27f) * 12f, context)); txtMessage.SetHeight (nolines); txtMessage.SetTextColor (Android.Graphics.Color.Black); txtMessage.Text = messager; txtMessage.ContentDescription = eachMessage.Key; txtMessage.Click += ConversationItem_Clicked; layout2.AddView (txtMessage); } } else { int text = 0; for (int tt = 0; tt < eachMessage.Value.Message.MessageStepDBList.Count; ++tt) { if (eachMessage.Value.Message.MessageStepDBList [tt].StepType == MessageStep.StepTypes.Text) text++; } LinearLayout layout3 = new LinearLayout (context); LinearLayout.LayoutParams layout3params = new LinearLayout.LayoutParams (LinearLayout.LayoutParams.FillParent, LinearLayout.LayoutParams.WrapContent); layout3params.SetMargins ((int)ImageHelper.convertDpToPixel (10f, context), (int)ImageHelper.convertDpToPixel (5f, context), 0, (int)ImageHelper.convertDpToPixel (5f, context)); layout3.LayoutParameters = layout3params; layout3.Orientation = Orientation.Horizontal; layout3.SetGravity (GravityFlags.Left); layout3.ContentDescription = eachMessage.Key; layout3.Click += ConversationLayItem_Clicked; layout3.SetBackgroundResource (Resource.Drawable.attachmentspreviewbkgr); layout3.SetVerticalGravity (GravityFlags.CenterVertical); layout3.SetMinimumHeight (30); layout3.SetPadding ((int)ImageHelper.convertDpToPixel (10f, context), 0, (int)ImageHelper.convertDpToPixel (10f, context), 0); int end = eachMessage.Value.Message.MessageStepDBList.Count > 3 ? 3 : eachMessage.Value.Message.MessageStepDBList.Count; for (int i = 0; i < end; ++i) { switch (eachMessage.Value.Message.MessageStepDBList [i].StepType) { case LOLMessageDelivery.MessageStep.StepTypes.Text: if (text == 1) { using (TextView txtMessage = new TextView (context)) { using (LinearLayout.LayoutParams txtMessageParams = new LinearLayout.LayoutParams ((int)ImageHelper.convertDpToPixel (220f, context), (int)ImageHelper.convertDpToPixel (60f, context))) { txtMessageParams.SetMargins ((int)ImageHelper.convertDpToPixel (10f, context), 0, 0, 0); txtMessage.LayoutParameters = txtMessageParams; } txtMessage.SetPadding ((int)ImageHelper.convertDpToPixel (20f, context), (int)ImageHelper.convertDpToPixel (10f, context), (int)ImageHelper.convertDpToPixel (20f, context), (int)ImageHelper.convertDpToPixel (10f, context)); txtMessage.Gravity = GravityFlags.CenterVertical; if (eachMessage.Value.Message.FromAccountID == AndroidData.CurrentUser.AccountID) txtMessage.SetBackgroundResource (Resource.Drawable.bubblesolidright); else txtMessage.SetBackgroundResource (Resource.Drawable.bubblesolidleft); txtMessage.TextSize = 16f; for (int e = 0; e < eachMessage.Value.Message.MessageStepDBList.Count; ++e) { if (!string.IsNullOrEmpty (eachMessage.Value.Message.MessageStepDBList [e].MessageText)) { messager = eachMessage.Value.Message.MessageStepDBList [e].MessageText; break; } } if (string.IsNullOrEmpty (messager)) messager = "No text message found"; int nolines = (int)(ImageHelper.convertDpToPixel ((messager.Length / 27f) * 12f, context)); txtMessage.SetHeight (nolines); txtMessage.SetTextColor (Android.Graphics.Color.Black); txtMessage.Text = messager; txtMessage.ContentDescription = eachMessage.Key; txtMessage.Click += ConversationItem_Clicked; layout2.AddView (txtMessage); } } else { if (text > 1) { using (random = new ImageView (context)) { using (randomParams = new LinearLayout.LayoutParams ((int)ImageHelper.convertDpToPixel (30f, context), (int)ImageHelper.convertDpToPixel (30f, context))) { randomParams.SetMargins (0, 0, (int)ImageHelper.convertDpToPixel (5f, context), 0); random.LayoutParameters = randomParams; } random.ContentDescription = eachMessage.Key; random.Click += ConversationPicItem_Clicked; random.SetBackgroundResource (Resource.Drawable.icotext); layout3.AddView (random); } } } break; case LOLMessageDelivery.MessageStep.StepTypes.Animation: using (random = new ImageView (context)) { using (randomParams = new LinearLayout.LayoutParams ((int)ImageHelper.convertDpToPixel (30f, context), (int)ImageHelper.convertDpToPixel (30f, context))) { randomParams.SetMargins (0, 0, (int)ImageHelper.convertDpToPixel (5f, context), 0); random.LayoutParameters = randomParams; } random.ContentDescription = eachMessage.Key; random.Click += ConversationPicItem_Clicked; random.SetBackgroundResource (Resource.Drawable.icoanimation); layout3.AddView (random); } break; case LOLMessageDelivery.MessageStep.StepTypes.Comicon: using (random = new ImageView (context)) { using (randomParams = new LinearLayout.LayoutParams ((int)ImageHelper.convertDpToPixel (30f, context), (int)ImageHelper.convertDpToPixel (30f, context))) { randomParams.SetMargins (0, 0, (int)ImageHelper.convertDpToPixel (5f, context), 0); random.LayoutParameters = randomParams; } random.ContentDescription = eachMessage.Key; random.Click += ConversationPicItem_Clicked; random.SetBackgroundResource (Resource.Drawable.icocomicons); layout3.AddView (random); } break; case LOLMessageDelivery.MessageStep.StepTypes.Comix: using (random = new ImageView (context)) { using (randomParams = new LinearLayout.LayoutParams ((int)ImageHelper.convertDpToPixel (30f, context), (int)ImageHelper.convertDpToPixel (30f, context))) { randomParams.SetMargins (0, 0, (int)ImageHelper.convertDpToPixel (5f, context), 0); random.LayoutParameters = randomParams; } random.ContentDescription = eachMessage.Key; random.Click += ConversationPicItem_Clicked; random.SetBackgroundResource (Resource.Drawable.icocomix); layout3.AddView (random); } break; case LOLMessageDelivery.MessageStep.StepTypes.Emoticon: using (random = new ImageView (context)) { using (randomParams = new LinearLayout.LayoutParams ((int)ImageHelper.convertDpToPixel (30f, context), (int)ImageHelper.convertDpToPixel (30f, context))) { randomParams.SetMargins (0, 0, (int)ImageHelper.convertDpToPixel (5f, context), 0); random.LayoutParameters = randomParams; } random.ContentDescription = eachMessage.Key; random.Click += ConversationPicItem_Clicked; random.SetBackgroundResource (Resource.Drawable.icoemoticons); layout3.AddView (random); } break; case LOLMessageDelivery.MessageStep.StepTypes.Polling: using (random = new ImageView (context)) { using (randomParams = new LinearLayout.LayoutParams ((int)ImageHelper.convertDpToPixel (30f, context), (int)ImageHelper.convertDpToPixel (30f, context))) { randomParams.SetMargins (0, 0, (int)ImageHelper.convertDpToPixel (5f, context), 0); random.LayoutParameters = randomParams; } random.ContentDescription = eachMessage.Key; random.Click += ConversationPicItem_Clicked; random.SetBackgroundResource (Resource.Drawable.icopolls); layout3.AddView (random); } break; case LOLMessageDelivery.MessageStep.StepTypes.SoundFX: using (random = new ImageView (context)) { using (randomParams = new LinearLayout.LayoutParams ((int)ImageHelper.convertDpToPixel (30f, context), (int)ImageHelper.convertDpToPixel (30f, context))) { randomParams.SetMargins (0, 0, (int)ImageHelper.convertDpToPixel (5f, context), 0); random.LayoutParameters = randomParams; } random.ContentDescription = eachMessage.Key; random.Click += ConversationPicItem_Clicked; random.SetBackgroundResource (Resource.Drawable.icosoundfx); layout3.AddView (random); } break; case LOLMessageDelivery.MessageStep.StepTypes.Video: using (random = new ImageView (context)) { using (randomParams = new LinearLayout.LayoutParams ((int)ImageHelper.convertDpToPixel (30f, context), (int)ImageHelper.convertDpToPixel (30f, context))) { randomParams.SetMargins (0, 0, (int)ImageHelper.convertDpToPixel (5f, context), 0); random.LayoutParameters = randomParams; } random.ContentDescription = eachMessage.Key; random.Click += ConversationPicItem_Clicked; random.SetBackgroundResource (Resource.Drawable.icovideo); layout3.AddView (random); } break; case LOLMessageDelivery.MessageStep.StepTypes.Voice: using (random = new ImageView (context)) { using (randomParams = new LinearLayout.LayoutParams ((int)ImageHelper.convertDpToPixel (30f, context), (int)ImageHelper.convertDpToPixel (30f, context))) { randomParams.SetMargins (0, 0, (int)ImageHelper.convertDpToPixel (5f, context), 0); random.LayoutParameters = randomParams; } random.ContentDescription = eachMessage.Key; random.Click += ConversationPicItem_Clicked; random.SetBackgroundResource (Resource.Drawable.icovoice); layout3.AddView (random); } break; } } using (random = new ImageView (context)) { random.LayoutParameters = new ViewGroup.LayoutParams ((int)ImageHelper.convertDpToPixel (30f, context), (int)ImageHelper.convertDpToPixel (30f, context)); random.SetBackgroundResource (Resource.Drawable.playblack); random.ContentDescription = eachMessage.Value.Message.MessageGuid; random.Click += PlayButton_Clicked; layout3.AddView (random); } layout2.AddView (layout3); } LinearLayout layout4 = new LinearLayout (context); layout4.Orientation = Orientation.Vertical; layout4.SetGravity (GravityFlags.Right); using (TextView noMessages = new TextView (context)) { noMessages.LayoutParameters = new ViewGroup.LayoutParams ((int)ImageHelper.convertDpToPixel (240f, context), (int)ImageHelper.convertDpToPixel (20f, context)); noMessages.SetPadding ((int)ImageHelper.convertDpToPixel (10f, context), 0, (int)ImageHelper.convertDpToPixel (10f, context), 0); noMessages.SetTextColor (Color.White); noMessages.TextSize = 12f; noMessages.Text = unreadMessageCounts [eachMessage.Key] + " messages unread"; noMessages.Gravity = GravityFlags.Right; layout4.AddView (noMessages); } layout2.AddView (layout4); layout.AddView (layout2); listWrapper.AddView (layout); m++; } } } }); if (getGuid.Count > 0) { cpUI = 0; LOLConnectClient service = new LOLConnectClient (LOLConstants.DefaultHttpBinding, LOLConstants.LOLConnectEndpoint); service.UserGetImageDataCompleted += Service_UserGetImageDataCompleted; service.UserGetImageDataAsync (AndroidData.CurrentUser.AccountID, getGuid [0], new Guid (AndroidData.ServiceAuthToken)); } }
/** * Create a default view to be used for tabs. This is called if a custom tab view is not set via * {@link #setCustomTabView(int, int)}. */ protected TextView CreateDefaultTabView(Context context) { TextView textView = new TextView(context); textView.Gravity = Android.Views.GravityFlags.Center; textView.SetTextSize(ComplexUnitType.Sp, 12); textView.Typeface = Typeface.DefaultBold; if (Build.VERSION.SdkInt >= Android.OS.BuildVersionCodes.Honeycomb) { // If we're running on Honeycomb or newer, then we can use the Theme's // selectableItemBackground to ensure that the View has a pressed state TypedValue outValue = new TypedValue(); Context.Theme.ResolveAttribute(Android.Resource.Attribute.SelectableItemBackground,outValue, true); textView.SetBackgroundResource(outValue.ResourceId); } if ((int)Build.VERSION.SdkInt >= 14 || (int)Build.VERSION.SdkInt <= 15){ // If we're running on ICS or newer, enable all-caps to match the Action Bar tab style textView.SetAllCaps(true); } int padding = (int) (16 * Resources.DisplayMetrics.Density); textView.SetPadding(padding, padding, padding, padding); return textView; }
public void NodeClick(View v) { if (nodeIndex < -1 || route == null || route.AllStep == null || nodeIndex > route.AllStep.Count) { return; } //���ýڵ����� if (v.Id == Resource.Id.next && nodeIndex < route.AllStep.Count - 1) { nodeIndex++; } else if (v.Id == Resource.Id.pre && nodeIndex > 1) { nodeIndex--; } if (nodeIndex < 0 || nodeIndex >= route.AllStep.Count) { return; } //��ȡ�ڽ����Ϣ LatLng nodeLocation = null; string nodeTitle = null; object step = route.AllStep[nodeIndex]; string stepSimpleName = ((Object)step).Class.SimpleName; string drivingStepName = typeof(DrivingRouteLine.DrivingStep).Name; string walkingStepName = typeof(WalkingRouteLine.WalkingStep).Name; string transitStepName = typeof(TransitRouteLine.TransitStep).Name; if (stepSimpleName == drivingStepName)// if (step is DrivingRouteLine.DrivingStep) { nodeLocation = (Android.Runtime.Extensions.JavaCast<DrivingRouteLine.DrivingStep>((Object)step)).Entrace.Location; nodeTitle = (Android.Runtime.Extensions.JavaCast<DrivingRouteLine.DrivingStep>((Object)step)).Instructions; } else if (stepSimpleName == walkingStepName)// else if (step is WalkingRouteLine.WalkingStep) { nodeLocation = (Android.Runtime.Extensions.JavaCast<WalkingRouteLine.WalkingStep>((Object)step)).Entrace.Location; nodeTitle = (Android.Runtime.Extensions.JavaCast<WalkingRouteLine.WalkingStep>((Object)step)).Instructions; } else if (stepSimpleName == transitStepName)// else if (step is TransitRouteLine.TransitStep) { nodeLocation = (Android.Runtime.Extensions.JavaCast<TransitRouteLine.TransitStep>((Object)step)).Entrace.Location; nodeTitle = (Android.Runtime.Extensions.JavaCast<TransitRouteLine.TransitStep>((Object)step)).Instructions; } if (nodeLocation == null || nodeTitle == null) { return; } //�ƶ��ڵ������� mBaidumap.SetMapStatus(MapStatusUpdateFactory.NewLatLng(nodeLocation)); // Show popup viewCache = LayoutInflater.Inflate(Resource.Layout.custom_text_view, null); popupText = viewCache.FindViewById<TextView>(Resource.Id.textcache); popupText.SetBackgroundResource(Resource.Drawable.popup); popupText.Text = nodeTitle; mBaidumap.ShowInfoWindow(new InfoWindow(popupText, nodeLocation, null)); }
private void PrepareViews(int co) { if (co >= counter || done) RunOnUiThread(delegate { t.Stop(); Window.ClearFlags(WindowManagerFlags.KeepScreenOn); Finish(); }); if (!done) t.Start(); float[] newSizes = new float[2]; newSizes [0] = 200f; if (wowZapp.LaffOutOut.Singleton.resizeFonts) { newSizes [0] *= wowZapp.LaffOutOut.Singleton.bigger; newSizes [1] = newSizes [0]; } this.stepViews = new Dictionary<int, View>(); string path = System.IO.Path.Combine(wowZapp.LaffOutOut.Singleton.ContentDirectory, "tempaudio.wav"); string videoPath = System.IO.Path.Combine(wowZapp.LaffOutOut.Singleton.ContentDirectory, "tempvideo.mp4"); #if DEBUG System.Diagnostics.Debug.WriteLine("co = {0}, counter = {1}", co, counter); #endif MessageStep eachMessageStep = null; if (co != counter) { eachMessageStep = MessagePlaybackUtil.messageSteps [co]; ContentPackItem packItem = null; MessagePlaybackUtil.contentPackItems.TryGetValue(eachMessageStep.ContentPackItemID, out packItem); #if DEBUG System.Diagnostics.Debug.WriteLine("co = {0}, messagestep type = {1}, contentPackID = {2}, packItem = {3}", co, eachMessageStep, eachMessageStep.ContentPackItemID, packItem != null ? "yes" : "no"); #endif switch (eachMessageStep.StepType) { case MessageStep.StepTypes.Text: RunOnUiThread(delegate { using (TextView textMessage = new TextView (context)) { textMessage.LayoutParameters = new ViewGroup.LayoutParams((int)ImageHelper.convertDpToPixel(250f, context), (int)ImageHelper.convertDpToPixel(150f, context)); textMessage.SetBackgroundResource(Resource.Drawable.bubblesolidleft); textMessage.Gravity = GravityFlags.Top; textMessage.SetPadding((int)ImageHelper.convertDpToPixel(20f, context), (int)ImageHelper.convertDpToPixel(15f, context), (int)ImageHelper.convertDpToPixel(20f, context), (int)ImageHelper.convertDpToPixel(15f, context)); textMessage.SetTextColor(Color.Black); textMessage.SetTextSize(Android.Util.ComplexUnitType.Pt, 12f); textMessage.Text = MessagePlaybackUtil.messageSteps [co].MessageText; textMessage.Visibility = ViewStates.Visible; linView.AddView(textMessage); this.stepViews [eachMessageStep.StepNumber] = textMessage; } }); break; case MessageStep.StepTypes.Comix: if (packItem != null) { RunOnUiThread(delegate { using (ImageView preview = new ImageView (context)) { preview.LayoutParameters = new ViewGroup.LayoutParams((int)ImageHelper.convertDpToPixel(newSizes [0], context), (int)ImageHelper.convertDpToPixel(newSizes [1], context)); preview.SetScaleType(ImageView.ScaleType.FitXy); Android.Graphics.Drawables.Drawable imgDataC = Android.Graphics.Drawables.Drawable.CreateFromStream(new MemoryStream(packItem.ContentPackItemIcon), "Comix"); preview.SetImageDrawable(imgDataC); linView.AddView(preview); this.stepViews [eachMessageStep.StepNumber] = preview; } }); } break; case MessageStep.StepTypes.Comicon: if (packItem != null) { RunOnUiThread(delegate { using (Android.Graphics.Drawables.Drawable imgDataS = Android.Graphics.Drawables.Drawable.CreateFromStream (new MemoryStream (packItem.ContentPackItemIcon), "Comicon")) { using (ImageView preview = new ImageView (context)) { preview.LayoutParameters = new ViewGroup.LayoutParams((int)ImageHelper.convertDpToPixel(newSizes [0], context), (int)ImageHelper.convertDpToPixel(newSizes [1], context)); preview.SetScaleType(ImageView.ScaleType.FitXy); preview.SetImageDrawable(imgDataS); linView.AddView(preview); this.stepViews [eachMessageStep.StepNumber] = preview; byte[] audio = packItem.ContentPackData; System.IO.File.WriteAllBytes(path, audio); AudioPlayer csfx = new AudioPlayer(context); t.Interval = csfx.findDuration(path) + 1000; csfx.playFromFile(path); } } }); } break; case MessageStep.StepTypes.SoundFX: if (packItem != null) { RunOnUiThread(delegate { using (ImageView preview = new ImageView (context)) { preview.LayoutParameters = new ViewGroup.LayoutParams((int)ImageHelper.convertDpToPixel(newSizes [0], context), (int)ImageHelper.convertDpToPixel(newSizes [1], context)); preview.SetScaleType(ImageView.ScaleType.FitXy); preview.SetImageResource(Resource.Drawable.audiofile); linView.AddView(preview); byte[] audio = packItem.ContentPackData; System.IO.File.WriteAllBytes(path, audio); AudioPlayer csfx = new AudioPlayer(context); t.Interval = csfx.findDuration(path) + 1000; csfx.playFromFile(path); this.stepViews [eachMessageStep.StepNumber] = preview; } }); } break; case MessageStep.StepTypes.Emoticon: if (packItem != null) { //RunOnUiThread (delegate { t.Interval = 5000; string base64String = System.Convert.ToBase64String(packItem.ContentPackData, 0, packItem.ContentPackData.Length); using (WebView wv = new WebView (context)) { string url = "<img src=\"data:image/gif;base64," + base64String + "\" width=\"" + ((int)newSizes [0]).ToString() + "\" height=\"" + ((int)newSizes [1]).ToString() + "\" />"; wv.LoadDataWithBaseURL(null, url, "text/html", "UTF-8", null); wv.VerticalScrollBarEnabled = false; wv.HorizontalScrollBarEnabled = false; wv.LayoutParameters = new ViewGroup.LayoutParams((int)ImageHelper.convertDpToPixel(200f, context), (int)ImageHelper.convertDpToPixel(200f, context)); wv.SetBackgroundColor(Color.Transparent); RunOnUiThread(() => linView.AddView(wv)); } //}); } break; case MessageStep.StepTypes.Voice: if (MessagePlaybackUtil.voiceRecordings != null) { RunOnUiThread(delegate { using (ImageView preview = new ImageView (context)) { preview.LayoutParameters = new ViewGroup.LayoutParams((int)ImageHelper.convertDpToPixel(newSizes [0], context), (int)ImageHelper.convertDpToPixel(newSizes [1], context)); preview.SetScaleType(ImageView.ScaleType.FitXy); preview.SetImageResource(Resource.Drawable.microphone); linView.AddView(preview); this.stepViews [eachMessageStep.StepNumber] = preview; } //byte[] audio = getLocalVoiceRecording (MessagePlaybackUtil.voiceRecordings [eachMessageStep.StepNumber]); AudioPlayer voice = new AudioPlayer(context); #if DEBUG System.Diagnostics.Debug.WriteLine("audio file filename = {0}, stepNumber = {1}", MessagePlaybackUtil.voiceRecordings [eachMessageStep.StepNumber], eachMessageStep.StepNumber); #endif t.Interval = voice.findDuration(MessagePlaybackUtil.voiceRecordings [eachMessageStep.StepNumber]) + 1000; string audioPath = MessagePlaybackUtil.voiceRecordings [eachMessageStep.StepNumber]; if (!File.Exists(audioPath)) { #if DEBUG System.Diagnostics.Debug.WriteLine("audio file doesn't exist for playback"); #endif } else voice.playFromFile(audioPath); isPlaying = true; }); } break; case MessageStep.StepTypes.Video: if (packItem != null) { RunOnUiThread(delegate { SurfaceView preview = new SurfaceView(context); preview.LayoutParameters = new ViewGroup.LayoutParams((int)ImageHelper.convertDpToPixel(newSizes [0], context), (int)ImageHelper.convertDpToPixel(newSizes [1], context)); linView.AddView(preview); byte[] audio = packItem.ContentPackData; System.IO.File.WriteAllBytes(videoPath, audio); videoPlay voice = new videoPlay(preview, videoPath); t.Interval = voice.videoDuration(path) + 1000; voice.videoStart(); this.stepViews [eachMessageStep.StepNumber] = preview; isPlaying = true; }); } break; case MessageStep.StepTypes.Animation: /*if (eachMessageStep.AnimationData != null) { string animationHtml = Translator.MakePlaybackCode (eachMessageStep.AnimationData, (int)newSizes [0], (int)newSizes [1], RenderPlatformTypes.Android, JSTemplate); t.Interval = Convert.ToInt32 (eachMessageStep.AnimationData.Duration) + 100; using (WebView wv = new WebView (context)) { wv.LoadDataWithBaseURL (null, animationHtml, "text/html", "UTF-8", null); wv.VerticalScrollBarEnabled = false; wv.HorizontalScrollBarEnabled = false; wv.LayoutParameters = new ViewGroup.LayoutParams ((int)ImageHelper.convertDpToPixel (200f, context), (int)ImageHelper.convertDpToPixel (200f, context)); wv.SetBackgroundColor (Color.Transparent); RunOnUiThread (() => linView.AddView (wv)); } }*/ break; case MessageStep.StepTypes.Polling: if (MessagePlaybackUtil.pollSteps.Count > 0) { PollingStep pollStep = MessagePlaybackUtil.pollSteps [eachMessageStep.StepNumber]; if (string.IsNullOrEmpty(pollStep.PollingAnswer1)) { t.Stop(); MessagePollUtil.pollStep = pollStep; MessagePollUtil.recipients = MessagePlaybackUtil.recipients; MessagePollUtil.isPhoto = true; LOLMessageSurveyResult pollResult; #if DEBUG System.Diagnostics.Debug.WriteLine("PollResults = {0}", MessagePlaybackUtil.pollResults == null ? "null" : "something"); #endif if (MessagePlaybackUtil.pollResults.TryGetValue(eachMessageStep.StepNumber, out pollResult)) MessagePollUtil.pollScreenType = PollingScreenType.Results; else MessagePollUtil.pollScreenType = PollingScreenType.Vote; #if DEBUG System.Diagnostics.Debug.WriteLine("polltype = {0}", MessagePollUtil.pollScreenType); #endif RunOnUiThread(delegate { SetContentView(Resource.Layout.PhotoPoll); ImageView topleft = FindViewById<ImageView>(Resource.Id.imgPoll1); topleft.Tag = 1; ImageView topright = FindViewById<ImageView>(Resource.Id.imgPoll2); topright.Tag = 2; ImageView bottomleft = FindViewById<ImageView>(Resource.Id.imgPoll3); bottomleft.Tag = 3; ImageView bottomright = FindViewById<ImageView>(Resource.Id.imgPoll4); bottomright.Tag = 4; voteTL = FindViewById<ProgressBar>(Resource.Id.pbVoteTL); voteTR = FindViewById<ProgressBar>(Resource.Id.pbVoteTR); voteBL = FindViewById<ProgressBar>(Resource.Id.pbVoteBL); voteBR = FindViewById<ProgressBar>(Resource.Id.pbVoteBR); TextView textPoll = FindViewById<TextView>(Resource.Id.txtPollText); textPoll.Text = MessagePollUtil.pollStep.PollingQuestion; doner = FindViewById<Button>(Resource.Id.btnDone); if (MessagePollUtil.pollScreenType == PollingScreenType.Results) { doner.Click += delegate { Intent i = new Intent(this, typeof(MessagePlayback)); i.PutExtra("position", co + 1); StartActivity(i); Finish(); }; } else doner.Visibility = ViewStates.Invisible; ImageButton btnUniBack = FindViewById<ImageButton>(Resource.Id.btnUniBack); btnUniBack.Visibility = ViewStates.Invisible; if (MessagePollUtil.pollScreenType == PollingScreenType.Vote) { voteTL.Visibility = voteTR.Visibility = voteBL.Visibility = voteBR.Visibility = ViewStates.Invisible; topleft.Click += new EventHandler(Photo_Click); topright.Click += new EventHandler(Photo_Click); bottomleft.Click += new EventHandler(Photo_Click); bottomright.Click += new EventHandler(Photo_Click); } else if (MessagePollUtil.pollScreenType == PollingScreenType.Results) { LOLMessageClient service = new LOLMessageClient(LOLConstants.DefaultHttpBinding, LOLConstants.LOLMessageEndpoint); service.PollingStepGetResultsCompleted += Service_PollingStepGetResultsCompleted; service.PollingStepGetResultsAsync(eachMessageStep.StepID, AndroidData.CurrentUser.AccountID, new Guid(AndroidData.ServiceAuthToken)); } if (MessagePollUtil.pollStep.PollingData1 != null) { if (MessagePollUtil.pollStep.PollingData1.Length != 0) { #if DEBUG System.Diagnostics.Debug.WriteLine("in A"); #endif using (Drawable imgDataA = Drawable.CreateFromStream (new MemoryStream (MessagePollUtil.pollStep.PollingData1), "Poll1")) { topleft.SetImageDrawable(imgDataA); } } } if (MessagePollUtil.pollStep.PollingData2 != null) { if (MessagePollUtil.pollStep.PollingData2.Length != 0) { #if DEBUG System.Diagnostics.Debug.WriteLine("in B"); #endif using (Drawable imgDataB = Drawable.CreateFromStream (new MemoryStream (MessagePollUtil.pollStep.PollingData2), "Poll2")) { topright.SetImageDrawable(imgDataB); } } } if (MessagePollUtil.pollStep.PollingData3 != null) { if (MessagePollUtil.pollStep.PollingData3.Length != 0) { #if DEBUG System.Diagnostics.Debug.WriteLine("in C"); #endif using (Drawable imgDataC = Drawable.CreateFromStream (new MemoryStream (MessagePollUtil.pollStep.PollingData3), "Poll3")) { bottomleft.SetImageDrawable(imgDataC); } } } if (MessagePollUtil.pollStep.PollingData4 != null) { if (MessagePollUtil.pollStep.PollingData4.Length != 0) { #if DEBUG System.Diagnostics.Debug.WriteLine("in D"); #endif using (Drawable imgDataD = Drawable.CreateFromStream (new MemoryStream (MessagePollUtil.pollStep.PollingData4), "Poll4")) { bottomright.SetImageDrawable(imgDataD); } } } }); } else { MessagePollUtil.isPhoto = false; MessagePollUtil.pollStep = pollStep; MessagePollUtil.recipients = MessagePlaybackUtil.recipients; LOLMessageSurveyResult pollResult; if (MessagePlaybackUtil.pollResults.TryGetValue(eachMessageStep.StepNumber, out pollResult)) MessagePollUtil.pollScreenType = PollingScreenType.Results; else MessagePollUtil.pollScreenType = PollingScreenType.Vote; t.Stop(); RunOnUiThread(delegate { SetContentView(Resource.Layout.TextPoll); Button opt1 = FindViewById<Button>(Resource.Id.btnOpt1); opt1.Tag = 1; Button opt2 = FindViewById<Button>(Resource.Id.btnOpt2); opt2.Tag = 2; Button opt3 = FindViewById<Button>(Resource.Id.btnOpt3); opt3.Tag = 3; Button opt4 = FindViewById<Button>(Resource.Id.btnOpt4); opt4.Tag = 4; res1 = FindViewById<ProgressBar>(Resource.Id.pbRes1); res2 = FindViewById<ProgressBar>(Resource.Id.pbRes2); res3 = FindViewById<ProgressBar>(Resource.Id.pbRes3); res4 = FindViewById<ProgressBar>(Resource.Id.pbRes4); TextView pollQ = FindViewById<TextView>(Resource.Id.txtPollText); pollQ.Text = MessagePollUtil.pollStep.PollingQuestion; Button finished = FindViewById<Button>(Resource.Id.btnDone); finished.Click += delegate { Intent i = new Intent(this, typeof(MessagePlayback)); i.PutExtra("position", co + 1); StartActivity(i); Finish(); }; doner = FindViewById<Button>(Resource.Id.btnDone); if (MessagePollUtil.pollScreenType == PollingScreenType.Results) { doner.Click += delegate { Intent i = new Intent(this, typeof(MessagePlayback)); i.PutExtra("position", co + 1); StartActivity(i); Finish(); }; } else doner.Visibility = ViewStates.Invisible; ImageButton btnUniBack = FindViewById<ImageButton>(Resource.Id.btnUniBack); btnUniBack.Visibility = ViewStates.Invisible; opt1.Text = MessagePollUtil.pollStep.PollingAnswer1; opt2.Text = MessagePollUtil.pollStep.PollingAnswer2; opt3.Text = MessagePollUtil.pollStep.PollingAnswer3; opt4.Text = MessagePollUtil.pollStep.PollingAnswer4; if (MessagePollUtil.pollScreenType == PollingScreenType.Vote) { res1.Visibility = res2.Visibility = res3.Visibility = res4.Visibility = ViewStates.Invisible; opt1.Click += new EventHandler(PollButton_Click); opt2.Click += new EventHandler(PollButton_Click); opt3.Click += new EventHandler(PollButton_Click); opt4.Click += new EventHandler(PollButton_Click); } else { LOLMessageClient service = new LOLMessageClient(LOLConstants.DefaultHttpBinding, LOLConstants.LOLMessageEndpoint); service.PollingStepGetResultsCompleted += Service_PollingStepGetResultsCompleted; service.PollingStepGetResultsAsync(eachMessageStep.StepID, AndroidData.CurrentUser.AccountID, new Guid(AndroidData.ServiceAuthToken)); } }); } } break; } } if (File.Exists(path)) File.Delete(path); if (File.Exists(videoPath)) File.Delete(videoPath); }
private void RefreshTableContent2() { if (pfPharmacyTable != null) { int childCount = pfPharmacyTable.ChildCount; // Remove all rows except the first one if (childCount > 1) { pfPharmacyTable.RemoveViews(1, childCount - 1); } pharmacies = (List<Pharmacy>)PharmacyManager.GetPharmacies (pfSearchEdit.Text, 20); foreach (var pharmacy in pharmacies) { string src = pfSearchEdit.Text; string srcWithCap = UppercaseFirst(pfSearchEdit.Text); string rpl = ""; TableRow row = new TableRow (Activity); row.SetBackgroundResource(Resource.Drawable.bottomline); //View view = layoutInflater.Inflate (Resource.Layout.LeftDrawerItem, null, false);//TextView id = new TextView (this.Activity); TextView id = new TextView (Activity); // id.SetTextAppearance (this.Activity, global::Android.Resource.Style.TextAppearanceLarge); //?android:attr/textAppearanceLarge // id.SetTextAppearance(Activity, Resource.Style.rowTextForPharmacy); // id.SetPadding(24, 0, 24, 0); // TableRow.LayoutParams p = // p.RightMargin = 24; // p.LeftMargin = 24; id.LayoutParameters = new TableRow.LayoutParams() {RightMargin = 24, LeftMargin = 24}; id.SetBackgroundResource(Resource.Drawable.bottomline); id.SetTextAppearance (Activity, Resource.Style.rowTextForPharmacy); id.SetHeight (48); id.Gravity = GravityFlags.Center; id.Text = pharmacy.id.ToString (); row.AddView (id); // CheckBox chk = new CheckBox (Activity); // chk.SetPadding(24, 16, 24, 16); // row.AddView (chk); TextView fullName = new TextView (Activity); // fullName.SetTextAppearance (Activity, global::Android.Resource.Style.TextAppearanceLarge); //?android:attr/textAppearanceLarge // fullName.SetPadding(0, 0, 56, 0); // TableRow.LayoutParams fullNameP = new TableRow.LayoutParams(); // fullNameP.RightMargin = 56; fullName.LayoutParameters = new TableRow.LayoutParams() {RightMargin = 56}; // fullName.SetTextAppearance (Activity, Resource.Style.rowTextForPharmacy); // fullName.SetBackgroundResource(Resource.Drawable.bottomline); fullName.SetTextAppearance (Activity, Resource.Style.rowTextForPharmacy); fullName.SetHeight (48); fullName.Gravity = GravityFlags.CenterVertical; if (string.IsNullOrEmpty (src)) { fullName.Text = pharmacy.fullName; } else { rpl = pharmacy.fullName.Replace (src, @"<font color='red'>" + src + @"</font>"); rpl = rpl.Replace (srcWithCap, @"<font color='red'>" + srcWithCap + @"</font>"); fullName.TextFormatted = Html.FromHtml (rpl); } row.AddView (fullName); TextView shortName = new TextView (Activity); // shortName.SetPadding(0, 0, 56, 0);0 // shortName.SetBackgroundResource(Resource.Drawable.bottomline); shortName.SetTextAppearance (Activity, Resource.Style.rowTextForPharmacy); shortName.SetHeight (48); shortName.Gravity = GravityFlags.CenterVertical; if (string.IsNullOrEmpty (src)) { shortName.Text = pharmacy.shortName; } else { rpl = pharmacy.shortName.Replace (src, @"<font color='red'>" + src + @"</font>"); rpl = rpl.Replace (srcWithCap, @"<font color='red'>" + srcWithCap + @"</font>"); shortName.TextFormatted = Html.FromHtml (rpl); } row.AddView (shortName); TextView officialName = new TextView (Activity); // officialName.SetPadding(0, 0, 56, 0); // officialName.SetBackgroundResource(Resource.Drawable.bottomline); officialName.SetTextAppearance (Activity, Resource.Style.rowTextForPharmacy); officialName.SetHeight (48); officialName.Gravity = GravityFlags.CenterVertical; if (string.IsNullOrEmpty (src)) { officialName.Text = pharmacy.officialName; } else { rpl = pharmacy.officialName.Replace (src, @"<font color='red'>" + src + @"</font>"); rpl = rpl.Replace (srcWithCap, @"<font color='red'>" + srcWithCap + @"</font>"); officialName.TextFormatted = Html.FromHtml (rpl); } row.AddView (officialName); TextView address = new TextView (Activity); // address.SetTextAppearance (this.Activity, global::Android.Resource.Style.TextAppearanceLarge); //?android:attr/textAppearanceLarge // address.SetPadding(0, 0, 56, 0); // address.SetTextAppearance (Activity, Resource.Style.rowTextForPharmacy); // address.SetBackgroundResource(Resource.Drawable.bottomline); address.SetTextAppearance (Activity, Resource.Style.rowTextForPharmacy); address.SetHeight (48); address.Gravity = GravityFlags.CenterVertical; if (string.IsNullOrEmpty (src)) { address.Text = pharmacy.address; } else { rpl = pharmacy.address.Replace (src, @"<font color='red'>" + src + @"</font>"); rpl = rpl.Replace (srcWithCap, @"<font color='red'>" + srcWithCap + @"</font>"); address.TextFormatted = Html.FromHtml (rpl); } row.AddView (address); TextView subway = new TextView (Activity); // subway.SetPadding(0, 0, 56, 0); // subway.SetBackgroundResource(Resource.Drawable.bottomline); subway.SetTextAppearance (Activity, Resource.Style.rowTextForPharmacy); subway.SetHeight (48); subway.Gravity = GravityFlags.CenterVertical; if (string.IsNullOrEmpty (src)) { subway.Text = pharmacy.subway; } else { rpl = pharmacy.subway.Replace (src, @"<font color='red'>" + src + @"</font>"); rpl = rpl.Replace (srcWithCap, @"<font color='red'>" + srcWithCap + @"</font>"); subway.TextFormatted = Html.FromHtml (rpl); } row.AddView (subway); TextView phone = new TextView (Activity); // phone.SetPadding(0, 0, 56, 0); // phone.SetBackgroundResource(Resource.Drawable.bottomline); phone.SetTextAppearance (Activity, Resource.Style.rowTextForPharmacy); phone.SetHeight (48); phone.Gravity = GravityFlags.CenterVertical; if (string.IsNullOrEmpty (src)) { phone.Text = pharmacy.phone; } else { rpl = pharmacy.phone.Replace (src, @"<font color='red'>" + src + @"</font>"); rpl = rpl.Replace (srcWithCap, @"<font color='red'>" + srcWithCap + @"</font>"); phone.TextFormatted = Html.FromHtml (rpl); } row.AddView (phone); TextView email = new TextView (Activity); // email.SetPadding(0, 0, 56, 0); // email.SetBackgroundResource(Resource.Drawable.bottomline); email.SetTextAppearance (Activity, Resource.Style.rowTextForPharmacy); email.SetHeight (48); email.Gravity = GravityFlags.CenterVertical; if (string.IsNullOrEmpty (src)) { email.Text = pharmacy.email; } else { rpl = pharmacy.email.Replace (src, @"<font color='red'>" + src + @"</font>"); rpl = rpl.Replace (srcWithCap, @"<font color='red'>" + srcWithCap + @"</font>"); email.TextFormatted = Html.FromHtml (rpl); } row.AddView (email); // Button delete = new Button (this.Activity); // delete.SetTextAppearance (this.Activity, global::Android.Resource.Style.TextAppearanceLarge); //?android:attr/textAppearanceLarge // delete.SetPadding(0, 16, 24, 16); // delete.Text = @"Del"; // delete.Id = pharmacy.id; // delete.Click += PharmacyDelete_Click; // // row.AddView (delete); pfPharmacyTable.AddView(row); } } }
private void createUI(List<MessageDB> message, List<UserDB> contact, string nameTitle, bool clear = false) { message.Reverse (); contact.Reverse (); int m = 0; string messager = ""; bool dd = false; if (message != null && contact != null) { if (clear == false) RunOnUiThread (() => listWrapper.RemoveAllViewsInLayout ()); string othername = string.Empty; for (int i = 0; i < contact.Count; ++i) { if (string.IsNullOrEmpty (nameTitle)) othername = contact [i].FirstName + " " + contact [i].LastName; else othername = nameTitle; if (isMe != othername) { RunOnUiThread (delegate { Header.headertext = othername; Header.fontsize = 36f; ImageHelper.fontSizeInfo (header.Context); header.SetTextSize (Android.Util.ComplexUnitType.Dip, Header.fontsize); header.Text = Header.headertext; }); break; } } if (contact.Count > 1) { string toReturn = ""; List<UserDB> sortedList = new List<UserDB> (); sortedList = contact.OrderBy (s => s.LastName).OrderBy (s => s.FirstName).ToList (); foreach (UserDB eachItem in sortedList) toReturn += string.Format ("{0} {1}, ", eachItem.FirstName, eachItem.LastName); int last = toReturn.LastIndexOf (", "); toReturn = toReturn.Remove (last); RunOnUiThread (delegate { using (LinearLayout btnlayout = new LinearLayout (context)) { btnlayout.Orientation = Android.Widget.Orientation.Vertical; btnlayout.SetGravity (GravityFlags.Center); btnlayout.LayoutParameters = new ViewGroup.LayoutParams (LinearLayout.LayoutParams.FillParent, LinearLayout.LayoutParams.WrapContent); btnlayout.SetPadding ((int)ImageHelper.convertDpToPixel (5f, context), 0, (int)ImageHelper.convertDpToPixel (5f, context), (int)ImageHelper.convertDpToPixel (10f, context)); using (TextView name = new TextView(context)) { name.Text = toReturn; name.SetTextSize (Android.Util.ComplexUnitType.Dip, 18f); name.SetTextColor (Color.Black); btnlayout.AddView (name); } using (Button showAll = new Button (context)) { showAll.Gravity = GravityFlags.CenterVertical; showAll.Text = Application.Context.Resources.GetString (Resource.String.messageShowAllInConversation); showAll.Click += (object sender, EventArgs e) => { showParticipants (sender, e, contact); }; showAll.SetWidth ((int)ImageHelper.convertDpToPixel (180f, context)); showAll.SetHeight ((int)ImageHelper.convertDpToPixel (30f, context)); showAll.SetBackgroundResource (Resource.Drawable.button); btnlayout.AddView (showAll); } listWrapper.AddView (btnlayout); } }); } if (getGuid != null) getGuid.Clear (); RunOnUiThread (delegate { foreach (MessageDB messages in message) { string name = contact [m].FirstName + " " + contact [m].LastName; ImageView random = null; LinearLayout layout = new LinearLayout (context); layout.Orientation = Android.Widget.Orientation.Horizontal; layout.SetGravity (GravityFlags.CenterVertical); layout.SetPadding ((int)ImageHelper.convertDpToPixel (5f, context), 0, (int)ImageHelper.convertDpToPixel (5f, context), (int)ImageHelper.convertDpToPixel (10f, context)); LinearLayout layout2 = new LinearLayout (context); layout2.Orientation = Orientation.Vertical; layout2.SetGravity (GravityFlags.Center); if (name == isMe) layout.AddView (contactUserInterface (messages, contact [m], true)); else layout.AddView (contactUserInterface (messages, contact [m], false)); /*ImageView profilepic = new ImageView (context); profilepic.LayoutParameters = new ViewGroup.LayoutParams ((int)ImageHelper.convertDpToPixel (55f, context), (int)ImageHelper.convertDpToPixel (100f, context)); if (contact == null) profilepic.SetImageDrawable (Application.Context.Resources.GetDrawable (Resource.Drawable.defaultuserimage)); else { profilepic.Tag = new Java.Lang.String ("profilepic_" + contact [m].AccountID); profilepic.SetImageResource (Resource.Drawable.defaultuserimage); layout.AddView (profilepic); if (contact [m].Picture.Length == 0 && contact [m].HasProfileImage) getGuid.Add (contact [m].AccountID); else { if (contact [m].Picture.Length > 0) LoadUserImage (contact [m], profilepic); else profilepic.SetImageDrawable (Application.Context.Resources.GetDrawable (Resource.Drawable.defaultuserimage)); } TextView name = new TextView (context); name.LayoutParameters = new ViewGroup.LayoutParams ((int)ImageHelper.convertDpToPixel (230f, context), (int)ImageHelper.convertDpToPixel (40f, context)); name.Gravity = GravityFlags.Center; name.SetTextColor (Color.White); name.TextSize = 16f; layout2.AddView (name); if (messages.MessageStepDBList.Count == 1 && messages.MessageStepDBList [0].StepType == MessageStep.StepTypes.Text) { TextView text = new TextView (context); text.LayoutParameters = new ViewGroup.LayoutParams ((int)ImageHelper.convertDpToPixel (220f, context), (int)ImageHelper.convertDpToPixel (60f, context)); text.SetPadding ((int)ImageHelper.convertDpToPixel (20f, context), 0, (int)ImageHelper.convertDpToPixel (10f, context), 0); text.Gravity = GravityFlags.CenterVertical; if (name == isMe) text.SetBackgroundResource (Resource.Drawable.bubblesolidright); else text.SetBackgroundResource (Resource.Drawable.bubblesolidleft); text.TextSize = 16f; for (int e = 0; e < messages.MessageStepDBList.Count; ++e) { if (!string.IsNullOrEmpty (messages.MessageStepDBList [e].MessageText)) { messager = messages.MessageStepDBList [e].MessageText; break; } } if (string.IsNullOrEmpty (messager)) messager = "No text message found"; int nolines = (int)(ImageHelper.convertDpToPixel ((messager.Length / 27f) * 12f, context)); text.SetHeight (nolines); text.SetTextColor (Android.Graphics.Color.Black); text.Text = messager; layout2.Clickable = true; layout2.AddView (text); } else {*/ LinearLayout layout3 = new LinearLayout (context); layout3.Orientation = Orientation.Horizontal; if (name == isMe) layout3.SetGravity (GravityFlags.Right); else layout3.SetGravity (GravityFlags.Left); layout3.SetBackgroundResource (Resource.Drawable.attachmentspreviewbkgr); layout3.SetVerticalGravity (GravityFlags.CenterVertical); layout3.SetMinimumHeight (30); layout3.SetPadding ((int)ImageHelper.convertDpToPixel (10f, context), 0, (int)ImageHelper.convertDpToPixel (10f, context), 0); if (name != isMe) { using (random = new ImageView (context)) { random.Tag = m; random.LayoutParameters = new ViewGroup.LayoutParams ((int)ImageHelper.convertDpToPixel (30f, context), (int)ImageHelper.convertDpToPixel (30f, context)); random.SetBackgroundResource (Resource.Drawable.playblack); random.ContentDescription = messages.MessageGuid; random.Click += PlayButton_Clicked; layout3.AddView (random); } } int textt = 0; for (int tt = 0; tt < messages.MessageStepDBList.Count; ++tt) { if (messages.MessageStepDBList [tt].StepType == MessageStep.StepTypes.Text) textt++; } for (int i = 0; i < messages.MessageStepDBList.Count; ++i) { switch (messages.MessageStepDBList [i].StepType) { case LOLMessageDelivery.MessageStep.StepTypes.Text: if (textt == 1) { TextView text = new TextView (context); text.LayoutParameters = new ViewGroup.LayoutParams ((int)ImageHelper.convertDpToPixel (220f, context), (int)ImageHelper.convertDpToPixel (60f, context)); text.SetPadding ((int)ImageHelper.convertDpToPixel (20f, context), 0, (int)ImageHelper.convertDpToPixel (10f, context), 0); text.Gravity = GravityFlags.CenterVertical; if (name == isMe) text.SetBackgroundResource (Resource.Drawable.bubblesolidright); else text.SetBackgroundResource (Resource.Drawable.bubblesolidleft); text.TextSize = 16f; for (int e = 0; e < messages.MessageStepDBList.Count; ++e) { if (!string.IsNullOrEmpty (messages.MessageStepDBList [e].MessageText)) { messager = messages.MessageStepDBList [e].MessageText; break; } } if (string.IsNullOrEmpty (messager)) messager = "No text message found"; int nolines = (int)(ImageHelper.convertDpToPixel ((messager.Length / 27f) * 12f, context)); text.SetHeight (nolines); text.SetTextColor (Android.Graphics.Color.Black); text.Text = messager; layout2.Clickable = true; layout2.AddView (text); } else { if (textt > 1) { using (random = new ImageView (context)) { random.LayoutParameters = new ViewGroup.LayoutParams ((int)ImageHelper.convertDpToPixel (30f, context), (int)ImageHelper.convertDpToPixel (30f, context)); random.SetBackgroundResource (Resource.Drawable.textmsg); layout3.AddView (random); } } } break; case LOLMessageDelivery.MessageStep.StepTypes.Animation: using (random = new ImageView (context)) { random.LayoutParameters = new ViewGroup.LayoutParams ((int)ImageHelper.convertDpToPixel (30f, context), (int)ImageHelper.convertDpToPixel (30f, context)); random.SetBackgroundResource (Resource.Drawable.drawicon); layout3.AddView (random); } break; case LOLMessageDelivery.MessageStep.StepTypes.Comicon: using (random = new ImageView (context)) { random.LayoutParameters = new ViewGroup.LayoutParams ((int)ImageHelper.convertDpToPixel (30f, context), (int)ImageHelper.convertDpToPixel (30f, context)); random.SetBackgroundResource (Resource.Drawable.comicon); layout3.AddView (random); } break; case LOLMessageDelivery.MessageStep.StepTypes.Comix: using (random = new ImageView (context)) { random.LayoutParameters = new ViewGroup.LayoutParams ((int)ImageHelper.convertDpToPixel (30f, context), (int)ImageHelper.convertDpToPixel (30f, context)); random.SetBackgroundResource (Resource.Drawable.comicmsgs); layout3.AddView (random); } break; case LOLMessageDelivery.MessageStep.StepTypes.Emoticon: using (random = new ImageView (context)) { random.LayoutParameters = new ViewGroup.LayoutParams ((int)ImageHelper.convertDpToPixel (30f, context), (int)ImageHelper.convertDpToPixel (30f, context)); random.SetBackgroundResource (Resource.Drawable.emoticonmsg); layout3.AddView (random); } break; case LOLMessageDelivery.MessageStep.StepTypes.Polling: using (random = new ImageView (context)) { random.LayoutParameters = new ViewGroup.LayoutParams ((int)ImageHelper.convertDpToPixel (30f, context), (int)ImageHelper.convertDpToPixel (30f, context)); random.SetBackgroundResource (Resource.Drawable.pollmsg); layout3.AddView (random); } break; case LOLMessageDelivery.MessageStep.StepTypes.SoundFX: using (random = new ImageView (context)) { random.LayoutParameters = new ViewGroup.LayoutParams ((int)ImageHelper.convertDpToPixel (30f, context), (int)ImageHelper.convertDpToPixel (30f, context)); random.SetBackgroundResource (Resource.Drawable.soundfxmsg); layout3.AddView (random); } break; case LOLMessageDelivery.MessageStep.StepTypes.Video: using (random = new ImageView (context)) { random.LayoutParameters = new ViewGroup.LayoutParams ((int)ImageHelper.convertDpToPixel (30f, context), (int)ImageHelper.convertDpToPixel (30f, context)); random.SetBackgroundResource (Resource.Drawable.videomsg); layout3.AddView (random); } break; case LOLMessageDelivery.MessageStep.StepTypes.Voice: using (random = new ImageView (context)) { random.LayoutParameters = new ViewGroup.LayoutParams ((int)ImageHelper.convertDpToPixel (30f, context), (int)ImageHelper.convertDpToPixel (30f, context)); random.SetBackgroundResource (Resource.Drawable.voicemsg); layout3.AddView (random); } break; } } if (name == isMe) { using (random = new ImageView (context)) { random.LayoutParameters = new ViewGroup.LayoutParams ((int)ImageHelper.convertDpToPixel (30f, context), (int)ImageHelper.convertDpToPixel (30f, context)); random.SetBackgroundResource (Resource.Drawable.playblack); random.Click += (object ss, EventArgs ee) => { random_Click (ss, ee, message); }; layout3.AddView (random); } } layout2.AddView (layout3); layout.AddView (layout2); listWrapper.AddView (layout); if (m + 1 < contact.Count) m++; } //} }); if (getGuid.Count > 0) { cpUI = 0; LOLConnectClient service = new LOLConnectClient (LOLConstants.DefaultHttpBinding, LOLConstants.LOLConnectEndpoint); service.UserGetImageDataCompleted += Service_UserGetImageDataCompleted; service.UserGetImageDataAsync (AndroidData.CurrentUser.AccountID, getGuid [0], new Guid (AndroidData.ServiceAuthToken)); } } }
public Android.Views.View GetInfoWindow (Marker marker) { var textView = new TextView (Application.Context); textView.Text = marker.Title; textView.SetBackgroundResource (Resource.Drawable.undo_bar_bg); var padding = Application.Context.Resources.GetDimensionPixelSize (Resource.Dimension.default_text_padding); textView.SetPadding (padding, padding, padding, padding); textView.SetTextColor (Application.Context.Resources.GetColor (Android.Resource.Color.White)); return textView; }
private TextView messageTextBox(MessageDB message, int position, int leftOver) { TextView txtMessage = new TextView (context); using (LinearLayout.LayoutParams txtMessageParams = new LinearLayout.LayoutParams (leftOver, (int)ImageHelper.convertDpToPixel (60f, context))) { txtMessageParams.SetMargins ((int)ImageHelper.convertDpToPixel (10f, context), 0, 0, 0); txtMessage.LayoutParameters = txtMessageParams; } txtMessage.SetPadding ((int)ImageHelper.convertDpToPixel (20f, context), (int)ImageHelper.convertDpToPixel (10f, context), (int)ImageHelper.convertDpToPixel (20f, context), (int)ImageHelper.convertDpToPixel (10f, context)); txtMessage.Gravity = GravityFlags.CenterVertical; txtMessage.SetBackgroundResource (Resource.Drawable.bubblesolidleft); txtMessage.TextSize = 16f; if (position < message.MessageStepDBList.Count) { if (string.IsNullOrEmpty (message.MessageStepDBList [position].MessageText)) txtMessage.Text = ""; else txtMessage.Text = message.MessageStepDBList [position].MessageText; } int nolines = (int)(ImageHelper.convertDpToPixel ((txtMessage.Text.Length / 27f) * 12f, context)); txtMessage.SetHeight (nolines); txtMessage.SetTextColor (Android.Graphics.Color.Black); return txtMessage; }
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { RelativeLayout pagecontainder = new RelativeLayout (nn_activity); pagecontainder.LayoutParameters = new RelativeLayout.LayoutParams (RelativeLayout.LayoutParams.MatchParent, RelativeLayout.LayoutParams.WrapContent); ImageView leftarrowimg = new ImageView (nn_activity); RelativeLayout.LayoutParams leftarrowimgparam = new RelativeLayout.LayoutParams (TapUtil.dptodx(32),TapUtil.dptodx(32)); leftarrowimgparam.AddRule (LayoutRules.AlignParentLeft); leftarrowimgparam.AddRule (LayoutRules.CenterVertical); leftarrowimg.SetImageResource (Resource.Drawable.ic_indicatorarrowleft); leftarrowimg.Alpha = 0.5f; leftarrowimg.Clickable = true; leftarrowimg.LayoutParameters = leftarrowimgparam; leftarrowimg.Click -= OnLeftArrowClick; leftarrowimg.Click += OnLeftArrowClick; ImageView rightarrowimg = new ImageView (nn_activity); RelativeLayout.LayoutParams rightarrowimgparam = new RelativeLayout.LayoutParams (TapUtil.dptodx(32),TapUtil.dptodx(32)); rightarrowimgparam.AddRule (LayoutRules.AlignParentRight); rightarrowimgparam.AddRule (LayoutRules.CenterVertical); rightarrowimg.SetImageResource (Resource.Drawable.ic_indicatorarrowright); rightarrowimg.Alpha = 0.5f; rightarrowimg.Clickable = true; rightarrowimg.LayoutParameters = rightarrowimgparam; rightarrowimg.Click -= OnRightArrowClick; rightarrowimg.Click += OnRightArrowClick; RelativeLayout headercontainer = new RelativeLayout (nn_activity); RelativeLayout.LayoutParams headercontainerlayout=new RelativeLayout.LayoutParams (RelativeLayout.LayoutParams.MatchParent,RelativeLayout.LayoutParams.WrapContent); headercontainer.LayoutParameters = headercontainerlayout; headercontainer.Id = TapUtil.generateViewId (); headercontainer.SetPadding (TapUtil.dptodx(30),TapUtil.dptodx(10),TapUtil.dptodx(30),TapUtil.dptodx(0)); eventimagview = new ImageView (nn_activity); RelativeLayout.LayoutParams eventimagviewlayoutparam = new RelativeLayout.LayoutParams (TapUtil.dptodx(40),TapUtil.dptodx(40)); eventimagviewlayoutparam.AddRule (LayoutRules.CenterVertical); eventimagview.LayoutParameters = eventimagviewlayoutparam; eventimagview.SetImageResource (TapUtil.defaulticon); eventimagview.Id = TapUtil.generateViewId (); eventimagview.Background = new BitmapDrawable (Resources, nn_goalcard.ornanizationbitmap); LinearLayout headerlinearlayout = new LinearLayout (nn_activity); RelativeLayout.LayoutParams headerlayoutparam = new RelativeLayout.LayoutParams (RelativeLayout.LayoutParams.MatchParent,RelativeLayout.LayoutParams.WrapContent); headerlayoutparam.AddRule (LayoutRules.RightOf, eventimagview.Id); headerlayoutparam.LeftMargin = TapUtil.dptodx (5); headerlinearlayout.LayoutParameters = headerlayoutparam; headerlinearlayout.Orientation = Orientation.Vertical; eventnametextview = new TextView (nn_activity); LinearLayout.LayoutParams eventnametextviewparam = new LinearLayout.LayoutParams (LinearLayout.LayoutParams.WrapContent,LinearLayout.LayoutParams.WrapContent); eventnametextview.Text="eventname"; eventnametextview.Typeface = Typeface.DefaultBold; eventnametextview.TextSize = TapUtil.dptodx(8); eventnametextview.Gravity = GravityFlags.Center; eventnametextviewparam.Gravity = GravityFlags.Center; eventnametextview.Text = nn_goalcard.eventinfo.event_name; eventnametextview.LayoutParameters = eventnametextviewparam; organizationnametextview = new TextView (nn_activity); LinearLayout.LayoutParams organizationnametextviewparam = new LinearLayout.LayoutParams (LinearLayout.LayoutParams.WrapContent,LinearLayout.LayoutParams.WrapContent); organizationnametextviewparam.Gravity = GravityFlags.Center; organizationnametextview.Text="orgination"; organizationnametextview.Typeface = Typeface.DefaultBold; organizationnametextview.TextSize = TapUtil.dptodx(6); organizationnametextview.LayoutParameters = organizationnametextviewparam; organizationnametextview.Text = nn_goalcard.eventinfo.organization; organizationnametextview.InputType = global::Android.Text.InputTypes.TextFlagMultiLine; headerlinearlayout.AddView (eventnametextview); headerlinearlayout.AddView (organizationnametextview); headercontainer.AddView (eventimagview); headercontainer.AddView (headerlinearlayout); pagecontainder.AddView (headercontainer); scrollerview = new ScrollView (nn_activity); RelativeLayout.LayoutParams scollviewparam=new RelativeLayout.LayoutParams (RelativeLayout.LayoutParams.MatchParent,RelativeLayout.LayoutParams.MatchParent); scollviewparam.AddRule (LayoutRules.Below, headercontainer.Id); scollviewparam.TopMargin = TapUtil.dptodx (20); scrollerview.LayoutParameters = scollviewparam; RelativeLayout slideritemcontainer = new RelativeLayout (nn_activity); slideritemcontainer.LayoutParameters=new ScrollView.LayoutParams ( ScrollView.LayoutParams.MatchParent,ScrollView.LayoutParams.WrapContent); slideritemcontainer.SetPadding (TapUtil.dptodx(30),TapUtil.dptodx(10),TapUtil.dptodx(30),TapUtil.dptodx(10)); try{ DateTime eventEndTime=DateTime.ParseExact (nn_goalcard.eventinfo.event_end_time.Substring (0, 19), "yyyy-MM-ddTHH:mm:ss", null); hours=(eventEndTime-DateTime.Now).TotalHours; } catch{ hours = 0; } daybartextview = new TextView (nn_activity); int leftday = (int)hours / 24; int lefthours = (int)hours % 24; daybartextview.Text = string.Format (" "+leftday+" Days,"+" "+lefthours+" Hours"); daybartextview.Gravity = GravityFlags.Center; daybartextview.Typeface = Typeface.DefaultBold; daybartextview.SetBackgroundResource(Resource.Color.iosblue); daybartextview.TextSize = TapUtil.dptodx (8); daybartextview.SetTextColor (Color.White); daybartextview.Id = TapUtil.generateViewId (); RelativeLayout.LayoutParams daybartextviewparam=new RelativeLayout.LayoutParams (RelativeLayout.LayoutParams.MatchParent,RelativeLayout.LayoutParams.WrapContent); daybartextview.LayoutParameters = daybartextviewparam; slideritemcontainer.AddView (daybartextview); circlepanelrealtivelayout = new RelativeLayout (nn_activity); circlepanelrealtivelayout.SetBackgroundResource (Resource.Drawable.bg_relativelayout_grayround); circlepanelrealtivelayout.Id = TapUtil.generateViewId (); RelativeLayout.LayoutParams circlepanelparam=new RelativeLayout.LayoutParams (RelativeLayout.LayoutParams.MatchParent,RelativeLayout.LayoutParams.WrapContent); circlepanelparam.TopMargin=TapUtil.dptodx(20); circlepanelparam.AddRule (LayoutRules.Below, daybartextview.Id); circlepanelrealtivelayout.LayoutParameters= circlepanelparam; circlepanelrealtivelayout.SetPadding (TapUtil.dptodx (5), TapUtil.dptodx (5), TapUtil.dptodx (5), TapUtil.dptodx (5)); personalprogresslabel = new TextView (nn_activity); personalprogresslabel.Text=GoalScreenData.personalProgressLabelText; RelativeLayout.LayoutParams personalprogresslabelparam=new RelativeLayout.LayoutParams (RelativeLayout.LayoutParams.MatchParent,RelativeLayout.LayoutParams.WrapContent); personalprogresslabel.LayoutParameters = personalprogresslabelparam; personalprogresslabel.Gravity = GravityFlags.Center; personalprogresslabel.Typeface = Typeface.DefaultBold; personalprogresslabel.Id = TapUtil.generateViewId (); goalslinearlayout = new LinearLayout (nn_activity); RelativeLayout.LayoutParams goalslayoutparam=new RelativeLayout.LayoutParams (RelativeLayout.LayoutParams.MatchParent,RelativeLayout.LayoutParams.WrapContent); goalslayoutparam.AddRule (LayoutRules.Below, personalprogresslabel.Id); goalslayoutparam.TopMargin = TapUtil.dptodx (10); goalslinearlayout.LayoutParameters = goalslayoutparam; goalslinearlayout.Orientation = Orientation.Horizontal; goalslinearlayout.Id = TapUtil.generateViewId (); int peronalrise = 0; int goalamount = 0; if (!string.IsNullOrEmpty(nn_goalcard.eventinfo.gross_sales) ) { peronalrise = Int32.Parse(nn_goalcard.eventinfo.gross_sales); } if(!string.IsNullOrEmpty(nn_goalcard.eventinfo.seller_goal)){ goalamount = Int32.Parse(nn_goalcard.eventinfo.seller_goal); } LinearLayout raisedlinearlayout = new LinearLayout (nn_activity); raisedlinearlayout.Orientation = Orientation.Vertical; LinearLayout.LayoutParams raisedlayoutparam = new LinearLayout.LayoutParams (LinearLayout.LayoutParams.MatchParent,TapUtil.dptodx(40)); raisedlayoutparam.Weight = 1; raisedlinearlayout.LayoutParameters = raisedlayoutparam; railedpricetextview = new TextView (nn_activity); railedpricetextview.Text = "$"+peronalrise; railedpricetextview.LayoutParameters =new RelativeLayout.LayoutParams (RelativeLayout.LayoutParams.MatchParent,TapUtil.dptodx(20)); railedpricetextview.Gravity = GravityFlags.Center; TextView railedpricelabel = new TextView (nn_activity); railedpricelabel.Text = GoalScreenData.raiseToDateText; railedpricelabel.LayoutParameters=new RelativeLayout.LayoutParams (RelativeLayout.LayoutParams.MatchParent,TapUtil.dptodx(20)); railedpricelabel.Gravity = GravityFlags.Center; raisedlinearlayout.AddView (railedpricetextview); raisedlinearlayout.AddView (railedpricelabel); LinearLayout goalslinearlayoutseprater = new LinearLayout (nn_activity); goalslinearlayoutseprater.LayoutParameters=new LinearLayout.LayoutParams (TapUtil.dptodx(1),TapUtil.dptodx(40)); goalslinearlayoutseprater.SetBackgroundColor (Color.LightGray); LinearLayout goalamoutlinearlayout = new LinearLayout (nn_activity); goalamoutlinearlayout.Orientation = Orientation.Vertical; LinearLayout.LayoutParams goalnumlayoutparam = new LinearLayout.LayoutParams (LinearLayout.LayoutParams.MatchParent,TapUtil.dptodx(40)); goalnumlayoutparam.Weight = 1; goalamoutlinearlayout.LayoutParameters = goalnumlayoutparam; goalsamounttextview = new TextView (nn_activity); goalsamounttextview.Text = "$"+goalamount; goalsamounttextview.LayoutParameters=new RelativeLayout.LayoutParams (RelativeLayout.LayoutParams.MatchParent,TapUtil.dptodx(20)); goalsamounttextview.Gravity = GravityFlags.Center; TextView goalsamountlabel = new TextView (nn_activity); goalsamountlabel.Text = GoalScreenData.goalAmountText; goalsamountlabel.LayoutParameters=new RelativeLayout.LayoutParams (RelativeLayout.LayoutParams.MatchParent,TapUtil.dptodx(20)); goalsamountlabel.Gravity = GravityFlags.Center; goalamoutlinearlayout.AddView (goalsamounttextview); goalamoutlinearlayout.AddView (goalsamountlabel); goalslinearlayout.AddView (raisedlinearlayout); goalslinearlayout.AddView (goalslinearlayoutseprater); goalslinearlayout.AddView (goalamoutlinearlayout); int circlewidthdp = 200; int progresswidthdp = 20; int stokewidth = 2; decimal percent=(decimal)0; if (!string.IsNullOrEmpty(nn_goalcard.eventinfo.gross_sales) && !string.IsNullOrEmpty(nn_goalcard.eventinfo.seller_goal)) { if (peronalrise < 0 | goalamount < 0) { percent = 0; }else if(peronalrise>=goalamount){ percent = 1; }else if(peronalrise<goalamount){ percent = (decimal)peronalrise / goalamount; } } //rounded layout circlecontainter = new RelativeLayout (nn_activity); RelativeLayout.LayoutParams circlecontainterlayoutparam=new RelativeLayout.LayoutParams (TapUtil.dptodx(circlewidthdp),TapUtil.dptodx(circlewidthdp)); circlecontainterlayoutparam.AddRule (LayoutRules.Below, goalslinearlayout.Id); circlecontainterlayoutparam.AddRule (LayoutRules.CenterHorizontal); circlecontainterlayoutparam.TopMargin = TapUtil.dptodx (20); circlecontainter.LayoutParameters = circlecontainterlayoutparam; stokerelativelayout = new AvatarProgressRelativeLayout (nn_activity,circlewidthdp,progresswidthdp,stokewidth,Convert.ToSingle(percent)); stokerelativelayout.Invalidate (); //content inside innercircle RelativeLayout imgtextcontainter = new RelativeLayout (nn_activity); RelativeLayout.LayoutParams imgtextcontainterlayoutparam=new RelativeLayout.LayoutParams (RelativeLayout.LayoutParams.MatchParent,RelativeLayout.LayoutParams.MatchParent); imgtextcontainterlayoutparam.AddRule(LayoutRules.CenterHorizontal); imgtextcontainter.LayoutParameters = imgtextcontainterlayoutparam; imgtextcontainter.SetPadding (TapUtil.dptodx (stokerelativelayout.progresswidthdp*2), TapUtil.dptodx (stokerelativelayout.progresswidthdp*2), TapUtil.dptodx (stokerelativelayout.progresswidthdp*2), TapUtil.dptodx (stokerelativelayout.progresswidthdp*2)); ImageView imagview = new ImageView (nn_activity); imagview.SetImageResource (Resource.Drawable.Goals_Avatar_Person); imagview.LayoutParameters = new RelativeLayout.LayoutParams (RelativeLayout.LayoutParams.MatchParent,TapUtil.dptodx(Convert.ToSingle(circlewidthdp*0.4))); imagview.Id = TapUtil.generateViewId (); textview = new TextView (nn_activity); RelativeLayout.LayoutParams textlayoutparam = new RelativeLayout.LayoutParams (RelativeLayout.LayoutParams.MatchParent, TapUtil.dptodx (Convert.ToSingle(circlewidthdp * 0.1))); textlayoutparam.AddRule (LayoutRules.Below, imagview.Id); textview.Gravity = GravityFlags.Center; textview.LayoutParameters = textlayoutparam; textview.Id = TapUtil.generateViewId (); textview.Text=Math.Round(percent*100)+"%"; textview.Typeface=Typeface.DefaultBold; clicktoseeprizetextview = new TextView (nn_activity); RelativeLayout.LayoutParams clicktoseeprizetextviewlayoutparam = new RelativeLayout.LayoutParams (RelativeLayout.LayoutParams.MatchParent, TapUtil.dptodx (Convert.ToSingle(circlewidthdp * 0.1))); clicktoseeprizetextviewlayoutparam.AddRule (LayoutRules.Below, textview.Id); clicktoseeprizetextview.Gravity = GravityFlags.Center; clicktoseeprizetextview.LayoutParameters = clicktoseeprizetextviewlayoutparam; clicktoseeprizetextview.Id = TapUtil.generateViewId (); clicktoseeprizetextview.Text=GoalScreenData.clickToSeeGoalPrizeLabel; clicktoseeprizetextview.Typeface=Typeface.DefaultBold; clicktoseeprizetextview.TextSize = TapUtil.dptodx (3); clicktoseeprizetextview.SetTextColor (Resources.GetColor(Resource.Color.iosblue)); clicktoseeprizetextview.Visibility = ViewStates.Gone; imgtextcontainter.AddView (imagview); imgtextcontainter.AddView (textview); imgtextcontainter.AddView (clicktoseeprizetextview); circlecontainter.AddView (stokerelativelayout); circlecontainter.AddView (imgtextcontainter); circlepanelrealtivelayout.AddView (personalprogresslabel); circlepanelrealtivelayout.AddView (goalslinearlayout); circlepanelrealtivelayout.AddView (circlecontainter); prizeinfocontainer = new RelativeLayout (nn_activity); prizeinfocontainer.LayoutParameters=new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MatchParent,RelativeLayout.LayoutParams.MatchParent); prizeinfocontainer.Visibility=ViewStates.Invisible; prizeinfocontainer.Tag=0; prizetextview = new TextView (nn_activity); RelativeLayout.LayoutParams prizelayoutparam=new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MatchParent,RelativeLayout.LayoutParams.WrapContent); prizelayoutparam.AddRule (LayoutRules.CenterHorizontal); prizelayoutparam.TopMargin = TapUtil.dptodx (10); prizetextview.Gravity = GravityFlags.Center; prizetextview.LayoutParameters = prizelayoutparam; prizetextview.Text=nn_goalcard.eventinfo.seller_prize_description; prizetextview.Id = TapUtil.generateViewId (); prizeimage=new ImageView(nn_activity); RelativeLayout.LayoutParams prizeimageparam=new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MatchParent,RelativeLayout.LayoutParams.MatchParent); prizeimageparam.AddRule (LayoutRules.Below, prizetextview.Id); prizeimage.LayoutParameters = prizeimageparam; prizelayoutparam.AddRule (LayoutRules.CenterHorizontal); prizeinfocontainer.AddView (prizetextview); prizeinfocontainer.AddView (prizeimage); circlepanelrealtivelayout.AddView (prizeinfocontainer); slideritemcontainer.AddView (circlepanelrealtivelayout); //add leaderboard RelativeLayout leaderboardrelativelayout = new RelativeLayout (nn_activity); leaderboardrelativelayout.SetBackgroundResource (Resource.Drawable.bg_relativelayout_grayround); leaderboardrelativelayout.Id = TapUtil.generateViewId (); RelativeLayout.LayoutParams leaderboardparam=new RelativeLayout.LayoutParams (RelativeLayout.LayoutParams.MatchParent,RelativeLayout.LayoutParams.WrapContent); leaderboardparam.TopMargin=TapUtil.dptodx(20); leaderboardparam.AddRule (LayoutRules.Below, circlepanelrealtivelayout.Id); leaderboardrelativelayout.LayoutParameters= leaderboardparam; leaderboardrelativelayout.SetPadding (TapUtil.dptodx (5), TapUtil.dptodx (5), TapUtil.dptodx (5), TapUtil.dptodx (5)); ListView leaderboardlistview = new ListView (nn_activity); leaderboardlistview.LayoutParameters=new RelativeLayout.LayoutParams (RelativeLayout.LayoutParams.MatchParent,0); leaderboardlistview.Adapter = leaderboardadapter; leaderboardrelativelayout.AddView (leaderboardlistview); setListViewHeightBasedOnItems (leaderboardlistview); slideritemcontainer.AddView (leaderboardrelativelayout); scrollerview.AddView (slideritemcontainer); pagecontainder.AddView (scrollerview); pagecontainder.AddView (leftarrowimg); pagecontainder.AddView (rightarrowimg); return pagecontainder; }
public override Java.Lang.Object InstantiateItem(ViewGroup container, int position) { TextView v = new TextView(_activity); v.SetBackgroundResource(Resource.Color.background_window); v.Text = string.Format("PAGE {0}", position + 1); int padding = (int)TypedValue.ApplyDimension(ComplexUnitType.Dip, 16, _activity.Resources.DisplayMetrics); v.SetPadding(padding, padding, padding, padding); v.Gravity = GravityFlags.Center; container.AddView(v, 0); return v; }
/// <summary> /// ������ϷTitle�Ͷ�Ӧʡ���б� /// </summary> public void SetGameTitle() { txtTitle.Text = Barrier.Title; List<Barrier> list = ShengDaoList.ToList(); list.Sort(delegate(Barrier a, Barrier b) { return (new Random()).Next(-1, 1); }); glShengList.RemoveAllViews(); foreach (var item in list) { TextView textView = new TextView(this); GridLayout.LayoutParams m = new GridLayout.LayoutParams(); m.Width = GridLayout.LayoutParams.WrapContent; m.Height = GridLayout.LayoutParams.WrapContent; if (Resources.DisplayMetrics.Density == 1) { m.SetMargins(10, 10, 10, 10); textView.SetTextSize(Android.Util.ComplexUnitType.Sp, 22); } else { m.SetMargins(5, 5, 5, 5); } textView.LayoutParameters = m; textView.SetTextColor(Android.Graphics.Color.White); textView.SetBackgroundResource(Resource.Drawable.game_sheng); textView.Gravity = GravityFlags.Center; textView.Text = item.Name; textView.Id = item.Id; textView.SetOnClickListener(this); glShengList.AddView(textView); } switch (Barrier.Id) { case 0: imgPeople.SetImageResource(Resource.Drawable.game_people_jian); break; case 1: imgPeople.SetImageResource(Resource.Drawable.game_people_ling); break; case 2: imgPeople.SetImageResource(Resource.Drawable.game_people_qian); break; case 3: imgPeople.SetImageResource(Resource.Drawable.game_people_yao); break; case 4: imgPeople.SetImageResource(Resource.Drawable.game_people_ye); break; } }