Ejemplo n.º 1
0
        private void CreateNotificationChannel()
        {
            if (Build.VERSION.SdkInt >= BuildVersionCodes.O)
            {
                var notificationManager = NotificationManager.FromContext(this);

                if (notificationManager.NotificationChannels.Any(notificationChannel =>
                                                                 notificationChannel.Id == FeedUpdateChannel))
                {
                    return;
                }

                var name                    = new Java.Lang.String(GetString(Resource.String.Android_NotificationChannel_Name));
                var description             = GetString(Resource.String.Android_NotificationChannel_Description);
                NotificationChannel channel =
                    new NotificationChannel(FeedUpdateChannel, name, NotificationImportance.Default)
                {
                    Description = description
                };
                // Register the channel with the system; you can't change the importance
                // or other notification behaviors after this

                notificationManager.CreateNotificationChannel(channel);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Sends a command.
        /// </summary>
        /// <param name="cmd">
        /// The command to send
        /// </param>
        public void SendCommand(string cmd)
        {
            // adds the carriage return character
            var message = new Java.Lang.String(cmd + "\r");

            SendMessage(message);
        }
        public override ICharSequence GetPageTitleFormatted(int position)
        {
            Java.Lang.String title = new Java.Lang.String("");
            SituationView    view  = (SituationView)position;

            switch (view)
            {
            case SituationView.SituationWhat:
                title = new Java.Lang.String("1. What is the Situation");
                break;

            case SituationView.SituationWho:
                title = new Java.Lang.String("2. Who were you with");
                break;

            case SituationView.SituationWhere:
                title = new Java.Lang.String("3. Where were you");
                break;

            case SituationView.SituationWhen:
                title = new Java.Lang.String("4. When did it happen");
                break;

            default:
                break;
            }

            return(title);
        }
Ejemplo n.º 4
0
            protected override Filter.FilterResults PerformFiltering(Java.Lang.ICharSequence constraint)
            {
                FilterResults results = new FilterResults();

                if (constraint != null)
                {
                    var searchFor = constraint.ToString();
                    Console.WriteLine("searchFor:" + searchFor);
                    var matchList = new List <string>();

                    if (list.Contains(searchFor))
                    {
                    }
                    Console.WriteLine("resultCount:" + matchList.Count);

                    Java.Lang.Object[] matchObjects;
                    matchObjects = new Java.Lang.Object[matchList.Count];
                    for (int i = 0; i < matchList.Count; i++)
                    {
                        matchObjects[i] = new Java.Lang.String(matchList[i]);
                    }

                    results.Values = matchObjects;
                    results.Count  = matchList.Count;
                }
                return(results);
            }
Ejemplo n.º 5
0
        private void DisplayItems_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            if (e.Action == NotifyCollectionChangedAction.Reset && this.dataSource.SortDescriptors.Count > 0 && this.dataSource.SortDescriptors[0].Direction == Syncfusion.DataSource.ListSortDirection.Descending)
            {
                if (decendingAlphaIndex == null)
                {
                    decendingAlphaIndex = new Dictionary <string, int>();
                    for (int i = 0; i < this.Count; i++)
                    {
                        var key = (this[i] as Contacts).ContactName[0].ToString();
                        if (!decendingAlphaIndex.ContainsKey(key))
                        {
                            decendingAlphaIndex.Add(key, i);
                        }
                    }

                    decendingSection = new string[decendingAlphaIndex.Keys.Count];
                    decendingAlphaIndex.Keys.CopyTo(decendingSection, 0);
                    decendingSectionsObjects = new Java.Lang.Object[decendingSection.Length];
                    for (int i = 0; i < sections.Length; i++)
                    {
                        decendingSectionsObjects[i] = new Java.Lang.String(decendingSection[i]);
                    }
                }
            }

            this.NotifyDataSetChanged();
        }
Ejemplo n.º 6
0
        public PhoneContactAdapter(Activity activity, List <PhoneContactModel> _chat)
        {
            this.context = activity;
            _items       = _chat.ToList();
            Filter       = new PhoneContactFilter(this);


            alphaIndex = new Dictionary <string, int>();
            for (int i = 0; i < _items.Count; i++)
            {
                var key = _items[i].name.ToString().Substring(0, 1);
                if (!alphaIndex.ContainsKey(key))
                {
                    alphaIndex.Add(key, i);
                }
            }

            sections = new string[alphaIndex.Keys.Count];
            alphaIndex.Keys.CopyTo(sections, 0);
            sectionsObjects = new Java.Lang.Object[sections.Length];
            for (int i = 0; i < sections.Length; i++)
            {
                sectionsObjects[i] = new Java.Lang.String(sections[i]);
            }
        }
Ejemplo n.º 7
0
        private static void verifyPayment(Payment payment)
        {
            string     resultString = "".ToString();
            JSONObject jsonObject   = new JSONObject();

            jsonObject.Put("payload", payment.Payload);

            string verifystring = (string)jsonObject;
            Dictionary <string, string> headers = new Dictionary <string, string>();

            headers.Add("Content-Type", "application/json; charset=UTF-8");
            headers.Add(merchantApiHeaderKeyForApiSecretKey, merchantApiSecretKey);
            //
            AsyncHttpClient.Post(merchantServerUrl + VERIFY, headers, verifystring, new HttpResponseCallback
            {
                Success = (response) =>
                {
                    Java.Lang.String mString      = new Java.Lang.String(response, Charset.ForName("UTF-8"));
                    JSONObject jsonVerifyResponse = new JSONObject((string)mString);
                    Java.Lang.String authResponse = new Java.Lang.String(jsonVerifyResponse.GetString("authResponse"));
                    if (authResponse.EqualsIgnoreCase(payment.GetPaymentStatus().ToString()))
                    {
                        resultString = "Payment is " + payment.GetPaymentStatus().ToString().ToLower() + " and verified.";
                    }
                    else
                    {
                        resultString = "Failed to verify payment.";
                    }
                },
                Failure = (th) =>
                {
                    Toast.MakeText(context, resultString, ToastLength.Long).Show();
                }
            });
        }
Ejemplo n.º 8
0
 public void AddBitmapToMemoryCache(Java.Lang.String key, Bitmap bitmap)
 {
     if (bitmap != null && GetBitmapFromMemCache(key) == null)
     {
         _memoryCache.Put(key, bitmap);
     }
 }
Ejemplo n.º 9
0
 public void SetValue(Java.Lang.String value)
 {
     returnValue = value.ToString();
     try { latch.CountDown(); } catch (System.Exception ex) {
         DLogger.WriteLog(ex);
     }
 }
Ejemplo n.º 10
0
        public void ExecuteBadge(Context context, ComponentName componentName, int badgeCount)
        {
            try
            {
                var miuiNotificationClass = Class.ForName("android.app.MiuiNotification");
                var miuiNotification      = miuiNotificationClass.NewInstance();
                var field = miuiNotificationClass.GetDeclaredField("messageCount");
                field.Accessible = true;

                try
                {
                    field.Set(miuiNotification, String.ValueOf(badgeCount == 0 ? "" : badgeCount.ToString()));
                }
                catch (Exception)
                {
                    field.Set(miuiNotification, badgeCount);
                }
            }
            catch (Exception)
            {
                var localIntent = new Intent(IntentAction);
                localIntent.PutExtra(ExtraUpdateAppComponentName, $"{componentName.PackageName}/{componentName.ClassName}");
                localIntent.PutExtra(ExtraUpdateAppMsgText, String.ValueOf(badgeCount == 0 ? "" : badgeCount.ToString()));

                if (BroadcastHelper.CanResolveBroadcast(context, localIntent))
                {
                    context.SendBroadcast(localIntent);
                }
            }

            if (Build.Manufacturer.Equals("Xiaomi", StringComparison.CurrentCultureIgnoreCase))
            {
                TryNewMiuiBadge(context, badgeCount);
            }
        }
Ejemplo n.º 11
0
        public override ICharSequence GetPageTitleFormatted(int position)
        {
            var           tittle = mFragmentTitleList[position];
            ICharSequence derp   = new Java.Lang.String(tittle);

            return(derp);
        }
Ejemplo n.º 12
0
            public override IEditable Replace(int start, int end, ICharSequence tb, int tbstart, int tbend)
            {
                // Create a copy of this string builder to preview the change, allowing the TextBox's event handlers to act on the modified text.
                var copy = new SpannableStringBuilder(this);

                copy.Replace(start, end, tb, tbstart, tbend);
                var previewText = copy.ToString();

                var finalText = Owner.ProcessTextInput(previewText);

                if (Owner._wasLastEditModified = previewText != finalText)
                {
                    // Text was modified. Use new text as the replacement string, re-applying spans to ensure EditText's and keyboard's internals aren't disrupted.
                    ICharSequence replacement;
                    if (tb is ISpanned spanned)
                    {
                        var spannable = new SpannableString(finalText);
                        TextUtils.CopySpansFrom(spanned, tbstart, Min(tbend, spannable.Length()), null, spannable, 0);
                        replacement = spannable;
                    }
                    else
                    {
                        replacement = new Java.Lang.String(finalText);
                    }

                    base.Replace(0, Length(), replacement, 0, finalText.Length);
                }
                else
                {
                    // Text was not modified, use original replacement ICharSequence
                    base.Replace(start, end, tb, tbstart, tbend);
                }

                return(this);
            }
        public View GetHeaderView(int position, View convertView, ViewGroup parent)
        {
            HeaderViewHolder holder;

            if (convertView == null)
            {
                convertView     = mInflater.Inflate(mHeaderResId, parent, false);
                holder          = new HeaderViewHolder();
                holder.textView = (TextView)convertView.FindViewById(Android.Resource.Id.Text1);
                convertView.Tag = holder;
            }
            else
            {
                holder = (HeaderViewHolder)convertView.Tag;
            }

            T             item = this[position];
            ICharSequence s;

            if (item is CharSequence)
            {
                s = (ICharSequence)item;
            }
            else
            {
                s = new Java.Lang.String(item.ToString());
            }

            // set header text as first char in string
            holder.textView.SetText(s.SubSequence(0, 1), TextView.BufferType.Normal);

            return(convertView);
        }
Ejemplo n.º 14
0
            public override ICharSequence GetPageTitleFormatted(int position)
            {
                ICharSequence cs;

                cs = new Java.Lang.String(titles[position]);
                return(cs);
            }
Ejemplo n.º 15
0
        Java.Lang.Object[] sectionsObjects; // array of objects to store  // need java.lang.objects for indexing !!

        public MyCustomAdapter(Activity activity, List <string> items)
        {
            this.activity = activity;
            this.items    = items;

            // dictionary
            alphaIndex = new Dictionary <string, int>();
            for (int i = 0; i < items.Count; i++)
            {
                var key = items[i][0].ToString(); // pulls out the 1st character[0] in items
                if (!alphaIndex.ContainsKey(key)) // if index doesn't already contain 'key' then add it
                {
                    alphaIndex.Add(key, i);
                }
            }
            // sections - array of keys
            sections = new string[alphaIndex.Keys.Count];   // number of sections
            alphaIndex.Keys.CopyTo(sections, 0);            // copy to sections at index 0
            sectionsObjects = new Java.Lang.Object[sections.Length];


            // sections objects (add)
            for (int i = 0; i < sections.Length; i++)
            {
                sectionsObjects[i] = new Java.Lang.String(sections[i]);
            }
        }
Ejemplo n.º 16
0
            protected override FilterResults PerformFiltering(ICharSequence constraint)
            {
                FilterResults results = new FilterResults();

                if (!System.String.IsNullOrEmpty(constraint.ToString()))
                {
                    FilterdList = Adapter.nameList.Where(a => a.ToLower().Contains(constraint.ToString().ToLower())).ToList();

                    Adapter.MatchNames = FilterdList.ToArray();

                    Object[] matchObjects = new Object[FilterdList.Count];
                    for (int i = 0; i < FilterdList.Count; i++)
                    {
                        matchObjects[i] = new String(FilterdList[i]);
                    }

                    results.Values = matchObjects;
                    results.Count  = FilterdList.Count;
                }
                else
                {
                    Adapter.ResetSearch();
                }

                return(results);
            }
Ejemplo n.º 17
0
        public override ICharSequence GetPageTitleFormatted(int position)
        {
            Java.Lang.String title = new Java.Lang.String("");
            SituationView    view  = (SituationView)position;

            switch (view)
            {
            case SituationView.SituationWhat:
                title = new Java.Lang.String(((Activity)_context).GetString(Resource.String.situationQuestion1));
                break;

            case SituationView.SituationWho:
                title = new Java.Lang.String(((Activity)_context).GetString(Resource.String.situationQuestion2));
                break;

            case SituationView.SituationWhere:
                title = new Java.Lang.String(((Activity)_context).GetString(Resource.String.situationQuestion3));
                break;

            case SituationView.SituationWhen:
                title = new Java.Lang.String(((Activity)_context).GetString(Resource.String.situationQuestion4));
                break;

            default:
                break;
            }

            return(title);
        }
Ejemplo n.º 18
0
            protected override Filter.FilterResults PerformFiltering(Java.Lang.ICharSequence constraint)
            {
                FilterResults results = new FilterResults();

                if (constraint != null)
                {
                    var searchFor = constraint.ToString().ToLower();
                    //Console.System.Diagnostics.Debug.WriteLine("searchFor:" + searchFor);
                    // var matchList = new List<TruckModel>();
                    // find matches, IndexOf means look for the input anywhere in the items
                    // but it isn't case-sensitive by default!
                    var matches = from i in customAdapter._list where i.PR.ToLower().Contains(searchFor) select i;
                    //foreach (var match in matches) {
                    //matchList.Add (match);
                    //}
                    customAdapter._list = matches.ToList();
                    // Console.System.Diagnostics.Debug.WriteLine("resultCount:" + customAdapter.MatchItems.Count);
                    // not sure if the Java array/FilterResults are used
                    Java.Lang.Object[] matchObjects;
                    matchObjects = new Java.Lang.Object[customAdapter._list.Count];
                    for (int i = 0; i < customAdapter._list.Count; i++)
                    {
                        matchObjects[i] = new Java.Lang.String(customAdapter._list[i].PR.ToLower());
                    }
                    results.Values = matchObjects;
                    results.Count  = customAdapter._list.Count;
                }
                return(results);
            }
Ejemplo n.º 19
0
        public void writeData(Java.Lang.String data)
        {
            //Extraemos el stream de salida
            try
            {
                outStream = btSocket.OutputStream;
            }
            catch (System.Exception e)
            {
                System.Console.WriteLine("Error al enviar" + e.Message);
            }

            //creamos el string que enviaremos
            Java.Lang.String message = data;

            //lo convertimos en bytes
            byte[] msgBuffer = message.GetBytes();

            try
            {
                //Escribimos en el buffer el arreglo que acabamos de generar
                outStream.Write(msgBuffer, 0, msgBuffer.Length);
            }
            catch (System.Exception e)
            {
                System.Console.WriteLine("Error al enviar" + e.Message);
            }
        }
Ejemplo n.º 20
0
            public override void Run()
            {
                byte[] btBuffer = new byte[1024]; // btBuffer store for the stream
                int    bytes;

                // Keep listening to the InputStream while connected
                while (!done)
                {
                    try
                    {
                        //Read from the stream
                        bytes = btInStream.Read(btBuffer, 0, btBuffer.Length);
                        string readMessage = "" + bytes;

                        Java.Lang.String rMessage = new Java.Lang.String(btBuffer, 0, bytes);
                        readMessage = (string)rMessage;

                        if (readMessage != null)
                        {
                            RecieverThread rct = new RecieverThread(readMessage);
                            rct.Start();
                        }


                        //Send the message to the ui
                        btHandler.ObtainMessage(Constants.MESSAGE_READ, bytes, -1, btBuffer).SendToTarget();

                        /*
                         * BufferedReader br = null;
                         * StringBuilder sb = new StringBuilder();
                         *
                         * String line;
                         * try {
                         *
                         * br = new BufferedReader(new InputStreamReader(in));
                         *
                         * while ((line = br.readLine()) != null) {
                         *  sb.append(line);
                         * }
                         *
                         * } catch (IOException e) {
                         * e.printStackTrace();
                         * } finally {
                         * if (br != null) {
                         *  try {
                         *      br.close();
                         *  } catch (IOException e) {
                         *      e.printStackTrace();
                         *  }
                         * }
                         * }*/
                    }
                    catch (Java.IO.IOException e)
                    {
                        e.PrintStackTrace();
                        break;
                    }
                }
            }
Ejemplo n.º 21
0
        private static SpannableString GetTextWithImages(Context context, Java.Lang.String text)
        {
            SpannableString spannable = new SpannableString(text);

            //Spann spannable = spannableFactory.NewSpannable(text);
            AddImages(context, spannable);
            return(spannable);
        }
Ejemplo n.º 22
0
        public override ICharSequence GetPageTitleFormatted(int position)
        {
            var fragment = fragments[position];

            ICharSequence charSeq = new Java.Lang.String(fragment.Title);

            return(charSeq);
        }
Ejemplo n.º 23
0
            public override void OnSuccess(Java.Lang.String p0)
            {
                m_context.FindViewById(Resource.Id.wait_view).Visibility  = Android.Views.ViewStates.Gone;
                m_context.FindViewById(Resource.Id.login_form).Visibility = Android.Views.ViewStates.Visible;
                Intent intent = new Intent(m_context, typeof(HomeActivity));

                m_context.StartActivity(intent);
                m_context.Finish();
            }
 public VideoDetailsPagerAdapter(FragmentManager fm, List <Fragment> fragments, string[] titlesList) : base(fm)
 {
     this.fragments = fragments;
     for (int i = 0; i < titlesList.Length; i++)
     {
         titles[i] = new Java.Lang.String(titlesList[i]);
     }
     //this.titles = titlesList;
 }
Ejemplo n.º 25
0
            public override void HandleMessage(Message msg)
            {
                switch (msg.What)
                {
                case MESSAGE_STATE_CHANGE:
                    if (Debug)
                    {
                        Log.Info(TAG, "MESSAGE_STATE_CHANGE: " + msg.Arg1);
                    }
                    switch (msg.Arg1)
                    {
                    case BluetoothChatService.STATE_CONNECTED:
                        Log.Info(TAG, "MESSAGE_STATE_CHANGE: STATE_CONNECTED");
                        bluetoothChat.conversationArrayAdapter.Clear();
                        //bluetoothChat.conversationArrayAdapter.Clear ();
                        break;

                    case BluetoothChatService.STATE_CONNECTING:
                        Log.Info(TAG, "MESSAGE_STATE_CHANGE: STATE_CONNECTING");
                        break;

                    case BluetoothChatService.STATE_LISTEN:
                    case BluetoothChatService.STATE_NONE:
                        Log.Info(TAG, "MESSAGE_STATE_CHANGE: STATE_LISTEN/None");
                        break;
                    }
                    break;

                case MESSAGE_WRITE:
                    byte[] writeBuf = (byte[])msg.Obj;
                    // construct a string from the buffer
                    var writeMessage = new Java.Lang.String(writeBuf);
                    bluetoothChat.conversationArrayAdapter.Add("Me: " + writeMessage);
                    //bluetoothChat.conversationArrayAdapter.Add ("Me: " + writeMessage);
                    break;

                case MESSAGE_READ:
                    byte[] readBuf = (byte[])msg.Obj;
                    // construct a string from the valid bytes in the buffer
                    var readMessage = new Java.Lang.String(readBuf, 0, msg.Arg1);
                    bluetoothChat.conversationArrayAdapter.Add(bluetoothChat.connectedDeviceName + ":  " + readMessage);
                    //*********sendback to card...........
                    //bluetoothChat.conversationArrayAdapter.Add (bluetoothChat.connectedDeviceName + ":  " + readMessage);
                    break;

                case MESSAGE_DEVICE_NAME:
                    // save the connected device's name
                    bluetoothChat.connectedDeviceName = msg.Data.GetString(DEVICE_NAME);
                    Toast.MakeText(Application.Context, "Connected to " + bluetoothChat.connectedDeviceName, ToastLength.Short).Show();
                    break;

                case MESSAGE_TOAST:
                    Toast.MakeText(Application.Context, msg.Data.GetString(TOAST), ToastLength.Short).Show();
                    break;
                }
            }
Ejemplo n.º 26
0
            public override void HandleMessage(Message msg)
            {
                switch (msg.What)
                {
                /* Messages from OBDConnectionServices */
                case MESSAGE_STATE_CHANGE:
                    switch (msg.Arg1)
                    {
                    case OBDConnectionService.STATE_CONNECTED:
                        //here you should indicate the state change in some way...
                        OBDConnection.conversationArrayAdapter.Clear();
                        break;

                    case OBDConnectionService.STATE_CONNECTING:
                        break;

                    case OBDConnectionService.STATE_LISTEN:
                    case OBDConnectionService.STATE_NONE:
                        break;
                    }
                    break;

                case MESSAGE_WRITE:
                    byte[] writeBuf = (byte[])msg.Obj;
                    //here you can show the message you send
                    // construct a string from the buffer
                    var writeMessage = new Java.Lang.String(writeBuf);
                    //OBDConnection.conversationArrayAdapter.Add("Me: " + writeMessage);
                    break;

                case MESSAGE_READ:
                    OBDConnection.readBuf   = (byte[])msg.Obj;
                    OBDConnection.lenghtBuf = msg.Arg1;
                    // here you can show the message you receive
                    // construct a string from the valid bytes in the buffer
                    var readMessage = new Java.Lang.String(OBDConnection.readBuf, 0, msg.Arg1);
                    OBDConnection.conversationArrayAdapter.Add(OBDConnection.connectedDeviceName + ":  " + readMessage);
                    break;

                case MESSAGE_DEVICE_NAME:
                    // save the connected device's name
                    OBDConnection.connectedDeviceName = msg.Data.GetString(DEVICE_NAME);
                    Toast.MakeText(Application.Context, "Connected to " + OBDConnection.connectedDeviceName, ToastLength.Short).Show();
                    break;

                case MESSAGE_TOAST:
                    Toast.MakeText(Application.Context, msg.Data.GetString(TOAST), ToastLength.Short).Show();
                    break;

                /* Messages from timer delegate */
                case TIMER_TIMEFLOW_RAISED:
                    OBDConnection.time_sec++;
                    OBDConnection.conversationArrayAdapter.Add(OBDConnection.time_sec);
                    break;
                }
            }
Ejemplo n.º 27
0
        /** Needed for the Digest Access Authentication. */
        private System.String computeMd5Hash(Java.Lang.String buffer)
        {
            MessageDigest md;

            try {
                md = MessageDigest.GetInstance("MD5");
                return(bytesToHex(md.Digest(buffer.GetBytes("UTF-8"))));
            } catch (NoSuchAlgorithmException ignore) {
            } catch (UnsupportedEncodingException e) {}
            return("");
        }
Ejemplo n.º 28
0
        private void BuildSectionIndex()
        {
            int i = 0;

            sectionsObjects = new Java.Lang.Object[tides.Count];
            foreach (Tides tide in tides)
            {
                secIndex.Add(CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(tide.Index));
                sectionsObjects[i++] = new Java.Lang.String(CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(tide.Index));
            }
        }
Ejemplo n.º 29
0
		async Task SearchWithStringAsync (ICharSequence constraint)
		{
			var searchString = constraint?.ToString ();

			if (searchString == null) {
				LocationResults = new List<WuAcLocation> ();
				ResultStrings = new List<SpannableString> ();
				return;
			}

			bool canceled = false;

			try {

				ResultStrings = new List<SpannableString> ();

				if (!string.IsNullOrWhiteSpace (searchString)) {

					LocationResults = await WuAcClient.GetAsync (searchString);

					Java.Lang.Object [] matchObjects = new Java.Lang.Object [LocationResults.Count];

					for (int i = 0; i < LocationResults.Count; i++) {

						var name = LocationResults [i].name;

						ResultStrings.Add (name.GetSearchResultSpannableString (searchString));

						matchObjects [i] = new Java.Lang.String (name);
					}

					filterResults.Values = matchObjects;
					filterResults.Count = LocationResults.Count;

				} else {

					LocationResults = new List<WuAcLocation> ();
				}

			} catch (System.Exception ex) {

				System.Diagnostics.Debug.WriteLine (ex.Message);

				canceled = true;

			} finally {

				if (!canceled) {
					publish = true;
					Activity.RunOnUiThread (() => PublishResults (constraint, filterResults));
				}
			}
		}
Ejemplo n.º 30
0
            public override void HandleMessage(Message msg)
            {
                switch (msg.What)
                {
                case MESSAGE_STATE_CHANGE:
                    if (Debug)
                    {
                        Log.Info(TAG, "MESSAGE_STATE_CHANGE: " + msg.Arg1);
                    }
                    switch (msg.Arg1)
                    {
                    case BluetoothActivityService.STATE_CONNECTED:
                        bluetoothActivity.title.SetText(Resource.String.title_connected_to);
                        bluetoothActivity.title.Append(bluetoothActivity.connectedDeviceName);
                        bluetoothActivity.conversationArrayAdapter.Clear();
                        break;

                    case BluetoothActivityService.STATE_CONNECTING:
                        bluetoothActivity.title.SetText(Resource.String.title_connecting);
                        break;

                    case BluetoothActivityService.STATE_LISTEN:
                    case BluetoothActivityService.STATE_NONE:
                        bluetoothActivity.title.SetText(Resource.String.title_not_connected);
                        break;
                    }
                    break;

                case MESSAGE_WRITE:
                    byte[] writeBuf = (byte[])msg.Obj;
                    // construct a string from the buffer
                    var writeMessage = new Java.Lang.String(writeBuf);
                    bluetoothActivity.conversationArrayAdapter.Add(">" + writeMessage);
                    break;

                case MESSAGE_READ:
                    byte[] readBuf = (byte[])msg.Obj;
                    // construct a string from the valid bytes in the buffer
                    var readMessage = new Java.Lang.String(readBuf, 0, msg.Arg1);
                    bluetoothActivity.conversationArrayAdapter.Add("<" + readMessage);
                    break;

                case MESSAGE_DEVICE_NAME:
                    // save the connected device's name
                    bluetoothActivity.connectedDeviceName = msg.Data.GetString(DEVICE_NAME);
                    Toast.MakeText(Application.Context, "Connected to " + bluetoothActivity.connectedDeviceName, ToastLength.Short).Show();
                    break;

                case MESSAGE_TOAST:
                    Toast.MakeText(Application.Context, msg.Data.GetString(TOAST), ToastLength.Short).Show();
                    break;
                }
            }
Ejemplo n.º 31
0
        public void Connect(string address)
        {
            if (address.Equals(""))
            {
                Toast.MakeText(this, "Direccion mac no encontrada, intentelo de nuevo.", ToastLength.Short).Show();
                StartActivity(typeof(MainActivity));
                Finish();
            }

            BluetoothDevice device = null;

            try
            {
                device = btAdapter.GetRemoteDevice(address);
                Console.WriteLine("Conexion en curso" + device);
            }
            catch (IllegalArgumentException e)
            {
                Console.WriteLine(e);
                Toast.MakeText(this, "La direccion mac " + address + " es incorrecta, intentelo de nuevo.", ToastLength.Short).Show();
                StartActivity(typeof(MainActivity));
                Finish();
            }

            // btAdapter.CancelDiscovery();
            try
            {
                btSocket = device.CreateRfcommSocketToServiceRecord(MY_UUID);
                btSocket.Connect();
                Toast.MakeText(this, "Conexion Correcta", ToastLength.Short).Show();

                dataToSend = new Java.Lang.String("Hola " + name);
                writeData(dataToSend);
            }
            catch (System.Exception e)
            {
                Console.WriteLine(e.Message);
                Toast.MakeText(this, "Error en la conexion", ToastLength.Short).Show();

                StartActivity(typeof(MainActivity));
                Finish();

                try
                {
                    btSocket.Close();
                }
                catch (System.Exception)
                {
                    Console.WriteLine("Imposible Conectar");
                }
                Console.WriteLine("Socket Creado");
            }
        }
Ejemplo n.º 32
0
        public DeviceUuidFactory(Context context)
        {
            if (uuid == null)
            {
                lock (_lock)
                {
                    if (uuid == null)
                    {
                        var prefs = context.GetSharedPreferences(PREFS_FILE, FileCreationMode.Private);
                        var id = prefs.GetString(PREFS_DEVICE_ID, null);

                        if (!string.IsNullOrWhiteSpace(id))
                        {
                            // Use the ids previously computed and stored in the prefs file
                            uuid = UUID.FromString(id);
                        }
                        else
                        {
                            var androidId = Settings.Secure.GetString(context.ContentResolver, Settings.Secure.AndroidId);

                            // Use the Android ID unless it's broken, in which case fallback on deviceId,
                            // unless it's not available, then fallback on a random number which we store
                            // to a prefs file

                            if ("9774d56d682e549c" == androidId)
                            {
                                //Generate a new UUID rather than require READ_PHONE_STATE
                                var c = new Java.Lang.String(androidId);
                                uuid = UUID.NameUUIDFromBytes(c.GetBytes("utf8"));
                            }
                            else
                            {
                                uuid = UUID.RandomUUID();
                            }

                            prefs.Edit().PutString(PREFS_DEVICE_ID, uuid.ToString()).Apply();
                        }
                    }
                }
            }
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            /**
             * 使用地图sdk前需先初始化BMapManager.
             * BMapManager是全局的,可为多个MapView共用,它需要地图模块创建前创建,
             * 并在地图地图模块销毁后销毁,只要还有地图模块在使用,BMapManager就不应该销毁
             */
            DemoApplication app = (DemoApplication)this.Application;
            if (app.mBMapManager == null)
            {
                app.mBMapManager = new BMapManager(ApplicationContext);
                /**
                 * 如果BMapManager没有初始化则初始化BMapManager
                 */
                app.mBMapManager.Init(new DemoApplication.MyGeneralListener());
            }
            SetContentView(Resource.Layout.activity_geometry);
            ICharSequence titleLable = new String("自定义绘制功能");
            Title = titleLable.ToString();

            //初始化地图
            mMapView = FindViewById<MapView>(Resource.Id.bmapView);
            mMapView.Controller.SetZoom(12.5f);
            mMapView.Controller.EnableClick(true);

            //UI初始化
            clearBtn = FindViewById<Button>(Resource.Id.button1);
            resetBtn = FindViewById<Button>(Resource.Id.button2);

            Android.Views.View.IOnClickListener clearListener = new ClearListenerImpl(this);
            Android.Views.View.IOnClickListener restListener = new RestListenerImpl(this);

            clearBtn.SetOnClickListener(clearListener);
            resetBtn.SetOnClickListener(restListener);

            //界面加载时添加绘制图层
            AddCustomElementsDemo();
        }
Ejemplo n.º 34
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.activity_geocoder);
            ICharSequence titleLable = new String("������빦��");
            Title = titleLable.ToString();

            // ��ͼ��ʼ��
            mMapView = FindViewById<MapView>(Resource.Id.bmapView);
            mBaiduMap = mMapView.Map;

            // ��ʼ������ģ�飬ע���¼�����
            mSearch = GeoCoder.NewInstance();
            mSearch.SetOnGetGeoCodeResultListener(this);
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            /**
             * 使用地图sdk前需先初始化BMapManager.
             * BMapManager是全局的,可为多个MapView共用,它需要地图模块创建前创建,
             * 并在地图地图模块销毁后销毁,只要还有地图模块在使用,BMapManager就不应该销毁
             */
            DemoApplication app = (DemoApplication)this.Application;
            if (app.mBMapManager == null)
            {
                app.mBMapManager = new BMapManager(ApplicationContext);
                /**
                 * 如果BMapManager没有初始化则初始化BMapManager
                 */
                app.mBMapManager.Init(new DemoApplication.MyGeneralListener());
            }
            SetContentView(Resource.Layout.activity_locationoverlay);
            ICharSequence titleLable = new String("定位功能");
            Title = titleLable.ToString();

            myListener = new MyLocationListenner(this);

            requestLocButton = FindViewById<Button>(Resource.Id.button1);
            mCurBtnType = E_BUTTON_TYPE.LOC;
            Android.Views.View.IOnClickListener btnClickListener = new BtnClickListenerImpl(this);

            requestLocButton.SetOnClickListener(btnClickListener);

            RadioGroup group = this.FindViewById<RadioGroup>(Resource.Id.radioGroup);
            radioButtonListener = new RadioButtonListenerImpl(this);
            group.SetOnCheckedChangeListener(radioButtonListener);

            //地图初始化
            mMapView = FindViewById<MyLocationMapView>(Resource.Id.bmapView);
            mMapController = mMapView.Controller;
            mMapView.Controller.SetZoom(14);
            mMapView.Controller.EnableClick(true);
            mMapView.SetBuiltInZoomControls(true);
            //创建 弹出泡泡图层
            CreatePaopao();

            //定位初始化
            mLocClient = new LocationClient(this);
            locData = new LocationData();
            mLocClient.RegisterLocationListener(myListener);
            LocationClientOption option = new LocationClientOption();
            option.OpenGps = true;//打开gps
            option.CoorType = "bd09ll";     //设置坐标类型
            option.ScanSpan = 1000;
            mLocClient.LocOption = option;
            mLocClient.Start();

            //定位图层初始化
            myLocationOverlay = new LocationOverlay(this, mMapView);
            //设置定位数据
            myLocationOverlay.SetData(locData);
            //添加定位图层
            mMapView.Overlays.Add(myLocationOverlay);
            myLocationOverlay.EnableCompass();
            //修改定位数据后刷新图层生效
            mMapView.Refresh();

        }
