Skip to content

Instantly share code, notes, and snippets.

View wei-spring's full-sized avatar
🏠
Working from home

魏春生 wei-spring

🏠
Working from home
View GitHub Profile
@aslamanver
aslamanver / main_screen.dart
Created October 3, 2019 11:09
Flutter custom inheritance - Extending the base class
import 'package:flutter/material.dart';
class MainScreen extends StatefulWidget {
@override
_MainScreenState createState() => _MainScreenState();
}
class _MainScreenState extends _BaseStatefulState<MainScreen> {
@override
Widget build(BuildContext context) {
@PasanBhanu
PasanBhanu / AndroidDownloadImage.java
Created September 26, 2019 09:04
Download Image from URL and Added to Gallery - Android (Java)
/*
This method can be used to download an image from the internet using a url in Android. This use Android Download Manager to
download the file and added it to the Gallery. Downloaded image will be saved to "Pictures"
Folder in your internal storage
*/
private void downloadImageNew(String filename, String downloadUrlOfImage){
try{
DownloadManager dm = (DownloadManager) getSystemService(Context.DOWNLOAD_SERVICE);
Uri downloadUri = Uri.parse(downloadUrlOfImage);
@putraxor
putraxor / autoscroll_text.dart
Created January 28, 2019 06:09
Flutter Marquee Text Widget
import 'package:flutter/animation.dart';
import 'package:flutter/material.dart';
class AutoScrollText extends StatefulWidget {
final double height;
final List<Widget> items;
AutoScrollText({this.height = 24.0, this.items});
@override
State<StatefulWidget> createState() => new _AutoScrollTextState();
@niusounds
niusounds / AudioInputStream.kt
Last active March 31, 2024 17:22
AudioInputStream and AudioOutputStream for Android. These wrap AudioRecord and AudioTrack.
import android.media.AudioFormat
import android.media.AudioRecord
import android.media.MediaRecorder
import java.io.IOException
import java.io.InputStream
class AudioInputStream(
audioSource: Int = MediaRecorder.AudioSource.DEFAULT,
sampleRate: Int = 44100,
channelConfig: Int = AudioFormat.CHANNEL_IN_MONO,
@jhonsore
jhonsore / README.md
Last active November 9, 2022 03:07
[DEPRECATED] Upload an Image from camera or gallery in WebView.

This is an old way to Upload an Image from camera or gallery in WebView. It was made a long time ago and is not maintened anymore. Use it at your own risk.

@AlexisLeon
AlexisLeon / rn.input-numbers.js
Created January 15, 2017 04:28
TextInput accepts only numbers - React Native
import React, { Component } from 'react';
import { TextInput } from 'react-native';
class Input extends Component {
constructor(props) {
super(props);
this.state = {
text: ''
};
}
@joinAero
joinAero / FlymeUtils.java
Created February 17, 2016 13:04
Android - Helper for 3rd party roms: Flyme & MIUI.
package cc.cubone.turbo.core.rom;
import android.os.Build;
import android.view.Window;
import android.view.WindowManager;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
/**
@rharter
rharter / RevealDrawable.java
Created April 3, 2015 17:41
A Drawable that transitions between two child Drawables based on this Drawable's current level value. The idea here is that the center value (5000) will show the 'selected' Drawable, and any other value will show a transitional value between the 'selected' Drawable and the 'unselected' Drawable.
package com.pixite.fragment.widget;
import android.content.res.Resources;
import android.graphics.Canvas;
import android.graphics.ColorFilter;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.Drawable.Callback;
import android.view.Gravity;
@daniellevass
daniellevass / starting_library_project_AS.md
Last active August 30, 2020 00:48
Getting Started with a library project in Android Studio

Getting Started with a library project in Android Studio

So we're working on creating Android Material Awesome, a library which will hopefully incorperate the benefits of Material Design, Twitter's Bootstrap, and FontAwesome. What we really wanted is a project other people can easily include into their projects using gradle dependencies. To do this we needed to create a standalone library project so we could make it as lightweight as possible for including as a dependency, and a sample app that would use it for testing. These are the steps we took to get started in Android Studio (version 1.1).

Create Projects

The first thing we needed to do was to create two new projects, with all the default settings (Blank Activity etc). One for our sample app, and one for our library. We added both of ours into the same GitHub repo, however you can save them wherever you like.

Fix Up Library Project

@benny-shotvibe
benny-shotvibe / gist:1e0d745b7bc68a9c3256
Last active November 3, 2023 20:36
Android Save To Gallery
// This is an outdated way to do this...
// Inspired by:
// http://stackoverflow.com/questions/8560501/android-save-image-into-gallery/8722494#8722494
// https://gist.github.com/samkirton/0242ba81d7ca00b475b9
public static void saveImageToGallery(ContentResolver cr, String imagePath) {
String title = "Saved From Glance";
String description = title;