protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.myCarInfo);
            string   carId               = Intent.GetStringExtra("ID");
            TextView myCarModelView      = FindViewById <TextView>(Resource.Id.myCarInfoModel);
            TextView myCarProductionView = FindViewById <TextView>(Resource.Id.myCarInfoProduction);
            TextView myCarLicenseView    = FindViewById <TextView>(Resource.Id.myCarInfoLicense);
            TextView myCarModeView       = FindViewById <TextView>(Resource.Id.myCarInfoMode);
            Button   myCarsExit          = FindViewById <Button>(Resource.Id.myCarExit);

            myCarsExit.Click += funcExit;


            carInfo_result info = new carInfo_result();

            info.get_from_cloud("https://carshareserver.azurewebsites.net/api/getCarDetails?vehicle_id=" + carId);
            carTotalInfo totalInfo = info.getInfo();

            myCarModelView.Text      = totalInfo.Manufacturer + " " + totalInfo.model;
            myCarProductionView.Text = totalInfo.year;
            myCarLicenseView.Text    = carId;
            if (totalInfo.mode)
            {
                myCarModeView.Text = "Automatic";
            }
            else
            {
                myCarModeView.Text = "Manual";
            }

            if (totalInfo.img != "")
            {
                imgAdress = totalInfo.img;
                GetImageBitmapFromUrl(imgAdress, loadCarImage);

                void loadCarImage(object sender, DownloadDataCompletedEventArgs e)
                {
                    byte[] raw  = e.Result;
                    Bitmap img1 = BitmapFactory.DecodeByteArray(raw, 0, raw.Length);

                    if (img1 != null)
                    {
                        imagen = FindViewById <ImageView>(Resource.Id.myCarInfoImg);
                        imagen.SetImageBitmap(img1);

                        //Calculate image size
                        double ratio = (double)img1.Height / (double)img1.Width;
                        FindViewById <RelativeLayout>(Resource.Id.myCarloadingPanel).Visibility = ViewStates.Gone;
                        imagen.LayoutParameters.Height = (int)((double)Resources.DisplayMetrics.WidthPixels * ratio);
                    }
                }
            }
            else
            {
                FindViewById <RelativeLayout>(Resource.Id.myCarloadingPanel).Visibility = ViewStates.Gone;
            }
        }
