Android REST Controller with Simple Cache Control Headers using Retrofit 1.9.0 + OkHttp 2.2.0
This file contains hidden or 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
| #!/bin/bash | |
| #Modify this with your IP range | |
| MY_IP_RANGE="192\.168\.1" | |
| #You usually wouldn't have to modify this | |
| PORT_BASE=5555 | |
| #List the devices on the screen for your viewing pleasure | |
| adb devices |
This file contains hidden or 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
| // on error the server sends JSON | |
| /* | |
| { "error": { "data": { "message":"A thing went wrong" } } } | |
| */ | |
| // create model classes.. | |
| public class ErrorResponse { | |
| Error error; | |
This file contains hidden or 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 final class Api { | |
| //region Variables | |
| private static final String API_HOST = Application.string(R.string.api_server); | |
| private static final Object sLockObject = new Object(); | |
| private static Service sService = null; | |
| static final int DISK_CACHE_SIZE = 50 * 1024 * 1024; // 50MB | |
| //endregion |
This file contains hidden or 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
| # built application files | |
| *.apk | |
| *.ap_ | |
| # files for the dex VM | |
| *.dex | |
| # Java class files | |
| *.class |
This file contains hidden or 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
| #!/bin/bash | |
| ## Copyright (C) 2015 Cerebral Gardens http://www.cerebralgardens.com/ | |
| ## | |
| ## Permission is hereby granted, free of charge, to any person obtaining a copy of this | |
| ## software and associated documentation files (the "Software"), to deal in the Software | |
| ## without restriction, including without limitation the rights to use, copy, modify, | |
| ## merge, publish, distribute, sublicense, and/or sell copies of the Software, and to | |
| ## permit persons to whom the Software is furnished to do so, subject to the following | |
| ## conditions: |
This file contains hidden or 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
| /** | |
| * The MIT License (MIT) | |
| * | |
| * Copyright (c) 2015 Circle Internet Financial | |
| * | |
| * Permission is hereby granted, free of charge, to any person obtaining a copy | |
| * of this software and associated documentation files (the "Software"), to deal | |
| * in the Software without restriction, including without limitation the rights | |
| * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
| * copies of the Software, and to permit persons to whom the Software is |
This file contains hidden or 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
| mWebView.setWebViewClient(new WebViewClient() { | |
| @Override | |
| public WebResourceResponse shouldInterceptRequest(WebView view, String url) { | |
| if (url.contains("creditcard_cvc.jpg")) { | |
| Log.v("WebView", "Replacing [" + url + "] with [R.raw.tmp_replacement]"); | |
| ContentResolver contentResolver = getActivity().getContentResolver(); | |
| return new WebResourceResponse(contentResolver.getType(Uri.parse(url)), "UTF-8", getResources().openRawResource(R.raw.tmp_replacement)); | |
| } | |
| return super.shouldInterceptRequest(view, url); |
OlderNewer
