Android Open Source - bumper Accident Information Adapter






From Project

Back to project page bumper.

License

The source code is released under:

MIT License

If you think the Android project bumper 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.varwise.bumper;
/*  w w w.  ja  v a 2s . c  om*/
import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.CheckBox;
import android.widget.RelativeLayout;
import android.widget.TextView;

import java.util.ArrayList;

/**
 * Created by rembam on 12.07.14.
 */
public class AccidentInformationAdapter extends ArrayAdapter<AccidentInformation> {

    private ArrayList<AccidentInformation> items;
    private int textViewResourceId;
    public AccidentInformationAdapter(Context context, int textViewResourceId, ArrayList<AccidentInformation> items) {
        super(context, textViewResourceId, items);
        this.textViewResourceId = textViewResourceId;
        this.items = items;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        RelativeLayout layout;
        View v = convertView;

        if (v == null) {
            layout = new RelativeLayout(getContext());
            LayoutInflater vi = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            v = vi.inflate(textViewResourceId, layout, true);


        }
        else{
            layout = (RelativeLayout) convertView;
        }

        AccidentInformation accidentInformation = items.get(position);

        if (accidentInformation != null) {
            TextView numberTV = (TextView) layout.findViewById(R.id.numer233322);
            TextView line = (TextView) layout.findViewById(R.id.line);

            if (numberTV != null) {
                if(accidentInformation.getNumber()== -1) {
                    numberTV.setText("");
                }
                else{
                    numberTV.setText(ordinal(accidentInformation.getNumber()));

                }
            }

            if (line != null) {
                if (accidentInformation.getNumber() == -1) {
                    line.setTextColor(Color.GRAY);
                    line.setText("Click to add new accident...");
                } else {
                    line.setText(accidentInformation.getDateSimpleFormat());
                }
            }

        }
        return v;
    }

    public static String ordinal(int i) {
        String[] sufixes = new String[] { "th", "st", "nd", "rd", "th", "th", "th", "th", "th", "th" };
        switch (i % 100) {
            case 11:
            case 12:
            case 13:
                return i + "th";
            default:
                return i + sufixes[i % 10];

        }
    }

}




Java Source Code List

com.varwise.bumper.AccidentInformationAdapter.java
com.varwise.bumper.AccidentInformation.java
com.varwise.bumper.ApplicationTest.java
com.varwise.bumper.ChooseLocationScreen.java
com.varwise.bumper.DocumentsCheckScreen.java
com.varwise.bumper.EditScreen.java
com.varwise.bumper.HealthQuestionScreen.java
com.varwise.bumper.ImageAdapter.java
com.varwise.bumper.InsuranceScreen.java
com.varwise.bumper.MainScreen.java
com.varwise.bumper.MoveVehiclesScreen.java
com.varwise.bumper.ObstructQuestionScreen.java
com.varwise.bumper.OffendersStatement.java
com.varwise.bumper.PhotoViewFullScreen.java
com.varwise.bumper.PhotoViewScreen.java
com.varwise.bumper.ScreenCheck.java
com.varwise.bumper.ScreenDB.java
com.varwise.bumper.ScreenInformationAdapter.java
com.varwise.bumper.ScreenInformation.java
com.varwise.bumper.VictimQuestionScreen.java