+// Copyright 2011 Google Inc. All Rights Reserved.\r
+//\r
+// Licensed under the Apache License, Version 2.0 (the "License");\r
+// you may not use this file except in compliance with the License.\r
+// You may obtain a copy of the License at\r
+//\r
+// http://www.apache.org/licenses/LICENSE-2.0\r
+//\r
+// Unless required by applicable law or agreed to in writing, software\r
+// distributed under the License is distributed on an "AS IS" BASIS,\r
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+// See the License for the specific language governing permissions and\r
+// limitations under the License.\r
+\r
package com.hughes.android.dictionary;\r
\r
import java.io.File;\r
/** Called when the activity is first created. */\r
@Override\r
public void onCreate(final Bundle savedInstanceState) {\r
- ((DictionaryApplication)getApplication()).applyTheme(this);\r
+ //((DictionaryApplication)getApplication()).applyTheme(this);\r
\r
super.onCreate(savedInstanceState);\r
final Intent intent = getIntent();\r
final URLConnection connection = uri.openConnection();\r
contentLength = connection.getContentLength();\r
final InputStream in = connection.getInputStream();\r
+ if (in == null) {\r
+ throw new IOException("Unable to open InputStream from source: " + source);\r
+ }\r
final FileOutputStream out = new FileOutputStream(destTmpFile); \r
int bytesRead = copyStream(in, out, R.string.downloading);\r
\r
\r
setDownloadStatus(String.format(getString(R.string.downloadFinished),\r
bytesProcessed));\r
+ \r
+ // If all went well, we can exit this activity.\r
+ uiHandler.post(new Runnable() {\r
+ @Override\r
+ public void run() {\r
+ finish();\r
+ }\r
+ });\r
+ \r
} catch (IOException e) {\r
Log.e("THAD", "Error downloading file", e);\r
setDownloadStatus(String.format(getString(R.string.errorDownloadingFile), e.getLocalizedMessage()));\r