Exemple #1
0
        protected async override void OnCreate(Bundle bundle)
        {
            TabLayoutResource = Resource.Layout.Tabbar;
            ToolbarResource   = Resource.Layout.Toolbar;

            base.OnCreate(bundle);

#if !XTC
            //2 InitializeHockeyApp();
#endif
            drawerLayout = FindViewById <DrawerLayout>(Resource.Id.drawer_layout);

            //Set hamburger items menu
            SupportActionBar.SetHomeAsUpIndicator(Resource.Drawable.ic_menu);

            //setup navigation view

            /*3 navigationView = FindViewById<NavigationView>(Resource.Id.nav_view);
             *
             * //handle navigation
             * navigationView.NavigationItemSelected += (sender, e) =>
             * {
             *  e.MenuItem.SetChecked(true);
             *
             *  ListItemClicked(e.MenuItem.ItemId);
             *
             *
             *  SupportActionBar.Title = e.MenuItem.ItemId == Resource.Id.menu_profile
             *      ? Settings.Current.UserFirstName
             *      : e.MenuItem.TitleFormatted.ToString();
             *
             *  SupportActionBar.Title = e.MenuItem.TitleFormatted.ToString();
             *
             *  drawerLayout.CloseDrawers();
             * };
             */

            if (Intent.GetBooleanExtra("tracking", false))
            {
                ListItemClicked(Resource.Id.menu_current_trip);
                SupportActionBar.Title = "Current Trip";
                return;
            }

            global::Xamarin.Forms.Forms.Init(this, bundle);

            Plugin.CurrentActivity.CrossCurrentActivity.Current.Init(this, bundle);

            SetContentView(LayoutResource);

            await MyDriving.Services.OBDDataProcessor.GetProcessor().Initialize(ViewModel.ViewModelBase.StoreManager);

            //await MyDriving.Services.OBDDataProcessor.GetProcessor().Initialize();

            Android.Support.V4.App.Fragment fragment = null;
            fragment = FragmentCurrentTrip.NewInstance();


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


            //if first time you will want to go ahead and click first item.

            /*4
             * if (bundle == null)
             * {
             *  ListItemClicked(Resource.Id.menu_current_trip);
             *  SupportActionBar.Title = "Current Trip";
             * }*/
        }
Exemple #2
0
        public async Task UpdaterAsync(CancellationToken ct)
        {
            _Loading_Fragment = new Loading_Fragment();
            _Step3_Fragment   = new Step3_Fragment();



            ISharedPreferences prefs = PreferenceManager.GetDefaultSharedPreferences(this);
            var api_key = prefs.GetString("api_key", null);

            var trans = SupportFragmentManager.BeginTransaction();

            trans.Add(Resource.Id.Step3_Frame, _Step3_Fragment, "Fragment");
            trans.Add(Resource.Id.Step3_Frame, _Loading_Fragment, "Fragment");
            trans.Hide(_Step3_Fragment);
            trans.Show(_Loading_Fragment);
            trans.Commit();

            DigitalOceanClient client = new DigitalOceanClient(api_key);
            var keys = await client.Keys.GetAll();

            trans = SupportFragmentManager.BeginTransaction();
            trans.Hide(_Loading_Fragment);
            trans.Show(_Step3_Fragment);
            trans.Commit();

            List <sshkey> sshkeys = new List <sshkey>();

            RadioGroup lls = FindViewById <RadioGroup>(Resource.Id.sshkeygroup);

            for (int i = 0; i < keys.Count; i++)
            {
                CheckBox cb = new CheckBox(this);
                cb.Text = keys[i].Name;
                cb.Id   = View.GenerateViewId();
                sshkey x = new sshkey();
                x.Id      = keys[i].Id;
                x.Name    = keys[i].Name;
                x.radioid = cb.Id;
                sshkeys.Add(x);
                cb.Click += delegate(object sender, EventArgs e) { CheckBoxOnClick(cb, sshkeys); };
                lls.AddView(cb);
            }

            createdrop.Backups           = false;
            createdrop.Ipv6              = false;
            createdrop.Monitoring        = false;
            createdrop.PrivateNetworking = false;

            CheckBox bcb   = FindViewById <CheckBox>(Resource.Id.checkBoxbackup);
            CheckBox ipbcb = FindViewById <CheckBox>(Resource.Id.checkBoxipv6net);
            CheckBox moncb = FindViewById <CheckBox>(Resource.Id.checkBoxmonitor);
            CheckBox pvcb  = FindViewById <CheckBox>(Resource.Id.checkBoxprivnet);



            bcb.CheckedChange += (o, e) =>
            {
                if (FindViewById <CheckBox>(Resource.Id.checkBoxbackup).Checked)
                {
                    createdrop.Backups = true;
                }
                else
                {
                    createdrop.Backups = false;
                }
            };

            ipbcb.CheckedChange += (o, e) =>
            {
                if (FindViewById <CheckBox>(Resource.Id.checkBoxipv6net).Checked)
                {
                    createdrop.Ipv6 = true;
                }
                else
                {
                    createdrop.Ipv6 = false;
                }
            };

            moncb.CheckedChange += (o, e) =>
            {
                if (FindViewById <CheckBox>(Resource.Id.checkBoxmonitor).Checked)
                {
                    createdrop.Monitoring = true;
                }
                else
                {
                    createdrop.Monitoring = false;
                }
            };

            pvcb.CheckedChange += (o, e) =>
            {
                if (FindViewById <CheckBox>(Resource.Id.checkBoxprivnet).Checked)
                {
                    createdrop.PrivateNetworking = true;
                }
                else
                {
                    createdrop.PrivateNetworking = false;
                }
            };

            Button next = FindViewById <Button>(Resource.Id.NextS3);
            Button back = FindViewById <Button>(Resource.Id.BackS3);

            EditText tagsedit = FindViewById <EditText>(Resource.Id.Tags);


            back.Click += (o, e) =>
            {
                var intent = new Intent(this, typeof(Step2Activity));
                intent.PutExtra("DropletName", createdrop.Name);
                intent.PutExtra("DropletDistro", Intent.Extras.GetString("DropletDistro"));
                StartActivity(intent);
            };

            next.Click += async(o, e) =>
            {
                for (int i = 0; i < sshkeys.Count; i++)
                {
                    if (sshkeys[i].selected)
                    {
                        createdrop.SshIdsOrFingerprints.Add(sshkeys[i].Id);
                    }
                }
                createdrop.UserData = null;
                string[] tags = tagsedit.Text.Split(",");
                if (tags.Length > 0)
                {
                    for (int i = 0; i < tags.Length; i++)
                    {
                        if (tags[i] != "" && tags[i] != null)
                        {
                            createdrop.Tags.Add(tags[i]);
                        }
                    }
                }

                trans = SupportFragmentManager.BeginTransaction();
                trans.Show(_Loading_Fragment);
                trans.Hide(_Step3_Fragment);
                trans.Commit();

                var creationAction = await client.Droplets.Create(createdrop);

                trans = SupportFragmentManager.BeginTransaction();
                trans.Hide(_Loading_Fragment);
                trans.Show(_Step3_Fragment);
                trans.Commit();

                var intent = new Intent(this, typeof(MainActivity));
                StartActivity(intent);
            };
        }
        public bool OnNavigationItemSelected(IMenuItem item)
        {
            Bundle bundle = new Bundle();

            //todo replace to user id
            bundle.PutInt("UserID", 2);

            int id = item.ItemId;

            if (id == Resource.Id.nav_dean_students)
            {
                Intent intent = new Intent(this, typeof(DeanViewStudent));
                StartActivity(intent);
            }
            else if (id == Resource.Id.nav_dean_journal)
            {
                Intent intent = new Intent(this, typeof(DeanViewJournal));
                StartActivity(intent);
            }
            else if (id == Resource.Id.nav_dean_subjects)
            {
                Intent intent = new Intent(this, typeof(DeanViewSubject));
                StartActivity(intent);
            }
            else if (id == Resource.Id.nav_dean_professors)
            {
                Intent intent = new Intent(this, typeof(DeanViewProfessor));
                StartActivity(intent);
            }
            else if (id == Resource.Id.nav_gLeader_students)
            {
                Android.Support.V4.App.Fragment fragment = new LeaderStudentsFragment();
                fragment.Arguments = bundle;
                SupportFragmentManager.BeginTransaction()
                .Replace(Resource.Id.content_frame, fragment)
                .Commit();
            }
            else if (id == Resource.Id.nav_gLeader_subjects)
            {
                Android.Support.V4.App.Fragment fragment = new LeaderSubjectsFragment();
                fragment.Arguments = bundle;
                SupportFragmentManager.BeginTransaction()
                .Replace(Resource.Id.content_frame, fragment)
                .Commit();
            }
            else if (id == Resource.Id.nav_gLeader_professors)
            {
                Android.Support.V4.App.Fragment fragment = new LeaderProfessorsFragment();
                fragment.Arguments = bundle;
                SupportFragmentManager.BeginTransaction()
                .Replace(Resource.Id.content_frame, fragment)
                .Commit();
            }
            else if (id == Resource.Id.nav_gLeader_day)
            {
                Android.Support.V4.App.Fragment fragment = new LeaderDayFragment();
                fragment.Arguments = bundle;
                SupportFragmentManager.BeginTransaction()
                .Replace(Resource.Id.content_frame, fragment)
                .Commit();
            }
            else if (id == Resource.Id.nav_gLeader_week)
            {
                //There is menu for Group
            }
            else if (id == Resource.Id.nav_gLeader_semestr)
            {
                //There is menu for Group Leader
            }

            DrawerLayout drawer = FindViewById <DrawerLayout>(Resource.Id.drawer_layout);

            drawer.CloseDrawer(GravityCompat.Start);
            return(true);
        }
 public void OnTabSelected(ActionBar.Tab tab, FragmentTransaction ft)
 {
     SupportFragmentManager.PopBackStack(null, FragmentManager.PopBackStackInclusive);
     content.SetCurrentItem(tab.Position, true);
     Log.Debug(Tag, "The tab {0} as been selected.", tab.Text);
 }
 public void ReplaceFragment(Fragment fragment)
 {
     SupportFragmentManager.BeginTransaction()
     .Replace(Resource.Id.content_frame, fragment)
     .Commit();
 }