Ejemplo n.º 36
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.activity_poisearch);
            // ��ʼ������ģ�飬ע�������¼�����
            mPoiSearch = PoiSearch.NewInstance();
            mPoiSearch.SetOnGetPoiSearchResultListener(this);
            mSuggestionSearch = SuggestionSearch.NewInstance();
            mSuggestionSearch.SetOnGetSuggestionResultListener(this);
            keyWorldsView = FindViewById<AutoCompleteTextView>(Resource.Id.searchkey);
            sugAdapter = new ArrayAdapter<string>(this,
                    Android.Resource.Layout.SimpleDropDownItem1Line);
            keyWorldsView.Adapter = sugAdapter;
            mBaiduMap = (Android.Runtime.Extensions.JavaCast<SupportMapFragment>(SupportFragmentManager
                    .FindFragmentById(Resource.Id.map))).BaiduMap;

            /**
             * ������ؼ��ֱ仯ʱ����̬���½����б�
             */
            keyWorldsView.AfterTextChanged += (sender, e) => { };
            keyWorldsView.BeforeTextChanged += (sender, e) => { };
            keyWorldsView.TextChanged += (sender, e) =>
            {
                ICharSequence cs = new String(e.Text.ToString());
                if (cs.Length() <= 0)
                {
                    return;
                }
                string city = (FindViewById<EditText>(Resource.Id.city)).Text;
                /**
                 * ʹ�ý������������ȡ�����б�������onSuggestionResult()�и���
                 */
                mSuggestionSearch
                        .RequestSuggestion((new SuggestionSearchOption())
                                .Keyword(cs.ToString()).City(city));
            };
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            /**
             * 使用地图sdk前需先初始化BMapManager.
             * BMapManager是全局的,可为多个MapView共用,它需要地图模块创建前创建,
             * 并在地图地图模块销毁后销毁,只要还有地图模块在使用,BMapManager就不应该销毁
             */
            DemoApplication app = (DemoApplication)this.Application;
            if (app.mBMapManager == null)
            {
                app.mBMapManager = new BMapManager(ApplicationContext);
                /**
                 * 如果BMapManager没有初始化则初始化BMapManager
                 */
                app.mBMapManager.Init(new DemoApplication.MyGeneralListener());
            }
            SetContentView(Resource.Layout.geocoder);
            ICharSequence titleLable = new String("地理编码功能");
            Title = titleLable.ToString();

            //地图初始化
            mMapView = FindViewById<MapView>(Resource.Id.bmapView);
            mMapView.Controller.EnableClick(true);
            mMapView.Controller.SetZoom(12);

            // 初始化搜索模块,注册事件监听
            mSearch = new MKSearch();
            mSearch.Init(app.mBMapManager, new IMKSearchListenerImpl(this));

            // 设定地理编码及反地理编码按钮的响应
            mBtnReverseGeoCode = FindViewById<Button>(Resource.Id.reversegeocode);
            mBtnGeoCode = FindViewById<Button>(Resource.Id.geocode);

            Android.Views.View.IOnClickListener clickListener = new ClickListenerImpl(this);

            mBtnReverseGeoCode.SetOnClickListener(clickListener);
            mBtnGeoCode.SetOnClickListener(clickListener);
        }
        //static SystemBarTintManager {
        //    // Android allows a system property to override the presence of the navigation bar.
        //    // Used by the emulator.
        //    // See https://github.com/android/platform_frameworks_base/blob/master/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java#L1076
        //    if (Build.VERSION.SDKINT >= BuildVersionCodes.KITKAT) {
        //        try {
        //            Class c = Class.forName("android.os.SystemProperties");
        //            Method m = c.getDeclaredMethod("get", String.class);
        //            m.setAccessible(true);
        //            sNavBarOverride = (String) m.invoke(null, "qemu.hw.mainkeys");
        //        } catch (Throwable e) {
        //            sNavBarOverride = null;
        //        }
        //    }
        //}


        static void main()
        {
            if (Build.VERSION.SdkInt >= BuildVersionCodes.Kitkat)
            {
                try
                {
                    Class c = Class.ForName("android.os.SystemProperties");
                    Java.Lang.String ss = new Java.Lang.String();

                    Method m = c.GetDeclaredMethod("get", new Class[] { ss.Class });
                    m.Accessible = true;
                    sNavBarOverride = (string)m.Invoke(null, "qemu.hw.mainkeys");
                }
                catch (Throwable e)
                {
                    sNavBarOverride = null;
                }
            }
        }
