我有一个画廊应用程序,它对我工作正常,我看到Crashlaytic上的奇怪崩溃这是日志
Fatal Exception: java.lang.NullPointerException: Attempt to invoke virtual method 'char[] java.lang.String.toCharArray()' on a null object reference
at java.io.File.fixSlashes(File.java:185)
at java.io.File.(File.java:134)
at com.*****.*****.adapters.AlbumsAdapter.onBindViewHolder(AlbumsAdapter.java:94)
at com.*****.*****.adapters.AlbumsAdapter.onViewRecycled(AlbumsAdapter.java:34)
at android.support.v7.widget.RecyclerView$Adapter.onBindViewHolder(RecyclerView.java:6508)
at android.support.v7.widget.RecyclerView$Adapter.onCreateViewHolder(RecyclerView.java:6541)
at android.support.v7.widget.RecyclerView$Recycler.tryBindViewHolderByDeadline(RecyclerView.java:5484)
at android.support.v7.widget.RecyclerView$Recycler.tryGetViewHolderForPositionByDeadline(RecyclerView.java:5750)
at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5589)
at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5585)
at android.support.v7.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:2231)
at android.support.v7.widget.GridLayoutManager.layoutChunk(GridLayoutManager.java:556)
at android.support.v7.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1518)
at android.support.v7.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:610)
at android.support.v7.widget.GridLayoutManager.onLayoutChildren(GridLayoutManager.java:170)
at android.support.v7.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:3719)
at android.support.v7.widget.RecyclerView.dispatchLayout(RecyclerView.java:3436)
at android.support.v7.widget.RecyclerView.onLayout(RecyclerView.java:3988)
at android.view.View.layout(View.java:15679)
at android.view.ViewGroup.layout(ViewGroup.java:5061)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:579)
at android.widget.FrameLayout.onLayout(FrameLayout.java:514)
at android.view.View.layout(View.java:15679)
at android.view.ViewGroup.layout(ViewGroup.java:5061)
这是我的行,我收到此崩溃这是我的onBindViewHolder
方法
request = GlideApp.with(context)
.asDrawable()
.centerCrop()
.override(reqWidth, reqWidth)
.transition(withNoTransition());
@Override
public void onBindViewHolder(final CustomViewHolder holder, int position) {
Utilities.setMaxLines(holder.img_label);
Log.i("times", "times");
AlbumClass item = list.get(position);
if (item.getType() == Utilities.TYPE_VIDEOS) {
if (item.bitmap != null)
holder.gallery_img.setImageBitmap(item.bitmap);
} else {
Uri uri = Uri.fromFile(new File(item.getFilePath()));
request.load(uri).into(holder.gallery_img);
}
//holder.gallery_img.setImageBitmap(Utilities.getImageBitmap(type, mContext, item.getFirstChildId()));
holder.img_label.setText(item.getName());
holder.count.setText(String.valueOf(item.getCount()));
}