Exemple #6
0
        private bool ShouldReplaceCurrentFragment(int contentId, string tag)
        {
            var currentFragment = SupportFragmentManager.FindFragmentById(contentId);

            return(currentFragment == null || currentFragment.Tag != tag);
        }
Exemple #7
0
        private void ListItemClicked(int position)
        {
            Android.Support.V4.App.Fragment fragment = null;
            string Tag = "";

            switch (position)
            {
            case 0:

                //Console.WriteLine ("Canvass clickkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk");
                fragment = new CanvassesFragment();
                Tag      = "canvassesFragment";
                SupportFragmentManager.PopBackStack();

//				try {
//					Console.WriteLine (" checking");
//					Android.Support.V4.App.FragmentTransaction ft = SupportFragmentManager.BeginTransaction ();
//					Console.WriteLine (" Fragments found"+SupportFragmentManager.Fragments.Count);
//					foreach (var item in SupportFragmentManager.Fragments) {
//						Console.WriteLine (" item"+item.ToString());
//						if (item.IsAdded) {
//							Console.WriteLine ("Deattaching item"+item.ToString());
//							ft.Detach (item);
//							Console.WriteLine ("done item"+item.ToString());
//						}
//
//					}
//					ft.Add(Resource.Id.content_frame, new CanvassesFragment(), "canvassesFragment");
//
//					ft.AddToBackStack (null);
//					ft.Commit ();
//				} catch (Exception ex) {
//					Console.WriteLine (" exception"+ex.Message);
//				}
//


                break;

            case 1:

                fragment = new mapFragment();
                SupportFragmentManager.PopBackStack();
                Tag = "mapFragment";
                break;

            case 2:
                fragment = new RegisterFragment();
                SupportFragmentManager.PopBackStack();
                Tag = "registerFragment";
                break;

            case 3:
                fragment = new SettingsFragment();
                SupportFragmentManager.PopBackStack();

                Tag = "settingsFragment";
                break;
            }
            try
            {
                SupportFragmentManager.BeginTransaction()
                .Replace(Resource.Id.content_frame, fragment, Tag)
                .Commit();
            }
            catch (Exception ex)
            {
                //Console.WriteLine ("Exception : " + ex.ToString());
            }

            this.m_DrawerList.SetItemChecked(position, true);
            SupportActionBar.Title = this.m_Title = Sections[position];
            this.m_Drawer.CloseDrawer(this.m_DrawerList);
        }