Ejemplo n.º 39
0
 protected override void OnCreate(Bundle savedInstanceState)
 {
     base.OnCreate(savedInstanceState);
     SetContentView(Resource.Layout.activity_routeplan);
     ICharSequence titleLable = new String("·�߹滮����");
     Title = titleLable.ToString();
     //��ʼ����ͼ
     mMapView = FindViewById<MapView>(Resource.Id.map);
     mBaidumap = mMapView.Map;
     mBtnPre = FindViewById<Button>(Resource.Id.pre);
     mBtnNext = FindViewById<Button>(Resource.Id.next);
     mBtnPre.Visibility = ViewStates.Invisible;
     mBtnNext.Visibility = ViewStates.Invisible;
     //��ͼ����¼�����
     mBaidumap.SetOnMapClickListener(this);
     // ��ʼ������ģ�飬ע���¼�����
     mSearch = RoutePlanSearch.NewInstance();
     mSearch.SetOnGetRoutePlanResultListener(this);
 }
        MapView mMapView = null;	// 地图View
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            /**
             * 使用地图sdk前需先初始化BMapManager.
             * BMapManager是全局的,可为多个MapView共用,它需要地图模块创建前创建,
             * 并在地图地图模块销毁后销毁,只要还有地图模块在使用,BMapManager就不应该销毁
             */
            DemoApplication app = (DemoApplication)this.Application;
            if (app.mBMapManager == null)
            {
                app.mBMapManager = new BMapManager(ApplicationContext);
                /**
                 * 如果BMapManager没有初始化则初始化BMapManager
                 */
                app.mBMapManager.Init(new DemoApplication.MyGeneralListener());
            }
            SetContentView(Resource.Layout.activity_customroute);
            ICharSequence titleLable = new String("路线规划功能——自设路线示例");
            Title = titleLable.ToString();
            //初始化地图
            mMapView = FindViewById<MapView>(Resource.Id.bmapView);
            mMapView.Controller.EnableClick(true);
            mMapView.Controller.SetZoom(13);

            /** 演示自定义路线使用方法	
             *  在北京地图上画一个北斗七星
             *  想知道某个点的百度经纬度坐标请点击:http://api.map.baidu.com/lbsapi/getpoint/index.html	
             */
            GeoPoint p1 = new GeoPoint((int)(39.9411 * 1E6), (int)(116.3714 * 1E6));
            GeoPoint p2 = new GeoPoint((int)(39.9498 * 1E6), (int)(116.3785 * 1E6));
            GeoPoint p3 = new GeoPoint((int)(39.9436 * 1E6), (int)(116.4029 * 1E6));
            GeoPoint p4 = new GeoPoint((int)(39.9329 * 1E6), (int)(116.4035 * 1E6));
            GeoPoint p5 = new GeoPoint((int)(39.9218 * 1E6), (int)(116.4115 * 1E6));
            GeoPoint p6 = new GeoPoint((int)(39.9144 * 1E6), (int)(116.4230 * 1E6));
            GeoPoint p7 = new GeoPoint((int)(39.9126 * 1E6), (int)(116.4387 * 1E6));
            //起点坐标
            GeoPoint start = p1;
            //终点坐标
            GeoPoint stop = p7;
            //第一站,站点坐标为p3,经过p1,p2
            GeoPoint[] step1 = new GeoPoint[3];
            step1[0] = p1;
            step1[1] = p2;
            step1[2] = p3;
            //第二站,站点坐标为p5,经过p4
            GeoPoint[] step2 = new GeoPoint[2];
            step2[0] = p4;
            step2[1] = p5;
            //第三站,站点坐标为p7,经过p6
            GeoPoint[] step3 = new GeoPoint[2];
            step3[0] = p6;
            step3[1] = p7;
            //站点数据保存在一个二维数据中
            GeoPoint[][] routeData = new GeoPoint[3][];
            routeData[0] = step1;
            routeData[1] = step2;
            routeData[2] = step3;
            //用站点数据构建一个MKRoute
            MKRoute route = new MKRoute();
            route.CustomizeRoute(start, stop, routeData);
            //将包含站点信息的MKRoute添加到RouteOverlay中
            RouteOverlay routeOverlay = new RouteOverlay(this, mMapView);
            routeOverlay.SetData(route);
            //向地图添加构造好的RouteOverlay
            mMapView.Overlays.Add(routeOverlay);
            //执行刷新使生效
            mMapView.Refresh();
        }
