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 me.shkschneider.skeleton.helper; | |
import android.text.TextUtils; | |
import android.util.Log; | |
/** | |
* Improved android.util.Log. | |
* | |
* Logs class and method automatically: | |
* [MyApplication onCreate():34] Hello, world! |
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
# <https://code.google.com/p/android/issues/detail?id=78377#c188> | |
# <https://stackoverflow.com/questions/30526173> | |
-keepattributes ** | |
-keep class !android.support.v7.internal.view.menu.**, ** { | |
!private <fields>; | |
protected <fields>; | |
public <fields>; | |
<methods>; | |
} | |
#-dontpreverify |
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
// Uses GSON library | |
// getJsonElement(jsonObject, "{errors}{email}[reasons:0]") | |
// Retrieves the first JsonElement of the JsonArray "reasons" of the JsonObject "email" of the JsonObject "errors"... in one line ;) | |
public static JsonElement getJsonElement(@NonNull final JsonObject jsonObject, final String string) { | |
// matches all | |
if (TextUtils.isEmpty(string)) { | |
return jsonObject; | |
} | |
// bad formats |
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 class Code39Extended { | |
protected Code39Extended() { | |
// Empty | |
} | |
private static final Character NULL = '\0'; | |
// <https://en.wikipedia.org/wiki/Code_39#Full_ASCII_Code_39> | |
private static final HashMap<String, HashMap<String, Character>> EXTENDED = new HashMap<String, HashMap<String, Character>>() { |
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
#!/usr/bin/env python | |
# | |
# <https://github.com/arzzen/python-simple-brainwallet> | |
# <https://github.com/jgilmour/brainwallet-check> | |
# <https://bitcointalk.org/index.php?topic=84238.0> | |
# JeromeS | |
# ShkSchneider <https://github.com/shkschneider> | |
import base58 | |
import binascii |
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
class MainViewModel : ViewModel() { | |
private lateinit var users: MutableLiveData<List<User>> | |
fun getUsers(): LiveData<List<User>> { | |
if (!::users.isInitialized) { | |
users = MutableLiveData() | |
// TODO loading of the data (hopefully using coroutines) | |
users.postValue(arrayListOf( | |
User(login = "user.name1"), |
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 val viewModel by lazy { | |
ViewModelProviders.of(this).get(MainViewModel::class.java) | |
} | |
// inside onCreate() | |
viewModel.getUsers().observe(this, Observer { | |
display(it) | |
}) |
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
object DataManager { | |
fun dummy(context: Context) { | |
val db = MyDatabase.get(context) | |
db.users().insert(User(login = "user.name")) | |
db.projects().insert(Project(name = "project.name")) | |
db.notifications().insert(Notification(msg = "created")) | |
} | |
} |
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
@Database(entities = [ | |
User::class, | |
Project::class, | |
Notification::class | |
], version = 1, exportSchema = false) | |
abstract class MyDatabase : RoomDatabase() { | |
abstract fun users(): Users | |
abstract fun projects(): Projects | |
abstract fun notifications(): Notifications | |
companion object { |
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
@UiThread | |
fun getUsers(context: Context): LiveData<List<User>> { | |
if (!::users.isInitialized) { | |
users = MutableLiveData() | |
users.postValue(MyDatabase.get(context).users().getAll()) | |
GlobalScope.launch(Dispatchers.Main) { | |
val usersFromDb: List<User> = async(Dispatchers.IO) { | |
return@async MyDatabase.get(context).users().getAll() | |
}.await() | |
users.value = usersFromDb |
OlderNewer