Ejemplo n.º 1
0
        } // ChangePictureBtnAction

        public void OnSubmitButton(object sender, EventArgs e)
        {
            if (String.IsNullOrEmpty(nameEntry.Text) || String.IsNullOrEmpty(addressEntry.Text) ||
                String.IsNullOrEmpty(phoneEntry.Text))
            {
                DisplayAlert("Alert", "Please enter all information", "OK");
                return;
            }
            ContactAdapter updatedInfo = new ContactAdapter(new Models.Contact(nameEntry.Text,
                                                                               addressEntry.Text, phoneEntry.Text,
                                                                               ((ContactDetailViewModel)this.BindingContext).GetId(),
                                                                               ((ContactDetailViewModel)this.BindingContext).GetImageSource()));

            contactDetailVM.UpdateData(updatedInfo);
            if (newContact)
            {
                DisplayAlert("Confirm", "Added " + nameEntry.Text + " successfully", "OK");
            }
            else
            {
                DisplayAlert("Confirm", "Information has been changed", "OK");
            }
            var address = addressEntry.Text;

            this.ChangeMapLocation(address);
        } // OnSubmitButton
Ejemplo n.º 2
0
        public async Task <ObservableCollection <ContactAdapter> > RefreshContacts()
        {
            List <Contact> contacts = await App.Database.GetAllContacts();

            this.ContactAdapters = new ObservableCollection <ContactAdapter>(ContactAdapter.ToContactAdapters(contacts));
            return(contactAdapters);
        }
Ejemplo n.º 3
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            SetContentView(Resource.Layout.Main);

            contacts = new List <Contact> {
                new Contact {
                    Name = "hamed", Number = "0918989998", Id = 2
                }, new Contact {
                    Name = "saeed", Number = "09123232656", Id = 21
                }, new Contact {
                    Name = "koorosh", Number = "098686866", Id = 30
                }, new Contact {
                    Name = "milad", Number = "09335656565", Id = 17
                }, new Contact {
                    Name = "kami", Number = "0938654545", Id = 18
                }, new Contact {
                    Name = "ali", Number = "03212254345", Id = 65
                }, new Contact {
                    Name = "abas", Number = "98989898989", Id = 10
                }, new Contact {
                    Name = "messi", Number = "9565874654545", Id = 15
                }
            };

            var recycler      = FindViewById <RecyclerView>(Resource.Id.contacts_recyclerview);
            var layoutManager = new LinearLayoutManager(this, LinearLayoutManager.Vertical, false);

            //var layoutManager = new GridLayoutManager(this,2);
            recycler.SetLayoutManager(layoutManager);
            var adapter = new ContactAdapter(this, recycler, contacts);

            recycler.SetAdapter(adapter);
        }
Ejemplo n.º 4
0
        public async Task <ContactAdapter> GetContactById(int givenId)
        {
            Contact foundContact = await contactService.GetContactById(givenId);

            ContactAdapter temp = new ContactAdapter(foundContact);

            return(temp);
        }
Ejemplo n.º 5
0
        private void DisplayInformation(ContactAdapter contactAdapter)
        {
            nameEntry.Text    = contactAdapter.Name;
            addressEntry.Text = contactAdapter.Address;
            phoneEntry.Text   = contactAdapter.Phone;
            var address = addressEntry.Text;

            this.ChangeMapLocation(address);
        }
Ejemplo n.º 6
0
 async void OnDelete(object sender, EventArgs e) {
     var mi = ((MenuItem)sender);
     ContactAdapter rowData = (ContactAdapter)mi.CommandParameter;
     var confirmed = await DisplayAlert("Confirm", "Are you sure you want to delete " + rowData.Name + "?", "Yes", "No");
     if (confirmed) {
         contactListVM.DeleteContact(rowData);
         this.OnAppearing();
     }
 }
Ejemplo n.º 7
0
        public void DisplayDetail(ContactAdapter receivedData)
        {
            geoCoder = new Geocoder();
            int selectedId = receivedData.Id;

            contactDetailVM = new ContactDetailViewModel(receivedData.Name, receivedData.Address,
                                                         receivedData.Phone, receivedData.Id, receivedData.ImageSource);
            this.BindingContext = contactDetailVM;
            this.ChooseDisplayContext(receivedData.Id);
            this.DisplayProfilePicture(profilePicture);
            this.ChangePictureBtnAction(changePictureBtn);
        }
Ejemplo n.º 8
0
 private async void ChooseDisplayContext(int selectedId)
 {
     if (selectedId != 0)   // user is modifying existing contact
     {
         newContact = false;
         ContactAdapter contactAdapter = await((ContactDetailViewModel)this.BindingContext).GetContactById(selectedId);
         DisplayInformation(contactAdapter);
     }
     else
     {
         newContact = true;
         DisplayDefaultDetailPage();
     }
 }
Ejemplo n.º 9
0
        private async void InitializeListVM()
        {
            contactService = App.Database;
            List <Contact> contacts = await contactService.GetAllContacts();

            contactAdapters = new ObservableCollection <ContactAdapter>(ContactAdapter.ToContactAdapters(contacts));
            for (int i = 0; i < contactAdapters.Count; i++)
            {
                if (contactAdapters[i].ImageSource == "")
                {
                    contactAdapters[i].ImageSource = "usernew.png";
                }
            }
        }
