Search in sources :

Example 1 with NewChatMsgIndicator

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

the class MyRidesAdapter method configureMyActiveRides.

private void configureMyActiveRides(int position, final MyRidesAdapter.ViewHolder holder) {
    final RideForJson rideOffer = (RideForJson) rides.get(position);
    int color = Util.getColorbyZone(rideOffer.getZone());
    holder.location_tv.setTextColor(color);
    holder.photo_iv.setBorderColor(color);
    String profilePicUrl = rideOffer.getDriver().getProfilePicUrl();
    if (profilePicUrl != null && !profilePicUrl.isEmpty()) {
        Picasso.with(activity).load(profilePicUrl).placeholder(R.drawable.user_pic).error(R.drawable.user_pic).transform(new RoundedTransformation()).into(holder.photo_iv);
    }
    String timeText;
    if (rideOffer.isGoing())
        timeText = activity.getResources().getString(R.string.arrivingAt, Util.formatTime(rideOffer.getTime()));
    else
        timeText = activity.getResources().getString(R.string.leavingAt, Util.formatTime(rideOffer.getTime()));
    holder.time_tv.setText(timeText);
    holder.date_tv.setText(Util.formatBadDateWithoutYear(rideOffer.getDate()));
    holder.name_tv.setText(rideOffer.getDriver().getName());
    String location;
    if (rideOffer.isGoing())
        location = rideOffer.getNeighborhood() + " ➜ " + rideOffer.getHub();
    else
        location = rideOffer.getHub() + " ➜ " + rideOffer.getNeighborhood();
    holder.location_tv.setText(location);
    holder.layout.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            NewChatMsgIndicator.deleteAll(NewChatMsgIndicator.class, "db_id = ?", rideOffer.getDbId() + "");
            holder.newMsgIndicator_iv.setVisibility(View.INVISIBLE);
            Intent intent = new Intent(activity, ActiveRideAct.class);
            intent.putExtra("ride", rideOffer);
            activity.startActivity(intent);
            activity.overridePendingTransition(R.anim.anim_right_slide_in, R.anim.anim_left_slide_out);
        }
    });
    boolean found = false;
    for (NewChatMsgIndicator newChatMsgIndicator : newChatMsgIndicatorList) {
        if (newChatMsgIndicator.getDbId() == rideOffer.getDbId()) {
            holder.newMsgIndicator_iv.setVisibility(View.VISIBLE);
            found = true;
            break;
        }
    }
    if (!found)
        holder.newMsgIndicator_iv.setVisibility(View.INVISIBLE);
}
Also used : ActiveRideAct(br.ufrj.caronae.acts.ActiveRideAct) RideForJson(br.ufrj.caronae.models.modelsforjson.RideForJson) NewChatMsgIndicator(br.ufrj.caronae.models.NewChatMsgIndicator) RoundedTransformation(br.ufrj.caronae.RoundedTransformation) Intent(android.content.Intent) ImageView(android.widget.ImageView) CircleImageView(de.hdodenhof.circleimageview.CircleImageView) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView)

Example 2 with NewChatMsgIndicator

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

