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
public class DataBindingAdapters { | |
@BindingAdapter("visible") public static void setVisibility(View view, boolean isVisible) { | |
view.setVisibility(isVisible ? VISIBLE : GONE); | |
} | |
} |
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
/** | |
* Many things are omitted to focus on the relevant data. | |
*/ | |
public class Activity extends AppCompatActivity { | |
Binder binder; | |
@Override protected void onCreate(@Nullable Bundle savedInstanceState) { | |
bind(); | |
} |
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
import com.jakewharton.rxrelay2.PublishRelay | |
import io.reactivex.Observable | |
import io.reactivex.Observer | |
import org.junit.rules.TestRule | |
import org.junit.runner.Description | |
import org.junit.runners.model.Statement | |
/** | |
* [PublishRelay]-like [Observable] enforcing: | |
* 1. a unique observer at a time, and |
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
const regexp = /\[(.*?)\]\((.+?)\)/g | |
const editor = document.querySelector('.ql-editor') | |
editor.addEventListener( | |
'keydown', | |
(e) => { | |
if (e.metaKey && e.shiftKey && e.key == 9) { | |
let innerHtml = editor.innerHTML | |
const matches = innerHtml.matchAll(regexp); | |
for (const match of 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
public class XmlOrJsonConverterFactory extends Converter.Factory { | |
final Converter.Factory xml = SimpleXmlConverterFactory.create(); | |
final Converter.Factory gson = GsonConverterFactory.create(); | |
@Override | |
public Converter<ResponseBody, ?> responseBodyConverter( | |
Type type, Annotation[] annotations, Retrofit retrofit) { | |
// Retrofit gives us all the annotations so we just need to check | |
for (Annotation annotation : annotations) { |
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
/** | |
* Many things are omitted to focus on the relevant data. | |
*/ | |
public class Activity extends AppCompatActivity { | |
Binder binder; | |
@Override protected void onCreate(@Nullable Bundle savedInstanceState) { | |
Object lastCustomNonConfigInstance = getLastCustomNonConfigurationInstance(); | |
if (lastCustomNonConfigInstance != null) { | |
binder = (Binder) lastCustomNonConfigInstance; |
OlderNewer