Skip to content

Instantly share code, notes, and snippets.

View devmike01's full-sized avatar
💭
Thinking about C++

Gbenga devmike01

💭
Thinking about C++
View GitHub Profile
// File generated by FlutterFire CLI.
// ignore_for_file: lines_longer_than_80_chars
import 'package:firebase_core/firebase_core.dart' show FirebaseOptions;
import 'package:flutter/foundation.dart'
show defaultTargetPlatform, kIsWeb, TargetPlatform;
/// Default [FirebaseOptions] for use with your Firebase apps.
///
/// Example:
/// ```dart
@guptahitesh121
guptahitesh121 / two_finger_swipe.dart
Last active September 14, 2022 06:14
Flutter Sample code to detect 2 finger swipe vertically using `RawGestureDetector` and `MultiDragGestureRecognizer`.
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Swipe Demo',
/* Copyright 2019 Google LLC.
SPDX-License-Identifier: Apache-2.0 */
fun animateVisibility(view: View, visible: Boolean) {
val targetAlpha = if (visible) 1f else 0f
if (view.alpha == targetAlpha) return
view.visibility = View.VISIBLE
val spring = view.spring(SpringAnimation.ALPHA)
(view.getTag(R.id.tag_pending_end_listener) as?
DynamicAnimation.OnAnimationEndListener)?.let {
@dlew
dlew / script.sh
Created November 9, 2018 16:36
Simple AndroidX Migration Script
#!/usr/bin/env bash
# I've found that the "Migrate to AndroidX" converter in Android Studio doesn't work very
# well, so I wrote my own script to do the simple job of converting package names.
#
# You can download a CSV of package names here: https://developer.android.com/topic/libraries/support-library/downloads/androidx-class-mapping.csv
#
# It'll run faster on a clean build because then there are fewer files to scan over.
#
# Uses `gsed` because I'm on a Mac. Can easily replace with `sed` if you don't have `gsed`.
@JoseAlcerreca
JoseAlcerreca / EventObserver.kt
Created April 26, 2018 12:14
An Observer for Events, simplifying the pattern of checking if the Event's content has already been handled.
/**
* An [Observer] for [Event]s, simplifying the pattern of checking if the [Event]'s content has
* already been handled.
*
* [onEventUnhandledContent] is *only* called if the [Event]'s contents has not been handled.
*/
class EventObserver<T>(private val onEventUnhandledContent: (T) -> Unit) : Observer<Event<T>> {
override fun onChanged(event: Event<T>?) {
event?.getContentIfNotHandled()?.let { value ->
onEventUnhandledContent(value)
@Kovrinic
Kovrinic / .gitconfig
Last active April 11, 2024 11:50
git global url insteadOf setup
# one or the other, NOT both
[url "https://github"]
insteadOf = git://github
# or
[url "git@github.com:"]
insteadOf = git://github
@mbunyard
mbunyard / MockResponseInterceptor.java
Created November 18, 2016 21:11
OkHttp3 interceptor which provides a mock response from local resource file.
package com.rogerthat.network.util;
import android.content.Context;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URLConnection;
import okhttp3.Interceptor;
@amilcar-sr
amilcar-sr / CallValidation.java
Last active June 10, 2021 19:34
Solution to avoid ActivityNotFoundException when attempting to start an activity with ACTION_DIAL. This problem is common in tablets with no call capabilities.
/**
* Method that checks whether the device has apps installed that can handle the Intents or not.
* @param intent Intent that will be checked.
* @return true if there are apps that can handle the Intent, false otherwise.
*/
private boolean checkAppsForIntent(Intent intent) {
PackageManager packageManager = getActivity().getPackageManager();
return intent.resolveActivity(packageManager) != null;
}
@riggaroo
riggaroo / RestServiceMockUtils.java
Last active May 1, 2021 17:52
Mocking API Responses using a Retrofit Client in Android
public class RestServiceMockUtils {
public static String convertStreamToString(InputStream is) throws Exception {
BufferedReader reader = new BufferedReader(new InputStreamReader(is));
StringBuilder sb = new StringBuilder();
String line = null;
while ((line = reader.readLine()) != null) {
sb.append(line).append("\n");
}
reader.close();
@winterbe
winterbe / Sample1View.java
Created January 15, 2011 12:04
Android custom painting and animations
package de.winterberg.android.sandbox.sample1;
import android.content.Context;
import android.graphics.*;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.LinearInterpolator;
import android.view.animation.RotateAnimation;
/**