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
@granoeste
granoeste / EachDirectoryPath.md
Last active November 4, 2024 06:16
[Android] How to get the each directory path.

System directories

Method Result
Environment.getDataDirectory() /data
Environment.getDownloadCacheDirectory() /cache
Environment.getRootDirectory() /system

External storage directories

@comoc
comoc / ClearCanvas.java
Created October 9, 2013 02:30
Clear the Canvas of a SurfaceView for Android.
// Obtain a SurfaceView.
// SurfaceView surfaceView = (SurfaceView)findViewById(R.id.surfaceView1);
Canvas canvas = surfaceView.getHolder().lockCanvas();
canvas.drawColor(Color.TRANSPARENT, PorterDuff.Mode.CLEAR);
// Draw someting
surfaceView.getHolder().unlockCanvasAndPost(canvas);
@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;
@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

@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;
@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;
/**
@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: ''
};
}
@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.

@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,
@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();