Skip to content

Commit

Permalink
Merge pull request #1032 from Meisolsson/readme-image
Browse files Browse the repository at this point in the history
Loading repository images in README
  • Loading branch information
Meisolsson committed Jan 3, 2017
2 parents 4117b76 + 01e3a4a commit 0ad99e1
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@
import android.view.View;
import android.view.ViewGroup;
import android.webkit.JavascriptInterface;
import android.webkit.URLUtil;
import android.webkit.WebSettings;

import com.github.pockethub.android.util.HtmlUtils;
import com.meisolsson.githubsdk.core.ServiceGenerator;
import com.meisolsson.githubsdk.model.Content;
import com.meisolsson.githubsdk.model.Repository;
Expand Down Expand Up @@ -47,7 +49,7 @@ public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
webview = (WebView) view;

Repository repo = getParcelableExtra(Intents.EXTRA_REPOSITORY);
final Repository repo = getParcelableExtra(Intents.EXTRA_REPOSITORY);
WebSettings settings = webview.getSettings();
settings.setJavaScriptEnabled(true);
webview.addJavascriptInterface(this, "Readme");
Expand All @@ -61,8 +63,11 @@ public void onViewCreated(View view, Bundle savedInstanceState) {
@Override
public void onNext(String s) {
super.onNext(s);
String baseUrl = String.format("https://github.com/%s/%s/raw/%s/",
repo.owner().login(), repo.name(), "master");

String data = PAGE_START + s + PAGE_END;
webview.loadDataWithBaseURL("file:///android_asset/", data, "text/html", "UTF-8", null);
webview.loadDataWithBaseURL(baseUrl, data, "text/html", "UTF-8", null);
}
});
}
Expand Down

0 comments on commit 0ad99e1

Please sign in to comment.