Skip to content

Instantly share code, notes, and snippets.

View dmytrodanylyk's full-sized avatar

Dmytro Danylyk dmytrodanylyk

View GitHub Profile
apply plugin: 'findbugs'
task findbugs(type: FindBugs) {
excludeFilter = file("$project.rootDir/tools/rules-findbugs.xml")
classes = fileTree("$project.buildDir/intermediates/classes/dev/debug/com/dd")
source = fileTree("$project.rootDir/src/main/java/com/dd/")
classpath = files()
reports {
xml.enabled = false
apply plugin: 'com.android.application'
apply from: "$project.rootDir/tools/script-findbugs.gradle"
...
// MainActivity.java
...
private void someMethod(int variable) {
switch (variable) {
case 1:
System.out.println("1");
case 2:
System.out.println("2");
<FindBugsFilter>
<Bug pattern="SF_SWITCH_NO_DEFAULT" />
<Bug pattern="SF_SWITCH_FALLTHROUGH" />
</FindBugsFilter>
apply plugin: 'pmd'
task pmd(type: Pmd) {
ruleSetFiles = files("$project.rootDir/tools/rules-pmd.xml")
source = fileTree('src/main/java/')
reports {
xml.enabled = false
html.enabled = true
html.destination = "$project.buildDir/outputs/pmd/pmd.html"
apply plugin: 'com.android.application'
apply from: "$project.rootDir/tools/script-pmd.gradle"
...
// MainActivity.java
...
private void someMethod(int a, int b, int c, int d) {
if (a > b) {
if (b > c) {
if (c > d) {
if (d > a) {
// some logic
class NewPresenter(private val todoDao: TodoDao) {
private var description: CharSequence? = null
fun bind(view: TodoView) {
todoDao.all()
.observeOn(AndroidSchedulers.mainThread())
.subscribe { view.updateTodos(it) }
}
// dispatches execution onto the Android main UI thread
private val uiContext: CoroutineContext = UI
// represents a common pool of shared threads as the coroutine dispatcher
private val bgContext: CoroutineContext = CommonPool
private fun loadData() = launch(uiContext) {
view.showLoading() // ui thread
val task = async(bgContext) { dataProvider.loadData("Task") }
val result = task.await() // non ui thread, suspend until finished
view.showData(result) // ui thread
}