Пример #1
0
        /// <summary>
        /// Alert dialog initializer. Shows during app load data from API
        /// </summary>
        private void AlertDialogWhenDataLoading()
        {
            LayoutInflater layoutInflater = LayoutInflater.From(this);
            View           mview          = layoutInflater.Inflate(Resource.Layout._alertDialogLoading, null);

            Android.App.AlertDialog.Builder alertDialogBuilder = new Android.App.AlertDialog.Builder(this);
            alertDialogBuilder.SetView(mview);
            Android.App.AlertDialog alertDialogAndroid = alertDialogBuilder.Create();
            alertDialogAndroid.SetCancelable(false);
            alertDialogAndroid.Show();
        }
Пример #2
0
        public override bool OnCreateOptionsMenu(IMenu menu)
        {
            MenuInflater.Inflate(Resource.Menu.bottom_menu, menu);

            var searchItem = menu.FindItem(Resource.Id.search);

            var searchView  = MenuItemCompat.GetActionView(searchItem);
            var _searchView = searchView.JavaCast <Android.Support.V7.Widget.SearchView>();

            _searchView.QueryHint = "Pretrazi prijatelja..";

            _searchView.QueryTextChange += (s, e) =>
            {
                if (e.NewText.Equals(String.Empty))
                {
                    tabLayout.Visibility      = ViewStates.Visible;
                    viewPager.Visibility      = ViewStates.Visible;
                    listView.Adapter          = null;
                    layoutPretrage.Visibility = ViewStates.Gone;
                }
                else
                {
                    tabLayout.Visibility      = ViewStates.Gone;
                    viewPager.Visibility      = ViewStates.Gone;
                    layoutPretrage.Visibility = ViewStates.Visible;
                }
            };

            _searchView.QueryTextSubmit += (s, e) =>
            {
                _searchView.ClearFocus();

                alert = new Android.App.AlertDialog.Builder(this).Create();
                alert.SetTitle("Vrsi se pretraga!");
                alert.SetMessage("Molimo sacekajte!");
                alert.SetCancelable(false);

                alert.Show();

                alertGreska = new Android.App.AlertDialog.Builder(this).Create();
                alertGreska.SetTitle("Pretraga neuspesna!");
                alertGreska.SetMessage("Nije pronadjeno nijedno poklapanje sa: " + e.Query);
                alertGreska.SetButton("U redu", delegate(object sender, DialogClickEventArgs args) { alert.Dismiss(); });

                Thread novaNit = new Thread(() => FuncijaZaNoviNit(e.Query));
                novaNit.Start();

                e.Handled = true;
            };

            return(true);
        }
Пример #3
0
 /// <summary>
 /// 申请理由对话框
 /// </summary>
 private void ShowRationalDialog(string[] permissions)
 {
     lock (this)
     {
         AlertDialog alertDialog = (new AlertDialog.Builder(mActivity))
                                   .SetMessage(mOptions.RationalMessage)
                                   .SetPositiveButton(mOptions.RationalBtnText, (s, e) => RequestPermissions(permissions))
                                   .Create();
         alertDialog.SetCancelable(mOptions.DialogCancelable);
         alertDialog.SetCanceledOnTouchOutside(mOptions.DialogCanceledOnTouchOutside);
         alertDialog.Show();
     }
 }
Пример #4
0
        private void CallAlert()
        {
            var layoutInflater     = LayoutInflater.From(this);
            var mview              = layoutInflater.Inflate(Resource.Layout._alertRateAppDialog, null);
            var alertDialogBuilder = new Android.App.AlertDialog.Builder(this);

            alertDialogBuilder.SetView(mview);
            alertDialogAndroid = alertDialogBuilder.Create();
            alertDialogAndroid.Show();
            alertDialogAndroid.SetCanceledOnTouchOutside(false);
            alertDialogAndroid.SetCancelable(false);
            var rateButtonYes = mview.FindViewById <Button>(Resource.Id.buttonYes);
            var rateButtonNo  = mview.FindViewById <Button>(Resource.Id.buttonNo);

            rateButtonNo.Click  += (s, e) => alertDialogAndroid.Dismiss();
            rateButtonYes.Click += RateButtonYes_Click;
        }
