Skip to content
This repository has been archived by the owner on Jan 17, 2024. It is now read-only.

Commit

Permalink
fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
allenchang1 committed Jun 15, 2021
1 parent f2e6ee2 commit 890559c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import androidx.loader.app.LoaderManager;
import androidx.loader.content.Loader;
Expand Down Expand Up @@ -74,9 +75,15 @@ public void onLoaderReset(Loader<Cursor> loader) {
mCallbacks.onAlbumMediaReset();
}

public void onCreate(@NonNull FragmentActivity context, @NonNull AlbumMediaCallbacks callbacks) {
mContext = new WeakReference<Context>(context);
mLoaderManager = context.getSupportLoaderManager();
public void onCreate(@NonNull FragmentActivity activity, @NonNull AlbumMediaCallbacks callbacks) {
mContext = new WeakReference<>(activity);
mLoaderManager = LoaderManager.getInstance(activity);
mCallbacks = callbacks;
}

public void onCreate(@NonNull Fragment fragment, @NonNull AlbumMediaCallbacks callbacks) {
mContext = new WeakReference<>(fragment.getContext());
mLoaderManager = LoaderManager.getInstance(fragment);
mCallbacks = callbacks;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public void onActivityCreated(@Nullable Bundle savedInstanceState) {
int spacing = getResources().getDimensionPixelSize(R.dimen.media_grid_spacing);
mRecyclerView.addItemDecoration(new MediaGridInset(spanCount, spacing, false));
mRecyclerView.setAdapter(mAdapter);
mAlbumMediaCollection.onCreate(getActivity(), this);
mAlbumMediaCollection.onCreate(this, this);
mAlbumMediaCollection.load(album, selectionSpec.capture);
}

Expand Down
1 change: 1 addition & 0 deletions sample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,5 @@ dependencies {
implementation 'io.reactivex.rxjava2:rxjava:2.2.12'
implementation 'com.github.bumptech.glide:glide:4.9.0'
implementation 'com.squareup.picasso:picasso:2.5.2'
implementation group: 'androidx.fragment', name: 'fragment', version: '1.3.3'
}

0 comments on commit 890559c

Please sign in to comment.