}//把时间设定为系统时间 public void SetTime() { DateTime time = new DateTime(year, month, day, hour, minute, 20); TimeText.Text = year.ToString() + "年" + month.ToString() + "月" + day.ToString() + "日 " + hour.ToString() + ":" + minute.ToString(); var 冬Weeks = TimeTools.计算冬的周(time); var 夏Weeks = TimeTools.计算夏的周(time); if (冬Weeks <= 20) { WeekText.Text = "第" + 冬Weeks.ToString() + "周 " + NumberToWeekChinese(Convert.ToInt16(time.DayOfWeek.ToString("D"))); } else if (夏Weeks < 1) { WeekText.Text = "距离开学还有" + (TimeTools.计算本学期夏开学时间(time) - time).Days / 7 + "周"; } else if (夏Weeks <= 20) { WeekText.Text = "第" + 夏Weeks.ToString() + "周 " + NumberToWeekChinese(Convert.ToInt16(time.DayOfWeek.ToString("D"))); } else { WeekText.Text = "距离开学还有" + (TimeTools.计算本学期冬开学时间(time).AddYears(1) - time).Days / 7 + "周"; } searchRoom.ResetShowDatas(this); //显示数据应用更改 roomlist_adapter.NotifyDataSetChanged(); //显示数据刷新 }//应用更改的时间并更新显示的数据
public Condition(Context context, SearchRoom searchRoom, RecyclerView.Adapter roomlist_adapter) { this.context = context; this.searchRoom = searchRoom; this.roomlist_adapter = roomlist_adapter; #region 中二病 TextView 中二病 = ((Activity)context).FindViewById <TextView>(Resource.Id.中二病Text); ImageView 中二病imageView = ((Activity)context).FindViewById <ImageView>(Resource.Id.中二病imageView); ImageView LeftMenuHead = ((Activity)context).FindViewById <ImageView>(Resource.Id.imageButton1); 中二病imageView.Click += 中二病imageView_Click; 中二病.Click += 中二病imageView_Click; void 中二病imageView_Click(object sender, EventArgs e) { if (中二病Flag) { 中二病.Text = "普通模式"; 中二病Flag = false; LeftMenuHead.SetImageDrawable(context.GetDrawable(Resource.Drawable.ic_launcher_foreground_HD)); SetTime(); } else { 中二病.Text = "中二病模式"; 中二病Flag = true; LeftMenuHead.SetImageDrawable(context.GetDrawable(Resource.Drawable.APPButtonImage)); SetTime(); } } #endregion #region 监听时间改变 var intentFilter = new IntentFilter(); intentFilter.AddAction(Intent.ActionTimeTick);//每分钟变化 TimeChangeReceiver timeChangeReceiver = new TimeChangeReceiver(); context.RegisterReceiver(timeChangeReceiver, intentFilter); timeChangeReceiver.condition = this; #endregion #region 空教室 EmptyRoomSwitch = ((Activity)context).FindViewById <LinearLayout>(Resource.Id.EmptyRoomSwitch); EmptyRoomText = ((Activity)context).FindViewById <TextView>(Resource.Id.EmptyRoomText); EmptyRoomSwitch.Click += (sender, args) => { if (EmptyRoomFlag) { EmptyRoomFlag = false; EmptyRoomText.Text = "全部教室"; } else { EmptyRoomFlag = true; EmptyRoomText.Text = "空教室"; } searchRoom.ResetShowDatas(this); //显示数据应用更改 roomlist_adapter.NotifyDataSetChanged(); //显示数据刷新 }; #endregion #region 时间 TimeLockButton = ((Activity)context).FindViewById <Button>(Resource.Id.TimeLockButton); WeekText = ((Activity)context).FindViewById <TextView>(Resource.Id.WeekText); TimeText = ((Activity)context).FindViewById <TextView>(Resource.Id.TimeText); SetTimeToNow(); //初始化时间 SetTime(); //应用更改 WeekText.Click += (sender, args) => { ChangeWeek(); };//改变周 TimeText.Click += (sender, args) => { ChangeTime(); };//改变时间 #endregion }