Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 17 additions & 6 deletions android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,22 +1,27 @@
buildscript {
repositories {
google()
jcenter()
}

dependencies {
classpath 'com.android.tools.build:gradle:1.3.1'
classpath 'com.android.tools.build:gradle:3.5.2'
}
}

def getExtOrDefault(name, fallback) {
return rootProject.ext.has(name) ? rootProject.ext.get(name) : fallback
}

apply plugin: 'com.android.library'

android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
compileSdkVersion getExtOrDefault('compileSdkVersion', 28)
buildToolsVersion getExtOrDefault('buildToolsVersion', "28.0.3")

defaultConfig {
minSdkVersion 16
targetSdkVersion 22
targetSdkVersion getExtOrDefault('targetSdkVersion', 28)
versionCode 1
versionName "1.0"
}
Expand All @@ -25,6 +30,12 @@ android {
}
}

repositories {
google()
jcenter()
mavenCentral()
}

dependencies {
compile 'com.facebook.react:react-native:+'
}
api 'com.facebook.react:react-native:+'
}
Binary file modified android/gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
4 changes: 2 additions & 2 deletions android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Mon Dec 28 10:00:20 PST 2015
#Sat Apr 18 20:53:10 BST 2020
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.0.1-all.zip
72 changes: 42 additions & 30 deletions android/gradlew
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,25 +1,43 @@
#!/usr/bin/env bash
#!/usr/bin/env sh

##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null

APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"

warn ( ) {
warn () {
echo "$*"
}

die ( ) {
die () {
echo
echo "$*"
echo
Expand All @@ -30,6 +48,7 @@ die ( ) {
cygwin=false
msys=false
darwin=false
nonstop=false
case "`uname`" in
CYGWIN* )
cygwin=true
Expand All @@ -40,26 +59,11 @@ case "`uname`" in
MINGW* )
msys=true
;;
NONSTOP* )
nonstop=true
;;
esac

# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null

CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar

# Determine the Java command to use to start the JVM.
Expand All @@ -85,7 +89,7 @@ location of your Java installation."
fi

# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
Expand Down Expand Up @@ -150,11 +154,19 @@ if $cygwin ; then
esac
fi

# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
function splitJvmOpts() {
JVM_OPTS=("$@")
# Escape application args
save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
APP_ARGS=$(save "$@")

# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"

# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
cd "$(dirname "$0")"
fi

exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
exec "$JAVACMD" "$@"
14 changes: 4 additions & 10 deletions android/gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal

@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=

set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%

@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=

@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome

Expand Down Expand Up @@ -46,10 +46,9 @@ echo location of your Java installation.
goto fail

:init
@rem Get command-line arguments, handling Windowz variants
@rem Get command-line arguments, handling Windows variants

if not "%OS%" == "Windows_NT" goto win9xME_args
if "%@eval[2+2]" == "4" goto 4NT_args

:win9xME_args
@rem Slurp the command line arguments.
Expand All @@ -60,11 +59,6 @@ set _SKIP=2
if "x%~1" == "x" goto execute

set CMD_LINE_ARGS=%*
goto execute

:4NT_args
@rem Get arguments from the 4NT Shell from JP Software
set CMD_LINE_ARGS=%$

:execute
@rem Setup the command line
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,15 @@
import android.graphics.BitmapFactory;
import android.graphics.drawable.AnimationDrawable;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.util.Log;
import android.os.AsyncTask;
import android.widget.ImageView;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashMap;
Expand Down Expand Up @@ -43,11 +46,19 @@ public DownloadImageTask(Integer index, String uri, Context context) {

@Override
protected Bitmap doInBackground(String... params) {
if (this.uri.startsWith("http")) {
return this.loadBitmapByExternalURL(this.uri);
}
try {
if (this.uri.startsWith("http")) {
return this.loadBitmapByExternalURL(this.uri);
} else if (this.uri.startsWith("file://")) {
File file = new File(new URI(this.uri));
return BitmapFactory.decodeFile(file.getAbsolutePath());
}

return this.loadBitmapByLocalResource(this.uri);
} catch (Exception e) {

return this.loadBitmapByLocalResource(this.uri);
}
return null;
}


Expand All @@ -57,20 +68,28 @@ private Bitmap loadBitmapByLocalResource(String uri) {

private Bitmap loadBitmapByExternalURL(String uri) {
Bitmap bitmap = null;
InputStream in = null;

try {
InputStream in = new URL(uri).openStream();
in = new URL(uri).openStream();
bitmap = BitmapFactory.decodeStream(in);
} catch (IOException e) {
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (in != null) {
in.close();
}
} catch (Exception e) {
}
}

return bitmap;
}

@Override
protected void onPostExecute(Bitmap bitmap) {
if (!isCancelled()) {
if (!isCancelled() && bitmap != null) {
onTaskCompleted(this, index, bitmap);
}
}
Expand All @@ -91,6 +110,11 @@ private void onTaskCompleted(DownloadImageTask downloadImageTask, Integer index,
}

public void setImages(ArrayList<String> uris) {
Drawable drawable = getDrawable();
if(drawable instanceof AnimationDrawable){
((AnimationDrawable)drawable).stop();
}

if (isLoading()) {
// cancel ongoing tasks (if still loading previous images)
for (int index = 0; index < activeTasks.size(); index++) {
Expand All @@ -108,7 +132,7 @@ public void setImages(ArrayList<String> uris) {
try {
task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
} catch (RejectedExecutionException e){
Log.e("react-native-image-sequence", "DownloadImageTask failed" + e.getMessage());
Log.e("image-sequence", "DownloadImageTask failed" + e.getMessage());
break;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import com.facebook.common.util.UriUtil;
import androidx.core.content.ContextCompat;

import javax.annotation.Nullable;
import java.util.HashMap;
import java.util.Map;
import javax.annotation.Nullable;

import com.facebook.common.util.UriUtil;


public class RCTResourceDrawableIdHelper {
Expand Down Expand Up @@ -36,7 +38,7 @@ public int getResourceDrawableId(Context context, @Nullable String name) {

public @Nullable Drawable getResourceDrawable(Context context, @Nullable String name) {
int resId = getResourceDrawableId(context, name);
return resId > 0 ? context.getResources().getDrawable(resId) : null;
return resId > 0 ? ContextCompat.getDrawable(context, resId) : null;
}

public Uri getResourceDrawableUri(Context context, @Nullable String name) {
Expand Down
1 change: 1 addition & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ ImageSequence.defaultProps = {
};

ImageSequence.propTypes = {
...ViewPropTypes,
startFrameIndex: number,
images: array.isRequired,
framesPerSecond: number,
Expand Down
3 changes: 2 additions & 1 deletion typings/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Component } from 'react';
import { ViewProps } from 'react-native';

interface ImageSequenceProps {
interface ImageSequenceProps extends ViewProps {
/** An array of source images. Each element of the array should be the result of a call to require(imagePath). */
images: any[];
/** Which index of the images array should the sequence start at. Default: 0 */
Expand Down