Skip to content

Instantly share code, notes, and snippets.

View .eslintrc20200501.js
module.exports = {
"parser": "babel-eslint",
"extends": [
"eslint:recommended",
"plugin:react/recommended",
"prettier",
"prettier/react"
],
"plugins": [
"react",
@zi6xuan
zi6xuan / findMatchingSimulator.js
Created Oct 14, 2019
findMatchingSimulator.js
View findMatchingSimulator.js
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
@zi6xuan
zi6xuan / Activity.java
Created Sep 11, 2019
Fix the VideoView memory leak
View Activity.java
@Override
protected void attachBaseContext(Context newBase) {
super.attachBaseContext(new ContextWrapper(newBase){
@Override
public Object getSystemService(String name) {
if(Context.AUDIO_SERVICE.equals(name)){
return getApplicationContext().getSystemService(name);
}
return super.getSystemService(name);
}
@zi6xuan
zi6xuan / rn-location.js
Created Sep 6, 2019
The RN obtains the location function, automatically checks and requests permissions
View rn-location.js
export async function getCurrentPosition(onSuccess, onError, error3) {
if (isAndroid) {
const granted = await PermissionsAndroid.check(PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION);
if (!granted) {
PermissionsAndroid.request(PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION)
.then((status) => {
if (status == PermissionStatus.granted) {
//
getCurrentPosition(onSuccess, onError, false);
}
View JImage.js
import React, { Component } from 'react';
import { Image, InteractionManager } from 'react-native';
export default class JImage extends Component<Props> {
constructor(props) {
super(props)
this.state = {
width: 1,
height: 1
@zi6xuan
zi6xuan / StorageUtils.java
Created Oct 12, 2018
获得所有sd卡挂载目录
View StorageUtils.java
public class StorageUtils {
public static ArrayList<Volume> getVolume(Context context) {
ArrayList<Volume> list_storagevolume = new ArrayList<Volume>();
StorageManager storageManager = (StorageManager) context.getSystemService(Context.STORAGE_SERVICE);
try {
Method method_volumeList = StorageManager.class.getMethod("getVolumeList");
@zi6xuan
zi6xuan / MsgBox.js
Created Sep 21, 2018
一个悬浮在手机顶端的信息提示框
View MsgBox.js
import { Theme, Overlay } from 'teaset';
export function BBox(msg: strings) {
let overlayView = (
<Overlay.PullView
containerStyle={{ alignItems: 'stretch', justifyContent: 'flex-start', backgroundColor: '#00000000', }}
side='top'
overlayOpacity={0}>
<View style={{ justifyContent: 'center', backgroundColor: '#000000D1', height: 120, paddingTop: Theme.statusBarHeight }}>
@zi6xuan
zi6xuan / richText.js
Created May 24, 2018
react-native text support url link
View richText.js
richText(str: string) {
//
let strAry = new Array();
let startI = 0;
let urls = str.match(/<https?\:\/\/.+?>/g);
let textAry = str.split(/<https?\:\/\/.+?>/);
let viewAry = new Array();
for (let i = 0; i < textAry.length; i++) {
let urlCom = null;
if (urls != null && i < urls.length) {
@zi6xuan
zi6xuan / Utils.java
Created Mar 29, 2018
部分手机或系统播放系统提示音,会循环播放,设置一个超时自动停止
View Utils.java
public static void playSystemSound(int type) {
AudioManager am = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE);
if (am == null) return;
final int ringerMode = am.getRingerMode();
switch (ringerMode) {
case AudioManager.RINGER_MODE_SILENT: //
{
//do nothing
}
break;
@zi6xuan
zi6xuan / .eslintrc.js
Created Mar 1, 2018
vscode eslint 配置文件参考
View .eslintrc.js
module.exports = {
"parser": "babel-eslint",
"extends": [
"eslint:recommended",
"plugin:react/recommended"
],
"plugins": [
"react",
"react-native"
],