protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetTheme(Resource.Style.AppTheme); splashPresenter = new SplashPresenter(this, this); var ClientId = Resources.GetString(Resource.String.ClientId); var ClientSercret = Resources.GetString(Resource.String.ClientSercret); if (ClientId == "" || ClientSercret == "") { Toast.MakeText(this, Resources.GetString(Resource.String.client_error), ToastLength.Long).Show(); } else { var basic = Square.OkHttp3.Credentials.Basic(Resources.GetString(Resource.String.ClientId), Resources.GetString(Resource.String.ClientSercret)); splashPresenter.GetAccessToken(TokenShared.GetAccessToken(this), basic); var user = UserShared.GetAccessToken(this); if (user.refresh_token != "") { splashPresenter.UserRefreshToken(user, basic); } } RunOnUiThread(() => { new Handler().PostDelayed(() => { MainActivity.Start(this); ActivityCompat.FinishAfterTransition(this); }, 1000); }); }
protected virtual void SetToolBarNavBack() { toolbar.SetNavigationIcon(Resource.Drawable.back_24dp); toolbar.NavigationClick += (s, e) => { ActivityCompat.FinishAfterTransition(this); }; }
public async void SubmitClick(object o, EventArgs eventargs) { bool isPrivate = false; var userToken = UserTokenUtil.GetToken(this); if (et_content.Text.Trim().Length == 0) { return; } rg_isPrivate.CheckedChange += (s, e) => { if (e.CheckedId == rb_true.Id) { isPrivate = true; } else if (e.CheckedId == rb_false.Id) { isPrivate = false; } }; if (userToken.IsExpire) { Android.Support.V7.App.AlertDialog.Builder alertDialog = new Android.Support.V7.App.AlertDialog.Builder(this) .SetTitle("登录提示") .SetMessage("未登录或登录token已经过期") .SetPositiveButton("授权", (s1, e1) => { StartActivity(new Intent(this, typeof(loginactivity))); }) .SetNegativeButton("取消", (s1, e1) => { return; }); alertDialog.Create().Show(); } var dialog = new ProgressDialog(this); dialog.SetProgressStyle(ProgressDialogStyle.Spinner); dialog.SetCancelable(false); dialog.SetCanceledOnTouchOutside(false); dialog.SetTitle(Resources.GetString(Resource.String.bookmark_add)); dialog.SetMessage("提交中......."); dialog.Show(); var result = await StatusService.Add(userToken, et_content.Text.Trim(), isPrivate); if (result.Success) { dialog.Hide(); AlertUtil.ToastShort(this, "发布成功"); ActivityCompat.FinishAfterTransition(this); } else { dialog.Hide(); AlertUtil.ToastShort(this, result.Message); } }
private void viewReleased(object sender, ViewReleasedEventArgs args) { var slideLayout = sender as SlideLayout; int distance = Math.Abs(slideLayout.CurrentDragChildViewLayoutedTop - slideLayout.CurrentDragChildViewDraggedTop); int finishDistance = convertDensityIndependentPixelToPixel(150); if (distance > finishDistance) { args.Handled = true; ActivityCompat.FinishAfterTransition(this); } }
public void BookmarkAddSuccess() { handler.Post(() => { if (dialog.IsShowing) { dialog.Dismiss(); } Toast.MakeText(this, Resources.GetString(Resource.String.addstatus_success), ToastLength.Short).Show(); SetResult(Result.Ok); ActivityCompat.FinishAfterTransition(this); }); }
private void Add() { string body = edit_content.Text.TrimEnd().TrimStart(); var userToken = UserTokenUtil.GetToken(this); var userInfo = UserInfoShared.GetUserInfo(this); if (userToken.IsExpire) { Android.Support.V7.App.AlertDialog.Builder alertDialog = new Android.Support.V7.App.AlertDialog.Builder(this) .SetTitle("µÇ¼Ìáʾ") .SetMessage("δµÇ¼»òµÇ¼tokenÒѾ¹ýÆÚ") .SetPositiveButton("ÊÚȨ", (s1, e1) => { StartActivity(new Intent(this, typeof(loginactivity))); }) .SetNegativeButton("È¡Ïû", (s1, e1) => { return; }); alertDialog.Create().Show(); } else { if (string.IsNullOrEmpty(body)) { AlertUtil.ToastShort(this, "ÇëÊäÈëÄÚÈÝ"); return; } ProgressDialog dialog = new ProgressDialog(this); dialog.SetTitle("ÆÀÂÛ"); dialog.SetMessage("Ìá½»ÆÀÂÛÖÐ....."); dialog.Show(); QuestionService.EditQuestionAnswerComment(userToken, body, questionId, answerId, commentId, userInfo.SpaceUserId, () => { RunOnUiThread(() => { dialog.Hide(); AlertUtil.ToastShort(this, "ÆÀÂ۳ɹ¦"); edit_content.Text = ""; btn_submit.Enabled = false; ActivityCompat.FinishAfterTransition(this); }); }, (error) => { RunOnUiThread(() => { dialog.Hide(); AlertUtil.ToastShort(this, error); btn_submit.Enabled = true; }); }); } }
private void Add() { string body = edit_content.Text.TrimEnd().TrimStart(); if (userToken.IsExpire) { Android.Support.V7.App.AlertDialog.Builder alertDialog = new Android.Support.V7.App.AlertDialog.Builder(this) .SetTitle("登录提示") .SetMessage("未登录或登录token已经过期") .SetPositiveButton("授权", (s1, e1) => { StartActivity(new Intent(this, typeof(loginactivity))); }) .SetNegativeButton("取消", (s1, e1) => { return; }); alertDialog.Create().Show(); } else { if (string.IsNullOrEmpty(body)) { AlertUtil.ToastShort(this, "请输入内容"); return; } ProgressDialog dialog = new ProgressDialog(this); dialog.SetTitle("评论"); dialog.SetMessage("提交评论中....."); dialog.Show(); QuestionService.EditQuestionAnswer(userToken, body, questionId, answerId, userInfo.SpaceUserId, () => { RunOnUiThread(() => { dialog.Hide(); AlertUtil.ToastShort(this, "评论成功"); edit_content.Text = ""; btn_submit.Enabled = false; ActivityCompat.FinishAfterTransition(this); }); }, (error) => { RunOnUiThread(() => { dialog.Hide(); AlertUtil.ToastShort(this, error); btn_submit.Enabled = true; }); }); } }
public void OnClick(View v) { switch (v.Id) { case Resource.Id.btnComment: PostComment(); break; default: InputMethodManager imm = (InputMethodManager)GetSystemService(Context.InputMethodService); imm.HideSoftInputFromWindow(txtContent.WindowToken, 0); ActivityCompat.FinishAfterTransition(this); break; } }
public void AnswersAddSuccess(QuestionAnswersModel model) { handler.Post(() => { if (dialog.IsShowing) { dialog.Dismiss(); } txtContent.Text = ""; Toast.MakeText(this, Resources.GetString(Resource.String.addstatus_success), ToastLength.Short).Show(); SetResult(Result.Ok); ActivityCompat.FinishAfterTransition(this); }); }
public void BookmarkEditSuccess(int position) { handler.Post(() => { if (dialog.IsShowing) { dialog.Dismiss(); } Toast.MakeText(this, Resources.GetString(Resource.String.addstatus_success), ToastLength.Short).Show(); var intent = new Intent(); intent.PutExtra("id", Id); intent.PutExtra("position", position); SetResult(Result.Ok, intent); ActivityCompat.FinishAfterTransition(this); }); }
public void OnClick(View v) { switch (v.Id) { case Resource.Id.login: var account = editAccount.Text; var password = editPassword.Text; if (account.Trim() == "") { Toast.MakeText(this, Resources.GetString(Resource.String.need_account), ToastLength.Short).Show(); return; } if (password.Trim() == "") { Toast.MakeText(this, Resources.GetString(Resource.String.need_password), ToastLength.Short).Show(); return; } //var publicKey = Resources.GetString(Resource.String.PublicKey); var publicKey = ""; if (publicKey == "") { Toast.MakeText(this, Resources.GetString(Resource.String.publicKey_error), ToastLength.Short).Show(); return; } RSAUtils rsaUtils = new RSAUtils(publicKey); dialog.SetMessage(Resources.GetString(Resource.String.logining)); dialog.Show(); var basic = Square.OkHttp3.Credentials.Basic(Resources.GetString(Resource.String.ClientId), Resources.GetString(Resource.String.ClientSercret)); loginPresenter.LoginAsync(TokenShared.GetAccessToken(this), basic, rsaUtils.Encrypt(account), rsaUtils.Encrypt(password)); break; default: InputMethodManager imm = (InputMethodManager)GetSystemService(Context.InputMethodService); imm.HideSoftInputFromWindow(editPassword.WindowToken, 0); SetResult(Result.Canceled); ActivityCompat.FinishAfterTransition(this); break; } }
protected override async void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.searchInput); var app = ((InitApp)ApplicationContext); if (app != null) { app.addActivity(this); } StatusBarUtil.SetColorStatusBars(this); Android.Support.V7.Widget.Toolbar toolbar = FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar); toolbar.SetNavigationIcon(Resource.Drawable.back_24dp); toolbar.NavigationClick += (s, e) => { //ActivityCompat.FinishAfterTransition(this); ActivityCompat.FinishAfterTransition(this); this.Finish(); }; initSearchHistory(); category = Intent.GetStringExtra("category"); keyword = Intent.GetStringExtra("keyword"); search_keyword = FindViewById <SearchView>(Resource.Id.search_keyword); search_keyword.QueryTextSubmit += (h, _keyword) => { keyword = _keyword.Query.Trim(); if (keyword == null || keyword.Length == 0) { return; } SearchResultActivity.Enter(category, keyword, true, this); }; //search_keyword.SetIconifiedByDefault(false); //设置展开图标的样式 search_keyword.OnActionViewExpanded(); //初始可以点击输入的状态 search_keyword.RequestFocus(); //将控件设置成可获取焦点状态,默认是无法获取焦点的,只有设置成true,才能获取控件的点击事件 search_keyword.Focusable = true; }
protected override async void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.searchResult); var app = ((InitApp)ApplicationContext); if (app != null) { app.addActivity(this); } tv_question = FindViewById <TextView>(Resource.Id.tv_question); tv_news = FindViewById <TextView>(Resource.Id.tv_news); tv_kb = FindViewById <TextView>(Resource.Id.tv_kb); tv_blog = FindViewById <TextView>(Resource.Id.tv_blog); search_keyword = FindViewById <SearchView>(Resource.Id.search_keyword); _recyclerView = FindViewById <RecyclerView>(Resource.Id.recyclerView); Android.Support.V7.Widget.Toolbar toolbar = FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar); swipeRefreshLayout = FindViewById <SwipeRefreshLayout>(Resource.Id.swipeRefreshLayout); swipeRefreshLayout.SetColorScheme(Resource.Color.primary); swipeRefreshLayout.Refreshing = false; StatusBarUtil.SetColorStatusBars(this); category = Intent.GetStringExtra("category"); keyword = Intent.GetStringExtra("keyword"); startQuery = Intent.GetBooleanExtra("startquery", false); initCategoryClick(); //初始化category单击事件 initCategoryByCategory(); //初始化category 选中的状态 toolbar.SetNavigationIcon(Resource.Drawable.back_24dp); toolbar.NavigationClick += (s, e) => { ActivityCompat.FinishAfterTransition(this); }; swipeRefreshLayout.Refresh += (s, e) => { swipeRefreshLayout.PostDelayed(() => { swipeRefreshLayout.Refreshing = false; }, 1000); }; _recyclerView.SetLayoutManager(new Android.Support.V7.Widget.LinearLayoutManager(this)); //search_keyword.SubmitButtonEnabled = true; //默认为false 不显示提交按钮,是否启用提交按钮 search_keyword.OnActionViewExpanded(); //手动展开SearchView输入框,初始可以点击输入的状态 //search_keyword.SetIconifiedByDefault(false); //默认是为true 不显示输入框键盘,默认提交按钮不显示,该属性设置为false,则直接展开输入框弹出键盘 // search_keyword.RequestFocus(); //将控件设置成可获取焦点状态,默认是无法获取焦点的,只有设置成true,才能获取控件的点击事件 //search_keyword.Focusable = true; search_keyword.ClearFocus(); search_keyword.Focusable = true; if (!string.IsNullOrEmpty(keyword)) { search_keyword.QueryHint = keyword; } search_keyword.FocusChange += (s, e) => { System.Diagnostics.Debug.Write(e.HasFocus); if (e.HasFocus) { SearchInputActivity.Enter(category, this); } }; search_keyword.SetOnQueryTextFocusChangeListener(this); search_keyword.QueryTextSubmit += async(s, e) => { keyword = search_keyword.Query.Trim(); if (keyword == null || keyword.Length == 0) { return; } SearchHistoryShared.SetSearchHistory(keyword, this); swipeRefreshLayout.Refreshing = true; await listSearchService((list) => { swipeRefreshLayout.PostDelayed(() => { swipeRefreshLayout.Refreshing = false; }, 1000); searchList = list; initRecycler(); }); }; if (startQuery) { initCategoryByCategory(); SearchHistoryShared.SetSearchHistory(keyword, this); if (!string.IsNullOrEmpty(keyword)) { swipeRefreshLayout.Refreshing = true; await listSearchService((list) => { swipeRefreshLayout.PostDelayed(() => { swipeRefreshLayout.Refreshing = false; }, 1000); searchList = list; initRecycler(); }); } } }
public void OnClick(View v) { ActivityCompat.FinishAfterTransition(this); }
public void OnClick(View v) { SetResult(Result.Canceled); ActivityCompat.FinishAfterTransition(this); }
public async void AddQuestionClick(object o, EventArgs e) { if (userToken.IsExpire) { Android.Support.V7.App.AlertDialog.Builder alertDialog = new Android.Support.V7.App.AlertDialog.Builder(this) .SetTitle("登录提示") .SetMessage("未登录或登录token已经过期") .SetPositiveButton("授权", (s1, e1) => { StartActivity(new Intent(this, typeof(loginactivity))); }) .SetNegativeButton("取消", (s1, e1) => { return; }); alertDialog.Create().Show(); } string content = edit_content.Text.Trim(); string title = edit_content.Text.Trim(); string tags = edit_tags.Text.Trim(); if (string.IsNullOrEmpty(content) || content.Length > 100000 || content.Length < 20) { AlertUtil.ToastShort(this, "提问内容20-100000个字符之间"); return; } if (string.IsNullOrEmpty(title) || title.Length > 100000 || title.Length < 20) { AlertUtil.ToastShort(this, "标题6-200分字符"); return; } if (!string.IsNullOrEmpty(tags)) { var tagCount = tags.Split(',').Length; if (tagCount > 5) { AlertUtil.ToastShort(this, "不能超过5个标签,以中文都好隔开"); return; } } var userInfo = UserInfoShared.GetUserInfo(this); var dialog = new ProgressDialog(this); dialog.SetProgressStyle(ProgressDialogStyle.Spinner); dialog.SetCancelable(false); dialog.SetCanceledOnTouchOutside(false); dialog.SetTitle(Resources.GetString(Resource.String.bookmark_add)); dialog.SetMessage("提交中......."); dialog.Show(); var result = await QuestionService.Add(userToken, title, content, tags, flags, userInfo.SpaceUserId.ToString()); if (result.Success) { RunOnUiThread(() => { dialog.Hide(); edit_content.Text = ""; edit_title.Text = ""; edit_tags.Text = ""; rb_true.Checked = true; AlertUtil.ToastShort(this, "发布问答成功"); ActivityCompat.FinishAfterTransition(this); }); } else { RunOnUiThread(() => { dialog.Hide(); AlertUtil.ToastShort(this, result.Message); }); } }
public void StartMain() { MainActivity.Start(this); ActivityCompat.FinishAfterTransition(this); }