private void bindControls() { RoundImageView rImgView = FindViewById <RoundImageView>(Resource.Id.img_avator); if (blogger.Avatar.Contains("png") || blogger.Avatar.Contains("jpg") || blogger.Avatar.Contains("gif")) { imgLoader.DisplayImage(blogger.Avatar, rImgView, displayImageOptions); } TextView textHomePage = FindViewById <TextView>(Resource.Id.text_homepage); textHomePage.Text = blogger.Link.ToString(); TextView textBloggerApp = FindViewById <TextView>(Resource.Id.text_blogapp); textBloggerApp.Text = blogger.BlogApp; TextView textPostCount = FindViewById <TextView>(Resource.Id.text_blog_count); textPostCount.Text = "博文数:" + blogger.PostCount.ToString(); TextView textLastPost = FindViewById <TextView>(Resource.Id.text_lastupdate); textLastPost.Text = "最后更新:" + CommonHelper.DateDiff(DateTime.Now, blogger.Updated) + "前"; comAdaper = new CommonAdapter <Article>(this, Resource.Layout.blogger_article_list_item, articles); comAdaper.OnGetView += comAdapter_OnGetView; pListView.Adapter = comAdaper; pListView.ItemClick += pListView_ItemClick; ptrl = FindViewById <PullToRefreshLayout>(Resource.Id.refresh_view); ptrl.setOnRefreshListener(this); ptrl.AutoRefresh(); }
void Captureshow(CameraDevice cam, RoundImageView iv) { try { cam.StartAcquisition(); cam.Trigger(); var img = cam.Capture(); cam.StopAcquisition(); iv.SetImage(img); } catch (Exception ex) { Logger.Error(ex.Message); } }
private void bindControls() { BlogApplication.InitImageLoader(this); imgLoader = ImageLoader.Instance; displayImageOptions = new DisplayImageOptions.Builder() .ShowImageForEmptyUri(Resource.Drawable.girl) .ShowImageOnFail(Resource.Drawable.girl) .ShowImageOnLoading(Resource.Drawable.girl) .CacheInMemory(true) .CacheOnDisk(true) .ResetViewBeforeLoading() .Build(); btnBack = FindViewById <Button>(Resource.Id.title_bar_back); btnBack.Click += delegate { Finish(); }; textName = FindViewById <TextView>(Resource.Id.text_nickname); textAge = FindViewById <TextView>(Resource.Id.text_age); myBlog = FindViewById <LinearLayout>(Resource.Id.my_blog); myBlog.Click += delegate { if (CommonHelper.userInfo == null) { Msg.AppMsg.MakeText(this, "请先登录", Msg.AppMsg.STYLE_INFO).Show(); return; } StartActivity(new Intent(this, typeof(MyPostsActivity))); }; myCollect = FindViewById <LinearLayout>(Resource.Id.my_collect); myCollect.Click += delegate { if (CommonHelper.userInfo == null) { Msg.AppMsg.MakeText(this, "请先登录", Msg.AppMsg.STYLE_INFO).Show(); return; } StartActivity(new Intent(this, typeof(BookMarksActivity))); }; setting = FindViewById <LinearLayout>(Resource.Id.setting); setting.Click += delegate { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.SetMessage("APP作者:胡帅。一个不出名的帅小伙,只想安安静静写个代码。"); builder.SetPositiveButton("我知道啦", (object sender, DialogClickEventArgs e) => { AlertDialog dialog = sender as AlertDialog; dialog.Dismiss(); }); builder.SetTitle("提示"); builder.Show(); }; btnLoginOut = FindViewById <Button>(Resource.Id.btn_loginout); btnLoginOut.Click += btnLoginOut_Click; rImgView = FindViewById <RoundImageView>(Resource.Id.img_headPic); }
public static async void LoadImage(string url, RoundImageView img) { WebRequest Request = HttpWebRequest.CreateHttp(url); using (WebResponse response = Request.GetResponse()) { using (Stream stream = response.GetResponseStream()) { Bitmap bitmap = await BitmapFactory.DecodeStreamAsync(stream); img.SetImageBitmap(bitmap); img.play(); } } }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); Xamarin.Essentials.Platform.Init(this, savedInstanceState); RelativeLayout relativeLayout = new RelativeLayout(this); view = LayoutInflater.From(this).Inflate(this.Assets.OpenXmlResourceParser("res/layout/xamarin_activity.xml"), relativeLayout); SetContentView(relativeLayout); AuthDialog.Dialog.Properties = new Properties(); string content; using (StreamReader sr = new StreamReader(Assets.Open("Conf.dat"))) { content = sr.ReadToEnd(); } Stream stream = new MemoryStream(Android.Util.Base64.Decode(Encoding.UTF8.GetBytes(content), Base64Flags.NoWrap)); AuthDialog.Dialog.Properties.Load(stream); /*AuthDialog.Dialog.Properties = new Properties(); * AuthDialog.Dialog.Properties.SetProperty("Appid", "7"); * AuthDialog.Dialog.Properties.SetProperty("Ver", "1"); * AuthDialog.Dialog.Properties.SetProperty("MainClass", this.Class.Name);*/ if (AuthDialog.Dialog.AntiRun) { StartActivity(new Intent(this, Java.Lang.Class.ForName(AuthDialog.Dialog.Properties.GetProperty("MainClass")))); Finish(); return; } RoundImageView v = (RoundImageView)view.FindViewWithTag("image"); v.SetImageBitmap(BitmapFactory.DecodeStream(Assets.Open("bj.png"))); view.FindViewWithTag("mainview").Background = new BitmapDrawable(Resources, BitmapFactory.DecodeStream(Assets.Open("background.png"))); Loading.Show(this); HttpApi.GetCardAsync(this, mac.GetMac()); /*Button bt1 = (Button)view.FindViewWithTag("bt1"); * bt1.Click += delegate * { * Toast.MakeText(this, "xxx", ToastLength.Long).Show(); * };*/ }
private static void ShowDialog() { if (appInfo.data.dialog_style == 0 || appInfo.data.dialog_style == 1) { RelativeLayout relativeLayout = new RelativeLayout(Base); relativeLayout.LayoutParameters = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent); EditText Card = new EditText(Base); Card.LayoutParameters = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent); relativeLayout.SetPadding(30, 0, 30, 0); relativeLayout.AddView(Card); if (appInfo.data.dialog_style == 1) { Card.SetTextColor(Color.White); } auth = new AlertDialog.Builder(Base, appInfo.data.dialog_style == 0 ? 5 : 4) .SetTitle(appInfo.data.title) .SetMessage(appInfo.data.notice) .SetCancelable(false) .SetView(relativeLayout) .SetNegativeButton(string.IsNullOrEmpty(appInfo.data.weburl) ? "取消" : "购卡", delegate { }) .SetPositiveButton("验证", delegate { }) .SetNeutralButton(appInfo.data.try_count > 0 ? "试用" : "查码", delegate { }) .Show(); auth.GetButton((int)DialogButtonType.Positive).Click += delegate { string card = Card.Text.Trim(); if (string.Empty == card) { return; } if (string.Empty == mac.GetMac()) { new AlertDialog.Builder(Base) .SetTitle("请确认你的权限是否打开") .SetMessage("请在权限管理里(找到" + Base.PackageManager.GetApplicationLabel(Base.PackageManager.GetApplicationInfo(Base.PackageName, 0)) + ")打开-读取手机信息权限,如果依旧没有解决请联系客服进行协助") .SetPositiveButton("去开启", (s, e) => { Intent intent = new Intent("android.settings.APPLICATION_DETAILS_SETTINGS"); Android.Net.Uri uri = Android.Net.Uri.FromParts("package", Base.PackageName, null); intent.SetData(uri); Base.StartActivity(intent); }) .Show(); return; } Loading.Show(Base); mCard = card; HttpApi.loginAsync(mResult, card, mac.GetMac()); }; auth.GetButton((int)DialogButtonType.Negative).Click += delegate { if (string.IsNullOrEmpty(appInfo.data.weburl)) { System.Environment.Exit(0); } else { if (appInfo.data.weburl.StartsWith("https://www.kuaifaka.com/purchasing?link=")) { Loading.Show(Base); HttpApi.GetPage_data(mResult, appInfo.data.weburl); } else { Intent browserIntent = new Intent(Intent.ActionDefault, Android.Net.Uri.Parse(appInfo.data.weburl)); Base.StartActivity(browserIntent); } } }; auth.GetButton((int)DialogButtonType.Neutral).Click += delegate { if (appInfo.data.try_count > 0) { if (string.Empty == mac.GetMac()) { new AlertDialog.Builder(Base) .SetTitle("请确认你的权限是否打开") .SetMessage("请在权限管理里(找到" + Base.PackageManager.GetApplicationLabel(Base.PackageManager.GetApplicationInfo(Base.PackageName, 0)) + ")打开-读取手机信息权限,如果依旧没有解决请联系客服进行协助") .SetPositiveButton("去开启", (s, e) => { Intent intent = new Intent("android.settings.APPLICATION_DETAILS_SETTINGS"); Android.Net.Uri uri = Android.Net.Uri.FromParts("package", Base.PackageName, null); intent.SetData(uri); Base.StartActivity(intent); }) .Show(); return; } Loading.Show(Base); HttpApi.trialAsync(mResult, mac.GetMac()); } else { string card = Card.Text.Trim(); if (string.Empty == card) { return; } HttpApi.QueryAsync(mResult, card); } }; } else if (appInfo.data.dialog_style == 2) { RelativeLayout relativeLayout = new RelativeLayout(Base); view = LayoutInflater.From(Base).Inflate(Base.Assets.OpenXmlResourceParser("res/layout/xamarin_auth.xml"), relativeLayout); CardView cardView = (CardView)view.FindViewWithTag("cardview"); cardView.Radius = 45; cardView.Elevation = 1; cardView.PreventCornerOverlap = false; RoundImageView v = (RoundImageView)view.FindViewWithTag("image"); v.SetImageBitmap(BitmapFactory.DecodeStream(Base.Assets.Open("bj.png"))); auth = new AlertDialog.Builder(Base, 4) .SetView(relativeLayout) .SetCancelable(false) .Show(); auth.Window.SetBackgroundDrawableResource(Android.Resource.Color.Transparent); EditText Card = (EditText)view.FindViewWithTag("et"); ((TextView)view.FindViewWithTag("title")).SetText(appInfo.data.title, BufferType.Normal); ((TextView)view.FindViewWithTag("msg")).SetText(appInfo.data.notice, BufferType.Normal); if (string.Empty != appInfo.data.weburl) { ((Button)view.FindViewWithTag("bt2")).Visibility = ViewStates.Visible; } if (appInfo.data.try_count > 0) { ((Button)view.FindViewWithTag("bt1")).SetText("试用", BufferType.Normal); } else { ((Button)view.FindViewWithTag("bt1")).SetText("查码", BufferType.Normal); } view.FindViewWithTag("bt1").Click += delegate { if (appInfo.data.try_count > 0) { if (string.Empty == mac.GetMac()) { new AlertDialog.Builder(Base) .SetTitle("请确认你的权限是否打开") .SetMessage("请在权限管理里(找到" + Base.PackageManager.GetApplicationLabel(Base.PackageManager.GetApplicationInfo(Base.PackageName, 0)) + ")打开-读取手机信息权限,如果依旧没有解决请联系客服进行协助") .SetPositiveButton("去开启", (s, e) => { Intent intent = new Intent("android.settings.APPLICATION_DETAILS_SETTINGS"); Android.Net.Uri uri = Android.Net.Uri.FromParts("package", Base.PackageName, null); intent.SetData(uri); Base.StartActivity(intent); }) .Show(); return; } Loading.Show(Base); HttpApi.trialAsync(mResult, mac.GetMac()); } else { string card = Card.Text.Trim(); if (string.Empty == card) { return; } HttpApi.QueryAsync(mResult, card); } }; view.FindViewWithTag("bt2").Click += delegate { if (appInfo.data.weburl.StartsWith("https://www.kuaifaka.com/purchasing?link=")) { Loading.Show(Base); HttpApi.GetPage_data(mResult, appInfo.data.weburl); } else { Intent browserIntent = new Intent(Intent.ActionDefault, Android.Net.Uri.Parse(appInfo.data.weburl)); Base.StartActivity(browserIntent); } }; view.FindViewWithTag("bt3").Click += delegate { string card = Card.Text.Trim(); if (string.Empty == card) { return; } if (string.Empty == mac.GetMac()) { new AlertDialog.Builder(Base) .SetTitle("请确认你的权限是否打开") .SetMessage("请在权限管理里(找到" + Base.PackageManager.GetApplicationLabel(Base.PackageManager.GetApplicationInfo(Base.PackageName, 0)) + ")打开-读取手机信息权限,如果依旧没有解决请联系客服进行协助") .SetPositiveButton("去开启", (s, e) => { Intent intent = new Intent("android.settings.APPLICATION_DETAILS_SETTINGS"); Android.Net.Uri uri = Android.Net.Uri.FromParts("package", Base.PackageName, null); intent.SetData(uri); Base.StartActivity(intent); }) .Show(); return; } Loading.Show(Base); mCard = card; HttpApi.loginAsync(mResult, card, mac.GetMac()); }; } if (appInfo.data.version > Convert.ToInt32(Properties.GetProperty("Ver"))) { new AlertDialog.Builder(Base) .SetTitle(appInfo.data.title) .SetMessage(appInfo.data.update_msg) .SetCancelable(appInfo.data.updatemode == 0 ? false : true) .SetPositiveButton("更新", (s, e) => { Intent browserIntent = new Intent(Intent.ActionDefault, Android.Net.Uri.Parse(appInfo.data.update_url)); Base.StartActivity(browserIntent); }).Show(); } }
private static void ShowGroup() { if (appInfo.data.group_style == 0 || appInfo.data.group_style == 1) { RelativeLayout relativeLayout = new RelativeLayout(Base); view = LayoutInflater.From(Base).Inflate(Base.Assets.OpenXmlResourceParser("res/layout/xamarin_group_style_right.xml"), relativeLayout); auth = new AlertDialog.Builder(Base, 4) .SetView(relativeLayout) .SetCancelable(false) .Show(); auth.Window.SetBackgroundDrawableResource(Android.Resource.Color.Transparent); CardView cardView = (CardView)view.FindViewWithTag("view"); cardView.Radius = 45; cardView.Elevation = 1; cardView.PreventCornerOverlap = false; GradientDrawable gd1 = new GradientDrawable(); gd1.SetCornerRadius(45); gd1.SetColor(appInfo.data.group_style == 0 ? Color.White : Color.Black); cardView.Background = gd1; ImageView v = (ImageView)view.FindViewWithTag("image"); HttpApi.LoadImage2("http://q2.qlogo.cn/headimg_dl?dst_uin=" + appInfo.data.qq_key + "&spec=100", v); if (appInfo.data.group_style == 1) { ((TextView)view.FindViewWithTag("title")).SetTextColor(Color.White); ((TextView)view.FindViewWithTag("msg")).SetTextColor(Color.White); ((Button)view.FindViewWithTag("start")).SetTextColor(Color.White); ((Button)view.FindViewWithTag("qq")).SetTextColor(Color.White); ((Button)view.FindViewWithTag("more")).SetTextColor(Color.White); ((Button)view.FindViewWithTag("group")).SetTextColor(Color.White); } ((TextView)view.FindViewWithTag("title")).SetText(appInfo.data.title, BufferType.Normal); ((TextView)view.FindViewWithTag("msg")).SetText(appInfo.data.notice, BufferType.Normal); if (share.GetInt("Share_Count", 0) >= appInfo.data.share_count) { ((Button)view.FindViewWithTag("start")).SetText("进入软件", BufferType.Normal); } view.FindViewWithTag("start").Click += (delegate { if (share.GetInt("Share_Count", 0) >= appInfo.data.share_count) { if (auth != null) { auth.Dismiss(); } HookView.Visibility = ViewStates.Gone; } else { Intent intent = new Intent("android.intent.action.SEND"); intent.SetType("text/plain"); intent.PutExtra(Intent.ExtraSubject, "分享"); intent.PutExtra(Intent.ExtraText, appInfo.data.share_msg); intent.SetFlags(ActivityFlags.NewTask); intent.SetComponent(new ComponentName("com.tencent.mobileqq", "com.tencent.mobileqq.activity.JumpActivity")); Base.StartActivity(intent); new Handler().PostDelayed(() => { edit.PutInt("Share_Count", share.GetInt("Share_Count", 0) + 1); edit.Apply(); Toast.MakeText(Base, "你已分享 " + share.GetInt("Share_Count", 0) + " / " + appInfo.data.share_count + "次", ToastLength.Long).Show(); }, 7000); } }); view.FindViewWithTag("group").Click += (delegate { Intent browserIntent = new Intent(Intent.ActionDefault, Android.Net.Uri.Parse("mqqapi://card/show_pslcard?src_type=internal&version=1&uin=" + appInfo.data.group_key + "&card_type=group&source=qrcode")); Base.StartActivity(browserIntent); }); view.FindViewWithTag("qq").Click += (delegate { Intent browserIntent = new Intent(Intent.ActionDefault, Android.Net.Uri.Parse("mqqwpa://im/chat?chat_type=wpa&uin=" + appInfo.data.qq_key)); Base.StartActivity(browserIntent); }); view.FindViewWithTag("more").Click += (delegate { Intent browserIntent = new Intent(Intent.ActionDefault, Android.Net.Uri.Parse(appInfo.data.more_url)); Base.StartActivity(browserIntent); }); } else if (appInfo.data.group_style == 2) { RelativeLayout relativeLayout = new RelativeLayout(Base); view = LayoutInflater.From(Base).Inflate(Base.Assets.OpenXmlResourceParser("res/layout/xamarin_group.xml"), relativeLayout); ((TextView)view.FindViewWithTag("Title")).SetText(appInfo.data.title, BufferType.Normal); ((TextView)view.FindViewWithTag("Tips")).SetText(appInfo.data.notice, BufferType.Normal); TextView Count = (TextView)view.FindViewWithTag("Count"); Count.SetText("你已分享 " + share.GetInt("Share_Count", 0) + " / " + appInfo.data.share_count + "次", BufferType.Normal); GradientDrawable gd1 = new GradientDrawable(); gd1.SetCornerRadius(100); gd1.SetColor(Color.ParseColor("#FF237686")); view.FindViewWithTag("Start1").Background = gd1; GradientDrawable gd = new GradientDrawable(); gd.SetCornerRadius(50); gd.SetStroke(3, Color.White); view.FindViewWithTag("bottom").Background = gd; TextView Group = (TextView)view.FindViewWithTag("Group"); TextView QQ = (TextView)view.FindViewWithTag("QQ"); TextView More = (TextView)view.FindViewWithTag("More"); if (share.GetInt("Share_Count", 0) >= appInfo.data.share_count) { ((TextView)view.FindViewWithTag("Start")).SetText("进入软件", BufferType.Normal); } view.FindViewWithTag("Start").Click += (delegate { if (share.GetInt("Share_Count", 0) >= appInfo.data.share_count) { if (auth != null) { auth.Dismiss(); } HookView.Visibility = ViewStates.Gone; } else { Intent intent = new Intent("android.intent.action.SEND"); intent.SetType("text/plain"); intent.PutExtra(Intent.ExtraSubject, "分享"); intent.PutExtra(Intent.ExtraText, appInfo.data.share_msg); intent.SetFlags(ActivityFlags.NewTask); intent.SetComponent(new ComponentName("com.tencent.mobileqq", "com.tencent.mobileqq.activity.JumpActivity")); Base.StartActivity(intent); new Handler().PostDelayed(() => { edit.PutInt("Share_Count", share.GetInt("Share_Count", 0) + 1); edit.Apply(); Count.SetText("你已分享 " + share.GetInt("Share_Count", 0) + " / " + appInfo.data.share_count + "次", BufferType.Normal); }, 7000); } }); Group.Click += (delegate { Intent browserIntent = new Intent(Intent.ActionDefault, Android.Net.Uri.Parse("mqqapi://card/show_pslcard?src_type=internal&version=1&uin=" + appInfo.data.group_key + "&card_type=group&source=qrcode")); Base.StartActivity(browserIntent); }); QQ.Click += (delegate { Intent browserIntent = new Intent(Intent.ActionDefault, Android.Net.Uri.Parse("mqqwpa://im/chat?chat_type=wpa&uin=" + appInfo.data.qq_key)); Base.StartActivity(browserIntent); }); More.Click += (delegate { Intent browserIntent = new Intent(Intent.ActionDefault, Android.Net.Uri.Parse(appInfo.data.more_url)); Base.StartActivity(browserIntent); }); Group.SetOnTouchListener(new Touch()); QQ.SetOnTouchListener(new Touch()); More.SetOnTouchListener(new Touch()); RoundImageView v = (RoundImageView)view.FindViewWithTag("img"); HttpApi.LoadImage("http://q2.qlogo.cn/headimg_dl?dst_uin=" + appInfo.data.qq_key + "&spec=100", v); auth = new AlertDialog.Builder(Base, 4) .SetView(relativeLayout) .SetCancelable(false) .Show(); auth.Window.SetBackgroundDrawableResource(Android.Resource.Color.Transparent); auth.Window.SetLayout(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent); } }
protected async override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); Xamarin.Essentials.Platform.Init(this, savedInstanceState); SetContentView(Resource.Layout.activity_main); //var toolbar = FindViewById<Toolbar>(Resource.Id.toolbar); //SetSupportActionBar(toolbar); FloatingActionButton fab = FindViewById <FloatingActionButton>(Resource.Id.fab); fab.Click += FabOnClick; //DrawerLayout drawer = FindViewById<DrawerLayout>(Resource.Id.drawer_layout); //ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar, Resource.String.navigation_drawer_open, Resource.String.navigation_drawer_close); //drawer.AddDrawerListener(toggle); //toggle.SyncState(); NavigationView navigationView = FindViewById <NavigationView>(Resource.Id.nav_view); navigationView.SetNavigationItemSelectedListener(this); #region RecyclerView var recyclerView = FindViewById <RecyclerView>(Resource.Id.recyclerView_main); var manager = new GridLayoutManager(this, 2); mPhotoAlbum = new PhotoAlbum(); mAdapter = new PhotoAlbumAdapter(mPhotoAlbum); mAdapter.ItemClick += OnItemClick; manager.SetSpanSizeLookup(new MySpanSizeLookup(mAdapter)); recyclerView.SetLayoutManager(manager); recyclerView.SetAdapter(mAdapter); UIHander uIHander = new UIHander(HandleiAction); recyclerView.AddOnScrollListener(new RecyclerViewOnScrollListtener(AddList, manager, uIHander)); #endregion swipeRefreshLayout = FindViewById <SwipeRefreshLayout>(Resource.Id.switch_refresh); swipeRefreshLayout.SetColorSchemeColors(Resource.Color.colorPrimary); swipeRefreshLayout.Refresh += SwipeRefreshLayout_Refresh; imagebutton = FindViewById <RoundImageView>(Resource.Id.iv_userphoto_mycenter_myprofile); imagebutton.Click += Imagebutton_Click; // 更新用户头像 ThreadPool.QueueUserWorkItem(q => SetImage()); Init(); }