Ejemplo n.º 1
0
        private void BtnViewProfile_Click(object sender, EventArgs e)
        {
            var    profile = new ProfileFragment();
            Bundle b       = new Bundle();
            long   UserId  = Convert.ToInt64(GlobalClass.UserID);

            b.PutLong("UserId", UserId);
            profile.Arguments = (b);
            Android.Support.V4.App.FragmentManager eventFragmentManager = Activity.SupportFragmentManager;
            eventFragmentManager.BeginTransaction().Replace(Resource.Id.content_frame, profile, "profile").AddToBackStack("profile").Commit();
        }
Ejemplo n.º 2
0
        private void Profile_pic_Click(object sender, System.EventArgs e)
        {
            var profile = new ProfileFragment();

            Android.Support.V4.App.Fragment containerFragment = SupportFragmentManager.FindFragmentById(Resource.Id.content_frame);

            if (containerFragment.Class.Name.Equals(profile.Class.Name) && SearchUserId == 0)
            {
                drawerLayout.CloseDrawers();
                return;
            }
            Bundle b      = new Bundle();
            long   UserId = Convert.ToInt64(GlobalClass.UserID);

            b.PutLong("UserId", UserId);
            profile.Arguments = (b);
            Android.Support.V4.App.FragmentManager eventFragmentManager = SupportFragmentManager;
            eventFragmentManager.BeginTransaction().Replace(Resource.Id.content_frame, profile, "profile").AddToBackStack("profile").Commit();
            drawerLayout.CloseDrawers();
        }
Ejemplo n.º 3
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            try
            {
                SetContentView(Resource.Layout.Main);
                Toolbar  toolbar       = (Toolbar)FindViewById(Resource.Id.toolbar);
                TextView toolbar_title = (TextView)FindViewById(Resource.Id.toolbar_title);
                SetSupportActionBar(toolbar);
                this.Title = "";

                SupportActionBar.SetHomeAsUpIndicator(Resource.Drawable.ic_menu_white_24dp);
                SupportActionBar.SetDisplayHomeAsUpEnabled(true);
                SupportActionBar.SetHomeButtonEnabled(true);

                if (Build.VERSION.SdkInt >= Android.OS.BuildVersionCodes.Lollipop)
                {
                    Window.AddFlags(WindowManagerFlags.DrawsSystemBarBackgrounds);
                    Window.SetStatusBarColor(new Android.Graphics.Color(Android.Support.V4.Content.ContextCompat.GetColor(this, Resource.Color.primaryDark)));
                }

                From               = Intent.GetStringExtra("FromEvent");
                EventIdRequest     = Intent.GetLongExtra("EventRequest", 0);
                SearchUserId       = Intent.GetLongExtra("FromPeople", 0);
                FriendNotification = Intent.GetStringExtra("FriendNotification");
                FromESF            = Intent.GetStringExtra("FromESF");
                toNotification     = Intent.GetStringExtra("ToNotification");

                btnEditProfile     = (Button)FindViewById(Resource.Id.btnEditProfile);
                drawerLayout       = (DrawerLayout)FindViewById(Resource.Id.drawer_layout);
                navigationView     = (NavigationView)FindViewById(Resource.Id.navigation_view);
                listDrawerMenu     = (ListView)FindViewById(Resource.Id.listDrawerMenu);
                profile_pic        = (ImageView)FindViewById(Resource.Id.profile_pic);
                tvUsername         = (TextView)FindViewById(Resource.Id.tvUsername);
                profile_pic.Click += Profile_pic_Click;

                var    prefs         = Application.Context.GetSharedPreferences("WeClip", FileCreationMode.Private);
                string strUserName   = prefs.GetString("UserName", "");
                string strProfilePic = prefs.GetString("ProfilePic", "");
                tvUsername.Text = strUserName;

                if (string.IsNullOrEmpty(strProfilePic))
                {
                    profile_pic.SetImageResource(Resource.Drawable.contact_withoutphoto);
                }
                else
                {
                    Picasso.With(this).Load(strProfilePic)
                    .Transform(new CircleTransformation()).Resize(240, 240)
                    .CenterInside().Into(profile_pic);
                }

                List <DrawerItemModel> listDrawersItems = new List <DrawerItemModel>();
                listDrawersItems.Add(new DrawerItemModel("Home"));
                listDrawersItems.Add(new DrawerItemModel("Invite friends"));
                listDrawersItems.Add(new DrawerItemModel("Settings"));
                listDrawersItems.Add(new DrawerItemModel("Help"));
                //   listDrawersItems.Add(new DrawerItemModel("Change password"));
                listDrawersItems.Add(new DrawerItemModel("Logout"));
                listDrawerMenu.Adapter    = new DrawerItemAdapter(this, listDrawersItems);
                listDrawerMenu.ItemClick += ListDrawerMenu_ItemClick;
                btnEditProfile.Click     += BtnEditProfile_Click;

                if (EventIdRequest != 0)
                {
                    var eventRequest = new EventRequestFragment();
                    MainActivity.myBundle.PutLong("EventID", EventIdRequest);
                    Android.Support.V4.App.FragmentManager eventFragmentManager = SupportFragmentManager;
                    eventFragmentManager.BeginTransaction().Replace(Resource.Id.content_frame, eventRequest).Commit();
                }
                else if (!string.IsNullOrEmpty(FriendNotification))
                {
                    var notification = new NotificationFragment();
                    Android.Support.V4.App.FragmentManager eventFragmentManager = SupportFragmentManager;
                    eventFragmentManager.BeginTransaction().Replace(Resource.Id.content_frame, notification).Commit();
                }

                else if (!string.IsNullOrEmpty(toNotification))
                {
                    try
                    {
                        var notification = new NotificationFragment();
                        Android.Support.V4.App.FragmentManager eventFragmentManager = SupportFragmentManager;
                        eventFragmentManager.BeginTransaction().Replace(Resource.Id.content_frame, notification).Commit();
                    }
                    catch (System.Exception ex)
                    {
                        throw;
                    }
                }

                else if (!string.IsNullOrEmpty(FromESF))
                {
                    var homeFragment = new EventFragment();
                    Android.Support.V4.App.FragmentManager eventFragmentManager = SupportFragmentManager;
                    eventFragmentManager.BeginTransaction().Replace(Resource.Id.content_frame, homeFragment).Commit();
                }

                else if (SearchUserId != 0)
                {
                    var    profile = new ProfileFragment();
                    Bundle b       = new Bundle();
                    long   UserId  = SearchUserId;
                    b.PutLong("UserId", UserId);
                    profile.Arguments = (b);
                    Android.Support.V4.App.FragmentManager eventFragmentManager = SupportFragmentManager;
                    eventFragmentManager.BeginTransaction().Replace(Resource.Id.content_frame, profile).Commit();
                }
                else if (string.IsNullOrEmpty(From))
                {
                    var homeFragment = new HomeFragment();
                    Android.Support.V4.App.FragmentManager eventFragmentManager = SupportFragmentManager;
                    eventFragmentManager.BeginTransaction().Replace(Resource.Id.content_frame, homeFragment, "home").Commit();
                }
                else
                {
                    var homeFragment = new EventFragment();
                    Android.Support.V4.App.FragmentManager eventFragmentManager = SupportFragmentManager;
                    eventFragmentManager.BeginTransaction().Replace(Resource.Id.content_frame, homeFragment, "event").AddToBackStack("event").Commit();
                }
            }
            catch (Java.Lang.Exception ex)
            {
                new CrashReportAsync("MainActivity", "OnCreates", ex.Message + ex.StackTrace + ex.Cause + ex.InnerException).Execute();
            }
        }