Skip to content

Instantly share code, notes, and snippets.

/*
* Copyright 2024 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
from xml.dom import minidom
from pathlib import Path
import sys
import os
import re
import glob
import json
import argparse
path_to_konsist_report = os.getcwd() + '/konsistTest/build/test-results/testAppProductionDebugUnitTest'
@chethann
chethann / RemoteImage.kt
Created December 22, 2022 13:52
A simple Composable / utility which uses Glide to load remote images in Jetpack compose. All goodness and featured of Glide come by default!
import android.graphics.Bitmap
import android.graphics.drawable.Drawable
import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.width
import androidx.compose.runtime.*
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.ColorFilter
import androidx.compose.ui.graphics.asImageBitmap
@chethann
chethann / WebviewResourceMappingHelper.java
Created November 24, 2017 09:19
WebviewResourceMappingHelper Sample Code
package com.test.android.helpers;
import android.os.Build;
import android.webkit.WebResourceResponse;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.test.android.Application;
import org.apache.commons.collections.CollectionUtils;
CacheKey cacheKey = DefaultCacheKeyFactory.getInstance().getEncodedCacheKey(ImageRequest.fromUri(imageUrl));
StagingArea stagingArea = StagingArea.getInstance();
EncodedImage result = stagingArea.get(cacheKey);
if(result != null){
result.close();
return true;
}
return ImagePipelineFactory.getInstance().getMainDiskStorageCache()
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);
}
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();
}
}
CloseableReference<CloseableImage> imageRef = imageReference.clone();
imageRefMap.put(imageUrl,imageRef);
CloseableImage image = imageRef.get();
final Bitmap bitmap = ((CloseableBitmap) image).getUnderlyingBitmap();
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{
{
"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",