Android Open Source - digital-ocean-swimmer Region Adapter

From Project

Back to project page digital-ocean-swimmer.


The source code is released under:

MIT License

If you think the Android project digital-ocean-swimmer 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.yassirh.digitalocean.ui;
/*w w w . j ava  2  s .co m*/
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.yassirh.digitalocean.R;
import com.yassirh.digitalocean.model.Region;
import com.yassirh.digitalocean.utils.ApiHelper;

import java.util.List;

public class RegionAdapter extends BaseAdapter {
    private List<Region> data;
    private static LayoutInflater inflater=null;
    public RegionAdapter(Activity activity, List<Region> data) {;
        inflater = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

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

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

    public long getItemId(int position) {
      return (long)position;
    public View getView(int position, View convertView, ViewGroup parent) {
        View vi=convertView;
            vi = inflater.inflate(R.layout.region_list_row, parent, false);

        final Region region = data.get(position);
        TextView nameTextView = (TextView)vi.findViewById(;
        TextView featuresTextView = (TextView)vi.findViewById(;
        ImageView flagImageView = (ImageView)vi.findViewById(;
        flagImageView.setImageResource(ApiHelper.getLocationFlag(region.getName(), region.isAvailable()));
      featuresTextView.setText(region.getFeatures().replace(";", ", "));        
        return vi;

    public void setData(List<Region> data) { = data;

Java Source Code List