Android Open Source - cnp Posts Adapter






From Project

Back to project page cnp.

License

The source code is released under:

MIT License

If you think the Android project cnp 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.urucas.copynpaste.adapters;
/*w  w w.j  a  v a 2s  .c o m*/
import java.util.ArrayList;

import com.urucas.copynpaste.model.Post;
import com.urucas.copynpaste.R;

import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

public class PostsAdapter extends ArrayAdapter<Post>{

  public PostsAdapter(Context context, int resource, ArrayList<Post> posts) {
    super(context, resource, posts);
  }

  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
    
    LayoutInflater inflater = (LayoutInflater) this.getContext()
            .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    
    Post _post = getItem(position);
    
    View rowView = inflater.inflate(R.layout.adapter_post_item, parent, false);
    TextView data = (TextView) rowView.findViewById(R.id.postData);
         data.setText(_post.getData());
         
    return rowView;
  }
  
  public void addAll(ArrayList<Post> _posts) {
    for(int i=0; i<_posts.size();i++) {
      Post post = _posts.get(i);
      Log.i("post data", post.getData());
      this.insert(post, this.getCount());
    }
  }
}




Java Source Code List

com.urucas.copynpaste.CNPApplication.java
com.urucas.copynpaste.activities.HomeActivity.java
com.urucas.copynpaste.activities.SplashActivity.java
com.urucas.copynpaste.adapters.PostsAdapter.java
com.urucas.copynpaste.callbacks.PostsCallback.java
com.urucas.copynpaste.callbacks.UserCallback.java
com.urucas.copynpaste.controllers.ApiController.java
com.urucas.copynpaste.model.Post.java
com.urucas.copynpaste.model.User.java
com.urucas.copynpaste.parser.PostParser.java
com.urucas.copynpaste.parser.PostsParser.java
com.urucas.copynpaste.parser.UserParser.java
com.urucas.services.JSONRequestTaskHandler.java
com.urucas.services.JSONRequestTask.java
com.urucas.services.JSONRequest.java
com.urucas.services.RequestTaskHandler.java
com.urucas.services.RequestTask.java
com.urucas.utils.Utils.java