|
@ -15,6 +15,7 @@ import gr.thmmy.mthmmy.base.BaseApplication; |
|
|
import gr.thmmy.mthmmy.base.BaseFragment; |
|
|
import gr.thmmy.mthmmy.base.BaseFragment; |
|
|
import gr.thmmy.mthmmy.model.TopicSummary; |
|
|
import gr.thmmy.mthmmy.model.TopicSummary; |
|
|
import gr.thmmy.mthmmy.utils.RelativeTimeTextView; |
|
|
import gr.thmmy.mthmmy.utils.RelativeTimeTextView; |
|
|
|
|
|
import timber.log.Timber; |
|
|
|
|
|
|
|
|
class UnreadAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> { |
|
|
class UnreadAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> { |
|
|
private final List<TopicSummary> unreadList; |
|
|
private final List<TopicSummary> unreadList; |
|
@ -69,8 +70,15 @@ class UnreadAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> { |
|
|
viewHolder.mTitleView.setText(unreadList.get(holder.getAdapterPosition()).getSubject()); |
|
|
viewHolder.mTitleView.setText(unreadList.get(holder.getAdapterPosition()).getSubject()); |
|
|
|
|
|
|
|
|
String dateTimeString=unreadList.get(holder.getAdapterPosition()).getDateTimeModified(); |
|
|
String dateTimeString=unreadList.get(holder.getAdapterPosition()).getDateTimeModified(); |
|
|
if(BaseApplication.getInstance().isDisplayRelativeTimeEnabled()) |
|
|
if(BaseApplication.getInstance().isDisplayRelativeTimeEnabled()){ |
|
|
viewHolder.mDateTimeView.setReferenceTime(Long.valueOf(dateTimeString)); |
|
|
try{ |
|
|
|
|
|
viewHolder.mDateTimeView.setReferenceTime(Long.valueOf(dateTimeString)); |
|
|
|
|
|
} |
|
|
|
|
|
catch(NumberFormatException e){ |
|
|
|
|
|
Timber.e(e, "Invalid number format."); |
|
|
|
|
|
viewHolder.mDateTimeView.setText(dateTimeString); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
else |
|
|
else |
|
|
viewHolder.mDateTimeView.setText(dateTimeString); |
|
|
viewHolder.mDateTimeView.setText(dateTimeString); |
|
|
|
|
|
|
|
@ -89,14 +97,11 @@ class UnreadAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> { |
|
|
markReadViewHolder.text.setText(unreadList.get(holder.getAdapterPosition()).getSubject()); |
|
|
markReadViewHolder.text.setText(unreadList.get(holder.getAdapterPosition()).getSubject()); |
|
|
markReadViewHolder.topic = unreadList.get(holder.getAdapterPosition()); |
|
|
markReadViewHolder.topic = unreadList.get(holder.getAdapterPosition()); |
|
|
|
|
|
|
|
|
markReadViewHolder.mView.setOnClickListener(new View.OnClickListener() { |
|
|
markReadViewHolder.mView.setOnClickListener(v -> { |
|
|
@Override |
|
|
if (null != mListener) { |
|
|
public void onClick(View v) { |
|
|
// Notify the active callbacks interface (the activity, if the
|
|
|
if (null != mListener) { |
|
|
// fragment is attached to one) that an item has been selected.
|
|
|
// Notify the active callbacks interface (the activity, if the
|
|
|
markReadListener.onMarkReadInteraction(unreadList.get(holder.getAdapterPosition()).getTopicUrl()); |
|
|
// fragment is attached to one) that an item has been selected.
|
|
|
|
|
|
markReadListener.onMarkReadInteraction(unreadList.get(holder.getAdapterPosition()).getTopicUrl()); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|