Apply markup to PVR text views; addresses #191 (#474)

This commit is contained in:
Mon Zafra 2017-10-20 21:15:59 +08:00 committed by Synced Synapse
parent 45ecfc2e25
commit 206b5c9bc6
4 changed files with 19 additions and 11 deletions

View File

@ -35,6 +35,7 @@ import org.xbmc.kore.jsonrpc.ApiCallback;
import org.xbmc.kore.jsonrpc.method.PVR;
import org.xbmc.kore.jsonrpc.type.PVRType;
import org.xbmc.kore.utils.LogUtils;
import org.xbmc.kore.utils.UIUtils;
import java.util.ArrayList;
import java.util.Calendar;
@ -223,10 +224,11 @@ public class PVRChannelEPGListFragment extends Fragment
viewHolder.broadcastId = broadcastDetails.broadcastid;
viewHolder.title = broadcastDetails.title;
viewHolder.titleView.setText(broadcastDetails.title);
viewHolder.detailsView.setText(broadcastDetails.plot);
String duration = String.format(this.getContext().getString(R.string.minutes_abbrev2),
String.valueOf(broadcastDetails.runtime));
Context context = getContext();
viewHolder.titleView.setText(UIUtils.applyMarkup(context, broadcastDetails.title));
viewHolder.detailsView.setText(UIUtils.applyMarkup(context, broadcastDetails.plot));
String duration = context.getString(R.string.minutes_abbrev2,
String.valueOf(broadcastDetails.runtime));
int flags = DateUtils.FORMAT_ABBREV_ALL | DateUtils.FORMAT_SHOW_TIME;
viewHolder.startTimeView.setText(DateUtils.formatDateTime(getActivity(), broadcastDetails.starttime.getTime(), flags));

View File

@ -479,11 +479,12 @@ public class PVRChannelsListFragment extends Fragment
viewHolder.channelId = channelDetails.channelid;
viewHolder.channelName = channelDetails.channel;
viewHolder.titleView.setText(channelDetails.channel);
Context context = getContext();
viewHolder.titleView.setText(UIUtils.applyMarkup(context, channelDetails.channel));
String details = (channelDetails.broadcastnow != null)?
channelDetails.broadcastnow.title : null;
viewHolder.detailsView.setText(details);
UIUtils.loadImageWithCharacterAvatar(getContext(), hostManager,
viewHolder.detailsView.setText(UIUtils.applyMarkup(context, details));
UIUtils.loadImageWithCharacterAvatar(context, hostManager,
channelDetails.thumbnail, channelDetails.channel,
viewHolder.artView, artWidth, artHeight);

View File

@ -230,9 +230,10 @@ public class PVRRecordingsListFragment extends Fragment
viewHolder.recordingId = recordingDetails.recordingid;
viewHolder.title = recordingDetails.title;
viewHolder.titleView.setText(recordingDetails.title);
viewHolder.detailsView.setText(recordingDetails.channel);
UIUtils.loadImageWithCharacterAvatar(getContext(), hostManager,
Context context = getContext();
viewHolder.titleView.setText(UIUtils.applyMarkup(context, recordingDetails.title));
viewHolder.detailsView.setText(UIUtils.applyMarkup(context, recordingDetails.channel));
UIUtils.loadImageWithCharacterAvatar(context, hostManager,
(recordingDetails.art != null) ?
recordingDetails.art.poster : recordingDetails.icon,
recordingDetails.channel,
@ -240,7 +241,7 @@ public class PVRRecordingsListFragment extends Fragment
int runtime = recordingDetails.runtime / 60;
String duration =
recordingDetails.starttime + " | " +
String.format(this.getContext().getString(R.string.minutes_abbrev), String.valueOf(runtime));
context.getString(R.string.minutes_abbrev, String.valueOf(runtime));
viewHolder.durationView.setText(duration);
return convertView;

View File

@ -625,6 +625,9 @@ public class UIUtils {
* or derivatives.
*/
public static SpannableStringBuilder applyMarkup(Context context, String src) {
if (src == null) {
return null;
}
SpannableStringBuilder sb = new SpannableStringBuilder();
int start = src.indexOf('[');
if (start == -1) {
@ -768,6 +771,7 @@ public class UIUtils {
}
/**
* This must be called after every {@link #end()}.
* @return true if we found a close tag when there are no open tags
*/
boolean imbalanced() {