Skip to content

Instantly share code, notes, and snippets.

View muchbeer's full-sized avatar

George Machibya muchbeer

  • Dar es Salaam
View GitHub Profile
@muchbeer
muchbeer / ConstraintLayout1.kt
Last active August 26, 2022 13:54 — forked from mitchtabian/ConstraintLayout1.kt
Learn how to create layouts with Android Studio’s Layout Editor and ConstraintLayout. This course will teach the basics of using ConstraintLayout, such as Constraints, Guidelines, Barriers, Bias, and Chains.
// Align composables with respect to one another
@Composable
fun CircularIndeterminateProgressBar(isDisplayed: Boolean) {
if (isDisplayed) {
ConstraintLayout(
modifier = Modifier.fillMaxSize()
) {
val (progress, text) = createRefs()
CircularProgressIndicator(
modifier = Modifier.constrainAs(progress) {
@muchbeer
muchbeer / CameraXFragment.kt
Created June 23, 2021 07:29 — forked from Rickyip/CameraXFragment.kt
CameraX on Android Fragment in Kotlin
import android.Manifest
import android.annotation.SuppressLint
import android.content.Context
import android.content.pm.PackageManager
import android.graphics.drawable.GradientDrawable
import android.net.Uri
import android.os.Bundle
import android.util.Log
import android.view.LayoutInflater
import android.view.View
@muchbeer
muchbeer / image_overlay.xml
Last active July 24, 2020 12:47 — forked from sazal-ns/image_overlay.xml
Scrim Overlay for Text background.
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:angle="-90"
android:startColor="#00000000"
android:centerColor="#00000000"
android:endColor="#00000000"
android:type="linear"/>
/* The date/time conversion code is going to be moved outside the asynctask later,
* so for convenience we're breaking it out into its own method now.
*/
private String getReadableDateString(long time){
// Because the API returns a unix timestamp (measured in seconds),
// it must be converted to milliseconds in order to be converted to valid date.
Date date = new Date(time * 1000);
SimpleDateFormat format = new SimpleDateFormat("E, MMM d");
return format.format(date).toString();
}