예제 #1
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            ViewGroup root = (ViewGroup)inflater.Inflate(Resource.Layout.fragment_content_activitybydate, null);

            txt_current_date = root.FindViewById <TextView>(Resource.Id.txt_current_date_new);
            DateTime dtnow;
            var      datestring = dtstate = Arguments.GetString("siteparamdate");

            dtnow = DateTime.ParseExact(datestring, "dd-MM-yyyy", System.Globalization.CultureInfo.InvariantCulture);
            txt_current_date.Text = string.Format("{0} {1}, {2}", dtnow.ToString("MMMM", System.Globalization.CultureInfo.InvariantCulture), dtnow.Day.ToString(), dtnow.Year);

            try
            {
                string mStringLoginInfo    = string.Empty;
                string mStringSessionToken = string.Empty;
                try
                {
                    objdb = new DBaseOperations();
                    var lstu = objdb.selectTable();
                    if (lstu != null && lstu.Count > default(int))
                    {
                        var uobj = lstu.FirstOrDefault();
                        if (uobj.Password == " ")
                        {
                            throw new Exception("Please login again");
                        }
                        mStringLoginInfo    = uobj.EmailId;
                        mStringSessionToken = uobj.AuthToken;
                    }
                }
                catch { }

                var client  = new RestClient(Common.UrlBase);
                var request = new RestRequest("Activity/GetActivityListByMonth", Method.GET);
                request.AddHeader("Content-Type", "application/json");
                request.AddHeader("TokenKey", mStringSessionToken);
                request.AddQueryParameter("dateStamp", dtnow.ToString("yyyy-MM-dd"));
                IRestResponse response    = client.Execute(request);
                var           content     = response.Content;
                var           responseObj = Newtonsoft.Json.JsonConvert.DeserializeObject <IList <ActivityDetailResponse> >(content);
                if (responseObj != null && responseObj.Count() > default(int))
                {
                    var            vCategoryString     = responseObj.Select(r => r.CategoryName).ToList();
                    var            vCategoryCodeString = responseObj.Select(r => r.CategoryID).ToList();
                    var            strCategoryImgUrls  = new List <string>();
                    IList <Bitmap> vCategoryViewImage  = new List <Bitmap>();
                    if (vCategoryString != null && vCategoryString.Count() > default(int))
                    {
                        foreach (var v in vCategoryString)
                        {
                            strCategoryImgUrls.Add(string.Format("{0}.png", v));
                        }
                        vCategoryViewImage = BitmapHelpers.GetImageListFromUrlList(strCategoryImgUrls, mStringSessionToken, this.Activity.Resources);
                    }

                    var            vProductString      = responseObj.Select(r => r.ProductName).ToList();
                    var            vProductCodeString  = responseObj.Select(r => r.ProductId).ToList();
                    var            strProductViewImage = new List <string>();
                    IList <Bitmap> vProductViewImage   = new List <Bitmap>();
                    if (vProductString != null && vProductString.Count() > default(int))
                    {
                        foreach (var v in vProductString)
                        {
                            strProductViewImage.Add(string.Format("{0}.png", v));
                        }
                        vProductViewImage = BitmapHelpers.GetImageListFromUrlList(strProductViewImage, mStringSessionToken, this.Activity.Resources);
                    }

                    var vProductActivityFor = responseObj.Select(r => r.ActivityDescription).ToList();

                    var vProductActivityCode = responseObj.Select(r => r.ActivityId).ToList();

                    gridViewCategoryString     = vCategoryString.ToArray();
                    gridViewCategoryCodeString = vCategoryCodeString.ToArray();
                    gridCategoryViewImage      = vCategoryViewImage.ToArray();
                    gridViewProductString      = vProductString.ToArray();
                    gridViewProductCodeString  = vProductCodeString.ToArray();
                    gridProductViewImage       = vProductViewImage.ToArray();
                    gridProductActivityFor     = vProductActivityFor.ToArray();
                    gridProductActivityCode    = vProductActivityCode.ToArray();
                }
                else
                {
                    //throw new Exception("No item found");

                    ActivityViewerFragment objFragment            = new ActivityViewerFragment();
                    Android.Support.V4.App.FragmentTransaction tx = FragmentManager.BeginTransaction();
                    tx.Replace(Resource.Id.m_main, objFragment, Constants.activityviewer);
                    tx.Commit();
                }

                _activity_dayview_helper adapterViewAndroid = new _activity_dayview_helper(this.Activity, gridViewCategoryString, gridViewCategoryCodeString, gridCategoryViewImage, gridViewProductString, gridViewProductCodeString, gridProductViewImage, gridProductActivityFor, gridProductActivityCode);
                androidGridView = root.FindViewById <GridView>(Resource.Id.grid_view_adctivity_dayview);
                new System.Threading.Thread(new System.Threading.ThreadStart(() =>
                {
                    if (this.Activity != null)
                    {
                        this.Activity.RunOnUiThread(() =>
                        {
                            androidGridView.SetAdapter(adapterViewAndroid);
                        });
                    }
                })).Start();
                androidGridView.ItemClick += (sndr, argus) => ItemSearch_clicked(sndr, argus, this.Activity);
            }
            catch (Exception ex)
            {
                this.Activity.RunOnUiThread(() =>
                {
                    Android.App.AlertDialog.Builder alertDiag = new Android.App.AlertDialog.Builder(this.Activity);
                    alertDiag.SetTitle(Resource.String.DialogHeaderError);
                    alertDiag.SetMessage(ex.Message);
                    alertDiag.SetIcon(Resource.Drawable.alert);
                    alertDiag.SetPositiveButton(Resource.String.DialogButtonOk, (senderAlert, args) =>
                    {
                        ActivityViewerFragment objFragment            = new ActivityViewerFragment();
                        Android.Support.V4.App.FragmentTransaction tx = FragmentManager.BeginTransaction();
                        tx.Replace(Resource.Id.m_main, objFragment, Constants.activityviewer);
                        tx.Commit();
                    });
                    Dialog diag = alertDiag.Create();
                    diag.Show();
                    diag.SetCanceledOnTouchOutside(false);
                });
            }

            return(root);
        }
