Esempio n. 1
0
        protected override async void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.TrainTime);
            InitializeLayoutParams();
            Window.SetStatusBarColor(new Android.Graphics.Color(Android.Support.V4.Content.ContextCompat.GetColor(this, Resource.Color.colorPrimary)));

            mainLinearLayout   = FindViewById <LinearLayout>(Resource.Id.MainLinearLayout);
            backButton         = FindViewById <ImageView>(Resource.Id.BackButton);
            favoriteButton     = FindViewById <ImageView>(Resource.Id.FavoriteButton);
            swipeRefreshLayout = FindViewById <SwipeRefreshLayout>(Resource.Id.swipe_refresh);
            toolBarText        = FindViewById <TextView>(Resource.Id.ToolbarText);
            GettedTimeTextView = FindViewById <TextView>(Resource.Id.GetedTimeTextView);

            backButton.Click           += BackButton_Click;
            favoriteButton.Click       += FavoriteButton_Click;
            swipeRefreshLayout.Refresh += SwipeRefreshLayout_Refresh;

            station = StationReader.GetStationByName(Intent.GetStringExtra("station"));
            if (station is null)
            {
                throw new NotSupportedException();
            }
            else
            {
                IsFavorited = UserConfigManager.IsFavoriteStation(station);
                await ShowData();

                toolBarText.Text = station.Name;
                favoriteButton.SetImageResource(IsFavorited ? Resource.Drawable.FavoritedIcon : Resource.Drawable.AddFavoriteIcon);
            }
        }
Esempio n. 2
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.TrainPosition);
            Window.SetStatusBarColor(new Android.Graphics.Color(Android.Support.V4.Content.ContextCompat.GetColor(this, Resource.Color.colorPrimary)));

            var line = Intent.GetStringExtra("Line");

            jrhLine = JrhLineCreater.FromString(line);

            trainPostionLinearLayout = FindViewById <LinearLayout>(Resource.Id.TrainpositionLinearLayout);
            var backButton = FindViewById <ImageView>(Resource.Id.BackButton);

            favoriteButton = FindViewById <ImageView>(Resource.Id.FavoriteButton);
            var TitleTextView = FindViewById <TextView>(Resource.Id.ToolbarText);

            swipeRefreshLayout = FindViewById <SwipeRefreshLayout>(Resource.Id.swipe_refresh);
            GettedTimeTextView = FindViewById <TextView>(Resource.Id.GetedTimeTextView);

            favoriteButton.Click       += FavoriteButton_Click;
            backButton.Click           += BackButton_Click;
            TitleTextView.Text          = jrhLine.GetName();
            swipeRefreshLayout.Refresh += SwipeRefreshLayout_Refresh;

            IsFavorited = UserConfigManager.IsFavoriteLine(jrhLine);
            favoriteButton.SetImageResource(IsFavorited ? Resource.Drawable.FavoritedIcon : Resource.Drawable.AddFavoriteIcon);

            RenderData(jrhLine);
        }
Esempio n. 3
0
 private void FavoriteButton_Click(object sender, EventArgs e)
 {
     if (IsFavorited)
     {
         UserConfigManager.DeleteFavoriteStation(station);
         var toast = Toast.MakeText(this, $"{station.Name}を削除しました", ToastLength.Short);
         toast.SetGravity(GravityFlags.Bottom, 0, 0);
         toast.Show();
         IsFavorited = false;
     }
     else
     {
         UserConfigManager.AddfavoriteStation(station);
         var toast = Toast.MakeText(this, $"{station.Name}を追加しました", ToastLength.Short);
         toast.SetGravity(GravityFlags.Bottom, 0, 0);
         toast.Show();
         IsFavorited = true;
     }
     favoriteButton.SetImageResource(IsFavorited ? Resource.Drawable.FavoritedIcon : Resource.Drawable.AddFavoriteIcon);
 }