Beispiel #1
0
        protected override async void OnCreate(Bundle savedInstanceState)
        {
            string theme = SettingsHelper.GetTheme(this);

            if (theme == "dark")
            {
                SetTheme(Resource.Style.Dark_Theme);
            }

            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.services_activity);

            Android.Support.V7.Widget.Toolbar toolbar = FindViewById(Resource.Id.toolbar).JavaCast <Android.Support.V7.Widget.Toolbar>();
            toolbar.SetContentInsetsAbsolute(0, 0);
            SetSupportActionBar(toolbar);

            ImageView backButton = FindViewById <ImageView>(Resource.Id.MenuButton);

            backButton.Click += ((sender, e) =>
            {
                OnBackPressed();
            });

            recyclerView = FindViewById <RecyclerView>(Resource.Id.recyclerView);

            LinearLayoutManager lm = new LinearLayoutManager(this);

            recyclerView.SetLayoutManager(lm);

            ProgressDialog progress = new ProgressDialog(this, Resource.Style.MyAlertDialogStyle);

            progress.SetMessage(Resources.GetString(Resource.String.loading_services));
            progress.SetProgressStyle(ProgressDialogStyle.Spinner);
            progress.Indeterminate = true;
            progress.SetCancelable(false);
            progress.Show();

            ISharedPreferences preferences = PreferenceManager.GetDefaultSharedPreferences(this);
            Configuration      config      = BaseContext.Resources.Configuration;
            String             lang        = preferences.GetString("locale", null);

            string token = SettingsHelper.GetToken(this);

            services = await ServiceHelper.GetServices(token);

            if (services != null)
            {
                ServicesAdapter adapter = new ServicesAdapter(services, lang);
                recyclerView.SetAdapter(adapter);
                adapter.ItemClick += Adapter_ItemClick;
            }

            progress.Dismiss();
        }