Skip to content

Instantly share code, notes, and snippets.

@jordanbeck
jordanbeck / JoinArrays.java
Last active December 30, 2015 12:09
Quick and dirty-ish way of joining an indeterminate number of arrays. Looping over them twice is probably not the best, but for my uses, it will only be at more 4 arrays, so the impact is minimal and will not be noticed in execution time. I'm aware that you can use Apache Commons Lang library and ArrayUtils.addAll, but I don't want another libra…
public static String[] joinArrays(String[]... arrays) {
int length = 0;
// Loop over to calculate final length
for (String[] array : arrays) {
length += array.length;
}
int traversedLength = 0;
String[] joinedArray = new String[length];
// Loop over second time to append
@jordanbeck
jordanbeck / README.md
Last active December 31, 2015 01:38
Attempting to update versionName and versionCode for gradle buildTypes [and currently failing]

This currently does not work the way I want, but I want to document it for personal reference.

Scenario:

I have an app that uses a library project being build in parallel. I want to have three different build types: debug, internal, release. I want each of those to have it's own package name, app name, version number, and version code. I want to be able to at least automate a build for internal on a nightly basis and upload to HockeyApp.

Problems:

  • First problem I ran into was that buildTypes in gradle do not allow you to specify versionNumber or versionCode. Just suffixes for those properties. So I moved to flavors...
  • Unfortunately, I'm using BuildConfig and with flavors, BuildConfig.java is not found by Android Studios. Everything does work this way (I can run gradle commands from the command line just fine), but without my IDE, it's kind of hard to work. Also, a downside to this approach is that it produces too many apks. If I have the three desired build types and have to have three flavors,
@jordanbeck
jordanbeck / ClickRecyclerViewAdapter.java
Last active October 14, 2015 16:05
Adding an easier way to add a click listener to a list item in RecyclerView. Current downside is that you have to call `super` from `onBindViewHolder`.
import android.support.annotation.CallSuper;
import android.support.v7.widget.RecyclerView;
import android.view.View;
public abstract class ClickRecyclerViewAdapter<T extends RecyclerView.ViewHolder>
extends RecyclerView.Adapter<T> {
protected OnRecyclerItemClickListener mItemClickListener;
public void setOnItemClickListener(OnRecyclerItemClickListener<T> itemClickListener) {
11-09 13:31:53.692 17761-17761/com.weightbook W/System.err: java.io.FileNotFoundException: /jacoco.exec: open failed: EROFS (Read-only file system)
11-09 13:31:53.692 17761-17761/com.weightbook W/System.err: at libcore.io.IoBridge.open(IoBridge.java:452)
11-09 13:31:53.692 17761-17761/com.weightbook W/System.err: at java.io.FileOutputStream.<init>(FileOutputStream.java:87)
11-09 13:31:53.692 17761-17761/com.weightbook W/System.err: at org.jacoco.agent.rt.internal_773e439.output.FileOutput.openFile(FileOutput.java:67)
11-09 13:31:53.692 17761-17761/com.weightbook W/System.err: at org.jacoco.agent.rt.internal_773e439.output.FileOutput.startup(FileOutput.java:49)
11-09 13:31:53.692 17761-17761/com.weightbook W/System.err: at org.jacoco.agent.rt.internal_773e439.Agent.startup(Agent.java:122)
11-09 13:31:53.692 17761-17761/com.weightbook W/System.err: at org.jacoco.agent.rt.internal_773e439.Agent.getInstance(Agent.java:50)
11-09 13:31:53.692 17761-17761/com.weightbook W/System.err: at o
#include <string.h>
#include <jni.h>
#include "test.h"
JNIEXPORT jstring JNICALL
Java_ai_aktive_jnitest_MainActivity_stringFromJNI(JNIEnv* env,
jobject thiz )
{
return (*env)->NewStringUTF(env, hello_world());
diff --git a/Etsy/src/main/java/com/etsy/android/ui/nav/dsl/NavigationKey.kt b/Etsy/src/main/java/com/etsy/android/ui/nav/dsl/NavigationKey.kt
index b4d17b9730..5949e18cfa 100644
--- a/Etsy/src/main/java/com/etsy/android/ui/nav/dsl/NavigationKey.kt
+++ b/Etsy/src/main/java/com/etsy/android/ui/nav/dsl/NavigationKey.kt
@@ -1,3 +1,11 @@
package com.etsy.android.ui.nav.dsl
+import com.etsy.android.lib.logger.referrers.Referrer
+
data class NavigationKey(val fragment: String, val params: Map<String, Any?>)
package com.etsy.android.ui.nav.dsl
data class NavigationKey(val fragment: String, val params: Map<String, Any?>)
diff --git a/internal-repos/android-jetpack-compose.tf b/internal-repos/android-jetpack-compose.tf
index be2967c..faf889c 100644
--- a/internal-repos/android-jetpack-compose.tf
+++ b/internal-repos/android-jetpack-compose.tf
@@ -13,7 +13,7 @@ resource "github_repository" "jetpack_compose_curriculum_repo" {
resource "github_team_repository" "jetpack_compose_curriculum_repo_all_team_admin_access" {
team_id = data.github_team.all_team.id
repository = github_repository.jetpack_compose_curriculum_repo.name
- permission = "admin"
+ permission = "push"
val price = Money(amount = BigDecimal(26), currencyCode = "USD")
val shop = Shop(1, "AThomeDesignGoods")
val signals = listOf("In 4 other carts", "Only 1 left!").map { title -> Signal(title) }.toList()
val variations = mapOf(
"Primary color" to "Beige",
"Style" to "Modern"
).map { entry -> Variation(entry.key, entry.value) }.toList()
val listing = Listing(
id = 0,
title = "Rustic Clay Collection Minimalism Mini Vases, Handmade Pottery Vases, Miscellaneous Vases",
@@ -5,6 +5,7 @@ import com.etsy.android.lib.logger.elk.grafana.Grafana
import com.etsy.android.lib.logger.logcat
import com.etsy.android.ui.cart.refactor.CartRefactorRepository
import com.etsy.android.ui.cart.refactor.CartRefactorResult
+import com.etsy.android.ui.cart.refactor.models.network.CartShopCouponResponse
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.withContext
import javax.inject.Inject
@@ -24,7 +25,11 @@ class ComboEndpointHandler @Inject constructor(
try {