예제 #2
0
        private void ItemSearch_clicked(object sender, AdapterView.ItemClickEventArgs e, Activity currentActivity)
        {
            androidGridView.ItemClick -= (sndr, argus) => ItemSearch_clicked(sndr, argus, currentActivity);
            try
            {
                if (gridViewCodeString[e.Position] == "BCK")
                {
                    DashboardFragment objFragment = new DashboardFragment();
                    Android.Support.V4.App.FragmentTransaction tx = FragmentManager.BeginTransaction();
                    tx.Replace(Resource.Id.m_main, objFragment, Constants.dashboard);
                    tx.Commit();
                }
                else if (gridViewCodeString[e.Position] == "NPR")
                {
                    if (objSelectedItem == null)
                    {
                        objSelectedItem = new List <ItemPayloadModelWithBase64>();
                    }
                    objSelectedItem.Add(new ItemPayloadModelWithBase64()
                    {
                        ItemName = gridViewString[e.Position],
                        ItemCode = gridViewCodeString[e.Position],
                        ItemIcon = BitmapHelpers.BitmapToBase64(gridViewImages[e.Position]),
                        prdType  = (ProductType)Convert.ToInt32(gridViewTypeCodeString[e.Position])
                    });

                    Bundle utilBundle = new Bundle();
                    utilBundle.PutString("siteparam", Newtonsoft.Json.JsonConvert.SerializeObject(objSelectedItem));
                    AddProductFragment objFragment = new AddProductFragment();
                    objFragment.Arguments = utilBundle;
                    Android.Support.V4.App.FragmentTransaction tx = FragmentManager.BeginTransaction();
                    tx.Replace(Resource.Id.m_main, objFragment, Constants.dashboard);
                    tx.Commit();
                }
                else
                {
                    //Identification of parent selection
                    if (gridViewCodeString[e.Position].Contains("Ø"))
                    {
                        objSelectedItem = null;
                    }

                    if (objSelectedItem == null)
                    {
                        objSelectedItem = new List <ItemPayloadModelWithBase64>();
                    }
                    objSelectedItem.Add(new ItemPayloadModelWithBase64()
                    {
                        ItemName = gridViewString[e.Position],
                        ItemCode = gridViewCodeString[e.Position],
                        ItemIcon = BitmapHelpers.BitmapToBase64(gridViewImages[e.Position]),
                        prdType  = (ProductType)Convert.ToInt32(gridViewTypeCodeString[e.Position])
                    });

                    if (gridViewCodeString[e.Position].Contains("Ø"))
                    {
                        AddActivityFragment objFragment = new AddActivityFragment();
                        Android.Support.V4.App.FragmentTransaction tx = FragmentManager.BeginTransaction();
                        tx.Replace(Resource.Id.m_main, objFragment, Constants.addactivity);
                        tx.Commit();
                    }
                    else
                    {
                        Bundle utilBundle = new Bundle();
                        if (objSelectedItem == null || objSelectedItem.Count() <= default(int))
                        {
                            AddActivityFragment objFragment = new AddActivityFragment();
                            Android.Support.V4.App.FragmentTransaction tx = FragmentManager.BeginTransaction();
                            tx.Replace(Resource.Id.m_main, objFragment, Constants.addactivity);
                            tx.Commit();
                        }
                        else if (objSelectedItem != null && objSelectedItem.Count() > default(int) && objSelectedItem.Count() <= 1)
                        {
                            utilBundle.PutString("siteparam", Newtonsoft.Json.JsonConvert.SerializeObject(objSelectedItem));
                            AddActivityFragment objFragment = new AddActivityFragment();
                            objFragment.Arguments = utilBundle;
                            Android.Support.V4.App.FragmentTransaction tx = FragmentManager.BeginTransaction();
                            tx.Replace(Resource.Id.m_main, objFragment, Constants.addactivity);
                            tx.Commit();
                        }
                        else if (objSelectedItem != null && objSelectedItem.Count() > 1)
                        {
                            utilBundle.PutString("siteparam", Newtonsoft.Json.JsonConvert.SerializeObject(objSelectedItem));
                            AddSelectedItemFragment objFragment = new AddSelectedItemFragment();
                            objFragment.Arguments = utilBundle;
                            Android.Support.V4.App.FragmentTransaction tx = FragmentManager.BeginTransaction();
                            tx.Replace(Resource.Id.m_main, objFragment, Constants.addactivity);
                            tx.Commit();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                currentActivity.RunOnUiThread(() =>
                {
                    Android.App.AlertDialog.Builder alertDiag = new Android.App.AlertDialog.Builder(currentActivity);
                    alertDiag.SetTitle(Resource.String.DialogHeaderError);
                    alertDiag.SetMessage(ex.Message);
                    alertDiag.SetIcon(Resource.Drawable.alert);
                    alertDiag.SetPositiveButton(Resource.String.DialogButtonOk, (senderAlert, args) =>
                    {
                        androidGridView.ItemClick += (sndr, argus) => ItemSearch_clicked(sndr, argus, currentActivity);
                    });
                    Dialog diag = alertDiag.Create();
                    diag.Show();
                    diag.SetCanceledOnTouchOutside(false);
                });
            }
        }
예제 #3
0
 private async System.Threading.Tasks.Task ResponseChat(ViewGroup root, Activity currentActivity, string Question)
 {
     await System.Threading.Tasks.Task.Run(() =>
     {
         try
         {
             var answer = this.Communicator(Question).FirstOrDefault().answer.Trim();
             if (!string.IsNullOrEmpty(answer))
             {
                 var objmsgAns                   = new Message();
                 objmsgAns.sender                = new UserLoginInfo();
                 objmsgAns.sender.GoodName       = Constants.ChatBotName;
                 objmsgAns.sender.ProfilePicture = BitmapHelpers.BitmapToBase64(BitmapHelpers.GetBitmapFromResource(currentActivity.Resources, Resource.Drawable.chatbot));
                 objmsgAns.message               = answer;
                 objmsgAns.createdAt             = DateTime.Now;
                 msg.Add(objmsgAns);
                 this.MessageSetter(msg, currentActivity, root, (Android.Support.V4.App.Fragment)FragmentManager.FindFragmentByTag(Constants.chatbot));
             }
         }
         catch { }
     });
 }
예제 #4
0
        protected void Send_Clicked(object sender, EventArgs e, Activity currentActivity, ViewGroup root)
        {
            button_chatbox_send.Click -= (sndr, argus) => Send_Clicked(sndr, argus, currentActivity, root);
            try
            {
                if (!string.IsNullOrEmpty(edittext_chatbox.Text.Trim()))
                {
                    if (msg == null)
                    {
                        msg = new List <Message>();
                    }

                    UserLoginInfo uobj = new UserLoginInfo();
                    try
                    {
                        objdb = new DBaseOperations();
                        var lstu = objdb.selectTable();
                        if (lstu != null && lstu.Count > default(int))
                        {
                            uobj = lstu.FirstOrDefault();
                        }
                    }
                    catch { }

                    var objmsg = new Message();
                    objmsg.message         = edittext_chatbox.Text.Trim();
                    objmsg.createdAt       = DateTime.Now;
                    objmsg.sender          = new UserLoginInfo();
                    objmsg.sender.EmailId  = uobj.EmailId;
                    objmsg.sender.GoodName = uobj.GoodName;
                    if (!string.IsNullOrEmpty(uobj.ProfilePicture))
                    {
                        objmsg.sender.ProfilePicture = uobj.ProfilePicture;
                    }
                    else
                    {
                        objmsg.sender.ProfilePicture = BitmapHelpers.BitmapToBase64(BitmapHelpers.GetBitmapFromResource(this.Activity.Resources, Resource.Drawable.chatbot));
                    }
                    msg.Add(objmsg);
                    this.MessageSetter(msg, currentActivity, root, (Android.Support.V4.App.Fragment)FragmentManager.FindFragmentByTag(Constants.chatbot));
                    var requestChatMsg = edittext_chatbox.Text.Trim();
                    edittext_chatbox.Text = string.Empty;

                    ThreadPool.QueueUserWorkItem(state =>
                    {
                        currentActivity.RunOnUiThread(() => this.ResponseChat(root, currentActivity, requestChatMsg));
                    });
                }
            }
            catch (Exception ex)
            {
                currentActivity.RunOnUiThread(() =>
                {
                    Android.App.AlertDialog.Builder alertDiag = new Android.App.AlertDialog.Builder(currentActivity);
                    alertDiag.SetTitle(Resource.String.DialogHeaderError);
                    alertDiag.SetMessage(ex.Message);
                    alertDiag.SetIcon(Resource.Drawable.alert);
                    alertDiag.SetPositiveButton(Resource.String.DialogButtonOk, (senderAlert, args) =>
                    {
                        //button_chatbox_send.Click += (sndr, argus) => Send_Clicked(sndr, argus, currentActivity, root);
                    });
                    Dialog diag = alertDiag.Create();
                    diag.Show();
                    diag.SetCanceledOnTouchOutside(false);
                });
            }
        }
예제 #5
0
        public override void OnActivityResult(int requestCode, int resultCode, Intent data)
        {
            try
            {
                if (Build.VERSION.SdkInt >= Build.VERSION_CODES.M)
                {
                    if (Android.Support.V4.Content.ContextCompat.CheckSelfPermission(this.Activity, Manifest.Permission.WriteExternalStorage) != (int)Permission.Granted)
                    {
                        Android.Support.V4.App.ActivityCompat.RequestPermissions(this.Activity, new String[] { Manifest.Permission.WriteExternalStorage, Manifest.Permission.ReadExternalStorage }, 53);
                    }
                    else
                    {
                        if (requestCode == 102)
                        {
                            Intent mediaScanIntent = new Intent(Intent.ActionMediaScannerScanFile);
                            Uri    contentUri      = Uri.FromFile(_file);
                            mediaScanIntent.SetData(contentUri);
                            this.Activity.SendBroadcast(mediaScanIntent);
                            int height = profile_image0.Height;
                            int width  = Resources.DisplayMetrics.WidthPixels;
                            using (Android.Graphics.Bitmap bitmap = _file.Path.LoadAndResizeBitmap(width, height))
                            {
                                profile_image0.RecycleBitmap();
                                profile_image0.SetImageBitmap(bitmap);

                                try
                                {
                                    this.SetProfileImageToNavMenuHeader(this.Activity, bitmap);
                                }
                                catch { }

                                _profilepicbase64 = BitmapHelpers.BitmapToBase64(bitmap);
                                try
                                {
                                    objdb = new DBaseOperations();
                                    var lstu = objdb.selectTable();
                                    if (lstu != null && lstu.Count > default(int))
                                    {
                                        var uobj = lstu.FirstOrDefault();
                                        objdb.updateTable(new UserLoginInfo()
                                        {
                                            Id = uobj.Id, EmailId = uobj.EmailId, GoodName = uobj.GoodName, Password = uobj.Password, IsAdmin = uobj.IsAdmin, AuthToken = uobj.AuthToken, ProfilePicture = _profilepicbase64
                                        });
                                    }
                                }
                                catch { }
                            }
                        }
                    }
                }
                else
                {
                    if (requestCode == 102)
                    {
                        Intent mediaScanIntent = new Intent(Intent.ActionMediaScannerScanFile);
                        Uri    contentUri      = Uri.FromFile(_file);
                        mediaScanIntent.SetData(contentUri);
                        this.Activity.SendBroadcast(mediaScanIntent);
                        int height = profile_image0.Height;
                        int width  = Resources.DisplayMetrics.WidthPixels;
                        using (Android.Graphics.Bitmap bitmap = _file.Path.LoadAndResizeBitmap(width, height))
                        {
                            profile_image0.RecycleBitmap();
                            profile_image0.SetImageBitmap(bitmap);

                            try
                            {
                                this.SetProfileImageToNavMenuHeader(this.Activity, bitmap);
                            }
                            catch { }

                            _profilepicbase64 = BitmapHelpers.BitmapToBase64(bitmap);
                            try
                            {
                                objdb = new DBaseOperations();
                                var lstu = objdb.selectTable();
                                if (lstu != null && lstu.Count > default(int))
                                {
                                    var uobj = lstu.FirstOrDefault();
                                    objdb.updateTable(new UserLoginInfo()
                                    {
                                        Id = uobj.Id, EmailId = uobj.EmailId, GoodName = uobj.GoodName, Password = uobj.Password, IsAdmin = uobj.IsAdmin, AuthToken = uobj.AuthToken, ProfilePicture = _profilepicbase64
                                    });
                                }
                            }
                            catch { }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                this.Activity.RunOnUiThread(() =>
                {
                    Android.App.AlertDialog.Builder alertDiag = new Android.App.AlertDialog.Builder(this.Activity);
                    alertDiag.SetTitle(Resource.String.DialogHeaderError);
                    alertDiag.SetMessage(ex.Message);
                    alertDiag.SetIcon(Resource.Drawable.alert);
                    alertDiag.SetPositiveButton(Resource.String.DialogButtonOk, (senderAlert, args) =>
                    {
                    });
                    Dialog diag = alertDiag.Create();
                    diag.Show();
                    diag.SetCanceledOnTouchOutside(false);
                });
            }
        }
        protected override void OnCreate(Bundle bundle)
        {
            try
            {
                base.OnCreate(bundle);
                SetContentView(Resource.Layout.activity_maincontent);

                mToolbar      = FindViewById <SupportToolbar>(Resource.Id.m_toolbar);
                mDrawerLayout = FindViewById <DrawerLayout>(Resource.Id.m_drawer_layout);
                mLeftDrawer   = FindViewById <ListView>(Resource.Id.m_left_drawer);

                dashboardFragment       = new DashboardFragment();
                myFarmDashboardFragment = new MyFarmDashboardFragment();
                myProfileFragment       = new MyProfileFragment();
                addActivityFragment     = new AddActivityFragment();
                activityViewerFragment  = new ActivityViewerFragment();
                askAggieFragment        = new AskAggieFragment();
                settingsFragment        = new SettingsFragment();
                contactFragment         = new ContactFragment();
                chatbotFragment         = new ChatbotFragment();
                chatListManagerFragment = new ChatListManagerFragment();

                mStackFragments = new Stack <SupportFragment>();

                mLeftDrawer.Tag = 0;

                SetSupportActionBar(mToolbar);

                mLeftDataSet = new List <string>();
                mLeftDataSet.Add("My Dashboard");
                mLeftDataSet.Add("My Farm");
                mLeftDataSet.Add("My Profile");
                mLeftDataSet.Add("Add Activitiy");
                mLeftDataSet.Add("View Activities");
                /*mLeftDataSet.Add("Ask an Aggie");*/
                /*mLeftDataSet.Add("Settings");*/

                var objdbTemp = new DBaseOperations();
                var lstux     = objdbTemp.selectTable();
                if (lstux != null && lstux.Count > default(int))
                {
                    var uobj = lstux.FirstOrDefault();
                    if (uobj != null && uobj.IsAdmin > default(int))
                    {
                        mLeftDataSet.Add("Chat Management");
                    }
                    else
                    {
                        mLeftDataSet.Add("Ask an Aggie");
                    }
                }
                else
                {
                    mLeftDataSet.Add("Ask an Aggie");
                }

                mLeftDataSet.Add("Contact Us");
                mLeftAdapter           = new ArrayAdapter <string>(this, Android.Resource.Layout.SimpleListItem1, mLeftDataSet);
                mLeftDrawer.Adapter    = mLeftAdapter;
                mLeftDrawer.ItemClick += MenuListView_ItemClick;

                mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, Resource.String.openDrawer, Resource.String.closeDrawer);

                mDrawerLayout.SetDrawerListener(mDrawerToggle);
                SupportActionBar.SetHomeButtonEnabled(true);
                SupportActionBar.SetDisplayShowTitleEnabled(true);
                SupportActionBar.SetDisplayHomeAsUpEnabled(true);
                mDrawerToggle.SyncState();

                if (bundle != null)
                {
                    if (bundle.GetString("DrawerState") == "Opened")
                    {
                        SupportActionBar.SetTitle(Resource.String.openDrawer);
                    }
                    else
                    {
                        SupportActionBar.SetTitle(Resource.String.closeDrawer);
                    }
                }
                else
                {
                    SupportActionBar.SetTitle(Resource.String.closeDrawer);
                }

                try
                {
                    string mStringLoginInfo    = string.Empty;
                    string mStringSessionToken = string.Empty;
                    string mStringGoodName     = string.Empty;
                    circular_imageViewLogo = this.FindViewById <Refractored.Controls.CircleImageView>(Resource.Id.circular_imageViewLogo);
                    imageViewLogo          = this.FindViewById <ImageView>(Resource.Id.imageViewLogo);
                    textView = this.FindViewById <TextView>(Resource.Id.textView);
                    try
                    {
                        objdb = new DBaseOperations();
                        var lstu = objdb.selectTable();
                        if (lstu != null && lstu.Count > default(int))
                        {
                            var uobj = lstu.FirstOrDefault();
                            if (uobj.Password == " ")
                            {
                                throw new Exception("Please login again");
                            }
                            mStringLoginInfo    = uobj.EmailId;
                            mStringSessionToken = uobj.AuthToken;
                            mStringGoodName     = uobj.GoodName;
                            _profilepicbase64   = uobj.ProfilePicture;
                        }
                    }
                    catch { }

                    if (!string.IsNullOrEmpty(_profilepicbase64))
                    {
                        var btmpimg = BitmapHelpers.Base64ToBitmap(_profilepicbase64);
                        circular_imageViewLogo.Visibility = ViewStates.Visible;
                        imageViewLogo.Visibility          = ViewStates.Gone;
                        textView.Text = string.Format("Hello, {0}", mStringGoodName);
                        circular_imageViewLogo.RecycleBitmap();
                        circular_imageViewLogo.SetImageBitmap(btmpimg);
                    }
                    else
                    {
                        circular_imageViewLogo.Visibility = ViewStates.Gone;
                        imageViewLogo.Visibility          = ViewStates.Visible;
                        textView.Text = !string.IsNullOrEmpty(mStringGoodName) ? string.Format("Hello, {0}", mStringGoodName) : "";
                    }
                }
                catch { }

                IList <Android.Support.V4.App.Fragment> fragmentsarray = SupportFragmentManager.Fragments;
                if (fragmentsarray != null && fragmentsarray.Count > default(int))
                {
                    foreach (Android.Support.V4.App.Fragment fragment in fragmentsarray)
                    {
                        string tag = fragment.Tag;
                        Android.Support.V4.App.FragmentTransaction tx = SupportFragmentManager.BeginTransaction();
                        tx.Replace(Resource.Id.m_main, fragment, fragment.Tag);
                        tx.Commit();
                        break;
                    }
                }
                else
                {
                    Android.Support.V4.App.FragmentTransaction tx = SupportFragmentManager.BeginTransaction();
                    tx.Replace(Resource.Id.m_main, dashboardFragment, Constants.dashboard);
                    tx.Commit();
                }
            }
            catch (Exception ex)
            {
                this.RunOnUiThread(() =>
                {
                    Android.App.AlertDialog.Builder alertDiag = new Android.App.AlertDialog.Builder(this);
                    alertDiag.SetTitle(Resource.String.DialogHeaderError);
                    alertDiag.SetMessage(ex.Message);
                    alertDiag.SetIcon(Resource.Drawable.alert);
                    alertDiag.SetPositiveButton(Resource.String.DialogButtonOk, (senderAlert, args) =>
                    {
                        Intent intent = new Intent(this, typeof(MainActivity));
                        StartActivity(intent);
                        this.Finish();
                    });
                    Dialog diag = alertDiag.Create();
                    diag.Show();
                    diag.SetCanceledOnTouchOutside(false);
                });
            }
        }
        //protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
        public override void OnActivityResult(int requestCode, int resultCode, Intent data)
        {
            try
            {
                if (Build.VERSION.SdkInt >= Build.VERSION_CODES.M)
                {
                    if (Android.Support.V4.Content.ContextCompat.CheckSelfPermission(this.Activity, Manifest.Permission.Camera) != (int)Permission.Granted || Android.Support.V4.Content.ContextCompat.CheckSelfPermission(this.Activity, Manifest.Permission.WriteExternalStorage) != (int)Permission.Granted)
                    {
                        Android.Support.V4.App.ActivityCompat.RequestPermissions(this.Activity, new string[] { Manifest.Permission.Camera, Manifest.Permission.WriteExternalStorage, Manifest.Permission.ReadExternalStorage }, 54);

                        /*FragmentManager.FindFragmentById(Resource.Layout.fragment_content_addproduct).RequestPermissions(new string[]
                         * {
                         *      Manifest.Permission.Camera, Manifest.Permission.WriteExternalStorage,
                         *      Manifest.Permission.ReadExternalStorage
                         * }, 54);*/
                    }
                    else
                    {
                        if (requestCode == 102)
                        {
                            Intent mediaScanIntent = new Intent(Intent.ActionMediaScannerScanFile);
                            Uri    contentUri      = Uri.FromFile(_file);
                            mediaScanIntent.SetData(contentUri);
                            this.Activity.SendBroadcast(mediaScanIntent);
                            int height = profile_image.Height;
                            int width  = Resources.DisplayMetrics.WidthPixels;
                            //int width = profile_image.Width;
                            using (Android.Graphics.Bitmap bitmap = _file.Path.LoadAndResizeBitmap(width, height))
                            {
                                profile_image.RecycleBitmap();
                                profile_image.SetImageBitmap(bitmap);

                                _profilepicbase64 = BitmapHelpers.BitmapToBase64(bitmap);
                            }
                        }
                    }
                }
                else
                {
                    //if (requestCode == 102 && resultCode == (int)Result.Ok)
                    if (requestCode == 102)
                    {
                        Intent mediaScanIntent = new Intent(Intent.ActionMediaScannerScanFile);
                        Uri    contentUri      = Uri.FromFile(_file);
                        mediaScanIntent.SetData(contentUri);
                        this.Activity.SendBroadcast(mediaScanIntent);
                        int height = profile_image.Height;
                        int width  = Resources.DisplayMetrics.WidthPixels;
                        //int width = profile_image.Width;
                        using (Android.Graphics.Bitmap bitmap = _file.Path.LoadAndResizeBitmap(width, height))
                        {
                            profile_image.RecycleBitmap();
                            profile_image.SetImageBitmap(bitmap);

                            _profilepicbase64 = BitmapHelpers.BitmapToBase64(bitmap);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                this.Activity.RunOnUiThread(() =>
                {
                    Android.App.AlertDialog.Builder alertDiag = new Android.App.AlertDialog.Builder(this.Activity);
                    alertDiag.SetTitle(Resource.String.DialogHeaderError);
                    alertDiag.SetMessage(ex.Message);
                    alertDiag.SetIcon(Resource.Drawable.alert);
                    alertDiag.SetPositiveButton(Resource.String.DialogButtonOk, (senderAlert, args) =>
                    {
                    });
                    Dialog diag = alertDiag.Create();
                    diag.Show();
                    diag.SetCanceledOnTouchOutside(false);
                });
            }
        }