Exemple #8
0
 private void FragmentNavigate(Android.Support.V4.App.Fragment fragment)
 {
     Android.Support.V4.App.FragmentTransaction transaction = SupportFragmentManager.BeginTransaction();
     transaction.Replace(Resource.Id.contentFrame, fragment);
     transaction.Commit();
 }
        //Api sent Comment
        private async void ImgSentOnClick(object sender, EventArgs e)
        {
            try
            {
                IsRecording = false;

                if (BtnVoice.Tag?.ToString() == "Audio")
                {
                    var interTortola = new FastOutSlowInInterpolator();
                    TopFragment.Animate()?.SetInterpolator(interTortola)?.TranslationY(1200)?.SetDuration(300);
                    SupportFragmentManager.BeginTransaction().Remove(RecordSoundFragment).Commit();

                    PathVoice = RecorderService.GetRecorded_Sound_Path();
                }

                if (string.IsNullOrEmpty(TxtComment.Text) && string.IsNullOrWhiteSpace(TxtComment.Text) && string.IsNullOrEmpty(PathImage) && string.IsNullOrEmpty(PathVoice))
                {
                    return;
                }

                if (Methods.CheckConnectivity())
                {
                    var dataUser = ListUtils.MyProfileList?.FirstOrDefault();
                    //Comment Code

                    var    unixTimestamp = DateTimeOffset.UtcNow.ToUnixTimeSeconds();
                    string time2         = unixTimestamp.ToString(CultureInfo.InvariantCulture);

                    CommentObjectExtra comment = new CommentObjectExtra
                    {
                        Id             = unixTimestamp.ToString(),
                        PostId         = PostObject.Id,
                        UserId         = UserDetails.UserId,
                        Text           = TxtComment.Text,
                        Time           = time2,
                        CFile          = PathImage,
                        Record         = PathVoice,
                        Publisher      = dataUser,
                        Url            = dataUser?.Url,
                        Fullurl        = PostObject?.PostUrl,
                        Orginaltext    = TxtComment.Text,
                        Owner          = true,
                        CommentLikes   = "0",
                        CommentWonders = "0",
                        IsCommentLiked = false,
                        Replies        = "0",
                        RepliesCount   = "0"
                    };

                    MAdapter.CommentList.Add(comment);

                    var index = MAdapter.CommentList.IndexOf(comment);
                    if (index > -1)
                    {
                        MAdapter.NotifyItemInserted(index);
                    }

                    MRecycler.Visibility = ViewStates.Visible;

                    var dd = MAdapter.CommentList.FirstOrDefault();
                    if (dd?.Text == MAdapter.EmptyState)
                    {
                        MAdapter.CommentList.Remove(dd);
                        MAdapter.NotifyItemRemoved(MAdapter.CommentList.IndexOf(dd));
                    }

                    ImgGallery.SetImageDrawable(AppSettings.SetTabDarkTheme ? GetDrawable(Resource.Drawable.ic_action_addpost_Ligth) : GetDrawable(Resource.Drawable.ic_action_AddPost));
                    var text = TxtComment.Text;

                    //Hide keyboard
                    TxtComment.Text = "";

                    (int apiStatus, var respond) = await RequestsAsync.Comment.CreatePostComments(PostObject.PostId, text, PathImage, PathVoice);

                    if (apiStatus == 200)
                    {
                        if (respond is CreateComments result)
                        {
                            var date = MAdapter.CommentList.FirstOrDefault(a => a.Id == comment.Id) ?? MAdapter.CommentList.FirstOrDefault(x => x.Id == result.Data.Id);
                            if (date != null)
                            {
                                var db = ClassMapper.Mapper?.Map <CommentObjectExtra>(result.Data);

                                date    = db;
                                date.Id = result.Data.Id;

                                index = MAdapter.CommentList.IndexOf(MAdapter.CommentList.FirstOrDefault(a => a.Id == unixTimestamp.ToString()));
                                if (index > -1)
                                {
                                    MAdapter.CommentList[index] = db;

                                    //MAdapter.NotifyItemChanged(index);
                                    //MRecycler.ScrollToPosition(index);
                                }

                                var postFeedAdapter = TabbedMainActivity.GetInstance()?.NewsFeedTab?.PostFeedAdapter;
                                var dataGlobal      = postFeedAdapter?.ListDiffer?.Where(a => a.PostData?.Id == PostObject?.PostId).ToList();
                                if (dataGlobal?.Count > 0)
                                {
                                    foreach (var dataClass in from dataClass in dataGlobal let indexCom = postFeedAdapter.ListDiffer.IndexOf(dataClass) where indexCom > -1 select dataClass)
                                    {
                                        dataClass.PostData.PostComments = MAdapter.CommentList.Count.ToString();

                                        if (dataClass.PostData.GetPostComments?.Count > 0)
                                        {
                                            var dataComment = dataClass.PostData.GetPostComments.FirstOrDefault(a => a.Id == date.Id);
                                            if (dataComment == null)
                                            {
                                                dataClass.PostData.GetPostComments.Add(date);
                                            }
                                        }
                                        else
                                        {
                                            dataClass.PostData.GetPostComments = new List <GetCommentObject> {
                                                date
                                            };
                                        }

                                        postFeedAdapter.NotifyItemChanged(postFeedAdapter.ListDiffer.IndexOf(dataClass), "commentReplies");
                                    }
                                }

                                var postFeedAdapter2 = WRecyclerView.GetInstance()?.NativeFeedAdapter;
                                var dataGlobal2      = postFeedAdapter2?.ListDiffer?.Where(a => a.PostData?.Id == PostObject?.PostId).ToList();
                                if (dataGlobal2?.Count > 0)
                                {
                                    foreach (var dataClass in from dataClass in dataGlobal2 let indexCom = postFeedAdapter2.ListDiffer.IndexOf(dataClass) where indexCom > -1 select dataClass)
                                    {
                                        dataClass.PostData.PostComments = MAdapter.CommentList.Count.ToString();

                                        if (dataClass.PostData.GetPostComments?.Count > 0)
                                        {
                                            var dataComment = dataClass.PostData.GetPostComments.FirstOrDefault(a => a.Id == date.Id);
                                            if (dataComment == null)
                                            {
                                                dataClass.PostData.GetPostComments.Add(date);
                                            }
                                        }
                                        else
                                        {
                                            dataClass.PostData.GetPostComments = new List <GetCommentObject> {
                                                date
                                            };
                                        }

                                        postFeedAdapter2.NotifyItemChanged(postFeedAdapter2.ListDiffer.IndexOf(dataClass), "commentReplies");
                                    }
                                }
                            }
                        }
                    }
                    //else Methods.DisplayReportResult(this, respond);

                    //Hide keyboard
                    TxtComment.Text = "";
                    PathImage       = "";
                    PathVoice       = "";

                    BtnVoice.Tag = "Free";
                    BtnVoice.SetImageResource(Resource.Drawable.microphone);
                    BtnVoice.ClearColorFilter();
                }
                else
                {
                    Toast.MakeText(this, GetText(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short)?.Show();
                }
            }
            catch (Exception exception)
            {
                Methods.DisplayReportResultTrack(exception);
            }
        }
        /// <summary>
        /// This method is called when the activity is starting.
        /// It contains the logic for the buttons shown in this activity.
        /// </summary>
        /// <param name="savedInstanceState"> a Bundle that contains the data the activity most recently
        /// supplied if the activity is being re-initialized after previously being shut down. </param>
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.PrivateProfile);

            _loggedId = Intent.GetStringExtra("LoggedId");

            var json = Intent.GetStringExtra("User");

            _user = JsonConvert.DeserializeObject <User>(json);

            _nameView  = FindViewById <TextView>(Resource.Id.nameView);
            _ageView   = FindViewById <TextView>(Resource.Id.ageView);
            _chefView  = FindViewById <TextView>(Resource.Id.chefPText);
            _scoreView = FindViewById <TextView>(Resource.Id.scorePText);

            _pfp          = FindViewById <ImageView>(Resource.Id.profilePic);
            _btnFollowers = FindViewById <Button>(Resource.Id.btnFollowers);
            _btnFollowing = FindViewById <Button>(Resource.Id.btnFollowing);
            _btnFollow    = FindViewById <Button>(Resource.Id.btnCFollow);
            _btnDate      = FindViewById <Button>(Resource.Id.btnPDate);
            _btnScore     = FindViewById <Button>(Resource.Id.btnPScore);
            _btnDiff      = FindViewById <Button>(Resource.Id.btnPDiff);
            _btnRateChef  = FindViewById <Button>(Resource.Id.btnRateChef);

            _menuListView = FindViewById <ListView>(Resource.Id.menuListView);

            _nameView.Text = "Name: " + _user.firstName + " " + _user.lastName;
            _ageView.Text  = "Age: " + _user.age;


            if (!string.IsNullOrEmpty(_user.photo))
            {
                pictureUrl = $"http://{MainActivity.Ipv4}:8080/CookTime_war/cookAPI/resources/getPicture?id={_user.photo}";
                Bitmap bitmap = GetImageBitmapFromUrl(pictureUrl);
                _pfp.SetImageBitmap(bitmap);
            }
            if (_user.chef)
            {
                _chefView.Text          = "Chef: yes";
                _scoreView.Text         = "Score: " + _user.chefScore;
                _btnRateChef.Visibility = ViewStates.Visible;
            }
            else
            {
                _chefView.Text          = "Chef: no";
                _scoreView.Text         = "";
                _btnRateChef.Visibility = ViewStates.Gone;
            }

            _btnFollowers.Text = "FOLLOWERS: " + _user.followerEmails.Count;
            _btnFollowing.Text = "FOLLOWING: " + _user.followingEmails.Count;

            using var webClient = new WebClient { BaseAddress = "http://" + MainActivity.Ipv4 + ":8080/CookTime_war/cookAPI/" };

            var url = "resources/isFollowing?ownEmail=" + _loggedId + "&followingEmail=" + _user.email;

            webClient.Headers[HttpRequestHeader.ContentType] = "application/json";
            var response = webClient.DownloadString(url);

            _btnFollow.Text = response == "0" ? "FOLLOW" : "UNFOLLOW";

            url = "resources/myMenu?email=" + _user.email + "&filter=date";
            var send = webClient.DownloadString(url);

            _menuList                = JsonConvert.DeserializeObject <IList <string> >(send);
            _adapter                 = new RecipeAdapter(this, _menuList);
            _menuListView.Adapter    = _adapter;
            _menuListView.ItemClick += ListClick;

            _btnFollow.Click += (sender, args) =>
            {
                using var webClient2 = new WebClient { BaseAddress = "http://" + MainActivity.Ipv4 + ":8080/CookTime_war/cookAPI/" };
                var followUrl = "resources/followUser?ownEmail=" + _loggedId + "&followingEmail=" + _user.email;
                webClient2.Headers[HttpRequestHeader.ContentType] = "application/json";
                var answer = webClient2.DownloadString(followUrl);

                followUrl = "resources/getUser?id=" + _loggedId;
                webClient2.Headers[HttpRequestHeader.ContentType] = "application/json";
                var userJson = webClient2.DownloadString(followUrl);

                _btnFollow.Text = answer == "0" ? "FOLLOW" : "UNFOLLOW";

                var toastText = answer == "0" ? "unfollowed" : "followed";

                var toast = Toast.MakeText(this, "User " + toastText + ". Redirecting to MyProfile...", ToastLength.Short);
                toast.Show();

                var intent = new Intent(this, typeof(MyProfileActivity));
                intent.PutExtra("User", userJson);
                intent.SetFlags(ActivityFlags.NewTask | ActivityFlags.ClearTask);
                StartActivity(intent);
                OverridePendingTransition(Android.Resource.Animation.SlideInLeft, Android.Resource.Animation.SlideOutRight);
            };

            _btnFollowers.Click += (sender, args) =>
            {
                var intent = new Intent(this, typeof(FollowActivity));
                intent.PutExtra("Title", "Followers");
                intent.PutExtra("LoggedId", _loggedId);
                intent.PutStringArrayListExtra("FollowList", _user.followerEmails);

                StartActivity(intent);
                OverridePendingTransition(Android.Resource.Animation.SlideInLeft, Android.Resource.Animation.SlideOutRight);
            };

            _btnFollowing.Click += (sender, args) =>
            {
                var intent = new Intent(this, typeof(FollowActivity));
                intent.PutExtra("Title", "Following");
                intent.PutExtra("LoggedId", _loggedId);
                intent.PutStringArrayListExtra("FollowList", _user.followingEmails);

                StartActivity(intent);
                OverridePendingTransition(Android.Resource.Animation.SlideInLeft, Android.Resource.Animation.SlideOutRight);
            };

            _btnDate.Click += (sender, args) =>
            {
                sortStr = "date";
                SortMenu();
            };

            _btnScore.Click += (sender, args) =>
            {
                sortStr = "score";
                SortMenu();
            };

            _btnDiff.Click += (sender, args) =>
            {
                sortStr = "difficulty";
                SortMenu();
            };

            _btnRateChef.Click += (sender, args) =>
            {
                //Brings dialog fragment forward
                var transaction = SupportFragmentManager.BeginTransaction();
                var dialogRate  = new DialogRate();

                dialogRate.Show(transaction, "rate");
                dialogRate.LoggedId = _loggedId;
                dialogRate.ChefId   = _user.email;
                dialogRate.Type     = 1;

                dialogRate.EventHandlerRate += RateResult;
            };

            _pfp.Click += (sender, args) =>
            {
                if (!string.IsNullOrEmpty(_user.photo))
                {
                    var transaction = SupportFragmentManager.BeginTransaction();
                    var dialogPShow = new DialogPShow();

                    dialogPShow.Url      = pictureUrl;
                    dialogPShow.TypeText = "Profile Picture";
                    dialogPShow.Show(transaction, "privPfp");
                }
                else
                {
                    string toastText = "user has not set a profile picture you can view.";
                    Toast  _toast    = Toast.MakeText(this, toastText, ToastLength.Short);
                    _toast.Show();
                }
            };
        }
