Created
February 8, 2016 13:15
-
-
Save billmote/7c56d692fc63183635df to your computer and use it in GitHub Desktop.
This file contains hidden or 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 com.example.helloworld.ui.adapters; | |
import android.content.Context; | |
import android.view.LayoutInflater; | |
import android.view.View; | |
import android.view.ViewGroup; | |
import android.widget.ImageView; | |
import android.widget.TextView; | |
import com.exacttarget.etpushsdk.adapter.CloudPageListAdapter; | |
import com.exacttarget.etpushsdk.data.Message; | |
import com.example.helloworld.R; | |
public class MyCloudPageListAdapter extends CloudPageListAdapter { | |
private Context context; | |
public MyCloudPageListAdapter(Context context) { | |
super(context); | |
this.context = context; | |
} | |
@Override | |
public View getView(int position, View convertView, ViewGroup parent) { | |
Message message = (Message) getItem(position); | |
ViewHolder holder; | |
if (convertView == null) { | |
LayoutInflater layoutInflater = LayoutInflater.from(context); | |
convertView = layoutInflater.inflate(R.layout.cloudpage_list_item, parent, false); | |
holder = new ViewHolder(convertView); | |
convertView.setTag(holder); | |
} else { | |
holder = (ViewHolder) convertView.getTag(); | |
} | |
if (message.getRead()) { | |
holder.icon.setImageResource(R.drawable.read); | |
} else { | |
holder.icon.setImageResource(R.drawable.unread); | |
} | |
holder.subject.setText(message.getSubject()); | |
holder.time.setText(android.text.format.DateFormat.format("MMM dd yyyy - hh:mm a", message.getStartDate())); | |
return convertView; | |
} | |
private static class ViewHolder { | |
private ImageView icon; | |
private TextView subject; | |
private TextView time; | |
ViewHolder(View view) { | |
icon = (ImageView) view.findViewById(R.id.readUnreadIcon); | |
subject = (TextView) view.findViewById(R.id.cloudpageSubject); | |
time = (TextView) view.findViewById(R.id.timeTextView); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment