protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); Id = Intent.GetIntExtra("id", 0); articlePresenter = new ArticlePresenter(this); handler = new Handler(); StatusBarCompat.SetOrdinaryToolBar(this); toolbar = FindViewById <Toolbar>(Resource.Id.toolbar); toolbar.SetNavigationIcon(Resource.Drawable.back_24dp); SetSupportActionBar(toolbar); SupportActionBar.SetDisplayHomeAsUpEnabled(true); toolbar.SetNavigationOnClickListener(this); toolbar.SetOnMenuItemClickListener(this); swipeRefreshLayout = FindViewById <SwipeRefreshLayout>(Resource.Id.swipeRefreshLayout); swipeRefreshLayout.SetColorSchemeResources(Resource.Color.primary); swipeRefreshLayout.SetOnRefreshListener(this); scrollView = FindViewById <NestedScrollView>(Resource.Id.scrollView); txtTitle = FindViewById <TextView>(Resource.Id.txtTitle); imgAvatar = FindViewById <ImageView>(Resource.Id.llAvatar); txtAuthor = FindViewById <TextView>(Resource.Id.txtAuthor); txtPostdate = FindViewById <TextView>(Resource.Id.txtPostdate); txtBody = FindViewById <WebView>(Resource.Id.txtBody); txtBody.Settings.JavaScriptEnabled = true; txtBody.Settings.DomStorageEnabled = true; txtBody.Settings.LoadsImagesAutomatically = true; txtBody.Settings.DefaultTextEncodingName = "utf-8"; txtBody.SetWebViewClient(BodyWebViewClient.With(this)); txtBody.ScrollBarStyle = ScrollbarStyles.InsideOverlay; txtBody.Settings.SetSupportZoom(false); txtBody.Settings.BuiltInZoomControls = false; txtBody.Settings.CacheMode = CacheModes.CacheElseNetwork; txtBody.Settings.SetLayoutAlgorithm(WebSettings.LayoutAlgorithm.SingleColumn); var jsInterface = new WebViewJSInterface(this); txtBody.AddJavascriptInterface(jsInterface, "openlistner"); jsInterface.CallFromPageReceived += delegate(object sender, WebViewJSInterface.CallFromPageReceivedEventArgs e) { PhotoActivity.Start(this, e.Result.Split(','), e.Index); }; txtDigg = FindViewById <TextView>(Resource.Id.txtDigg); txtRead = FindViewById <TextView>(Resource.Id.txtRead); txtComments = FindViewById <TextView>(Resource.Id.txtComments); txtBookmark = FindViewById <TextView>(Resource.Id.txtBookmark); swipeRefreshLayout.Post(async() => { await articlePresenter.GetClientArticle(Id); }); shareAction = new ShareAction(this).SetDisplayList(SHARE_MEDIA.Weixin, SHARE_MEDIA.WeixinCircle, SHARE_MEDIA.WeixinFavorite, SHARE_MEDIA.Sina).SetShareboardclickCallback(this); }
public void GetServiceDailySuccess(DailyModel daily) { if (swipeRefreshLayout.Refreshing) { swipeRefreshLayout.Refreshing = false; } if (daily != null && daily.id > 0) { this.daily = daily; title = daily.title; txtTitle.Text = daily.title; txtAuthor.Text = daily.image_source; body.Settings.JavaScriptEnabled = true; body.Settings.DomStorageEnabled = true; var jsInterface = new WebViewJSInterface(this); body.SetWebViewClient(DailyWebViewClient.With(this)); body.AddJavascriptInterface(jsInterface, "openlistner"); body.LoadRenderedContent(daily.body.Replace("img-place-holder", "img-place-holder1")); jsInterface.CallFromPageReceived += delegate(object sender, WebViewJSInterface.CallFromPageReceivedEventArgs e) { switch (e.Type) { case WebViewJSInterface.CallFromType.Image: PhotoActivity.Start(this, e.Result.Split(','), e.Index); break; case WebViewJSInterface.CallFromType.Href: Intent intent = new Intent(); intent.SetAction("android.intent.action.VIEW"); intent.SetData(Android.Net.Uri.Parse(e.Result)); intent.SetClassName("com.android.browser", "com.android.browser.BrowserActivity"); StartActivity(intent); break; } }; if (daily.image != "") { Picasso.With(this).Load(daily.image).Into(titleImage); } else { appbar.LayoutParameters = new CoordinatorLayout.LayoutParams(CoordinatorLayout.LayoutParams.MatchParent, toolbar.Height); toolbarTitle.Text = title; } } }
public async void GetServiceArticleSuccess(ArticleModel article) { if (swipeRefreshLayout.Refreshing) { swipeRefreshLayout.Refreshing = false; } title = article.Title; txtAuthor.Text = article.Author.Name; if (article.Author.IsOrg) { org.Visibility = ViewStates.Visible; org.SetImageResource(Resource.Drawable.identity); } else { if (article.Author.Badge != null) { org.Visibility = ViewStates.Visible; if (article.Author.Badge.Identity != null) { org.SetImageResource(Resource.Drawable.identity); } else if (article.Author.Badge.Best_answerer != null) { org.SetImageResource(Resource.Drawable.bestanswerer); } } else { org.Visibility = ViewStates.Gone; } } txtBio.Text = article.Author.Bio; if (this.article == null || this.article.Content != article.Content) { var content = "<h1>" + article.Title + "</h1>" + article.Content; articleContent.Settings.JavaScriptEnabled = true; articleContent.Settings.CacheMode = CacheModes.CacheElseNetwork; var jsInterface = new WebViewJSInterface(this); articleContent.SetWebViewClient(DailyWebViewClient.With(this)); articleContent.AddJavascriptInterface(jsInterface, "openlistner"); articleContent.LoadRenderedContent(content); jsInterface.CallFromPageReceived += delegate(object sender, WebViewJSInterface.CallFromPageReceivedEventArgs e) { switch (e.Type) { case WebViewJSInterface.CallFromType.Image: PhotoActivity.Start(this, e.Result.Split(','), e.Index); break; case WebViewJSInterface.CallFromType.Href: Intent intent = new Intent(); intent.SetAction("android.intent.action.VIEW"); intent.SetData(Android.Net.Uri.Parse(e.Result)); intent.SetClassName("com.android.browser", "com.android.browser.BrowserActivity"); StartActivity(intent); break; } }; } txtTime.Text = "创建于:" + Convert.ToDateTime(article.PublishedTime).ToString("yyyy-MM-dd"); if (article.LikesCount > 0) { txtGood.Text = article.LikesCount.ToString(); } if (article.CommentsCount > 0) { txtComments.Text = article.CommentsCount.ToString(); (txtComments.Parent as FrameLayout).Click += delegate { ArticleCommentActivity.Start(this, slug); }; } if (article.TitleImage != "") { Picasso.With(this) .Load(article.TitleImage) .Into(titleImage); } else { appbar.LayoutParameters = new CoordinatorLayout.LayoutParams(CoordinatorLayout.LayoutParams.MatchParent, toolbar.Height); toolbarTitle.Text = title; } var avatar = article.Author.Avatar.Template.Replace("{id}", article.Author.Avatar.Id); avatar = avatar.Replace("{size}", "l"); await ImageService.Instance.LoadUrl(avatar) .Retry(3, 200) .DownSample(40, 40) .Transform(new CircleTransformation()) .LoadingPlaceholder("ic_placeholder.png", ImageSource.ApplicationBundle) .ErrorPlaceholder("ic_placeholder.png", ImageSource.ApplicationBundle) .IntoAsync(imgAvatar); this.article = article; }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); Id = Intent.GetIntExtra("id", 0); questionPresenter = new QuestionPresenter(this); handler = new Handler(); StatusBarCompat.SetOrdinaryToolBar(this); toolbar = FindViewById <Toolbar>(Resource.Id.toolbar); toolbar.SetNavigationIcon(Resource.Drawable.back_24dp); SetSupportActionBar(toolbar); SupportActionBar.SetDisplayHomeAsUpEnabled(true); toolbar.SetNavigationOnClickListener(this); toolbar.SetOnMenuItemClickListener(this); swipeRefreshLayout = FindViewById <SwipeRefreshLayout>(Resource.Id.swipeRefreshLayout); swipeRefreshLayout.SetColorSchemeResources(Resource.Color.primary); swipeRefreshLayout.SetOnRefreshListener(this); txtTitle = FindViewById <TextView>(Resource.Id.txtTitle); imgIconName = FindViewById <ImageView>(Resource.Id.imgIconName); txtUserName = FindViewById <TextView>(Resource.Id.txtUserName); txtScore = FindViewById <TextView>(Resource.Id.txtScore); txtDateAdded = FindViewById <TextView>(Resource.Id.txtDateAdded); txtGold = FindViewById <TextView>(Resource.Id.txtGold); txtDealFlag = FindViewById <TextView>(Resource.Id.txtDealFlag); txtTag = FindViewById <TextView>(Resource.Id.txtTag); this.txtDealFlag.Selected = true; txtBody = FindViewById <WebView>(Resource.Id.txtBody); txtBody.Settings.JavaScriptEnabled = true; txtBody.Settings.DomStorageEnabled = true; txtBody.Settings.LoadsImagesAutomatically = true; txtBody.Settings.DefaultTextEncodingName = "utf-8"; txtBody.SetWebViewClient(BodyWebViewClient.With(this)); txtBody.ScrollBarStyle = ScrollbarStyles.InsideOverlay; txtBody.Settings.SetSupportZoom(false); txtBody.Settings.BuiltInZoomControls = false; txtBody.Settings.CacheMode = CacheModes.CacheElseNetwork; txtBody.Settings.SetLayoutAlgorithm(WebSettings.LayoutAlgorithm.SingleColumn); var jsInterface = new WebViewJSInterface(this); txtBody.AddJavascriptInterface(jsInterface, "openlistner"); jsInterface.CallFromPageReceived += delegate(object sender, WebViewJSInterface.CallFromPageReceivedEventArgs e) { PhotoActivity.Start(this, e.Result.Split(','), e.Index); }; txtDigg = FindViewById <TextView>(Resource.Id.txtDigg); txtRead = FindViewById <TextView>(Resource.Id.txtRead); txtBookmark = FindViewById <TextView>(Resource.Id.txtBookmark); txtComments = FindViewById <TextView>(Resource.Id.txtComments); txtComments.Text = Resources.GetString(Resource.String.answer); (txtComments.Parent as FrameLayout).Click += delegate { if (question != null && question.Qid > 0) { QuestionAnswersActivity.Start(this, question.Qid); } }; (txtBookmark.Parent as FrameLayout).Click += delegate { if (question != null && question.Qid > 0) { var linkurl = "https://q.cnblogs.com/q/" + question.Qid + "/"; var title = question.Title + "_²©ÎÊ_²©¿ÍÔ°"; BookmarkAddActivity.Start(this, linkurl, title, true); } }; swipeRefreshLayout.Post(async() => { await questionPresenter.GetClientQuestion(Id); }); shareAction = new ShareAction(this).SetDisplayList(SHARE_MEDIA.Weixin, SHARE_MEDIA.WeixinCircle, SHARE_MEDIA.WeixinFavorite, SHARE_MEDIA.Sina).SetShareboardclickCallback(this); }