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 Drawable getScaledDrawable(Context context, int resourceId, int scaleInDp) { | |
| BitmapFactory.Options options = new BitmapFactory.Options(); | |
| DisplayMetrics metrics = context.getResources().getDisplayMetrics(); | |
| options.inScreenDensity = metrics.densityDpi; | |
| options.inTargetDensity = metrics.densityDpi; | |
| options.inDensity = DisplayMetrics.DENSITY_DEFAULT; | |
| final int px = roundToInt(convertDpToPixel(scaleInDp)); | |
| Bitmap bitmap = BitmapFactory.decodeResource(context.getResources(), resourceId, options); | |
| BitmapDrawable drawable = new BitmapDrawable(context.getResources(), Bitmap.createScaledBitmap(bitmap, px, px, true)); | |
| Log.v("Scaling", "Scaling image [" + scaleInDp + "dp to " + px + "px] => [" + bitmap.getWidth() + "x" + bitmap.getHeight() + " px] to [" + drawable.getIntrinsicWidth() + "x" + drawable.getIntrinsicHeight() + " px]"); |
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
| task installObb() << { | |
| description = "Install all OBB packages" | |
| def stdout = new ByteArrayOutputStream() | |
| def obbFile = "main." + getVersionCode() + "." + getApplicationId() + ".obb" | |
| def source = "../" + obbFile + ".zip" | |
| def destination = "/sdcard/Android/obb/" + getApplicationId() + "/" + obbFile | |
| println("adb push " + source + " " + destination) |
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
| preBuild << { delete('src/main/res/values/com_crashlytics_export_strings.xml') } |
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 class ClassFactory { | |
| public static <T> T getInstance() { | |
| final Class<T> clazzOfT = null; | |
| T t = null; | |
| try { | |
| t = clazzOfT.newInstance(); | |
| } catch (final InstantiationException | IllegalAccessException e) { |
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 getCommitCount() { | |
| final Scanner s = new Scanner(getCommitNumberFromGit()); | |
| int count = 0; | |
| while (s.hasNextLine()) { | |
| s.nextLine(); | |
| count++; | |
| } | |
| return count; |
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
| package com.java.forloopvsiterator.test; | |
| import java.util.ArrayList; | |
| import java.util.ConcurrentModificationException; | |
| import java.util.Iterator; | |
| import java.util.List; | |
| public class Main { | |
| public static void main(String[] args) { |
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 void sendMessage(@NotNull final String fromEmail, @NotNull final String fromName) { | |
| final String apiKey = AppConfig.getValue(MANDRILLAPP_API_KEY); | |
| final MandrillServiceFactory serviceFactory = new MandrillServiceFactory(apiKey, new GsonJsonHandler(new Gson()), new HttpComponentsHandler(new DefaultHttpClient())); | |
| final Category.Messages messages = serviceFactory.getService(Category.Messages.class); | |
| final Struct message = Struct.with("text", "" + feedbackMessage.getText().toString()) | |
| .set("to", StructArray.with(Struct.with("email", Localization.getString(R.string.kEmailTitle)))) | |
| .set("subject", Localization.getString(currentMode.resourceId)) | |
| .set("from_email", fromEmail) | |
| .set("from_name", fromName); |
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
| /** | |
| * Created by Jan Rabe on 01/09/15. | |
| */ | |
| public class ListStorage<T> implements IStorage<T> { | |
| private final Type listType = new TypeToken<ArrayList<T>>() { | |
| }.getType(); | |
| @NotNull |
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 void setupCrashlytics(@NotNull final Activity activity) { | |
| final Crashlytics crashlytics = new Crashlytics(); | |
| // hack to set fully classified version name @see gradle task.canonicalReleaseVersionName | |
| try { | |
| final Field versionNameField = CrashlyticsCore.class.getDeclaredField("versionName"); | |
| versionNameField.setAccessible(true); | |
| versionNameField.set(crashlytics.core, Build.getValue(CANONICAL_VERSION_NAME)); | |
| } catch (Exception e) { | |
| e.printStackTrace(); |
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
| /** | |
| * Format dd.MM.yy hh:mm e.g.: 24.09.15 12:26 | |
| */ | |
| public static Date parseDate(final String date) { | |
| final DateFormat df = new SimpleDateFormat("dd.MM.yy hh:mm"); | |
| Date result = null; | |
| try { | |
| result = df.parse(date); |