Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b2071890 authored by Ivan Chiang's avatar Ivan Chiang
Browse files

Fix crash issue when hit back while scrolling

- When the user clicked the back key, stop the scroll.
- Add null check

Test: manual
Test: atest DocumentsUIGoogleTests
Change-Id: I9cb5fc04488150837eff90545894f8408cbd197a
Fix: 131713100
parent 8bd8cfd9
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -793,6 +793,11 @@ public abstract class BaseActivity
     */
    protected boolean popDir() {
        if (mState.stack.size() > 1) {
            final DirectoryFragment fragment = getDirectoryFragment();
            if (fragment != null) {
                fragment.stopScroll();
            }

            mState.stack.pop();
            refreshCurrentRootAndDirectory(AnimationView.ANIM_LEAVE);
            return true;
+8 −0
Original line number Diff line number Diff line
@@ -335,6 +335,10 @@ public class DocumentInfo implements Durable, Parcelable {
     * Missing or null values are returned as -1.
     */
    public static long getCursorLong(Cursor cursor, String columnName) {
        if (cursor == null) {
            return -1;
        }

        final int index = cursor.getColumnIndex(columnName);
        if (index == -1) return -1;
        final String value = cursor.getString(index);
@@ -350,6 +354,10 @@ public class DocumentInfo implements Durable, Parcelable {
     * Missing or null values are returned as 0.
     */
    public static int getCursorInt(Cursor cursor, String columnName) {
        if (cursor == null) {
            return 0;
        }

        final int index = cursor.getColumnIndex(columnName);
        return (index != -1) ? cursor.getInt(index) : 0;
    }
+10 −1
Original line number Diff line number Diff line
@@ -1096,7 +1096,7 @@ public class DirectoryFragment extends Fragment implements SwipeRefreshLayout.On
    }

    /**
     *  Scroll recycler view in fregment to top
     *  Scroll to top of recyclerView in fragment
     */
    public void scrollToTop() {
        if (mRecView != null) {
@@ -1104,6 +1104,15 @@ public class DirectoryFragment extends Fragment implements SwipeRefreshLayout.On
        }
    }

    /**
     *  Stop the scroll of recyclerView in fragment
     */
    public void stopScroll() {
        if (mRecView != null) {
            mRecView.stopScroll();
        }
    }

    @Override
    public void onRefresh() {
        // Remove thumbnail cache. We do this not because we're worried about stale thumbnails as it