Exemple #11
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.main);
            key = true;
            EditText        tb1     = FindViewById <EditText>(Resource.Id.text);
            SeekBar         ss      = FindViewById <SeekBar>(Resource.Id.speed);
            TextView        sst     = FindViewById <TextView>(Resource.Id.textSpeed);
            SeekBar         sp      = FindViewById <SeekBar>(Resource.Id.ton);
            TextView        spt     = FindViewById <TextView>(Resource.Id.textton);
            Button          button1 = FindViewById <Button>(Resource.Id.buttonread);
            ttsListFragment frag    = SupportFragmentManager.FindFragmentById(Resource.Id.tts_list_fragment) as ttsListFragment;

            ttslist     = new List <elemTts>();
            ss.Progress = sp.Progress = 127;
            sst.Text    = spt.Text = "0,5";
            context     = button1.Context;

            tt = new TextToSpeech(this, this);
            tt.SetPitch(1.25f);
            tt.SetSpeechRate(1f);
            sp.StopTrackingTouch += (object sender, SeekBar.StopTrackingTouchEventArgs e) =>
            {
                var seek     = sender as SeekBar;
                var progress = seek.Progress / 255f;
                tt.SetPitch(seek.Progress / 170f + 0.5f);
                spt.Text = progress.ToString("F2");
            };
            ss.StopTrackingTouch += (object sender, SeekBar.StopTrackingTouchEventArgs e) =>
            {
                var seek     = sender as SeekBar;
                var progress = seek.Progress / 255f;
                tt.SetSpeechRate(seek.Progress / 255f + 0.1f);
                sst.Text = progress.ToString("F2");
            };
            button1.Click += delegate
            {
                try
                {
                    if (new Regex(@"[А-Яа-я]").Match(tb1.Text).Success)
                    {
                        tb1.FindFocus();
                        throw new Exception("возможно чтение только символов английского алфавита");
                    }

                    ttslist.Add(new elemTts(tb1.Text, ss.Progress / 255f + 0.1f, sp.Progress / 170f + 0.5f));
                    frag.OnResume();
                    if (ttslist.Count == 1)
                    {
                        Dictionary <string, string> param = new Dictionary <string, string> {
                            { TextToSpeech.Engine.KeyParamUtteranceId, "1" }
                        };
                        tt.PlaySilence(10, QueueMode.Add, param);
                    }
                }
                catch (Exception E)
                {
                    Toast.MakeText(this, E.Message, ToastLength.Short).Show();
                }
            };
            Button button2 = FindViewById <Button>(Resource.Id.buttonload);

            button2.Click += delegate
            {
                StartActivityForResult(new Intent(this, typeof(FilePickerActivity)), tkey);
            };
        }
Exemple #12
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            Xamarin.Essentials.Platform.Init(this, savedInstanceState);

            SetContentView(Resource.Layout.activity_main);

            _appBar          = FindViewById <Toolbar>(Resource.Id.main_appbar);
            _navBar          = FindViewById <BottomNavigationView>(Resource.Id.main_navbar);
            _mainContainer   = FindViewById <FragmentContainerView>(Resource.Id.main_container);
            _loadingView     = FindViewById(Resource.Id.main_loading_view);
            _emptyView       = FindViewById(Resource.Id.main_empty_view);
            _errorView       = FindViewById(Resource.Id.main_error_view);
            _currentPackage  = PackageManager?.GetPackageInfo(PackageName, 0);
            _retryButton     = FindViewById <Button>(Resource.Id.fragment_recyclerview_error_retry);
            _emptyTextView   = FindViewById <TextView>(Resource.Id.fragment_recyclerview_empty_text);
            _errorTextView   = FindViewById <TextView>(Resource.Id.fragment_recyclerview_error_text);
            _loadingTextView = FindViewById <TextView>(Resource.Id.fragment_recyclerview_loading_textview);
            _emptyImageView  = FindViewById <ImageView>(Resource.Id.fragment_recyclerview_empty_image);
            _errorImageView  = FindViewById <ImageView>(Resource.Id.fragment_recyclerview_error_image);

            SetSupportActionBar(_appBar);
            SupportFragmentManager.BackStackChanged += OnBackStackChanged;
            _navBar.NavigationItemSelected          += Navbar_NavigationItemSelected;
            _retryButton.Click += RetryButton_Click;

            // Work around for white icons on white background
            // on status bar and navigation bar on older versions of Android
            if (Build.VERSION.SdkInt < BuildVersionCodes.M)
            {
                Window?.SetStatusBarColor(Color.Black);
            }
            if (Build.VERSION.SdkInt < BuildVersionCodes.OMr1)
            {
                Window?.SetNavigationBarColor(Color.Black);
            }

            var accountsDir = ((IDataStorage)this).GetAccountsDir();
            var cacheDir    = ((IDataStorage)this).GetCacheDir();

            if (accountsDir == null ||
                cacheDir == null)
            {
                // TODO: Panic
                return;
            }

            _accounts = new Accounts(accountsDir, cacheDir);

            _client = new HttpClient();

            if (savedInstanceState != null)
            {
                // TODO: Load Accounts Data

                if (SupportFragmentManager.BackStackEntryCount > 0)
                {
                    SupportActionBar.SetDisplayHomeAsUpEnabled(true);
                    _navBar.Visibility = ViewStates.Gone;
                }

                ((IFragmentContainer)this).ShowContentView();

                return;
            }

            BeginTransition();
            SupportFragmentManager
            .BeginTransaction()
            .Add(Resource.Id.main_container, _accountsFragment)
            .Commit();
        }
