Source:
<code>private void setupMessageHandlers() { bridge.addListener("ipaSpan", new CommunicationBridge.JSEventListener() { @Override public void onMessage(String messageType, JSONObject messagePayload) { try { String text = messagePayload.getString("contents"); final int textSize = 30; TextView textView = new TextView(getActivity()); textView.setGravity(Gravity.CENTER); textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize); textView.setText(Html.fromHtml(text)); AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setView(textView); builder.show(); } catch (JSONException e) { L.logRemoteErrorIfProd(e); } } }); bridge.addListener("imageClicked", new CommunicationBridge.JSEventListener() { @Override public void onMessage(String messageType, JSONObject messagePayload) { try { String href = decodeURL(messagePayload.getString("href")); if (href.startsWith("/wiki/") || href.startsWith("./")) { PageTitle imageTitle = model.getTitle().getSite().titleForInternalLink(href); GalleryActivity.showGallery(getActivity(), model.getTitleOriginal(), imageTitle, GalleryFunnel.SOURCE_NON_LEAD_IMAGE); } else { linkHandler.onUrlClick(href); } } catch (JSONException e) { L.logRemoteErrorIfProd(e); } } }); bridge.addListener("mediaClicked", new CommunicationBridge.JSEventListener() { @Override public void onMessage(String messageType, JSONObject messagePayload) { try { String href = decodeURL(messagePayload.getString("href")); <START> String title = RbSwitch.INSTANCE.isRestBaseEnabled() <END> ? href.replaceFirst("./", "") : href.replaceFirst("/wiki/", ""); GalleryActivity.showGallery(getActivity(), model.getTitleOriginal(), new PageTitle(title, model.getTitle().getSite()), GalleryFunnel.SOURCE_NON_LEAD_IMAGE); } catch (JSONException e) { L.logRemoteErrorIfProd(e); } } }); }</code><technical_language>question do replacements unconditionally. if a page is saved cached</technical_language>

Target:
private void setupMessageHandlers() { bridge.addListener("ipaSpan", new CommunicationBridge.JSEventListener() { @Override public void onMessage(String messageType, JSONObject messagePayload) { try { String text = messagePayload.getString("contents"); final int textSize = 30; TextView textView = new TextView(getActivity()); textView.setGravity(Gravity.CENTER); textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize); textView.setText(Html.fromHtml(text)); AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setView(textView); builder.show(); } catch (JSONException e) { L.logRemoteErrorIfProd(e); } } }); bridge.addListener("imageClicked", new CommunicationBridge.JSEventListener() { @Override public void onMessage(String messageType, JSONObject messagePayload) { try { String href = decodeURL(messagePayload.getString("href")); if (href.startsWith("/wiki/") || href.startsWith("./")) { PageTitle imageTitle = model.getTitle().getSite().titleForInternalLink(href); GalleryActivity.showGallery(getActivity(), model.getTitleOriginal(), imageTitle, GalleryFunnel.SOURCE_NON_LEAD_IMAGE); } else { linkHandler.onUrlClick(href); } } catch (JSONException e) { L.logRemoteErrorIfProd(e); } } }); bridge.addListener("mediaClicked", new CommunicationBridge.JSEventListener() { @Override public void onMessage(String messageType, JSONObject messagePayload) { try { String href = decodeURL(messagePayload.getString("href")); String title = href.replaceFirst("./", "").replaceFirst("/wiki/", ""); GalleryActivity.showGallery(getActivity(), model.getTitleOriginal(), new PageTitle(title, model.getTitle().getSite()), GalleryFunnel.SOURCE_NON_LEAD_IMAGE); } catch (JSONException e) { L.logRemoteErrorIfProd(e); } } }); }