Example #2
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            carId = Intent.GetStringExtra("ID");
            SetContentView(Resource.Layout.carInfoLayout);
            GridLayout carModeGridLayout = FindViewById <GridLayout>(Resource.Id.gridLayout1);

            TextView carModelView      = FindViewById <TextView>(Resource.Id.carInfoModel);
            TextView carProductionView = FindViewById <TextView>(Resource.Id.carInfoProduction);
            TextView carLicenseView    = FindViewById <TextView>(Resource.Id.carInfoLicense);
            TextView carModeView       = FindViewById <TextView>(Resource.Id.carInfoMode);
            TextView carUserView       = FindViewById <TextView>(Resource.Id.carInfoUser);
            TextView carUserEmailView  = FindViewById <TextView>(Resource.Id.carInfoUserEmail);
            TextView carInfoReview     = FindViewById <TextView>(Resource.Id.carInfoUserReview);

            requestCarButton        = FindViewById <Button>(Resource.Id.requestCarButton);
            requestCarButton.Click += requestCar;
            Button viewReviews = FindViewById <Button>(Resource.Id.carInfoViewReviews);

            viewReviews.Click += viewFunc;
            carInfo_result info = new carInfo_result();

            info.get_from_cloud("https://carshareserver.azurewebsites.net/api/getCarDetails?vehicle_id=" + carId);
            carTotalInfo totalInfo = info.getInfo();

            carModelView.Text      = totalInfo.Manufacturer + " " + totalInfo.model;
            carProductionView.Text = totalInfo.year;
            carLicenseView.Text    = carId;
            if (totalInfo.mode)
            {
                carModeView.Text = "Automatic";
            }
            else
            {
                carModeView.Text = "Manual";
            }

            user carOwner = totalInfo.User;

            Preferences.Set("reviewee", carOwner.id);
            carUserView.Text      = carOwner.first_name + " " + carOwner.last_name;
            carUserEmailView.Text = carOwner.email;
            async void GetImageBitmapFromUrl(string url, DownloadDataCompletedEventHandler eventFunc)
            {
                Bitmap img1 = null;

                using (var webClient = new System.Net.WebClient())
                {
                    webClient.DownloadDataCompleted += eventFunc;
                    webClient.DownloadDataAsync(new Uri(url));
                }
            }

            if (carOwner.img != "")
            {
                GetImageBitmapFromUrl("https://carshareserver.azurewebsites.net/api/getUserImage?user_id=" + carOwner.id, loadUserImage);

                void loadUserImage(object sender, DownloadDataCompletedEventArgs e)
                {
                    byte[] raw  = e.Result;
                    Bitmap img1 = BitmapFactory.DecodeByteArray(raw, 0, raw.Length);

                    if (img1 != null)
                    {
                        ImageView userImage = FindViewById <ImageView>(Resource.Id.userImg);
                        userImage.SetImageBitmap(img1);
                    }
                }
            }
            if (totalInfo.img != "")
            {
                imgAdress = totalInfo.img;
                GetImageBitmapFromUrl(imgAdress, loadCarImage);

                void loadCarImage(object sender, DownloadDataCompletedEventArgs e)
                {
                    byte[] raw  = e.Result;
                    Bitmap img1 = BitmapFactory.DecodeByteArray(raw, 0, raw.Length);

                    if (img1 != null)
                    {
                        ImageView imagen = FindViewById <ImageView>(Resource.Id.carInfoImg);
                        imagen.SetImageBitmap(img1);

                        //Calculate image size
                        double ratio = (double)img1.Height / (double)img1.Width;
                        FindViewById <RelativeLayout>(Resource.Id.carInfoLoadingPanel).Visibility = ViewStates.Gone;
                        imagen.LayoutParameters.Height = (int)((double)Resources.DisplayMetrics.WidthPixels * ratio);
                    }
                }
            }
            else
            {
                FindViewById <RelativeLayout>(Resource.Id.carInfoLoadingPanel).Visibility = ViewStates.Gone;
            }
            reviewee = carOwner.id;
            string user_id    = Preferences.Get("user_id", "");
            string login_hash = Preferences.Get("login_hash", "");
            string address    = "https://carshareserver.azurewebsites.net/api/getReviews?reviewee_id=" + reviewee + "&login_hash=" + login_hash + "&user_id=" + user_id;

            reviewInfo.get_from_cloud(address);
            int stauts = reviewInfo.getReviews().status;

            if (stauts == -1)
            {
                carInfoReview.Text = "N/A";
            }
            else
            {
                if (reviewInfo.getReviews().avg_rate == -1)
                {
                    carInfoReview.Text = "N/A";
                }
                else
                {
                    carInfoReview.Text = reviewInfo.getReviews().avg_rate.ToString();
                }
            }
        }
