Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate Fragments #2886

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.Fragment;
import android.content.Context;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.annotation.VisibleForTesting;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.view.View;
import com.bumptech.glide.Glide;
Expand Down Expand Up @@ -115,8 +115,9 @@ public static GlideRequests with(@NonNull Fragment arg0) {
/**
* @see Glide#with(Fragment)
*/
@Deprecated
@NonNull
public static GlideRequests with(@NonNull android.support.v4.app.Fragment arg0) {
public static GlideRequests with(@NonNull android.app.Fragment arg0) {
return (GlideRequests) Glide.with(arg0);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ private String getDataUriString(CompressFormat format) {
return "data:" + mimeType + ";base64," + bytes;
}

@SuppressWarnings("deprecation")
private String getBase64BitmapBytes(CompressFormat format) {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
Drawable drawable = context.getResources().getDrawable(ResourceIds.raw.canonical);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.bumptech.glide.integration.recyclerview;

import android.app.Activity;
import android.app.Fragment;
import android.support.annotation.NonNull;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v7.widget.RecyclerView;
import com.bumptech.glide.Glide;
Expand Down Expand Up @@ -62,9 +62,12 @@ public RecyclerViewPreloader(@NonNull Fragment fragment,
}

/**
* Helper constructor that accepts an {@link android.support.v4.app.Fragment}.
* Helper constructor that accepts an {@link android.app.Fragment}.
* @deprecated Use constructor <code>RecyclerViewPreloader(Fragment, PreloadModelProvider<T>,
* PreloadSizeProvider<T>)</code> instead.
*/
public RecyclerViewPreloader(@NonNull android.support.v4.app.Fragment fragment,
@Deprecated
public RecyclerViewPreloader(@NonNull android.app.Fragment fragment,
@NonNull PreloadModelProvider<T> preloadModelProvider,
@NonNull PreloadSizeProvider<T> preloadDimensionProvider,
int maxPreload) {
Expand Down
16 changes: 9 additions & 7 deletions library/src/main/java/com/bumptech/glide/Glide.java
Original file line number Diff line number Diff line change
Expand Up @@ -724,27 +724,29 @@ public static RequestManager with(@NonNull FragmentActivity activity) {
}

/**
* Begin a load with Glide that will be tied to the given {@link android.app.Fragment}'s lifecycle
* and that uses the given {@link android.app.Fragment}'s default options.
* Begin a load with Glide that will be tied to the given
* {@link android.support.v4.app.Fragment}'s lifecycle and that uses the given
* {@link android.support.v4.app.Fragment}'s default options.
*
* @param fragment The fragment to use.
* @return A RequestManager for the given Fragment that can be used to start a load.
*/
@NonNull
public static RequestManager with(@NonNull android.app.Fragment fragment) {
public static RequestManager with(@NonNull Fragment fragment) {
return getRetriever(fragment.getActivity()).get(fragment);
}

/**
* Begin a load with Glide that will be tied to the given
* {@link android.support.v4.app.Fragment}'s lifecycle and that uses the given
* {@link android.support.v4.app.Fragment}'s default options.
* Begin a load with Glide that will be tied to the given {@link android.app.Fragment}'s lifecycle
* and that uses the given {@link android.app.Fragment}'s default options.
*
* @param fragment The fragment to use.
* @return A RequestManager for the given Fragment that can be used to start a load.
* @deprecated Use method {@link #with(Fragment)} instead.
*/
@Deprecated
@NonNull
public static RequestManager with(@NonNull Fragment fragment) {
public static RequestManager with(@NonNull android.app.Fragment fragment) {
return getRetriever(fragment.getActivity()).get(fragment);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
* @see com.bumptech.glide.manager.RequestManagerRetriever
* @see com.bumptech.glide.RequestManager
*/
@Deprecated
public class RequestManagerFragment extends Fragment {
private static final String TAG = "RMFragment";
private final ActivityFragmentLifecycle lifecycle;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public class RequestManagerRetriever implements Handler.Callback {
/**
* Pending adds for RequestManagerFragments.
*/
@SuppressWarnings("deprecation")
@VisibleForTesting
final Map<android.app.FragmentManager, RequestManagerFragment> pendingRequestManagerFragments =
new HashMap<>();
Expand Down Expand Up @@ -229,6 +230,8 @@ private Fragment findSupportFragment(@NonNull View target, @NonNull FragmentActi
return result;
}

@SuppressWarnings("deprecation")
@Deprecated
@Nullable
private android.app.Fragment findFragment(@NonNull View target, @NonNull Activity activity) {
tempViewToFragment.clear();
Expand All @@ -255,6 +258,8 @@ private android.app.Fragment findFragment(@NonNull View target, @NonNull Activit

// TODO: Consider using an accessor class in the support library package to more directly retrieve
// non-support Fragments.
@SuppressWarnings("deprecation")
@Deprecated
@TargetApi(Build.VERSION_CODES.O)
private void findAllFragmentsWithViews(
@NonNull android.app.FragmentManager fragmentManager,
Expand All @@ -271,6 +276,8 @@ private void findAllFragmentsWithViews(
}
}

@SuppressWarnings("deprecation")
@Deprecated
private void findAllFragmentsWithViewsPreO(
@NonNull android.app.FragmentManager fragmentManager,
@NonNull ArrayMap<View, android.app.Fragment> result) {
Expand Down Expand Up @@ -313,6 +320,8 @@ private static void assertNotDestroyed(@NonNull Activity activity) {
}
}

@SuppressWarnings("deprecation")
@Deprecated
@NonNull
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
public RequestManager get(@NonNull android.app.Fragment fragment) {
Expand All @@ -328,6 +337,8 @@ public RequestManager get(@NonNull android.app.Fragment fragment) {
}
}

@SuppressWarnings("deprecation")
@Deprecated
@NonNull
RequestManagerFragment getRequestManagerFragment(
@NonNull final android.app.FragmentManager fm, @Nullable android.app.Fragment parentHint) {
Expand All @@ -345,6 +356,8 @@ RequestManagerFragment getRequestManagerFragment(
return current;
}

@SuppressWarnings("deprecation")
@Deprecated
@NonNull
private RequestManager fragmentGet(@NonNull Context context,
@NonNull android.app.FragmentManager fm,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ private interface Harness {
void onTrimMemory(@SuppressWarnings("SameParameterValue") int level);
}

@SuppressWarnings("deprecation")
private static class RequestManagerHarness implements Harness {
private final ActivityController<Activity> controller;
private final RequestManagerFragment fragment;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ public void testSupportCanGetRequestManagerFromActivity() {
assertEquals(manager, retriever.get(fragmentActivity));
}

@SuppressWarnings("deprecation")
@Test
public void testCanGetRequestManagerFromFragment() {
Activity activity = Robolectric.buildActivity(Activity.class).create().start().resume().get();
Expand Down Expand Up @@ -168,6 +169,7 @@ public void testCanGetRequestManagerFromDetachedFragment_PreJellyBeanMr1() {
helpTestCanGetRequestManagerFromDetachedFragment();
}

@SuppressWarnings("deprecation")
private void helpTestCanGetRequestManagerFromDetachedFragment() {
Activity activity = Robolectric.buildActivity(Activity.class).create().start().resume().get();
android.app.Fragment fragment = new android.app.Fragment();
Expand Down Expand Up @@ -202,6 +204,7 @@ private void helpTestSupportCanGetRequestManagerFromDetachedFragment() {
retriever.get(fragment);
}

@SuppressWarnings("deprecation")
@Test(expected = IllegalArgumentException.class)
public void testThrowsIfFragmentNotAttached() {
android.app.Fragment fragment = new android.app.Fragment();
Expand Down Expand Up @@ -319,6 +322,7 @@ public void testDoesNotThrowIfAskedToGetManagerForActivityPreJellYBeanMr1() {
assertNotNull(retriever.get(spyActivity));
}

@SuppressWarnings("deprecation")
@Test
@RequiresApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
public void testDoesNotThrowIfAskedToGetManagerForFragmentPreJellyBeanMr1() {
Expand Down Expand Up @@ -376,6 +380,7 @@ public boolean hasFragmentWithTag(String tag) {
.findFragmentByTag(RequestManagerRetriever.FRAGMENT_TAG);
}

@SuppressWarnings("deprecation")
@Override
public void addFragmentWithTag(String tag, RequestManager requestManager) {
RequestManagerFragment fragment = new RequestManagerFragment();
Expand Down