OSDN Git Service

fix startup crash
authorJohn Hoford <hoford@google.com>
Tue, 10 Sep 2013 23:59:23 +0000 (16:59 -0700)
committerJohn Hoford <hoford@google.com>
Tue, 10 Sep 2013 23:59:23 +0000 (16:59 -0700)
bug:10673620
Change-Id: If1a8aad0c2258702fe4fc7048b4e82eea302169c

res/layout/filtershow_splashscreen.xml [new file with mode: 0644]
src/com/android/gallery3d/filtershow/FilterShowActivity.java

diff --git a/res/layout/filtershow_splashscreen.xml b/res/layout/filtershow_splashscreen.xml
new file mode 100644 (file)
index 0000000..06958ca
--- /dev/null
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+     Copyright (C) 2013 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+              android:layout_width="fill_parent"
+              android:layout_height="fill_parent"
+              android:orientation="vertical"
+              android:gravity="center_horizontal|center_vertical"
+              android:padding="10dip">
+
+<ProgressBar android:id="@+id/progress_bar"
+             android:layout_alignParentRight="true"
+             android:layout_width="wrap_content"
+             android:layout_height="wrap_content"
+             android:gravity="center_vertical"
+             android:visibility="visible"
+             android:paddingBottom="144dp" />
+
+</LinearLayout>
index 56ae93e..d4cb16f 100644 (file)
@@ -29,6 +29,7 @@ import android.content.pm.ActivityInfo;
 import android.content.res.Configuration;
 import android.content.res.Resources;
 import android.graphics.Bitmap;
+import android.graphics.Color;
 import android.graphics.Matrix;
 import android.graphics.Point;
 import android.graphics.Rect;
@@ -60,6 +61,7 @@ import android.widget.AdapterView.OnItemClickListener;
 import android.widget.FrameLayout;
 import android.widget.ShareActionProvider;
 import android.widget.ShareActionProvider.OnShareTargetSelectedListener;
+import android.widget.Spinner;
 import android.widget.Toast;
 
 import com.android.gallery3d.R;
@@ -186,6 +188,7 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL
 
     private ProcessingService mBoundService;
     private boolean mIsBound = false;
+    private Menu mMenu;
 
     public ProcessingService getProcessingService() {
         return mBoundService;
@@ -242,14 +245,19 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL
         }
     }
 
-    private void setupPipeline() {
-        doBindService();
+    public void updateUIAfterServiceStarted() {
+        MasterImage.setMaster(mMasterImage);
         ImageFilter.setActivityForMemoryToasts(this);
         mUserPresetsManager = new UserPresetsManager(this);
         mUserPresetsAdapter = new UserPresetsAdapter(this);
-    }
 
-    public void updateUIAfterServiceStarted() {
+        setupMasterImage();
+        setupMenu();
+        setDefaultValues();
+        fillEditors();
+        getWindow().setBackgroundDrawable(new ColorDrawable(0));
+        loadXML();
+
         fillCategories();
         loadMainPanel();
         extractXMPData();
@@ -264,16 +272,11 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL
         if (onlyUsePortrait) {
             setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
         }
-        MasterImage.setMaster(mMasterImage);
 
         clearGalleryBitmapPool();
-        setupPipeline();
-
-        setupMasterImage();
-        setDefaultValues();
-        fillEditors();
-
-        loadXML();
+        doBindService();
+        getWindow().setBackgroundDrawable(new ColorDrawable(Color.GRAY));
+        setContentView(R.layout.filtershow_splashscreen);
         UsageStatistics.onContentViewChanged(UsageStatistics.COMPONENT_EDITOR, "Main");
         UsageStatistics.onEvent(UsageStatistics.COMPONENT_EDITOR,
                 UsageStatistics.CATEGORY_LIFECYCLE, UsageStatistics.LIFECYCLE_START);
@@ -549,6 +552,8 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL
         int curveHandleSize = (int) res.getDimension(R.dimen.crop_indicator_size);
         Spline.setCurveHandle(curveHandle, curveHandleSize);
         Spline.setCurveWidth((int) getPixelsFromDip(3));
+
+        mOriginalImageUri = null;
     }
 
     private void startLoadBitmap(Uri uri) {
@@ -780,7 +785,8 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL
             }
 
             if (!result) {
-                if (!mOriginalImageUri.equals(mSelectedImageUri)) {
+                if (mOriginalImageUri != null
+                        && !mOriginalImageUri.equals(mSelectedImageUri)) {
                     mOriginalImageUri = mSelectedImageUri;
                     mOriginalPreset = null;
                     Toast.makeText(FilterShowActivity.this,
@@ -953,12 +959,15 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL
                 .getActionProvider();
         mShareActionProvider.setShareIntent(getDefaultShareIntent());
         mShareActionProvider.setOnShareTargetSelectedListener(this);
+        mMenu = menu;
+        return true;
+    }
 
-        MenuItem undoItem = menu.findItem(R.id.undoButton);
-        MenuItem redoItem = menu.findItem(R.id.redoButton);
-        MenuItem resetItem = menu.findItem(R.id.resetHistoryButton);
+    private void setupMenu(){
+        MenuItem undoItem = mMenu.findItem(R.id.undoButton);
+        MenuItem redoItem = mMenu.findItem(R.id.redoButton);
+        MenuItem resetItem = mMenu.findItem(R.id.resetHistoryButton);
         mMasterImage.getHistory().setMenuItems(undoItem, redoItem, resetItem);
-        return true;
     }
 
     @Override