Ejemplo n.º 41
0
        protected override void OnMeasure(int widthMeasureSpec, int heightMeasureSpec)
        {
            base.OnMeasure (widthMeasureSpec, heightMeasureSpec);
            return;

            _inMeasure = true;
            //base.OnMeasure (widthMeasureSpec, heightMeasureSpec);
            try {
                var availableWidth = MeasureSpec.GetSize (widthMeasureSpec) - CompoundPaddingLeft - CompoundPaddingRight;
                var availableHeight = MeasureSpec.GetSize (heightMeasureSpec) - CompoundPaddingTop - CompoundPaddingBottom;

                _originalText = GetOriginalText ();

                if (_originalText == null || _originalText.Length () == 0 || availableWidth <= 0) {
                    SetMeasuredDimension (widthMeasureSpec, heightMeasureSpec);
                    return;
                }

                var textPaint = Paint;
                var targetTextSize = _maxTextSize;
                var originalText = new Java.Lang.String (_originalText.ToString ());
                var finalText = originalText;

                var textSize = GetTextSize (originalText, textPaint, targetTextSize);
                var textExcedsBounds = textSize.Height () > availableHeight || textSize.Width () > availableWidth;

                if (_shrinkTextSize && textExcedsBounds) {
                    var heightMultiplier = availableHeight / (float)textSize.Height ();
                    var widthMultiplier = availableWidth / (float)textSize.Width ();
                    var multiplier = System.Math.Min (heightMultiplier, widthMultiplier);

                    targetTextSize = System.Math.Max (targetTextSize * multiplier, _minTextSize);

                    textSize = GetTextSize (finalText, textPaint, targetTextSize);
                }
                if (textSize.Width () > availableWidth) {
                    var modifiedText = new StringBuilder ();
                    var lines = originalText.Split (Java.Lang.JavaSystem.GetProperty ("line.separator"));
                    for (var i = 0; i < lines.Length; i++) {
                        modifiedText.Append (ResizeLine (textPaint, lines [i], availableWidth));
                        if (i != lines.Length - 1)
                            modifiedText.Append (Java.Lang.JavaSystem.GetProperty ("line.separator"));
                    }

                    finalText = new Java.Lang.String (modifiedText);
                    textSize = GetTextSize (finalText, textPaint, targetTextSize);
                }

                textPaint.TextSize = targetTextSize;

                var isMultiline = finalText.IndexOf ('\n') > -1;
                if (isMultiline) {
                    SetLineSpacing (LineSpacingExtra, LineSpacingMultiplierMultiline);
                    SetIncludeFontPadding (false);
                } else {
                    SetLineSpacing (LineSpacingExtra, LineSpacingMultiplierSingleline);
                    SetIncludeFontPadding (true);
                }

                Text = finalText + "\u200B";

                var measuredWidth = textSize.Width () + CompoundPaddingLeft + CompoundPaddingRight;
                var measureHeight = textSize.Height () + CompoundPaddingTop + CompoundPaddingBottom;

                measureHeight = System.Math.Max (measureHeight, MeasureSpec.GetSize (heightMeasureSpec));
                SetMeasuredDimension (measuredWidth, measureHeight);
            } finally {
                _inMeasure = false;

            }
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            /**
             * 使用地图sdk前需先初始化BMapManager.
             * BMapManager是全局的,可为多个MapView共用,它需要地图模块创建前创建,
             * 并在地图地图模块销毁后销毁,只要还有地图模块在使用,BMapManager就不应该销毁
             */
            DemoApplication app = (DemoApplication)this.Application;
            if (app.mBMapManager == null)
            {
                app.mBMapManager = new BMapManager(ApplicationContext);
                /**
                 * 如果BMapManager没有初始化则初始化BMapManager
                 */
                app.mBMapManager.Init(new DemoApplication.MyGeneralListener());
            }
            SetContentView(Resource.Layout.routeplan);
            ICharSequence titleLable = new String("路线规划功能");
            Title = titleLable.ToString();
            //初始化地图
            mMapView = FindViewById<MapView>(Resource.Id.bmapView);
            mMapView.SetBuiltInZoomControls(false);
            mMapView.Controller.SetZoom(12);
            mMapView.Controller.EnableClick(true);

            //初始化按键
            mBtnDrive = FindViewById<Button>(Resource.Id.drive);
            mBtnTransit = FindViewById<Button>(Resource.Id.transit);
            mBtnWalk = FindViewById<Button>(Resource.Id.walk);
            mBtnPre = FindViewById<Button>(Resource.Id.pre);
            mBtnNext = FindViewById<Button>(Resource.Id.next);
            mBtnCusRoute = FindViewById<Button>(Resource.Id.custombutton);
            mBtnCusIcon = FindViewById<Button>(Resource.Id.customicon);
            mBtnPre.Visibility = ViewStates.Invisible;
            mBtnNext.Visibility = ViewStates.Invisible;

            //按键点击事件
            Android.Views.View.IOnClickListener clickListener = new ClickListenerImpl(this);
            Android.Views.View.IOnClickListener nodeClickListener = new NodeClickListenerImpl(this);
            Android.Views.View.IOnClickListener customClickListener = new CustomClickListenerImpl(this);
            Android.Views.View.IOnClickListener changeRouteIconListener = new ChangeRouteIconListenerImpl(this);

            mBtnDrive.SetOnClickListener(clickListener);
            mBtnTransit.SetOnClickListener(clickListener);
            mBtnWalk.SetOnClickListener(clickListener);
            mBtnPre.SetOnClickListener(nodeClickListener);
            mBtnNext.SetOnClickListener(nodeClickListener);
            mBtnCusRoute.SetOnClickListener(customClickListener);
            mBtnCusIcon.SetOnClickListener(changeRouteIconListener);
            //创建 弹出泡泡图层
            CreatePaopao();

            //地图点击事件处理
            mMapView.RegMapTouchListner(new IMKMapTouchListenerImpl(this));
            // 初始化搜索模块,注册事件监听
            mSearch = new MKSearch();
            mSearch.Init(app.mBMapManager, new IMKSearchListenerImpl(this));
        }