the class MyActiveRidesAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(final ViewHolder viewHolder, final int position) {
    final RideForJson rideOffer = ridesList.get(position);
    int color = ContextCompat.getColor(activity, R.color.zone_outros);
    int bgRes = R.drawable.bg_bt_raise_zone_outros;
    if (rideOffer.getZone().equals("Centro")) {
        color = ContextCompat.getColor(activity, R.color.zone_centro);
        bgRes = R.drawable.bg_bt_raise_zone_centro;
    }
    if (rideOffer.getZone().equals("Zona Sul")) {
        color = ContextCompat.getColor(activity, R.color.zone_sul);
        bgRes = R.drawable.bg_bt_raise_zone_sul;
    }
    if (rideOffer.getZone().equals("Zona Oeste")) {
        color = ContextCompat.getColor(activity, R.color.zone_oeste);
        bgRes = R.drawable.bg_bt_raise_zone_oeste;
    }
    if (rideOffer.getZone().equals("Zona Norte")) {
        color = ContextCompat.getColor(activity, R.color.zone_norte);
        bgRes = R.drawable.bg_bt_raise_zone_norte;
    }
    if (rideOffer.getZone().equals("Baixada")) {
        color = ContextCompat.getColor(activity, R.color.zone_baixada);
        bgRes = R.drawable.bg_bt_raise_zone_baixada;
    }
    if (rideOffer.getZone().equals("Grande Niterói")) {
        color = ContextCompat.getColor(activity, R.color.zone_niteroi);
        bgRes = R.drawable.bg_bt_raise_zone_niteroi;
    }
    viewHolder.location_tv.setTextColor(color);
    String profilePicUrl = rideOffer.getDriver().getProfilePicUrl();
    if (profilePicUrl != null && !profilePicUrl.isEmpty()) {
        Picasso.with(activity).load(profilePicUrl).placeholder(R.drawable.user_pic).error(R.drawable.user_pic).transform(new RoundedTransformation()).into(viewHolder.photo_iv);
    }
    if (App.getUser().getDbId() != rideOffer.getDriver().getDbId())
        viewHolder.photo_iv.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View view) {
                Intent intent = new Intent(activity, ProfileAct.class);
                intent.putExtra("user", new Gson().toJson(rideOffer.getDriver()));
                intent.putExtra("from", "myactiveridesadapter");
                activity.startActivity(intent);
            }
        });
    String timeText;
    if (rideOffer.isGoing())
        timeText = activity.getResources().getString(R.string.arrivingAt, Util.formatTime(rideOffer.getTime()));
    else
        timeText = activity.getResources().getString(R.string.leavingAt, Util.formatTime(rideOffer.getTime()));
    viewHolder.time_tv.setText(timeText);
    viewHolder.date_tv.setText(Util.formatBadDateWithoutYear(rideOffer.getDate()));
    viewHolder.name_tv.setText(rideOffer.getDriver().getName());
    String location;
    if (rideOffer.isGoing())
        location = rideOffer.getNeighborhood() + " ➜ " + rideOffer.getHub();
    else
        location = rideOffer.getHub() + " ➜ " + rideOffer.getNeighborhood();
    viewHolder.location_tv.setText(location);
    viewHolder.cardView.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            NewChatMsgIndicator.deleteAll(NewChatMsgIndicator.class, "db_id = ?", rideOffer.getDbId() + "");
            viewHolder.newMsgIndicator_iv.setVisibility(View.INVISIBLE);
            int colorChat = ContextCompat.getColor(activity, R.color.gray);
            viewHolder.newMsgIndicator_iv.setColorFilter(colorChat);
            Intent intent = new Intent(activity, ActiveRideAct.class);
            intent.putExtra("ride", rideOffer);
            activity.startActivity(intent);
        }
    });
    final int finalColor = color;
    final int finalBgRes = bgRes;
    final String finallocation = location;
    viewHolder.newMsgIndicator_iv.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            List<ChatAssets> l = ChatAssets.find(ChatAssets.class, "ride_id = ?", rideOffer.getDbId() + "");
            if (l == null || l.isEmpty())
                new ChatAssets(rideOffer.getDbId() + "", finallocation, finalColor, finalBgRes, Util.formatBadDateWithoutYear(rideOffer.getDate()), Util.formatTime(rideOffer.getTime())).save();
            Intent intent = new Intent(activity, ChatAct.class);
            intent.putExtra("rideId", rideOffer.getDbId() + "");
            activity.startActivity(intent);
        }
    });
    boolean found = false;
    for (NewChatMsgIndicator newChatMsgIndicator : newChatMsgIndicatorList) {
        if (newChatMsgIndicator.getDbId() == rideOffer.getDbId()) {
            viewHolder.newMsgIndicator_iv.setVisibility(View.VISIBLE);
            found = true;
            break;
        }
    }
    if (!found) {
        int colorChat = ContextCompat.getColor(activity, R.color.gray);
        viewHolder.newMsgIndicator_iv.setColorFilter(colorChat);
        viewHolder.newMsgIndicator_iv.setVisibility(View.INVISIBLE);
    }
}
Also used : ActiveRideAct(br.ufrj.caronae.acts.ActiveRideAct) RideForJson(br.ufrj.caronae.models.modelsforjson.RideForJson) ChatAssets(br.ufrj.caronae.models.ChatAssets) NewChatMsgIndicator(br.ufrj.caronae.models.NewChatMsgIndicator) Gson(com.google.gson.Gson) Intent(android.content.Intent) ImageView(android.widget.ImageView) CircleImageView(de.hdodenhof.circleimageview.CircleImageView) View(android.view.View) CardView(android.support.v7.widget.CardView) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) RoundedTransformation(br.ufrj.caronae.RoundedTransformation) List(java.util.List) ChatAct(br.ufrj.caronae.acts.ChatAct)

Aggregations

Intent (android.content.Intent)2 RecyclerView (android.support.v7.widget.RecyclerView)2 View (android.view.View)2 ImageView (android.widget.ImageView)2 TextView (android.widget.TextView)2 RoundedTransformation (br.ufrj.caronae.RoundedTransformation)2 ActiveRideAct (br.ufrj.caronae.acts.ActiveRideAct)2 NewChatMsgIndicator (br.ufrj.caronae.models.NewChatMsgIndicator)2 RideForJson (br.ufrj.caronae.models.modelsforjson.RideForJson)2 CircleImageView (de.hdodenhof.circleimageview.CircleImageView)2 CardView (android.support.v7.widget.CardView)1 ChatAct (br.ufrj.caronae.acts.ChatAct)1 ChatAssets (br.ufrj.caronae.models.ChatAssets)1 Gson (com.google.gson.Gson)1 List (java.util.List)1