package org.r3pek.guiatv; import java.text.ParseException; import java.text.SimpleDateFormat; import android.app.Activity; import android.graphics.Color; import android.os.Bundle; import android.widget.ImageView; import android.widget.TextView; public class ProgramDetails extends Activity { private ImageView ivIcon; private TextView tvName; private TextView tvStartHour; private TextView tvEndHour; private TextView tvDuration; private TextView tvDescription; private TextView tvPrgDate; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.program_details); Program p = (Program) getIntent().getSerializableExtra("org.r3pek.guiatv.program"); String channel = (String) getIntent().getStringExtra("org.r3pek.guiatv.channel"); channel = channel.replaceAll(" ", "_").replaceAll("-", "_").replaceAll("\\+", "_").replaceAll("!", "_").replaceAll("&", "_"); channel = channel.toLowerCase(); ivIcon = (ImageView) findViewById(R.id.ivIcon); tvName = (TextView) findViewById(R.id.tvPrgName); tvStartHour = (TextView) findViewById(R.id.tvStartHour); tvEndHour = (TextView) findViewById(R.id.tvEndHour); tvDuration = (TextView) findViewById(R.id.tvDuration); tvDescription = (TextView) findViewById(R.id.tvDescription); tvPrgDate = (TextView) findViewById(R.id.tvPrgDate); SimpleDateFormat format = new SimpleDateFormat("HH:mm"); SimpleDateFormat format_ori = new SimpleDateFormat("yyyy-MM-dd HH:mm"); tvName.setText(p.getTitle()); try { tvStartHour.setText(format.format(format_ori.parse(p.getStartHour()))); tvEndHour.setText(format.format(format_ori.parse(p.getEndHour()))); } catch (ParseException e) { } tvDuration.setText((p.getDurantion() / 60 / 60) + "h" + ((p.getDurantion() / 60) % 60) + "m"); tvDescription.setText(p.getDescription()); tvPrgDate.setText("(" + getIntent().getStringExtra("org.r3pek.guiatv.day") + ")"); int res = getApplicationContext().getResources().getIdentifier(channel, "drawable", "org.r3pek.guiatv"); if (res > 0) { ivIcon.setImageResource(res); ivIcon.setBackgroundColor(Color.WHITE); } else { ivIcon.setImageResource(R.drawable.none); ivIcon.setBackgroundDrawable(null); } } }