Last active
April 30, 2016 03:00
-
-
Save AraujoJordan/9c3e67f282d0fccc97dfc1ab95f7d8c5 to your computer and use it in GitHub Desktop.
[Nova Cursos] Aula9 - DailyExercise e Adapter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package araujo.jordan.a7minnova; | |
import java.util.Date; | |
public class DailyExercise { | |
private long id; | |
private Date exercise; | |
private boolean pulou; | |
private int porcentagem; | |
private String category; | |
public DailyExercise(long id, Date exercise, boolean pulou, int porcentagem, String category) { | |
this.id = id; | |
this.exercise = exercise; | |
this.pulou = pulou; | |
this.porcentagem = porcentagem; | |
this.category = category; | |
} | |
public String getCategory() { | |
return category; | |
} | |
public void setCategory(String category) { | |
this.category = category; | |
} | |
public long getId() { | |
return id; | |
} | |
public void setId(long id) { | |
this.id = id; | |
} | |
public Date getExercise() { | |
return exercise; | |
} | |
public void setExercise(Date exercise) { | |
this.exercise = exercise; | |
} | |
public boolean isPulou() { | |
return pulou; | |
} | |
public void setPulou(boolean pulou) { | |
this.pulou = pulou; | |
} | |
public int getPorcentagem() { | |
return porcentagem; | |
} | |
public void setPorcentagem(int porcentagem) { | |
this.porcentagem = porcentagem; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package araujo.jordan.a7minnova; | |
import android.content.Context; | |
import android.graphics.drawable.BitmapDrawable; | |
import android.support.v4.content.res.ResourcesCompat; | |
import android.view.LayoutInflater; | |
import android.view.View; | |
import android.view.ViewGroup; | |
import android.widget.ArrayAdapter; | |
import android.widget.Button; | |
import android.widget.ImageView; | |
import android.widget.TextView; | |
public class DailyExerciseAdapter extends ArrayAdapter<DailyExercise> { | |
public DailyExerciseAdapter(Context context) { | |
super(context, R.layout.card_daily_workout); | |
} | |
@Override | |
public View getView(int position, View convertView, ViewGroup parent) { | |
final View card = LayoutInflater.from(getContext()).inflate(R.layout.card_daily_workout, parent, false); | |
final DailyExercise dailyExercise = getItem(position); | |
ImageView imageView = (ImageView) card.findViewById(R.id.imageView); | |
TextView title = (TextView) card.findViewById(R.id.title); | |
TextView desc = (TextView) card.findViewById(R.id.desc); | |
Button startBtn = (Button) card.findViewById(R.id.startBtn); | |
Button jumpBtn = (Button) card.findViewById(R.id.jumpBtn); | |
title.setText(dailyExercise.getCategory()); | |
if(dailyExercise.getCategory().equals("Abdominal")) { | |
desc.setText("Faça 30 abdominais"); | |
imageView.setImageDrawable(ResourcesCompat.getDrawable(getContext().getResources(), R.drawable.abdominal, null)); | |
} | |
startBtn.setOnClickListener(new View.OnClickListener() { | |
@Override | |
public void onClick(View v) { | |
} | |
}); | |
jumpBtn.setOnClickListener(new View.OnClickListener() { | |
@Override | |
public void onClick(View v) { | |
dailyExercise.setPulou(true); | |
card.setVisibility(View.GONE); | |
} | |
}); | |
return card; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment