예제 #1
0
        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);
            });

            sharesWidget = new UMengSharesWidget(this);
        }
예제 #2
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            handler = new Handler();
            fm = SupportFragmentManager;

            toolbar = FindViewById<Toolbar>(Resource.Id.toolbar);
            SetSupportActionBar(toolbar);
            toolbar.SetOnMenuItemClickListener(this);

            coordinatorLayout = FindViewById<CoordinatorLayout>(Resource.Id.coordinatorLayout);

            drawerLayout = FindViewById<DrawerLayout>(Resource.Id.drawerLayout);
            navigationView = FindViewById<NavigationView>(Resource.Id.navigationview);
            var headerLayout = navigationView.InflateHeaderView(Resource.Layout.header_layout);
            navigationView.InflateMenu(Resource.Menu.main);
            navigationView.SetNavigationItemSelectedListener(this);
            Avatar = headerLayout.FindViewById<ImageView>(Resource.Id.headerAvatar);
            Avatar.SetOnClickListener(this);
            Author = headerLayout.FindViewById<TextView>(Resource.Id.headerAuthor);
            Seniority = headerLayout.FindViewById<TextView>(Resource.Id.headerSeniority);
            txtLogout = headerLayout.FindViewById<TextView>(Resource.Id.headerLogout);
            txtLogout.Click += delegate
            {
                LoginUtils.Instance(this).DeleteUser();
                UpdateUserView();
            };

            drawerToggle = new ActionBarDrawerToggle(this, drawerLayout, toolbar, Resource.String.drawer_open, Resource.String.drawer_close);
            drawerLayout.AddDrawerListener(this);
            SupportActionBar.SetDisplayHomeAsUpEnabled(true);
            SupportActionBar.SetHomeButtonEnabled(true);

            StatusBarCompat.SetDrawerToolbarTabLayout(this, coordinatorLayout);

            UpdateUserView();

            navigationView.Post(() =>
            {
                SwitchNavigationBar(Resource.Id.home);
            });

            updManager = IFlytekUpdate.GetInstance(this.ApplicationContext);
            updManager.SetDebugMode(true);
            updManager.SetParameter(UpdateConstants.ExtraWifionly, "true");
            updManager.SetParameter(UpdateConstants.ExtraNotiIcon, "true");
            updManager.SetParameter(UpdateConstants.ExtraStyle, UpdateConstants.UpdateUiDialog);
            updManager.AutoUpdate(this, this);

            sharesWidget = new UMengSharesWidget(this);

        }
예제 #3
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            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);
            var packageInfo = this.PackageManager.GetPackageInfo(this.PackageName, 0);
            var txtVersion  = FindViewById <TextView>(Resource.Id.txtVersion);

            txtVersion.Text = packageInfo.VersionName;
            FindViewById <LinearLayout>(Resource.Id.layoutSurvey).Click += (object sender, EventArgs e) =>
            {
                Intent intent = new Intent(Intent.ActionSendto);
                intent.AddFlags(ActivityFlags.NewTask);
                intent.SetData(Android.Net.Uri.Parse("mailto:" + Resources.GetString(Resource.String.survey_email)));
                if (intent.ResolveActivity(this.PackageManager) != null)
                {
                    intent.PutExtra(Intent.ExtraSubject, "来自 " + packageInfo.PackageName + " - " + packageInfo.VersionName + " 的反馈意见");
                    intent.PutExtra(Intent.ExtraText, "设备信息:Android " + Build.VERSION.Release + " - " + Build.Manufacturer + " - " + Build.Model + "\n(如果涉及隐私请手动删除这个内容)\n\n");
                    StartActivity(intent);
                }
                else
                {
                    Toast.MakeText(this, "系统中没有安装邮件客户端", ToastLength.Short).Show();
                }
            };
            FindViewById <LinearLayout>(Resource.Id.layoutQQ).Click += (object sender, EventArgs e) =>
            {
                sharesWidget.Open("http://shang.qq.com/wpa/qunwpa?idkey=5c281d37638467fb0f411484dcd513b89ba82b58decb8518cc2523b95232dd9b", "博客园第三方APP开发交流群");
            };
            FindViewById <LinearLayout>(Resource.Id.layoutOpenSourceUrl).Click += (object sender, EventArgs e) =>
            {
                sharesWidget.Open(Resources.GetString(Resource.String.open_source_url), "博客园第三方Android客户端,Xamarin App,Material Design风格");
            };
            sharesWidget = new UMengSharesWidget(this);
        }
예제 #4
0
        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);
            });
            sharesWidget = new UMengSharesWidget(this);
        }