Java Code Examples for com.bumptech.glide.Glide#with()

The following examples show how to use com.bumptech.glide.Glide#with() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SubredditListingRecyclerViewAdapter.java    From Infinity-For-Reddit with GNU Affero General Public License v3.0 6 votes vote down vote up
public SubredditListingRecyclerViewAdapter(Context context, Retrofit oauthRetrofit, Retrofit retrofit,
                                           CustomThemeWrapper customThemeWrapper,
                                           String accessToken, String accountName,
                                           RedditDataRoomDatabase redditDataRoomDatabase,
                                           Callback callback) {
    super(DIFF_CALLBACK);
    this.context = context;
    this.oauthRetrofit = oauthRetrofit;
    this.retrofit = retrofit;
    this.accessToken = accessToken;
    this.accountName = accountName;
    this.redditDataRoomDatabase = redditDataRoomDatabase;
    this.callback = callback;
    glide = Glide.with(context);
    colorPrimaryLightTheme = customThemeWrapper.getColorPrimaryLightTheme();
    primaryTextColor = customThemeWrapper.getPrimaryTextColor();
    secondaryTextColor = customThemeWrapper.getSecondaryTextColor();
    colorAccent = customThemeWrapper.getColorAccent();
    buttonTextColor = customThemeWrapper.getButtonTextColor();
    unsubscribed = customThemeWrapper.getUnsubscribed();
}
 
Example 2
Source File: MediaSessionPlaybackReporter.java    From PainlessMusicPlayer with Apache License 2.0 5 votes vote down vote up
MediaSessionPlaybackReporter(
        @NonNull final Context context,
        @NonNull final AlbumThumbHolder albumThumbHolder,
        @NonNull final MediaSessionCompat mediaSession) {
    mDisplayMetrics = context.getResources().getDisplayMetrics();
    mAlbumThumbHolder = albumThumbHolder;
    mMediaSession = mediaSession;
    mGlide = Glide.with(context);
}
 
Example 3
Source File: ImageProxyUtils.java    From Pas with Apache License 2.0 5 votes vote down vote up
public void loadImage(Activity context, String url, ImageView imageView) {
    requestManager = Glide.with(context);
    this.mContext = context;
    this.mImage = imageView;
    this.url = url;

    loadImage(TYPE);
}
 
Example 4
Source File: FollowedUsersRecyclerViewAdapter.java    From Infinity-For-Reddit with GNU Affero General Public License v3.0 5 votes vote down vote up
public FollowedUsersRecyclerViewAdapter(Context context, Retrofit oauthRetrofit,
                                        RedditDataRoomDatabase redditDataRoomDatabase,
                                        CustomThemeWrapper customThemeWrapper,
                                        String accessToken) {
    mContext = context;
    mOauthRetrofit = oauthRetrofit;
    mRedditDataRoomDatabase = redditDataRoomDatabase;
    mAccessToken = accessToken;
    glide = Glide.with(context);
    mPrimaryTextColor = customThemeWrapper.getPrimaryTextColor();
    mSecondaryTextColor = customThemeWrapper.getSecondaryTextColor();
}
 
Example 5
Source File: MainActivity.java    From AlbumSelector with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    KLog.d("===========MainActivity:onCreate=============");
    setContentView(R.layout.activity_main);
    ButterKnife.bind(this);
    setSupportActionBar(mToolbar);
    mRecyclerView.setHasFixedSize(true);
    mRecyclerView.setLayoutManager(new GridLayoutManager(this, 3));
    mRecyclerView.addItemDecoration(new GridDividerDecorator(this));
    mAdapter = new SelectedImgAdapter(Glide.with(this));
    mRecyclerView.setAdapter(mAdapter);
}
 
Example 6
Source File: ImageProxyUtils.java    From Pas with Apache License 2.0 5 votes vote down vote up
public void loadImage(Context context, String url, ImageView imageView) {
    requestManager = Glide.with(context);
    this.mContext = context;
    this.mImage = imageView;
    this.url = url;

    loadImage(TYPE);
}
 
Example 7
Source File: GlideX.java    From NClientV2 with Apache License 2.0 5 votes vote down vote up
@Nullable
public static RequestManager with(Context context) {
    try {
        return Glide.with(context);
    } catch (VerifyError | IllegalStateException ignore) {
        return null;
    }
}
 
Example 8
Source File: RecyclerViewPreloader.java    From FastAndroid with Apache License 2.0 5 votes vote down vote up
/**
 * Helper constructor that accepts an {@link Fragment}.
 */
public RecyclerViewPreloader(Fragment fragment,
                             PreloadModelProvider<T> preloadModelProvider,
                             PreloadSizeProvider<T> preloadDimensionProvider,
                             int maxPreload) {

    this(Glide.with(fragment), preloadModelProvider, preloadDimensionProvider, maxPreload);
}
 
