OSDN Git Service

Check getFileInfo is null
authorjruesga <jorge@ruesga.com>
Thu, 18 Oct 2012 23:02:29 +0000 (01:02 +0200)
committerjruesga <jorge@ruesga.com>
Thu, 18 Oct 2012 23:02:29 +0000 (01:02 +0200)
src/com/cyanogenmod/explorer/activities/BookmarksActivity.java
src/com/cyanogenmod/explorer/activities/NavigationActivity.java
src/com/cyanogenmod/explorer/activities/SearchActivity.java
tests/src/com/cyanogenmod/explorer/commands/shell/ListCommandTest.java

index 71cd07f..b05149d 100644 (file)
@@ -232,8 +232,17 @@ public class BookmarksActivity extends Activity implements OnItemClickListener,
             // Check that the bookmark exists
             try {
                 FileSystemObject fso = CommandHelper.getFileInfo(this, path, null);
-                intent.putExtra(NavigationActivity.EXTRA_BOOKMARK_SELECTION, fso);
-                setResult(RESULT_OK, intent);
+                if (fso != null) {
+                    intent.putExtra(NavigationActivity.EXTRA_BOOKMARK_SELECTION, fso);
+                    setResult(RESULT_OK, intent);
+                } else {
+                    // The bookmark not exists, delete the user-defined bookmark
+                    try {
+                        Bookmark b = Bookmarks.getBookmark(getContentResolver(), path);
+                        Bookmarks.removeBookmark(this, b);
+                        refresh();
+                    } catch (Exception ex) {/**NON BLOCK**/}
+                }
             } catch (Exception e) {
                 // Capture the exception
                 ExceptionUtil.translateException(this, e);
index ad95f68..25c8f9e 100644 (file)
@@ -1122,8 +1122,11 @@ public class NavigationActivity extends Activity
                 String path = ((NavigationViewInfoParcelable)h.getItem()).getCurrentDir();
 
                 try {
-                    CommandHelper.getFileInfo(this, path, null);
-                    break;
+                    FileSystemObject info = CommandHelper.getFileInfo(this, path, null);
+                    if (info != null) {
+                        break;
+                    }
+                    this.mHistory.remove(this.mHistory.size() - 1);
                 } catch (Exception e) {
                     ExceptionUtil.translateException(this, e, true, false);
                     this.mHistory.remove(this.mHistory.size() - 1);
index c775545..de653a4 100644 (file)
@@ -956,17 +956,24 @@ public class SearchActivity extends Activity
             // Check that the bookmark exists
             try {
                 FileSystemObject fso = CommandHelper.getFileInfo(this, item.getFullPath(), null);
-                if (FileHelper.isDirectory(fso)) {
-                    intent.putExtra(NavigationActivity.EXTRA_SEARCH_ENTRY_SELECTION, fso);
-                    intent.putExtra(
-                            NavigationActivity.EXTRA_SEARCH_LAST_SEARCH_DATA,
-                            (Parcelable)createSearchInfo());
-                    setResult(RESULT_OK, intent);
+                if (fso != null) {
+                    if (FileHelper.isDirectory(fso)) {
+                        intent.putExtra(NavigationActivity.EXTRA_SEARCH_ENTRY_SELECTION, fso);
+                        intent.putExtra(
+                                NavigationActivity.EXTRA_SEARCH_LAST_SEARCH_DATA,
+                                (Parcelable)createSearchInfo());
+                        setResult(RESULT_OK, intent);
+                    } else {
+                        // Open the file here, so when focus back to the app, the search activity
+                        // its in top of the stack
+                        ActionsPolicy.openFileSystemObject(this, fso, false);
+                        return;
+                    }
                 } else {
-                    // Open the file here, so when focus back to the app, the search activity
-                    // its in top of the stack
-                    ActionsPolicy.openFileSystemObject(this, fso, false);
-                    return;
+                    // The fso not exists, delete the fso from the search
+                    try {
+                        removeItem(item);
+                    } catch (Exception ex) {/**NON BLOCK**/}
                 }
 
             } catch (Exception e) {
index 891d817..99f2406 100644 (file)
@@ -72,7 +72,8 @@ public class ListCommandTest extends AbstractConsoleTest {
      */
     @MediumTest
     public void testListInfo() throws Exception {
-        FileSystemObject file = CommandHelper.getFileInfo(getContext(), LS_INFOFILE, getConsole());
+        FileSystemObject file =
+                CommandHelper.getFileInfo(getContext(), LS_INFOFILE, getConsole());
         assertNotNull("file==null", file); //$NON-NLS-1$
         assertTrue(
                 String.format("file!=%s", LS_INFOFILE_NAME), //$NON-NLS-1$