Skip to content

Instantly share code, notes, and snippets.

Tomasz tmaxxdd

Block or report user

Report or block tmaxxdd

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View dbl.xml
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@{user.firstName}" />
View rxbinding.java
import com.jakewharton.rxbinding.view.RxView;
...
Button button = (Button) findViewById(R.id.button);
RxView.clicks(button)
.subscribe(aVoid -> {
//Perform some work here//
});
View anko.kt
// Same as findViewById() but simpler to use
val name = find<TextView>(R.id.name)
name.hint = "Enter your name"
name.onClick { /*do something*/ }
View dsl.kt
verticalLayout {
val name = editText()
button("Say Hello") {
onClick { toast("Hello, ${name.text}!") }
}
}
View butterknife.java
class ExampleActivity extends Activity {
@BindView(R.id.user) EditText username;
@BindView(R.id.pass) EditText password;
@BindString(R.string.login_error) String loginErrorMessage;
@OnClick(R.id.submit) void submit() {
// TODO call server...
}
View ext_fun_bind.kt
//XML
<TextView
android:id="@+id/hello"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
//Import all layout
kotlinx.android.synthetic.main.activity_main.*
//Kotlin
View listener_hell.java
final EditText name = (EditText) v.findViewById(R.id.name);
//Create a TextWatcher and specify that this TextWatcher should be called whenever the EditText’s content changes//
name.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
//Perform some work//
View firebase_read.kt
//Get path to data according to selected tab
val databaseRef = FirebaseDatabase.getInstance().getReference(ref)
val topics = ArrayList<Topic>()
databaseRef.orderByChild("index").addValueEventListener(object : ValueEventListener {
override fun onDataChange(data: DataSnapshot) {
/*
In the database a child contains more fields
than Topic model. So we have to choose which one we want to match.
*/
View firebase_rules.json
// Simple rules that allow everyone to fetch the data
// and change it only by admin.
{
"rules": {
".read": true,
".write": false
}
}
View firebase_db_init.kt
// This is a reference to the project (root)
// Here you can manage state and logging
val database = FirebaseDatabase.getInstance()
// This is a reference to the specific data.
// Here you can work with your informations.
val myRef = database.getReference("fajne-koty")
You can’t perform that action at this time.