Android Open Source - LheidoSMS M M S Fragment






From Project

Back to project page LheidoSMS.

License

The source code is released under:

GNU General Public License

If you think the Android project LheidoSMS 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.lheidosms.fragment;
//from w w  w.j  a  v a 2 s  .c om
import android.net.Uri;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ImageButton;
import android.widget.Toast;

import com.lheidosms.adapter.MmsAdapter;
import com.lheidosms.app.R;
import com.lheidosms.receiver.MmsFragmentReceiver;
import com.lheidosms.utils.LheidoUtils;
import com.lheidosms.utils.Message;
import com.squareup.picasso.Picasso;
import com.twotoasters.jazzylistview.JazzyListView;

/**
 * Created by lheido on 31/10/14.
 */
public class MmsFragment extends SmsBaseFragment {
    private ImageButton zoom;

    @Override
    protected View initRootView(LayoutInflater inflater, ViewGroup container) {
        return inflater.inflate(R.layout.conversation_mms, container, false);
    }

    @Override
    protected com.twotoasters.jazzylistview.JazzyListView initList(View rootView) {
        // add extra view only with MMS
        zoom = (ImageButton)rootView.findViewById(R.id.expanded_image);
        zoom.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                zoom.setVisibility(View.INVISIBLE);
            }
        });
        return (JazzyListView)rootView.findViewById(R.id.list_conversation_mms);
    }

    @Override
    protected void initBroadcastReceiver() {
        mBroadCast = new MmsFragmentReceiver() {
            @Override
            protected void customNotifyDelivered(long id) {

            }

            @Override
            protected void customNotifyReceive(long id, String sender, String body, long date, boolean isRead) {

            }
        };
        filter = ((MmsFragmentReceiver) mBroadCast).getIntentFilter(3000);
//        mBroadCast = new SmsReceiver(){
//            @Override
//            public void customReceivedSMS() {}
//
//            @Override
//            public void customReceivedMMS() {
//                if(PhoneNumberUtils.compare(phoneContact, phone) && !mOnPause){
////                    updateFragment();
//                    //on est dans la bonne conversation !
////                    Time t = new Time();
////                    t.set(date);
////                    add_(-1L, body, phoneContact, 0, t, 0);
////                    conversation_nb_sms += 1;
////                    liste.smoothScrollToPosition(liste.getBottom());
////                    LheidoUtils.Send.newMessageRead(context, list_conversationId, phoneContact);
//                }
//            }
//
//            @Override
//            public void customNewMessageRead(int position, String phone) {}
//
//            @Override
//            public void customDelivered(long _id){
//                int k = 0;
//                boolean find = false;
//                while(!find && k < Message_list.size()){
//                    if(_id == Message_list.get(k).getId()){
//                        find = true;
//                        Message_list.get(k).setRead(true);
//                        mAdapter.notifyDataSetChanged();
//                    }
//                    k++;
//                }
//            }
//        };
//        filter.addAction(LheidoUtils.ACTION_RECEIVE_MMS);
    }

    @Override
    protected void initConversationAdapter() {
        mAdapter = new MmsAdapter(context, phoneContact, Message_list);
    }

    @Override
    protected void initListOnItemClick(AdapterView<?> adapterView, View view, int position, long id) {
        Uri uri = Message_list.get(Message_list.size()-1-position).getUriPicture();
        try{
            Picasso.with(context).load(uri).resize(zoom.getMeasuredWidth()-zoom.getPaddingLeft()*2, zoom.getMeasuredHeight()-zoom.getPaddingTop()*2).centerInside().into(zoom);
        }catch (Exception e){
            e.printStackTrace();
        }
        zoom.setVisibility(View.VISIBLE);
    }

    @Override
    protected void initListOnItemLongClick(AdapterView<?> adapterView, View view, int position, long id) {

    }

    @Override
    protected void load_conversation() {
        LheidoUtils.MmsTask loadTask = new LheidoUtils.MmsTask(getActivity(), conversationId) {
            @Override
            protected void onProgressUpdate(Message... prog) {
                if (this.act.get() != null) {
                    add__(prog[0], 1);
                }
            }
        };
        loadTask.execTask();
    }

    @Override
    protected void load_more_conversation(final long last_id, final int index, final int top, final int start_count) {
        LheidoUtils.MmsTask more = new LheidoUtils.MmsTask(getActivity(), conversationId, last_id) {
            @Override
            protected void onProgressUpdate(Message... prog) {
                if (this.act.get() != null) {
                    Message_list.add(prog[0]);
                }
            }

            @Override
            protected void onPreExecute() {
                super.onPreExecute();
            }

            @Override
            protected void onPostExecute(Boolean result) {
                if (act.get() != null) {
                    if (!result)
                        Toast.makeText(context, "Problme gnration conversation", Toast.LENGTH_LONG).show();
                    swipeLayout.setRefreshing(false);
                    mAdapter.notifyDataSetChanged();
                    int finalposition = index + liste.getCount() - start_count;
                    liste.setSelectionFromTop(finalposition, top);
                }
            }
        };
        more.execTask();
    }
}




Java Source Code List

com.lheidosms.adapter.ContactsListAdapter.java
com.lheidosms.adapter.ConversationAdapter.java
com.lheidosms.adapter.ListeConversationsAdapter.java
com.lheidosms.adapter.MMSAdapter.java
com.lheidosms.adapter.SmsAdapter.java
com.lheidosms.adapter.SmsBaseAdapter.java
com.lheidosms.adapter.ViewPagerAdapter.java
com.lheidosms.app.AutoComplete.java
com.lheidosms.app.Global.java
com.lheidosms.app.MainLheidoSMS.java
com.lheidosms.fragment.MMSFragment.java
com.lheidosms.fragment.NavigationDrawerFragment.java
com.lheidosms.fragment.SMSFragment.java
com.lheidosms.fragment.SmsBaseFragment.java
com.lheidosms.preference.LheidoSMSPreferenceOldApi.java
com.lheidosms.preference.LheidoSMSPreference.java
com.lheidosms.preference.PrefConversationFragment.java
com.lheidosms.preference.PrefGeneralFragment.java
com.lheidosms.preference.PrefListConversationsFragment.java
com.lheidosms.preference.PrefReceiveFragment.java
com.lheidosms.receiver.BootReceiver.java
com.lheidosms.receiver.LheidoBaseReceiver.java
com.lheidosms.receiver.MainServiceReceiver.java
com.lheidosms.receiver.MmsFragmentReceiver.java
com.lheidosms.receiver.SmsFragmentReceiver.java
com.lheidosms.receiver.SmsReceiver.java
com.lheidosms.service.DeleteOldSMSService.java
com.lheidosms.service.LheidoSMSService.java
com.lheidosms.service.MainService.java
com.lheidosms.service.RemoveConversationService.java
com.lheidosms.utils.BuildFragment.java
com.lheidosms.utils.LheidoContact.java
com.lheidosms.utils.LheidoUtils.java
com.lheidosms.utils.Message.java