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
<html> | |
<head> | |
<title>Simple hovercard</title> | |
<script src="http://code.jquery.com/jquery-latest.min.js" | |
type="text/javascript"></script> | |
<script> | |
$(function(){ | |
$('#hoverbox').mouseleave(function(){ | |
$('#hoverbox').hide(); |
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
package com.android.fresco; | |
import org.apache.commons.lang3.StringUtils; | |
import android.graphics.Bitmap; | |
import android.net.Uri; | |
import android.util.Log; | |
import com.facebook.cache.common.CacheKey; | |
import com.facebook.cache.common.SimpleCacheKey; |
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
@Override | |
public WebResourceResponse shouldInterceptRequest(WebView view, WebResourceRequest request) { | |
String resourceUrl = request.getUrl().toString(); | |
String fileExtension = WebviewResourceMappingHelper.getInstance().getFileExt(resourceUrl); | |
if(WebviewResourceMappingHelper.getInstance().getOverridableExtensions().contains(fileExtension)){ | |
String encoding = "UTF-8"; | |
String assetName = WebviewResourceMappingHelper.getInstance().getLocalAssetPath(resourceUrl); | |
if (StringUtils.isNotEmpty(assetName)) { | |
String mimeType = WebviewResourceMappingHelper.getInstance().getMimeType(fileExtension); | |
if (StringUtils.isNotEmpty(mimeType)) { |
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
public WebResourceResponse getWebResourceResponseFromAsset(String assetPath, String mimeType, String encoding) throws IOException{ | |
InputStream inputStream = getActivity().getAssets().open(assetPath); | |
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { | |
int statusCode = 200; | |
String reasonPhase = "OK"; | |
Map<String, String> responseHeaders = new HashMap<String, String>(); | |
responseHeaders.put("Access-Control-Allow-Origin", "*"); | |
return new WebResourceResponse(mimeType, encoding, statusCode, reasonPhase, responseHeaders, inputStream); | |
} | |
return new WebResourceResponse(mimeType, encoding, inputStream); |
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
public static InputStream readFromCacheSync(String imageUrl) { | |
CacheKey cacheKey = DefaultCacheKeyFactory.getInstance().getEncodedCacheKey(ImageRequest.fromUri(imageUrl), null); | |
StagingArea stagingArea = StagingArea.getInstance(); | |
EncodedImage encodedImage = stagingArea.get(cacheKey); | |
if (encodedImage != null) { | |
return encodedImage.getInputStream(); | |
} | |
try { | |
return readFromDiskCache(cacheKey); |
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
{ | |
"hash": "5d5a03b6cc4edc0cc7d44f46c8ad3b30", | |
"urls": [ | |
"http://myntra.myntassets.com/checkout/build/css/mobile-cart-android-v2-b0533de818b7c79a0c51249a869214dca3f09d53.zip.css", | |
"http://myntra.myntassets.com/checkout/build/js/cart-app-android-v2-319197031848b6cc165d220a48a4c96764cb5cc6.zip.js", | |
"http://myntra.myntassets.com/checkout/build/js/common-app-android-v2-b001242bcde0440a307bd801bc67f9cb54869924.zip.js", | |
"http://myntra.myntassets.com/checkout/build/js/common-app-v2-b001242bcde0440a307bd801bc67f9cb54869924.zip.js", | |
"http://myntra.myntassets.com/checkout/images/checkout_sprite_2x_v22.png", | |
"http://myntra.myntassets.com/checkout/images/checkout_sprite_v22.png", | |
"http://myntra.myntassets.com/checkout/images/sprite-global_v70.png", |
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
private static void downloadBitmap(ImageRequest imageRequest, Context context, final IBitmapDownloader iBitmapDownloader) { | |
DataSource<CloseableReference<CloseableImage>> dataSourceImage = Fresco.getImagePipeline().fetchDecodedImage(imageRequest, context); | |
DataSubscriber<CloseableReference<CloseableImage>> dataSubscriberImage = new BaseDataSubscriber<CloseableReference<CloseableImage>>() { | |
@Override | |
public void onNewResultImpl(DataSource<CloseableReference<CloseableImage>> dataSource) { | |
CloseableReference<CloseableImage> imageReference = dataSource.getResult(); | |
if (imageReference != null) { | |
iBitmapDownloader.onSuccess(imageReference); | |
} | |
else{ |
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
CloseableReference<CloseableImage> imageRef = imageReference.clone(); | |
imageRefMap.put(imageUrl,imageRef); | |
CloseableImage image = imageRef.get(); | |
final Bitmap bitmap = ((CloseableBitmap) image).getUnderlyingBitmap(); |
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
Iterator<Map.Entry<String, CloseableReference<CloseableImage>>> entries = imageRefMap.entrySet().iterator(); | |
while (entries.hasNext()) { | |
Map.Entry<String, CloseableReference<CloseableImage>> entry = entries.next(); | |
CloseableReference<CloseableImage> closeableRef = entry.getValue(); | |
if(closeableRef != null){ | |
closeableRef.close(); | |
} | |
} |
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
try { | |
CacheKey cacheKey = new SimpleCacheKey(url); | |
ByteArrayOutputStream stream = new ByteArrayOutputStream(); | |
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, stream); | |
final byte[] byteArray = stream.toByteArray(); | |
Fresco.getImagePipelineFactory().getMainDiskStorageCache().insert(cacheKey, new WriterCallback() { | |
@Override | |
public void write(OutputStream outputStream) throws IOException { | |
outputStream.write(byteArray); | |
} |
OlderNewer