CustomGlideStreamLoader.java 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /**
  2. * Nextcloud Android client application
  3. *
  4. * @author Alejandro Bautista
  5. * @author Chris Narkiewicz
  6. *
  7. * Copyright (C) 2017 Alejandro Bautista
  8. * Copyright (C) 2019 Chris Narkiewicz <hello@ezaquarii.com>
  9. *
  10. * This program is free software; you can redistribute it and/or
  11. * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
  12. * License as published by the Free Software Foundation; either
  13. * version 3 of the License, or any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
  19. *
  20. * You should have received a copy of the GNU Affero General Public
  21. * License along with this program. If not, see <http://www.gnu.org/licenses/>.
  22. */
  23. package com.owncloud.android.utils.glide;
  24. import com.bumptech.glide.load.data.DataFetcher;
  25. import com.bumptech.glide.load.model.stream.StreamModelLoader;
  26. import com.nextcloud.client.account.CurrentAccountProvider;
  27. import com.nextcloud.client.network.ClientFactory;
  28. import java.io.InputStream;
  29. /**
  30. * Custom Model for OwnCloudClient
  31. */
  32. public class CustomGlideStreamLoader implements StreamModelLoader<String> {
  33. private final CurrentAccountProvider currentAccount;
  34. private final ClientFactory clientFactory;
  35. public CustomGlideStreamLoader(CurrentAccountProvider currentAccount, ClientFactory clientFactory) {
  36. this.currentAccount = currentAccount;
  37. this.clientFactory = clientFactory;
  38. }
  39. @Override
  40. public DataFetcher<InputStream> getResourceFetcher(String url, int width, int height) {
  41. return new HttpStreamFetcher(currentAccount, clientFactory, url);
  42. }
  43. }