Glide Version: 3.7.0
Integration libraries:
Device/Android Version:
Issue details / Repro steps / Use case background:
I have a Fragment which loads images from a dynamic list of them. If I enter the Fragment and stay until the images all load, there's not problem. If I replace the Fragment before loading of all the images is complete, I get a You must pass in non null View exception. What am I doing wrong?
Glide load line / GlideModule (if any) / list Adapter code (if any):
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View rootView = inflater.inflate(R.layout.fragment_chatholder, container, false);
LinearLayout horizontalLayout = (LinearLayout) rootView.findViewById(R.id.chat_horizontal_layout);
int dpConversion = (int) rootView.getResources().getDisplayMetrics().density;
for (int k = 0; k < matches.size(); k++) {
if (horizontalLayout != null) {
CircleImageButton newButton = new CircleImageButton(rootView.getContext());
newButton.setIndex(k);
newButton.setBackgroundColor(Color.alpha(0));
newButton.setScaleType(ImageView.ScaleType.FIT_CENTER);
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams
.WRAP_CONTENT, LinearLayout.LayoutParams.MATCH_PARENT);
params.setMargins(0, 0, dpConversion, 0);
newButton.setOnClickListener(this);
horizontalLayout.addView(newButton, params);
Glide.with(getActivity()).load(matches.get(k).getPhoto_one_url()).asBitmap().transform(new CircleTransform(getActivity())).skipMemoryCache(true).into(newButton);
}
}
return rootView;
}
Layout XML:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".ChatHolderFragment">
<HorizontalScrollView
android:layout_width="match_parent"
android:layout_height="100dp"
android:padding="1dp">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="horizontal"
android:id="@+id/chat_horizontal_layout"/>
</HorizontalScrollView>
<View
android:layout_width="match_parent"
android:layout_height="2dp"
android:background="#33000000"/>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:id="@+id/chat_fragment_holder"/>
</LinearLayout>
Stack trace / LogCat:
java.lang.IllegalArgumentException: You must pass in a non null View
at com.bumptech.glide.GenericRequestBuilder.into(GenericRequestBuilder.java:678)
at com.bumptech.glide.BitmapRequestBuilder.into(BitmapRequestBuilder.java:498)
at com.ldsmatchup.ldsmatchup.UserFragment.onCreate(UserFragment.java:43)
at android.app.Fragment.performCreate(Fragment.java:2198)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:942)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1148)
at android.app.BackStackRecord.run(BackStackRecord.java:793)
at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1535)
at android.app.FragmentManagerImpl$1.run(FragmentManager.java:482)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Wow, I'm sorry, I was looking at the wrong fragment... Never mind.
Most helpful comment
Wow, I'm sorry, I was looking at the wrong fragment... Never mind.