Example 9
Source File: MeiziFragment.java    From NewsMe with Apache License 2.0 4 votes vote down vote up
private void initView() {
    MeiziAdapter adapter = new MeiziAdapter(getActivity(), data, Glide.with(getActivity()));
    getBinding().content.setAdapter(adapter);
}
 
Example 10
Source File: PhotoPickerFragment.java    From PhotoPicker with Apache License 2.0 4 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setRetainInstance(true);

    mGlideRequestManager = Glide.with(this);

    directories = new ArrayList<>();
    originalPhotos = getArguments().getStringArrayList(EXTRA_ORIGIN);

    column = getArguments().getInt(EXTRA_COLUMN, DEFAULT_COLUMN_NUMBER);
    isCrop = getArguments().getBoolean(EXTRA_CROP, false);
    isOpenCamera = getArguments().getBoolean(EXTRA_OPEN_CAMERA, false);


    boolean showCamera = getArguments().getBoolean(EXTRA_CAMERA, true);
    boolean previewEnable = getArguments().getBoolean(EXTRA_PREVIEW_ENABLED, true);

    photoGridAdapter = new PhotoGridAdapter(getActivity(), mGlideRequestManager, directories, originalPhotos, column);
    photoGridAdapter.setShowCamera(showCamera);
    photoGridAdapter.setPreviewEnable(previewEnable);

    Bundle mediaStoreArgs = new Bundle();

    boolean showGif = getArguments().getBoolean(EXTRA_GIF);
    mediaStoreArgs.putBoolean(EXTRA_SHOW_GIF, showGif);
    MediaStoreHelper.getPhotoDirs(getActivity(), mediaStoreArgs,
            new MediaStoreHelper.PhotosResultCallback() {
                @Override
                public void onResultCallback(List<PhotoDirectory> dirs) {
                    directories.clear();
                    directories.addAll(dirs);
                    photoGridAdapter.notifyDataSetChanged();
                    listAdapter.notifyDataSetChanged();
                    adjustHeight();
                }
            });

    captureManager = new ImageCaptureManager(getActivity());
}
 
Example 11
Source File: GlideUtils.java    From DevUtils with Apache License 2.0 4 votes vote down vote up
@NonNull
public static GlideLoader with(@NonNull Context context) {
    return new GlideLoader(Glide.with(context));
}
 
Example 12
Source File: ImageLoader.java    From v2ex with Apache License 2.0 4 votes vote down vote up
/**
 * Construct a standard ImageLoader object.
 */
public ImageLoader(Context context) {
    requestManager = Glide.with(context);
    mCenterCrop = new CenterCrop(Glide.get(context).getBitmapPool());
    mFitCenter = new FitCenter(Glide.get(context).getBitmapPool());
}
 
Example 13
Source File: GlideUtils.java    From DevUtils with Apache License 2.0 4 votes vote down vote up
@NonNull
public static GlideLoader with(@NonNull android.app.Fragment fragment) {
    return new GlideLoader(Glide.with(fragment));
}
 
Example 14
Source File: UploadRecyclerAdapter.java    From RxUploader with Apache License 2.0 4 votes vote down vote up
public UploadRecyclerAdapter(@NonNull Context context) {
    photoList = new UploadPhotoList(this);
    glide = Glide.with(context);
}
 
Example 15
Source File: SubredditMultiselectionActivity.java    From Infinity-For-Reddit with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    ((Infinity) getApplication()).getAppComponent().inject(this);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_subscribed_subreddits_multiselection);

    ButterKnife.bind(this);

    applyCustomTheme();

    if (mSharedPreferences.getBoolean(SharedPreferencesUtils.SWIPE_RIGHT_TO_GO_BACK_FROM_POST_DETAIL, true)) {
        Slidr.attach(this);
    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        Window window = getWindow();

        if (isChangeStatusBarIconColor()) {
            addOnOffsetChangedListener(mAppBarLayout);
        }

        if (isImmersiveInterface()) {
            window.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
            adjustToolbar(mToolbar);

            int navBarHeight = getNavBarHeight();
            if (navBarHeight > 0) {
                mRecyclerView.setPadding(0, 0, 0, navBarHeight);
            }
        }
    }

    setSupportActionBar(mToolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    mGlide = Glide.with(this);

    mSwipeRefreshLayout.setEnabled(false);

    if (savedInstanceState != null) {
        mNullAccessToken = savedInstanceState.getBoolean(NULL_ACCESS_TOKEN_STATE);
        mAccessToken = savedInstanceState.getString(ACCESS_TOKEN_STATE);
        mAccountName = savedInstanceState.getString(ACCOUNT_NAME_STATE);

        if (!mNullAccessToken && mAccountName == null) {
            getCurrentAccountAndBindView();
        } else {
            bindView();
        }
    } else {
        getCurrentAccountAndBindView();
    }
}
 
