Search in sources :

Example 1 with RideHistoryForJson

use of br.ufrj.caronae.models.modelsforjson.RideHistoryForJson in project caronae-android by caronae.

the class RidesHistoryAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(final RidesHistoryAdapter.ViewHolder holder, int position) {
    final RideHistoryForJson historyRide = historyRides.get(position);
    int color = 0, bgRes = 0;
    if (historyRide.getZone().equals("Centro")) {
        color = ContextCompat.getColor(activity, R.color.zone_centro);
        bgRes = R.drawable.bg_bt_raise_zone_centro;
    }
    if (historyRide.getZone().equals("Zona Sul")) {
        color = ContextCompat.getColor(activity, R.color.zone_sul);
        bgRes = R.drawable.bg_bt_raise_zone_sul;
    }
    if (historyRide.getZone().equals("Zona Oeste")) {
        color = ContextCompat.getColor(activity, R.color.zone_oeste);
        bgRes = R.drawable.bg_bt_raise_zone_oeste;
    }
    if (historyRide.getZone().equals("Zona Norte")) {
        color = ContextCompat.getColor(activity, R.color.zone_norte);
        bgRes = R.drawable.bg_bt_raise_zone_norte;
    }
    if (historyRide.getZone().equals("Baixada")) {
        color = ContextCompat.getColor(activity, R.color.zone_baixada);
        bgRes = R.drawable.bg_bt_raise_zone_baixada;
    }
    if (historyRide.getZone().equals("Grande Niterói")) {
        color = ContextCompat.getColor(activity, R.color.zone_niteroi);
        bgRes = R.drawable.bg_bt_raise_zone_niteroi;
    }
    if (historyRide.getZone().equals("Outros")) {
        color = ContextCompat.getColor(activity, R.color.zone_outros);
        bgRes = R.drawable.bg_bt_raise_zone_outros;
    }
    if (historyRide.isGoing())
        holder.time_tv.setText(activity.getString(R.string.arrivedAt, historyRide.getTime() + " | "));
    else
        holder.time_tv.setText(activity.getString(R.string.leftAt, historyRide.getTime() + " | "));
    holder.time_tv.setTextColor(color);
    holder.date_tv.setText(Util.formatDateRemoveYear(historyRide.getDate()));
    holder.date_tv.setTextColor(color);
    holder.name_tv.setTextColor(color);
    String location;
    if (historyRide.isGoing()) {
        location = historyRide.getNeighborhood() + " ➜ " + historyRide.getHub();
    } else {
        location = historyRide.getHub() + " ➜ " + historyRide.getNeighborhood();
    }
    holder.location_tv.setText(location);
    holder.location_tv.setTextColor(color);
    User driver = historyRide.getDriver();
    if (driver != null) {
        holder.name_tv.setText(driver.getName());
        String driverPic = driver.getProfilePicUrl();
        if (driverPic != null && !driverPic.isEmpty()) {
            Picasso.with(activity).load(driverPic).placeholder(R.drawable.user_pic).error(R.drawable.user_pic).transform(new RoundedTransformation()).into(holder.photo_iv);
        } else {
            holder.photo_iv.setImageResource(R.drawable.user_pic);
        }
    }
}
Also used : RideHistoryForJson(br.ufrj.caronae.models.modelsforjson.RideHistoryForJson) User(br.ufrj.caronae.models.User) RoundedTransformation(br.ufrj.caronae.RoundedTransformation)

Aggregations

RoundedTransformation (br.ufrj.caronae.RoundedTransformation)1 User (br.ufrj.caronae.models.User)1 RideHistoryForJson (br.ufrj.caronae.models.modelsforjson.RideHistoryForJson)1