Android Open Source - CloudPaste-Android Main List View Adapter






From Project

Back to project page CloudPaste-Android.

License

The source code is released under:

MIT License

If you think the Android project CloudPaste-Android 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.alwaysallthetime.cloudpaste.adapter;
/*from  w ww  .  j a v a 2s  . c  om*/
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.alwaysallthetime.cloudpaste.R;
import com.alwaysallthetime.messagebeast.model.MessagePlus;

import java.util.List;

public class MainListViewAdapter extends ArrayAdapter<MessagePlus> {
    private List<MessagePlus> mMessages;

    public MainListViewAdapter(Context context, List<MessagePlus> messages) {
        super(context, -1, messages);
        mMessages = messages;
    }

    public void refresh(List<MessagePlus> items) {
        mMessages.clear();
        mMessages.addAll(items);
        notifyDataSetChanged();
    }

    public void removeItemAt(int position) {
        mMessages.remove(position);
        notifyDataSetChanged();;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        MessagePlus item = getItem(position);
        if(convertView == null) {
            convertView = new MainListViewAdapterLayout(getContext());
        }
        ((MainListViewAdapterLayout)convertView).setItem(item);
        return convertView;
    }

    public class MainListViewAdapterLayout extends LinearLayout {

        TextView mTextView;

        public MainListViewAdapterLayout(Context context) {
            super(context);

            LayoutInflater.from(context).inflate(R.layout.adapter_main_list, this, true);
            mTextView = (TextView) findViewById(R.id.MainListAdapterTextView);
        }

        public void setItem(MessagePlus message) {
            mTextView.setText(message.getMessage().getText());
        }
    }

}




Java Source Code List

com.alwaysallthetime.cloudpaste.BaseCloudPasteActivity.java
com.alwaysallthetime.cloudpaste.BaseLoginActivity.java
com.alwaysallthetime.cloudpaste.CloudPaste.java
com.alwaysallthetime.cloudpaste.LaunchActivity.java
com.alwaysallthetime.cloudpaste.LoginWebViewActivity.java
com.alwaysallthetime.cloudpaste.MainActivity.java
com.alwaysallthetime.cloudpaste.MessageManagerInstance.java
com.alwaysallthetime.cloudpaste.ShareToCloudPasteActivity.java
com.alwaysallthetime.cloudpaste.adapter.MainListViewAdapter.java
com.alwaysallthetime.cloudpaste.client.CloudPasteADNClient.java