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 convertMillisToString(long duration) { | |
long sec = (duration / 1000) % 60; | |
long min = (duration / (1000 * 60)) % 60; | |
return String.format(Locale.US, "%02d:%02d", min, sec); | |
} |
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 android.text.TextUtils; | |
import java.math.BigDecimal; | |
import java.util.ArrayList; | |
import java.util.Collection; | |
public class PersianNumbersToLettersConverter { | |
private final String splitter; | |
ArrayList<ArrayList<String>> words = new ArrayList<>(); | |
/** |
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 splitDigits(number: Long): String? { | |
return try { | |
val decimalFormat = DecimalFormat() | |
val decimalFormatSymbol = DecimalFormatSymbols() | |
decimalFormatSymbol.groupingSeparator = ',' | |
decimalFormat.decimalFormatSymbols = decimalFormatSymbol | |
decimalFormat.format(number) | |
} catch (ex: Exception) { | |
number.toString() | |
} |
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 android.os.Bundle | |
import android.view.LayoutInflater | |
import android.view.View | |
import android.view.ViewGroup | |
import androidx.annotation.LayoutRes | |
import androidx.databinding.DataBindingUtil | |
import androidx.databinding.ViewDataBinding | |
import com.kcd.karchidari.common.base.view.BaseFragment | |
abstract class FragmentX<T : ViewDataBinding>(@LayoutRes private val layoutResId: Int) : BaseFragment() { |
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 android.annotation.SuppressLint | |
import android.view.LayoutInflater | |
import android.view.ViewGroup | |
import androidx.annotation.LayoutRes | |
import androidx.databinding.DataBindingUtil | |
import androidx.databinding.ViewDataBinding | |
import androidx.recyclerview.widget.RecyclerView | |
import com.kcd.karchidari.BR | |
import timber.log.Timber | |
import java.util.* |
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 timber.log.Timber | |
import java.net.InetSocketAddress | |
import java.net.Socket | |
object InternetAvailability { | |
val isAvailable: Boolean | |
get() { | |
return try { | |
val socket = Socket() | |
socket.connect(InetSocketAddress("8.8.8.8", 53)) |
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 convertUriToPath(context: Context, uri: Uri?): String { | |
var filePath = "" | |
val wholeID = DocumentsContract.getDocumentId(uri) | |
// Split at colon, use second item in the array | |
val id = wholeID.split(":").toTypedArray()[1] | |
val column = arrayOf(MediaStore.Images.Media.DATA) | |
// where id is equal to | |
val sel = MediaStore.Images.Media._ID + "=?" |
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 View.showKeyboard(isShow: Boolean) { | |
val imm = context.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager | |
if (isShow) { | |
if (requestFocus()) imm.showSoftInput(this, 0) | |
} else { | |
imm.hideSoftInputFromWindow(windowToken, 0) | |
} | |
} |
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 androidx.lifecycle.LifecycleOwner | |
import androidx.lifecycle.LiveData | |
import androidx.lifecycle.Observer | |
import androidx.lifecycle.Transformations | |
object ExtensionsUtils { | |
fun <T> LifecycleOwner.observe(liveData: LiveData<T>?, action: (t: T) -> Unit) { | |
liveData?.observe(this, Observer { t -> action(t) }) | |
} |
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 getMsgHttpCodeErr(code: Int): String { | |
val result = StringBuilder() | |
result.append(when (code) { | |
in 400..499 -> { | |
result.append("Client errors") | |
result.append(" ===> ") | |
result.append(when (code) { | |
400 -> "Bad Request" | |
401 -> "Unauthorized" | |
402 -> "Payment Required" |
OlderNewer