DocsUI: Don't crash on invalid window sizes.
Our layout code asserts when passed an (invalid) width of 0. The assert is unnecessary as we already handle this situation by always laying out the content pane with a column count of at least 1. Also, per Steve, bump the minimum column count in grid mode to 2. BUG=27150284 Change-Id: I8aa87beaaf4907ef5248999d0c590deef732589f
This commit is contained in:
@@ -98,7 +98,6 @@ import com.android.documentsui.model.RootInfo;
|
||||
import com.android.documentsui.services.FileOperationService;
|
||||
import com.android.documentsui.services.FileOperationService.OpType;
|
||||
import com.android.documentsui.services.FileOperations;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
@@ -406,9 +405,9 @@ public class DirectoryFragment extends Fragment
|
||||
int cellMargin = 2 * getResources().getDimensionPixelSize(R.dimen.grid_item_margin);
|
||||
int viewPadding = mRecView.getPaddingLeft() + mRecView.getPaddingRight();
|
||||
|
||||
assert(mRecView.getWidth() > 0);
|
||||
|
||||
int columnCount = Math.max(1,
|
||||
// RecyclerView sometimes gets a width of 0 (see b/27150284). Clamp so that we always lay
|
||||
// out the grid with at least 2 columns.
|
||||
int columnCount = Math.max(2,
|
||||
(mRecView.getWidth() - viewPadding) / (cellWidth + cellMargin));
|
||||
|
||||
return columnCount;
|
||||
|
||||
Reference in New Issue
Block a user