Android Open Source - digital-ocean-swimmer Size 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 .ja v a2  s  . c  o m
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.yassirh.digitalocean.R;
import com.yassirh.digitalocean.model.Size;

import java.util.Formatter;
import java.util.List;
import java.util.Locale;

public class SizeAdapter extends BaseAdapter {
    private List<Size> data;
    private static LayoutInflater inflater=null;
    public SizeAdapter(Activity activity, List<Size> 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.size_list_row, parent, false);

        final Size size = data.get(position);
        TextView ramcpuTextView = (TextView)vi.findViewById(;
        TextView diskTextView = (TextView)vi.findViewById(;
        TextView transferTextView = (TextView)vi.findViewById(;
        TextView monthlyPriceTextView = (TextView)vi.findViewById(;
        TextView hourlyPriceTextView = (TextView)vi.findViewById(;
        ramcpuTextView.setText(size.getSlug().toUpperCase(Locale.US) + "/" + size.getCpu() + "CPU");
        diskTextView.setText(size.getDisk() +"GB SSD DISK");
        transferTextView.setText(size.getTransfer() + "TB TRANSFER");
        Formatter formatter = new Formatter();
        monthlyPriceTextView.setText("$" + size.getCostPerMonth()+"/mo");
        hourlyPriceTextView.setText("$" + formatter.format("%1.5f",size.getCostPerHour())+"/hour");
        return vi;

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

Java Source Code List