Skip to content

Instantly share code, notes, and snippets.

View ugommirikwe's full-sized avatar

Ugo ugommirikwe

View GitHub Profile
@ugommirikwe
ugommirikwe / ios_spinner_avd.xml
Created April 28, 2023 12:11 — forked from DarkionAvey/ios_spinner_avd.xml
iOS-like spinner as an animated vector drawable for Android without the need of custom classes, or worse, gifs. Use support library to get it to work on older devices. To change color, simply change fillColor but not the alpha. You have to register a callback to make it repeat, because android doesn't allow animationset to repeat
<animated-vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt">
<aapt:attr name="android:drawable">
<vector
android:name="vector"
android:width="20dp"
android:height="20dp"
android:viewportWidth="60"
android:viewportHeight="60">
<path
#Ruby version
ruby_version("3.0.2")
# Uncomment the line if you want fastlane to automatically update itself
# update_fastlane
fastlane_require 'dotenv'
default_platform(:ios)
fastlane_require 'dotenv'
default_platform(:android)
platform :android do
# Have an easy way to get the root of the project
def root_path
Dir.pwd.sub(/.*\Kfastlane/, '').sub(/.*\Kandroid/, '').sub(/.*\Kios/, '').sub(/.*\K\/\//, '')
end
@ugommirikwe
ugommirikwe / MainActivity.kt
Last active May 1, 2021 09:58
Here's how you would implement a permission request/validation in a Jetpack Compose app. Note the code was to intended for embedding a MapBox map, but there are some other code related to using the MapBox map that are not shown here. This code snippet is just for requesting permissions in a Compose UI app. This solution was inspired by: https://…
package io.ugommirikwe.app
import android.Manifest
import android.content.Intent
import android.content.pm.PackageManager
import android.os.Bundle
import android.provider.Settings
import androidx.activity.compose.LocalActivityResultRegistryOwner
import androidx.activity.compose.setContent
import androidx.appcompat.app.AppCompatActivity
@ugommirikwe
ugommirikwe / CoroutineTestRule.kt
Created April 24, 2020 13:12 — forked from AniketSK/CoroutineTestRule.kt
A test rule to allow testing coroutines that use the main dispatcher. Without this you'd run into "java.lang.IllegalStateException: Module with the Main dispatcher had failed to initialize. For tests Dispatchers.setMain from kotlinx-coroutines-test module can be used"
package com.aniketkadam.sharevideoshortcut
import org.junit.rules.TestWatcher
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.test.TestCoroutineDispatcher
import kotlinx.coroutines.test.resetMain
import kotlinx.coroutines.test.setMain
import org.junit.runner.Description
@ugommirikwe
ugommirikwe / ios_android.dart
Created August 8, 2019 14:01 — forked from slightfoot/ios_android.dart
Example of using defaultTargetPlatform to change the entire widget tree based on platform.
import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
void main() {
//runApp(IOSApp());
//runApp(AndroidApp());
runApp(defaultTargetPlatform == TargetPlatform.iOS ? IOSApp() : AndroidApp());
}
@ugommirikwe
ugommirikwe / querystring.swift
Created February 27, 2019 08:34 — forked from gillesdemey/querystring.swift
Retrieve specific query string parameter from NSURL
func getQueryStringParameter(url: String, param: String) -> String? {
let url = NSURLComponents(string: url)!
return
(url.queryItems? as [NSURLQueryItem])
.filter({ (item) in item.name == param }).first?
.value()
}
@ugommirikwe
ugommirikwe / isValidCssSelector.js
Created February 7, 2019 21:19
Utility Javascript function to check if a provided value is a valid CSS selector string.
function isValidCssSelector(selector) {
var re = /^[A-Za-z]+[\w\-\:\.]*$/
return re.test(id)
}
@ugommirikwe
ugommirikwe / isEmpty.js
Created February 7, 2019 21:15
Utility function to coerce a value of any native JavaScript data type to a boolean representation.
function isEmpty(data) {
if (typeof data === 'number' || typeof data === 'boolean') {
return false
}
if (typeof data === 'undefined' || data === null) {
return true
}
if (typeof data.length !== 'undefined') {
@ugommirikwe
ugommirikwe / ApiService.java
Created September 29, 2015 08:33 — forked from dustin-graham/ApiService.java
Infinite Scrolling Android RecyclerView with RxJava
public static Observable<List<String>> paginatedThings(final Observable<Void> onNextObservable) {
return Observable.create(new Observable.OnSubscribe<List<String>>() {
@Override
public void call(final Subscriber<? super List<String>> subscriber) {
onNextObservable.subscribe(new Observer<Void>() {
int latestPage = -1;
@Override
public void onCompleted() {
subscriber.onCompleted();