Skip to content

Instantly share code, notes, and snippets.

View malihehmoradi's full-sized avatar
✨Looking for new challenges✨

Maliheh Moradi malihehmoradi

✨Looking for new challenges✨
View GitHub Profile
@malihehmoradi
malihehmoradi / Context.kt
Last active October 7, 2023 16:30
TextAlign.Justify doesn't work with Persian text in Text composable, just put it in a CompositionLocalProvider with LayoutDirection.Rtl for working. #android #compose #kotlin
CompositionLocalProvider(LocalLayoutDirection provides LayoutDirection.Rtl) {
Text(
text = stringResource(id = R.string.contactUs),
textAlign = TextAlign.Justify,
modifier = Modifier
.fillMaxWidth()
)
}
@malihehmoradi
malihehmoradi / SensorActivity.kt
Last active September 24, 2023 12:01
Get last ambient temperature from android device with temperature sensor.
public class SensorActivity extends Activity implements SensorEventListener {
private final SensorManager mSensorManager;
private final Sensor mTempSensor;
private float lastTemperature= 0F
public SensorActivity() {
mSensorManager = (SensorManager)getSystemService(SENSOR_SERVICE);
mTempSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_AMBIENT_TEMPERATURE);
@malihehmoradi
malihehmoradi / PaymentMethod.kt
Last active March 14, 2023 13:14
Create an enum class for defining two constants with specific name and value.
import java.text.NumberFormat
import java.util.*
enum class PaymentMethod(val balance: Double) {
CASH(14.02) {
override fun printFormattedAmount(): String {
return NumberFormat.getCurrencyInstance(Locale.US).format(balance)
}
},