Пример #5
0
 /// <summary>
 /// 拒绝权限提示框
 /// </summary>
 private void ShowDeniedDialog(LinkedList <string> permissions)
 {
     lock (this)
     {
         AlertDialog alertDialog = (new AlertDialog.Builder(mActivity)).SetMessage(mOptions.DeniedMessage)
                                   .SetNegativeButton(mOptions.DeniedCloseBtn, (s, e) => {
             if (this.mCallback != null)
             {
                 this.mCallback.OnDenied(permissions);
             }
             this.OnDestroy();
         }).SetPositiveButton(mOptions.DeniedSettingBtn, (s, e) => this.StartSetting()).Create();
         alertDialog.SetCancelable(mOptions.DialogCancelable);
         alertDialog.SetCanceledOnTouchOutside(mOptions.DialogCanceledOnTouchOutside);
         alertDialog.Show();
     }
 }
Пример #6
0
 void DelegatDlaItemClick(AdapterView.ItemClickEventArgs e)
 {
     Tuple<string, string> item = lv.GetItemAtPosition(e.Position).Cast<Tuple<string, string>>();
     if (item.Item1 == nickname)
         return;
     ad = new AlertDialog.Builder(this).Create();
     ad.SetCancelable(false); // This blocks the 'BACK' button
     ad.SetMessage(string.Format("Czy chcesz zaprosiæ u¿ytkownika {0} do gry?", item.Item1));
     ad.SetButton("Nie", delegate
     {
     });
     ad.SetButton2("Tak", delegate
     {
         byte[] buff = new byte[MainActivity.MAX_LENGTH];
         buff = System.Text.Encoding.ASCII.GetBytes(string.Format("{0};{1}", Convert.ToInt32(MessageTypes.Invite), item.Item1));
         Sockets.client.GetStream().Write(buff, 0, buff.Length);
     });
     ad.Show();
 }
