Exemplo n.º 1
0
        public bool OnNavigationItemSelected(IMenuItem item)
        {
            int id = item.ItemId;



            Android.Support.V4.App.Fragment fragment1 = null;

            if (id == Resource.Id.nav_home)
            {
                fragment1 = new Home();
                SupportFragmentManager.BeginTransaction()
                .Replace(Resource.Id.content_frame, fragment1)
                .Commit();


                DrawerLayout drawer = FindViewById <DrawerLayout>(Resource.Id.drawer_layout);
                drawer.CloseDrawer(GravityCompat.Start);
            }


            else if (id == Resource.Id.nav_shop)
            {
                var uri    = Android.Net.Uri.Parse("https://myshop.mahendras.org");
                var intent = new Intent(Intent.ActionView, uri);
                StartActivity(intent);
                // fragment1 = new MyShop();
                // SupportFragmentManager.BeginTransaction()
                //.Replace(Resource.Id.content_frame, fragment1)
                //.Commit();


                DrawerLayout drawer = FindViewById <DrawerLayout>(Resource.Id.drawer_layout);
                drawer.CloseDrawer(GravityCompat.Start);
            }

            else if (id == Resource.Id.nav_portal)
            {
                ISharedPreferences       pref;
                ISharedPreferencesEditor edit;
                pref = GetSharedPreferences("login", FileCreationMode.Private);
                edit = pref.Edit();
                string username = pref.GetString("username", String.Empty);
                if (username.Length > 0)
                {
                    var taskIntentActivity2 = new Intent(this, typeof(MainActivity1));
                    StartActivityForResult(taskIntentActivity2, 102);
                }
                else
                {
                    Toast.MakeText(this, "Please Login First", ToastLength.Short).Show();
                }



                //  fragment1 = new ST_Portal_Fragment();
            }
            else if (id == Resource.Id.nav_about)
            {
                fragment1 = new AboutUsFragment();
                SupportFragmentManager.BeginTransaction()
                .Replace(Resource.Id.content_frame, fragment1)
                .Commit();


                DrawerLayout drawer = FindViewById <DrawerLayout>(Resource.Id.drawer_layout);
                drawer.CloseDrawer(GravityCompat.Start);
            }
            //else if (id == Resource.Id.nav_branches)
            //{
            //    fragment1 = new BranchFragment();
            //}
            else if (id == Resource.Id.nav_contact)
            {
                fragment1 = new ContactUsFragment();
                SupportFragmentManager.BeginTransaction()
                .Replace(Resource.Id.content_frame, fragment1)
                .Commit();


                DrawerLayout drawer = FindViewById <DrawerLayout>(Resource.Id.drawer_layout);
                drawer.CloseDrawer(GravityCompat.Start);
            }

            //else if (id == Resource.Id.nav_setting)
            //{
            //    fragment1 = new NoticeBoardFinal();
            //}
            else if (id == Resource.Id.nav_rate)
            {
                var uri    = Android.Net.Uri.Parse("https://play.google.com/store/apps/details?id=com.makemedroid.keye5bb63c9");
                var intent = new Intent(Intent.ActionView, uri);
                StartActivity(intent);
                // fragment1 = new RateAppFragment();
                // SupportFragmentManager.BeginTransaction()
                //.Replace(Resource.Id.content_frame, fragment1)
                //.Commit();


                DrawerLayout drawer = FindViewById <DrawerLayout>(Resource.Id.drawer_layout);
                drawer.CloseDrawer(GravityCompat.Start);
            }
            else if (id == Resource.Id.nav_share)
            {
                fragment1 = new ShareFragment();
                SupportFragmentManager.BeginTransaction()
                .Replace(Resource.Id.content_frame, fragment1)
                .Commit();


                DrawerLayout drawer = FindViewById <DrawerLayout>(Resource.Id.drawer_layout);
                drawer.CloseDrawer(GravityCompat.Start);
            }
            //else if (id == Resource.Id.nav_invite)
            //{
            //    fragment1 = new InviteFragment();
            //    SupportFragmentManager.BeginTransaction()
            //   .Replace(Resource.Id.content_frame, fragment1)
            //   .Commit();


            //    DrawerLayout drawer = FindViewById<DrawerLayout>(Resource.Id.drawer_layout);
            //    drawer.CloseDrawer(GravityCompat.Start);
            //}
            else if (id == Resource.Id.nav_like)
            {
                fragment1 = new LikeFragment();
                SupportFragmentManager.BeginTransaction()
                .Replace(Resource.Id.content_frame, fragment1)
                .Commit();


                DrawerLayout drawer = FindViewById <DrawerLayout>(Resource.Id.drawer_layout);
                drawer.CloseDrawer(GravityCompat.Start);
            }



            else if (id == Resource.Id.nav_privacy)
            {
                fragment1 = new PrivacyFragment();

                SupportFragmentManager.BeginTransaction()
                .Replace(Resource.Id.content_frame, fragment1)
                .Commit();


                DrawerLayout drawer = FindViewById <DrawerLayout>(Resource.Id.drawer_layout);
                drawer.CloseDrawer(GravityCompat.Start);
            }

            else if (id == Resource.Id.nav_login)
            {
                // var intent3 = new Intent(this, typeof(LoginActivity_STPortal));
                // StartActivityForResult(intent3, 105);



                if (item.ItemId == Resource.Id.nav_login)
                {
                    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)
                    {
                        Log = false;
                        item.SetIcon(Resource.Drawable.menu_log);


                        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) =>
                        {
                            item.SetIcon(Resource.Drawable.menu_log);


                            edit.Clear();
                            edit.Apply();
                            username    = "";
                            profilepath = "";

                            Toast.MakeText(this, "You have successfully logged off", ToastLength.Long).Show();
                            Finish();
                            var log_out = new Intent(this, typeof(MainActivity));
                            StartActivityForResult(log_out, 110);
                        });

                        alert.SetNegativeButton(("No"), (sender, args) =>
                        {
                        });

                        Dialog dialog = alert.Create();
                        dialog.Show();
                    }
                }
            }



            return(true);
        }
