Example #1
0
        /// <summary>
        /// When the activity is created
        /// </summary>
        /// <param name="bundle">Any data passed to the activity</param>
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            //Allow this inbox to be retrieved by other classes
            //This allows the inbox to be updated when a new message arrives
            MainActivity.references.Put("Inbox", this);

            SetContentView(Resource.Layout.messaging_inbox);

            taskListView = (ListView)FindViewById(Resource.Id.listView);

            //Get all the users that this user has had a conversation with
            users = MessageRepository.GetMessagedUsers().ToArray <string>();
            tasks = new List <Message>();

            //Get the most recent message from each user to display in the "main" messaging list
            foreach (string s in users)
            {
                tasks.Add(MessageRepository.GetMostRecentMessageFrom(s));
            }

            // create our adapter
            taskList = new MsgListAdapterInbox(this, users.ToList());

            //Hook up our adapter to our ListView
            taskListView.Adapter = taskList;
        }
Example #2
0
        /// <summary>
        /// Get the view for an item in the list
        /// </summary>
        /// <param name="position">The position of the item in the list</param>
        /// <param name="convertView">Unused</param>
        /// <param name="parent">The list view that this item is in</param>
        /// <returns>The view for the item at the given position</returns>
        public override View GetView(int position, View convertView, ViewGroup parent)
        {
            // Get our object for position
            var item = users[position];

            // Inflate convertView from our item layout
            var view = context.LayoutInflater.Inflate(Resource.Layout.msg_adapter_inbox, parent, false);

            view.Clickable = true;

            //Find and set the gui components
            mTextUsername      = view.FindViewById <TextView>(Resource.Id.textUsername);
            mTextRecentMessage = view.FindViewById <TextView>(Resource.Id.textRecentMessage);

            mTextRecentMessage.Text = MessageRepository.GetMostRecentMessageFrom(item).MsgText;
            mTextUsername.Text      = MessageRepository.GetMostRecentMessageFrom(item).UserName;

            //Bring up the message list for the select user
            view.Click += (object sender, EventArgs e) => {
                context.viewConversation(position);
            };

            //Return the created view
            return(view);
        }