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 AuthenticationManagerTest : KoinTest{ | |
@Before | |
fun initTest(){ | |
loadKoinModules(listOf(module { | |
scope(TEST_SCOPE, override = true) { MockWebServer() } | |
factory (override = true){ AuthenticationManager(get<MockWebServer>().url("").toString()) } | |
})) | |
getKoin().createScope(TEST_SCOPE) | |
} |
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 AuthenticationManagerTest : KoinTest{ | |
lateinit var server : MockWebServer | |
@Before | |
fun initTest(){ | |
server = MockWebServer() | |
} | |
@After |
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 TestMockResponseFileReader{ | |
@Test | |
fun `read simple file`(){ | |
val reader = MockResponseFileReader("test.json") | |
assertEquals(reader.content, "success") | |
} | |
} |
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 MockResponseFileReader(path: String) { | |
val content: String | |
init { | |
val reader = InputStreamReader(this.javaClass.classLoader.getResourceAsStream(path)) | |
content = reader.readText() | |
reader.close() | |
} | |
} |
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
{ | |
"token": "RpIjoiEJgOdrXjo9vM1espZWyaHDfCUfVXDII7-BWdaGtBctfwsCFXQ", | |
"idUser": 31098 | |
} |
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 AuthenticationManager(endpoint: String) { | |
var login : LoginResponse? = null | |
private val okHttpClient = OkHttpClient.Builder().build() | |
private val retrofit = Retrofit.Builder() | |
.baseUrl(endpoint) | |
.client(okHttpClient) | |
.addConverterFactory(GsonConverterFactory.create()) | |
.addCallAdapterFactory(RxJava2CallAdapterFactory.create()) |
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
private var shadow: Bitmap? = null | |
private val shadowPaint = Paint(ANTI_ALIAS_FLAG) | |
private var shadowRadius = context.resources.getDimension(R.dimen.shadow_default_radius) | |
private var shadowXOffset = context.resources.getDimension(R.dimen.shadow_default_x_translation) | |
private var shadowYOffset = context.resources.getDimension(R.dimen.shadow_default_y_translation) | |
private var shadowColor = ContextCompat.getColor(context, R.color.shadow_default_color) | |
private lateinit var shadowView: ImageView |
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 getPath(width: Int, height: Int): Path { | |
return Path().apply { | |
val cutoutRadius = 50f | |
val cutoutWidth = if (cutoutRadius != 0f) cutoutRadius else width / 8f | |
val cutoutHeight = 3 * cutoutWidth / 4 | |
val padding = 0f | |
val pathLeft = padding | |
val pathRight = width - padding | |
val pathTop = padding |
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
override fun draw(canvas: Canvas) { | |
if (shapePath != null) { | |
canvas.clipPath(shapePath) | |
} | |
super.draw(canvas) | |
} |
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
findViewById<TextView>(R.id.tv_round_outline).apply { | |
val provider = object : ViewOutlineProvider() { | |
override fun getOutline(view: View, outline: Outline) { | |
outline.setRoundRect(0, 0, view.width, view.height, view.height / 2f) | |
} | |
} | |
outlineProvider = provider | |
clipToOutline = true | |
} |