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 void handleMessage(final Message msg) { | |
switch (msg.what) { | |
case REQUEST_SUBMIT: { | |
Action action = (Action) msg.obj; | |
dispatcher.performSubmit(action); | |
break; | |
} | |
case REQUEST_CANCEL: { | |
Action action = (Action) msg.obj; | |
dispatcher.performCancel(action); |
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
RequestCreator requestCreator = picasso.load("http://i.imgur.com/DvpvklR.png"); | |
requestCreator.tag("TagName"); | |
requestCreator.memoryPolicy(MemoryPolicy.NO_CACHE); | |
requestCreator.networkPolicy(NetworkPolicy.NO_STORE); | |
requestCreator.placeholder(R.drawable.placeholder); | |
requestCreator.error(R.drawable.error); | |
//Finally load into imageView. | |
requestCreator.into(imageView); |
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 Picasso build() { | |
Context context = this.context; | |
if (downloader == null) { | |
downloader = new OkHttp3Downloader(context); | |
} | |
if (cache == null) { | |
cache = new LruCache(context); | |
} | |
if (service == null) { |
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
class PicassoExecutorService extends ThreadPoolExecutor { | |
private static final int DEFAULT_THREAD_COUNT = 3; | |
PicassoExecutorService() { | |
super(DEFAULT_THREAD_COUNT, DEFAULT_THREAD_COUNT, 0, TimeUnit.MILLISECONDS, | |
new PriorityBlockingQueue<Runnable>(), new Utils.PicassoThreadFactory()); | |
} | |
void adjustThreadCount(NetworkInfo info) { | |
if (info == null || !info.isConnectedOrConnecting()) { |
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
function showToast(){ | |
handler.handleMessage('This is a toast message from Javascript !!'); | |
} | |
function giveCallbackToClient(){ | |
handler.setWebViewTextCallback(); | |
} |
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 class CustomWebViewClient extends WebViewClient { | |
private String TAG = "CustomWebViewClient"; | |
@Override | |
public void onPageStarted(WebView view, String url, Bitmap favicon) { | |
super.onPageStarted(view, url, favicon); | |
Log.d(TAG, "The webView with the following url " + url + " has started loading"); | |
} |
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
function setText(text){ | |
document.getElementById('text-container').innerHTML=text; | |
} |
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
@NonNull | |
public static String formatScript(@NonNull final String function, | |
@Nullable final Object... params) { | |
final StringBuilder builder = new StringBuilder(function).append('('); | |
final int length = params.length; | |
for (int i = 0; i < params.length; ++i) { | |
if (params[i] instanceof String) { | |
builder.append("\'"); | |
} |
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 void callJavaScriptFunction(final WebView webView, final String script) { | |
if (webView == null) { | |
return; | |
} | |
webView.post(new Runnable() { | |
@Override | |
public void run() { | |
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { | |
webView.evaluateJavascript(script, new ValueCallback<String>() { | |
@Override |
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 class WebViewJsInterface { | |
private WebView webView; | |
private Context context; | |
public WebViewJsInterface(Context context, WebView webView) { | |
this.webView = webView; | |
this.context=context; | |
} |
NewerOlder