Skip to content

Commit

Permalink
Fix issues#812: zhihu#812
Browse files Browse the repository at this point in the history
  • Loading branch information
lotosbin committed Mar 9, 2022
1 parent 21591ae commit fb00ab9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 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 @@ -76,10 +77,14 @@ public void onLoaderReset(Loader<Cursor> loader) {

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

public void onDestroy() {
if (mLoaderManager != null) {
mLoaderManager.destroyLoader(LOADER_ID);
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

0 comments on commit fb00ab9

Please sign in to comment.