Example 16
Source File: SubredditMultiselectionRecyclerViewAdapter.java    From Infinity-For-Reddit with GNU Affero General Public License v3.0 4 votes vote down vote up
public SubredditMultiselectionRecyclerViewAdapter(Context context, CustomThemeWrapper customThemeWrapper) {
    glide = Glide.with(context);
    primaryTextColor = customThemeWrapper.getPrimaryTextColor();
    colorAccent = customThemeWrapper.getColorAccent();
}
 
Example 17
Source File: JokeFragment.java    From NewsMe with Apache License 2.0 4 votes vote down vote up
private void initView() {
    JokeAdapter adapter = new JokeAdapter(getContext(), mJokes, Glide.with(getContext()));
    adapter.setOnItemClickListener(this);
    getBinding().content.setAdapter(adapter);
}
 
Example 18
Source File: FollowedUsersListingFragment.java    From Infinity-For-Reddit with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_followed_users_listing, container, false);

    ButterKnife.bind(this, rootView);

    ((Infinity) mActivity.getApplication()).getAppComponent().inject(this);

    applyTheme();

    Resources resources = getResources();

    if ((mActivity instanceof BaseActivity && ((BaseActivity) mActivity).isImmersiveInterface())) {
        mRecyclerView.setPadding(0, 0, 0, ((BaseActivity) mActivity).getNavBarHeight());
    } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O
            && mSharedPreferences.getBoolean(SharedPreferencesUtils.IMMERSIVE_INTERFACE_KEY, true)) {
        int navBarResourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android");
        if (navBarResourceId > 0) {
            mRecyclerView.setPadding(0, 0, 0, resources.getDimensionPixelSize(navBarResourceId));
        }
    }

    mGlide = Glide.with(this);

    mLinearLayoutManager = new LinearLayoutManager(mActivity);
    mRecyclerView.setLayoutManager(mLinearLayoutManager);
    FollowedUsersRecyclerViewAdapter adapter = new FollowedUsersRecyclerViewAdapter(mActivity,
            mOauthRetrofit, mRedditDataRoomDatabase, customThemeWrapper,
            getArguments().getString(EXTRA_ACCESS_TOKEN));
    mRecyclerView.setAdapter(adapter);
    new FastScrollerBuilder(mRecyclerView).build();

    mSubscribedUserViewModel = new ViewModelProvider(this,
            new SubscribedUserViewModel.Factory(mActivity.getApplication(), mRedditDataRoomDatabase, getArguments().getString(EXTRA_ACCOUNT_NAME)))
            .get(SubscribedUserViewModel.class);

    mSubscribedUserViewModel.getAllSubscribedUsers().observe(this, subscribedUserData -> {
        mSwipeRefreshLayout.setRefreshing(false);
        if (subscribedUserData == null || subscribedUserData.size() == 0) {
            mRecyclerView.setVisibility(View.GONE);
            mLinearLayout.setVisibility(View.VISIBLE);
            mGlide.load(R.drawable.error_image).into(mImageView);
        } else {
            mLinearLayout.setVisibility(View.GONE);
            mRecyclerView.setVisibility(View.VISIBLE);
            mGlide.clear(mImageView);
        }
        adapter.setSubscribedUsers(subscribedUserData);
    });

    mSubscribedUserViewModel.getAllFavoriteSubscribedUsers().observe(this, favoriteSubscribedUserData -> {
        mSwipeRefreshLayout.setRefreshing(false);
        if (favoriteSubscribedUserData != null && favoriteSubscribedUserData.size() > 0) {
            mLinearLayout.setVisibility(View.GONE);
            mRecyclerView.setVisibility(View.VISIBLE);
            mGlide.clear(mImageView);
        }
        adapter.setFavoriteSubscribedUsers(favoriteSubscribedUserData);
    });

    return rootView;
}
 
Example 19
Source File: RecentActivityRecyclerAdapter.java    From PainlessMusicPlayer with Apache License 2.0 4 votes vote down vote up
RecentActivityRecyclerAdapter(@NonNull final Context context) {
    super(context);
    requestManager = Glide.with(context);
}
 
Example 20
Source File: RecyclerViewPreloader.java    From AndroidBase with Apache License 2.0 4 votes vote down vote up
/**
 * Helper constructor that accepts an {@link Fragment}.
 */
public RecyclerViewPreloader(Fragment fragment,
    PreloadModelProvider<T> preloadModelProvider, PreloadSizeProvider<T> preloadDimensionProvider,
    int maxPreload) {
  this(Glide.with(fragment), preloadModelProvider, preloadDimensionProvider, maxPreload);
}