本文整理汇总了C#中Post.IsExpired方法的典型用法代码示例。如果您正苦于以下问题:C# Post.IsExpired方法的具体用法?C# Post.IsExpired怎么用?C# Post.IsExpired使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Post
的用法示例。
在下文中一共展示了Post.IsExpired方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BindDataToCell
public void BindDataToCell (Post post)
{
CellUserImageButton.SetUserImage(post.userPoster);
CellUsernameLabel.SetTitle (post.userPoster.username);
CellCaptionTextView.AttributedText = NativeStringUtils.ParseStringForKeywords (post, post.text);
CellLikeButton.SetImage((post.liked) ? UIImage.FromBundle("LikeSelected") : UIImage.FromBundle("Like"));
CellRepostButton.SetImage((post.isReposted) ? UIImage.FromBundle("RepostSelected") : UIImage.FromBundle("Repost"));
CellCommentButton.Image = (post.commented) ? UIImage.FromBundle ("CommentSelected") : UIImage.FromBundle("Comment");
if (post.userPoster.IsMe()) {
CellLikeButton.Hidden = true;
CellRepostButton.Hidden = true;
} else {
CellLikeButton.Hidden = false;
CellRepostButton.Hidden = false;
}
CellRepostButton.Enabled = !post.userPoster.isprivate;
if (post.userReposter != null)
{
CellRepostedLabel.Hidden = false;
CellRepostedLabel.SetTitle((post.userReposter.IsMe()) ? "by you" : "by " + post.userReposter.username);
}
else
{
CellRepostedLabel.Hidden = true;
CellRepostedLabel.SetTitle("");
}
CellTimeElapsedLabel.Text = StringUtils.GetPrettyDateAbs (post.datestamp);
if (post.IsExpired ()) {
CellTimeRemaining.Expire(StringUtils.GetTopTime(post));
CellClockImage.Hidden = true;
} else {
CellTimeRemaining.Live(StringUtils.GetPrettyDateAbs(post.expiration), ViewUtils.GetTimeRemainingColor(post.expiration));
CellClockImage.Hidden = false;
if (post.userPoster.username.ToLower() != Globe.SharedInstance.User.username.ToLower())
{
CellLikeButton.Hidden = false;
CellRepostButton.Hidden = false;
}
}
}
示例2: SetTimeRemaining
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;
}
}
示例3: BindDataToCell
public void BindDataToCell(Post post, UITableView tableView, NSIndexPath indexPath)
{
CellActivityIndicator.Hidden = false;
CellActivityIndicator.StartAnimating();
CellPostImageImage.Layer.CornerRadius = 8;
CellPostImageImage.ClipsToBounds = true;
CellPostImageImage.SetImage(NSUrl.FromString(StringUtils.GetPostImageURL(post)), null, delegate (UIImage image, NSError error, SDImageCacheType cacheType, NSUrl imageUrl)
{
if (image != null)
{
if (post.ImageHeight <= 0)
{
UIImage test = ImageUtils.ScaleImageToWidth(image, (float)Math.Min((float)tableView.Frame.Size.Width - 16, (float)(image.Size.Width * image.CurrentScale)));
if (test != null)
{
post.ImageHeight = (float)test.Size.Height;
}
}
CellPostImageHeight.Constant = post.ImageHeight;
SetNeedsLayout();
if (cacheType != SDImageCacheType.Memory)
{
if (Array.IndexOf(tableView.IndexPathsForVisibleRows, indexPath) > -1)
{
tableView.BeginUpdates();
tableView.ReloadRows(new NSIndexPath[1] { indexPath }, UITableViewRowAnimation.Automatic);
tableView.EndUpdates();
}
}
}
CellActivityIndicator.Hidden = true;
});
CellUserImageButton.SetUserImage(post.userPoster);
CellUsernameLabel.SetTitle(post.userPoster.username);
CellCaptionTextView.AttributedText = NativeStringUtils.ParseStringForKeywords(post, post.text);
CellLikeButton.SetImage((post.liked) ? UIImage.FromBundle("LikeSelected") : UIImage.FromBundle("Like"));
CellRepostButton.SetImage((post.isReposted) ? UIImage.FromBundle("RepostSelected") : UIImage.FromBundle("Repost"));
CellCommentButton.Image = (post.commented) ? UIImage.FromBundle("CommentSelected") : UIImage.FromBundle("Comment");
if (post.userPoster.IsMe())
{
CellLikeButton.Hidden = true;
CellRepostButton.Hidden = true;
}
else {
CellLikeButton.Hidden = false;
CellRepostButton.Hidden = false;
}
CellRepostButton.Enabled = !post.userPoster.isprivate;
if (post.userReposter != null)
{
CellRepostedLabel.Hidden = false;
CellRepostedLabel.SetTitle((post.userReposter.IsMe()) ? "by you" : "by " + post.userReposter.username);
}
else
{
CellRepostedLabel.Hidden = true;
CellRepostedLabel.SetTitle("");
}
CellTimeElapsedLabel.Text = StringUtils.GetPrettyDateAbs(post.datestamp);
if (post.IsExpired())
{
CellTimeRemaining.Expire(StringUtils.GetTopTime(post));
CellClockImage.Hidden = true;
}
else {
CellTimeRemaining.Live(StringUtils.GetPrettyDateAbs(post.expiration), ViewUtils.GetTimeRemainingColor(post.expiration));
CellClockImage.Hidden = false;
if (post.userPoster.username.ToLower() != Globe.SharedInstance.User.username.ToLower())
{
CellLikeButton.Hidden = false;
CellRepostButton.Hidden = false;
}
}
}
示例4: LikePost
public static async Task<bool> LikePost(Post post, UIButton likeButton, UITableView tableView = null, NSIndexPath indexPath = null)
{
if (post.liked || post.IsExpired())
{
return false;
}
likeButton.SetImage(UIImage.FromBundle("LikeSelected"), UIControlState.Normal);
likeButton.SetImage(UIImage.FromBundle("LikeSelected"), UIControlState.Highlighted);
likeButton.SetImage(UIImage.FromBundle("LikeSelected"), UIControlState.Selected);
UIView.Animate(.3, delegate
{
likeButton.Transform = CoreGraphics.CGAffineTransform.MakeScale((nfloat)1.7, (nfloat)1.7);
}, delegate
{
likeButton.Transform = CoreGraphics.CGAffineTransform.MakeScale((nfloat)1, (nfloat)1);
});
if (post.userPoster.idUser != Globe.SharedInstance.User.idUser)
{
post.liked = true;
post.expiration = post.expiration + 60000;
likeButton.SetImage(UIImage.FromBundle("LikeSelected"), UIControlState.Normal);
likeButton.SetImage(UIImage.FromBundle("LikeSelected"), UIControlState.Highlighted);
likeButton.SetImage(UIImage.FromBundle("LikeSelected"), UIControlState.Selected);
AVAudioSession audioSession = AVAudioSession.SharedInstance();
NSError error = audioSession.SetCategory(AVAudioSessionCategory.Ambient, AVAudioSessionCategoryOptions.MixWithOthers);
audioSession.SetActive(true, out error);
AVAudioPlayer player = new AVAudioPlayer(new NSUrl("ticksound.m4a"), "m4a", out error);
player.NumberOfLoops = 1;
player.Play();
player.FinishedPlaying += (sender, e) =>
{
player.Stop();
player = null;
};
try
{
bool result = await TenServices.LikePost(post);
if (!result)
{
post.liked = false;
likeButton.SetImage(UIImage.FromBundle("Like"), UIControlState.Normal);
likeButton.SetImage(UIImage.FromBundle("Like"), UIControlState.Highlighted);
likeButton.SetImage(UIImage.FromBundle("Like"), UIControlState.Selected);
}
else {
if (tableView != null && indexPath != null)
{
tableView.ReloadRows(new NSIndexPath[] { indexPath }, UITableViewRowAnimation.None);
}
}
return result;
}
catch (RESTError)
{
post.liked = false;
likeButton.SetImage(UIImage.FromBundle("Like"), UIControlState.Normal);
likeButton.SetImage(UIImage.FromBundle("Like"), UIControlState.Highlighted);
likeButton.SetImage(UIImage.FromBundle("Like"), UIControlState.Selected);
}
finally
{
if (!post.liked)
{
post.expiration = post.expiration - 60000;
}
}
}
return false;
}