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
package me.alirezaiyan.gist; | |
import android.content.Context; | |
import android.support.v7.widget.LinearLayoutManager; | |
import android.util.AttributeSet; | |
/** | |
* @author rezaiyan (alirezaiyann@gmail.com) | |
* @since 3/13/18 21:42. | |
* |
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
package com.ott.common.di; | |
/** | |
* @author rezaiyan (alirezaiyann@gmail.com) | |
* @since 6:29 PM. | |
*/ | |
import android.support.annotation.NonNull; |
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
package com.parvazyab.android.common.adapter; | |
import android.util.Log; | |
import com.google.gson.JsonSyntaxException; | |
import java.io.IOException; | |
import java.lang.annotation.Annotation; | |
import okhttp3.ResponseBody; |
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 static String formatPrice(double priceAsDouble) { | |
NumberFormat formatter = NumberFormat.getInstance(); | |
if (Math.round(priceAsDouble * 100) % 100 == 0) { | |
formatter.setMaximumFractionDigits(0); | |
} | |
return formatter.format(priceAsDouble); | |
} |
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
// Activity | |
val file = File(path) | |
val requestFile = RequestBody.create(MediaType.parse(context.contentResolver.getType(data.data)), file) | |
val body = MultipartBody.Part.createFormData("avatar", file.name, requestFile) | |
presenter.uploadUserAvatar(body) | |
// Activity | |
// Endpoint.kt | |
@Multipart | |
@POST(Const.URL.USER_AVATAR_UPDATE) |
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
suspend fun <T> Call<T>.await(): T = suspendCoroutine { continuation -> | |
enqueue(object : Callback<T> { | |
override fun onFailure(call: Call<T>, t: Throwable) { | |
continuation.resumeWithException(t) | |
} | |
override fun onResponse(call: Call<T>, response: Response<T>) { | |
if (response.isSuccessful) | |
continuation.resume(response.body()!!) |
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
package com.weembee.sdk.base | |
import retrofit2.HttpException | |
sealed class Result<out Any> { | |
data class Ok<T: Any>(val value: T): Result<T>() | |
data class NetworkError(val code: Int): Result<Nothing>() | |
data class Error(val throwable: Throwable): Result<Nothing>() | |
} |
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
@BindingAdapter("setActorsData") | |
fun setAvatars(recyclerView: RecyclerView, list: ArrayList<Actor>) { | |
val context = recyclerView.context | |
val radius = context.resources.getDimension(R.dimen.list_radius) | |
val peek = context.resources.getDimension(R.dimen.list_peek) | |
val layoutManager = TurnLayoutManager(context, | |
TurnLayoutManager.Gravity.END, | |
TurnLayoutManager.Orientation.HORIZONTAL, | |
radius.toInt(), | |
peek.toInt(), |
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
<keymap version="1" name="Default for XWin copy" parent="Default for XWin"> | |
<action id="$Copy"> | |
<keyboard-shortcut first-keystroke="ctrl c" /> | |
<keyboard-shortcut first-keystroke="ctrl insert" /> | |
<keyboard-shortcut first-keystroke="ctrl #1000632" /> | |
</action> | |
<action id="$Cut"> | |
<keyboard-shortcut first-keystroke="ctrl x" /> | |
<keyboard-shortcut first-keystroke="shift delete" /> | |
<keyboard-shortcut first-keystroke="ctrl #1000637" /> |
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
#!/bin/bash | |
echo -e "yes\n<USERNAME>\n<PASSWORD>" | sudo openconnect <HOST> |