Пример #7
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            CrossCurrentActivity.Current.Activity = this;
            base.OnCreate(savedInstanceState);
            startServiceIntent = new Intent(this, typeof(TriTrackService));
            user_id            = Intent.GetIntExtra("user_id", 0);
            SetContentView(Resource.Layout.Map);
            daToolbar = FindViewById <SupportToolbar>(Resource.Id.toolbar);
            SetSupportActionBar(daToolbar);
            daLeftDrawer = FindViewById <ListView>(Resource.Id.left_drawer);


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

            drawerOptions = new List <string>();
            drawerOptions.Add("Home");
            drawerOptions.Add("History");
            drawerOptions.Add("Log Out");
            drawerOptionsAdapter    = new ArrayAdapter <string>(this, Android.Resource.Layout.SimpleListItem1, drawerOptions);
            daLeftDrawer.Adapter    = drawerOptionsAdapter;
            daLeftDrawer.ItemClick += DaLeftDrawer_ItemClick;

            daDrawerToggle = new MyActionBarDrawerToggle(
                this,
                daDrawerLayout,
                Resource.String.openDrawer,
                Resource.String.closeDrawer);
            SetSupportActionBar(daToolbar);
            daDrawerLayout.AddDrawerListener(daDrawerToggle);
            SupportActionBar.SetHomeButtonEnabled(true);
            SupportActionBar.SetDisplayHomeAsUpEnabled(true);
            daDrawerToggle.SyncState();
            MapFragment mapFragment = (MapFragment)FragmentManager.FindFragmentById(Resource.Id.the_fucking_map);

            mapFragment.GetMapAsync(this);
            switchB         = FindViewById <Button>(Resource.Id.switch_button);
            switchB.Enabled = false;
            distanceText    = FindViewById <TextView>(Resource.Id.distance);
            WorkOutMode     = FindViewById <Switch>(Resource.Id.type);
            //latlonglist = FindViewById<TextView>(Resource.Id.LATLONG);
            getPos();
            switchB.Click += delegate
            {
                if (WorkoutInProgress == false)
                {
                    if (WorkOutMode.Checked == false)
                    {
                        workoutMode = "BIKE";
                    }
                    else
                    {
                        workoutMode = "RUN";
                    }
                    getPos();
                    switchB.SetBackgroundColor(Android.Graphics.Color.Red);
                    daMap.Clear();
                    polyline       = new PolylineOptions().InvokeWidth(20).InvokeColor(Color.Red.ToArgb());
                    sec            = 0;
                    min            = 0;
                    hour           = 0;
                    distance       = 0;
                    timer          = new Timer();
                    timer.Interval = 1000;
                    timer.Elapsed += Timer_Elapsed;
                    timer.Start();
                    TimerText         = FindViewById <TextView>(Resource.Id.timer_text);
                    TimerText.Text    = ("0:00:00");
                    WorkoutInProgress = true;
                    start.SetPosition(new LatLng(position.Latitude, position.Longitude));
                    start.SetTitle("Start");
                    daMap.AddMarker(start);
                    polyline.Add(new LatLng(position.Latitude, position.Longitude));
                    StartListening();
                    //LatLng latlng = new LatLng(position.Latitude, position.Longitude);
                    //CameraUpdate camera = CameraUpdateFactory.NewLatLngZoom(latlng, 15);
                    //daMap.MoveCamera(camera);
                    switchB.Text = "FINISH WORKOUT";
                }
                else if (WorkoutInProgress == true)
                {
                    // THIS GETS A STRING OF THE POLYLINE
                    //MAYBE STORE THIS A BLOB IN THE SQL DATABASE String.Join(":", polyline.Points);
                    switchB.SetBackgroundColor(Android.Graphics.Color.ParseColor("#219653"));
                    switchB.Enabled   = false;
                    switchB.Text      = "START NEW WORKOUT";
                    WorkoutInProgress = false;
                    timer.Stop();
                    finish.SetPosition(new LatLng(position.Latitude, position.Longitude));
                    finish.SetTitle("Finish");
                    daMap.AddMarker(finish);
                    StopListening();
                    Android.App.AlertDialog.Builder diaglog = new Android.App.AlertDialog.Builder(this);
                    Android.App.AlertDialog         alert   = diaglog.Create();
                    alert.SetCanceledOnTouchOutside(false);
                    alert.SetCancelable(false);
                    alert.SetTitle("Good Work");
                    alert.SetMessage("Your workout is complete, would you like to record it?");
                    alert.SetButton("Yes", (c, ev) => {
                        switchB.Enabled = true;
                        SubmitWorkoutToDatabase();
                        switchB.Text = "START NEW WORKOUT"; //TODO: SEND WORKOUT INFO TO THE DATABASE!
                        alert.Dismiss();                    //TODO: save polyine data to new table in the database.
                    });
                    alert.SetButton2("No", (c, ev) => {
                        switchB.Enabled = true;
                        daMap.Clear();
                        alert.Dismiss();
                        sec            = 0;
                        min            = 0;
                        hour           = 0;
                        distance       = 0;
                        TimerText.Text = ("0:00:00");
                        switchB.Text   = "START NEW WORKOUT";
                    });
                    alert.Show();
                }
            };
        }
