Esempio n. 1
0
        protected void ManageButtonProfile()
        {
            tmp      = bearer;
            isUpload = true;
            APICall apiCall = new APICall();

            bearer   = tmp;
            listView = FindViewById <ListView>(Resource.Id.listview);
            ImageView ImageView = FindViewById <ImageView>(Resource.Id.background);
            Button    back      = FindViewById <Button>(Resource.Id.back);

            back.Click += delegate
                          // When back clicked set view to FrontPage
            {
                SetContentView(Resource.Layout.activity_main);
                ManageButtonLogin();
            };
            Button upload = FindViewById <Button>(Resource.Id.upload);

            upload.Click += async delegate
            {
                FileData filedata = await CrossFilePicker.Current.PickFile();

                if (filedata != null)
                {
                    Byte[] file = filedata.DataArray;
                    Console.WriteLine(filedata.FileName);
                    APICall api = new APICall();
                    api.UploadPicture(Convert.ToBase64String(file), filedata.FileName, "Xamarin c'est pas tiptop", tmp);
                    listView.Adapter = new HomeScreenAdapter(this, apiCall.GetPictureUploaded(tmp));
                }
            };
            Button switchPage = FindViewById <Button>(Resource.Id.switchPage);

            switchPage.Click += delegate
            {
                if (isUpload)
                {
                    isUpload = false;
                    ImageView.SetBackgroundResource(Resource.Drawable.Profile2);
                    listView.Adapter = new HomeScreenAdapter(this, apiCall.GetPictureFavorited(tmp));
                }
                else
                {
                    isUpload = true;
                    ImageView.SetBackgroundResource(Resource.Drawable.Profile);
                    listView.Adapter = new HomeScreenAdapter(this, apiCall.GetPictureUploaded(tmp));
                }
            };
            if (isUpload)
            {
                listView.Adapter = new HomeScreenAdapter(this, apiCall.GetPictureUploaded(tmp));
            }
            else
            {
                listView.Adapter = new HomeScreenAdapter(this, apiCall.GetPictureFavorited(tmp));
            }
        }
Esempio n. 2
0
        protected void ManageButtonFrontpage()
        {
            this.frontpage = new APICall();
            Button login = FindViewById <Button>(Resource.Id.profile);

            login.Click += delegate
            {
                SetContentView(Resource.Layout.activity_main);
                ManageButtonLogin();
            };
            Constructor(frontpage);
        }
Esempio n. 3
0
        protected void Constructor(APICall frontpage)
        {
            APICall api = new APICall();

            if (tmp == null)
            {
                tmp = "c15bf5ea4b40e6c6f2728a17c4173672d556823e";
            }
            this.tag          = FindViewById <Button>(Resource.Id.tag);
            this.editTextTag  = FindViewById <EditText>(Resource.Id.editTextTag);
            this.frontpageStr = new List <string>();
            this.frontpageStr = frontpage.GetFrontpage("user", "time", 1, "day", tmp); // TODO remove this and ask users for the parameters they want
            tagClicked();
            listView            = FindViewById <ListView>(Resource.Id.listview);
            listView.Adapter    = new HomeScreenAdapter(this, frontpageStr);
            listView.ItemClick += (object sender, Android.Widget.AdapterView.ItemClickEventArgs e) =>
            {
                string selectedFromList = listView.GetItemAtPosition(e.Position).ToString();
                Console.WriteLine(selectedFromList);
                selectedFromList = selectedFromList.Substring(20, selectedFromList.Length - 24);
                api.FavoritePicture(selectedFromList, tmp);
            };
        }