Skip to content

Instantly share code, notes, and snippets.

View sabiou's full-sized avatar
📿
La hawla wa la quwwata illa Billah

Farouk Sabiou sabiou

📿
La hawla wa la quwwata illa Billah
View GitHub Profile
@sabiou
sabiou / build.gradle.kts
Created October 26, 2023 21:45 — forked from mileskrell/build.gradle.kts
Example of declaring Android signing configs using Gradle Kotlin DSL
android {
signingConfigs {
getByName("debug") {
keyAlias = "debug"
keyPassword = "my debug key password"
storeFile = file("/home/miles/keystore.jks")
storePassword = "my keystore password"
}
create("release") {
keyAlias = "release"
inline fun getValueAnimator(forward: Boolean = true, duration: Long, interpolator: TimeInterpolator,
crossinline updateListener: (progress: Float) -> Unit
): ValueAnimator {
val a =
if (forward) ValueAnimator.ofFloat(0f, 1f)
else ValueAnimator.ofFloat(1f, 0f)
a.addUpdateListener { updateListener(it.animatedValue as Float) }
a.duration = duration
a.interpolator = interpolator
return a
class ToolbarBehavior : CoordinatorLayout.Behavior<AppBarLayout>() {
/** Consume if vertical scroll because we don't care about other scrolls */
override fun onStartNestedScroll(coordinatorLayout: CoordinatorLayout, child: AppBarLayout,
directTargetChild: View, target: View, axes: Int, type: Int): Boolean {
getViews(child)
return axes == ViewCompat.SCROLL_AXIS_VERTICAL ||
super.onStartNestedScroll(coordinatorLayout, child, directTargetChild, target, axes, type)
}
tabsRecyclerView.addOnScrollListener(object : RecyclerView.OnScrollListener() {
override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
totalTabsScroll += dx
}
})
viewPager.registerOnPageChangeCallback(object : ViewPager2.OnPageChangeCallback() {
override fun onPageScrolled(position: Int, positionOffset: Float, positionOffsetPixels: Int) {
// Scroll tabs as viewpager is scrolled
val dx = (position + positionOffset) * tabItemWidth - totalTabsScroll
@sabiou
sabiou / ShowbizView.kt
Created May 4, 2019 03:20 — forked from nickbutcher/ShowbizView.kt
A prototype of an animation I helped out on, see: https://twitter.com/crafty/status/1073612862139064332
/*
* Copyright 2018 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
public class MediaPlayerService extends Service implements MediaPlayer.OnCompletionListener,
MediaPlayer.OnPreparedListener, MediaPlayer.OnErrorListener, MediaPlayer.OnSeekCompleteListener,
MediaPlayer.OnInfoListener, MediaPlayer.OnBufferingUpdateListener,
AudioManager.OnAudioFocusChangeListener {
public static final String ACTION_PLAY = "com.be.homsi.ACTION_PLAY";
public static final String ACTION_PAUSE = "com.be.homsi.ACTION_PAUSE";
public static final String ACTION_PREVIOUS = "com.be.homsi.ACTION_PREVIOUS";
public static final String ACTION_NEXT = "com.be.homsi.ACTION_NEXT";
@sabiou
sabiou / Inter.java
Last active April 4, 2019 09:58 — forked from tchiks1/Inter
public class Inter extends Fragment implements MainView {
List<InterpretationModel> passages;
List<InterpretationModel> interlists;
Menu test; AudioAdapter adapters;
public RecyclerView mRecyclerView,recycleraudio;
public Recycleradapter mAdapter;
boolean serviceBound = false;
TextView textView;
package com.be.homsi.adapter;
import android.Manifest;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.ServiceConnection;
import android.content.SharedPreferences;
@sabiou
sabiou / IfElse.kt
Created March 5, 2019 02:58 — forked from ragdroid/IfElse.kt
Simplified if-else
infix fun <T>Boolean.then(action : () -> T): T? {
return if (this)
action.invoke()
else null
}
infix fun <T>T?.elze(action: () -> T): T {
return if (this == null)
action.invoke()
@sabiou
sabiou / Data.kt
Created February 1, 2019 23:38 — forked from florina-muntenescu/Data.kt
Using RoomDatabase#Callback to pre-populate the database - https://medium.com/google-developers/7-pro-tips-for-room-fbadea4bfbd1
/*
* Copyright (C) 2017 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software