Example #3
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            SetContentView(Resource.Layout.openCarLayout);
            base.OnCreate(savedInstanceState);
            carId = Intent.GetStringExtra("ID");

            carInfo_result info = new carInfo_result();

            info.get_from_cloud("https://carshareserver.azurewebsites.net/api/getCarDetails?vehicle_id=" + carId);
            carTotalInfo totalInfo = info.getInfo();

            IMG = totalInfo.img;

            CheckBt();
            bluetoothDeviceReceiver = new BluetoothDeviceReceiver(MAC_ADDRESS, this);
            RegisterReceiver(bluetoothDeviceReceiver, new IntentFilter(BluetoothDevice.ActionFound));

            openCarButton = FindViewById <Button>(Resource.Id.openCarButton);
            var gradientDrawable = openCarButton.Background.Current as GradientDrawable;

            gradientDrawable.SetColor(Color.Gray);
            openCarButton.Click  += tryOpenCar;
            openCarButton.Enabled = false;

            TextView lisence = FindViewById <TextView>(Resource.Id.openCarLicense);

            lisence.Text = carId;
            async void GetImageBitmapFromUrl(string url, DownloadDataCompletedEventHandler eventFunc)
            {
                Bitmap img1 = null;

                using (var webClient = new System.Net.WebClient())
                {
                    webClient.DownloadDataCompleted += eventFunc;
                    webClient.DownloadDataAsync(new Uri(url));
                }
            }

            if (IMG != "")
            {
                GetImageBitmapFromUrl(IMG, loadCarImage);
                void loadCarImage(object sender, DownloadDataCompletedEventArgs e)
                {
                    byte[] raw  = e.Result;
                    Bitmap img1 = BitmapFactory.DecodeByteArray(raw, 0, raw.Length);

                    if (img1 != null)
                    {
                        ImageView imagen = FindViewById <ImageView>(Resource.Id.openCarImg);
                        imagen.SetImageBitmap(img1);

                        //Calculate image size
                        double ratio = (double)img1.Height / (double)img1.Width;
                        FindViewById <RelativeLayout>(Resource.Id.openCarloadingPanel).Visibility = ViewStates.Gone;
                        imagen.LayoutParameters.Height = (int)((double)Resources.DisplayMetrics.WidthPixels * ratio);
                    }
                }
            }
            else
            {
                FindViewById <RelativeLayout>(Resource.Id.openCarloadingPanel).Visibility = ViewStates.Gone;
            }


            bool started = mBluetoothAdapter.StartDiscovery();

            System.Console.WriteLine("is scan startd: " + started);
            //Connect();
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.handleReqLayout);
            carId     = Intent.GetStringExtra("ID");
            renter_id = Intent.GetStringExtra("renter_id");


            user   user       = new user();
            string login_hash = Preferences.Get("login_hash", "1");

            user.get_from_cloud(renter_id, login_hash);

            approve   = FindViewById <Button>(Resource.Id.approveReqButton);
            decline   = FindViewById <Button>(Resource.Id.declineReqButton);
            carImage  = FindViewById <ImageView>(Resource.Id.handleRequstImg);
            lisence   = FindViewById <TextView>(Resource.Id.handelReqLicense);
            userEmail = FindViewById <TextView>(Resource.Id.handleReqUserEmail);
            username  = FindViewById <TextView>(Resource.Id.handleReqUserName);

            username.Text  = user.first_name + " " + user.last_name;
            userEmail.Text = user.email;

            approve.Click += approveAction;
            decline.Click += declineAction;
            carInfo_result info = new carInfo_result();

            info.get_from_cloud("https://carshareserver.azurewebsites.net/api/getCarDetails?vehicle_id=" + carId);
            carTotalInfo totalInfo = info.getInfo();

            IMG          = totalInfo.img;
            lisence.Text = totalInfo.id;
            async void GetImageBitmapFromUrl(string url, DownloadDataCompletedEventHandler eventFunc)
            {
                Bitmap img1 = null;

                using (var webClient = new System.Net.WebClient())
                {
                    webClient.DownloadDataCompleted += eventFunc;
                    webClient.DownloadDataAsync(new Uri(url));
                }
            }

            if (IMG != "")
            {
                GetImageBitmapFromUrl(IMG, loadCarImage);

                void loadCarImage(object sender, DownloadDataCompletedEventArgs e)
                {
                    byte[] raw  = e.Result;
                    Bitmap img1 = BitmapFactory.DecodeByteArray(raw, 0, raw.Length);

                    if (img1 != null)
                    {
                        ImageView imagen = FindViewById <ImageView>(Resource.Id.handleRequstImg);
                        imagen.SetImageBitmap(img1);

                        //Calculate image size
                        double ratio = (double)img1.Height / (double)img1.Width;
                        FindViewById <RelativeLayout>(Resource.Id.handelReqLoadingPanel).Visibility = ViewStates.Gone;
                        imagen.LayoutParameters.Height = (int)((double)Resources.DisplayMetrics.WidthPixels * ratio);
                    }
                }
            }
            else
            {
                FindViewById <RelativeLayout>(Resource.Id.handelReqLoadingPanel).Visibility = ViewStates.Gone;
            }
        }