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
| import android.os.Bundle | |
| import android.support.annotation.LayoutRes | |
| import android.support.v4.app.Fragment | |
| import android.view.LayoutInflater | |
| import android.view.View | |
| import android.view.ViewGroup | |
| import com.arellomobile.mvp.MvpDelegate | |
| import com.google.android.gms.maps.GoogleMap | |
| import com.google.android.gms.maps.MapView | |
| import com.google.android.gms.maps.OnMapReadyCallback |
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
| /* MediaDecoder | |
| Author: Andrew Stubbs (based on some examples from the docs) | |
| This class opens a file, reads the first audio channel it finds, and returns raw audio data. | |
| Usage: | |
| MediaDecoder decoder = new MediaDecoder("myfile.m4a"); | |
| short[] data; | |
| while ((data = decoder.readShortData()) != null) { |
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
| Genymotion emulators are already rooted and with SU installed | |
| To fix "adb server version (<server-version>) doesn't match this client (<client-version>); killing...": | |
| Change SDK location https://stackoverflow.com/questions/30757191/adb-and-genymotion-error-adb-server-is-out-of-date-killing-cannot-bind-tc | |
| To find current SDK location: | |
| https://stackoverflow.com/questions/34532063/finding-android-sdk-on-mac-and-adding-to-path | |
| System apps reside in: | |
| /system/app/<AppName>/<AppName>.apk |
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
| private Bitmap defaultPin; | |
| private GoogleMap googleMap; | |
| private List<MapItem> items; | |
| private void putItemsOnMap() { | |
| for (MapItem item : items) { | |
| // wrap google map marker with target, also set marker's pin with default pin bitmap, coordinates, etc, so it still be shown on map while real one is downloaded/transformed | |
| MarkerTarget marker = new MarkerTarget(googleMap.addMarker(new MarkerOptions().position(new LatLng(item.getLatitude(), item.getLongitude())).title(item.getName()).icon(BitmapDescriptorFactory.fromBitmap(defaultPin)))); | |
| Glide.with(this) | |
| .load(item.getPinImageUrl()) |
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 Observable<SomeResponse> downloadAndFilterListInResponse() { | |
| return mSomeRetrofitApi.downloadSomeData() // get response from server/etc | |
| // start iterating through list in response object | |
| .flatMap(response -> Observable.from(response.getListWeWantToFilterOut()) | |
| // NOTE: this is inner sequence, gets result from Observable.from | |
| .filter(item -> item != null) // filters out items that are null | |
| .toList() // all items combined into list again | |
| .take(100) // take only first 100 items, rest will be ignored | |
| .map(items -> { // now we need to 'map' list into response | |
| response.setListWeWantToFilterOut(items); // overwrite list in object with filtered list |
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 static void setActionDoneListener(EditText editText, final ActionDoneListener editTextActionDoneListener) { | |
| editText.setOnEditorActionListener(new TextView.OnEditorActionListener() { | |
| @Override | |
| public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { | |
| if (actionId == EditorInfo.IME_ACTION_DONE) { | |
| editTextActionDoneListener.onActionDone(); | |
| return false; | |
| } | |
| return false; | |
| } |
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
| private class HttpInterceptor implements Interceptor { | |
| @Override | |
| public Response intercept(Chain chain) throws IOException { | |
| Request request = chain.request(); | |
| //Build new request | |
| Request.Builder builder = request.newBuilder(); | |
| builder.header("Accept", "application/json"); //if necessary, say to consume JSON | |
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
| def toCamelCase(String string) { | |
| String result = "" | |
| string.findAll("[^\\W]+") { String word -> | |
| result += word.capitalize() | |
| } | |
| return result | |
| } | |
| afterEvaluate { project -> | |
| Configuration runtimeConfiguration = project.configurations.getByName('compile') |
NewerOlder