Ejemplo n.º 10
0
        private void OnSuccessOperationResponseEvent(OperationCode operationCode, SubCode subCode, OperationResponse response)
        {
            if (operationCode != OperationCode.Contact)
            {
                return;
            }
            switch (subCode)
            {
            case SubCode.Contact_List:
                if (response.Parameters.TryGetParameter(ParameterKeys.USER_MODEL_LIST, out UserListModel model) && model != null && model.Users?.Count > 0)
                {
                    AddToConsole("请求联系人列表成功", false);
                    mContacts = model.Users;
                    RunOnUiThread(() =>
                    {
                        mContactAdapter          = new ContactAdapter(mActivity, Resource.Layout.ContactItem, mContacts);
                        mContactListView.Adapter = mContactAdapter;
                    });
                }
                else
                {
                    AddToConsole("联系人列表为空", false);
                    mContacts = new List <UserModel>();
                    RunOnUiThread(() =>
                    {
                        mContactAdapter          = new ContactAdapter(mActivity, Resource.Layout.ContactItem, mContacts);
                        mContactListView.Adapter = mContactAdapter;
                    });
                }
                break;

            case SubCode.Contact_Add_Response:

                break;
            }
        }
Ejemplo n.º 11
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            /*CNP.RequestReceived += (sender, e) =>
             * {
             *  using (var ewh = new EventWaitHandle(false, EventResetMode.ManualReset))
             *  {
             *      var go = false;
             *      RunOnUiThread(() =>
             *      {
             *          try
             *          {
             *              var b = new AlertDialog.Builder(BaseContext);
             *              b.SetCancelable(true);
             *              b.SetIcon(Resource.Drawable.Icon);
             *              b.SetMessage($"{e.Address} has sent you a contact request, would you like to accept? The connection PIN is {e.PIN}.");
             *              b.SetTitle("Incoming Contact Request");
             *              b.SetPositiveButton("Yes", (_sender, _e) =>
             *              {
             *                  go = true;
             *                  ewh.Set();
             *                  var _b = new Bundle(1);
             *                  _b.PutByteArray("address", e.Address.Serialize());
             *                  StartActivity(typeof(AddContactActivity));
             *              });
             *              b.SetNegativeButton("No", (_sender, _e) => ewh.Set());
             *              b.Create().Show();
             *          }
             *          catch (Exception ex)
             *          {
             *              Log.RecordEvent(this, $"handler failed with message {ex.Message}", LogEntrySeverity.Error);
             *          }
             *      });
             *      ewh.WaitOne();
             *      if (go)
             *          e.Accept();
             *  }
             * };*/
            CNP.RequestReceived     += (sender, e) => e.Accept();
            ActionBar.NavigationMode = ActionBarNavigationMode.Tabs;
            a = new ContactAdapter(Configuration.Contacts);
            var list = new ListView(BaseContext)
            {
                Adapter = a
            };

            SetContentView(list);
            var all = ActionBar.NewTab();

            all.SetText("All");
            all.TabSelected   += All_TabSelected;
            all.TabReselected += All_TabSelected;
            ActionBar.AddTab(all);
            var online = ActionBar.NewTab();

            online.SetText("Online");
            online.TabSelected   += All_TabSelected;
            online.TabReselected += All_TabSelected;
            ActionBar.AddTab(online);
            var recent = ActionBar.NewTab();

            recent.SetText("Recent");
            recent.TabSelected   += Recent_TabSelected;
            recent.TabReselected += Recent_TabSelected;
            ActionBar.AddTab(recent);
            ActionBar.SetLogo(Resource.Drawable.Icon);
        }
Ejemplo n.º 12
0
 public ContactDetailPage(ContactAdapter receivedData)
 {
     InitializeComponent();
     this.DisplayDetail(receivedData);
 }
Ejemplo n.º 13
0
 public async void DeleteContact(ContactAdapter contactAdapter)
 {
     int temp = await contactService.DeleteContact(contactAdapter.Contact);
 }
        public List <Contact> GetAll()
        {
            var allContacts = dbContext.ContactDetails.Select(x => x).ToList();

            return(ContactAdapter.AdaptContacts(allContacts));
        }
Ejemplo n.º 15
0
 public void UpdateData(ContactAdapter contactAdapter)
 {
     contactService.UpdateData(contactAdapter.Contact);
 }
Ejemplo n.º 16
0
 async void OnContactSelected(object sender, SelectedItemChangedEventArgs e) {
     ListView listView = (ListView)sender;
     ContactAdapter rowData = (ContactAdapter)listView.SelectedItem;
     await Navigation.PushAsync(new ContactDetailPage(rowData));
 }
        public Contact GetById(int id)
        {
            var contact = dbContext.ContactDetails.FirstOrDefault(x => x.id.Equals(id));

            return(ContactAdapter.AdaptContact(contact));
        }