This repository has been archived by the owner on Sep 30, 2021. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 927
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…rm dialog first before forking.
- Loading branch information
Kosh
committed
Mar 1, 2017
1 parent
60cb930
commit c42d3cd
Showing
16 changed files
with
152 additions
and
40 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
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
78 changes: 78 additions & 0 deletions
78
app/src/main/java/com/fastaccess/provider/uil/UILImageGetter.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,78 @@ | ||
package com.fastaccess.provider.uil; | ||
|
||
import android.content.res.Resources; | ||
import android.graphics.Bitmap; | ||
import android.graphics.Canvas; | ||
import android.graphics.drawable.BitmapDrawable; | ||
import android.graphics.drawable.Drawable; | ||
import android.support.v4.content.ContextCompat; | ||
import android.text.Html; | ||
import android.view.View; | ||
import android.widget.TextView; | ||
|
||
import com.fastaccess.R; | ||
import com.nostra13.universalimageloader.core.ImageLoader; | ||
import com.nostra13.universalimageloader.core.listener.SimpleImageLoadingListener; | ||
|
||
import java.io.InputStream; | ||
|
||
public class UILImageGetter implements Html.ImageGetter { | ||
private TextView container; | ||
|
||
public UILImageGetter(TextView view) { | ||
this.container = view; | ||
} | ||
|
||
@Override public Drawable getDrawable(String source) { | ||
UrlImageDownloader urlDrawable = new UrlImageDownloader(container.getResources(), source); | ||
urlDrawable.drawable = ContextCompat.getDrawable(container.getContext(), R.drawable.ic_image); | ||
ImageLoader.getInstance().loadImage(source, new SimpleListener(urlDrawable)); | ||
return urlDrawable; | ||
} | ||
|
||
private class SimpleListener extends SimpleImageLoadingListener { | ||
UrlImageDownloader urlImageDownloader; | ||
|
||
public SimpleListener(UrlImageDownloader downloader) { | ||
super(); | ||
urlImageDownloader = downloader; | ||
} | ||
|
||
@Override public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) { | ||
int width = loadedImage.getWidth(); | ||
int newWidth = width; | ||
if (width > container.getWidth()) { | ||
newWidth = container.getWidth(); | ||
} | ||
BitmapDrawable result = new BitmapDrawable(container.getResources(), loadedImage); | ||
result.setBounds(0, 0, newWidth, loadedImage.getHeight()); | ||
urlImageDownloader.setBounds(0, 0, newWidth, result.getIntrinsicHeight()); | ||
urlImageDownloader.drawable = result; | ||
container.requestLayout(); | ||
container.invalidate(); | ||
} | ||
} | ||
|
||
private class UrlImageDownloader extends BitmapDrawable { | ||
public Drawable drawable; | ||
|
||
public UrlImageDownloader(Resources res, InputStream is) { | ||
super(res, is); | ||
} | ||
|
||
public UrlImageDownloader(Resources res, String filepath) { | ||
super(res, filepath); | ||
drawable = new BitmapDrawable(res, filepath); | ||
} | ||
|
||
public UrlImageDownloader(Resources res, Bitmap bitmap) { | ||
super(res, bitmap); | ||
} | ||
|
||
@Override public void draw(Canvas canvas) { | ||
if (drawable != null) { | ||
drawable.draw(canvas); | ||
} | ||
} | ||
} | ||
} |
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
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