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 Context.createNotificationSettingsIntent() = | |
when { | |
Build.VERSION.SDK_INT >= Build.VERSION_CODES.O -> { | |
Intent(Settings.ACTION_APP_NOTIFICATION_SETTINGS).apply { | |
putExtra(Settings.EXTRA_APP_PACKAGE, packageName) | |
} | |
} | |
Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP -> { | |
Intent().apply { | |
action = "android.settings.APP_NOTIFICATION_SETTINGS" |
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 junit.framework.TestCase.assertEquals | |
import kotlinx.coroutines.* | |
import kotlinx.coroutines.test.TestCoroutineDispatcher | |
import org.junit.Rule | |
import org.junit.Test | |
/** | |
* Check the official example for ScopeBuilder with the following url. | |
* https://kotlinlang.org/docs/reference/coroutines/basics.html#scope-builder | |
* **/ |
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
// before | |
setOuterBounds(x, y, width, height); | |
setInnerBounds(x + 2, y + 2, width - 4, height - 4); | |
// after | |
setOuterBounds(bounds); | |
setInnerBounds(bounds.expand(-2)); |
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
// 반환 결과값이 단순한 경우 | |
int size() { | |
int result = 1; | |
for (Node each : getChildren()) | |
result += each.size(); | |
return result; | |
} | |
// 파라미터를 전달해서 결과를 수집하는 직관적인 경우 | |
asList() { |
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
// 가변 상태를 키로하고 값을 데이터로 하는 맵의 예제 | |
class FlexibleObject { | |
/*package*/ Map<String, Object> properties = new HashMap<String, Object>(); | |
/*package*/ Object getProperty(String key) { | |
return properties.get(key); | |
} | |
/*package*/ void setProperty(String key, Objecct value) { | |
properties.set(key, value); |
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
// 의존관계가 있는 경우 | |
Rectangle void setWidth(int width) { | |
this.width = width; | |
area = width * height; | |
} | |
// 의존관계가 있으나 명확하지 않은 경우 | |
Widget void setBorder(int width) { | |
this.width = width; | |
notifyListener |
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
class GraphicEditor { | |
... | |
public void mouseDown() { | |
tool.mouseDown(this); | |
} | |
... | |
} | |
class RectangleTool { | |
... |
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
class GraphicEditor { | |
... | |
public void mouseDown() { | |
tool.mouseDown(); | |
} | |
... | |
} | |
class RectangleTool { | |
private GraphicEditor editor; |
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
class ExchangeRate { | |
private int CountryCode; | |
public void b() { | |
Info info = new Info(); | |
int d = info.day; | |
int m = info.month; | |
int y = info.year; | |
} |
NewerOlder