Exemple #13
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.fragmentHolder);

            btnNext = FindViewById <ImageButton>(Resource.Id.btnContinueFragment);
            btnBack = FindViewById <ImageButton>(Resource.Id.btnBackFragment);

            var mFrg1 = new O_IFR_Day_XC5();
            var mFrg2 = new O_IFR_Day_XC6();

            mStackFragment = new Stack <SupportFragment>();

            var trans = SupportFragmentManager.BeginTransaction();

            if (questionNum == 5)
            {
                mCurrent    = mFrg2;
                questionNum = 3;
            }
            else
            {
                questionNum = 0;
                mCurrent    = mFrg1;
            }
            trans.Add(Resource.Id.frameLayout1, mCurrent);
            trans.Commit();

            Bundle bundle = new Bundle();;

            Android.App.FragmentTransaction fragmentTransaction = FragmentManager.BeginTransaction();
            mFrg2.Arguments = bundle;
            mFrg1.Arguments = bundle;

            var txtRisk    = FindViewById <TextView>(Resource.Id.txtRiskFragment);
            var txtRiskNum = FindViewById <TextView>(Resource.Id.txtRiskNumFragment);

            ShortCutFunctions sc = new ShortCutFunctions();

            sc.riskShow(txtRisk, txtRiskNum, "Destination Risk", destinationRisk, 8, 10);

            btnNext.Click += (s, e) =>
            {
                if (mCurrent.Equals(mFrg2)) //determining question
                {
                    if (destinationRisk > 9)
                    {
                        sc.alertShow("Destination Risk", this);
                    }
                    else
                    {
                        StartActivity(typeof(O_IFR_Day_XC_4Alternate));
                        questionNum = 5;
                    }
                }
                else
                {
                    questionNum += 3;
                    replaceFragment(mFrg2);
                }
            };

            btnBack.Click += (s, e) =>
            {
                if (mCurrent.Equals(mFrg1))
                {
                    StartActivity(typeof(O_IFR_Day_XC_2Enroute));
                }
                else
                {
                    replaceFragment(mFrg1);
                    questionNum -= 3;
                }
            };
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            CrossCurrentActivity.Current.Init(this, savedInstanceState);
            //  Xamarin.Essentials.Platform.Init(this, savedInstanceState);
            SetContentView(Resource.Layout.activity_main);
            ActionBar.Hide();

            Android.Support.V7.Widget.Toolbar toolbar = FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar);
            SetSupportActionBar(toolbar);

            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);

            navigationView.SetNavigationItemSelectedListener(this);

            mFragment1     = new HomeFragment();
            mFragment2     = new HangarFragment();
            mFragment3     = new OrgFragment();
            mFragment4     = new TradeFragment();
            mFragment5     = new DatabankFragment();
            mFragment6     = new MissionsFragment();
            mFragment7     = new TradeportsFragment();
            mFragment8     = new CommadatiesFragment();
            mFragment9     = new MiningFragment();
            mFragment10    = new MyOrgFragment();
            mFragment11    = new SearchFragment();
            mFragment12    = new ShipsFragment();
            mFragment13    = new ComponentsFragment();
            mFragment14    = new StoresFragment();
            mStackFragment = new Stack <SupportFragment>();



            var trans = SupportFragmentManager.BeginTransaction();

            trans.Add(Resource.Id.fragmentContainer, mFragment14, "Stores Fragment");
            trans.Hide(mFragment14);

            trans.Add(Resource.Id.fragmentContainer, mFragment13, "Components Fragment");
            trans.Hide(mFragment13);

            trans.Add(Resource.Id.fragmentContainer, mFragment12, "Ships Fragment");
            trans.Hide(mFragment12);

            trans.Add(Resource.Id.fragmentContainer, mFragment11, "Search Fragment");
            trans.Hide(mFragment11);

            trans.Add(Resource.Id.fragmentContainer, mFragment10, "MyOrg Fragment");
            trans.Hide(mFragment10);

            trans.Add(Resource.Id.fragmentContainer, mFragment9, "Mining Fragment");
            trans.Hide(mFragment9);

            trans.Add(Resource.Id.fragmentContainer, mFragment8, "Commadaties Fragment");
            trans.Hide(mFragment8);

            trans.Add(Resource.Id.fragmentContainer, mFragment7, "Tradeports Fragment");
            trans.Hide(mFragment7);

            trans.Add(Resource.Id.fragmentContainer, mFragment6, "Missions Fragment");
            trans.Hide(mFragment6);

            trans.Add(Resource.Id.fragmentContainer, mFragment5, "Databank Fragment");
            trans.Hide(mFragment5);

            trans.Add(Resource.Id.fragmentContainer, mFragment4, "Trade Fragment");
            trans.Hide(mFragment4);

            trans.Add(Resource.Id.fragmentContainer, mFragment3, "Org Fragment");
            trans.Hide(mFragment3);

            trans.Add(Resource.Id.fragmentContainer, mFragment2, "Hangar Fragment");
            trans.Hide(mFragment2);

            trans.Add(Resource.Id.fragmentContainer, mFragment1, "Home Fragment");
            trans.Commit();

            mCurrentFragment = mFragment1;
        }
        public override bool OnOptionsItemSelected(IMenuItem item)
        {
            Intent   intent;
            DBHelper dbh;

            switch (item.ItemId)
            {
            case Android.Resource.Id.Home:
                if (SupportFragmentManager.BackStackEntryCount > 0)
                {
                    SupportFragmentManager.PopBackStack();
                    mCurrentFragment = mStackFrag.Pop();
                }
                else
                {
                    Finish();
                }
                return(true);

            case Resource.Id.menu_slist_edit:
                intent = new Intent(this, typeof(EditShoppingListActivity));
                intent.PutExtra("ListId", selListId.ToString());
                StartActivity(intent);
                return(true);

            case Resource.Id.menu_slist_pend:
                dbh = new DBHelper();
                dbh.UpdateShoppingListStatus(selListId, "Pending");
                return(true);

            case Resource.Id.menu_slist_poned:
                dbh = new DBHelper();
                dbh.UpdateShoppingListStatus(selListId, "Postponed");
                return(true);

            case Resource.Id.menu_slist_done:
                dbh = new DBHelper();
                dbh.UpdateShoppingListStatus(selListId, "Completed");
                return(true);

            case Resource.Id.menu_slist_items:
                if (SupportFragmentManager.BackStackEntryCount > 0)
                {
                    SupportFragmentManager.PopBackStack();
                    mCurrentFragment = mStackFrag.Pop();
                }
                else
                {
                    ShowFragment(mListItemsFrag);
                }
                return(true);

            case Resource.Id.menu_sitem_add:
                intent = new Intent(this, typeof(NewShoppingItemActivity));
                intent.PutExtra("ListId", selListId.ToString());
                StartActivity(intent);
                return(true);

            default:
                return(base.OnOptionsItemSelected(item));
            }
        }
 /// <summary>
 /// Called when [navigate to].
 /// </summary>
 /// <param name="obj">The object.</param>
 void OnNavigateTo(NavigateToMessage obj)
 {
     SupportFragmentManager.PopBackStack(null, (int)PopBackStackFlags.None);
     ViewModel.SelectFirstView();
 }
 private void ChangeFragments(int position)
 {
     fragment = CreateNewFragment(position);
     SupportFragmentManager.BeginTransaction().Replace(Resource.Id.content_frame, fragment).Commit();
 }
        /// <summary>
        ///     Show Fragment with a specific tag at a specific placeholder
        /// </summary>
        /// <param name="tag">The tag for the fragment to lookup</param>
        /// <param name="contentId">Where you want to show the Fragment</param>
        /// <param name="bundle">Bundle which usually contains a Serialized MvxViewModelRequest</param>
        /// <param name="forceAddToBackStack">If you want to force add the fragment to the backstack so on backbutton it will go back to it. Note: This will override IMvxCachedFragmentInfo.AddToBackStack configuration.</param>
        /// <param name="forceReplaceFragment">If you want the fragment to be re-created</param>
        protected virtual void ShowFragment(string tag, int contentId, Bundle bundle, bool forceAddToBackStack = false, bool forceReplaceFragment = false)
        {
            IMvxCachedFragmentInfo fragInfo;

            FragmentCacheConfiguration.TryGetValue(tag, out fragInfo);

            IMvxCachedFragmentInfo currentFragInfo = null;
            var currentFragment = SupportFragmentManager.FindFragmentById(contentId);

            if (currentFragment != null)
            {
                FragmentCacheConfiguration.TryGetValue(currentFragment.Tag, out currentFragInfo);
            }

            if (fragInfo == null)
            {
                throw new MvxException("Could not find tag: {0} in cache, you need to register it first.", tag);
            }

            // We shouldn't replace the current fragment unless we really need to.
            FragmentReplaceMode fragmentReplaceMode = FragmentReplaceMode.ReplaceFragmentAndViewModel;

            if (!forceReplaceFragment)
            {
                fragmentReplaceMode = ShouldReplaceCurrentFragment(fragInfo, currentFragInfo, bundle);
            }

            if (fragmentReplaceMode == FragmentReplaceMode.NoReplace)
            {
                return;
            }

            var ft = SupportFragmentManager.BeginTransaction();

            OnBeforeFragmentChanging(fragInfo, ft);

            fragInfo.ContentId = contentId;

            //If we already have a previously created fragment, we only need to send the new parameters
            if (fragInfo.CachedFragment != null && fragmentReplaceMode == FragmentReplaceMode.ReplaceFragment)
            {
                ((Fragment)fragInfo.CachedFragment).Arguments.Clear();
                ((Fragment)fragInfo.CachedFragment).Arguments.PutAll(bundle);

                var childViewModelCache = Mvx.GetSingleton <IMvxChildViewModelCache>();
                var viewModelType       = fragInfo.CachedFragment.ViewModel.GetType();
                if (childViewModelCache.Exists(viewModelType))
                {
                    fragInfo.CachedFragment.ViewModel = childViewModelCache.Get(viewModelType);
                    childViewModelCache.Remove(viewModelType);
                }
            }
            else
            {
                //Otherwise, create one and cache it
                fragInfo.CachedFragment = Fragment.Instantiate(this, FragmentJavaName(fragInfo.FragmentType),
                                                               bundle) as IMvxFragmentView;
                OnFragmentCreated(fragInfo, ft);
            }

            currentFragment = fragInfo.CachedFragment as Fragment;
            ft.Replace(fragInfo.ContentId, fragInfo.CachedFragment as Fragment, fragInfo.Tag);

            //if replacing ViewModel then clear the cache after the fragment
            //has been added to the transaction so that the Tag property is not null
            //and the UniqueImmutableCacheTag property (if not overridden) has the correct value
            if (fragmentReplaceMode == FragmentReplaceMode.ReplaceFragmentAndViewModel)
            {
                var cache = Mvx.GetSingleton <IMvxMultipleViewModelCache>();
                cache.GetAndClear(fragInfo.ViewModelType, GetTagFromFragment(fragInfo.CachedFragment as Fragment));
            }

            if (currentFragment != null && fragInfo.AddToBackStack || forceAddToBackStack)
            {
                ft.AddToBackStack(fragInfo.Tag);
            }

            OnFragmentChanging(fragInfo, ft);
            ft.Commit();
            SupportFragmentManager.ExecutePendingTransactions();
            OnFragmentChanged(fragInfo);
        }