Пример #8
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.Main);                          //sets the content view to the layout

            Button btnPlay   = FindViewById <Button>(Resource.Id.btnPlay); //connects the elements from the layout
            Button btnScores = FindViewById <Button>(Resource.Id.BtnScores);
            Button btnExit   = FindViewById <Button>(Resource.Id.btnExit);

            var db = new SQLiteConnection(dbPath2);                                      //opens a connection to SQLLite

            db.CreateTable <WordsListDatabase>();                                        // creates my table with empty fields

            var table = db.Table <WordsListDatabase>();                                  //connects to the table in the database

            if (table.Count() != 0)                                                      //do nothing if table already has words init
            {
                Toast.MakeText(this, "WORDS DATABASE EXISTS", ToastLength.Short).Show(); //toast message to check if database exists.
            }
            else if (table.Count() == 0)                                                 //add the records if the table is empty
            {
                Toast.MakeText(this, "WORDS DATABASE CREATED", ToastLength.Long).Show(); //toast message when table gets created

                WordsListDatabase word0  = new WordsListDatabase("FERMENT");             //creates an emtry in the table
                WordsListDatabase word1  = new WordsListDatabase("DISTINCTIVE");
                WordsListDatabase word2  = new WordsListDatabase("POTATOES");
                WordsListDatabase word3  = new WordsListDatabase("SMOKY");
                WordsListDatabase word4  = new WordsListDatabase("FRUITY");
                WordsListDatabase word5  = new WordsListDatabase("GRAVY");
                WordsListDatabase word6  = new WordsListDatabase("MATURED");
                WordsListDatabase word7  = new WordsListDatabase("SWEET");
                WordsListDatabase word8  = new WordsListDatabase("SAUSAGE");
                WordsListDatabase word9  = new WordsListDatabase("NUTRITIOUS");
                WordsListDatabase word10 = new WordsListDatabase("CABBAGE");
                WordsListDatabase word11 = new WordsListDatabase("AEDJVLDS");
                WordsListDatabase word12 = new WordsListDatabase("JOKES");
                WordsListDatabase word13 = new WordsListDatabase("REPUTATION");
                WordsListDatabase word14 = new WordsListDatabase("SERVED");
                WordsListDatabase word15 = new WordsListDatabase("POISON");
                WordsListDatabase word16 = new WordsListDatabase("WHISKEY");
                WordsListDatabase word17 = new WordsListDatabase("RAW");
                WordsListDatabase word18 = new WordsListDatabase("POISON");
                WordsListDatabase word19 = new WordsListDatabase("CRUST");
                WordsListDatabase word20 = new WordsListDatabase("TRUST");
                WordsListDatabase word21 = new WordsListDatabase("CULINARY");
                WordsListDatabase word22 = new WordsListDatabase("FRIED");
                WordsListDatabase word23 = new WordsListDatabase("CHEESE");
                WordsListDatabase word24 = new WordsListDatabase("MIXED");

                db.Insert(word0); db.Insert(word1); db.Insert(word2); db.Insert(word3); db.Insert(word4); //inserts the emtry into the table
                db.Insert(word5); db.Insert(word6); db.Insert(word7); db.Insert(word8); db.Insert(word9);
                db.Insert(word10); db.Insert(word11); db.Insert(word12); db.Insert(word13); db.Insert(word14);
                db.Insert(word15); db.Insert(word16); db.Insert(word17); db.Insert(word18); db.Insert(word19);
                db.Insert(word20); db.Insert(word21); db.Insert(word22); db.Insert(word23); db.Insert(word24);
            }

            btnPlay.Click += delegate
            {
                StartActivity(typeof(PlayerActivity));

                var db2 = new SQLiteConnection(dbPath); //connection for the sqllite database
                db2.CreateTable <PlayerDatabase>();     //creates table from the class file
            };

            btnScores.Click += delegate
            {
                StartActivity(typeof(ScoresActivity));  //starts defined activity

                var db2 = new SQLiteConnection(dbPath); //connection for the sqllite database
                db2.CreateTable <PlayerDatabase>();     //creates table from the class file
            };

            btnExit.Click += delegate
            {
                Android.App.AlertDialog.Builder dialog = new Android.App.AlertDialog.Builder(this, Android.App.AlertDialog.ThemeHoloDark);
                Android.App.AlertDialog         alert  = dialog.Create();
                alert.SetCancelable(false);
                alert.SetTitle("EXIT GAME");
                alert.SetMessage("Are You Sure?");

                alert.SetButton("YES", (c, ev) =>
                {
                    Process.KillProcess(Process.MyPid());
                });
                alert.SetButton2("NO", (c, ev) =>
                {
                    alert.Cancel();
                });
                alert.Show();
            };
        }
Пример #9
0
		protected override Dialog OnCreateDialog (int id, Bundle args)
		{
			AlertDialog.Builder builder;
			builder = new AlertDialog.Builder (this);
			builder.SetInverseBackgroundForced (true);
			switch (id) {
			case 1:
				{
					builder.SetTitle (GetString(Resource.String.gps_request));
					builder.SetPositiveButton (GetString(Resource.String.gps_enable), EnableClicked);
					builder.SetNegativeButton (GetString(Resource.String.gps_cancel), CancelClicked);
					dialog = builder.Create ();
					break;
				}
			}

			if (dialog != null) {
				dialog.SetCanceledOnTouchOutside (false);
				dialog.SetCancelable (false);
			}
			return dialog;
		}
