Returns null if IndexOutOfBoundsException in ContentHelper
This commit is contained in:
1 parent
c2a93f2ce4
commit
a5b178df49
4 files changed
+43
-15
No files matched your search
@@ -605,7 +605,10 @@ public class FavoritesScene extends BaseScene implements
|
||||
if (mRecyclerView != null && mRecyclerView.isInCustomChoice()) {
|
||||
mRecyclerView.toggleItemChecked(position);
|
||||
} else if (mHelper != null) {
|
||||
GalleryInfo gi = mHelper.getDataAt(position);
|
||||
GalleryInfo gi = mHelper.getDataAtEx(position);
|
||||
if (gi == null) {
|
||||
return true;
|
||||
}
|
||||
Bundle args = new Bundle();
|
||||
args.putString(GalleryDetailScene.KEY_ACTION, GalleryDetailScene.ACTION_GALLERY_INFO);
|
||||
args.putParcelable(GalleryDetailScene.KEY_GALLERY_INFO, gi);
|
||||
@@ -751,7 +754,10 @@ public class FavoritesScene extends BaseScene implements
|
||||
SparseBooleanArray stateArray = mRecyclerView.getCheckedItemPositions();
|
||||
for (int i = 0, n = stateArray.size(); i < n; i++) {
|
||||
if (stateArray.valueAt(i)) {
|
||||
mModifyGiList.add(mHelper.getDataAt(stateArray.keyAt(i)));
|
||||
GalleryInfo gi = mHelper.getDataAtEx(stateArray.keyAt(i));
|
||||
if (gi != null) {
|
||||
mModifyGiList.add(gi);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1002,7 +1008,7 @@ public class FavoritesScene extends BaseScene implements
|
||||
@Nullable
|
||||
@Override
|
||||
public GalleryInfo getDataAt(int position) {
|
||||
return null != mHelper ? mHelper.getDataAt(position) : null;
|
||||
return null != mHelper ? mHelper.getDataAtEx(position) : null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -832,7 +832,11 @@ public final class GalleryListScene extends BaseScene
|
||||
return false;
|
||||
}
|
||||
|
||||
GalleryInfo gi = mHelper.getDataAt(position);
|
||||
GalleryInfo gi = mHelper.getDataAtEx(position);
|
||||
if (gi == null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Bundle args = new Bundle();
|
||||
args.putString(GalleryDetailScene.KEY_ACTION, GalleryDetailScene.ACTION_GALLERY_INFO);
|
||||
args.putParcelable(GalleryDetailScene.KEY_GALLERY_INFO, gi);
|
||||
@@ -946,7 +950,11 @@ public final class GalleryListScene extends BaseScene
|
||||
return false;
|
||||
}
|
||||
|
||||
final GalleryInfo gi = mHelper.getDataAt(position);
|
||||
final GalleryInfo gi = mHelper.getDataAtEx(position);
|
||||
if (gi == null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
new AlertDialog.Builder(context)
|
||||
.setTitle(EhUtils.getSuitableTitle(gi))
|
||||
.setItems(R.array.gallery_list_menu_entries, new DialogInterface.OnClickListener() {
|
||||
@@ -1340,7 +1348,7 @@ public final class GalleryListScene extends BaseScene
|
||||
@Nullable
|
||||
@Override
|
||||
public GalleryInfo getDataAt(int position) {
|
||||
return null != mHelper ? mHelper.getDataAt(position) : null;
|
||||
return null != mHelper ? mHelper.getDataAtEx(position) : null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -231,12 +231,14 @@ public class GalleryPreviewsScene extends ToolbarScene implements EasyRecyclerVi
|
||||
public boolean onItemClick(EasyRecyclerView parent, View view, int position, long id) {
|
||||
Context context = getContext2();
|
||||
if (null != context && null != mHelper && null != mGalleryInfo) {
|
||||
GalleryPreview p = mHelper.getDataAt(position);
|
||||
Intent intent = new Intent(context, GalleryActivity.class);
|
||||
intent.setAction(GalleryActivity.ACTION_EH);
|
||||
intent.putExtra(GalleryActivity.KEY_GALLERY_INFO, mGalleryInfo);
|
||||
intent.putExtra(GalleryActivity.KEY_PAGE, p.getPosition());
|
||||
startActivity(intent);
|
||||
GalleryPreview p = mHelper.getDataAtEx(position);
|
||||
if (p != null) {
|
||||
Intent intent = new Intent(context, GalleryActivity.class);
|
||||
intent.setAction(GalleryActivity.ACTION_EH);
|
||||
intent.putExtra(GalleryActivity.KEY_GALLERY_INFO, mGalleryInfo);
|
||||
intent.putExtra(GalleryActivity.KEY_PAGE, p.getPosition());
|
||||
startActivity(intent);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -272,9 +274,11 @@ public class GalleryPreviewsScene extends ToolbarScene implements EasyRecyclerVi
|
||||
@SuppressLint("SetTextI18n")
|
||||
public void onBindViewHolder(GalleryPreviewHolder holder, int position) {
|
||||
if (null != mHelper) {
|
||||
GalleryPreview preview = mHelper.getDataAt(position);
|
||||
preview.load(holder.image);
|
||||
holder.text.setText(Integer.toString(preview.getPosition() + 1));
|
||||
GalleryPreview preview = mHelper.getDataAtEx(position);
|
||||
if (preview != null) {
|
||||
preview.load(holder.image);
|
||||
holder.text.setText(Integer.toString(preview.getPosition() + 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
import android.os.Parcelable;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
@@ -368,6 +369,15 @@ public class ContentLayout extends FrameLayout {
|
||||
return mData.get(location);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public E getDataAtEx(int location) {
|
||||
if (location >= 0 && location < mData.size()) {
|
||||
return mData.get(location);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public int size() {
|
||||
return mData.size();
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user