Loading src/com/android/documentsui/dirlist/DirectoryFragment.java +45 −15 Original line number Diff line number Diff line Loading @@ -132,6 +132,7 @@ public class DirectoryFragment extends Fragment implements SwipeRefreshLayout.On }) @Retention(RetentionPolicy.SOURCE) public @interface RequestCode {} public static final int REQUEST_COPY_DESTINATION = 1; static final String TAG = "DirectoryFragment"; Loading @@ -140,6 +141,9 @@ public class DirectoryFragment extends Fragment implements SwipeRefreshLayout.On private static final int REFRESH_SPINNER_TIMEOUT = 500; private static final int PROVIDER_MAX_RETRIES = 10; private static final long PROVIDER_TEST_DELAY = 4000; private static final String ACTION_MEDIA_REMOVED = "android.intent.action.MEDIA_REMOVED"; private static final String ACTION_MEDIA_MOUNTED = "android.intent.action.MEDIA_MOUNTED"; private static final String ACTION_MEDIA_EJECT = "android.intent.action.MEDIA_EJECT"; private BaseActivity mActivity; Loading Loading @@ -257,6 +261,22 @@ public class DirectoryFragment extends Fragment implements SwipeRefreshLayout.On } }; private final BroadcastReceiver mSdCardBroadcastReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { onRefresh(); } }; private IntentFilter getSdCardStateChangeFilter() { IntentFilter sdCardStateChangeFilter = new IntentFilter(); sdCardStateChangeFilter.addAction(ACTION_MEDIA_REMOVED); sdCardStateChangeFilter.addAction(ACTION_MEDIA_MOUNTED); sdCardStateChangeFilter.addAction(ACTION_MEDIA_EJECT); sdCardStateChangeFilter.addDataScheme("file"); return sdCardStateChangeFilter; } private void checkUriAndScheduleCheckIfNeeded(UserId userId) { RootInfo currentRoot = mActivity.getCurrentRoot(); DocumentInfo currentDoc = mActivity.getDisplayState().stack.peek(); Loading Loading @@ -390,6 +410,7 @@ public class DirectoryFragment extends Fragment implements SwipeRefreshLayout.On mHandler.removeCallbacks(mProviderTestRunnable); } } getContext().unregisterReceiver(mSdCardBroadcastReceiver); // Cancel any outstanding thumbnail requests final int count = mRecView.getChildCount(); Loading Loading @@ -555,6 +576,7 @@ public class DirectoryFragment extends Fragment implements SwipeRefreshLayout.On // roots are updated. LocalBroadcastManager.getInstance(mActivity).registerReceiver(mReceiver, filter); } getContext().registerReceiver(mSdCardBroadcastReceiver, getSdCardStateChangeFilter()); } @Override Loading Loading @@ -672,6 +694,7 @@ public class DirectoryFragment extends Fragment implements SwipeRefreshLayout.On /** * Updates the layout after the view mode switches. * * @param mode The new view mode. */ private void updateLayout(@ViewMode int mode) { Loading Loading @@ -705,21 +728,26 @@ public class DirectoryFragment extends Fragment implements SwipeRefreshLayout.On /** * Updates the layout after the view mode switches. * * @param mode The new view mode. */ private void scaleLayout(float scale) { assert DEBUG; if (VERBOSE) Log.v( if (VERBOSE) { Log.v( TAG, "Handling scale event: " + scale + ", existing scale: " + mLiveScale); } if (mMode == MODE_GRID) { float minScale = getFraction(R.fraction.grid_scale_min); float maxScale = getFraction(R.fraction.grid_scale_max); float nextScale = mLiveScale * scale; if (VERBOSE) Log.v(TAG, if (VERBOSE) { Log.v(TAG, "Next scale " + nextScale + ", Min/max scale " + minScale + "/" + maxScale); } if (nextScale > minScale && nextScale < maxScale) { if (DEBUG) { Loading Loading @@ -1170,6 +1198,7 @@ public class DirectoryFragment extends Fragment implements SwipeRefreshLayout.On /** * Gets the model ID for a given RecyclerView item. * * @param view A View that is a document item view, or a child of a document item view. * @return The Model ID for the given document, or null if the given view is not associated with * a document item view. Loading Loading @@ -1250,6 +1279,7 @@ public class DirectoryFragment extends Fragment implements SwipeRefreshLayout.On ft.commitAllowingStateLoss(); } /** Gets the fragment from the fragment manager. */ public static @Nullable DirectoryFragment get(FragmentManager fm) { // TODO: deal with multiple directories shown at once Fragment fragment = fm.findFragmentById(getFragmentId()); Loading Loading
src/com/android/documentsui/dirlist/DirectoryFragment.java +45 −15 Original line number Diff line number Diff line Loading @@ -132,6 +132,7 @@ public class DirectoryFragment extends Fragment implements SwipeRefreshLayout.On }) @Retention(RetentionPolicy.SOURCE) public @interface RequestCode {} public static final int REQUEST_COPY_DESTINATION = 1; static final String TAG = "DirectoryFragment"; Loading @@ -140,6 +141,9 @@ public class DirectoryFragment extends Fragment implements SwipeRefreshLayout.On private static final int REFRESH_SPINNER_TIMEOUT = 500; private static final int PROVIDER_MAX_RETRIES = 10; private static final long PROVIDER_TEST_DELAY = 4000; private static final String ACTION_MEDIA_REMOVED = "android.intent.action.MEDIA_REMOVED"; private static final String ACTION_MEDIA_MOUNTED = "android.intent.action.MEDIA_MOUNTED"; private static final String ACTION_MEDIA_EJECT = "android.intent.action.MEDIA_EJECT"; private BaseActivity mActivity; Loading Loading @@ -257,6 +261,22 @@ public class DirectoryFragment extends Fragment implements SwipeRefreshLayout.On } }; private final BroadcastReceiver mSdCardBroadcastReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { onRefresh(); } }; private IntentFilter getSdCardStateChangeFilter() { IntentFilter sdCardStateChangeFilter = new IntentFilter(); sdCardStateChangeFilter.addAction(ACTION_MEDIA_REMOVED); sdCardStateChangeFilter.addAction(ACTION_MEDIA_MOUNTED); sdCardStateChangeFilter.addAction(ACTION_MEDIA_EJECT); sdCardStateChangeFilter.addDataScheme("file"); return sdCardStateChangeFilter; } private void checkUriAndScheduleCheckIfNeeded(UserId userId) { RootInfo currentRoot = mActivity.getCurrentRoot(); DocumentInfo currentDoc = mActivity.getDisplayState().stack.peek(); Loading Loading @@ -390,6 +410,7 @@ public class DirectoryFragment extends Fragment implements SwipeRefreshLayout.On mHandler.removeCallbacks(mProviderTestRunnable); } } getContext().unregisterReceiver(mSdCardBroadcastReceiver); // Cancel any outstanding thumbnail requests final int count = mRecView.getChildCount(); Loading Loading @@ -555,6 +576,7 @@ public class DirectoryFragment extends Fragment implements SwipeRefreshLayout.On // roots are updated. LocalBroadcastManager.getInstance(mActivity).registerReceiver(mReceiver, filter); } getContext().registerReceiver(mSdCardBroadcastReceiver, getSdCardStateChangeFilter()); } @Override Loading Loading @@ -672,6 +694,7 @@ public class DirectoryFragment extends Fragment implements SwipeRefreshLayout.On /** * Updates the layout after the view mode switches. * * @param mode The new view mode. */ private void updateLayout(@ViewMode int mode) { Loading Loading @@ -705,21 +728,26 @@ public class DirectoryFragment extends Fragment implements SwipeRefreshLayout.On /** * Updates the layout after the view mode switches. * * @param mode The new view mode. */ private void scaleLayout(float scale) { assert DEBUG; if (VERBOSE) Log.v( if (VERBOSE) { Log.v( TAG, "Handling scale event: " + scale + ", existing scale: " + mLiveScale); } if (mMode == MODE_GRID) { float minScale = getFraction(R.fraction.grid_scale_min); float maxScale = getFraction(R.fraction.grid_scale_max); float nextScale = mLiveScale * scale; if (VERBOSE) Log.v(TAG, if (VERBOSE) { Log.v(TAG, "Next scale " + nextScale + ", Min/max scale " + minScale + "/" + maxScale); } if (nextScale > minScale && nextScale < maxScale) { if (DEBUG) { Loading Loading @@ -1170,6 +1198,7 @@ public class DirectoryFragment extends Fragment implements SwipeRefreshLayout.On /** * Gets the model ID for a given RecyclerView item. * * @param view A View that is a document item view, or a child of a document item view. * @return The Model ID for the given document, or null if the given view is not associated with * a document item view. Loading Loading @@ -1250,6 +1279,7 @@ public class DirectoryFragment extends Fragment implements SwipeRefreshLayout.On ft.commitAllowingStateLoss(); } /** Gets the fragment from the fragment manager. */ public static @Nullable DirectoryFragment get(FragmentManager fm) { // TODO: deal with multiple directories shown at once Fragment fragment = fm.findFragmentById(getFragmentId()); Loading