Exemplo n.º 2
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.layoutAccount);

            var font = Typeface.CreateFromAsset(Assets, "Estedad.ttf");

            accountbtngift        = FindViewById <Button>(Resource.Id.accountbtngift);
            accountbtngift.Click += delegate {
                StartActivity(typeof(CustomActivity.Suprised_Activity));
            };
            accountbtnEventDay        = FindViewById <Button>(Resource.Id.accountbtnEventDay);
            accountbtnEventDay.Click += delegate {
                StartActivity(typeof(CustomActivity.EventDay_Activity));
            };

            Accountbtnenterevent = FindViewById <Button>(Resource.Id.Accountbtnenterevent);



            Accountbtnenterevent.Typeface = font;
            Accountbtnenterevent.Click   += delegate { StartActivity(typeof(EnterEvent)); };
            Accounttxtviewgroup           = FindViewById <TextView>(Resource.Id.Accounttxtviewgroup);
            Accounttxtviewgroup.Typeface  = font;
            Accountimgbtnlogo             = FindViewById <ImageButton>(Resource.Id.Accountimgbtnlogo);
            Accountimgbtnlogo.Click      += delegate { StartActivity(typeof(MainActivity)); };

            Accountbtnfilter          = FindViewById <Button>(Resource.Id.Accountbtnfilter);
            Accountbtnfilter.Typeface = font;
            Accountbtnfilter.Click   += delegate {
                Controller.Fragment.FilterMain fdlg = new Controller.Fragment.FilterMain(this);
                fdlg.Show(this.FragmentManager, "ebrahimfragmentfliterMainToFilterMain");
            };
            Accountbtnsearch          = FindViewById <Button>(Resource.Id.Accountbtnsearch);
            Accountbtnsearch.Typeface = font;


            Accountbtndelete            = FindViewById <Button>(Resource.Id.Accountbtndelete);
            Accountbtndelete.Click     += delegate { Accountedtxtsearch.Text = string.Empty; };
            Accountbtndelete.Typeface   = font;
            Accountedtxtsearch          = FindViewById <EditText>(Resource.Id.Accountedtxtsearch);
            Accountedtxtsearch.Typeface = font;

            Accountedtxtsearch.TextChanged += Accountedtxtsearch_TextChanged;


            AccountButtonEventMe          = FindViewById <Button>(Resource.Id.AccountButtonEventMe);
            AccountButtonEventMe.Typeface = font;
            AccountButtonEventMe.Click   += delegate {
                //رویدادهای من
                StartActivity(typeof(MyEventActivity.MyeventActivity));
            };
            FindViewById <ImageView>(Resource.Id.accountimgviewEventMe).Click += delegate {
                //رویداد های من
                StartActivity(typeof(MyEventActivity.MyeventActivity));
            };
            AccountButtonMark = FindViewById <Button>(Resource.Id.AccountButtonMark);
            ImageView im = FindViewById <ImageView>(Resource.Id.AccountImageviewMark);

            im.Click += delegate {
                //رویدادهای نشان شده
                Intent oi = new Intent(this, typeof(CustomActivity.MarkedEvent_Activity));

                StartActivity(oi);
            };
            AccountButtonMark.Click += delegate {
                Intent oi = new Intent(this, typeof(CustomActivity.MarkedEvent_Activity));

                StartActivity(oi);
            };
            AccountButtonMark.Typeface = font;

            accountbtnhesabmali          = FindViewById <Button>(Resource.Id.accountbtnhesabmali);
            accountbtnhesabmali.Typeface = font;
            accountbtnhesabmali.Click   += delegate {
                // حساب مالی
                Intent oi = new Intent(this, typeof(CustomActivity.Payed_Activity));
                StartActivity(oi);
            };
            ImageView hmali = FindViewById <ImageView>(Resource.Id.AccountImageviewMali);

            hmali.Click += delegate {
                // حساب مالی
                Intent oi = new Intent(this, typeof(CustomActivity.Payed_Activity));
                StartActivity(oi);
            };

            AccountButtonRule          = FindViewById <Button>(Resource.Id.AccountButtonRule);
            AccountButtonRule.Typeface = font;
            AccountButtonRule.Click   += delegate {
                Controller.Fragment.RuleFragment fdlg = new Controller.Fragment.RuleFragment(this);
                fdlg.Show(this.FragmentManager, "ebrahimfragmentrulefragment");
            };
            AccountImageviewRule        = FindViewById <ImageView>(Resource.Id.AccountImageviewRule);
            AccountImageviewRule.Click += delegate {
                Controller.Fragment.RuleFragment fdlg = new Controller.Fragment.RuleFragment(this);
                fdlg.Show(this.FragmentManager, "ebrahimfragmentrulefragment");
            };



            AccountbuttonAboutUs = FindViewById <Button>(Resource.Id.AccountbuttonAboutUs);

            AccountbuttonAboutUs.Typeface = font;
            AccountbuttonAboutUs.Click   += delegate {
                //درباره ما

                AboutUsFragment fdlg = new AboutUsFragment(this);
                fdlg.Show(this.FragmentManager, "ebrahimfragmentAccountShow");
            };

            ImageView Accountimageviewaboutus = FindViewById <ImageView>(Resource.Id.Accountimageviewaboutus);

            Accountimageviewaboutus.Click += delegate {
                //درباره ما

                AboutUsFragment fdlg = new AboutUsFragment(this);
                fdlg.Show(this.FragmentManager, "ebrahimfragmentAccountShow");
            };

            AccountbuttonContactMe          = FindViewById <Button>(Resource.Id.AccountbuttonContactMe);
            AccountbuttonContactMe.Typeface = font;
            AccountbuttonContactMe.Click   += delegate {
                //تماس با ایونتو
                TellEventoFragment fdlg = new TellEventoFragment(this);
                fdlg.Show(this.FragmentManager, "ebrahimTellEventoMananger");
            };
            ImageView AccountimageviewContactMe = FindViewById <ImageView>(Resource.Id.AccountimageviewContactMe);

            AccountimageviewContactMe.Click += delegate
            {
                //تماس با ایونتو
                TellEventoFragment fdlg = new TellEventoFragment(this);
                fdlg.Show(this.FragmentManager, "ebrahimTellEventoMananger");
            };
            accountbtncontact          = FindViewById <Button>(Resource.Id.accountbtncontact);
            accountbtncontact.Typeface = font;
            accountbtncontact.Click   += delegate { };

            accountbtngift              = FindViewById <Button>(Resource.Id.accountbtngift);
            accountbtngift.Typeface     = font;
            accountbtnEventDay          = FindViewById <Button>(Resource.Id.accountbtnEventDay);
            accountbtnEventDay.Typeface = font;
            accountbtngrouping          = FindViewById <Button>(Resource.Id.accountbtngrouping);
            accountbtngrouping.Typeface = font;
            accountbtngrouping.Click   += delegate { StartActivity(typeof(Grouping)); };
        }