Skip to content

Commit

Permalink
check if line has a style, fixes #16
Browse files Browse the repository at this point in the history
  • Loading branch information
grote committed Nov 13, 2013
1 parent dde3632 commit 8ee84dc
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/de/grobox/liberario/TripsActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -271,17 +271,19 @@ static public void addLineBox(Context context, ViewGroup lineLayout, Line line,
}

TextView transportsView = (TextView) LayoutInflater.from(context).inflate(R.layout.line_box, null);
transportsView.setText(line.label.substring(1));

GradientDrawable line_box = (GradientDrawable) context.getResources().getDrawable(R.drawable.line_box);
line_box.setColor(line.style.backgroundColor);
if(line.style != null) {
GradientDrawable line_box = (GradientDrawable) context.getResources().getDrawable(R.drawable.line_box);
line_box.setColor(line.style.backgroundColor);

// change shape and mutate before to not share state with other instances
line_box.mutate();
if(line.style.shape == Shape.CIRCLE) line_box.setShape(GradientDrawable.OVAL);
// change shape and mutate before to not share state with other instances
line_box.mutate();
if(line.style.shape == Shape.CIRCLE) line_box.setShape(GradientDrawable.OVAL);

transportsView.setText(line.label.substring(1));
transportsView.setBackgroundDrawable(line_box);
transportsView.setTextColor(line.style.foregroundColor);
transportsView.setBackgroundDrawable(line_box);
transportsView.setTextColor(line.style.foregroundColor);
}

// set margin, because setting in in xml didn't work
LinearLayout.LayoutParams llp = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
Expand Down

0 comments on commit 8ee84dc

Please sign in to comment.