Ejemplo n.º 43
0
			public override void HandleMessage (Message msg)
			{
				switch (msg.What) {
				case MESSAGE_STATE_CHANGE:
					if (Debug)
						Log.Info (TAG, "MESSAGE_STATE_CHANGE: " + msg.Arg1);
					switch (msg.Arg1) {
					case BluetoothChatService.STATE_CONNECTED:
						bluetoothChat.title.SetText (Resource.String.title_connected_to);
						bluetoothChat.title.Append (bluetoothChat.connectedDeviceName);
						bluetoothChat.conversationArrayAdapter.Clear ();
						break;
					case BluetoothChatService.STATE_CONNECTING:
						bluetoothChat.title.SetText (Resource.String.title_connecting);
						break;
					case BluetoothChatService.STATE_LISTEN:
					case BluetoothChatService.STATE_NONE:
						bluetoothChat.title.SetText (Resource.String.title_not_connected);
						break;
					}
					break;
				case MESSAGE_WRITE:
					byte[] writeBuf = (byte[])msg.Obj;
					// construct a string from the buffer
					var writeMessage = new Java.Lang.String (writeBuf);
					bluetoothChat.conversationArrayAdapter.Add ("Me: " + writeMessage);
					break;
				case MESSAGE_READ:
					byte[] readBuf = (byte[])msg.Obj;
					// construct a string from the valid bytes in the buffer
					var readMessage = new Java.Lang.String (readBuf, 0, msg.Arg1);
					bluetoothChat.conversationArrayAdapter.Add (bluetoothChat.connectedDeviceName + ":  " + readMessage);
					break;
				case MESSAGE_DEVICE_NAME:
					// save the connected device's name
					bluetoothChat.connectedDeviceName = msg.Data.GetString (DEVICE_NAME);
					Toast.MakeText (Application.Context, "Connected to " + bluetoothChat.connectedDeviceName, ToastLength.Short).Show ();
					break;
				case MESSAGE_TOAST:
					Toast.MakeText (Application.Context, msg.Data.GetString (TOAST), ToastLength.Short).Show ();
					break;
				}
			}
Ejemplo n.º 44
0
		private void SetupChat ()
		{
			Log.Debug (TAG, "SetupChat()");
	
			// Initialize the array adapter for the conversation thread
			conversationArrayAdapter = new ArrayAdapter<string> (this, Resource.Layout.message);
			conversationView = FindViewById<ListView> (Resource.Id.@in);
			conversationView.Adapter = conversationArrayAdapter;
	
			// Initialize the compose field with a listener for the return key
			outEditText = FindViewById<EditText> (Resource.Id.edit_text_out);
			// The action listener for the EditText widget, to listen for the return key
			outEditText.EditorAction += delegate(object sender, TextView.EditorActionEventArgs e) {
				// If the action is a key-up event on the return key, send the message
				if (e.ActionId == ImeAction.ImeNull && e.Event.Action == KeyEventActions.Up) {
					var message = new Java.Lang.String (((TextView) sender).Text);
					SendMessage (message);
				}	
			};
			
			// Initialize the send button with a listener that for click events
			sendButton = FindViewById<Button> (Resource.Id.button_send);
			sendButton.Click += delegate(object sender, EventArgs e) {
				// Send a message using content of the edit text widget
				var view = FindViewById<TextView> (Resource.Id.edit_text_out);
				var message = new Java.Lang.String (view.Text);
				SendMessage (message);
			};
			
			// Initialize the BluetoothChatService to perform bluetooth connections
			chatService = new BluetoothChatService (this, new MyHandler (this));
			
			// Initialize the buffer for outgoing messages
			outStringBuffer = new StringBuffer ("");
		}
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            /**
             * 使用地图sdk前需先初始化BMapManager.
             * BMapManager是全局的,可为多个MapView共用,它需要地图模块创建前创建,
             * 并在地图地图模块销毁后销毁,只要还有地图模块在使用,BMapManager就不应该销毁
             */
            DemoApplication app = (DemoApplication)this.Application;

            if (app.mBMapManager == null)
            {
                app.mBMapManager = new BMapManager(ApplicationContext);
                /**
                 * 如果BMapManager没有初始化则初始化BMapManager
                 */
                app.mBMapManager.Init(new DemoApplication.MyGeneralListener());
            }

            SetContentView(Resource.Layout.buslinesearch);

            ICharSequence titleLable = new String("公交线路查询功能");

            Title = titleLable.ToString();

            //地图初始化
            mMapView = FindViewById<MapView>(Resource.Id.bmapView);
            mMapView.Controller.EnableClick(true);
            mMapView.Controller.SetZoom(12);
            busLineIDList = new List<string>();

            //创建 弹出泡泡图层
            CreatePaopao();

            // 设定搜索按钮的响应
            mBtnSearch = FindViewById<Button>(Resource.Id.search);
            mBtnNextLine = FindViewById<Button>(Resource.Id.nextline);
            mBtnPre = FindViewById<Button>(Resource.Id.pre);
            mBtnNext = FindViewById<Button>(Resource.Id.next);
            mBtnPre.Visibility = ViewStates.Invisible;
            mBtnNext.Visibility = ViewStates.Invisible;

            //地图点击事件处理
            mMapView.RegMapTouchListner(new MKMapTouchListenerImpl(this));

            // 初始化搜索模块,注册事件监听
            mSearch = new MKSearch();
            mSearch.Init(app.mBMapManager, new MKSearchListenerImpl(this));

            Android.Views.View.IOnClickListener clickListener = new ClickListenerImpl(this);
            Android.Views.View.IOnClickListener nextLineClickListener = new NextLineClickListener(this);
            Android.Views.View.IOnClickListener nodeClickListener = new NodeClickListener(this);

            mBtnSearch.SetOnClickListener(clickListener);
            mBtnNextLine.SetOnClickListener(nextLineClickListener);
            mBtnPre.SetOnClickListener(nodeClickListener);
            mBtnNext.SetOnClickListener(nodeClickListener);

            //mBtnSearch.Click += (sender, e) =>
            //{
            //    SearchButtonProcess(mBtnSearch);
            //};


            //mBtnNextLine.Click += (sender, e) =>
            //{
            //    SearchNextBusline();
            //};

            //mBtnPre.Click += (sender, e) =>
            //{
            //    NodeClick(mBtnPre);
            //};

            //mBtnNext.Click += (sender, e) =>
            //{
            //    NodeClick(mBtnNext);
            //};
        }
Ejemplo n.º 46
0
 protected override void OnCreate(Bundle savedInstanceState)
 {
     base.OnCreate(savedInstanceState);
     SetContentView(Resource.Layout.activity_busline);
     ICharSequence titleLable = new String("������·��ѯ����");
     Title = titleLable.ToString();
     mBtnPre = FindViewById<Button>(Resource.Id.pre);
     mBtnNext = FindViewById<Button>(Resource.Id.next);
     mBtnPre.Visibility = ViewStates.Invisible;
     mBtnNext.Visibility = ViewStates.Invisible;
     mBaiduMap = (Android.Runtime.Extensions.JavaCast<SupportMapFragment>(SupportFragmentManager
             .FindFragmentById(Resource.Id.bmapView))).BaiduMap;
     mBaiduMap.SetOnMapClickListener(this);
     mSearch = PoiSearch.NewInstance();
     mSearch.SetOnGetPoiSearchResultListener(this);
     mBusLineSearch = BusLineSearch.NewInstance();
     mBusLineSearch.SetOnGetBusLineSearchResultListener(this);
     busLineIDList = new List<string>();
 }