Android Open Source - texting All Contacts Wrapper






From Project

Back to project page texting.

License

The source code is released under:

Free to use, distribute, do anything.

If you think the Android project texting listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.skk.texting.viewwrapper;
/*w w  w  .j av a 2s  .  co  m*/

import android.database.Cursor;
import android.text.Editable;
import android.text.TextWatcher;
import android.util.Log;
import android.view.View;
import android.widget.*;
import com.google.inject.Inject;
import com.skk.texting.R;
import com.skk.texting.TextingApplication;
import com.skk.texting.adaptor.ContactsAdaptor;
import com.skk.texting.adaptor.ConversationAdaptor;
import com.skk.texting.domain.Conversation;
import com.skk.texting.domain.ConversationRepository;
import com.skk.texting.domain.Person;
import com.skk.texting.evented.EventRepository;

public class AllContactsWrapper implements AdapterView.OnItemClickListener {

    private View allContacts;
    private EditText contactSearch;
    private ListView contactsList;

    private ConversationRepository conversationRepository;
    private ViewFlipper viewFlipper;
    private EventRepository eventRepository;

    @Inject
    public AllContactsWrapper(ConversationRepository conversationRepository, EventRepository eventRepository) {
        this.conversationRepository = conversationRepository;
        this.eventRepository = eventRepository;
    }

    public void initialize(View allContacts){

        this.allContacts = allContacts;
        contactSearch = (EditText) allContacts.findViewById(R.id.search_contact);
        contactsList = (ListView) allContacts.findViewById(R.id.contacts);
        setUpHandlers();
    }

    private void setUpHandlers() {
        contactsList.setOnItemClickListener(this);

        final ListView contactsList = this.contactsList;
        contactSearch.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) {

            }

            @Override
            public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) {
                ContactsAdaptor adapter = (ContactsAdaptor) contactsList.getAdapter();
                if(adapter != null)
                    adapter.getFilter().filter(charSequence);
            }

            @Override
            public void afterTextChanged(Editable editable) {

            }
        });
    }


    @Override
    public void onItemClick(AdapterView<?> adapterView, View view, int position, long l) {
        Cursor cursor = (Cursor) adapterView.getItemAtPosition(position);

        Person person = Person.fromCursor(cursor);

        Conversation conversation = conversationRepository.newConversation(person);

        conversation.setRecipient(person);

        TextingApplication applicationContext = (TextingApplication) view.getContext().getApplicationContext();
        applicationContext.setCurrentConversation(conversation);

        contactSearch.setText("");
        viewFlipper.setDisplayedChild(1);

        View currentView = viewFlipper.getCurrentView();
        ListView listView = (ListView) currentView.findViewById(R.id.listView);

        ConversationAdaptor conversationAdaptor = new ConversationAdaptor(view.getContext(), conversation, conversationRepository, eventRepository);
        listView.setAdapter(conversationAdaptor);
    }

    public void setViewFlipper(ViewFlipper viewFlipper) {

        this.viewFlipper = viewFlipper;
    }
}




Java Source Code List

com.skk.texting.ApplicationStart.java
com.skk.texting.TextingApplication.java
com.skk.texting.adaptor.ContactsAdaptor.java
com.skk.texting.adaptor.ConversationAdaptor.java
com.skk.texting.adaptor.TextMessageAdaptor.java
com.skk.texting.adaptor.view.ViewHolder.java
com.skk.texting.adaptor.view.ViewType.java
com.skk.texting.async.AsyncCursorUpdate.java
com.skk.texting.async.BackgroundTask.java
com.skk.texting.constants.ApplicationConstants.java
com.skk.texting.constants.TextMessageConstants.java
com.skk.texting.customview.CustomRelativeLayout.java
com.skk.texting.di.RoboSmallApplication.java
com.skk.texting.domain.ConversationRepository.java
com.skk.texting.domain.Conversation.java
com.skk.texting.domain.Person.java
com.skk.texting.domain.TextMessage.java
com.skk.texting.eventdata.EmptyEventData.java
com.skk.texting.eventdata.IncomingSmsData.java
com.skk.texting.eventdata.RepliedSms.java
com.skk.texting.evented.EventData.java
com.skk.texting.evented.EventHandler.java
com.skk.texting.evented.EventRepository.java
com.skk.texting.evented.Event.java
com.skk.texting.evented.HandleEvent.java
com.skk.texting.factory.PersonFactory.java
com.skk.texting.gesture.MotionEventRecorder.java
com.skk.texting.gesture.OnSwipeGestureHandler.java
com.skk.texting.gesture.SwipeGestureHandler.java
com.skk.texting.gesture.SwipeGestureListener.java
com.skk.texting.listener.IncomingSmsListener.java
com.skk.texting.listener.ListItemClickListener.java
com.skk.texting.viewwrapper.AllContactsWrapper.java
com.skk.texting.viewwrapper.HeaderWrapper.java
com.skk.texting.viewwrapper.MessageConsoleWrapper.java
com.skk.texting.viewwrapper.TextMessagesView.java