public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = (View) inflater.Inflate(Resource.Layout.ShiPinChaGnagJieGuo,container, false); Activity.Window.SetSoftInputMode (SoftInput.AdjustPan); //SetHasOptionsMenu(true); mHuoJingLiShiListView = view.FindViewById<ListView> (Resource.Id.HuoJingLiShi_listViewSP); mHeaderDanWeiMingCheng = view.FindViewById<TextView> (Resource.Id.txtHeaderDanWeiMingChengSP); mBtnHuoJingLiShiLastPage = view.FindViewById<Button> (Resource.Id.btnHuoJingLiShiLastPageSP); mBtnHuoJingLiShiNextPage = view.FindViewById<Button> (Resource.Id.btnHuoJingLiShiNextPageSP); mTxtHuoJingLiSHiPageToGo = view.FindViewById<EditText> (Resource.Id.txtHuoJingLiShiPageToGoSP); mbtnHuoJingLiSHiPageToGo = view.FindViewById<Button> (Resource.Id.btnHuoJingLiShiPageToGoSP); TiaoJian1 = view.FindViewById<TextView> (Resource.Id.ShiPinJieGuoTiaoJian1); TiaoJian2 = view.FindViewById<TextView> (Resource.Id.ShiPinJieGuoTiaoJian2); TiaoJian3 = view.FindViewById<TextView> (Resource.Id.ShiPinJieGuoTiaoJian3); TiaoJian4 = view.FindViewById<TextView> (Resource.Id.ShiPinJieGuoTiaoJian4); if (logInDialogCreate.mLoginInfo.dwmc.Length > 8) { mHeaderDanWeiMingCheng.Text = logInDialogCreate.mLoginInfo.dwmc.Substring (0, 8); } else { mHeaderDanWeiMingCheng.Text = logInDialogCreate.mLoginInfo.dwmc; } mProgressBar = view.FindViewById<ProgressBar> (Resource.Id.progressBar); mProgressBar.Visibility = ViewStates.Visible; switch (chaGangZhuangTai) { case "0": TiaoJian1.Text="查岗状态 :"+"等待"; break; case "1": TiaoJian1.Text="查岗状态 :"+"在岗"; break; case "2": TiaoJian1.Text="查岗状态 :"+"缺岗"; break; case "3": TiaoJian1.Text="查岗状态 :"+"断线"; break; } if (beginDate != "") { BeginTimeString = beginDate.Replace ("年", "-").Replace ("月", "-").Replace ("日", ""); dateBegin = BeginTimeString; } else { BeginTimeString="全部"; dateBegin = ""; } if (endDate != "") { EndTimestring = endDate.Replace ("年", "-").Replace ("月", "-").Replace ("日", ""); dateEnd = EndTimestring; } else { EndTimestring="全部"; dateEnd = ""; } TiaoJian3.Text ="开始时间:" + BeginTimeString; TiaoJian4.Text ="结束时间:" + EndTimestring; animationfadeIn = new AlphaAnimation(0.0f, 1.0f); animationfadeIn.Duration=500; animationfadeout = new AlphaAnimation(1.0f, 0.0f); animationfadeout.Duration=500; animationfadeout.StartOffset=500; mWorker=new BackgroundWorker(); mWorker.WorkerSupportsCancellation = true; mWorker.DoWork+= delegate(object sender1, DoWorkEventArgs e1) { BackgroundWorker mworker = sender1 as BackgroundWorker; if (mworker.CancellationPending == true) { e1.Cancel = true; } else { HttpRequestLiSHi (pageNum); } }; mWorker.RunWorkerCompleted+=delegate(object sender1, RunWorkerCompletedEventArgs e1) { if (e1.Cancelled == true) { } else if (!(e1.Error == null)) { } else { if (internetFlag == 1) { mHuoJingLiShiListView.StartAnimation (animationfadeout); mHuoJingLiShiAdapter = new ShiPinLiShiAdapter (Application.Context, Resource.Layout.HuoJingLiShiXinXI_Row, mHuoJingLiShiList); mHuoJingLiShiListView.Adapter = mHuoJingLiShiAdapter; mHuoJingLiShiListView.StartAnimation (animationfadeIn); internetFlag=0; if(mHuoJingLiShiAdapter.Count==0) { Toast mToast = Toast.MakeText (Application.Context, "没有历史记录", ToastLength.Short); mToast.Show (); } } else { Toast mToast = Toast.MakeText (Application.Context, "网络异常", ToastLength.Short); mToast.Show (); } } BackgroundWorker mWorker2 = new BackgroundWorker (); mWorker2.DoWork +=delegate { pausefor1Sec(); }; mWorker2.RunWorkerCompleted += delegate { mProgressBar.Visibility = ViewStates.Gone; }; mWorker2.RunWorkerAsync(); }; if (mWorker.IsBusy != true) { mWorker.RunWorkerAsync (); } mHuoJingLiShiListView.ItemClick += mHuoJingLiShiListView_ItemClick; mBtnHuoJingLiShiLastPage.Click+= MBtnHuoJingLiShiLastPage_Click; mBtnHuoJingLiShiNextPage.Click += MBtnHuoJingLiShiNextPage_Click; mbtnHuoJingLiSHiPageToGo.Click+= MbtnHuoJingLiSHiPageToGo_Click; return view ; }
void MBtnHuoJingLiShiNextPage_Click(object sender, EventArgs e) { mHuoJingLiShiListView.Enabled = false; if (mHuoJingLiShiList.Count == 0) { //toast Toast mToast = Toast.MakeText (Application.Context, "没有下一页了", ToastLength.Short); mToast.Show (); } else { if (pageNum.ToString() == mHuoJingLiShiList [0].maxPageNum) { //toast Toast mToast = Toast.MakeText (Application.Context, "没有下一页了", ToastLength.Short); mToast.Show (); } else { mProgressBar.Visibility = ViewStates.Visible; mWorkerNext=new BackgroundWorker(); mWorkerNext.WorkerSupportsCancellation = true; mWorkerNext.DoWork+= delegate(object sender1, DoWorkEventArgs e1) { BackgroundWorker mworker = sender1 as BackgroundWorker; if (mworker.CancellationPending == true) { e1.Cancel = true; } else { pageNum++; HttpRequestLiSHi (pageNum); } }; mWorkerNext.RunWorkerCompleted+=delegate(object sender1, RunWorkerCompletedEventArgs e1) { if (e1.Cancelled == true) { } else if (!(e1.Error == null)) { } else { if (internetFlag == 1) { mHuoJingLiShiListView.StartAnimation (animationfadeout); mHuoJingLiShiAdapter = new ShiPinLiShiAdapter (Application.Context, Resource.Layout.HuoJingLiShiXinXI_Row, mHuoJingLiShiList); mHuoJingLiShiListView.Adapter = mHuoJingLiShiAdapter; mHuoJingLiShiListView.StartAnimation (animationfadeIn); internetFlag=0; } else { Toast mToast = Toast.MakeText (Application.Context, "网络异常", ToastLength.Short); mToast.Show (); } mHuoJingLiShiListView.Enabled = true; } BackgroundWorker mWorker2 = new BackgroundWorker (); mWorker2.DoWork +=delegate { pausefor1Sec(); }; mWorker2.RunWorkerCompleted += delegate { mProgressBar.Visibility = ViewStates.Gone; }; mWorker2.RunWorkerAsync(); }; if (mWorkerNext.IsBusy != true) { mWorkerNext.RunWorkerAsync (); } } } }
void MbtnHuoJingLiSHiPageToGo_Click(object sender, EventArgs e) { mHuoJingLiShiListView.Enabled = false; InputMethodManager inputManager = (InputMethodManager)Activity.GetSystemService(Context.InputMethodService); inputManager.HideSoftInputFromWindow(mTxtHuoJingLiSHiPageToGo.WindowToken, HideSoftInputFlags.None); if (mTxtHuoJingLiSHiPageToGo.Text == null) { Toast mToast = Toast.MakeText (Application.Context, "请输入页码", ToastLength.Short); mToast.Show (); } else { if (mHuoJingLiShiList.Count == 0) { //toast Toast mToast = Toast.MakeText (Application.Context, "无此页", ToastLength.Short); mToast.Show (); } else { int result; if (isNumberic (mTxtHuoJingLiSHiPageToGo.Text, out result)) { if ((result < Convert.ToInt32(mHuoJingLiShiList [0].maxPageNum))&&(result>0)) { //跳转 mProgressBar.Visibility = ViewStates.Visible; mWorkerPageToGo=new BackgroundWorker(); mWorkerPageToGo.WorkerSupportsCancellation = true; mWorkerPageToGo.DoWork+= delegate(object sender1, DoWorkEventArgs e1) { BackgroundWorker mworker = sender1 as BackgroundWorker; if (mworker.CancellationPending == true) { e1.Cancel = true; } else { pageNum=result; HttpRequestLiSHi (result); } }; mWorkerPageToGo.RunWorkerCompleted+=delegate(object sender1, RunWorkerCompletedEventArgs e1) { if (e1.Cancelled == true) { } else if (!(e1.Error == null)) { } else { if (internetFlag == 1) { mHuoJingLiShiListView.StartAnimation (animationfadeout); mHuoJingLiShiAdapter = new ShiPinLiShiAdapter(Application.Context, Resource.Layout.HuoJingLiShiXinXI_Row, mHuoJingLiShiList); mHuoJingLiShiListView.Adapter = mHuoJingLiShiAdapter; mHuoJingLiShiListView.StartAnimation (animationfadeIn); internetFlag=0; } else { Toast mToast = Toast.MakeText (Application.Context, "网络异常", ToastLength.Short); mToast.Show (); } mHuoJingLiShiListView.Enabled = true; } BackgroundWorker mWorker2 = new BackgroundWorker (); mWorker2.DoWork +=delegate { pausefor1Sec(); }; mWorker2.RunWorkerCompleted += delegate { mProgressBar.Visibility = ViewStates.Gone; }; mWorker2.RunWorkerAsync(); }; if (mWorkerPageToGo.IsBusy != true) { mWorkerPageToGo.RunWorkerAsync (); } } else { Toast mToast = Toast.MakeText (Application.Context, "页码超出范围", ToastLength.Short); mToast.Show (); } } else { Toast mToast = Toast.MakeText (Application.Context, "请输入数字", ToastLength.Short); mToast.Show (); } } } mTxtHuoJingLiSHiPageToGo.Text=null; mTxtHuoJingLiSHiPageToGo.ClearFocus (); }
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = (View) inflater.Inflate(Resource.Layout.ShiPinChaGangListShow,container, false); Activity.Window.SetSoftInputMode (SoftInput.AdjustPan); //SetHasOptionsMenu(true); mHuoJingLiShiListView = view.FindViewById<ListView> (Resource.Id.HuoJingLiShi_listViewSP); mHeaderDanWeiMingCheng = view.FindViewById<TextView> (Resource.Id.txtHeaderDanWeiMingChengSP); mBtnHuoJingLiShiLastPage = view.FindViewById<Button> (Resource.Id.btnHuoJingLiShiLastPageSP); mBtnHuoJingLiShiNextPage = view.FindViewById<Button> (Resource.Id.btnHuoJingLiShiNextPageSP); mTxtHuoJingLiSHiPageToGo = view.FindViewById<EditText> (Resource.Id.txtHuoJingLiShiPageToGoSP); mbtnHuoJingLiSHiPageToGo = view.FindViewById<Button> (Resource.Id.btnHuoJingLiShiPageToGoSP); mImageButton1 = view.FindViewById<LinearLayout> (Resource.Id.imageButton1); mImageButton2 = view.FindViewById<LinearLayout> (Resource.Id.imageButton2); mImageButton3 = view.FindViewById<LinearLayout> (Resource.Id.imageButton3); if (logInDialogCreate.mLoginInfo.dwmc.Length > 8) { mHeaderDanWeiMingCheng.Text = logInDialogCreate.mLoginInfo.dwmc.Substring (0, 8); } else { mHeaderDanWeiMingCheng.Text = logInDialogCreate.mLoginInfo.dwmc; } mProgressBar = view.FindViewById<ProgressBar> (Resource.Id.progressBar); mProgressBar.Visibility = ViewStates.Visible; mImageButton1.Click += delegate { mProgressBar.Visibility = ViewStates.Visible; mWorkerChaGang=new BackgroundWorker(); mWorkerChaGang.WorkerSupportsCancellation = true; mWorkerChaGang.DoWork+= delegate(object sender1, DoWorkEventArgs e1) { BackgroundWorker mworker = sender1 as BackgroundWorker; if (mworker.CancellationPending == true) { e1.Cancel = true; } else { string strURLSend = this.Resources.GetString (Resource.String.HttpUri) + String.Format ("onguard_addexe_unit_android.jsp?dwbh={0}", logInDialogCreate.mLoginInfo.dwbh); Console.WriteLine (strURLSend); mHttpRequestHuoJingLiShi.HttpRequestFunc (strURLSend); if ((mHttpRequestHuoJingLiShi.HttpRecv == "666") || (mHttpRequestHuoJingLiShi.HttpRecv == "555")) { //有问题 internetFlag=0; } else { internetFlag=1; } } }; mWorkerChaGang.RunWorkerCompleted+=delegate(object sender1, RunWorkerCompletedEventArgs e1) { if (e1.Cancelled == true) { } else if (!(e1.Error == null)) { } else { if(internetFlag==1) { Toast mToast = Toast.MakeText (Application.Context, "发送查岗信号成功", ToastLength.Short); mToast.Show (); } else { Toast mToast = Toast.MakeText (Application.Context, "网络异常", ToastLength.Short); mToast.Show (); } } BackgroundWorker mWorker2 = new BackgroundWorker (); mWorker2.DoWork +=delegate { pageNum=1; HttpRequestLiSHi (pageNum); }; mWorker2.RunWorkerCompleted += delegate { if (internetFlag == 1) { mHuoJingLiShiListView.StartAnimation (animationfadeout); mHuoJingLiShiAdapter = new ShiPinLiShiAdapter (Application.Context, Resource.Layout.HuoJingLiShiXinXI_Row, mHuoJingLiShiList); mHuoJingLiShiListView.Adapter = mHuoJingLiShiAdapter; mHuoJingLiShiListView.StartAnimation (animationfadeIn); internetFlag=0; if(mHuoJingLiShiAdapter.Count==0) { Toast mToast = Toast.MakeText (Application.Context, "没有历史记录", ToastLength.Short); mToast.Show (); } } else{ Toast mToast = Toast.MakeText (Application.Context, "网络异常", ToastLength.Short); mToast.Show (); } BackgroundWorker mWorker3 = new BackgroundWorker (); mWorker3.DoWork +=delegate { pausefor1Sec(); }; mWorker3.RunWorkerCompleted += delegate { mProgressBar.Visibility = ViewStates.Gone; }; mWorker3.RunWorkerAsync(); }; if (mWorker2.IsBusy != true) { mWorker2.RunWorkerAsync (); } }; if (mWorkerChaGang.IsBusy != true) { mWorkerChaGang.RunWorkerAsync (); } }; mImageButton2.Click += delegate { var connectivityManager = (ConnectivityManager)Application.Context.GetSystemService(Context.ConnectivityService); var wifiNetworkInfo = connectivityManager.GetNetworkInfo(ConnectivityType.Wifi); if ((wifiNetworkInfo != null) && wifiNetworkInfo.IsConnected) { var ft1=this.FragmentManager.BeginTransaction (); ft1.SetCustomAnimations (Resource.Animation.Fragment_slide_R2C, Resource.Animation.Fragment_slide_C2L, Resource.Animation.Fragment_slide_L2C, Resource.Animation.Fragment_slide_C2R); ShiPinVideoFrag fragment =new ShiPinVideoFrag(); ft1.Hide (fragment); ft1.Replace (Resource.Id.content_frame, fragment,"ShiPinVideo"); ft1.AddToBackStack (null); ft1.Show (fragment); ft1.Commit (); }else{ var callDialog = new AlertDialog.Builder(Activity); callDialog.SetMessage(string.Format("您当前处于非wifi网络环境下,继续查看视频可能消耗流量,是否继续?")); callDialog.SetNeutralButton("继续", delegate { var ft1=this.FragmentManager.BeginTransaction (); ft1.SetCustomAnimations (Resource.Animation.Fragment_slide_R2C, Resource.Animation.Fragment_slide_C2L, Resource.Animation.Fragment_slide_L2C, Resource.Animation.Fragment_slide_C2R); ShiPinVideoFrag fragment =new ShiPinVideoFrag(); ft1.Hide (fragment); ft1.Replace (Resource.Id.content_frame, fragment,"ShiPinVideo"); ft1.AddToBackStack (null); ft1.Show (fragment); ft1.Commit (); }); callDialog.SetNegativeButton("取消", delegate { }); // Show the alert dialog to the user and wait for response. callDialog.Show(); } }; mImageButton3.Click += delegate { var ft1=this.FragmentManager.BeginTransaction (); ft1.SetCustomAnimations(Resource.Animation.card_flip_right_in, Resource.Animation.card_flip_right_out, Resource.Animation.card_flip_left_in, Resource.Animation.card_flip_left_out); ShipinChaGangSouSuo fragment =new ShipinChaGangSouSuo(); ft1.Hide (fragment); ft1.Replace (Resource.Id.content_frame, fragment,"ShiPinSouSuo"); ft1.AddToBackStack (null); ft1.Show (fragment); ft1.Commit (); }; animationfadeIn = new AlphaAnimation(0.0f, 1.0f); animationfadeIn.Duration=500; animationfadeout = new AlphaAnimation(1.0f, 0.0f); animationfadeout.Duration=500; animationfadeout.StartOffset=500; mWorker=new BackgroundWorker(); mWorker.WorkerSupportsCancellation = true; mWorker.DoWork+= delegate(object sender1, DoWorkEventArgs e1) { BackgroundWorker mworker = sender1 as BackgroundWorker; if (mworker.CancellationPending == true) { e1.Cancel = true; } else { HttpRequestLiSHi (pageNum); } }; mWorker.RunWorkerCompleted+=delegate(object sender1, RunWorkerCompletedEventArgs e1) { if (e1.Cancelled == true) { } else if (!(e1.Error == null)) { } else { if (internetFlag == 1) { mHuoJingLiShiListView.StartAnimation (animationfadeout); mHuoJingLiShiAdapter = new ShiPinLiShiAdapter (Application.Context, Resource.Layout.HuoJingLiShiXinXI_Row, mHuoJingLiShiList); mHuoJingLiShiListView.Adapter = mHuoJingLiShiAdapter; mHuoJingLiShiListView.StartAnimation (animationfadeIn); internetFlag=0; } else { Toast mToast = Toast.MakeText (Application.Context, "网络异常", ToastLength.Short); mToast.Show (); } } BackgroundWorker mWorker2 = new BackgroundWorker (); mWorker2.DoWork +=delegate { pausefor1Sec(); }; mWorker2.RunWorkerCompleted += delegate { mProgressBar.Visibility = ViewStates.Gone; }; mWorker2.RunWorkerAsync(); }; if (mWorker.IsBusy != true) { mWorker.RunWorkerAsync (); } mHuoJingLiShiListView.ItemClick += mHuoJingLiShiListView_ItemClick; mBtnHuoJingLiShiLastPage.Click+= MBtnHuoJingLiShiLastPage_Click; mBtnHuoJingLiShiNextPage.Click += MBtnHuoJingLiShiNextPage_Click; mbtnHuoJingLiSHiPageToGo.Click+= MbtnHuoJingLiSHiPageToGo_Click; return view ; }