]> gitweb.fperrin.net Git - Dictionary.git/blobdiff - src/com/hughes/android/dictionary/DownloadActivity.java
Theme, different color rows, dictionary_info, long click begin.
[Dictionary.git] / src / com / hughes / android / dictionary / DownloadActivity.java
old mode 100755 (executable)
new mode 100644 (file)
index a783402..0ed8454
@@ -1,3 +1,17 @@
+// 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
@@ -39,7 +53,7 @@ public class DownloadActivity extends Activity {
   /** 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
@@ -79,6 +93,9 @@ public class DownloadActivity extends Activity {
           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
@@ -105,6 +122,15 @@ public class DownloadActivity extends Activity {
           \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