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
<vector xmlns:android="http://schemas.android.com/apk/res/android" | |
android:width="24dp" | |
android:height="24dp" | |
android:viewportWidth="512" | |
android:viewportHeight="512"> | |
<path | |
android:fillColor="#FFF" | |
android:pathData="M160,0H0v160h160V0zM128,128H32V32h96V128zM64,64h32v32h-32zM352,0v160h160V0H352zM480,128h-96V32h96V128zM416,64h32v32h-32zM192,128h32v32h-32zM256,0h64v32h-64zM256,128l32,0l0,-32l32,0l0,-32l-96,0l0,-32l-32,0l0,32l0,16l0,16l64,0z" /> | |
<path | |
android:fillColor="#FFF" |
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
// Source + Unit Tests | |
package pl.expensive.storage; | |
import java.util.ArrayList; | |
import java.util.List; | |
public class SQLiteTableBuilder { | |
private String table; | |
private List<String> commands; |
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
struct node { | |
int value; | |
struct node *next; | |
}; | |
void push_front(struct node* root, int value) { | |
struct node* new_root = create_node(value); | |
if (!new_root) ERR("Cannot allocate memory for node to add/n"); | |
new_root->next = root; |
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
// From Plaid app [DesignerNewsLogin.class] | |
private void setupAccountAutocomplete() { | |
if (ContextCompat.checkSelfPermission(this, Manifest.permission.GET_ACCOUNTS) == | |
PackageManager.PERMISSION_GRANTED) { | |
permissionPrimer.setVisibility(View.GONE); | |
final Account[] accounts = AccountManager.get(this).getAccounts(); | |
final Set<String> emailSet = new HashSet<>(); | |
for (Account account : accounts) { | |
if (Patterns.EMAIL_ADDRESS.matcher(account.name).matches()) { |
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
/** | |
* Specifies how a [Lazy] instance synchronizes access among multiple threads. | |
*/ | |
public enum class LazyThreadSafetyMode { | |
/** | |
* Locks are used to ensure that only a single thread can initialize the [Lazy] instance. | |
*/ | |
SYNCHRONIZED, |
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
fun SQLiteDatabase.doesTableExistIncludingTemps(tableName: String): Boolean { | |
val sql = """SELECT name | |
FROM (SELECT * FROM sqlite_master UNION ALL SELECT * FROM sqlite_temp_master) | |
WHERE type='table';""" | |
val c = rawQuery(sql, null) | |
while (c.moveToNext()) { | |
if (c.getString(0) == tableName) return true else continue | |
} |
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
fun SQLiteDatabase.doesTableExist(tableName: String): Boolean { | |
val sql = "SELECT name FROM sqlite_master WHERE type='table';" | |
val c = rawQuery(sql, null) | |
while (c.moveToNext()) { | |
if (c.getString(0) == tableName) return true | |
else continue | |
} | |
return false | |
} |
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
@Test fun columnsForCategoryTable() { | |
val columns = getTableColumns(database.readableDatabase, "tbl_category") | |
assertThat(columns).containsExactly("uuid", "name", "color") | |
} | |
@Test fun createDefaultCategoriesTable() { | |
assertThat(database.readableDatabase.doesTableExist("tbl_category")).isTrue() | |
} |
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
@Test | |
public void storeWallets() { | |
Wallet wallet = Wallet.create(UUID.randomUUID(), "Test-Walet"); | |
model.insert(wallet); | |
assertThat(model.list()) | |
.containsExactly(wallet); | |
} |
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
@Test | |
public void listWallets() { | |
Wallet bankWallet = Wallet.create(randomUUID(), "bank"); | |
Wallet ccWallet = Wallet.create(randomUUID(), "credit card"); | |
db.execSQL(storeWalletSql(bankWallet)); | |
db.execSQL(storeWalletSql(ccWallet)); | |
assertThat(storage.list()).containsExactly(bankWallet, ccWallet); | |
} |
NewerOlder