1 package jarmos.app.activity;
7 import java.io.FileOutputStream;
8 import java.io.IOException;
10 import android.app.Activity;
11 import android.content.Context;
12 import android.os.Bundle;
13 import android.util.Log;
14 import android.webkit.WebView;
15 import android.webkit.WebViewClient;
16 import android.widget.Toast;
29 private WebView browser;
35 super.onCreate(icicle);
37 browser =
new WebView(
this);
38 setContentView(browser);
43 m = Const.getModelManager(getApplicationContext(), getIntent());
45 Log.e(
"BrowseActivity",
"Creation of ModelManager failed", e);
52 browser.setWebViewClient(
new WebViewClient() {
53 public void onReceivedError(WebView view,
int errorCode, String description, String failingUrl) {
54 Toast.makeText(BrowseActivity.this,
"Sorry, no informational page was supplied with this problem",
55 Toast.LENGTH_LONG).show();
61 browser.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
63 String file = m.getModelXMLTagValue(
"infohtml");
65 browser.loadUrl(m.getModelURI() +
"/" + file);
66 Log.d(
"browser", m.getModelURI() +
"/" + file);
68 String img = m.getModelXMLTagValue(
"model.description.image");
69 img = img != null ?
"<img src='" + m.getModelURI() +
"/" + img +
"' alt=''/>" :
"";
70 String html =
"<html><body bgcolor='Black'><center><font color='white'>Sorry, this model does not have any information page associated with it."
71 + img +
"</font></center>" +
"</body></html>";
73 FileOutputStream f = openFileOutput(
"noinfo.html", Context.MODE_PRIVATE);
74 f.write(html.getBytes());
76 }
catch (IOException e) {
77 Log.e(
"BrowseActivity",
"Error saving a temporary html file", e);
80 browser.loadUrl(
"file://" + Const.APP_DATA_DIRECTORY +
"/noinfo.html");
90 getParent().onBackPressed();
void onCreate(Bundle icicle)
This class serves as base class for accessing various types of models at different locations...
An activity which displays URLs in a simple browser.
This Exception gets thrown when an error occurs regarding the functionality of the ModelManager...
Class that contains miscellaneous JaRMoS specific constants and static functions. ...