Exemple #19
0
        public void PrepareRecord()
        {
            //================================remove those test which not belonged to loogedin user=============//
            MyFinalTestList = new List <AllTestModelData>();
            for (int i = 0; i < AllTestlist.Count; i++)
            {
                if (AllTestlist[i].Packages.Equals(packageid))
                {
                    MyFinalTestList.Add(AllTestlist[i]);
                }
                else
                {
                    string[] pacjagearray = AllTestlist[i].Packages.Split(",");
                    for (int y = 0; y < pacjagearray.Length; y++)
                    {
                        if (packageid.Equals(pacjagearray[y]))
                        {
                            MyFinalTestList.Add(AllTestlist[i]);
                            break;
                        }
                        else
                        {
                            continue;
                        }
                    }
                }
            }
            MyFinalTestListMock = new List <AllTestModelData>();
            for (int i = 0; i < AllTestlistMock.Count; i++)
            {
                if (AllTestlistMock[i].Packages.Equals(packageidMock))
                {
                    MyFinalTestListMock.Add(AllTestlistMock[i]);
                }
                else
                {
                    string[] pacjagearray = AllTestlistMock[i].Packages.Split(",");
                    for (int y = 0; y < pacjagearray.Length; y++)
                    {
                        if (packageidMock.Equals(pacjagearray[y]))
                        {
                            MyFinalTestListMock.Add(AllTestlistMock[i]);
                            break;
                        }
                        else
                        {
                            continue;
                        }
                    }
                }
            }


            List <AllTestModelData> GivenExamTest      = new List <AllTestModelData>();
            List <AllTestModelData> GivenPracticalTest = new List <AllTestModelData>();

            try
            {
                for (int i = 0; i < GivenTestlist.Count; i++)
                {
                    if (GivenTestlist[i].TestType.Equals("Exam"))
                    {
                        GivenExamTest.Add(GivenTestlist[i]);
                    }
                    else
                    {
                        GivenPracticalTest.Add(GivenTestlist[i]);
                    }
                }
            }
            catch (Exception)
            {
            }

            for (int i = 0; i < MyFinalTestList.Count; i++)
            {
                ISharedPreferences       pref;
                ISharedPreferencesEditor edit;
                pref = GetSharedPreferences(MyFinalTestList[i].ID + "", FileCreationMode.Private);
                edit = pref.Edit();
                string question = pref.GetString("TestRecord", String.Empty);
                if (question.Length > 0)
                {
                    MyFinalTestList[i].Text       = "Resume";
                    MyFinalTestList[i].background = Resource.Drawable.greenRectangle;
                }
                else
                {
                    MyFinalTestList[i].Text       = "Start Test";
                    MyFinalTestList[i].background = Resource.Drawable.mytestTextview;
                }
                for (int y = 0; y < GivenExamTest.Count; y++)
                {
                    if (MyFinalTestList[i].ID == GivenExamTest[y].TestID)
                    {
                        MyFinalTestList[i].Text       = "Taken";
                        MyFinalTestList[i].background = Resource.Drawable.myorangetextview;
                    }

                    else
                    {
                        continue;
                    }
                }
            }

            for (int i = 0; i < MyFinalTestListMock.Count; i++)
            {
                ISharedPreferences       pref;
                ISharedPreferencesEditor edit;
                pref = GetSharedPreferences(MyFinalTestListMock[i].ID + "", FileCreationMode.Private);
                edit = pref.Edit();
                string question = pref.GetString("TestRecord", String.Empty);
                if (question.Length > 0)
                {
                    MyFinalTestListMock[i].Text       = "Resume";
                    MyFinalTestListMock[i].background = Resource.Drawable.greenRectangle;
                }
                else
                {
                    MyFinalTestListMock[i].Text       = "Start Test";
                    MyFinalTestListMock[i].background = Resource.Drawable.mytestTextview;
                }
                for (int y = 0; y < GivenPracticalTest.Count; y++)
                {
                    if (MyFinalTestListMock[i].ID == GivenPracticalTest[y].TestID)
                    {
                        MyFinalTestListMock[i].Text       = "Taken";
                        MyFinalTestListMock[i].background = Resource.Drawable.myorangetextview;
                    }

                    else
                    {
                        continue;
                    }
                }
            }

            //===================================================================================================//
            txtOnlinetest.SetBackgroundResource(Resource.Drawable.TabOnlineTextviewSelect);
            txtOnlinetest.SetTextColor(new Android.Graphics.Color(ContextCompat.GetColor(this, Resource.Color.white)));

            txtMockTest.SetBackgroundResource(Resource.Drawable.TabMockTextviewUnselect);
            txtMockTest.SetTextColor(new Android.Graphics.Color(ContextCompat.GetColor(this, Resource.Color.black)));

            myFinalTestlistserilize     = JsonConvert.SerializeObject(MyFinalTestList);
            myFinalMOckTestlistserilize = JsonConvert.SerializeObject(MyFinalTestListMock);
            cp.Dismiss();
            DoOnlineTestFragment obj = new DoOnlineTestFragment();
            Bundle bundle            = new Bundle();

            // bundle.PutString("AllTestList", myFinalTestlistserilize);
            obj.Arguments = bundle;
            SupportFragmentManager.BeginTransaction().Replace(Resource.Id.testlistfragment, obj).Commit();
            //==================================================================================================//
        }