Пример #10
0
        protected override async void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            //Set your main view here
            SetContentView(Resource.Layout.main);
            dbPath   = Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), "SessionDB.db");
            mContext = Android.App.Application.Context;
            ap       = new AppPreferences(mContext);
            if (session_count < 1)
            {
                LayoutInflater layoutInflater = LayoutInflater.From(this);
                View           mView          = layoutInflater.Inflate(Resource.Layout.ProgressLayout, null);
                Android.Support.V7.App.AlertDialog.Builder alertProgress = new Android.Support.V7.App.AlertDialog.Builder(this);
                alertProgress.SetView(mView).SetCancelable(false);
                var       alert     = alertProgress.Show();
                Stopwatch stopWatch = new Stopwatch();
                stopWatch.Start();
                while (session_count < 1)
                {
                    stopWatch.Stop();
                    if (stopWatch.ElapsedMilliseconds >= 10000)
                    {
                        mView.FindViewById <TextView>(Resource.Id.displayLoading).Text = "Please Check the Internet Connection";
                    }
                    else
                    {
                        stopWatch.Start();
                    }

                    await fetchData();
                }
                alert.Dismiss();
            }


            if (ap.getValue("name") == "" && ap.getValue("mobilenumber") == "")
            {
                LayoutInflater layoutInflater = LayoutInflater.From(this);
                View           mView          = layoutInflater.Inflate(Resource.Layout.user_pref, null);
                Button         buttonRegitser = mView.FindViewById <Button>(Resource.Id.buttonRegister);
                Android.Support.V7.App.AlertDialog.Builder alertDialogBuilder = new Android.Support.V7.App.AlertDialog.Builder(this);
                alertDialogBuilder.SetView(mView);
                alertDialogBuilder.SetCancelable(false);
                var alert = alertDialogBuilder.Show();
                buttonRegitser.Click += async delegate
                {
                    var username     = mView.FindViewById <TextView>(Resource.Id.editUsername).Text;
                    var mobilenumber = mView.FindViewById <TextView>(Resource.Id.editMobileNumber).Text;
                    try
                    {
                        if (username.Length >= 3 && mobilenumber.Length == 10 && Convert.ToDouble(mobilenumber) < 10000000000)
                        {
                            ap.saveValue("name", username);
                            ap.saveValue("mobilenumber", mobilenumber);
                            ap.saveValue("primaryKey", "1");
                            int index = Convert.ToInt32(ap.getValue("primaryKey"));
                            alert.Dismiss();
                            displayOTP(index);
                        }
                        else
                        {
                            Toast.MakeText(this, "Please enter a valid Name and MobileNumber.", ToastLength.Short).Show();
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine("Exception from MainActitvity in the Inputs " + ex);
                        Toast.MakeText(this, "Please enter a valid Name and MobileNumber", ToastLength.Short).Show();
                    }
                };
            }
            else
            {
                int index = Convert.ToInt32(ap.getValue("primaryKey"));
                Console.WriteLine("TEST ATTEMPTED :" + index);
                if (index <= session_count)
                {
                    displayOTP(index);
                }
                else
                {
                    Android.App.AlertDialog.Builder dialog = new Android.App.AlertDialog.Builder(this);
                    Android.App.AlertDialog         alert1 = dialog.Create();
                    alert1.SetTitle("Sessions Complete");
                    alert1.SetMessage("Thank You!");
                    alert1.SetIcon(Resource.Drawable.icon);
                    alert1.SetCancelable(false);
                    alert1.SetButton("EXIT", (c, ev) =>
                    {
                        MoveTaskToBack(true);
                        this.Finish();
                        this.FinishAffinity();
                    });
                    alert1.Show();
                }
            }
        }
