Skip to content

Commit

Permalink
Apply markup to PVR text views; addresses #191 (#474)
Browse files Browse the repository at this point in the history
  • Loading branch information
monzee authored and SyncedSynapse committed Oct 20, 2017
1 parent 45ecfc2 commit 206b5c9
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
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;
Expand Down Expand Up @@ -223,10 +224,11 @@ public View getView(int position, View convertView, ViewGroup parent) {
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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -479,11 +479,12 @@ public View getView(int position, View convertView, ViewGroup parent) {
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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,17 +230,18 @@ public View getView(int position, View convertView, ViewGroup parent) {
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,
viewHolder.artView, artWidth, artHeight);
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;
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/java/org/xbmc/kore/utils/UIUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -625,6 +625,9 @@ public static void setRepeatButton(RepeatModeButton button, String repeatType) {
* 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) {
Expand Down Expand Up @@ -768,6 +771,7 @@ boolean end() {
}

/**
* This must be called after every {@link #end()}.
* @return true if we found a close tag when there are no open tags
*/
boolean imbalanced() {
Expand Down

0 comments on commit 206b5c9

Please sign in to comment.