Exemple #20
0
        public bool OnNavigationItemSelected(IMenuItem item)
        {
            int id = item.ItemId;

            if (id == Resource.Id.nav_issues)
            {
                DialogHelper.Prompt(this, "Question",
                                    "Go to GitHub issues?", "Yes", "No").ContinueWith(prev =>
                {
                    if (prev.Result == true)
                    {
                        var uri           = "https://github.com/taori/PCRemote2/issues";
                        var browserIntent = new Intent(Intent.ActionView, Uri.Parse(uri));
                        StartActivity(browserIntent);
                    }
                });
            }
            else if (id == Resource.Id.nav_logs)
            {
                using var transaction = SupportFragmentManager.BeginTransaction();
                var fragment = SupportFragmentManager.FindFragmentByTag(nameof(LogFragment));
                if (fragment == null)
                {
                    transaction.SetStatusBarTitle("Logs");
                    transaction.SetTransition(AndroidX.Fragment.App.FragmentTransaction.TransitFragmentFade);
                    transaction.AddToBackStack(null);
                    transaction.Replace(Resource.Id.app_bar_main_container, new LogFragment(), nameof(LogFragment));
                    transaction.Commit();
                }
                else
                {
                    transaction.SetTransition(AndroidX.Fragment.App.FragmentTransaction.TransitFragmentFade);
                    transaction.Replace(Resource.Id.app_bar_main_container, fragment, nameof(LogFragment));
                    transaction.Commit();
                }
            }
            else if (id == Resource.Id.nav_settings)
            {
                var fragmentExists = SupportFragmentManager.FindFragmentByTag(nameof(SettingsFragment)) != null;
                if (!fragmentExists)
                {
                    using var transaction = SupportFragmentManager.BeginTransaction();
                    transaction.SetStatusBarTitle("Settings");
                    transaction.ReplaceContentAnimated(new SettingsFragment(), nameof(SettingsFragment));
                    transaction.Commit();
                }
            }
            else if (id == Resource.Id.nav_update)
            {
                var fragmentExists = SupportFragmentManager.FindFragmentByTag(nameof(UpdateFragment)) != null;
                if (!fragmentExists)
                {
                    using var transaction = SupportFragmentManager.BeginTransaction();
                    transaction.SetStatusBarTitle("Update");
                    transaction.ReplaceContentAnimated(new UpdateFragment(), nameof(UpdateFragment));
                    transaction.Commit();
                }
            }

            DrawerLayout drawer = FindViewById <DrawerLayout>(Resource.Id.drawer_layout);

            drawer.CloseDrawer(GravityCompat.Start);
            return(true);
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            /* Needs to be registered only on the MainLauncher */
            Iconize.With(new MaterialModule());

            SetSupportActionBar(_toolbar);
            SupportActionBar.SetHomeButtonEnabled(true);
            SupportActionBar.SetDisplayHomeAsUpEnabled(true);

            /*
             * See Material Font Cheetsheat Here: https://goo.gl/FMCiR9
             */
            var icon = new IconDrawable(this, "md-menu");

            icon.Color(Color.White);

            /* Sets the size to the action bar, ready to put it there */
            icon.ActionBarSize();

            /* Add the icon the the ActionBar */
            SupportActionBar.SetHomeAsUpIndicator(icon);

            /* Implement the Hamburger Menu Selection Changed */
            _navigationView.NavigationItemSelected += (sender, item) =>
            {
                // Open Fragments Here
                Android.Support.V4.App.Fragment selectedFragment;
                switch (item.MenuItem.ItemId)
                {
                case Resource.Id.recommendations:
                    selectedFragment = new SearchUserFragment();
                    break;

                default:
                    selectedFragment = new ResultsTabFragment();
                    break;
                }

                try
                {
                    SupportFragmentManager
                    .BeginTransaction()
                    .Replace(Resource.Id.fragmentContainer, selectedFragment)
                    .Commit();

                    item.MenuItem.SetChecked(true);

                    _drawerLayout.CloseDrawers();
                }
                catch (Exception e)
                {
                    System.Diagnostics.Debug.WriteLine(e.Message);
                }
            };

            _navigationView.SetCheckedItem(Resource.Id.recommendations);
            try
            {
                SupportFragmentManager
                .BeginTransaction()
                .Replace(Resource.Id.fragmentContainer, new SearchUserFragment())
                .Commit();
            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.WriteLine(e.Message);
            }
        }
Exemple #22
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);
            mToolbar      = FindViewById <SupportToolbar>(Resource.Id.toolbar);
            mDrawerLayout = FindViewById <DrawerLayout>(Resource.Id.drawer_layout);
            mLeftDrawer   = FindViewById <ListView>(Resource.Id.left_drawer);
            mRightDrawer  = FindViewById <ListView>(Resource.Id.right_drawer);

            mFragment1 = new Fragment1();
            mFragment2 = new Fragment2();
            mFragment3 = new Fragment3();
            mFragment4 = new Fragment4();
            mFragment5 = new Fragment5();

            mStackFragment   = new Stack <SupportFragment>();
            mLeftDrawer.Tag  = 0;
            mRightDrawer.Tag = 1;

            SetSupportActionBar(mToolbar);

            mLeftDataSet = new List <string>();
            mLeftDataSet.Add("Home");
            mLeftDataSet.Add("Search");
            mLeftDataSet.Add("Search Map");
            mLeftAdapter        = new ArrayAdapter <String>(this, Android.Resource.Layout.SimpleListItem1, mLeftDataSet);
            mLeftDrawer.Adapter = mLeftAdapter;

            mRightDataSet = new List <string>();
            mRightDataSet.Add("About");
            mRightDataSet.Add("Contact Us");
            mRightAdapter        = new ArrayAdapter <String>(this, Android.Resource.Layout.SimpleListItem1, mRightDataSet);
            mRightDrawer.Adapter = mRightAdapter;


            var trans = SupportFragmentManager.BeginTransaction();

            trans.Add(Resource.Id.fragmentContainer, mFragment5, "Fragment5");
            trans.Hide(mFragment5);
            trans.Add(Resource.Id.fragmentContainer, mFragment4, "Fragment4");
            trans.Hide(mFragment4);
            trans.Add(Resource.Id.fragmentContainer, mFragment3, "Fragment3");
            trans.Hide(mFragment3);
            trans.Add(Resource.Id.fragmentContainer, mFragment2, "Fragment2");
            trans.Hide(mFragment2);
            trans.Add(Resource.Id.fragmentContainer, mFragment1, "Fragment1");
            trans.Commit();

            mCurrentFRagment = mFragment1;

            mDrawerLayout.AddDrawerListener(mDrawerToggle);
            SupportActionBar.SetDisplayHomeAsUpEnabled(true);
            SupportActionBar.SetHomeButtonEnabled(true);
            SupportActionBar.SetDisplayShowTitleEnabled(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);
            }
        }
Exemple #23
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.activity_page_preview);

            var toolbar = FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar);

            SetSupportActionBar(toolbar);

            SupportActionBar.Title = Texts.scan_results;
            SupportActionBar.SetDisplayHomeAsUpEnabled(true);
            SupportActionBar.SetDisplayShowHomeEnabled(true);

            var fragment = SupportFragmentManager.FindFragmentByTag(FILTERS_MENU_TAG);

            if (fragment != null)
            {
                SupportFragmentManager.BeginTransaction().Remove(fragment).CommitNow();
            }

            filterFragment = new FilterBottomSheetMenuFragment();

            var fragment2 = SupportFragmentManager.FindFragmentByTag(SAVE_MENU_TAG);

            if (fragment2 != null)
            {
                SupportFragmentManager.BeginTransaction().Remove(fragment2).CommitNow();
            }

            saveFragment = new SaveBottomSheetMenuFragment();

            adapter = new PageAdapter();
            adapter.HasStableIds = true;
            adapter.Context      = this;

            recycleView = FindViewById <RecyclerView>(Resource.Id.pages_preview);
            recycleView.HasFixedSize = true;
            recycleView.SetAdapter(adapter);

            var layout = new GridLayoutManager(this, 3);

            recycleView.SetLayoutManager(layout);

            adapter.SetItems(PageRepository.Pages);

            progress = FindViewById <ProgressBar>(Resource.Id.progressBar);

            var addPage = FindViewById <TextView>(Resource.Id.action_add_page);

            addPage.Text   = Texts.add_page;
            addPage.Click += delegate
            {
                var configuration = new DocumentScannerConfiguration();
                configuration.SetCameraPreviewMode(CameraPreviewMode.FillIn);
                configuration.SetIgnoreBadAspectRatio(true);
                var intent = DocumentScannerActivity.NewIntent(this, configuration);
                StartActivityForResult(intent, CAMERA_ACTIVITY);
            };

            var results = FindViewById <TextView>(Resource.Id.scan_results);

            results.Text = Texts.scan_results;

            delete        = FindViewById <TextView>(Resource.Id.action_delete_all);
            delete.Text   = Texts.delete_all;
            delete.Click += delegate
            {
                PageRepository.Clear();
                adapter.NotifyDataSetChanged();
                delete.Enabled = false;
                filter.Enabled = false;
                save.Enabled   = false;
            };

            filter        = FindViewById <TextView>(Resource.Id.action_filter);
            filter.Text   = Texts.filter;
            filter.Click += delegate
            {
                var existing = SupportFragmentManager.FindFragmentByTag(FILTERS_MENU_TAG);
                filterFragment.Show(SupportFragmentManager, FILTERS_MENU_TAG);
            };

            save        = FindViewById <Button>(Resource.Id.action_save_document);
            save.Text   = Texts.save;
            save.Click += delegate
            {
                var existing = SupportFragmentManager.FindFragmentByTag(SAVE_MENU_TAG);
                saveFragment.Show(SupportFragmentManager, SAVE_MENU_TAG);
            };
        }
Exemple #24
0
 private void DetectDetailFragmentDataContext()
 {
     _detailFragment = (DetailFragment)SupportFragmentManager.FindFragmentById(Resource.Id.detail_fragment);;
 }
Exemple #25
0
        protected Fragment GetCurrentFragment()
        {
            var fragment = SupportFragmentManager?.FindFragmentById(FragmentContainerId);

            return(fragment);
        }
