private void AddAttachment() { if (ViewModel.CurrentMovieReview != null && ViewModel.CurrentMovieReview.Attachment != null) { var bitmapSource = BitmapFactory.DecodeByteArray(ViewModel.CurrentMovieReview.Attachment, 0, ViewModel.CurrentMovieReview.Attachment.Length); attachmentImageView.Visibility = ViewStates.Visible; attachmentImageView.SetImageBitmap(bitmapSource); } }
public void Bind(Message message) { try { messageText.Text = message.message; timeText.Text = message.createdAt.ToString("dd MMM hh:mm tt"); nameText.Text = message.sender.GoodName; if (!string.IsNullOrEmpty(message.sender.ProfilePicture)) { profileImage.SetImageBitmap(BitmapHelpers.Base64ToBitmap(message.sender.ProfilePicture)); } else { profileImage.SetBackgroundResource(Resource.Drawable.chatbot); } } catch { } }
public void OnBitmapLoaded(Bitmap p0, Picasso.LoadedFrom p1) { _profileImage.SetImageBitmap(p0); }
protected override void OnActivityResult(int requestCode, Result resultCode, Intent data) { base.OnActivityResult(requestCode, resultCode, data); if (requestCode == 105 || requestCode == 203) { pref = GetSharedPreferences("login", FileCreationMode.Private); edit = pref.Edit(); username = pref.GetString("username", String.Empty); profilepath = pref.GetString("profilePath", String.Empty); userid = pref.GetInt("userid", 0); if (username.Length > 0) { // mymenuitem.SetTitle("Logout"); txtdisplay.Text = username; try { var imageBitmap = GetImageBitmapFromUrl(profilepath); profileimage.SetImageBitmap(imageBitmap); } catch (Exception e) { } } //if (mymenuitem.ItemId == Resource.Id.nav_login) //{ // if (Log) // { // Log = false; // mymenuitem.SetIcon(Resource.Drawable.menu_log); // mymenuitem.SetTitle("Logout"); // // var intent3 = new Intent(this, typeof(LoginActivity_STPortal)); // // StartActivityForResult(intent3, 105); // } // else // { // Android.App.AlertDialog.Builder alert = new Android.App.AlertDialog.Builder(this); // alert.SetTitle("Logout"); // alert.SetMessage("Do you want to logoff ?"); // alert.SetPositiveButton(("Yes"), (sender, args) => // { // mymenuitem.SetIcon(Resource.Drawable.menu_log); // mymenuitem.SetTitle("Login"); // edit.Clear(); // edit.Apply(); // username = ""; // profilepath = ""; // Toast.MakeText(this, "You have successfully logged off", ToastLength.Long).Show(); // var log_out = new Intent(this, typeof(MainActivity)); // StartActivityForResult(log_out, 110); // }); // alert.SetNegativeButton(("No"), (sender, args) => // { // }); // Dialog dialog = alert.Create(); // dialog.Show(); // } //} } }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.activity_main); OneSignal.Current.StartInit("aaf605c7-a2fc-401e-b9db-ea54f324f69c").EndInit(); pref = GetSharedPreferences("login", FileCreationMode.Private); edit = pref.Edit(); username = pref.GetString("username", String.Empty); profilepath = pref.GetString("profilePath", String.Empty); userid = pref.GetInt("userid", 0); StrictMode.VmPolicy.Builder builder = new StrictMode.VmPolicy.Builder(); StrictMode.SetVmPolicy(builder.Build()); StrictMode.ThreadPolicy.Builder builder1 = new StrictMode.ThreadPolicy.Builder().PermitAll(); StrictMode.SetThreadPolicy(builder1.Build()); Android.Support.V7.Widget.Toolbar toolbar = FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar); // toolbar.SetNavigationIcon(Resource.Drawable.login_image); // SupportActionBar.SetDisplayHomeAsUpEnabled(true); //// SetSupportActionBar(toolbar); //// toolbar.SetNavigationIcon((Resource.Drawable.notification_icon_background)); if (toolbar != null) { //toolbar.SetNavigationIcon((Resource.Drawable.home1)); SetSupportActionBar(toolbar); //SupportActionBar.SetDisplayHomeAsUpEnabled(true); //SupportActionBar.SetHomeButtonEnabled(true); } //if (SetSupportActionBar(toolbar) != null) //{ // SetSupportActionBar(toolbar).SetDisplayShowHomeEnabled(true); // SetSupportActionBar(toolbar)SsetDisplayHomeAsUpEnabled(true); //} // FloatingActionButton fab = FindViewById<FloatingActionButton>(Resource.Id.fab); // fab.Click += FabOnClick; DrawerLayout drawer = FindViewById <DrawerLayout>(Resource.Id.drawer_layout); ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar, Resource.String.navigation_drawer_open, Resource.String.navigation_drawer_close); drawer.AddDrawerListener(toggle); toggle.SyncState(); NavigationView navigationView = FindViewById <NavigationView>(Resource.Id.nav_view); LayoutInflater mInflater = (LayoutInflater)GetSystemService(Context.LayoutInflaterService); View header = navigationView.GetHeaderView(0); txtdisplay = header.FindViewById <TextView>(Resource.Id.usernametext); profileimage = header.FindViewById <Refractored.Controls.CircleImageView>(Resource.Id.profile); if (username.Length > 0) { txtdisplay.Text = username; var imageBitmap = GetImageBitmapFromUrl(profilepath); profileimage.SetImageBitmap(imageBitmap); } toggle.SyncState(); navigationView.SetNavigationItemSelectedListener(this); var bottomBar = FindViewById <BottomNavigationView>(Resource.Id.bottom_navigation); RemoveShiftMode(bottomBar); SupportFragmentManager.BeginTransaction() .Replace(Resource.Id.content_frame, new Home(), "Home") .Commit(); bottomBar.NavigationItemSelected += (s, a) => { LoadFragment(a.Item.ItemId); }; }
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); }); } }