Пример #11
0
        void MessageExecuteThread()
        {
            byte[] buffer;
            NetworkStream stream = Sockets.client.GetStream();

            while (Sockets.client.Connected)
            {
                if (thLock)
                    continue;

                if (isPlaying)
                {
                    buffer = System.Text.Encoding.ASCII.GetBytes(string.Format("{0};{1}", Convert.ToInt32(MessageTypes.ListRequestClient), nickname));
                    stream.Write(buffer, 0, buffer.Length);
                    isPlaying = false;
                }

                try
                {
                    buffer = new byte[MainActivity.MAX_LENGTH];
                    stream.Read(buffer, 0, buffer.Length);
                    string[] data = MessageParser.Split(buffer);
                    if (data.Length == 1)
                    {
                        Sockets.client.Close();
                        RunOnUiThread(delegate {
                            ad = new AlertDialog.Builder(this).Create();
                            ad.SetCancelable(false); // This blocks the 'BACK' button
                            ad.SetMessage("Nie mo¿na po³¹czyæ siê z serwerem. SprawdŸ po³¹czenie z internetem.");
                            ad.SetButton("OK", delegate
                            {
                                Android.OS.Process.KillProcess(Android.OS.Process.MyPid());
                            });
                            ad.Show();
                        });
                    }
                    switch (MessageParser.ToMessageType(data[0]))
                    {
                        case MessageTypes.SendPlayers:
                            ParsePlayerList(data[1]);
                            lv.Post(delegate { lv.Adapter = new PlayerListAdapter(this, this.data); });
                            break;
                        case MessageTypes.InviteClient:
                            if (data[1] == nickname)
                                break;
                            RunOnUiThread(delegate
                            {                                
                                ad = new AlertDialog.Builder(this).Create();
                                ad.SetCancelable(false); // This blocks the 'BACK' button
                                ad.SetMessage(string.Format("Masz zaproszenie do gry od {0}.", data[1]));                                
                                ad.SetButton("Odrzuæ", delegate 
                                {
                                    buffer = System.Text.Encoding.ASCII.GetBytes(string.Format("{0};{1}", Convert.ToInt32(MessageTypes.Decline), data[1]));
                                    stream.Write(buffer, 0, buffer.Length);
                                    czyOtwartyAlert = false;
                                });
                                ad.SetButton2("Akceptuj", delegate
                                {
                                    buffer = System.Text.Encoding.ASCII.GetBytes(string.Format("{0};{1}", Convert.ToInt32(MessageTypes.Accept), data[1]));
                                    stream.Write(buffer, 0, buffer.Length);
                                    czyOtwartyAlert = false;
                                });
                                ad.Show();
                            });
                            czyOtwartyAlert = true;
                            while (czyOtwartyAlert)
                                continue;
                            Thread.Sleep(100);
                            break;
                        case MessageTypes.StartClient:
                            RunOnUiThread(delegate
                            {
                                Intent intent = new Intent(this, typeof(GameActivity));
                                intent.PutExtra("Nickname", nickname);
                                intent.PutExtra("Data", data[1]);
                                StartActivity(intent);
                            });
                            thLock = true;
                            isPlaying = true;
                            break;
						case MessageTypes.PlayerIsBusy:
							RunOnUiThread(delegate {
								ad = new AlertDialog.Builder(this).Create();
								ad.SetCancelable(false); // This blocks the 'BACK' button
								ad.SetMessage(string.Format("Gracz {0} jest zajêty.", data[1]));
								ad.SetButton("Zamknij", delegate {});
								ad.Show();
							});
							break;
                    }
                }
                catch (System.Threading.ThreadAbortException e)
                {
                    return;
                }
                catch (Exception e)
                {
                    Sockets.client.Close();
                    RunOnUiThread(delegate {
                        ad = new AlertDialog.Builder(this).Create();
                        ad.SetCancelable(false); // This blocks the 'BACK' button
                        ad.SetMessage("Nie mo¿na po³¹czyæ siê z serwerem. SprawdŸ po³¹czenie z internetem.");
                        ad.SetButton("OK", delegate
                        {
                            Android.OS.Process.KillProcess(Android.OS.Process.MyPid());
                        });
                        ad.Show();
                    });
                }
            }
        }