Exemple #26
0
        private void SetTitlesFragmentDataContext()
        {
            var listFragment = (TitlesFragment)SupportFragmentManager.FindFragmentById(Resource.Id.titles_fragment);

            listFragment.ViewModel = ViewModel;
        }
 private void SetFragment(AndroidX.Fragment.App.Fragment fragment)
 {
     SupportFragmentManager.BeginTransaction()
     .Replace(Resource.Id.frag_container, fragment)
     .CommitAllowingStateLoss();
 }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.activity_main);
            Android.Support.V7.Widget.Toolbar toolbar = FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar);
            SetSupportActionBar(toolbar);

            IsPlayServicesAvailable();
            CreateNotificationChannel();

            Preferences.Set("isPending", false);
            Preferences.Set("isHandle", false);
            Preferences.Set("isWaiting", false);
            Preferences.Set("responseStauts", "");
            Preferences.Set("displaySetting", 0);

            const string TAG            = "MyFirebaseIIDService";
            var          refreshedToken = FirebaseInstanceId.Instance.Token;

            Log.Debug(TAG, "Refreshed token: " + refreshedToken);

            string carID     = "";
            string renter_id = "";
            string action    = "";
            bool   is_action = false;

            //push handling

            if (Intent.Extras != null)
            {
                foreach (var key in Intent.Extras.KeySet())
                {
                    if (key == "user_id")
                    {
                        renter_id = Intent.Extras.GetString(key);
                    }
                    if (key == "vehicle_id")
                    {
                        carID = Intent.Extras.GetString(key);
                    }
                    if (key == "action")
                    {
                        action    = Intent.Extras.GetString(key);
                        is_action = true;
                    }
                    if (key == "OTK")
                    {
                        string OTK = Intent.Extras.GetString(key);
                        Preferences.Set("OTK", OTK);
                    }
                }
                if (is_action)
                {
                    switch (Convert.ToInt32(action))
                    {
                    case 1:
                        Log.Debug(TAG, "Notification: Permit Request");
                        Preferences.Set("displaySetting", 1);
                        Preferences.Set("carId", carID);
                        string rent_car = Preferences.Get("carId", "");
                        Preferences.Set("renter_id", renter_id);
                        break;

                    case 2:     //declined
                        Preferences.Set("displaySetting", 2);
                        Log.Debug(TAG, "Notification: Permit Status Change");
                        break;

                    case 3:     //approved
                        Preferences.Set("displaySetting", 3);
                        break;

                    default:
                        Log.Debug(TAG, "Notification: Unknown");
                        break;
                    }
                }
            }

            //fragments init

            var trans = SupportFragmentManager.BeginTransaction();

            mMainFragment     = new mainFragment();
            mMyCarsFragment   = new myCars();
            mHistoryFragment  = new History();
            mCurrrentFragment = mMainFragment;
            trans.Add(Resource.Id.fragmentContainer, mHistoryFragment, "HistoryFragment");
            trans.Hide(mHistoryFragment);
            trans.Add(Resource.Id.fragmentContainer, mMyCarsFragment, "MyCarsFragment");
            trans.Hide(mMyCarsFragment);
            trans.Add(Resource.Id.fragmentContainer, mMainFragment, "Mainfragment");
            trans.Commit();

            //login try

            String login_hash = Preferences.Get("login_hash", "1");
            String user_id    = Preferences.Get("user_id", "0");

            if (login_hash == "1")
            {
                Intent login_try = new Intent(this, typeof(loginActivity));
                StartActivity(login_try);
                Finish();
            }
            else
            {
                user user = new user();
                user.get_from_cloud(user_id, login_hash);

                GetImageBitmapFromUrl("https://carshareserver.azurewebsites.net/api/getUserImage?user_id=" + user.id);
                void DownloadDataCompleted(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.imageView1);
                        if (imagen != null)
                        {
                            imagen.SetImageBitmap(img1);
                            TextView username = FindViewById <TextView>(Resource.Id.userName1);
                            TextView email    = FindViewById <TextView>(Resource.Id.email1);
                            username.Text = user.first_name + " " + user.last_name;
                            email.Text    = user.email;
                        }
                    }
                }

                //fab

                FloatingActionButton fab = FindViewById <FloatingActionButton>(Resource.Id.fab);
                fab.Click += FabOnClick;

                //navigation menu

                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);
                navigationView.SetNavigationItemSelectedListener(this);

                async void GetImageBitmapFromUrl(string url)
                {
                    Bitmap img1 = null;

                    using (var webClient = new WebClient())
                    {
                        webClient.DownloadDataCompleted += DownloadDataCompleted;
                        webClient.DownloadDataAsync(new Uri(url));
                    }
                }
            }
        }
        public override void configViews()
        {
            BookDiscussionFragment fragment = BookDiscussionFragment.newInstance(mIsDiscussion ? "ramble" : "original");

            SupportFragmentManager.BeginTransaction().Replace(Resource.Id.fragmentCO, fragment).Commit();
        }
Exemple #30
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            //Set background flying object view

            var transaction = SupportFragmentManager.BeginTransaction();

            transaction.Add(Resource.Id.under_fragment, new FlyingObjectsFragment());
            //transaction.Add(Resource.Id.center_fragment, new BlurViewFragment());
            transaction.Commit();



            SetContentView(Resource.Layout.instructionscreen);

            aboutslinkapp     = FindViewById <TextView>(Resource.Id.aboutslink);
            aboutslinkapp1    = FindViewById <TextView>(Resource.Id.aboutslinkinfo);
            slinkinstruction  = FindViewById <TextView>(Resource.Id.begin);
            TaptoshareTxtView = FindViewById <TextView>(Resource.Id.taptosharetextview);
            TextViewShare     = FindViewById <TextView>(Resource.Id.txtviewshare);
            //button = FindViewById<Button>(Resource.Id.btnStart);
            skipbtn       = FindViewById <Button>(Resource.Id.skip);
            Main_Relative = FindViewById <RelativeLayout>(Resource.Id.mainrelativelayout);
            myImage       = FindViewById <ImageView>(Resource.Id.imageview);

            FrontView2          = FindViewById <View>(Resource.Id.FrontView);
            ArrowImageIcon      = FindViewById <ImageView>(Resource.Id.arrowimg);
            SharedCardMobileImg = FindViewById <ImageView>(Resource.Id.sharecardimg);
            OutSideImageView    = FindViewById <ImageView>(Resource.Id.sharecardimg);
            LargerMobileimg     = FindViewById <ImageView>(Resource.Id.phoneimg);
            InsideImageView     = FindViewById <ImageView>(Resource.Id.inside_imageview);
            CircleRedImg        = FindViewById <ImageView>(Resource.Id.redcircleimg);
            ArrowImgView        = FindViewById <ImageView>(Resource.Id.arrowImgView);

            //geting id from InstructionscreenNext
            UserNameEdittext  = FrontView2.FindViewById <TextView>(Resource.Id.UserDisplayNameTextView);
            UserTitleEditText = FrontView2.FindViewById <TextView>(Resource.Id.TitleTextField);
            MainRelativeView  = FrontView2.FindViewById <RelativeLayout>(Resource.Id.main_layout);
            UserIconImage     = FrontView2.FindViewById <ImageView>(Resource.Id.HeaderImageView);
            Contect           = FrontView2.FindViewById <ImageView>(Resource.Id.contect);
            Facebook          = FrontView2.FindViewById <ImageView>(Resource.Id.facebook);
            Instagram         = FrontView2.FindViewById <ImageView>(Resource.Id.instagram);
            Linkedin          = FrontView2.FindViewById <ImageView>(Resource.Id.linkedin);
            CardName          = FrontView2.FindViewById <TextView>(Resource.Id.newcard);
            OutLet            = FrontView2.FindViewById <TextView>(Resource.Id.outlet);


            //Animation for rotating logoicon and  fade text
            rotateAboutCornerAnimation = AnimationUtils.LoadAnimation(this, Resource.Animator.hyperspace);
            fadeintext      = AnimationUtils.LoadAnimation(this, Resource.Animator.fadeout);
            fadeouttext     = AnimationUtils.LoadAnimation(this, Resource.Animator.fadein);
            Arrowanimation  = AnimationUtils.LoadAnimation(this, Resource.Animator.arrowanimate);
            MobileAnimation = AnimationUtils.LoadAnimation(this, Resource.Animator.moveMobileImg);
            MoveCircle      = AnimationUtils.LoadAnimation(this, Resource.Animator.moveRedCircle);

            skipbtn.Click += delegate
            {
                //go to main activity when click skip button
                StartActivity(typeof(MainActivity));
                //Intent intent = new Intent(this, typeof(BlurViewActivity));
                //StartActivity(intent);
            };


            AnimationSetAsync();

            //setting card name
        }