Android Open Source - acs-android-sdk Checkin Adapter

From Project

Back to project page acs-android-sdk.


The source code is released under:

Apache License

If you think the Android project acs-android-sdk 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

//from   w w  w  . j  a v  a 2  s . c om
import java.util.List;

import org.json.JSONException;
import org.json.JSONObject;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

// Adapter to show a list of checkins
public class CheckinAdapter extends BaseAdapter {
    private Context context;
    private boolean isPlaceView;
    private List<JSONObject> listCheckin;

    public CheckinAdapter(Context context, List<JSONObject> listCheckin, boolean isPlaceView) {
        this.context = context;
        this.listCheckin = listCheckin;
        this.isPlaceView = isPlaceView;

    public int getCount() {
        return listCheckin.size();

    public Object getItem(int position) {
        return listCheckin.get(position);

    public long getItemId(int position) {
        return position;

    public View getView(int position, View convertView, ViewGroup viewGroup) {
      JSONObject entry = listCheckin.get(position);
        if (convertView == null) {
            LayoutInflater inflater = (LayoutInflater) context
            convertView = inflater.inflate(R.layout.checkin_row, null);
        TextView checkinInfo = (TextView) convertView.findViewById(;
        if (isPlaceView) {
      try {
        JSONObject userJSON = entry.getJSONObject("user");
        checkinInfo.setText( userJSON.getString("first_name") + " checked in");
      } catch (JSONException e) {
        } else {
          try {
        JSONObject placeJSON = entry.getJSONObject("place");
        checkinInfo.setText("Checked in at " + placeJSON.getString("name") );
      } catch (JSONException e) {

        TextView checkinDate = (TextView) convertView.findViewById(;
        try {
    } catch (JSONException e) {

        return convertView;


Java Source Code List