-
-
Notifications
You must be signed in to change notification settings - Fork 257
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1115 from nextcloud/glide
replace universal-image-loader with glide
- Loading branch information
Showing
31 changed files
with
537 additions
and
432 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
News-Android-App/src/main/java/com/bumptech/glide/samples/svg/SvgDecoder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package com.bumptech.glide.samples.svg; | ||
|
||
import static com.bumptech.glide.request.target.Target.SIZE_ORIGINAL; | ||
|
||
import androidx.annotation.NonNull; | ||
|
||
import com.bumptech.glide.load.Options; | ||
import com.bumptech.glide.load.ResourceDecoder; | ||
import com.bumptech.glide.load.engine.Resource; | ||
import com.bumptech.glide.load.resource.SimpleResource; | ||
import com.caverock.androidsvg.SVG; | ||
import com.caverock.androidsvg.SVGParseException; | ||
|
||
import java.io.IOException; | ||
import java.io.InputStream; | ||
|
||
/** | ||
* Decodes an SVG internal representation from an {@link InputStream}. | ||
*/ | ||
public class SvgDecoder implements ResourceDecoder<InputStream, SVG> { | ||
|
||
@Override | ||
public boolean handles(@NonNull InputStream source, @NonNull Options options) { | ||
return true; | ||
} | ||
|
||
public Resource<SVG> decode(@NonNull InputStream source, int width, int height, @NonNull Options options) | ||
throws IOException { | ||
try { | ||
SVG svg = SVG.getFromInputStream(source); | ||
if (width != SIZE_ORIGINAL) { | ||
svg.setDocumentWidth(width); | ||
} | ||
if (height != SIZE_ORIGINAL) { | ||
svg.setDocumentHeight(height); | ||
} | ||
return new SimpleResource<>(svg); | ||
} catch (SVGParseException ex) { | ||
throw new IOException("Cannot load SVG from stream", ex); | ||
} | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
News-Android-App/src/main/java/com/bumptech/glide/samples/svg/SvgDrawableTranscoder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package com.bumptech.glide.samples.svg; | ||
|
||
import android.graphics.Picture; | ||
import android.graphics.drawable.PictureDrawable; | ||
|
||
import androidx.annotation.NonNull; | ||
import androidx.annotation.Nullable; | ||
|
||
import com.bumptech.glide.load.Options; | ||
import com.bumptech.glide.load.engine.Resource; | ||
import com.bumptech.glide.load.resource.SimpleResource; | ||
import com.bumptech.glide.load.resource.transcode.ResourceTranscoder; | ||
import com.caverock.androidsvg.SVG; | ||
|
||
/** | ||
* Convert the {@link SVG}'s internal representation to an Android-compatible one ({@link Picture}). | ||
*/ | ||
public class SvgDrawableTranscoder implements ResourceTranscoder<SVG, PictureDrawable> { | ||
@Nullable | ||
@Override | ||
public Resource<PictureDrawable> transcode(@NonNull Resource<SVG> toTranscode, @NonNull Options options) { | ||
SVG svg = toTranscode.get(); | ||
Picture picture = svg.renderToPicture(); | ||
PictureDrawable drawable = new PictureDrawable(picture); | ||
return new SimpleResource<>(drawable); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.