id
int32
0
165k
repo
stringlengths
7
58
path
stringlengths
12
218
func_name
stringlengths
3
140
original_string
stringlengths
73
34.1k
language
stringclasses
1 value
code
stringlengths
73
34.1k
code_tokens
list
docstring
stringlengths
3
16k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
105
339
14,400
kiegroup/drools
drools-core/src/main/java/org/drools/core/rule/Collect.java
Collect.determineResultClassName
private String determineResultClassName(ClassObjectType objType) { String className = objType.getClassName(); if ( List.class.getName().equals( className ) ) { className = ArrayList.class.getName(); } else if ( Set.class.getName().equals( className ) ) { className = HashSet.class.getName(); } else if ( Collection.class.getName().equals( className ) ) { className = ArrayList.class.getName(); } return className; }
java
private String determineResultClassName(ClassObjectType objType) { String className = objType.getClassName(); if ( List.class.getName().equals( className ) ) { className = ArrayList.class.getName(); } else if ( Set.class.getName().equals( className ) ) { className = HashSet.class.getName(); } else if ( Collection.class.getName().equals( className ) ) { className = ArrayList.class.getName(); } return className; }
[ "private", "String", "determineResultClassName", "(", "ClassObjectType", "objType", ")", "{", "String", "className", "=", "objType", ".", "getClassName", "(", ")", ";", "if", "(", "List", ".", "class", ".", "getName", "(", ")", ".", "equals", "(", "className", ")", ")", "{", "className", "=", "ArrayList", ".", "class", ".", "getName", "(", ")", ";", "}", "else", "if", "(", "Set", ".", "class", ".", "getName", "(", ")", ".", "equals", "(", "className", ")", ")", "{", "className", "=", "HashSet", ".", "class", ".", "getName", "(", ")", ";", "}", "else", "if", "(", "Collection", ".", "class", ".", "getName", "(", ")", ".", "equals", "(", "className", ")", ")", "{", "className", "=", "ArrayList", ".", "class", ".", "getName", "(", ")", ";", "}", "return", "className", ";", "}" ]
If the user uses an interface as a result type, use a default concrete class. List -> ArrayList Collection -> ArrayList Set -> HashSet
[ "If", "the", "user", "uses", "an", "interface", "as", "a", "result", "type", "use", "a", "default", "concrete", "class", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-core/src/main/java/org/drools/core/rule/Collect.java#L126-L136
14,401
kiegroup/drools
drools-core/src/main/java/org/drools/core/base/ClassFieldAccessorFactory.java
ClassFieldAccessorFactory.buildClassHeader
protected static ClassWriter buildClassHeader(Class< ? > superClass, String className) { ClassWriter cw = createClassWriter( superClass.getClassLoader(), Opcodes.ACC_PUBLIC + Opcodes.ACC_SUPER, className, null, Type.getInternalName( superClass ), null ); cw.visitSource( null, null ); return cw; }
java
protected static ClassWriter buildClassHeader(Class< ? > superClass, String className) { ClassWriter cw = createClassWriter( superClass.getClassLoader(), Opcodes.ACC_PUBLIC + Opcodes.ACC_SUPER, className, null, Type.getInternalName( superClass ), null ); cw.visitSource( null, null ); return cw; }
[ "protected", "static", "ClassWriter", "buildClassHeader", "(", "Class", "<", "?", ">", "superClass", ",", "String", "className", ")", "{", "ClassWriter", "cw", "=", "createClassWriter", "(", "superClass", ".", "getClassLoader", "(", ")", ",", "Opcodes", ".", "ACC_PUBLIC", "+", "Opcodes", ".", "ACC_SUPER", ",", "className", ",", "null", ",", "Type", ".", "getInternalName", "(", "superClass", ")", ",", "null", ")", ";", "cw", ".", "visitSource", "(", "null", ",", "null", ")", ";", "return", "cw", ";", "}" ]
Builds the class header
[ "Builds", "the", "class", "header" ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-core/src/main/java/org/drools/core/base/ClassFieldAccessorFactory.java#L277-L290
14,402
kiegroup/drools
drools-core/src/main/java/org/drools/core/base/ClassFieldAccessorFactory.java
ClassFieldAccessorFactory.build3ArgConstructor
private static void build3ArgConstructor(final Class< ? > superClazz, final String className, final ClassWriter cw) { MethodVisitor mv; { mv = cw.visitMethod( Opcodes.ACC_PUBLIC, "<init>", Type.getMethodDescriptor( Type.VOID_TYPE, Type.getType( int.class ), Type.getType( Class.class ), Type.getType( ValueType.class ) ), null, null ); mv.visitCode(); final Label l0 = new Label(); mv.visitLabel( l0 ); mv.visitVarInsn( Opcodes.ALOAD, 0 ); mv.visitVarInsn( Opcodes.ILOAD, 1 ); mv.visitVarInsn( Opcodes.ALOAD, 2 ); mv.visitVarInsn( Opcodes.ALOAD, 3 ); mv.visitMethodInsn( Opcodes.INVOKESPECIAL, Type.getInternalName( superClazz ), "<init>", Type.getMethodDescriptor( Type.VOID_TYPE, Type.getType( int.class ), Type.getType( Class.class ), Type.getType( ValueType.class ) ) ); final Label l1 = new Label(); mv.visitLabel( l1 ); mv.visitInsn( Opcodes.RETURN ); final Label l2 = new Label(); mv.visitLabel( l2 ); mv.visitLocalVariable( "this", "L" + className + ";", null, l0, l2, 0 ); mv.visitLocalVariable( "index", Type.getDescriptor( int.class ), null, l0, l2, 1 ); mv.visitLocalVariable( "fieldType", Type.getDescriptor( Class.class ), null, l0, l2, 2 ); mv.visitLocalVariable( "valueType", Type.getDescriptor( ValueType.class ), null, l0, l2, 3 ); mv.visitMaxs( 0, 0 ); mv.visitEnd(); } }
java
private static void build3ArgConstructor(final Class< ? > superClazz, final String className, final ClassWriter cw) { MethodVisitor mv; { mv = cw.visitMethod( Opcodes.ACC_PUBLIC, "<init>", Type.getMethodDescriptor( Type.VOID_TYPE, Type.getType( int.class ), Type.getType( Class.class ), Type.getType( ValueType.class ) ), null, null ); mv.visitCode(); final Label l0 = new Label(); mv.visitLabel( l0 ); mv.visitVarInsn( Opcodes.ALOAD, 0 ); mv.visitVarInsn( Opcodes.ILOAD, 1 ); mv.visitVarInsn( Opcodes.ALOAD, 2 ); mv.visitVarInsn( Opcodes.ALOAD, 3 ); mv.visitMethodInsn( Opcodes.INVOKESPECIAL, Type.getInternalName( superClazz ), "<init>", Type.getMethodDescriptor( Type.VOID_TYPE, Type.getType( int.class ), Type.getType( Class.class ), Type.getType( ValueType.class ) ) ); final Label l1 = new Label(); mv.visitLabel( l1 ); mv.visitInsn( Opcodes.RETURN ); final Label l2 = new Label(); mv.visitLabel( l2 ); mv.visitLocalVariable( "this", "L" + className + ";", null, l0, l2, 0 ); mv.visitLocalVariable( "index", Type.getDescriptor( int.class ), null, l0, l2, 1 ); mv.visitLocalVariable( "fieldType", Type.getDescriptor( Class.class ), null, l0, l2, 2 ); mv.visitLocalVariable( "valueType", Type.getDescriptor( ValueType.class ), null, l0, l2, 3 ); mv.visitMaxs( 0, 0 ); mv.visitEnd(); } }
[ "private", "static", "void", "build3ArgConstructor", "(", "final", "Class", "<", "?", ">", "superClazz", ",", "final", "String", "className", ",", "final", "ClassWriter", "cw", ")", "{", "MethodVisitor", "mv", ";", "{", "mv", "=", "cw", ".", "visitMethod", "(", "Opcodes", ".", "ACC_PUBLIC", ",", "\"<init>\"", ",", "Type", ".", "getMethodDescriptor", "(", "Type", ".", "VOID_TYPE", ",", "Type", ".", "getType", "(", "int", ".", "class", ")", ",", "Type", ".", "getType", "(", "Class", ".", "class", ")", ",", "Type", ".", "getType", "(", "ValueType", ".", "class", ")", ")", ",", "null", ",", "null", ")", ";", "mv", ".", "visitCode", "(", ")", ";", "final", "Label", "l0", "=", "new", "Label", "(", ")", ";", "mv", ".", "visitLabel", "(", "l0", ")", ";", "mv", ".", "visitVarInsn", "(", "Opcodes", ".", "ALOAD", ",", "0", ")", ";", "mv", ".", "visitVarInsn", "(", "Opcodes", ".", "ILOAD", ",", "1", ")", ";", "mv", ".", "visitVarInsn", "(", "Opcodes", ".", "ALOAD", ",", "2", ")", ";", "mv", ".", "visitVarInsn", "(", "Opcodes", ".", "ALOAD", ",", "3", ")", ";", "mv", ".", "visitMethodInsn", "(", "Opcodes", ".", "INVOKESPECIAL", ",", "Type", ".", "getInternalName", "(", "superClazz", ")", ",", "\"<init>\"", ",", "Type", ".", "getMethodDescriptor", "(", "Type", ".", "VOID_TYPE", ",", "Type", ".", "getType", "(", "int", ".", "class", ")", ",", "Type", ".", "getType", "(", "Class", ".", "class", ")", ",", "Type", ".", "getType", "(", "ValueType", ".", "class", ")", ")", ")", ";", "final", "Label", "l1", "=", "new", "Label", "(", ")", ";", "mv", ".", "visitLabel", "(", "l1", ")", ";", "mv", ".", "visitInsn", "(", "Opcodes", ".", "RETURN", ")", ";", "final", "Label", "l2", "=", "new", "Label", "(", ")", ";", "mv", ".", "visitLabel", "(", "l2", ")", ";", "mv", ".", "visitLocalVariable", "(", "\"this\"", ",", "\"L\"", "+", "className", "+", "\";\"", ",", "null", ",", "l0", ",", "l2", ",", "0", ")", ";", "mv", ".", "visitLocalVariable", "(", "\"index\"", ",", "Type", ".", "getDescriptor", "(", "int", ".", "class", ")", ",", "null", ",", "l0", ",", "l2", ",", "1", ")", ";", "mv", ".", "visitLocalVariable", "(", "\"fieldType\"", ",", "Type", ".", "getDescriptor", "(", "Class", ".", "class", ")", ",", "null", ",", "l0", ",", "l2", ",", "2", ")", ";", "mv", ".", "visitLocalVariable", "(", "\"valueType\"", ",", "Type", ".", "getDescriptor", "(", "ValueType", ".", "class", ")", ",", "null", ",", "l0", ",", "l2", ",", "3", ")", ";", "mv", ".", "visitMaxs", "(", "0", ",", "0", ")", ";", "mv", ".", "visitEnd", "(", ")", ";", "}", "}" ]
Creates a constructor for the field extractor receiving the index, field type and value type
[ "Creates", "a", "constructor", "for", "the", "field", "extractor", "receiving", "the", "index", "field", "type", "and", "value", "type" ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-core/src/main/java/org/drools/core/base/ClassFieldAccessorFactory.java#L296-L356
14,403
kiegroup/drools
drools-core/src/main/java/org/drools/core/base/ClassFieldAccessorFactory.java
ClassFieldAccessorFactory.buildGetMethod
protected static void buildGetMethod(final Class< ? > originalClass, final String className, final Class< ? > superClass, final Method getterMethod, final ClassWriter cw) { final Class< ? > fieldType = getterMethod.getReturnType(); Method overridingMethod; try { overridingMethod = superClass.getMethod( getOverridingGetMethodName( fieldType ), InternalWorkingMemory.class, Object.class ); } catch ( final Exception e ) { throw new RuntimeException( "This is a bug. Please report back to JBoss Rules team.", e ); } final MethodVisitor mv = cw.visitMethod( Opcodes.ACC_PUBLIC, overridingMethod.getName(), Type.getMethodDescriptor( overridingMethod ), null, null ); mv.visitCode(); final Label l0 = new Label(); mv.visitLabel( l0 ); mv.visitVarInsn( Opcodes.ALOAD, 2 ); mv.visitTypeInsn( Opcodes.CHECKCAST, Type.getInternalName( originalClass ) ); if ( originalClass.isInterface() ) { mv.visitMethodInsn( Opcodes.INVOKEINTERFACE, Type.getInternalName( originalClass ), getterMethod.getName(), Type.getMethodDescriptor( getterMethod ) ); } else { mv.visitMethodInsn( Opcodes.INVOKEVIRTUAL, Type.getInternalName( originalClass ), getterMethod.getName(), Type.getMethodDescriptor( getterMethod ) ); } mv.visitInsn( Type.getType( fieldType ).getOpcode( Opcodes.IRETURN ) ); final Label l1 = new Label(); mv.visitLabel( l1 ); mv.visitLocalVariable( "this", "L" + className + ";", null, l0, l1, 0 ); mv.visitLocalVariable( "workingMemory", Type.getDescriptor( InternalWorkingMemory.class ), null, l0, l1, 1 ); mv.visitLocalVariable( "object", Type.getDescriptor( Object.class ), null, l0, l1, 2 ); mv.visitMaxs( 0, 0 ); mv.visitEnd(); }
java
protected static void buildGetMethod(final Class< ? > originalClass, final String className, final Class< ? > superClass, final Method getterMethod, final ClassWriter cw) { final Class< ? > fieldType = getterMethod.getReturnType(); Method overridingMethod; try { overridingMethod = superClass.getMethod( getOverridingGetMethodName( fieldType ), InternalWorkingMemory.class, Object.class ); } catch ( final Exception e ) { throw new RuntimeException( "This is a bug. Please report back to JBoss Rules team.", e ); } final MethodVisitor mv = cw.visitMethod( Opcodes.ACC_PUBLIC, overridingMethod.getName(), Type.getMethodDescriptor( overridingMethod ), null, null ); mv.visitCode(); final Label l0 = new Label(); mv.visitLabel( l0 ); mv.visitVarInsn( Opcodes.ALOAD, 2 ); mv.visitTypeInsn( Opcodes.CHECKCAST, Type.getInternalName( originalClass ) ); if ( originalClass.isInterface() ) { mv.visitMethodInsn( Opcodes.INVOKEINTERFACE, Type.getInternalName( originalClass ), getterMethod.getName(), Type.getMethodDescriptor( getterMethod ) ); } else { mv.visitMethodInsn( Opcodes.INVOKEVIRTUAL, Type.getInternalName( originalClass ), getterMethod.getName(), Type.getMethodDescriptor( getterMethod ) ); } mv.visitInsn( Type.getType( fieldType ).getOpcode( Opcodes.IRETURN ) ); final Label l1 = new Label(); mv.visitLabel( l1 ); mv.visitLocalVariable( "this", "L" + className + ";", null, l0, l1, 0 ); mv.visitLocalVariable( "workingMemory", Type.getDescriptor( InternalWorkingMemory.class ), null, l0, l1, 1 ); mv.visitLocalVariable( "object", Type.getDescriptor( Object.class ), null, l0, l1, 2 ); mv.visitMaxs( 0, 0 ); mv.visitEnd(); }
[ "protected", "static", "void", "buildGetMethod", "(", "final", "Class", "<", "?", ">", "originalClass", ",", "final", "String", "className", ",", "final", "Class", "<", "?", ">", "superClass", ",", "final", "Method", "getterMethod", ",", "final", "ClassWriter", "cw", ")", "{", "final", "Class", "<", "?", ">", "fieldType", "=", "getterMethod", ".", "getReturnType", "(", ")", ";", "Method", "overridingMethod", ";", "try", "{", "overridingMethod", "=", "superClass", ".", "getMethod", "(", "getOverridingGetMethodName", "(", "fieldType", ")", ",", "InternalWorkingMemory", ".", "class", ",", "Object", ".", "class", ")", ";", "}", "catch", "(", "final", "Exception", "e", ")", "{", "throw", "new", "RuntimeException", "(", "\"This is a bug. Please report back to JBoss Rules team.\"", ",", "e", ")", ";", "}", "final", "MethodVisitor", "mv", "=", "cw", ".", "visitMethod", "(", "Opcodes", ".", "ACC_PUBLIC", ",", "overridingMethod", ".", "getName", "(", ")", ",", "Type", ".", "getMethodDescriptor", "(", "overridingMethod", ")", ",", "null", ",", "null", ")", ";", "mv", ".", "visitCode", "(", ")", ";", "final", "Label", "l0", "=", "new", "Label", "(", ")", ";", "mv", ".", "visitLabel", "(", "l0", ")", ";", "mv", ".", "visitVarInsn", "(", "Opcodes", ".", "ALOAD", ",", "2", ")", ";", "mv", ".", "visitTypeInsn", "(", "Opcodes", ".", "CHECKCAST", ",", "Type", ".", "getInternalName", "(", "originalClass", ")", ")", ";", "if", "(", "originalClass", ".", "isInterface", "(", ")", ")", "{", "mv", ".", "visitMethodInsn", "(", "Opcodes", ".", "INVOKEINTERFACE", ",", "Type", ".", "getInternalName", "(", "originalClass", ")", ",", "getterMethod", ".", "getName", "(", ")", ",", "Type", ".", "getMethodDescriptor", "(", "getterMethod", ")", ")", ";", "}", "else", "{", "mv", ".", "visitMethodInsn", "(", "Opcodes", ".", "INVOKEVIRTUAL", ",", "Type", ".", "getInternalName", "(", "originalClass", ")", ",", "getterMethod", ".", "getName", "(", ")", ",", "Type", ".", "getMethodDescriptor", "(", "getterMethod", ")", ")", ";", "}", "mv", ".", "visitInsn", "(", "Type", ".", "getType", "(", "fieldType", ")", ".", "getOpcode", "(", "Opcodes", ".", "IRETURN", ")", ")", ";", "final", "Label", "l1", "=", "new", "Label", "(", ")", ";", "mv", ".", "visitLabel", "(", "l1", ")", ";", "mv", ".", "visitLocalVariable", "(", "\"this\"", ",", "\"L\"", "+", "className", "+", "\";\"", ",", "null", ",", "l0", ",", "l1", ",", "0", ")", ";", "mv", ".", "visitLocalVariable", "(", "\"workingMemory\"", ",", "Type", ".", "getDescriptor", "(", "InternalWorkingMemory", ".", "class", ")", ",", "null", ",", "l0", ",", "l1", ",", "1", ")", ";", "mv", ".", "visitLocalVariable", "(", "\"object\"", ",", "Type", ".", "getDescriptor", "(", "Object", ".", "class", ")", ",", "null", ",", "l0", ",", "l1", ",", "2", ")", ";", "mv", ".", "visitMaxs", "(", "0", ",", "0", ")", ";", "mv", ".", "visitEnd", "(", ")", ";", "}" ]
Creates the proxy reader method for the given method
[ "Creates", "the", "proxy", "reader", "method", "for", "the", "given", "method" ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-core/src/main/java/org/drools/core/base/ClassFieldAccessorFactory.java#L361-L426
14,404
kiegroup/drools
drools-workbench-models/drools-workbench-models-commons/src/main/java/org/drools/workbench/models/commons/backend/rule/ActionCallMethodBuilder.java
ActionCallMethodBuilder.supports
public boolean supports(final String line) { final List<String> splits = new ArrayList<String>(); int depth = 0; int textDepth = 0; boolean escape = false; StringBuffer split = new StringBuffer(); for (char c : line.toCharArray()) { if (depth == 0 && c == '.') { splits.add(split.toString()); split = new StringBuffer(); depth = 0; textDepth = 0; escape = false; continue; } else if (c == '\\') { escape = true; split.append(c); continue; } else if (textDepth == 0 && c == '"') { textDepth++; } else if (!escape && textDepth > 0 && c == '"') { textDepth--; } else if (textDepth == 0 && c == '(') { depth++; } else if (textDepth == 0 && c == ')') { depth--; } split.append(c); escape = false; } splits.add(split.toString()); return splits.size() == 2; }
java
public boolean supports(final String line) { final List<String> splits = new ArrayList<String>(); int depth = 0; int textDepth = 0; boolean escape = false; StringBuffer split = new StringBuffer(); for (char c : line.toCharArray()) { if (depth == 0 && c == '.') { splits.add(split.toString()); split = new StringBuffer(); depth = 0; textDepth = 0; escape = false; continue; } else if (c == '\\') { escape = true; split.append(c); continue; } else if (textDepth == 0 && c == '"') { textDepth++; } else if (!escape && textDepth > 0 && c == '"') { textDepth--; } else if (textDepth == 0 && c == '(') { depth++; } else if (textDepth == 0 && c == ')') { depth--; } split.append(c); escape = false; } splits.add(split.toString()); return splits.size() == 2; }
[ "public", "boolean", "supports", "(", "final", "String", "line", ")", "{", "final", "List", "<", "String", ">", "splits", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "int", "depth", "=", "0", ";", "int", "textDepth", "=", "0", ";", "boolean", "escape", "=", "false", ";", "StringBuffer", "split", "=", "new", "StringBuffer", "(", ")", ";", "for", "(", "char", "c", ":", "line", ".", "toCharArray", "(", ")", ")", "{", "if", "(", "depth", "==", "0", "&&", "c", "==", "'", "'", ")", "{", "splits", ".", "add", "(", "split", ".", "toString", "(", ")", ")", ";", "split", "=", "new", "StringBuffer", "(", ")", ";", "depth", "=", "0", ";", "textDepth", "=", "0", ";", "escape", "=", "false", ";", "continue", ";", "}", "else", "if", "(", "c", "==", "'", "'", ")", "{", "escape", "=", "true", ";", "split", ".", "append", "(", "c", ")", ";", "continue", ";", "}", "else", "if", "(", "textDepth", "==", "0", "&&", "c", "==", "'", "'", ")", "{", "textDepth", "++", ";", "}", "else", "if", "(", "!", "escape", "&&", "textDepth", ">", "0", "&&", "c", "==", "'", "'", ")", "{", "textDepth", "--", ";", "}", "else", "if", "(", "textDepth", "==", "0", "&&", "c", "==", "'", "'", ")", "{", "depth", "++", ";", "}", "else", "if", "(", "textDepth", "==", "0", "&&", "c", "==", "'", "'", ")", "{", "depth", "--", ";", "}", "split", ".", "append", "(", "c", ")", ";", "escape", "=", "false", ";", "}", "splits", ".", "add", "(", "split", ".", "toString", "(", ")", ")", ";", "return", "splits", ".", "size", "(", ")", "==", "2", ";", "}" ]
ActionCallMethods do not support chained method invocations
[ "ActionCallMethods", "do", "not", "support", "chained", "method", "invocations" ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-workbench-models/drools-workbench-models-commons/src/main/java/org/drools/workbench/models/commons/backend/rule/ActionCallMethodBuilder.java#L67-L99
14,405
facebook/fresco
drawee/src/main/java/com/facebook/drawee/drawable/RoundedBitmapDrawable.java
RoundedBitmapDrawable.fromBitmapDrawable
public static RoundedBitmapDrawable fromBitmapDrawable( Resources res, BitmapDrawable bitmapDrawable) { return new RoundedBitmapDrawable(res, bitmapDrawable.getBitmap(), bitmapDrawable.getPaint()); }
java
public static RoundedBitmapDrawable fromBitmapDrawable( Resources res, BitmapDrawable bitmapDrawable) { return new RoundedBitmapDrawable(res, bitmapDrawable.getBitmap(), bitmapDrawable.getPaint()); }
[ "public", "static", "RoundedBitmapDrawable", "fromBitmapDrawable", "(", "Resources", "res", ",", "BitmapDrawable", "bitmapDrawable", ")", "{", "return", "new", "RoundedBitmapDrawable", "(", "res", ",", "bitmapDrawable", ".", "getBitmap", "(", ")", ",", "bitmapDrawable", ".", "getPaint", "(", ")", ")", ";", "}" ]
Creates a new RoundedBitmapDrawable from the given BitmapDrawable. @param res resources to use for this drawable @param bitmapDrawable bitmap drawable containing the bitmap to be used for this drawable @return the RoundedBitmapDrawable that is created
[ "Creates", "a", "new", "RoundedBitmapDrawable", "from", "the", "given", "BitmapDrawable", "." ]
0b85879d51c5036d5e46e627a6651afefc0b971a
https://github.com/facebook/fresco/blob/0b85879d51c5036d5e46e627a6651afefc0b971a/drawee/src/main/java/com/facebook/drawee/drawable/RoundedBitmapDrawable.java#L93-L97
14,406
facebook/fresco
fbcore/src/main/java/com/facebook/common/file/FileUtils.java
FileUtils.mkdirs
public static void mkdirs(File directory) throws CreateDirectoryException { if (directory.exists()) { // file exists and *is* a directory if (directory.isDirectory()) { return; } // file exists, but is not a directory - delete it if (!directory.delete()) { throw new CreateDirectoryException( directory.getAbsolutePath(), new FileDeleteException(directory.getAbsolutePath())); } } // doesn't exist. Create one if (!directory.mkdirs() && !directory.isDirectory()) { throw new CreateDirectoryException(directory.getAbsolutePath()); } }
java
public static void mkdirs(File directory) throws CreateDirectoryException { if (directory.exists()) { // file exists and *is* a directory if (directory.isDirectory()) { return; } // file exists, but is not a directory - delete it if (!directory.delete()) { throw new CreateDirectoryException( directory.getAbsolutePath(), new FileDeleteException(directory.getAbsolutePath())); } } // doesn't exist. Create one if (!directory.mkdirs() && !directory.isDirectory()) { throw new CreateDirectoryException(directory.getAbsolutePath()); } }
[ "public", "static", "void", "mkdirs", "(", "File", "directory", ")", "throws", "CreateDirectoryException", "{", "if", "(", "directory", ".", "exists", "(", ")", ")", "{", "// file exists and *is* a directory", "if", "(", "directory", ".", "isDirectory", "(", ")", ")", "{", "return", ";", "}", "// file exists, but is not a directory - delete it", "if", "(", "!", "directory", ".", "delete", "(", ")", ")", "{", "throw", "new", "CreateDirectoryException", "(", "directory", ".", "getAbsolutePath", "(", ")", ",", "new", "FileDeleteException", "(", "directory", ".", "getAbsolutePath", "(", ")", ")", ")", ";", "}", "}", "// doesn't exist. Create one", "if", "(", "!", "directory", ".", "mkdirs", "(", ")", "&&", "!", "directory", ".", "isDirectory", "(", ")", ")", "{", "throw", "new", "CreateDirectoryException", "(", "directory", ".", "getAbsolutePath", "(", ")", ")", ";", "}", "}" ]
Creates the specified directory, along with all parent paths if necessary @param directory directory to be created @throws CreateDirectoryException
[ "Creates", "the", "specified", "directory", "along", "with", "all", "parent", "paths", "if", "necessary" ]
0b85879d51c5036d5e46e627a6651afefc0b971a
https://github.com/facebook/fresco/blob/0b85879d51c5036d5e46e627a6651afefc0b971a/fbcore/src/main/java/com/facebook/common/file/FileUtils.java#L26-L45
14,407
facebook/fresco
fbcore/src/main/java/com/facebook/common/file/FileUtils.java
FileUtils.rename
public static void rename(File source, File target) throws RenameException { Preconditions.checkNotNull(source); Preconditions.checkNotNull(target); // delete the target first - but ignore the result target.delete(); if (source.renameTo(target)) { return; } Throwable innerException = null; if (target.exists()) { innerException = new FileDeleteException(target.getAbsolutePath()); } else if (!source.getParentFile().exists()) { innerException = new ParentDirNotFoundException(source.getAbsolutePath()); } else if (!source.exists()) { innerException = new FileNotFoundException(source.getAbsolutePath()); } throw new RenameException( "Unknown error renaming " + source.getAbsolutePath() + " to " + target.getAbsolutePath(), innerException); }
java
public static void rename(File source, File target) throws RenameException { Preconditions.checkNotNull(source); Preconditions.checkNotNull(target); // delete the target first - but ignore the result target.delete(); if (source.renameTo(target)) { return; } Throwable innerException = null; if (target.exists()) { innerException = new FileDeleteException(target.getAbsolutePath()); } else if (!source.getParentFile().exists()) { innerException = new ParentDirNotFoundException(source.getAbsolutePath()); } else if (!source.exists()) { innerException = new FileNotFoundException(source.getAbsolutePath()); } throw new RenameException( "Unknown error renaming " + source.getAbsolutePath() + " to " + target.getAbsolutePath(), innerException); }
[ "public", "static", "void", "rename", "(", "File", "source", ",", "File", "target", ")", "throws", "RenameException", "{", "Preconditions", ".", "checkNotNull", "(", "source", ")", ";", "Preconditions", ".", "checkNotNull", "(", "target", ")", ";", "// delete the target first - but ignore the result", "target", ".", "delete", "(", ")", ";", "if", "(", "source", ".", "renameTo", "(", "target", ")", ")", "{", "return", ";", "}", "Throwable", "innerException", "=", "null", ";", "if", "(", "target", ".", "exists", "(", ")", ")", "{", "innerException", "=", "new", "FileDeleteException", "(", "target", ".", "getAbsolutePath", "(", ")", ")", ";", "}", "else", "if", "(", "!", "source", ".", "getParentFile", "(", ")", ".", "exists", "(", ")", ")", "{", "innerException", "=", "new", "ParentDirNotFoundException", "(", "source", ".", "getAbsolutePath", "(", ")", ")", ";", "}", "else", "if", "(", "!", "source", ".", "exists", "(", ")", ")", "{", "innerException", "=", "new", "FileNotFoundException", "(", "source", ".", "getAbsolutePath", "(", ")", ")", ";", "}", "throw", "new", "RenameException", "(", "\"Unknown error renaming \"", "+", "source", ".", "getAbsolutePath", "(", ")", "+", "\" to \"", "+", "target", ".", "getAbsolutePath", "(", ")", ",", "innerException", ")", ";", "}" ]
Renames the source file to the target file. If the target file exists, then we attempt to delete it. If the delete or the rename operation fails, then we raise an exception @param source the source file @param target the new 'name' for the source file @throws IOException
[ "Renames", "the", "source", "file", "to", "the", "target", "file", ".", "If", "the", "target", "file", "exists", "then", "we", "attempt", "to", "delete", "it", ".", "If", "the", "delete", "or", "the", "rename", "operation", "fails", "then", "we", "raise", "an", "exception" ]
0b85879d51c5036d5e46e627a6651afefc0b971a
https://github.com/facebook/fresco/blob/0b85879d51c5036d5e46e627a6651afefc0b971a/fbcore/src/main/java/com/facebook/common/file/FileUtils.java#L54-L77
14,408
facebook/fresco
drawee/src/main/java/com/facebook/drawee/generic/GenericDraweeHierarchyBuilder.java
GenericDraweeHierarchyBuilder.init
private void init() { mFadeDuration = DEFAULT_FADE_DURATION; mDesiredAspectRatio = 0; mPlaceholderImage = null; mPlaceholderImageScaleType = DEFAULT_SCALE_TYPE; mRetryImage = null; mRetryImageScaleType = DEFAULT_SCALE_TYPE; mFailureImage = null; mFailureImageScaleType = DEFAULT_SCALE_TYPE; mProgressBarImage = null; mProgressBarImageScaleType = DEFAULT_SCALE_TYPE; mActualImageScaleType = DEFAULT_ACTUAL_IMAGE_SCALE_TYPE; mActualImageMatrix = null; mActualImageFocusPoint = null; mActualImageColorFilter = null; mBackground = null; mOverlays = null; mPressedStateOverlay = null; mRoundingParams = null; }
java
private void init() { mFadeDuration = DEFAULT_FADE_DURATION; mDesiredAspectRatio = 0; mPlaceholderImage = null; mPlaceholderImageScaleType = DEFAULT_SCALE_TYPE; mRetryImage = null; mRetryImageScaleType = DEFAULT_SCALE_TYPE; mFailureImage = null; mFailureImageScaleType = DEFAULT_SCALE_TYPE; mProgressBarImage = null; mProgressBarImageScaleType = DEFAULT_SCALE_TYPE; mActualImageScaleType = DEFAULT_ACTUAL_IMAGE_SCALE_TYPE; mActualImageMatrix = null; mActualImageFocusPoint = null; mActualImageColorFilter = null; mBackground = null; mOverlays = null; mPressedStateOverlay = null; mRoundingParams = null; }
[ "private", "void", "init", "(", ")", "{", "mFadeDuration", "=", "DEFAULT_FADE_DURATION", ";", "mDesiredAspectRatio", "=", "0", ";", "mPlaceholderImage", "=", "null", ";", "mPlaceholderImageScaleType", "=", "DEFAULT_SCALE_TYPE", ";", "mRetryImage", "=", "null", ";", "mRetryImageScaleType", "=", "DEFAULT_SCALE_TYPE", ";", "mFailureImage", "=", "null", ";", "mFailureImageScaleType", "=", "DEFAULT_SCALE_TYPE", ";", "mProgressBarImage", "=", "null", ";", "mProgressBarImageScaleType", "=", "DEFAULT_SCALE_TYPE", ";", "mActualImageScaleType", "=", "DEFAULT_ACTUAL_IMAGE_SCALE_TYPE", ";", "mActualImageMatrix", "=", "null", ";", "mActualImageFocusPoint", "=", "null", ";", "mActualImageColorFilter", "=", "null", ";", "mBackground", "=", "null", ";", "mOverlays", "=", "null", ";", "mPressedStateOverlay", "=", "null", ";", "mRoundingParams", "=", "null", ";", "}" ]
Initializes this builder to its defaults.
[ "Initializes", "this", "builder", "to", "its", "defaults", "." ]
0b85879d51c5036d5e46e627a6651afefc0b971a
https://github.com/facebook/fresco/blob/0b85879d51c5036d5e46e627a6651afefc0b971a/drawee/src/main/java/com/facebook/drawee/generic/GenericDraweeHierarchyBuilder.java#L80-L107
14,409
facebook/fresco
fbcore/src/main/java/com/facebook/widget/text/span/BetterImageSpan.java
BetterImageSpan.normalizeAlignment
public static final @BetterImageSpanAlignment int normalizeAlignment(int alignment) { switch (alignment) { case DynamicDrawableSpan.ALIGN_BOTTOM: return ALIGN_BOTTOM; case ALIGN_CENTER: return ALIGN_CENTER; case DynamicDrawableSpan.ALIGN_BASELINE: default: return ALIGN_BASELINE; } }
java
public static final @BetterImageSpanAlignment int normalizeAlignment(int alignment) { switch (alignment) { case DynamicDrawableSpan.ALIGN_BOTTOM: return ALIGN_BOTTOM; case ALIGN_CENTER: return ALIGN_CENTER; case DynamicDrawableSpan.ALIGN_BASELINE: default: return ALIGN_BASELINE; } }
[ "public", "static", "final", "@", "BetterImageSpanAlignment", "int", "normalizeAlignment", "(", "int", "alignment", ")", "{", "switch", "(", "alignment", ")", "{", "case", "DynamicDrawableSpan", ".", "ALIGN_BOTTOM", ":", "return", "ALIGN_BOTTOM", ";", "case", "ALIGN_CENTER", ":", "return", "ALIGN_CENTER", ";", "case", "DynamicDrawableSpan", ".", "ALIGN_BASELINE", ":", "default", ":", "return", "ALIGN_BASELINE", ";", "}", "}" ]
A helper function to allow dropping in BetterImageSpan as a replacement to ImageSpan, and allowing for center alignment if passed in.
[ "A", "helper", "function", "to", "allow", "dropping", "in", "BetterImageSpan", "as", "a", "replacement", "to", "ImageSpan", "and", "allowing", "for", "center", "alignment", "if", "passed", "in", "." ]
0b85879d51c5036d5e46e627a6651afefc0b971a
https://github.com/facebook/fresco/blob/0b85879d51c5036d5e46e627a6651afefc0b971a/fbcore/src/main/java/com/facebook/widget/text/span/BetterImageSpan.java#L45-L56
14,410
facebook/fresco
fbcore/src/main/java/com/facebook/widget/text/span/BetterImageSpan.java
BetterImageSpan.getSize
@Override public int getSize( Paint paint, CharSequence text, int start, int end, Paint.FontMetricsInt fontMetrics) { updateBounds(); if (fontMetrics == null) { return mWidth; } int offsetAbove = getOffsetAboveBaseline(fontMetrics); int offsetBelow = mHeight + offsetAbove; if (offsetAbove < fontMetrics.ascent) { fontMetrics.ascent = offsetAbove; } if (offsetAbove < fontMetrics.top) { fontMetrics.top = offsetAbove; } if (offsetBelow > fontMetrics.descent) { fontMetrics.descent = offsetBelow; } if (offsetBelow > fontMetrics.bottom) { fontMetrics.bottom = offsetBelow; } return mWidth; }
java
@Override public int getSize( Paint paint, CharSequence text, int start, int end, Paint.FontMetricsInt fontMetrics) { updateBounds(); if (fontMetrics == null) { return mWidth; } int offsetAbove = getOffsetAboveBaseline(fontMetrics); int offsetBelow = mHeight + offsetAbove; if (offsetAbove < fontMetrics.ascent) { fontMetrics.ascent = offsetAbove; } if (offsetAbove < fontMetrics.top) { fontMetrics.top = offsetAbove; } if (offsetBelow > fontMetrics.descent) { fontMetrics.descent = offsetBelow; } if (offsetBelow > fontMetrics.bottom) { fontMetrics.bottom = offsetBelow; } return mWidth; }
[ "@", "Override", "public", "int", "getSize", "(", "Paint", "paint", ",", "CharSequence", "text", ",", "int", "start", ",", "int", "end", ",", "Paint", ".", "FontMetricsInt", "fontMetrics", ")", "{", "updateBounds", "(", ")", ";", "if", "(", "fontMetrics", "==", "null", ")", "{", "return", "mWidth", ";", "}", "int", "offsetAbove", "=", "getOffsetAboveBaseline", "(", "fontMetrics", ")", ";", "int", "offsetBelow", "=", "mHeight", "+", "offsetAbove", ";", "if", "(", "offsetAbove", "<", "fontMetrics", ".", "ascent", ")", "{", "fontMetrics", ".", "ascent", "=", "offsetAbove", ";", "}", "if", "(", "offsetAbove", "<", "fontMetrics", ".", "top", ")", "{", "fontMetrics", ".", "top", "=", "offsetAbove", ";", "}", "if", "(", "offsetBelow", ">", "fontMetrics", ".", "descent", ")", "{", "fontMetrics", ".", "descent", "=", "offsetBelow", ";", "}", "if", "(", "offsetBelow", ">", "fontMetrics", ".", "bottom", ")", "{", "fontMetrics", ".", "bottom", "=", "offsetBelow", ";", "}", "return", "mWidth", ";", "}" ]
Returns the width of the image span and increases the height if font metrics are available.
[ "Returns", "the", "width", "of", "the", "image", "span", "and", "increases", "the", "height", "if", "font", "metrics", "are", "available", "." ]
0b85879d51c5036d5e46e627a6651afefc0b971a
https://github.com/facebook/fresco/blob/0b85879d51c5036d5e46e627a6651afefc0b971a/fbcore/src/main/java/com/facebook/widget/text/span/BetterImageSpan.java#L82-L113
14,411
facebook/fresco
imagepipeline/src/main/java/com/facebook/imagepipeline/core/ProducerSequenceFactory.java
ProducerSequenceFactory.getEncodedImageProducerSequence
public Producer<CloseableReference<PooledByteBuffer>> getEncodedImageProducerSequence( ImageRequest imageRequest) { try { if (FrescoSystrace.isTracing()) { FrescoSystrace.beginSection("ProducerSequenceFactory#getEncodedImageProducerSequence"); } validateEncodedImageRequest(imageRequest); final Uri uri = imageRequest.getSourceUri(); switch (imageRequest.getSourceUriType()) { case SOURCE_TYPE_NETWORK: return getNetworkFetchEncodedImageProducerSequence(); case SOURCE_TYPE_LOCAL_VIDEO_FILE: case SOURCE_TYPE_LOCAL_IMAGE_FILE: return getLocalFileFetchEncodedImageProducerSequence(); default: throw new IllegalArgumentException( "Unsupported uri scheme for encoded image fetch! Uri is: " + getShortenedUriString(uri)); } } finally { if (FrescoSystrace.isTracing()) { FrescoSystrace.endSection(); } } }
java
public Producer<CloseableReference<PooledByteBuffer>> getEncodedImageProducerSequence( ImageRequest imageRequest) { try { if (FrescoSystrace.isTracing()) { FrescoSystrace.beginSection("ProducerSequenceFactory#getEncodedImageProducerSequence"); } validateEncodedImageRequest(imageRequest); final Uri uri = imageRequest.getSourceUri(); switch (imageRequest.getSourceUriType()) { case SOURCE_TYPE_NETWORK: return getNetworkFetchEncodedImageProducerSequence(); case SOURCE_TYPE_LOCAL_VIDEO_FILE: case SOURCE_TYPE_LOCAL_IMAGE_FILE: return getLocalFileFetchEncodedImageProducerSequence(); default: throw new IllegalArgumentException( "Unsupported uri scheme for encoded image fetch! Uri is: " + getShortenedUriString(uri)); } } finally { if (FrescoSystrace.isTracing()) { FrescoSystrace.endSection(); } } }
[ "public", "Producer", "<", "CloseableReference", "<", "PooledByteBuffer", ">", ">", "getEncodedImageProducerSequence", "(", "ImageRequest", "imageRequest", ")", "{", "try", "{", "if", "(", "FrescoSystrace", ".", "isTracing", "(", ")", ")", "{", "FrescoSystrace", ".", "beginSection", "(", "\"ProducerSequenceFactory#getEncodedImageProducerSequence\"", ")", ";", "}", "validateEncodedImageRequest", "(", "imageRequest", ")", ";", "final", "Uri", "uri", "=", "imageRequest", ".", "getSourceUri", "(", ")", ";", "switch", "(", "imageRequest", ".", "getSourceUriType", "(", ")", ")", "{", "case", "SOURCE_TYPE_NETWORK", ":", "return", "getNetworkFetchEncodedImageProducerSequence", "(", ")", ";", "case", "SOURCE_TYPE_LOCAL_VIDEO_FILE", ":", "case", "SOURCE_TYPE_LOCAL_IMAGE_FILE", ":", "return", "getLocalFileFetchEncodedImageProducerSequence", "(", ")", ";", "default", ":", "throw", "new", "IllegalArgumentException", "(", "\"Unsupported uri scheme for encoded image fetch! Uri is: \"", "+", "getShortenedUriString", "(", "uri", ")", ")", ";", "}", "}", "finally", "{", "if", "(", "FrescoSystrace", ".", "isTracing", "(", ")", ")", "{", "FrescoSystrace", ".", "endSection", "(", ")", ";", "}", "}", "}" ]
Returns a sequence that can be used for a request for an encoded image from either network or local files. @param imageRequest the request that will be submitted @return the sequence that should be used to process the request
[ "Returns", "a", "sequence", "that", "can", "be", "used", "for", "a", "request", "for", "an", "encoded", "image", "from", "either", "network", "or", "local", "files", "." ]
0b85879d51c5036d5e46e627a6651afefc0b971a
https://github.com/facebook/fresco/blob/0b85879d51c5036d5e46e627a6651afefc0b971a/imagepipeline/src/main/java/com/facebook/imagepipeline/core/ProducerSequenceFactory.java#L135-L160
14,412
facebook/fresco
imagepipeline/src/main/java/com/facebook/imagepipeline/core/ProducerSequenceFactory.java
ProducerSequenceFactory.getNetworkFetchEncodedImageProducerSequence
public Producer<CloseableReference<PooledByteBuffer>> getNetworkFetchEncodedImageProducerSequence() { synchronized (this) { if (FrescoSystrace.isTracing()) { FrescoSystrace.beginSection( "ProducerSequenceFactory#getNetworkFetchEncodedImageProducerSequence"); } if (mNetworkEncodedImageProducerSequence == null) { if (FrescoSystrace.isTracing()) { FrescoSystrace.beginSection( "ProducerSequenceFactory#getNetworkFetchEncodedImageProducerSequence:init"); } mNetworkEncodedImageProducerSequence = new RemoveImageTransformMetaDataProducer( getBackgroundNetworkFetchToEncodedMemorySequence()); if (FrescoSystrace.isTracing()) { FrescoSystrace.endSection(); } } if (FrescoSystrace.isTracing()) { FrescoSystrace.endSection(); } } return mNetworkEncodedImageProducerSequence; }
java
public Producer<CloseableReference<PooledByteBuffer>> getNetworkFetchEncodedImageProducerSequence() { synchronized (this) { if (FrescoSystrace.isTracing()) { FrescoSystrace.beginSection( "ProducerSequenceFactory#getNetworkFetchEncodedImageProducerSequence"); } if (mNetworkEncodedImageProducerSequence == null) { if (FrescoSystrace.isTracing()) { FrescoSystrace.beginSection( "ProducerSequenceFactory#getNetworkFetchEncodedImageProducerSequence:init"); } mNetworkEncodedImageProducerSequence = new RemoveImageTransformMetaDataProducer( getBackgroundNetworkFetchToEncodedMemorySequence()); if (FrescoSystrace.isTracing()) { FrescoSystrace.endSection(); } } if (FrescoSystrace.isTracing()) { FrescoSystrace.endSection(); } } return mNetworkEncodedImageProducerSequence; }
[ "public", "Producer", "<", "CloseableReference", "<", "PooledByteBuffer", ">", ">", "getNetworkFetchEncodedImageProducerSequence", "(", ")", "{", "synchronized", "(", "this", ")", "{", "if", "(", "FrescoSystrace", ".", "isTracing", "(", ")", ")", "{", "FrescoSystrace", ".", "beginSection", "(", "\"ProducerSequenceFactory#getNetworkFetchEncodedImageProducerSequence\"", ")", ";", "}", "if", "(", "mNetworkEncodedImageProducerSequence", "==", "null", ")", "{", "if", "(", "FrescoSystrace", ".", "isTracing", "(", ")", ")", "{", "FrescoSystrace", ".", "beginSection", "(", "\"ProducerSequenceFactory#getNetworkFetchEncodedImageProducerSequence:init\"", ")", ";", "}", "mNetworkEncodedImageProducerSequence", "=", "new", "RemoveImageTransformMetaDataProducer", "(", "getBackgroundNetworkFetchToEncodedMemorySequence", "(", ")", ")", ";", "if", "(", "FrescoSystrace", ".", "isTracing", "(", ")", ")", "{", "FrescoSystrace", ".", "endSection", "(", ")", ";", "}", "}", "if", "(", "FrescoSystrace", ".", "isTracing", "(", ")", ")", "{", "FrescoSystrace", ".", "endSection", "(", ")", ";", "}", "}", "return", "mNetworkEncodedImageProducerSequence", ";", "}" ]
Returns a sequence that can be used for a request for an encoded image from network.
[ "Returns", "a", "sequence", "that", "can", "be", "used", "for", "a", "request", "for", "an", "encoded", "image", "from", "network", "." ]
0b85879d51c5036d5e46e627a6651afefc0b971a
https://github.com/facebook/fresco/blob/0b85879d51c5036d5e46e627a6651afefc0b971a/imagepipeline/src/main/java/com/facebook/imagepipeline/core/ProducerSequenceFactory.java#L165-L189
14,413
facebook/fresco
imagepipeline/src/main/java/com/facebook/imagepipeline/core/ProducerSequenceFactory.java
ProducerSequenceFactory.getLocalFileFetchEncodedImageProducerSequence
public Producer<CloseableReference<PooledByteBuffer>> getLocalFileFetchEncodedImageProducerSequence() { synchronized (this) { if (FrescoSystrace.isTracing()) { FrescoSystrace.beginSection( "ProducerSequenceFactory#getLocalFileFetchEncodedImageProducerSequence"); } if (mLocalFileEncodedImageProducerSequence == null) { if (FrescoSystrace.isTracing()) { FrescoSystrace.beginSection( "ProducerSequenceFactory#getLocalFileFetchEncodedImageProducerSequence:init"); } mLocalFileEncodedImageProducerSequence = new RemoveImageTransformMetaDataProducer( getBackgroundLocalFileFetchToEncodeMemorySequence()); if (FrescoSystrace.isTracing()) { FrescoSystrace.endSection(); } } if (FrescoSystrace.isTracing()) { FrescoSystrace.endSection(); } } return mLocalFileEncodedImageProducerSequence; }
java
public Producer<CloseableReference<PooledByteBuffer>> getLocalFileFetchEncodedImageProducerSequence() { synchronized (this) { if (FrescoSystrace.isTracing()) { FrescoSystrace.beginSection( "ProducerSequenceFactory#getLocalFileFetchEncodedImageProducerSequence"); } if (mLocalFileEncodedImageProducerSequence == null) { if (FrescoSystrace.isTracing()) { FrescoSystrace.beginSection( "ProducerSequenceFactory#getLocalFileFetchEncodedImageProducerSequence:init"); } mLocalFileEncodedImageProducerSequence = new RemoveImageTransformMetaDataProducer( getBackgroundLocalFileFetchToEncodeMemorySequence()); if (FrescoSystrace.isTracing()) { FrescoSystrace.endSection(); } } if (FrescoSystrace.isTracing()) { FrescoSystrace.endSection(); } } return mLocalFileEncodedImageProducerSequence; }
[ "public", "Producer", "<", "CloseableReference", "<", "PooledByteBuffer", ">", ">", "getLocalFileFetchEncodedImageProducerSequence", "(", ")", "{", "synchronized", "(", "this", ")", "{", "if", "(", "FrescoSystrace", ".", "isTracing", "(", ")", ")", "{", "FrescoSystrace", ".", "beginSection", "(", "\"ProducerSequenceFactory#getLocalFileFetchEncodedImageProducerSequence\"", ")", ";", "}", "if", "(", "mLocalFileEncodedImageProducerSequence", "==", "null", ")", "{", "if", "(", "FrescoSystrace", ".", "isTracing", "(", ")", ")", "{", "FrescoSystrace", ".", "beginSection", "(", "\"ProducerSequenceFactory#getLocalFileFetchEncodedImageProducerSequence:init\"", ")", ";", "}", "mLocalFileEncodedImageProducerSequence", "=", "new", "RemoveImageTransformMetaDataProducer", "(", "getBackgroundLocalFileFetchToEncodeMemorySequence", "(", ")", ")", ";", "if", "(", "FrescoSystrace", ".", "isTracing", "(", ")", ")", "{", "FrescoSystrace", ".", "endSection", "(", ")", ";", "}", "}", "if", "(", "FrescoSystrace", ".", "isTracing", "(", ")", ")", "{", "FrescoSystrace", ".", "endSection", "(", ")", ";", "}", "}", "return", "mLocalFileEncodedImageProducerSequence", ";", "}" ]
Returns a sequence that can be used for a request for an encoded image from a local file.
[ "Returns", "a", "sequence", "that", "can", "be", "used", "for", "a", "request", "for", "an", "encoded", "image", "from", "a", "local", "file", "." ]
0b85879d51c5036d5e46e627a6651afefc0b971a
https://github.com/facebook/fresco/blob/0b85879d51c5036d5e46e627a6651afefc0b971a/imagepipeline/src/main/java/com/facebook/imagepipeline/core/ProducerSequenceFactory.java#L194-L218
14,414
facebook/fresco
imagepipeline/src/main/java/com/facebook/imagepipeline/core/ProducerSequenceFactory.java
ProducerSequenceFactory.getEncodedImagePrefetchProducerSequence
public Producer<Void> getEncodedImagePrefetchProducerSequence(ImageRequest imageRequest) { validateEncodedImageRequest(imageRequest); switch (imageRequest.getSourceUriType()) { case SOURCE_TYPE_NETWORK: return getNetworkFetchToEncodedMemoryPrefetchSequence(); case SOURCE_TYPE_LOCAL_VIDEO_FILE: case SOURCE_TYPE_LOCAL_IMAGE_FILE: return getLocalFileFetchToEncodedMemoryPrefetchSequence(); default: final Uri uri = imageRequest.getSourceUri(); throw new IllegalArgumentException( "Unsupported uri scheme for encoded image fetch! Uri is: " + getShortenedUriString(uri)); } }
java
public Producer<Void> getEncodedImagePrefetchProducerSequence(ImageRequest imageRequest) { validateEncodedImageRequest(imageRequest); switch (imageRequest.getSourceUriType()) { case SOURCE_TYPE_NETWORK: return getNetworkFetchToEncodedMemoryPrefetchSequence(); case SOURCE_TYPE_LOCAL_VIDEO_FILE: case SOURCE_TYPE_LOCAL_IMAGE_FILE: return getLocalFileFetchToEncodedMemoryPrefetchSequence(); default: final Uri uri = imageRequest.getSourceUri(); throw new IllegalArgumentException( "Unsupported uri scheme for encoded image fetch! Uri is: " + getShortenedUriString(uri)); } }
[ "public", "Producer", "<", "Void", ">", "getEncodedImagePrefetchProducerSequence", "(", "ImageRequest", "imageRequest", ")", "{", "validateEncodedImageRequest", "(", "imageRequest", ")", ";", "switch", "(", "imageRequest", ".", "getSourceUriType", "(", ")", ")", "{", "case", "SOURCE_TYPE_NETWORK", ":", "return", "getNetworkFetchToEncodedMemoryPrefetchSequence", "(", ")", ";", "case", "SOURCE_TYPE_LOCAL_VIDEO_FILE", ":", "case", "SOURCE_TYPE_LOCAL_IMAGE_FILE", ":", "return", "getLocalFileFetchToEncodedMemoryPrefetchSequence", "(", ")", ";", "default", ":", "final", "Uri", "uri", "=", "imageRequest", ".", "getSourceUri", "(", ")", ";", "throw", "new", "IllegalArgumentException", "(", "\"Unsupported uri scheme for encoded image fetch! Uri is: \"", "+", "getShortenedUriString", "(", "uri", ")", ")", ";", "}", "}" ]
Returns a sequence that can be used for a prefetch request for an encoded image. <p>Guaranteed to return the same sequence as {@code getEncodedImageProducerSequence(request)}, except that it is pre-pended with a {@link SwallowResultProducer}. @param imageRequest the request that will be submitted @return the sequence that should be used to process the request
[ "Returns", "a", "sequence", "that", "can", "be", "used", "for", "a", "prefetch", "request", "for", "an", "encoded", "image", "." ]
0b85879d51c5036d5e46e627a6651afefc0b971a
https://github.com/facebook/fresco/blob/0b85879d51c5036d5e46e627a6651afefc0b971a/imagepipeline/src/main/java/com/facebook/imagepipeline/core/ProducerSequenceFactory.java#L229-L244
14,415
facebook/fresco
imagepipeline/src/main/java/com/facebook/imagepipeline/core/ProducerSequenceFactory.java
ProducerSequenceFactory.getDecodedImageProducerSequence
public Producer<CloseableReference<CloseableImage>> getDecodedImageProducerSequence( ImageRequest imageRequest) { if (FrescoSystrace.isTracing()) { FrescoSystrace.beginSection("ProducerSequenceFactory#getDecodedImageProducerSequence"); } Producer<CloseableReference<CloseableImage>> pipelineSequence = getBasicDecodedImageSequence(imageRequest); if (imageRequest.getPostprocessor() != null) { pipelineSequence = getPostprocessorSequence(pipelineSequence); } if (mUseBitmapPrepareToDraw) { pipelineSequence = getBitmapPrepareSequence(pipelineSequence); } if (FrescoSystrace.isTracing()) { FrescoSystrace.endSection(); } return pipelineSequence; }
java
public Producer<CloseableReference<CloseableImage>> getDecodedImageProducerSequence( ImageRequest imageRequest) { if (FrescoSystrace.isTracing()) { FrescoSystrace.beginSection("ProducerSequenceFactory#getDecodedImageProducerSequence"); } Producer<CloseableReference<CloseableImage>> pipelineSequence = getBasicDecodedImageSequence(imageRequest); if (imageRequest.getPostprocessor() != null) { pipelineSequence = getPostprocessorSequence(pipelineSequence); } if (mUseBitmapPrepareToDraw) { pipelineSequence = getBitmapPrepareSequence(pipelineSequence); } if (FrescoSystrace.isTracing()) { FrescoSystrace.endSection(); } return pipelineSequence; }
[ "public", "Producer", "<", "CloseableReference", "<", "CloseableImage", ">", ">", "getDecodedImageProducerSequence", "(", "ImageRequest", "imageRequest", ")", "{", "if", "(", "FrescoSystrace", ".", "isTracing", "(", ")", ")", "{", "FrescoSystrace", ".", "beginSection", "(", "\"ProducerSequenceFactory#getDecodedImageProducerSequence\"", ")", ";", "}", "Producer", "<", "CloseableReference", "<", "CloseableImage", ">", ">", "pipelineSequence", "=", "getBasicDecodedImageSequence", "(", "imageRequest", ")", ";", "if", "(", "imageRequest", ".", "getPostprocessor", "(", ")", "!=", "null", ")", "{", "pipelineSequence", "=", "getPostprocessorSequence", "(", "pipelineSequence", ")", ";", "}", "if", "(", "mUseBitmapPrepareToDraw", ")", "{", "pipelineSequence", "=", "getBitmapPrepareSequence", "(", "pipelineSequence", ")", ";", "}", "if", "(", "FrescoSystrace", ".", "isTracing", "(", ")", ")", "{", "FrescoSystrace", ".", "endSection", "(", ")", ";", "}", "return", "pipelineSequence", ";", "}" ]
Returns a sequence that can be used for a request for a decoded image. @param imageRequest the request that will be submitted @return the sequence that should be used to process the request
[ "Returns", "a", "sequence", "that", "can", "be", "used", "for", "a", "request", "for", "a", "decoded", "image", "." ]
0b85879d51c5036d5e46e627a6651afefc0b971a
https://github.com/facebook/fresco/blob/0b85879d51c5036d5e46e627a6651afefc0b971a/imagepipeline/src/main/java/com/facebook/imagepipeline/core/ProducerSequenceFactory.java#L259-L278
14,416
facebook/fresco
imagepipeline/src/main/java/com/facebook/imagepipeline/core/ProducerSequenceFactory.java
ProducerSequenceFactory.getDecodedImagePrefetchProducerSequence
public Producer<Void> getDecodedImagePrefetchProducerSequence( ImageRequest imageRequest) { Producer<CloseableReference<CloseableImage>> inputProducer = getBasicDecodedImageSequence(imageRequest); if (mUseBitmapPrepareToDraw) { inputProducer = getBitmapPrepareSequence(inputProducer); } return getDecodedImagePrefetchSequence(inputProducer); }
java
public Producer<Void> getDecodedImagePrefetchProducerSequence( ImageRequest imageRequest) { Producer<CloseableReference<CloseableImage>> inputProducer = getBasicDecodedImageSequence(imageRequest); if (mUseBitmapPrepareToDraw) { inputProducer = getBitmapPrepareSequence(inputProducer); } return getDecodedImagePrefetchSequence(inputProducer); }
[ "public", "Producer", "<", "Void", ">", "getDecodedImagePrefetchProducerSequence", "(", "ImageRequest", "imageRequest", ")", "{", "Producer", "<", "CloseableReference", "<", "CloseableImage", ">>", "inputProducer", "=", "getBasicDecodedImageSequence", "(", "imageRequest", ")", ";", "if", "(", "mUseBitmapPrepareToDraw", ")", "{", "inputProducer", "=", "getBitmapPrepareSequence", "(", "inputProducer", ")", ";", "}", "return", "getDecodedImagePrefetchSequence", "(", "inputProducer", ")", ";", "}" ]
Returns a sequence that can be used for a prefetch request for a decoded image. @param imageRequest the request that will be submitted @return the sequence that should be used to process the request
[ "Returns", "a", "sequence", "that", "can", "be", "used", "for", "a", "prefetch", "request", "for", "a", "decoded", "image", "." ]
0b85879d51c5036d5e46e627a6651afefc0b971a
https://github.com/facebook/fresco/blob/0b85879d51c5036d5e46e627a6651afefc0b971a/imagepipeline/src/main/java/com/facebook/imagepipeline/core/ProducerSequenceFactory.java#L286-L296
14,417
facebook/fresco
imagepipeline/src/main/java/com/facebook/imagepipeline/core/ProducerSequenceFactory.java
ProducerSequenceFactory.getLocalVideoFileFetchSequence
private synchronized Producer<CloseableReference<CloseableImage>> getLocalVideoFileFetchSequence() { if (mLocalVideoFileFetchSequence == null) { LocalVideoThumbnailProducer localVideoThumbnailProducer = mProducerFactory.newLocalVideoThumbnailProducer(); mLocalVideoFileFetchSequence = newBitmapCacheGetToBitmapCacheSequence(localVideoThumbnailProducer); } return mLocalVideoFileFetchSequence; }
java
private synchronized Producer<CloseableReference<CloseableImage>> getLocalVideoFileFetchSequence() { if (mLocalVideoFileFetchSequence == null) { LocalVideoThumbnailProducer localVideoThumbnailProducer = mProducerFactory.newLocalVideoThumbnailProducer(); mLocalVideoFileFetchSequence = newBitmapCacheGetToBitmapCacheSequence(localVideoThumbnailProducer); } return mLocalVideoFileFetchSequence; }
[ "private", "synchronized", "Producer", "<", "CloseableReference", "<", "CloseableImage", ">", ">", "getLocalVideoFileFetchSequence", "(", ")", "{", "if", "(", "mLocalVideoFileFetchSequence", "==", "null", ")", "{", "LocalVideoThumbnailProducer", "localVideoThumbnailProducer", "=", "mProducerFactory", ".", "newLocalVideoThumbnailProducer", "(", ")", ";", "mLocalVideoFileFetchSequence", "=", "newBitmapCacheGetToBitmapCacheSequence", "(", "localVideoThumbnailProducer", ")", ";", "}", "return", "mLocalVideoFileFetchSequence", ";", "}" ]
Bitmap cache get -> thread hand off -> multiplex -> bitmap cache -> local video thumbnail
[ "Bitmap", "cache", "get", "-", ">", "thread", "hand", "off", "-", ">", "multiplex", "-", ">", "bitmap", "cache", "-", ">", "local", "video", "thumbnail" ]
0b85879d51c5036d5e46e627a6651afefc0b971a
https://github.com/facebook/fresco/blob/0b85879d51c5036d5e46e627a6651afefc0b971a/imagepipeline/src/main/java/com/facebook/imagepipeline/core/ProducerSequenceFactory.java#L535-L544
14,418
facebook/fresco
imagepipeline/src/main/java/com/facebook/imagepipeline/core/ProducerSequenceFactory.java
ProducerSequenceFactory.newBitmapCacheGetToBitmapCacheSequence
private Producer<CloseableReference<CloseableImage>> newBitmapCacheGetToBitmapCacheSequence( Producer<CloseableReference<CloseableImage>> inputProducer) { BitmapMemoryCacheProducer bitmapMemoryCacheProducer = mProducerFactory.newBitmapMemoryCacheProducer(inputProducer); BitmapMemoryCacheKeyMultiplexProducer bitmapKeyMultiplexProducer = mProducerFactory.newBitmapMemoryCacheKeyMultiplexProducer(bitmapMemoryCacheProducer); ThreadHandoffProducer<CloseableReference<CloseableImage>> threadHandoffProducer = mProducerFactory.newBackgroundThreadHandoffProducer( bitmapKeyMultiplexProducer, mThreadHandoffProducerQueue); return mProducerFactory.newBitmapMemoryCacheGetProducer(threadHandoffProducer); }
java
private Producer<CloseableReference<CloseableImage>> newBitmapCacheGetToBitmapCacheSequence( Producer<CloseableReference<CloseableImage>> inputProducer) { BitmapMemoryCacheProducer bitmapMemoryCacheProducer = mProducerFactory.newBitmapMemoryCacheProducer(inputProducer); BitmapMemoryCacheKeyMultiplexProducer bitmapKeyMultiplexProducer = mProducerFactory.newBitmapMemoryCacheKeyMultiplexProducer(bitmapMemoryCacheProducer); ThreadHandoffProducer<CloseableReference<CloseableImage>> threadHandoffProducer = mProducerFactory.newBackgroundThreadHandoffProducer( bitmapKeyMultiplexProducer, mThreadHandoffProducerQueue); return mProducerFactory.newBitmapMemoryCacheGetProducer(threadHandoffProducer); }
[ "private", "Producer", "<", "CloseableReference", "<", "CloseableImage", ">", ">", "newBitmapCacheGetToBitmapCacheSequence", "(", "Producer", "<", "CloseableReference", "<", "CloseableImage", ">", ">", "inputProducer", ")", "{", "BitmapMemoryCacheProducer", "bitmapMemoryCacheProducer", "=", "mProducerFactory", ".", "newBitmapMemoryCacheProducer", "(", "inputProducer", ")", ";", "BitmapMemoryCacheKeyMultiplexProducer", "bitmapKeyMultiplexProducer", "=", "mProducerFactory", ".", "newBitmapMemoryCacheKeyMultiplexProducer", "(", "bitmapMemoryCacheProducer", ")", ";", "ThreadHandoffProducer", "<", "CloseableReference", "<", "CloseableImage", ">", ">", "threadHandoffProducer", "=", "mProducerFactory", ".", "newBackgroundThreadHandoffProducer", "(", "bitmapKeyMultiplexProducer", ",", "mThreadHandoffProducerQueue", ")", ";", "return", "mProducerFactory", ".", "newBitmapMemoryCacheGetProducer", "(", "threadHandoffProducer", ")", ";", "}" ]
Bitmap cache get -> thread hand off -> multiplex -> bitmap cache @param inputProducer producer providing the input to the bitmap cache @return bitmap cache get to bitmap cache sequence
[ "Bitmap", "cache", "get", "-", ">", "thread", "hand", "off", "-", ">", "multiplex", "-", ">", "bitmap", "cache" ]
0b85879d51c5036d5e46e627a6651afefc0b971a
https://github.com/facebook/fresco/blob/0b85879d51c5036d5e46e627a6651afefc0b971a/imagepipeline/src/main/java/com/facebook/imagepipeline/core/ProducerSequenceFactory.java#L740-L751
14,419
facebook/fresco
imagepipeline/src/main/java/com/facebook/imagepipeline/core/ProducerSequenceFactory.java
ProducerSequenceFactory.newLocalTransformationsSequence
private Producer<EncodedImage> newLocalTransformationsSequence( Producer<EncodedImage> inputProducer, ThumbnailProducer<EncodedImage>[] thumbnailProducers) { Producer<EncodedImage> localImageProducer = ProducerFactory.newAddImageTransformMetaDataProducer(inputProducer); localImageProducer = mProducerFactory.newResizeAndRotateProducer( localImageProducer, true, mImageTranscoderFactory); ThrottlingProducer<EncodedImage> localImageThrottlingProducer = mProducerFactory.newThrottlingProducer(localImageProducer); return mProducerFactory.newBranchOnSeparateImagesProducer( newLocalThumbnailProducer(thumbnailProducers), localImageThrottlingProducer); }
java
private Producer<EncodedImage> newLocalTransformationsSequence( Producer<EncodedImage> inputProducer, ThumbnailProducer<EncodedImage>[] thumbnailProducers) { Producer<EncodedImage> localImageProducer = ProducerFactory.newAddImageTransformMetaDataProducer(inputProducer); localImageProducer = mProducerFactory.newResizeAndRotateProducer( localImageProducer, true, mImageTranscoderFactory); ThrottlingProducer<EncodedImage> localImageThrottlingProducer = mProducerFactory.newThrottlingProducer(localImageProducer); return mProducerFactory.newBranchOnSeparateImagesProducer( newLocalThumbnailProducer(thumbnailProducers), localImageThrottlingProducer); }
[ "private", "Producer", "<", "EncodedImage", ">", "newLocalTransformationsSequence", "(", "Producer", "<", "EncodedImage", ">", "inputProducer", ",", "ThumbnailProducer", "<", "EncodedImage", ">", "[", "]", "thumbnailProducers", ")", "{", "Producer", "<", "EncodedImage", ">", "localImageProducer", "=", "ProducerFactory", ".", "newAddImageTransformMetaDataProducer", "(", "inputProducer", ")", ";", "localImageProducer", "=", "mProducerFactory", ".", "newResizeAndRotateProducer", "(", "localImageProducer", ",", "true", ",", "mImageTranscoderFactory", ")", ";", "ThrottlingProducer", "<", "EncodedImage", ">", "localImageThrottlingProducer", "=", "mProducerFactory", ".", "newThrottlingProducer", "(", "localImageProducer", ")", ";", "return", "mProducerFactory", ".", "newBranchOnSeparateImagesProducer", "(", "newLocalThumbnailProducer", "(", "thumbnailProducers", ")", ",", "localImageThrottlingProducer", ")", ";", "}" ]
Branch on separate images -> thumbnail resize and rotate -> thumbnail producers as provided -> local image resize and rotate -> add meta data producer @param inputProducer producer providing the input to add meta data producer @param thumbnailProducers the thumbnail producers from which to request the image before falling back to the full image producer sequence @return local transformations sequence
[ "Branch", "on", "separate", "images", "-", ">", "thumbnail", "resize", "and", "rotate", "-", ">", "thumbnail", "producers", "as", "provided", "-", ">", "local", "image", "resize", "and", "rotate", "-", ">", "add", "meta", "data", "producer" ]
0b85879d51c5036d5e46e627a6651afefc0b971a
https://github.com/facebook/fresco/blob/0b85879d51c5036d5e46e627a6651afefc0b971a/imagepipeline/src/main/java/com/facebook/imagepipeline/core/ProducerSequenceFactory.java#L762-L776
14,420
facebook/fresco
imagepipeline/src/main/java/com/facebook/imagepipeline/core/ProducerSequenceFactory.java
ProducerSequenceFactory.getPostprocessorSequence
private synchronized Producer<CloseableReference<CloseableImage>> getPostprocessorSequence( Producer<CloseableReference<CloseableImage>> inputProducer) { if (!mPostprocessorSequences.containsKey(inputProducer)) { PostprocessorProducer postprocessorProducer = mProducerFactory.newPostprocessorProducer(inputProducer); PostprocessedBitmapMemoryCacheProducer postprocessedBitmapMemoryCacheProducer = mProducerFactory.newPostprocessorBitmapMemoryCacheProducer(postprocessorProducer); mPostprocessorSequences.put(inputProducer, postprocessedBitmapMemoryCacheProducer); } return mPostprocessorSequences.get(inputProducer); }
java
private synchronized Producer<CloseableReference<CloseableImage>> getPostprocessorSequence( Producer<CloseableReference<CloseableImage>> inputProducer) { if (!mPostprocessorSequences.containsKey(inputProducer)) { PostprocessorProducer postprocessorProducer = mProducerFactory.newPostprocessorProducer(inputProducer); PostprocessedBitmapMemoryCacheProducer postprocessedBitmapMemoryCacheProducer = mProducerFactory.newPostprocessorBitmapMemoryCacheProducer(postprocessorProducer); mPostprocessorSequences.put(inputProducer, postprocessedBitmapMemoryCacheProducer); } return mPostprocessorSequences.get(inputProducer); }
[ "private", "synchronized", "Producer", "<", "CloseableReference", "<", "CloseableImage", ">", ">", "getPostprocessorSequence", "(", "Producer", "<", "CloseableReference", "<", "CloseableImage", ">", ">", "inputProducer", ")", "{", "if", "(", "!", "mPostprocessorSequences", ".", "containsKey", "(", "inputProducer", ")", ")", "{", "PostprocessorProducer", "postprocessorProducer", "=", "mProducerFactory", ".", "newPostprocessorProducer", "(", "inputProducer", ")", ";", "PostprocessedBitmapMemoryCacheProducer", "postprocessedBitmapMemoryCacheProducer", "=", "mProducerFactory", ".", "newPostprocessorBitmapMemoryCacheProducer", "(", "postprocessorProducer", ")", ";", "mPostprocessorSequences", ".", "put", "(", "inputProducer", ",", "postprocessedBitmapMemoryCacheProducer", ")", ";", "}", "return", "mPostprocessorSequences", ".", "get", "(", "inputProducer", ")", ";", "}" ]
post-processor producer -> copy producer -> inputProducer
[ "post", "-", "processor", "producer", "-", ">", "copy", "producer", "-", ">", "inputProducer" ]
0b85879d51c5036d5e46e627a6651afefc0b971a
https://github.com/facebook/fresco/blob/0b85879d51c5036d5e46e627a6651afefc0b971a/imagepipeline/src/main/java/com/facebook/imagepipeline/core/ProducerSequenceFactory.java#L789-L799
14,421
facebook/fresco
imagepipeline/src/main/java/com/facebook/imagepipeline/core/ProducerSequenceFactory.java
ProducerSequenceFactory.getDecodedImagePrefetchSequence
private synchronized Producer<Void> getDecodedImagePrefetchSequence( Producer<CloseableReference<CloseableImage>> inputProducer) { if (!mCloseableImagePrefetchSequences.containsKey(inputProducer)) { SwallowResultProducer<CloseableReference<CloseableImage>> swallowResultProducer = mProducerFactory.newSwallowResultProducer(inputProducer); mCloseableImagePrefetchSequences.put(inputProducer, swallowResultProducer); } return mCloseableImagePrefetchSequences.get(inputProducer); }
java
private synchronized Producer<Void> getDecodedImagePrefetchSequence( Producer<CloseableReference<CloseableImage>> inputProducer) { if (!mCloseableImagePrefetchSequences.containsKey(inputProducer)) { SwallowResultProducer<CloseableReference<CloseableImage>> swallowResultProducer = mProducerFactory.newSwallowResultProducer(inputProducer); mCloseableImagePrefetchSequences.put(inputProducer, swallowResultProducer); } return mCloseableImagePrefetchSequences.get(inputProducer); }
[ "private", "synchronized", "Producer", "<", "Void", ">", "getDecodedImagePrefetchSequence", "(", "Producer", "<", "CloseableReference", "<", "CloseableImage", ">", ">", "inputProducer", ")", "{", "if", "(", "!", "mCloseableImagePrefetchSequences", ".", "containsKey", "(", "inputProducer", ")", ")", "{", "SwallowResultProducer", "<", "CloseableReference", "<", "CloseableImage", ">>", "swallowResultProducer", "=", "mProducerFactory", ".", "newSwallowResultProducer", "(", "inputProducer", ")", ";", "mCloseableImagePrefetchSequences", ".", "put", "(", "inputProducer", ",", "swallowResultProducer", ")", ";", "}", "return", "mCloseableImagePrefetchSequences", ".", "get", "(", "inputProducer", ")", ";", "}" ]
swallow result producer -> inputProducer
[ "swallow", "result", "producer", "-", ">", "inputProducer" ]
0b85879d51c5036d5e46e627a6651afefc0b971a
https://github.com/facebook/fresco/blob/0b85879d51c5036d5e46e627a6651afefc0b971a/imagepipeline/src/main/java/com/facebook/imagepipeline/core/ProducerSequenceFactory.java#L804-L812
14,422
facebook/fresco
imagepipeline/src/main/java/com/facebook/imagepipeline/core/ProducerSequenceFactory.java
ProducerSequenceFactory.getBitmapPrepareSequence
private synchronized Producer<CloseableReference<CloseableImage>> getBitmapPrepareSequence( Producer<CloseableReference<CloseableImage>> inputProducer) { Producer<CloseableReference<CloseableImage>> bitmapPrepareProducer = mBitmapPrepareSequences.get(inputProducer); if (bitmapPrepareProducer == null) { bitmapPrepareProducer = mProducerFactory.newBitmapPrepareProducer(inputProducer); mBitmapPrepareSequences.put(inputProducer, bitmapPrepareProducer); } return bitmapPrepareProducer; }
java
private synchronized Producer<CloseableReference<CloseableImage>> getBitmapPrepareSequence( Producer<CloseableReference<CloseableImage>> inputProducer) { Producer<CloseableReference<CloseableImage>> bitmapPrepareProducer = mBitmapPrepareSequences.get(inputProducer); if (bitmapPrepareProducer == null) { bitmapPrepareProducer = mProducerFactory.newBitmapPrepareProducer(inputProducer); mBitmapPrepareSequences.put(inputProducer, bitmapPrepareProducer); } return bitmapPrepareProducer; }
[ "private", "synchronized", "Producer", "<", "CloseableReference", "<", "CloseableImage", ">", ">", "getBitmapPrepareSequence", "(", "Producer", "<", "CloseableReference", "<", "CloseableImage", ">", ">", "inputProducer", ")", "{", "Producer", "<", "CloseableReference", "<", "CloseableImage", ">>", "bitmapPrepareProducer", "=", "mBitmapPrepareSequences", ".", "get", "(", "inputProducer", ")", ";", "if", "(", "bitmapPrepareProducer", "==", "null", ")", "{", "bitmapPrepareProducer", "=", "mProducerFactory", ".", "newBitmapPrepareProducer", "(", "inputProducer", ")", ";", "mBitmapPrepareSequences", ".", "put", "(", "inputProducer", ",", "bitmapPrepareProducer", ")", ";", "}", "return", "bitmapPrepareProducer", ";", "}" ]
bitmap prepare producer -> inputProducer
[ "bitmap", "prepare", "producer", "-", ">", "inputProducer" ]
0b85879d51c5036d5e46e627a6651afefc0b971a
https://github.com/facebook/fresco/blob/0b85879d51c5036d5e46e627a6651afefc0b971a/imagepipeline/src/main/java/com/facebook/imagepipeline/core/ProducerSequenceFactory.java#L817-L828
14,423
facebook/fresco
imagepipeline-base/src/main/java/com/facebook/imageformat/ImageFormatChecker.java
ImageFormatChecker.readHeaderFromStream
private static int readHeaderFromStream( int maxHeaderLength, final InputStream is, final byte[] imageHeaderBytes) throws IOException { Preconditions.checkNotNull(is); Preconditions.checkNotNull(imageHeaderBytes); Preconditions.checkArgument(imageHeaderBytes.length >= maxHeaderLength); // If mark is supported by the stream, use it to let the owner of the stream re-read the same // data. Otherwise, just consume some data. if (is.markSupported()) { try { is.mark(maxHeaderLength); return ByteStreams.read(is, imageHeaderBytes, 0, maxHeaderLength); } finally { is.reset(); } } else { return ByteStreams.read(is, imageHeaderBytes, 0, maxHeaderLength); } }
java
private static int readHeaderFromStream( int maxHeaderLength, final InputStream is, final byte[] imageHeaderBytes) throws IOException { Preconditions.checkNotNull(is); Preconditions.checkNotNull(imageHeaderBytes); Preconditions.checkArgument(imageHeaderBytes.length >= maxHeaderLength); // If mark is supported by the stream, use it to let the owner of the stream re-read the same // data. Otherwise, just consume some data. if (is.markSupported()) { try { is.mark(maxHeaderLength); return ByteStreams.read(is, imageHeaderBytes, 0, maxHeaderLength); } finally { is.reset(); } } else { return ByteStreams.read(is, imageHeaderBytes, 0, maxHeaderLength); } }
[ "private", "static", "int", "readHeaderFromStream", "(", "int", "maxHeaderLength", ",", "final", "InputStream", "is", ",", "final", "byte", "[", "]", "imageHeaderBytes", ")", "throws", "IOException", "{", "Preconditions", ".", "checkNotNull", "(", "is", ")", ";", "Preconditions", ".", "checkNotNull", "(", "imageHeaderBytes", ")", ";", "Preconditions", ".", "checkArgument", "(", "imageHeaderBytes", ".", "length", ">=", "maxHeaderLength", ")", ";", "// If mark is supported by the stream, use it to let the owner of the stream re-read the same", "// data. Otherwise, just consume some data.", "if", "(", "is", ".", "markSupported", "(", ")", ")", "{", "try", "{", "is", ".", "mark", "(", "maxHeaderLength", ")", ";", "return", "ByteStreams", ".", "read", "(", "is", ",", "imageHeaderBytes", ",", "0", ",", "maxHeaderLength", ")", ";", "}", "finally", "{", "is", ".", "reset", "(", ")", ";", "}", "}", "else", "{", "return", "ByteStreams", ".", "read", "(", "is", ",", "imageHeaderBytes", ",", "0", ",", "maxHeaderLength", ")", ";", "}", "}" ]
Reads up to maxHeaderLength bytes from is InputStream. If mark is supported by is, it is used to restore content of the stream after appropriate amount of data is read. Read bytes are stored in imageHeaderBytes, which should be capable of storing maxHeaderLength bytes. @param maxHeaderLength the maximum header length @param is @param imageHeaderBytes @return number of bytes read from is @throws IOException
[ "Reads", "up", "to", "maxHeaderLength", "bytes", "from", "is", "InputStream", ".", "If", "mark", "is", "supported", "by", "is", "it", "is", "used", "to", "restore", "content", "of", "the", "stream", "after", "appropriate", "amount", "of", "data", "is", "read", ".", "Read", "bytes", "are", "stored", "in", "imageHeaderBytes", "which", "should", "be", "capable", "of", "storing", "maxHeaderLength", "bytes", "." ]
0b85879d51c5036d5e46e627a6651afefc0b971a
https://github.com/facebook/fresco/blob/0b85879d51c5036d5e46e627a6651afefc0b971a/imagepipeline-base/src/main/java/com/facebook/imageformat/ImageFormatChecker.java#L85-L106
14,424
facebook/fresco
samples/zoomable/src/main/java/com/facebook/samples/zoomable/DefaultZoomableController.java
DefaultZoomableController.reset
public void reset() { FLog.v(TAG, "reset"); mGestureDetector.reset(); mPreviousTransform.reset(); mActiveTransform.reset(); onTransformChanged(); }
java
public void reset() { FLog.v(TAG, "reset"); mGestureDetector.reset(); mPreviousTransform.reset(); mActiveTransform.reset(); onTransformChanged(); }
[ "public", "void", "reset", "(", ")", "{", "FLog", ".", "v", "(", "TAG", ",", "\"reset\"", ")", ";", "mGestureDetector", ".", "reset", "(", ")", ";", "mPreviousTransform", ".", "reset", "(", ")", ";", "mActiveTransform", ".", "reset", "(", ")", ";", "onTransformChanged", "(", ")", ";", "}" ]
Rests the controller.
[ "Rests", "the", "controller", "." ]
0b85879d51c5036d5e46e627a6651afefc0b971a
https://github.com/facebook/fresco/blob/0b85879d51c5036d5e46e627a6651afefc0b971a/samples/zoomable/src/main/java/com/facebook/samples/zoomable/DefaultZoomableController.java#L98-L104
14,425
facebook/fresco
samples/zoomable/src/main/java/com/facebook/samples/zoomable/DefaultZoomableController.java
DefaultZoomableController.setImageBounds
@Override public void setImageBounds(RectF imageBounds) { if (!imageBounds.equals(mImageBounds)) { mImageBounds.set(imageBounds); onTransformChanged(); if (mImageBoundsListener != null) { mImageBoundsListener.onImageBoundsSet(mImageBounds); } } }
java
@Override public void setImageBounds(RectF imageBounds) { if (!imageBounds.equals(mImageBounds)) { mImageBounds.set(imageBounds); onTransformChanged(); if (mImageBoundsListener != null) { mImageBoundsListener.onImageBoundsSet(mImageBounds); } } }
[ "@", "Override", "public", "void", "setImageBounds", "(", "RectF", "imageBounds", ")", "{", "if", "(", "!", "imageBounds", ".", "equals", "(", "mImageBounds", ")", ")", "{", "mImageBounds", ".", "set", "(", "imageBounds", ")", ";", "onTransformChanged", "(", ")", ";", "if", "(", "mImageBoundsListener", "!=", "null", ")", "{", "mImageBoundsListener", ".", "onImageBoundsSet", "(", "mImageBounds", ")", ";", "}", "}", "}" ]
Sets the image bounds, in view-absolute coordinates.
[ "Sets", "the", "image", "bounds", "in", "view", "-", "absolute", "coordinates", "." ]
0b85879d51c5036d5e46e627a6651afefc0b971a
https://github.com/facebook/fresco/blob/0b85879d51c5036d5e46e627a6651afefc0b971a/samples/zoomable/src/main/java/com/facebook/samples/zoomable/DefaultZoomableController.java#L200-L209
14,426
facebook/fresco
samples/zoomable/src/main/java/com/facebook/samples/zoomable/DefaultZoomableController.java
DefaultZoomableController.getImageRelativeToViewAbsoluteTransform
public void getImageRelativeToViewAbsoluteTransform(Matrix outMatrix) { outMatrix.setRectToRect(IDENTITY_RECT, mTransformedImageBounds, Matrix.ScaleToFit.FILL); }
java
public void getImageRelativeToViewAbsoluteTransform(Matrix outMatrix) { outMatrix.setRectToRect(IDENTITY_RECT, mTransformedImageBounds, Matrix.ScaleToFit.FILL); }
[ "public", "void", "getImageRelativeToViewAbsoluteTransform", "(", "Matrix", "outMatrix", ")", "{", "outMatrix", ".", "setRectToRect", "(", "IDENTITY_RECT", ",", "mTransformedImageBounds", ",", "Matrix", ".", "ScaleToFit", ".", "FILL", ")", ";", "}" ]
Gets the matrix that transforms image-relative coordinates to view-absolute coordinates. The zoomable transformation is taken into account.
[ "Gets", "the", "matrix", "that", "transforms", "image", "-", "relative", "coordinates", "to", "view", "-", "absolute", "coordinates", ".", "The", "zoomable", "transformation", "is", "taken", "into", "account", "." ]
0b85879d51c5036d5e46e627a6651afefc0b971a
https://github.com/facebook/fresco/blob/0b85879d51c5036d5e46e627a6651afefc0b971a/samples/zoomable/src/main/java/com/facebook/samples/zoomable/DefaultZoomableController.java#L276-L278
14,427
facebook/fresco
samples/zoomable/src/main/java/com/facebook/samples/zoomable/DefaultZoomableController.java
DefaultZoomableController.mapViewToImage
public PointF mapViewToImage(PointF viewPoint) { float[] points = mTempValues; points[0] = viewPoint.x; points[1] = viewPoint.y; mActiveTransform.invert(mActiveTransformInverse); mActiveTransformInverse.mapPoints(points, 0, points, 0, 1); mapAbsoluteToRelative(points, points, 1); return new PointF(points[0], points[1]); }
java
public PointF mapViewToImage(PointF viewPoint) { float[] points = mTempValues; points[0] = viewPoint.x; points[1] = viewPoint.y; mActiveTransform.invert(mActiveTransformInverse); mActiveTransformInverse.mapPoints(points, 0, points, 0, 1); mapAbsoluteToRelative(points, points, 1); return new PointF(points[0], points[1]); }
[ "public", "PointF", "mapViewToImage", "(", "PointF", "viewPoint", ")", "{", "float", "[", "]", "points", "=", "mTempValues", ";", "points", "[", "0", "]", "=", "viewPoint", ".", "x", ";", "points", "[", "1", "]", "=", "viewPoint", ".", "y", ";", "mActiveTransform", ".", "invert", "(", "mActiveTransformInverse", ")", ";", "mActiveTransformInverse", ".", "mapPoints", "(", "points", ",", "0", ",", "points", ",", "0", ",", "1", ")", ";", "mapAbsoluteToRelative", "(", "points", ",", "points", ",", "1", ")", ";", "return", "new", "PointF", "(", "points", "[", "0", "]", ",", "points", "[", "1", "]", ")", ";", "}" ]
Maps point from view-absolute to image-relative coordinates. This takes into account the zoomable transformation.
[ "Maps", "point", "from", "view", "-", "absolute", "to", "image", "-", "relative", "coordinates", ".", "This", "takes", "into", "account", "the", "zoomable", "transformation", "." ]
0b85879d51c5036d5e46e627a6651afefc0b971a
https://github.com/facebook/fresco/blob/0b85879d51c5036d5e46e627a6651afefc0b971a/samples/zoomable/src/main/java/com/facebook/samples/zoomable/DefaultZoomableController.java#L284-L292
14,428
facebook/fresco
samples/zoomable/src/main/java/com/facebook/samples/zoomable/DefaultZoomableController.java
DefaultZoomableController.mapImageToView
public PointF mapImageToView(PointF imagePoint) { float[] points = mTempValues; points[0] = imagePoint.x; points[1] = imagePoint.y; mapRelativeToAbsolute(points, points, 1); mActiveTransform.mapPoints(points, 0, points, 0, 1); return new PointF(points[0], points[1]); }
java
public PointF mapImageToView(PointF imagePoint) { float[] points = mTempValues; points[0] = imagePoint.x; points[1] = imagePoint.y; mapRelativeToAbsolute(points, points, 1); mActiveTransform.mapPoints(points, 0, points, 0, 1); return new PointF(points[0], points[1]); }
[ "public", "PointF", "mapImageToView", "(", "PointF", "imagePoint", ")", "{", "float", "[", "]", "points", "=", "mTempValues", ";", "points", "[", "0", "]", "=", "imagePoint", ".", "x", ";", "points", "[", "1", "]", "=", "imagePoint", ".", "y", ";", "mapRelativeToAbsolute", "(", "points", ",", "points", ",", "1", ")", ";", "mActiveTransform", ".", "mapPoints", "(", "points", ",", "0", ",", "points", ",", "0", ",", "1", ")", ";", "return", "new", "PointF", "(", "points", "[", "0", "]", ",", "points", "[", "1", "]", ")", ";", "}" ]
Maps point from image-relative to view-absolute coordinates. This takes into account the zoomable transformation.
[ "Maps", "point", "from", "image", "-", "relative", "to", "view", "-", "absolute", "coordinates", ".", "This", "takes", "into", "account", "the", "zoomable", "transformation", "." ]
0b85879d51c5036d5e46e627a6651afefc0b971a
https://github.com/facebook/fresco/blob/0b85879d51c5036d5e46e627a6651afefc0b971a/samples/zoomable/src/main/java/com/facebook/samples/zoomable/DefaultZoomableController.java#L298-L305
14,429
facebook/fresco
samples/zoomable/src/main/java/com/facebook/samples/zoomable/DefaultZoomableController.java
DefaultZoomableController.setTransform
public void setTransform(Matrix newTransform) { FLog.v(TAG, "setTransform"); mActiveTransform.set(newTransform); onTransformChanged(); }
java
public void setTransform(Matrix newTransform) { FLog.v(TAG, "setTransform"); mActiveTransform.set(newTransform); onTransformChanged(); }
[ "public", "void", "setTransform", "(", "Matrix", "newTransform", ")", "{", "FLog", ".", "v", "(", "TAG", ",", "\"setTransform\"", ")", ";", "mActiveTransform", ".", "set", "(", "newTransform", ")", ";", "onTransformChanged", "(", ")", ";", "}" ]
Sets a new zoom transformation.
[ "Sets", "a", "new", "zoom", "transformation", "." ]
0b85879d51c5036d5e46e627a6651afefc0b971a
https://github.com/facebook/fresco/blob/0b85879d51c5036d5e46e627a6651afefc0b971a/samples/zoomable/src/main/java/com/facebook/samples/zoomable/DefaultZoomableController.java#L385-L389
14,430
facebook/fresco
samples/zoomable/src/main/java/com/facebook/samples/zoomable/DefaultZoomableController.java
DefaultZoomableController.onTouchEvent
@Override public boolean onTouchEvent(MotionEvent event) { FLog.v(TAG, "onTouchEvent: action: ", event.getAction()); if (mIsEnabled && mIsGestureZoomEnabled) { return mGestureDetector.onTouchEvent(event); } return false; }
java
@Override public boolean onTouchEvent(MotionEvent event) { FLog.v(TAG, "onTouchEvent: action: ", event.getAction()); if (mIsEnabled && mIsGestureZoomEnabled) { return mGestureDetector.onTouchEvent(event); } return false; }
[ "@", "Override", "public", "boolean", "onTouchEvent", "(", "MotionEvent", "event", ")", "{", "FLog", ".", "v", "(", "TAG", ",", "\"onTouchEvent: action: \"", ",", "event", ".", "getAction", "(", ")", ")", ";", "if", "(", "mIsEnabled", "&&", "mIsGestureZoomEnabled", ")", "{", "return", "mGestureDetector", ".", "onTouchEvent", "(", "event", ")", ";", "}", "return", "false", ";", "}" ]
Notifies controller of the received touch event.
[ "Notifies", "controller", "of", "the", "received", "touch", "event", "." ]
0b85879d51c5036d5e46e627a6651afefc0b971a
https://github.com/facebook/fresco/blob/0b85879d51c5036d5e46e627a6651afefc0b971a/samples/zoomable/src/main/java/com/facebook/samples/zoomable/DefaultZoomableController.java#L397-L404
14,431
facebook/fresco
samples/zoomable/src/main/java/com/facebook/samples/zoomable/DefaultZoomableController.java
DefaultZoomableController.limit
private float limit(float value, float min, float max) { return Math.min(Math.max(min, value), max); }
java
private float limit(float value, float min, float max) { return Math.min(Math.max(min, value), max); }
[ "private", "float", "limit", "(", "float", "value", ",", "float", "min", ",", "float", "max", ")", "{", "return", "Math", ".", "min", "(", "Math", ".", "max", "(", "min", ",", "value", ")", ",", "max", ")", ";", "}" ]
Limits the value to the given min and max range.
[ "Limits", "the", "value", "to", "the", "given", "min", "and", "max", "range", "." ]
0b85879d51c5036d5e46e627a6651afefc0b971a
https://github.com/facebook/fresco/blob/0b85879d51c5036d5e46e627a6651afefc0b971a/samples/zoomable/src/main/java/com/facebook/samples/zoomable/DefaultZoomableController.java#L593-L595
14,432
facebook/fresco
samples/zoomable/src/main/java/com/facebook/samples/zoomable/DefaultZoomableController.java
DefaultZoomableController.canScrollInAllDirection
private boolean canScrollInAllDirection() { return mTransformedImageBounds.left < mViewBounds.left - EPS && mTransformedImageBounds.top < mViewBounds.top - EPS && mTransformedImageBounds.right > mViewBounds.right + EPS && mTransformedImageBounds.bottom > mViewBounds.bottom + EPS; }
java
private boolean canScrollInAllDirection() { return mTransformedImageBounds.left < mViewBounds.left - EPS && mTransformedImageBounds.top < mViewBounds.top - EPS && mTransformedImageBounds.right > mViewBounds.right + EPS && mTransformedImageBounds.bottom > mViewBounds.bottom + EPS; }
[ "private", "boolean", "canScrollInAllDirection", "(", ")", "{", "return", "mTransformedImageBounds", ".", "left", "<", "mViewBounds", ".", "left", "-", "EPS", "&&", "mTransformedImageBounds", ".", "top", "<", "mViewBounds", ".", "top", "-", "EPS", "&&", "mTransformedImageBounds", ".", "right", ">", "mViewBounds", ".", "right", "+", "EPS", "&&", "mTransformedImageBounds", ".", "bottom", ">", "mViewBounds", ".", "bottom", "+", "EPS", ";", "}" ]
Returns whether the scroll can happen in all directions. I.e. the image is not on any edge.
[ "Returns", "whether", "the", "scroll", "can", "happen", "in", "all", "directions", ".", "I", ".", "e", ".", "the", "image", "is", "not", "on", "any", "edge", "." ]
0b85879d51c5036d5e46e627a6651afefc0b971a
https://github.com/facebook/fresco/blob/0b85879d51c5036d5e46e627a6651afefc0b971a/samples/zoomable/src/main/java/com/facebook/samples/zoomable/DefaultZoomableController.java#L633-L638
14,433
facebook/fresco
samples/scrollperf/src/main/java/com/facebook/samples/scrollperf/util/DraweeUtil.java
DraweeUtil.createDraweeHierarchy
public static GenericDraweeHierarchy createDraweeHierarchy( final Context context, final Config config) { FrescoSystrace.beginSection("DraweeUtil#createDraweeHierarchy"); GenericDraweeHierarchyBuilder builder = new GenericDraweeHierarchyBuilder(context.getResources()) .setFadeDuration(config.fadeDurationMs) .setPlaceholderImage(Const.PLACEHOLDER) .setFailureImage(Const.FAILURE) .setActualImageScaleType(ScalingUtils.ScaleType.FIT_CENTER); applyScaleType(builder, config); if (config.useRoundedCorners || config.drawBorder) { final Resources res = context.getResources(); final RoundingParams roundingParams = new RoundingParams(); if (config.useRoundedCorners) { roundingParams.setRoundingMethod(RoundingParams.RoundingMethod.BITMAP_ONLY); roundingParams.setCornersRadius(res.getDimensionPixelSize(R.dimen.drawee_corner_radius)); roundingParams.setRoundAsCircle(config.useRoundedAsCircle); } if (config.drawBorder) { //noinspection deprecation roundingParams.setBorderColor(res.getColor(R.color.colorPrimary)); roundingParams.setBorderWidth(res.getDimensionPixelSize(R.dimen.drawee_border_width)); } builder.setRoundingParams(roundingParams); } GenericDraweeHierarchy result = builder.build(); FrescoSystrace.endSection(); return result; }
java
public static GenericDraweeHierarchy createDraweeHierarchy( final Context context, final Config config) { FrescoSystrace.beginSection("DraweeUtil#createDraweeHierarchy"); GenericDraweeHierarchyBuilder builder = new GenericDraweeHierarchyBuilder(context.getResources()) .setFadeDuration(config.fadeDurationMs) .setPlaceholderImage(Const.PLACEHOLDER) .setFailureImage(Const.FAILURE) .setActualImageScaleType(ScalingUtils.ScaleType.FIT_CENTER); applyScaleType(builder, config); if (config.useRoundedCorners || config.drawBorder) { final Resources res = context.getResources(); final RoundingParams roundingParams = new RoundingParams(); if (config.useRoundedCorners) { roundingParams.setRoundingMethod(RoundingParams.RoundingMethod.BITMAP_ONLY); roundingParams.setCornersRadius(res.getDimensionPixelSize(R.dimen.drawee_corner_radius)); roundingParams.setRoundAsCircle(config.useRoundedAsCircle); } if (config.drawBorder) { //noinspection deprecation roundingParams.setBorderColor(res.getColor(R.color.colorPrimary)); roundingParams.setBorderWidth(res.getDimensionPixelSize(R.dimen.drawee_border_width)); } builder.setRoundingParams(roundingParams); } GenericDraweeHierarchy result = builder.build(); FrescoSystrace.endSection(); return result; }
[ "public", "static", "GenericDraweeHierarchy", "createDraweeHierarchy", "(", "final", "Context", "context", ",", "final", "Config", "config", ")", "{", "FrescoSystrace", ".", "beginSection", "(", "\"DraweeUtil#createDraweeHierarchy\"", ")", ";", "GenericDraweeHierarchyBuilder", "builder", "=", "new", "GenericDraweeHierarchyBuilder", "(", "context", ".", "getResources", "(", ")", ")", ".", "setFadeDuration", "(", "config", ".", "fadeDurationMs", ")", ".", "setPlaceholderImage", "(", "Const", ".", "PLACEHOLDER", ")", ".", "setFailureImage", "(", "Const", ".", "FAILURE", ")", ".", "setActualImageScaleType", "(", "ScalingUtils", ".", "ScaleType", ".", "FIT_CENTER", ")", ";", "applyScaleType", "(", "builder", ",", "config", ")", ";", "if", "(", "config", ".", "useRoundedCorners", "||", "config", ".", "drawBorder", ")", "{", "final", "Resources", "res", "=", "context", ".", "getResources", "(", ")", ";", "final", "RoundingParams", "roundingParams", "=", "new", "RoundingParams", "(", ")", ";", "if", "(", "config", ".", "useRoundedCorners", ")", "{", "roundingParams", ".", "setRoundingMethod", "(", "RoundingParams", ".", "RoundingMethod", ".", "BITMAP_ONLY", ")", ";", "roundingParams", ".", "setCornersRadius", "(", "res", ".", "getDimensionPixelSize", "(", "R", ".", "dimen", ".", "drawee_corner_radius", ")", ")", ";", "roundingParams", ".", "setRoundAsCircle", "(", "config", ".", "useRoundedAsCircle", ")", ";", "}", "if", "(", "config", ".", "drawBorder", ")", "{", "//noinspection deprecation", "roundingParams", ".", "setBorderColor", "(", "res", ".", "getColor", "(", "R", ".", "color", ".", "colorPrimary", ")", ")", ";", "roundingParams", ".", "setBorderWidth", "(", "res", ".", "getDimensionPixelSize", "(", "R", ".", "dimen", ".", "drawee_border_width", ")", ")", ";", "}", "builder", ".", "setRoundingParams", "(", "roundingParams", ")", ";", "}", "GenericDraweeHierarchy", "result", "=", "builder", ".", "build", "(", ")", ";", "FrescoSystrace", ".", "endSection", "(", ")", ";", "return", "result", ";", "}" ]
Creates the Hierarchy using the information into the Config @param context The Context @param config The Config object @return The Hierarchy to use
[ "Creates", "the", "Hierarchy", "using", "the", "information", "into", "the", "Config" ]
0b85879d51c5036d5e46e627a6651afefc0b971a
https://github.com/facebook/fresco/blob/0b85879d51c5036d5e46e627a6651afefc0b971a/samples/scrollperf/src/main/java/com/facebook/samples/scrollperf/util/DraweeUtil.java#L38-L71
14,434
facebook/fresco
samples/scrollperf/src/main/java/com/facebook/samples/scrollperf/util/DraweeUtil.java
DraweeUtil.setBgColor
public static void setBgColor(View view, final Config config) { int[] colors = view.getContext().getResources().getIntArray(R.array.bg_colors); final int bgColor = colors[config.bgColor]; view.setBackgroundColor(bgColor); }
java
public static void setBgColor(View view, final Config config) { int[] colors = view.getContext().getResources().getIntArray(R.array.bg_colors); final int bgColor = colors[config.bgColor]; view.setBackgroundColor(bgColor); }
[ "public", "static", "void", "setBgColor", "(", "View", "view", ",", "final", "Config", "config", ")", "{", "int", "[", "]", "colors", "=", "view", ".", "getContext", "(", ")", ".", "getResources", "(", ")", ".", "getIntArray", "(", "R", ".", "array", ".", "bg_colors", ")", ";", "final", "int", "bgColor", "=", "colors", "[", "config", ".", "bgColor", "]", ";", "view", ".", "setBackgroundColor", "(", "bgColor", ")", ";", "}" ]
Utility method which set the bgColor based on configuration values @param view The View to change the bgColor to @param config The Config object
[ "Utility", "method", "which", "set", "the", "bgColor", "based", "on", "configuration", "values" ]
0b85879d51c5036d5e46e627a6651afefc0b971a
https://github.com/facebook/fresco/blob/0b85879d51c5036d5e46e627a6651afefc0b971a/samples/scrollperf/src/main/java/com/facebook/samples/scrollperf/util/DraweeUtil.java#L107-L111
14,435
facebook/fresco
imagepipeline/src/main/java/com/facebook/imagepipeline/cache/StagingArea.java
StagingArea.put
public synchronized void put(final CacheKey key, final EncodedImage encodedImage) { Preconditions.checkNotNull(key); Preconditions.checkArgument(EncodedImage.isValid(encodedImage)); // we're making a 'copy' of this reference - so duplicate it final EncodedImage oldEntry = mMap.put(key, EncodedImage.cloneOrNull(encodedImage)); EncodedImage.closeSafely(oldEntry); logStats(); }
java
public synchronized void put(final CacheKey key, final EncodedImage encodedImage) { Preconditions.checkNotNull(key); Preconditions.checkArgument(EncodedImage.isValid(encodedImage)); // we're making a 'copy' of this reference - so duplicate it final EncodedImage oldEntry = mMap.put(key, EncodedImage.cloneOrNull(encodedImage)); EncodedImage.closeSafely(oldEntry); logStats(); }
[ "public", "synchronized", "void", "put", "(", "final", "CacheKey", "key", ",", "final", "EncodedImage", "encodedImage", ")", "{", "Preconditions", ".", "checkNotNull", "(", "key", ")", ";", "Preconditions", ".", "checkArgument", "(", "EncodedImage", ".", "isValid", "(", "encodedImage", ")", ")", ";", "// we're making a 'copy' of this reference - so duplicate it", "final", "EncodedImage", "oldEntry", "=", "mMap", ".", "put", "(", "key", ",", "EncodedImage", ".", "cloneOrNull", "(", "encodedImage", ")", ")", ";", "EncodedImage", ".", "closeSafely", "(", "oldEntry", ")", ";", "logStats", "(", ")", ";", "}" ]
Stores key-value in this StagingArea. This call overrides previous value of stored reference if @param key @param encodedImage EncodedImage to be associated with key
[ "Stores", "key", "-", "value", "in", "this", "StagingArea", ".", "This", "call", "overrides", "previous", "value", "of", "stored", "reference", "if" ]
0b85879d51c5036d5e46e627a6651afefc0b971a
https://github.com/facebook/fresco/blob/0b85879d51c5036d5e46e627a6651afefc0b971a/imagepipeline/src/main/java/com/facebook/imagepipeline/cache/StagingArea.java#L48-L56
14,436
facebook/fresco
imagepipeline/src/main/java/com/facebook/imagepipeline/cache/StagingArea.java
StagingArea.clearAll
public void clearAll() { final List<EncodedImage> old; synchronized (this) { old = new ArrayList<>(mMap.values()); mMap.clear(); } for (int i = 0; i < old.size(); i++) { EncodedImage encodedImage = old.get(i); if (encodedImage != null) { encodedImage.close(); } } }
java
public void clearAll() { final List<EncodedImage> old; synchronized (this) { old = new ArrayList<>(mMap.values()); mMap.clear(); } for (int i = 0; i < old.size(); i++) { EncodedImage encodedImage = old.get(i); if (encodedImage != null) { encodedImage.close(); } } }
[ "public", "void", "clearAll", "(", ")", "{", "final", "List", "<", "EncodedImage", ">", "old", ";", "synchronized", "(", "this", ")", "{", "old", "=", "new", "ArrayList", "<>", "(", "mMap", ".", "values", "(", ")", ")", ";", "mMap", ".", "clear", "(", ")", ";", "}", "for", "(", "int", "i", "=", "0", ";", "i", "<", "old", ".", "size", "(", ")", ";", "i", "++", ")", "{", "EncodedImage", "encodedImage", "=", "old", ".", "get", "(", "i", ")", ";", "if", "(", "encodedImage", "!=", "null", ")", "{", "encodedImage", ".", "close", "(", ")", ";", "}", "}", "}" ]
Removes all items from the StagingArea.
[ "Removes", "all", "items", "from", "the", "StagingArea", "." ]
0b85879d51c5036d5e46e627a6651afefc0b971a
https://github.com/facebook/fresco/blob/0b85879d51c5036d5e46e627a6651afefc0b971a/imagepipeline/src/main/java/com/facebook/imagepipeline/cache/StagingArea.java#L61-L73
14,437
facebook/fresco
imagepipeline/src/main/java/com/facebook/imagepipeline/cache/StagingArea.java
StagingArea.remove
public boolean remove(final CacheKey key) { Preconditions.checkNotNull(key); final EncodedImage encodedImage; synchronized (this) { encodedImage = mMap.remove(key); } if (encodedImage == null) { return false; } try { return encodedImage.isValid(); } finally { encodedImage.close(); } }
java
public boolean remove(final CacheKey key) { Preconditions.checkNotNull(key); final EncodedImage encodedImage; synchronized (this) { encodedImage = mMap.remove(key); } if (encodedImage == null) { return false; } try { return encodedImage.isValid(); } finally { encodedImage.close(); } }
[ "public", "boolean", "remove", "(", "final", "CacheKey", "key", ")", "{", "Preconditions", ".", "checkNotNull", "(", "key", ")", ";", "final", "EncodedImage", "encodedImage", ";", "synchronized", "(", "this", ")", "{", "encodedImage", "=", "mMap", ".", "remove", "(", "key", ")", ";", "}", "if", "(", "encodedImage", "==", "null", ")", "{", "return", "false", ";", "}", "try", "{", "return", "encodedImage", ".", "isValid", "(", ")", ";", "}", "finally", "{", "encodedImage", ".", "close", "(", ")", ";", "}", "}" ]
Removes item from the StagingArea. @param key @return true if item was removed
[ "Removes", "item", "from", "the", "StagingArea", "." ]
0b85879d51c5036d5e46e627a6651afefc0b971a
https://github.com/facebook/fresco/blob/0b85879d51c5036d5e46e627a6651afefc0b971a/imagepipeline/src/main/java/com/facebook/imagepipeline/cache/StagingArea.java#L80-L94
14,438
facebook/fresco
imagepipeline/src/main/java/com/facebook/imagepipeline/cache/StagingArea.java
StagingArea.remove
public synchronized boolean remove(final CacheKey key, final EncodedImage encodedImage) { Preconditions.checkNotNull(key); Preconditions.checkNotNull(encodedImage); Preconditions.checkArgument(EncodedImage.isValid(encodedImage)); final EncodedImage oldValue = mMap.get(key); if (oldValue == null) { return false; } CloseableReference<PooledByteBuffer> oldRef = oldValue.getByteBufferRef(); CloseableReference<PooledByteBuffer> ref = encodedImage.getByteBufferRef(); try { if (oldRef == null || ref == null || oldRef.get() != ref.get()) { return false; } mMap.remove(key); } finally { CloseableReference.closeSafely(ref); CloseableReference.closeSafely(oldRef); EncodedImage.closeSafely(oldValue); } logStats(); return true; }
java
public synchronized boolean remove(final CacheKey key, final EncodedImage encodedImage) { Preconditions.checkNotNull(key); Preconditions.checkNotNull(encodedImage); Preconditions.checkArgument(EncodedImage.isValid(encodedImage)); final EncodedImage oldValue = mMap.get(key); if (oldValue == null) { return false; } CloseableReference<PooledByteBuffer> oldRef = oldValue.getByteBufferRef(); CloseableReference<PooledByteBuffer> ref = encodedImage.getByteBufferRef(); try { if (oldRef == null || ref == null || oldRef.get() != ref.get()) { return false; } mMap.remove(key); } finally { CloseableReference.closeSafely(ref); CloseableReference.closeSafely(oldRef); EncodedImage.closeSafely(oldValue); } logStats(); return true; }
[ "public", "synchronized", "boolean", "remove", "(", "final", "CacheKey", "key", ",", "final", "EncodedImage", "encodedImage", ")", "{", "Preconditions", ".", "checkNotNull", "(", "key", ")", ";", "Preconditions", ".", "checkNotNull", "(", "encodedImage", ")", ";", "Preconditions", ".", "checkArgument", "(", "EncodedImage", ".", "isValid", "(", "encodedImage", ")", ")", ";", "final", "EncodedImage", "oldValue", "=", "mMap", ".", "get", "(", "key", ")", ";", "if", "(", "oldValue", "==", "null", ")", "{", "return", "false", ";", "}", "CloseableReference", "<", "PooledByteBuffer", ">", "oldRef", "=", "oldValue", ".", "getByteBufferRef", "(", ")", ";", "CloseableReference", "<", "PooledByteBuffer", ">", "ref", "=", "encodedImage", ".", "getByteBufferRef", "(", ")", ";", "try", "{", "if", "(", "oldRef", "==", "null", "||", "ref", "==", "null", "||", "oldRef", ".", "get", "(", ")", "!=", "ref", ".", "get", "(", ")", ")", "{", "return", "false", ";", "}", "mMap", ".", "remove", "(", "key", ")", ";", "}", "finally", "{", "CloseableReference", ".", "closeSafely", "(", "ref", ")", ";", "CloseableReference", ".", "closeSafely", "(", "oldRef", ")", ";", "EncodedImage", ".", "closeSafely", "(", "oldValue", ")", ";", "}", "logStats", "(", ")", ";", "return", "true", ";", "}" ]
Removes key-value from the StagingArea. Both key and value must match. @param key @param encodedImage value corresponding to key @return true if item was removed
[ "Removes", "key", "-", "value", "from", "the", "StagingArea", ".", "Both", "key", "and", "value", "must", "match", "." ]
0b85879d51c5036d5e46e627a6651afefc0b971a
https://github.com/facebook/fresco/blob/0b85879d51c5036d5e46e627a6651afefc0b971a/imagepipeline/src/main/java/com/facebook/imagepipeline/cache/StagingArea.java#L102-L128
14,439
facebook/fresco
imagepipeline/src/main/java/com/facebook/imagepipeline/cache/StagingArea.java
StagingArea.containsKey
public synchronized boolean containsKey(CacheKey key) { Preconditions.checkNotNull(key); if (!mMap.containsKey(key)) { return false; } EncodedImage storedEncodedImage = mMap.get(key); synchronized (storedEncodedImage) { if (!EncodedImage.isValid(storedEncodedImage)) { // Reference is not valid, this means that someone cleared reference while it was still in // use. Log error // TODO: 3697790 mMap.remove(key); FLog.w( TAG, "Found closed reference %d for key %s (%d)", System.identityHashCode(storedEncodedImage), key.getUriString(), System.identityHashCode(key)); return false; } return true; } }
java
public synchronized boolean containsKey(CacheKey key) { Preconditions.checkNotNull(key); if (!mMap.containsKey(key)) { return false; } EncodedImage storedEncodedImage = mMap.get(key); synchronized (storedEncodedImage) { if (!EncodedImage.isValid(storedEncodedImage)) { // Reference is not valid, this means that someone cleared reference while it was still in // use. Log error // TODO: 3697790 mMap.remove(key); FLog.w( TAG, "Found closed reference %d for key %s (%d)", System.identityHashCode(storedEncodedImage), key.getUriString(), System.identityHashCode(key)); return false; } return true; } }
[ "public", "synchronized", "boolean", "containsKey", "(", "CacheKey", "key", ")", "{", "Preconditions", ".", "checkNotNull", "(", "key", ")", ";", "if", "(", "!", "mMap", ".", "containsKey", "(", "key", ")", ")", "{", "return", "false", ";", "}", "EncodedImage", "storedEncodedImage", "=", "mMap", ".", "get", "(", "key", ")", ";", "synchronized", "(", "storedEncodedImage", ")", "{", "if", "(", "!", "EncodedImage", ".", "isValid", "(", "storedEncodedImage", ")", ")", "{", "// Reference is not valid, this means that someone cleared reference while it was still in", "// use. Log error", "// TODO: 3697790", "mMap", ".", "remove", "(", "key", ")", ";", "FLog", ".", "w", "(", "TAG", ",", "\"Found closed reference %d for key %s (%d)\"", ",", "System", ".", "identityHashCode", "(", "storedEncodedImage", ")", ",", "key", ".", "getUriString", "(", ")", ",", "System", ".", "identityHashCode", "(", "key", ")", ")", ";", "return", "false", ";", "}", "return", "true", ";", "}", "}" ]
Determine if an valid entry for the key exists in the staging area.
[ "Determine", "if", "an", "valid", "entry", "for", "the", "key", "exists", "in", "the", "staging", "area", "." ]
0b85879d51c5036d5e46e627a6651afefc0b971a
https://github.com/facebook/fresco/blob/0b85879d51c5036d5e46e627a6651afefc0b971a/imagepipeline/src/main/java/com/facebook/imagepipeline/cache/StagingArea.java#L161-L183
14,440
facebook/fresco
samples/comparison/src/main/java/com/facebook/samples/comparison/urlsfetcher/ImageUrlsRequestBuilder.java
ImageUrlsRequestBuilder.addImageFormat
public ImageUrlsRequestBuilder addImageFormat(ImageFormat imageFormat, ImageSize imageSize) { mRequestedImageFormats.put(imageFormat, imageSize); return this; }
java
public ImageUrlsRequestBuilder addImageFormat(ImageFormat imageFormat, ImageSize imageSize) { mRequestedImageFormats.put(imageFormat, imageSize); return this; }
[ "public", "ImageUrlsRequestBuilder", "addImageFormat", "(", "ImageFormat", "imageFormat", ",", "ImageSize", "imageSize", ")", "{", "mRequestedImageFormats", ".", "put", "(", "imageFormat", ",", "imageSize", ")", ";", "return", "this", ";", "}" ]
Adds imageFormat to the set of image formats you want to download. imageSize specify server-side resize options.
[ "Adds", "imageFormat", "to", "the", "set", "of", "image", "formats", "you", "want", "to", "download", ".", "imageSize", "specify", "server", "-", "side", "resize", "options", "." ]
0b85879d51c5036d5e46e627a6651afefc0b971a
https://github.com/facebook/fresco/blob/0b85879d51c5036d5e46e627a6651afefc0b971a/samples/comparison/src/main/java/com/facebook/samples/comparison/urlsfetcher/ImageUrlsRequestBuilder.java#L37-L40
14,441
facebook/fresco
imagepipeline/src/main/java/com/facebook/imagepipeline/producers/LocalFetchProducer.java
LocalFetchProducer.getByteBufferBackedEncodedImage
protected EncodedImage getByteBufferBackedEncodedImage( InputStream inputStream, int length) throws IOException { CloseableReference<PooledByteBuffer> ref = null; try { if (length <= 0) { ref = CloseableReference.of(mPooledByteBufferFactory.newByteBuffer(inputStream)); } else { ref = CloseableReference.of(mPooledByteBufferFactory.newByteBuffer(inputStream, length)); } return new EncodedImage(ref); } finally { Closeables.closeQuietly(inputStream); CloseableReference.closeSafely(ref); } }
java
protected EncodedImage getByteBufferBackedEncodedImage( InputStream inputStream, int length) throws IOException { CloseableReference<PooledByteBuffer> ref = null; try { if (length <= 0) { ref = CloseableReference.of(mPooledByteBufferFactory.newByteBuffer(inputStream)); } else { ref = CloseableReference.of(mPooledByteBufferFactory.newByteBuffer(inputStream, length)); } return new EncodedImage(ref); } finally { Closeables.closeQuietly(inputStream); CloseableReference.closeSafely(ref); } }
[ "protected", "EncodedImage", "getByteBufferBackedEncodedImage", "(", "InputStream", "inputStream", ",", "int", "length", ")", "throws", "IOException", "{", "CloseableReference", "<", "PooledByteBuffer", ">", "ref", "=", "null", ";", "try", "{", "if", "(", "length", "<=", "0", ")", "{", "ref", "=", "CloseableReference", ".", "of", "(", "mPooledByteBufferFactory", ".", "newByteBuffer", "(", "inputStream", ")", ")", ";", "}", "else", "{", "ref", "=", "CloseableReference", ".", "of", "(", "mPooledByteBufferFactory", ".", "newByteBuffer", "(", "inputStream", ",", "length", ")", ")", ";", "}", "return", "new", "EncodedImage", "(", "ref", ")", ";", "}", "finally", "{", "Closeables", ".", "closeQuietly", "(", "inputStream", ")", ";", "CloseableReference", ".", "closeSafely", "(", "ref", ")", ";", "}", "}" ]
Creates a memory-backed encoded image from the stream. The stream is closed.
[ "Creates", "a", "memory", "-", "backed", "encoded", "image", "from", "the", "stream", ".", "The", "stream", "is", "closed", "." ]
0b85879d51c5036d5e46e627a6651afefc0b971a
https://github.com/facebook/fresco/blob/0b85879d51c5036d5e46e627a6651afefc0b971a/imagepipeline/src/main/java/com/facebook/imagepipeline/producers/LocalFetchProducer.java#L77-L92
14,442
facebook/fresco
animated-base/src/main/java/com/facebook/imagepipeline/animated/base/AnimatedImageResult.java
AnimatedImageResult.dispose
public synchronized void dispose() { CloseableReference.closeSafely(mPreviewBitmap); mPreviewBitmap = null; CloseableReference.closeSafely(mDecodedFrames); mDecodedFrames = null; }
java
public synchronized void dispose() { CloseableReference.closeSafely(mPreviewBitmap); mPreviewBitmap = null; CloseableReference.closeSafely(mDecodedFrames); mDecodedFrames = null; }
[ "public", "synchronized", "void", "dispose", "(", ")", "{", "CloseableReference", ".", "closeSafely", "(", "mPreviewBitmap", ")", ";", "mPreviewBitmap", "=", "null", ";", "CloseableReference", ".", "closeSafely", "(", "mDecodedFrames", ")", ";", "mDecodedFrames", "=", "null", ";", "}" ]
Disposes the result, which releases the reference to any bitmaps.
[ "Disposes", "the", "result", "which", "releases", "the", "reference", "to", "any", "bitmaps", "." ]
0b85879d51c5036d5e46e627a6651afefc0b971a
https://github.com/facebook/fresco/blob/0b85879d51c5036d5e46e627a6651afefc0b971a/animated-base/src/main/java/com/facebook/imagepipeline/animated/base/AnimatedImageResult.java#L118-L123
14,443
facebook/fresco
fbcore/src/main/java/com/facebook/common/internal/ImmutableMap.java
ImmutableMap.copyOf
public static <K, V> ImmutableMap<K, V> copyOf(Map<? extends K, ? extends V> map) { return new ImmutableMap<>(map); }
java
public static <K, V> ImmutableMap<K, V> copyOf(Map<? extends K, ? extends V> map) { return new ImmutableMap<>(map); }
[ "public", "static", "<", "K", ",", "V", ">", "ImmutableMap", "<", "K", ",", "V", ">", "copyOf", "(", "Map", "<", "?", "extends", "K", ",", "?", "extends", "V", ">", "map", ")", "{", "return", "new", "ImmutableMap", "<>", "(", "map", ")", ";", "}" ]
Dummy method at the moment to help us enforce types.
[ "Dummy", "method", "at", "the", "moment", "to", "help", "us", "enforce", "types", "." ]
0b85879d51c5036d5e46e627a6651afefc0b971a
https://github.com/facebook/fresco/blob/0b85879d51c5036d5e46e627a6651afefc0b971a/fbcore/src/main/java/com/facebook/common/internal/ImmutableMap.java#L88-L90
14,444
facebook/fresco
imagepipeline/src/main/java/com/facebook/imagepipeline/producers/LocalExifThumbnailProducer.java
LocalExifThumbnailProducer.getRotationAngle
private int getRotationAngle(final ExifInterface exifInterface) { return JfifUtil.getAutoRotateAngleFromOrientation( Integer.parseInt(exifInterface.getAttribute(ExifInterface.TAG_ORIENTATION))); }
java
private int getRotationAngle(final ExifInterface exifInterface) { return JfifUtil.getAutoRotateAngleFromOrientation( Integer.parseInt(exifInterface.getAttribute(ExifInterface.TAG_ORIENTATION))); }
[ "private", "int", "getRotationAngle", "(", "final", "ExifInterface", "exifInterface", ")", "{", "return", "JfifUtil", ".", "getAutoRotateAngleFromOrientation", "(", "Integer", ".", "parseInt", "(", "exifInterface", ".", "getAttribute", "(", "ExifInterface", ".", "TAG_ORIENTATION", ")", ")", ")", ";", "}" ]
Gets the correction angle based on the image's orientation
[ "Gets", "the", "correction", "angle", "based", "on", "the", "image", "s", "orientation" ]
0b85879d51c5036d5e46e627a6651afefc0b971a
https://github.com/facebook/fresco/blob/0b85879d51c5036d5e46e627a6651afefc0b971a/imagepipeline/src/main/java/com/facebook/imagepipeline/producers/LocalExifThumbnailProducer.java#L162-L165
14,445
facebook/fresco
drawee/src/main/java/com/facebook/drawee/drawable/DrawableUtils.java
DrawableUtils.multiplyColorAlpha
public static int multiplyColorAlpha(int color, int alpha) { if (alpha == 255) { return color; } if (alpha == 0) { return color & 0x00FFFFFF; } alpha = alpha + (alpha >> 7); // make it 0..256 int colorAlpha = color >>> 24; int multipliedAlpha = colorAlpha * alpha >> 8; return (multipliedAlpha << 24) | (color & 0x00FFFFFF); }
java
public static int multiplyColorAlpha(int color, int alpha) { if (alpha == 255) { return color; } if (alpha == 0) { return color & 0x00FFFFFF; } alpha = alpha + (alpha >> 7); // make it 0..256 int colorAlpha = color >>> 24; int multipliedAlpha = colorAlpha * alpha >> 8; return (multipliedAlpha << 24) | (color & 0x00FFFFFF); }
[ "public", "static", "int", "multiplyColorAlpha", "(", "int", "color", ",", "int", "alpha", ")", "{", "if", "(", "alpha", "==", "255", ")", "{", "return", "color", ";", "}", "if", "(", "alpha", "==", "0", ")", "{", "return", "color", "&", "0x00FFFFFF", ";", "}", "alpha", "=", "alpha", "+", "(", "alpha", ">>", "7", ")", ";", "// make it 0..256", "int", "colorAlpha", "=", "color", ">>>", "24", ";", "int", "multipliedAlpha", "=", "colorAlpha", "*", "alpha", ">>", "8", ";", "return", "(", "multipliedAlpha", "<<", "24", ")", "|", "(", "color", "&", "0x00FFFFFF", ")", ";", "}" ]
Multiplies the color with the given alpha. @param color color to be multiplied @param alpha value between 0 and 255 @return multiplied color
[ "Multiplies", "the", "color", "with", "the", "given", "alpha", "." ]
0b85879d51c5036d5e46e627a6651afefc0b971a
https://github.com/facebook/fresco/blob/0b85879d51c5036d5e46e627a6651afefc0b971a/drawee/src/main/java/com/facebook/drawee/drawable/DrawableUtils.java#L90-L101
14,446
facebook/fresco
drawee/src/main/java/com/facebook/drawee/drawable/DrawableUtils.java
DrawableUtils.getOpacityFromColor
public static int getOpacityFromColor(int color) { int colorAlpha = color >>> 24; if (colorAlpha == 255) { return PixelFormat.OPAQUE; } else if (colorAlpha == 0) { return PixelFormat.TRANSPARENT; } else { return PixelFormat.TRANSLUCENT; } }
java
public static int getOpacityFromColor(int color) { int colorAlpha = color >>> 24; if (colorAlpha == 255) { return PixelFormat.OPAQUE; } else if (colorAlpha == 0) { return PixelFormat.TRANSPARENT; } else { return PixelFormat.TRANSLUCENT; } }
[ "public", "static", "int", "getOpacityFromColor", "(", "int", "color", ")", "{", "int", "colorAlpha", "=", "color", ">>>", "24", ";", "if", "(", "colorAlpha", "==", "255", ")", "{", "return", "PixelFormat", ".", "OPAQUE", ";", "}", "else", "if", "(", "colorAlpha", "==", "0", ")", "{", "return", "PixelFormat", ".", "TRANSPARENT", ";", "}", "else", "{", "return", "PixelFormat", ".", "TRANSLUCENT", ";", "}", "}" ]
Gets the opacity from a color. Inspired by Android ColorDrawable. @param color @return opacity expressed by one of PixelFormat constants
[ "Gets", "the", "opacity", "from", "a", "color", ".", "Inspired", "by", "Android", "ColorDrawable", "." ]
0b85879d51c5036d5e46e627a6651afefc0b971a
https://github.com/facebook/fresco/blob/0b85879d51c5036d5e46e627a6651afefc0b971a/drawee/src/main/java/com/facebook/drawee/drawable/DrawableUtils.java#L108-L117
14,447
facebook/fresco
imagepipeline/src/main/java/com/facebook/imagepipeline/platform/PlatformDecoderFactory.java
PlatformDecoderFactory.buildPlatformDecoder
public static PlatformDecoder buildPlatformDecoder( PoolFactory poolFactory, boolean gingerbreadDecoderEnabled) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { int maxNumThreads = poolFactory.getFlexByteArrayPoolMaxNumThreads(); return new OreoDecoder( poolFactory.getBitmapPool(), maxNumThreads, new Pools.SynchronizedPool<>(maxNumThreads)); } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { int maxNumThreads = poolFactory.getFlexByteArrayPoolMaxNumThreads(); return new ArtDecoder( poolFactory.getBitmapPool(), maxNumThreads, new Pools.SynchronizedPool<>(maxNumThreads)); } else { if (gingerbreadDecoderEnabled && Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) { return new GingerbreadPurgeableDecoder(); } else { return new KitKatPurgeableDecoder(poolFactory.getFlexByteArrayPool()); } } }
java
public static PlatformDecoder buildPlatformDecoder( PoolFactory poolFactory, boolean gingerbreadDecoderEnabled) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { int maxNumThreads = poolFactory.getFlexByteArrayPoolMaxNumThreads(); return new OreoDecoder( poolFactory.getBitmapPool(), maxNumThreads, new Pools.SynchronizedPool<>(maxNumThreads)); } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { int maxNumThreads = poolFactory.getFlexByteArrayPoolMaxNumThreads(); return new ArtDecoder( poolFactory.getBitmapPool(), maxNumThreads, new Pools.SynchronizedPool<>(maxNumThreads)); } else { if (gingerbreadDecoderEnabled && Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) { return new GingerbreadPurgeableDecoder(); } else { return new KitKatPurgeableDecoder(poolFactory.getFlexByteArrayPool()); } } }
[ "public", "static", "PlatformDecoder", "buildPlatformDecoder", "(", "PoolFactory", "poolFactory", ",", "boolean", "gingerbreadDecoderEnabled", ")", "{", "if", "(", "Build", ".", "VERSION", ".", "SDK_INT", ">=", "Build", ".", "VERSION_CODES", ".", "O", ")", "{", "int", "maxNumThreads", "=", "poolFactory", ".", "getFlexByteArrayPoolMaxNumThreads", "(", ")", ";", "return", "new", "OreoDecoder", "(", "poolFactory", ".", "getBitmapPool", "(", ")", ",", "maxNumThreads", ",", "new", "Pools", ".", "SynchronizedPool", "<>", "(", "maxNumThreads", ")", ")", ";", "}", "else", "if", "(", "Build", ".", "VERSION", ".", "SDK_INT", ">=", "Build", ".", "VERSION_CODES", ".", "LOLLIPOP", ")", "{", "int", "maxNumThreads", "=", "poolFactory", ".", "getFlexByteArrayPoolMaxNumThreads", "(", ")", ";", "return", "new", "ArtDecoder", "(", "poolFactory", ".", "getBitmapPool", "(", ")", ",", "maxNumThreads", ",", "new", "Pools", ".", "SynchronizedPool", "<>", "(", "maxNumThreads", ")", ")", ";", "}", "else", "{", "if", "(", "gingerbreadDecoderEnabled", "&&", "Build", ".", "VERSION", ".", "SDK_INT", "<", "Build", ".", "VERSION_CODES", ".", "KITKAT", ")", "{", "return", "new", "GingerbreadPurgeableDecoder", "(", ")", ";", "}", "else", "{", "return", "new", "KitKatPurgeableDecoder", "(", "poolFactory", ".", "getFlexByteArrayPool", "(", ")", ")", ";", "}", "}", "}" ]
Provide the implementation of the PlatformDecoder for the current platform using the provided PoolFactory @param poolFactory The PoolFactory @return The PlatformDecoder implementation
[ "Provide", "the", "implementation", "of", "the", "PlatformDecoder", "for", "the", "current", "platform", "using", "the", "provided", "PoolFactory" ]
0b85879d51c5036d5e46e627a6651afefc0b971a
https://github.com/facebook/fresco/blob/0b85879d51c5036d5e46e627a6651afefc0b971a/imagepipeline/src/main/java/com/facebook/imagepipeline/platform/PlatformDecoderFactory.java#L25-L42
14,448
facebook/fresco
samples/showcase/src/main/java/com/facebook/fresco/samples/showcase/MainActivity.java
MainActivity.showFragment
private void showFragment(ShowcaseFragment fragment) { final FragmentTransaction fragmentTransaction = getSupportFragmentManager() .beginTransaction() .replace(R.id.content_main, (Fragment) fragment); if (fragment.getBackstackTag() != null) { fragmentTransaction.addToBackStack(fragment.getBackstackTag()); } fragmentTransaction.commit(); setTitle(fragment.getTitleId()); }
java
private void showFragment(ShowcaseFragment fragment) { final FragmentTransaction fragmentTransaction = getSupportFragmentManager() .beginTransaction() .replace(R.id.content_main, (Fragment) fragment); if (fragment.getBackstackTag() != null) { fragmentTransaction.addToBackStack(fragment.getBackstackTag()); } fragmentTransaction.commit(); setTitle(fragment.getTitleId()); }
[ "private", "void", "showFragment", "(", "ShowcaseFragment", "fragment", ")", "{", "final", "FragmentTransaction", "fragmentTransaction", "=", "getSupportFragmentManager", "(", ")", ".", "beginTransaction", "(", ")", ".", "replace", "(", "R", ".", "id", ".", "content_main", ",", "(", "Fragment", ")", "fragment", ")", ";", "if", "(", "fragment", ".", "getBackstackTag", "(", ")", "!=", "null", ")", "{", "fragmentTransaction", ".", "addToBackStack", "(", "fragment", ".", "getBackstackTag", "(", ")", ")", ";", "}", "fragmentTransaction", ".", "commit", "(", ")", ";", "setTitle", "(", "fragment", ".", "getTitleId", "(", ")", ")", ";", "}" ]
Utility method to display a specific Fragment. If the tag is not null we add a backstack @param fragment The Fragment to add
[ "Utility", "method", "to", "display", "a", "specific", "Fragment", ".", "If", "the", "tag", "is", "not", "null", "we", "add", "a", "backstack" ]
0b85879d51c5036d5e46e627a6651afefc0b971a
https://github.com/facebook/fresco/blob/0b85879d51c5036d5e46e627a6651afefc0b971a/samples/showcase/src/main/java/com/facebook/fresco/samples/showcase/MainActivity.java#L273-L283
14,449
facebook/fresco
static-webp/src/main/java/com/facebook/imagepipeline/nativecode/WebpTranscoderImpl.java
WebpTranscoderImpl.transcodeWebpToJpeg
@Override public void transcodeWebpToJpeg( InputStream inputStream, OutputStream outputStream, int quality) throws IOException { StaticWebpNativeLoader.ensure(); nativeTranscodeWebpToJpeg( Preconditions.checkNotNull(inputStream), Preconditions.checkNotNull(outputStream), quality); }
java
@Override public void transcodeWebpToJpeg( InputStream inputStream, OutputStream outputStream, int quality) throws IOException { StaticWebpNativeLoader.ensure(); nativeTranscodeWebpToJpeg( Preconditions.checkNotNull(inputStream), Preconditions.checkNotNull(outputStream), quality); }
[ "@", "Override", "public", "void", "transcodeWebpToJpeg", "(", "InputStream", "inputStream", ",", "OutputStream", "outputStream", ",", "int", "quality", ")", "throws", "IOException", "{", "StaticWebpNativeLoader", ".", "ensure", "(", ")", ";", "nativeTranscodeWebpToJpeg", "(", "Preconditions", ".", "checkNotNull", "(", "inputStream", ")", ",", "Preconditions", ".", "checkNotNull", "(", "outputStream", ")", ",", "quality", ")", ";", "}" ]
Transcodes webp image given by input stream into jpeg.
[ "Transcodes", "webp", "image", "given", "by", "input", "stream", "into", "jpeg", "." ]
0b85879d51c5036d5e46e627a6651afefc0b971a
https://github.com/facebook/fresco/blob/0b85879d51c5036d5e46e627a6651afefc0b971a/static-webp/src/main/java/com/facebook/imagepipeline/nativecode/WebpTranscoderImpl.java#L47-L57
14,450
facebook/fresco
static-webp/src/main/java/com/facebook/imagepipeline/nativecode/WebpTranscoderImpl.java
WebpTranscoderImpl.transcodeWebpToPng
@Override public void transcodeWebpToPng( InputStream inputStream, OutputStream outputStream) throws IOException { StaticWebpNativeLoader.ensure(); nativeTranscodeWebpToPng( Preconditions.checkNotNull(inputStream), Preconditions.checkNotNull(outputStream)); }
java
@Override public void transcodeWebpToPng( InputStream inputStream, OutputStream outputStream) throws IOException { StaticWebpNativeLoader.ensure(); nativeTranscodeWebpToPng( Preconditions.checkNotNull(inputStream), Preconditions.checkNotNull(outputStream)); }
[ "@", "Override", "public", "void", "transcodeWebpToPng", "(", "InputStream", "inputStream", ",", "OutputStream", "outputStream", ")", "throws", "IOException", "{", "StaticWebpNativeLoader", ".", "ensure", "(", ")", ";", "nativeTranscodeWebpToPng", "(", "Preconditions", ".", "checkNotNull", "(", "inputStream", ")", ",", "Preconditions", ".", "checkNotNull", "(", "outputStream", ")", ")", ";", "}" ]
Transcodes Webp image given by input stream into png.
[ "Transcodes", "Webp", "image", "given", "by", "input", "stream", "into", "png", "." ]
0b85879d51c5036d5e46e627a6651afefc0b971a
https://github.com/facebook/fresco/blob/0b85879d51c5036d5e46e627a6651afefc0b971a/static-webp/src/main/java/com/facebook/imagepipeline/nativecode/WebpTranscoderImpl.java#L62-L70
14,451
facebook/fresco
fbcore/src/main/java/com/facebook/common/executors/ConstrainedExecutorService.java
ConstrainedExecutorService.execute
@Override public void execute(Runnable runnable) { if (runnable == null) { throw new NullPointerException("runnable parameter is null"); } if (!mWorkQueue.offer(runnable)) { throw new RejectedExecutionException( mName + " queue is full, size=" + mWorkQueue.size()); } final int queueSize = mWorkQueue.size(); final int maxSize = mMaxQueueSize.get(); if ((queueSize > maxSize) && mMaxQueueSize.compareAndSet(maxSize, queueSize)) { FLog.v(TAG, "%s: max pending work in queue = %d", mName, queueSize); } // else, there was a race and another thread updated and logged the max queue size startWorkerIfNeeded(); }
java
@Override public void execute(Runnable runnable) { if (runnable == null) { throw new NullPointerException("runnable parameter is null"); } if (!mWorkQueue.offer(runnable)) { throw new RejectedExecutionException( mName + " queue is full, size=" + mWorkQueue.size()); } final int queueSize = mWorkQueue.size(); final int maxSize = mMaxQueueSize.get(); if ((queueSize > maxSize) && mMaxQueueSize.compareAndSet(maxSize, queueSize)) { FLog.v(TAG, "%s: max pending work in queue = %d", mName, queueSize); } // else, there was a race and another thread updated and logged the max queue size startWorkerIfNeeded(); }
[ "@", "Override", "public", "void", "execute", "(", "Runnable", "runnable", ")", "{", "if", "(", "runnable", "==", "null", ")", "{", "throw", "new", "NullPointerException", "(", "\"runnable parameter is null\"", ")", ";", "}", "if", "(", "!", "mWorkQueue", ".", "offer", "(", "runnable", ")", ")", "{", "throw", "new", "RejectedExecutionException", "(", "mName", "+", "\" queue is full, size=\"", "+", "mWorkQueue", ".", "size", "(", ")", ")", ";", "}", "final", "int", "queueSize", "=", "mWorkQueue", ".", "size", "(", ")", ";", "final", "int", "maxSize", "=", "mMaxQueueSize", ".", "get", "(", ")", ";", "if", "(", "(", "queueSize", ">", "maxSize", ")", "&&", "mMaxQueueSize", ".", "compareAndSet", "(", "maxSize", ",", "queueSize", ")", ")", "{", "FLog", ".", "v", "(", "TAG", ",", "\"%s: max pending work in queue = %d\"", ",", "mName", ",", "queueSize", ")", ";", "}", "// else, there was a race and another thread updated and logged the max queue size", "startWorkerIfNeeded", "(", ")", ";", "}" ]
Submit a task to be executed in the future. @param runnable The task to be executed.
[ "Submit", "a", "task", "to", "be", "executed", "in", "the", "future", "." ]
0b85879d51c5036d5e46e627a6651afefc0b971a
https://github.com/facebook/fresco/blob/0b85879d51c5036d5e46e627a6651afefc0b971a/fbcore/src/main/java/com/facebook/common/executors/ConstrainedExecutorService.java#L95-L113
14,452
facebook/fresco
imagepipeline/src/main/java/com/facebook/imagepipeline/producers/ThumbnailSizeChecker.java
ThumbnailSizeChecker.isImageBigEnough
public static boolean isImageBigEnough(int width, int height, ResizeOptions resizeOptions) { if (resizeOptions == null) { return getAcceptableSize(width) >= BitmapUtil.MAX_BITMAP_SIZE && getAcceptableSize(height) >= (int) BitmapUtil.MAX_BITMAP_SIZE; } else { return getAcceptableSize(width) >= resizeOptions.width && getAcceptableSize(height) >= resizeOptions.height; } }
java
public static boolean isImageBigEnough(int width, int height, ResizeOptions resizeOptions) { if (resizeOptions == null) { return getAcceptableSize(width) >= BitmapUtil.MAX_BITMAP_SIZE && getAcceptableSize(height) >= (int) BitmapUtil.MAX_BITMAP_SIZE; } else { return getAcceptableSize(width) >= resizeOptions.width && getAcceptableSize(height) >= resizeOptions.height; } }
[ "public", "static", "boolean", "isImageBigEnough", "(", "int", "width", ",", "int", "height", ",", "ResizeOptions", "resizeOptions", ")", "{", "if", "(", "resizeOptions", "==", "null", ")", "{", "return", "getAcceptableSize", "(", "width", ")", ">=", "BitmapUtil", ".", "MAX_BITMAP_SIZE", "&&", "getAcceptableSize", "(", "height", ")", ">=", "(", "int", ")", "BitmapUtil", ".", "MAX_BITMAP_SIZE", ";", "}", "else", "{", "return", "getAcceptableSize", "(", "width", ")", ">=", "resizeOptions", ".", "width", "&&", "getAcceptableSize", "(", "height", ")", ">=", "resizeOptions", ".", "height", ";", "}", "}" ]
Checks whether the producer may be able to produce images of the specified size. This makes no promise about being able to produce images for a particular source, only generally being able to produce output of the desired resolution. @param width the desired width @param height the desired height @return true if the producer can meet these needs
[ "Checks", "whether", "the", "producer", "may", "be", "able", "to", "produce", "images", "of", "the", "specified", "size", ".", "This", "makes", "no", "promise", "about", "being", "able", "to", "produce", "images", "for", "a", "particular", "source", "only", "generally", "being", "able", "to", "produce", "output", "of", "the", "desired", "resolution", "." ]
0b85879d51c5036d5e46e627a6651afefc0b971a
https://github.com/facebook/fresco/blob/0b85879d51c5036d5e46e627a6651afefc0b971a/imagepipeline/src/main/java/com/facebook/imagepipeline/producers/ThumbnailSizeChecker.java#L39-L47
14,453
facebook/fresco
drawee/src/main/java/com/facebook/drawee/controller/AbstractDraweeControllerBuilder.java
AbstractDraweeControllerBuilder.init
private void init() { mCallerContext = null; mImageRequest = null; mLowResImageRequest = null; mMultiImageRequests = null; mTryCacheOnlyFirst = true; mControllerListener = null; mControllerViewportVisibilityListener = null; mTapToRetryEnabled = false; mAutoPlayAnimations = false; mOldController = null; mContentDescription = null; }
java
private void init() { mCallerContext = null; mImageRequest = null; mLowResImageRequest = null; mMultiImageRequests = null; mTryCacheOnlyFirst = true; mControllerListener = null; mControllerViewportVisibilityListener = null; mTapToRetryEnabled = false; mAutoPlayAnimations = false; mOldController = null; mContentDescription = null; }
[ "private", "void", "init", "(", ")", "{", "mCallerContext", "=", "null", ";", "mImageRequest", "=", "null", ";", "mLowResImageRequest", "=", "null", ";", "mMultiImageRequests", "=", "null", ";", "mTryCacheOnlyFirst", "=", "true", ";", "mControllerListener", "=", "null", ";", "mControllerViewportVisibilityListener", "=", "null", ";", "mTapToRetryEnabled", "=", "false", ";", "mAutoPlayAnimations", "=", "false", ";", "mOldController", "=", "null", ";", "mContentDescription", "=", "null", ";", "}" ]
Initializes this builder.
[ "Initializes", "this", "builder", "." ]
0b85879d51c5036d5e46e627a6651afefc0b971a
https://github.com/facebook/fresco/blob/0b85879d51c5036d5e46e627a6651afefc0b971a/drawee/src/main/java/com/facebook/drawee/controller/AbstractDraweeControllerBuilder.java#L84-L96
14,454
facebook/fresco
drawee/src/main/java/com/facebook/drawee/controller/AbstractDraweeControllerBuilder.java
AbstractDraweeControllerBuilder.build
@Override public AbstractDraweeController build() { validate(); // if only a low-res request is specified, treat it as a final request. if (mImageRequest == null && mMultiImageRequests == null && mLowResImageRequest != null) { mImageRequest = mLowResImageRequest; mLowResImageRequest = null; } return buildController(); }
java
@Override public AbstractDraweeController build() { validate(); // if only a low-res request is specified, treat it as a final request. if (mImageRequest == null && mMultiImageRequests == null && mLowResImageRequest != null) { mImageRequest = mLowResImageRequest; mLowResImageRequest = null; } return buildController(); }
[ "@", "Override", "public", "AbstractDraweeController", "build", "(", ")", "{", "validate", "(", ")", ";", "// if only a low-res request is specified, treat it as a final request.", "if", "(", "mImageRequest", "==", "null", "&&", "mMultiImageRequests", "==", "null", "&&", "mLowResImageRequest", "!=", "null", ")", "{", "mImageRequest", "=", "mLowResImageRequest", ";", "mLowResImageRequest", "=", "null", ";", "}", "return", "buildController", "(", ")", ";", "}" ]
Builds the specified controller.
[ "Builds", "the", "specified", "controller", "." ]
0b85879d51c5036d5e46e627a6651afefc0b971a
https://github.com/facebook/fresco/blob/0b85879d51c5036d5e46e627a6651afefc0b971a/drawee/src/main/java/com/facebook/drawee/controller/AbstractDraweeControllerBuilder.java#L285-L296
14,455
facebook/fresco
drawee/src/main/java/com/facebook/drawee/controller/AbstractDraweeControllerBuilder.java
AbstractDraweeControllerBuilder.validate
protected void validate() { Preconditions.checkState( (mMultiImageRequests == null) || (mImageRequest == null), "Cannot specify both ImageRequest and FirstAvailableImageRequests!"); Preconditions.checkState( (mDataSourceSupplier == null) || (mMultiImageRequests == null && mImageRequest == null && mLowResImageRequest == null), "Cannot specify DataSourceSupplier with other ImageRequests! Use one or the other."); }
java
protected void validate() { Preconditions.checkState( (mMultiImageRequests == null) || (mImageRequest == null), "Cannot specify both ImageRequest and FirstAvailableImageRequests!"); Preconditions.checkState( (mDataSourceSupplier == null) || (mMultiImageRequests == null && mImageRequest == null && mLowResImageRequest == null), "Cannot specify DataSourceSupplier with other ImageRequests! Use one or the other."); }
[ "protected", "void", "validate", "(", ")", "{", "Preconditions", ".", "checkState", "(", "(", "mMultiImageRequests", "==", "null", ")", "||", "(", "mImageRequest", "==", "null", ")", ",", "\"Cannot specify both ImageRequest and FirstAvailableImageRequests!\"", ")", ";", "Preconditions", ".", "checkState", "(", "(", "mDataSourceSupplier", "==", "null", ")", "||", "(", "mMultiImageRequests", "==", "null", "&&", "mImageRequest", "==", "null", "&&", "mLowResImageRequest", "==", "null", ")", ",", "\"Cannot specify DataSourceSupplier with other ImageRequests! Use one or the other.\"", ")", ";", "}" ]
Validates the parameters before building a controller.
[ "Validates", "the", "parameters", "before", "building", "a", "controller", "." ]
0b85879d51c5036d5e46e627a6651afefc0b971a
https://github.com/facebook/fresco/blob/0b85879d51c5036d5e46e627a6651afefc0b971a/drawee/src/main/java/com/facebook/drawee/controller/AbstractDraweeControllerBuilder.java#L299-L307
14,456
facebook/fresco
drawee/src/main/java/com/facebook/drawee/controller/AbstractDraweeControllerBuilder.java
AbstractDraweeControllerBuilder.buildController
protected AbstractDraweeController buildController() { if (FrescoSystrace.isTracing()) { FrescoSystrace.beginSection("AbstractDraweeControllerBuilder#buildController"); } AbstractDraweeController controller = obtainController(); controller.setRetainImageOnFailure(getRetainImageOnFailure()); controller.setContentDescription(getContentDescription()); controller.setControllerViewportVisibilityListener(getControllerViewportVisibilityListener()); maybeBuildAndSetRetryManager(controller); maybeAttachListeners(controller); if (FrescoSystrace.isTracing()) { FrescoSystrace.endSection(); } return controller; }
java
protected AbstractDraweeController buildController() { if (FrescoSystrace.isTracing()) { FrescoSystrace.beginSection("AbstractDraweeControllerBuilder#buildController"); } AbstractDraweeController controller = obtainController(); controller.setRetainImageOnFailure(getRetainImageOnFailure()); controller.setContentDescription(getContentDescription()); controller.setControllerViewportVisibilityListener(getControllerViewportVisibilityListener()); maybeBuildAndSetRetryManager(controller); maybeAttachListeners(controller); if (FrescoSystrace.isTracing()) { FrescoSystrace.endSection(); } return controller; }
[ "protected", "AbstractDraweeController", "buildController", "(", ")", "{", "if", "(", "FrescoSystrace", ".", "isTracing", "(", ")", ")", "{", "FrescoSystrace", ".", "beginSection", "(", "\"AbstractDraweeControllerBuilder#buildController\"", ")", ";", "}", "AbstractDraweeController", "controller", "=", "obtainController", "(", ")", ";", "controller", ".", "setRetainImageOnFailure", "(", "getRetainImageOnFailure", "(", ")", ")", ";", "controller", ".", "setContentDescription", "(", "getContentDescription", "(", ")", ")", ";", "controller", ".", "setControllerViewportVisibilityListener", "(", "getControllerViewportVisibilityListener", "(", ")", ")", ";", "maybeBuildAndSetRetryManager", "(", "controller", ")", ";", "maybeAttachListeners", "(", "controller", ")", ";", "if", "(", "FrescoSystrace", ".", "isTracing", "(", ")", ")", "{", "FrescoSystrace", ".", "endSection", "(", ")", ";", "}", "return", "controller", ";", "}" ]
Builds a regular controller.
[ "Builds", "a", "regular", "controller", "." ]
0b85879d51c5036d5e46e627a6651afefc0b971a
https://github.com/facebook/fresco/blob/0b85879d51c5036d5e46e627a6651afefc0b971a/drawee/src/main/java/com/facebook/drawee/controller/AbstractDraweeControllerBuilder.java#L310-L324
14,457
facebook/fresco
drawee/src/main/java/com/facebook/drawee/controller/AbstractDraweeControllerBuilder.java
AbstractDraweeControllerBuilder.obtainDataSourceSupplier
protected Supplier<DataSource<IMAGE>> obtainDataSourceSupplier( final DraweeController controller, final String controllerId) { if (mDataSourceSupplier != null) { return mDataSourceSupplier; } Supplier<DataSource<IMAGE>> supplier = null; // final image supplier; if (mImageRequest != null) { supplier = getDataSourceSupplierForRequest(controller, controllerId, mImageRequest); } else if (mMultiImageRequests != null) { supplier = getFirstAvailableDataSourceSupplier( controller, controllerId, mMultiImageRequests, mTryCacheOnlyFirst); } // increasing-quality supplier; highest-quality supplier goes first if (supplier != null && mLowResImageRequest != null) { List<Supplier<DataSource<IMAGE>>> suppliers = new ArrayList<>(2); suppliers.add(supplier); suppliers.add(getDataSourceSupplierForRequest(controller, controllerId, mLowResImageRequest)); supplier = IncreasingQualityDataSourceSupplier.create(suppliers, false); } // no image requests; use null data source supplier if (supplier == null) { supplier = DataSources.getFailedDataSourceSupplier(NO_REQUEST_EXCEPTION); } return supplier; }
java
protected Supplier<DataSource<IMAGE>> obtainDataSourceSupplier( final DraweeController controller, final String controllerId) { if (mDataSourceSupplier != null) { return mDataSourceSupplier; } Supplier<DataSource<IMAGE>> supplier = null; // final image supplier; if (mImageRequest != null) { supplier = getDataSourceSupplierForRequest(controller, controllerId, mImageRequest); } else if (mMultiImageRequests != null) { supplier = getFirstAvailableDataSourceSupplier( controller, controllerId, mMultiImageRequests, mTryCacheOnlyFirst); } // increasing-quality supplier; highest-quality supplier goes first if (supplier != null && mLowResImageRequest != null) { List<Supplier<DataSource<IMAGE>>> suppliers = new ArrayList<>(2); suppliers.add(supplier); suppliers.add(getDataSourceSupplierForRequest(controller, controllerId, mLowResImageRequest)); supplier = IncreasingQualityDataSourceSupplier.create(suppliers, false); } // no image requests; use null data source supplier if (supplier == null) { supplier = DataSources.getFailedDataSourceSupplier(NO_REQUEST_EXCEPTION); } return supplier; }
[ "protected", "Supplier", "<", "DataSource", "<", "IMAGE", ">", ">", "obtainDataSourceSupplier", "(", "final", "DraweeController", "controller", ",", "final", "String", "controllerId", ")", "{", "if", "(", "mDataSourceSupplier", "!=", "null", ")", "{", "return", "mDataSourceSupplier", ";", "}", "Supplier", "<", "DataSource", "<", "IMAGE", ">", ">", "supplier", "=", "null", ";", "// final image supplier;", "if", "(", "mImageRequest", "!=", "null", ")", "{", "supplier", "=", "getDataSourceSupplierForRequest", "(", "controller", ",", "controllerId", ",", "mImageRequest", ")", ";", "}", "else", "if", "(", "mMultiImageRequests", "!=", "null", ")", "{", "supplier", "=", "getFirstAvailableDataSourceSupplier", "(", "controller", ",", "controllerId", ",", "mMultiImageRequests", ",", "mTryCacheOnlyFirst", ")", ";", "}", "// increasing-quality supplier; highest-quality supplier goes first", "if", "(", "supplier", "!=", "null", "&&", "mLowResImageRequest", "!=", "null", ")", "{", "List", "<", "Supplier", "<", "DataSource", "<", "IMAGE", ">>>", "suppliers", "=", "new", "ArrayList", "<>", "(", "2", ")", ";", "suppliers", ".", "add", "(", "supplier", ")", ";", "suppliers", ".", "add", "(", "getDataSourceSupplierForRequest", "(", "controller", ",", "controllerId", ",", "mLowResImageRequest", ")", ")", ";", "supplier", "=", "IncreasingQualityDataSourceSupplier", ".", "create", "(", "suppliers", ",", "false", ")", ";", "}", "// no image requests; use null data source supplier", "if", "(", "supplier", "==", "null", ")", "{", "supplier", "=", "DataSources", ".", "getFailedDataSourceSupplier", "(", "NO_REQUEST_EXCEPTION", ")", ";", "}", "return", "supplier", ";", "}" ]
Gets the top-level data source supplier to be used by a controller.
[ "Gets", "the", "top", "-", "level", "data", "source", "supplier", "to", "be", "used", "by", "a", "controller", "." ]
0b85879d51c5036d5e46e627a6651afefc0b971a
https://github.com/facebook/fresco/blob/0b85879d51c5036d5e46e627a6651afefc0b971a/drawee/src/main/java/com/facebook/drawee/controller/AbstractDraweeControllerBuilder.java#L332-L363
14,458
facebook/fresco
drawee/src/main/java/com/facebook/drawee/controller/AbstractDraweeControllerBuilder.java
AbstractDraweeControllerBuilder.maybeBuildAndSetGestureDetector
protected void maybeBuildAndSetGestureDetector(AbstractDraweeController controller) { GestureDetector gestureDetector = controller.getGestureDetector(); if (gestureDetector == null) { gestureDetector = GestureDetector.newInstance(mContext); controller.setGestureDetector(gestureDetector); } }
java
protected void maybeBuildAndSetGestureDetector(AbstractDraweeController controller) { GestureDetector gestureDetector = controller.getGestureDetector(); if (gestureDetector == null) { gestureDetector = GestureDetector.newInstance(mContext); controller.setGestureDetector(gestureDetector); } }
[ "protected", "void", "maybeBuildAndSetGestureDetector", "(", "AbstractDraweeController", "controller", ")", "{", "GestureDetector", "gestureDetector", "=", "controller", ".", "getGestureDetector", "(", ")", ";", "if", "(", "gestureDetector", "==", "null", ")", "{", "gestureDetector", "=", "GestureDetector", ".", "newInstance", "(", "mContext", ")", ";", "controller", ".", "setGestureDetector", "(", "gestureDetector", ")", ";", "}", "}" ]
Installs a gesture detector to the given controller.
[ "Installs", "a", "gesture", "detector", "to", "the", "given", "controller", "." ]
0b85879d51c5036d5e46e627a6651afefc0b971a
https://github.com/facebook/fresco/blob/0b85879d51c5036d5e46e627a6651afefc0b971a/drawee/src/main/java/com/facebook/drawee/controller/AbstractDraweeControllerBuilder.java#L438-L444
14,459
facebook/fresco
fbcore/src/main/java/com/facebook/common/util/UriUtil.java
UriUtil.isLocalContactUri
public static boolean isLocalContactUri(Uri uri) { return isLocalContentUri(uri) && ContactsContract.AUTHORITY.equals(uri.getAuthority()) && !uri.getPath().startsWith(LOCAL_CONTACT_IMAGE_URI.getPath()); }
java
public static boolean isLocalContactUri(Uri uri) { return isLocalContentUri(uri) && ContactsContract.AUTHORITY.equals(uri.getAuthority()) && !uri.getPath().startsWith(LOCAL_CONTACT_IMAGE_URI.getPath()); }
[ "public", "static", "boolean", "isLocalContactUri", "(", "Uri", "uri", ")", "{", "return", "isLocalContentUri", "(", "uri", ")", "&&", "ContactsContract", ".", "AUTHORITY", ".", "equals", "(", "uri", ".", "getAuthority", "(", ")", ")", "&&", "!", "uri", ".", "getPath", "(", ")", ".", "startsWith", "(", "LOCAL_CONTACT_IMAGE_URI", ".", "getPath", "(", ")", ")", ";", "}" ]
Checks if the given URI is a general Contact URI, and not a specific display photo. @param uri the URI to check @return true if the uri is a Contact URI, and is not already specifying a display photo.
[ "Checks", "if", "the", "given", "URI", "is", "a", "general", "Contact", "URI", "and", "not", "a", "specific", "display", "photo", "." ]
0b85879d51c5036d5e46e627a6651afefc0b971a
https://github.com/facebook/fresco/blob/0b85879d51c5036d5e46e627a6651afefc0b971a/fbcore/src/main/java/com/facebook/common/util/UriUtil.java#L121-L125
14,460
facebook/fresco
fbcore/src/main/java/com/facebook/common/util/UriUtil.java
UriUtil.isLocalCameraUri
public static boolean isLocalCameraUri(Uri uri) { String uriString = uri.toString(); return uriString.startsWith(MediaStore.Images.Media.EXTERNAL_CONTENT_URI.toString()) || uriString.startsWith(MediaStore.Images.Media.INTERNAL_CONTENT_URI.toString()); }
java
public static boolean isLocalCameraUri(Uri uri) { String uriString = uri.toString(); return uriString.startsWith(MediaStore.Images.Media.EXTERNAL_CONTENT_URI.toString()) || uriString.startsWith(MediaStore.Images.Media.INTERNAL_CONTENT_URI.toString()); }
[ "public", "static", "boolean", "isLocalCameraUri", "(", "Uri", "uri", ")", "{", "String", "uriString", "=", "uri", ".", "toString", "(", ")", ";", "return", "uriString", ".", "startsWith", "(", "MediaStore", ".", "Images", ".", "Media", ".", "EXTERNAL_CONTENT_URI", ".", "toString", "(", ")", ")", "||", "uriString", ".", "startsWith", "(", "MediaStore", ".", "Images", ".", "Media", ".", "INTERNAL_CONTENT_URI", ".", "toString", "(", ")", ")", ";", "}" ]
Checks if the given URI is for a photo from the device's local media store. @param uri the URI to check @return true if the URI points to a media store photo
[ "Checks", "if", "the", "given", "URI", "is", "for", "a", "photo", "from", "the", "device", "s", "local", "media", "store", "." ]
0b85879d51c5036d5e46e627a6651afefc0b971a
https://github.com/facebook/fresco/blob/0b85879d51c5036d5e46e627a6651afefc0b971a/fbcore/src/main/java/com/facebook/common/util/UriUtil.java#L133-L137
14,461
facebook/fresco
fbcore/src/main/java/com/facebook/common/util/UriUtil.java
UriUtil.getRealPathFromUri
@Nullable public static String getRealPathFromUri(ContentResolver contentResolver, final Uri srcUri) { String result = null; if (isLocalContentUri(srcUri)) { Cursor cursor = null; try { cursor = contentResolver.query(srcUri, null, null, null, null); if (cursor != null && cursor.moveToFirst()) { int idx = cursor.getColumnIndex(MediaStore.Images.ImageColumns.DATA); if (idx != -1) { result = cursor.getString(idx); } } } finally { if (cursor != null) { cursor.close(); } } } else if (isLocalFileUri(srcUri)) { result = srcUri.getPath(); } return result; }
java
@Nullable public static String getRealPathFromUri(ContentResolver contentResolver, final Uri srcUri) { String result = null; if (isLocalContentUri(srcUri)) { Cursor cursor = null; try { cursor = contentResolver.query(srcUri, null, null, null, null); if (cursor != null && cursor.moveToFirst()) { int idx = cursor.getColumnIndex(MediaStore.Images.ImageColumns.DATA); if (idx != -1) { result = cursor.getString(idx); } } } finally { if (cursor != null) { cursor.close(); } } } else if (isLocalFileUri(srcUri)) { result = srcUri.getPath(); } return result; }
[ "@", "Nullable", "public", "static", "String", "getRealPathFromUri", "(", "ContentResolver", "contentResolver", ",", "final", "Uri", "srcUri", ")", "{", "String", "result", "=", "null", ";", "if", "(", "isLocalContentUri", "(", "srcUri", ")", ")", "{", "Cursor", "cursor", "=", "null", ";", "try", "{", "cursor", "=", "contentResolver", ".", "query", "(", "srcUri", ",", "null", ",", "null", ",", "null", ",", "null", ")", ";", "if", "(", "cursor", "!=", "null", "&&", "cursor", ".", "moveToFirst", "(", ")", ")", "{", "int", "idx", "=", "cursor", ".", "getColumnIndex", "(", "MediaStore", ".", "Images", ".", "ImageColumns", ".", "DATA", ")", ";", "if", "(", "idx", "!=", "-", "1", ")", "{", "result", "=", "cursor", ".", "getString", "(", "idx", ")", ";", "}", "}", "}", "finally", "{", "if", "(", "cursor", "!=", "null", ")", "{", "cursor", ".", "close", "(", ")", ";", "}", "}", "}", "else", "if", "(", "isLocalFileUri", "(", "srcUri", ")", ")", "{", "result", "=", "srcUri", ".", "getPath", "(", ")", ";", "}", "return", "result", ";", "}" ]
Get the path of a file from the Uri. @param contentResolver the content resolver which will query for the source file @param srcUri The source uri @return The Path for the file or null if doesn't exists
[ "Get", "the", "path", "of", "a", "file", "from", "the", "Uri", "." ]
0b85879d51c5036d5e46e627a6651afefc0b971a
https://github.com/facebook/fresco/blob/0b85879d51c5036d5e46e627a6651afefc0b971a/fbcore/src/main/java/com/facebook/common/util/UriUtil.java#L205-L227
14,462
facebook/fresco
fbcore/src/main/java/com/facebook/common/util/UriUtil.java
UriUtil.getUriForQualifiedResource
public static Uri getUriForQualifiedResource(String packageName, int resourceId) { return new Uri.Builder() .scheme(QUALIFIED_RESOURCE_SCHEME) .authority(packageName) .path(String.valueOf(resourceId)) .build(); }
java
public static Uri getUriForQualifiedResource(String packageName, int resourceId) { return new Uri.Builder() .scheme(QUALIFIED_RESOURCE_SCHEME) .authority(packageName) .path(String.valueOf(resourceId)) .build(); }
[ "public", "static", "Uri", "getUriForQualifiedResource", "(", "String", "packageName", ",", "int", "resourceId", ")", "{", "return", "new", "Uri", ".", "Builder", "(", ")", ".", "scheme", "(", "QUALIFIED_RESOURCE_SCHEME", ")", ".", "authority", "(", "packageName", ")", ".", "path", "(", "String", ".", "valueOf", "(", "resourceId", ")", ")", ".", "build", "(", ")", ";", "}" ]
Returns a URI for the given resource ID in the given package. Use this method only if you need to specify a package name different to your application's main package. @param packageName a package name (e.g. com.facebook.myapp.plugin) @param resourceId to resource ID to use @return the URI
[ "Returns", "a", "URI", "for", "the", "given", "resource", "ID", "in", "the", "given", "package", ".", "Use", "this", "method", "only", "if", "you", "need", "to", "specify", "a", "package", "name", "different", "to", "your", "application", "s", "main", "package", "." ]
0b85879d51c5036d5e46e627a6651afefc0b971a
https://github.com/facebook/fresco/blob/0b85879d51c5036d5e46e627a6651afefc0b971a/fbcore/src/main/java/com/facebook/common/util/UriUtil.java#L262-L268
14,463
facebook/fresco
native-imagetranscoder/src/main/java/com/facebook/imagepipeline/nativecode/NativeJpegTranscoder.java
NativeJpegTranscoder.transcodeJpeg
@VisibleForTesting public static void transcodeJpeg( final InputStream inputStream, final OutputStream outputStream, final int rotationAngle, final int scaleNumerator, final int quality) throws IOException { NativeJpegTranscoderSoLoader.ensure(); Preconditions.checkArgument(scaleNumerator >= MIN_SCALE_NUMERATOR); Preconditions.checkArgument(scaleNumerator <= MAX_SCALE_NUMERATOR); Preconditions.checkArgument(quality >= MIN_QUALITY); Preconditions.checkArgument(quality <= MAX_QUALITY); Preconditions.checkArgument(JpegTranscoderUtils.isRotationAngleAllowed(rotationAngle)); Preconditions.checkArgument( scaleNumerator != SCALE_DENOMINATOR || rotationAngle != 0, "no transformation requested"); nativeTranscodeJpeg( Preconditions.checkNotNull(inputStream), Preconditions.checkNotNull(outputStream), rotationAngle, scaleNumerator, quality); }
java
@VisibleForTesting public static void transcodeJpeg( final InputStream inputStream, final OutputStream outputStream, final int rotationAngle, final int scaleNumerator, final int quality) throws IOException { NativeJpegTranscoderSoLoader.ensure(); Preconditions.checkArgument(scaleNumerator >= MIN_SCALE_NUMERATOR); Preconditions.checkArgument(scaleNumerator <= MAX_SCALE_NUMERATOR); Preconditions.checkArgument(quality >= MIN_QUALITY); Preconditions.checkArgument(quality <= MAX_QUALITY); Preconditions.checkArgument(JpegTranscoderUtils.isRotationAngleAllowed(rotationAngle)); Preconditions.checkArgument( scaleNumerator != SCALE_DENOMINATOR || rotationAngle != 0, "no transformation requested"); nativeTranscodeJpeg( Preconditions.checkNotNull(inputStream), Preconditions.checkNotNull(outputStream), rotationAngle, scaleNumerator, quality); }
[ "@", "VisibleForTesting", "public", "static", "void", "transcodeJpeg", "(", "final", "InputStream", "inputStream", ",", "final", "OutputStream", "outputStream", ",", "final", "int", "rotationAngle", ",", "final", "int", "scaleNumerator", ",", "final", "int", "quality", ")", "throws", "IOException", "{", "NativeJpegTranscoderSoLoader", ".", "ensure", "(", ")", ";", "Preconditions", ".", "checkArgument", "(", "scaleNumerator", ">=", "MIN_SCALE_NUMERATOR", ")", ";", "Preconditions", ".", "checkArgument", "(", "scaleNumerator", "<=", "MAX_SCALE_NUMERATOR", ")", ";", "Preconditions", ".", "checkArgument", "(", "quality", ">=", "MIN_QUALITY", ")", ";", "Preconditions", ".", "checkArgument", "(", "quality", "<=", "MAX_QUALITY", ")", ";", "Preconditions", ".", "checkArgument", "(", "JpegTranscoderUtils", ".", "isRotationAngleAllowed", "(", "rotationAngle", ")", ")", ";", "Preconditions", ".", "checkArgument", "(", "scaleNumerator", "!=", "SCALE_DENOMINATOR", "||", "rotationAngle", "!=", "0", ",", "\"no transformation requested\"", ")", ";", "nativeTranscodeJpeg", "(", "Preconditions", ".", "checkNotNull", "(", "inputStream", ")", ",", "Preconditions", ".", "checkNotNull", "(", "outputStream", ")", ",", "rotationAngle", ",", "scaleNumerator", ",", "quality", ")", ";", "}" ]
Transcodes an image to match the specified rotation angle and the scale factor. @param inputStream The {@link InputStream} of the image that will be transcoded. @param outputStream The {@link OutputStream} where the newly created image is written to. @param rotationAngle 0, 90, 180 or 270 @param scaleNumerator 1 - 16, image will be scaled using scaleNumerator/8 factor @param quality 1 - 100
[ "Transcodes", "an", "image", "to", "match", "the", "specified", "rotation", "angle", "and", "the", "scale", "factor", "." ]
0b85879d51c5036d5e46e627a6651afefc0b971a
https://github.com/facebook/fresco/blob/0b85879d51c5036d5e46e627a6651afefc0b971a/native-imagetranscoder/src/main/java/com/facebook/imagepipeline/nativecode/NativeJpegTranscoder.java#L143-L165
14,464
facebook/fresco
native-imagetranscoder/src/main/java/com/facebook/imagepipeline/nativecode/NativeJpegTranscoder.java
NativeJpegTranscoder.transcodeJpegWithExifOrientation
@VisibleForTesting public static void transcodeJpegWithExifOrientation( final InputStream inputStream, final OutputStream outputStream, final int exifOrientation, final int scaleNumerator, final int quality) throws IOException { NativeJpegTranscoderSoLoader.ensure(); Preconditions.checkArgument(scaleNumerator >= MIN_SCALE_NUMERATOR); Preconditions.checkArgument(scaleNumerator <= MAX_SCALE_NUMERATOR); Preconditions.checkArgument(quality >= MIN_QUALITY); Preconditions.checkArgument(quality <= MAX_QUALITY); Preconditions.checkArgument(JpegTranscoderUtils.isExifOrientationAllowed(exifOrientation)); Preconditions.checkArgument( scaleNumerator != SCALE_DENOMINATOR || exifOrientation != ExifInterface.ORIENTATION_NORMAL, "no transformation requested"); nativeTranscodeJpegWithExifOrientation( Preconditions.checkNotNull(inputStream), Preconditions.checkNotNull(outputStream), exifOrientation, scaleNumerator, quality); }
java
@VisibleForTesting public static void transcodeJpegWithExifOrientation( final InputStream inputStream, final OutputStream outputStream, final int exifOrientation, final int scaleNumerator, final int quality) throws IOException { NativeJpegTranscoderSoLoader.ensure(); Preconditions.checkArgument(scaleNumerator >= MIN_SCALE_NUMERATOR); Preconditions.checkArgument(scaleNumerator <= MAX_SCALE_NUMERATOR); Preconditions.checkArgument(quality >= MIN_QUALITY); Preconditions.checkArgument(quality <= MAX_QUALITY); Preconditions.checkArgument(JpegTranscoderUtils.isExifOrientationAllowed(exifOrientation)); Preconditions.checkArgument( scaleNumerator != SCALE_DENOMINATOR || exifOrientation != ExifInterface.ORIENTATION_NORMAL, "no transformation requested"); nativeTranscodeJpegWithExifOrientation( Preconditions.checkNotNull(inputStream), Preconditions.checkNotNull(outputStream), exifOrientation, scaleNumerator, quality); }
[ "@", "VisibleForTesting", "public", "static", "void", "transcodeJpegWithExifOrientation", "(", "final", "InputStream", "inputStream", ",", "final", "OutputStream", "outputStream", ",", "final", "int", "exifOrientation", ",", "final", "int", "scaleNumerator", ",", "final", "int", "quality", ")", "throws", "IOException", "{", "NativeJpegTranscoderSoLoader", ".", "ensure", "(", ")", ";", "Preconditions", ".", "checkArgument", "(", "scaleNumerator", ">=", "MIN_SCALE_NUMERATOR", ")", ";", "Preconditions", ".", "checkArgument", "(", "scaleNumerator", "<=", "MAX_SCALE_NUMERATOR", ")", ";", "Preconditions", ".", "checkArgument", "(", "quality", ">=", "MIN_QUALITY", ")", ";", "Preconditions", ".", "checkArgument", "(", "quality", "<=", "MAX_QUALITY", ")", ";", "Preconditions", ".", "checkArgument", "(", "JpegTranscoderUtils", ".", "isExifOrientationAllowed", "(", "exifOrientation", ")", ")", ";", "Preconditions", ".", "checkArgument", "(", "scaleNumerator", "!=", "SCALE_DENOMINATOR", "||", "exifOrientation", "!=", "ExifInterface", ".", "ORIENTATION_NORMAL", ",", "\"no transformation requested\"", ")", ";", "nativeTranscodeJpegWithExifOrientation", "(", "Preconditions", ".", "checkNotNull", "(", "inputStream", ")", ",", "Preconditions", ".", "checkNotNull", "(", "outputStream", ")", ",", "exifOrientation", ",", "scaleNumerator", ",", "quality", ")", ";", "}" ]
Transcodes an image to match the specified exif orientation and the scale factor. @param inputStream The {@link InputStream} of the image that will be transcoded. @param outputStream The {@link OutputStream} where the newly created image is written to. @param exifOrientation 0, 90, 180 or 270 @param scaleNumerator 1 - 16, image will be scaled using scaleNumerator/8 factor @param quality 1 - 100
[ "Transcodes", "an", "image", "to", "match", "the", "specified", "exif", "orientation", "and", "the", "scale", "factor", "." ]
0b85879d51c5036d5e46e627a6651afefc0b971a
https://github.com/facebook/fresco/blob/0b85879d51c5036d5e46e627a6651afefc0b971a/native-imagetranscoder/src/main/java/com/facebook/imagepipeline/nativecode/NativeJpegTranscoder.java#L185-L208
14,465
facebook/fresco
imagepipeline/src/main/java/com/facebook/imagepipeline/request/ImageRequest.java
ImageRequest.getSourceUriType
private static @SourceUriType int getSourceUriType(final Uri uri) { if (uri == null) { return SOURCE_TYPE_UNKNOWN; } if (UriUtil.isNetworkUri(uri)) { return SOURCE_TYPE_NETWORK; } else if (UriUtil.isLocalFileUri(uri)) { if (MediaUtils.isVideo(MediaUtils.extractMime(uri.getPath()))) { return SOURCE_TYPE_LOCAL_VIDEO_FILE; } else { return SOURCE_TYPE_LOCAL_IMAGE_FILE; } } else if (UriUtil.isLocalContentUri(uri)) { return SOURCE_TYPE_LOCAL_CONTENT; } else if (UriUtil.isLocalAssetUri(uri)) { return SOURCE_TYPE_LOCAL_ASSET; } else if (UriUtil.isLocalResourceUri(uri)) { return SOURCE_TYPE_LOCAL_RESOURCE; } else if (UriUtil.isDataUri(uri)) { return SOURCE_TYPE_DATA; } else if (UriUtil.isQualifiedResourceUri(uri)) { return SOURCE_TYPE_QUALIFIED_RESOURCE; } else { return SOURCE_TYPE_UNKNOWN; } }
java
private static @SourceUriType int getSourceUriType(final Uri uri) { if (uri == null) { return SOURCE_TYPE_UNKNOWN; } if (UriUtil.isNetworkUri(uri)) { return SOURCE_TYPE_NETWORK; } else if (UriUtil.isLocalFileUri(uri)) { if (MediaUtils.isVideo(MediaUtils.extractMime(uri.getPath()))) { return SOURCE_TYPE_LOCAL_VIDEO_FILE; } else { return SOURCE_TYPE_LOCAL_IMAGE_FILE; } } else if (UriUtil.isLocalContentUri(uri)) { return SOURCE_TYPE_LOCAL_CONTENT; } else if (UriUtil.isLocalAssetUri(uri)) { return SOURCE_TYPE_LOCAL_ASSET; } else if (UriUtil.isLocalResourceUri(uri)) { return SOURCE_TYPE_LOCAL_RESOURCE; } else if (UriUtil.isDataUri(uri)) { return SOURCE_TYPE_DATA; } else if (UriUtil.isQualifiedResourceUri(uri)) { return SOURCE_TYPE_QUALIFIED_RESOURCE; } else { return SOURCE_TYPE_UNKNOWN; } }
[ "private", "static", "@", "SourceUriType", "int", "getSourceUriType", "(", "final", "Uri", "uri", ")", "{", "if", "(", "uri", "==", "null", ")", "{", "return", "SOURCE_TYPE_UNKNOWN", ";", "}", "if", "(", "UriUtil", ".", "isNetworkUri", "(", "uri", ")", ")", "{", "return", "SOURCE_TYPE_NETWORK", ";", "}", "else", "if", "(", "UriUtil", ".", "isLocalFileUri", "(", "uri", ")", ")", "{", "if", "(", "MediaUtils", ".", "isVideo", "(", "MediaUtils", ".", "extractMime", "(", "uri", ".", "getPath", "(", ")", ")", ")", ")", "{", "return", "SOURCE_TYPE_LOCAL_VIDEO_FILE", ";", "}", "else", "{", "return", "SOURCE_TYPE_LOCAL_IMAGE_FILE", ";", "}", "}", "else", "if", "(", "UriUtil", ".", "isLocalContentUri", "(", "uri", ")", ")", "{", "return", "SOURCE_TYPE_LOCAL_CONTENT", ";", "}", "else", "if", "(", "UriUtil", ".", "isLocalAssetUri", "(", "uri", ")", ")", "{", "return", "SOURCE_TYPE_LOCAL_ASSET", ";", "}", "else", "if", "(", "UriUtil", ".", "isLocalResourceUri", "(", "uri", ")", ")", "{", "return", "SOURCE_TYPE_LOCAL_RESOURCE", ";", "}", "else", "if", "(", "UriUtil", ".", "isDataUri", "(", "uri", ")", ")", "{", "return", "SOURCE_TYPE_DATA", ";", "}", "else", "if", "(", "UriUtil", ".", "isQualifiedResourceUri", "(", "uri", ")", ")", "{", "return", "SOURCE_TYPE_QUALIFIED_RESOURCE", ";", "}", "else", "{", "return", "SOURCE_TYPE_UNKNOWN", ";", "}", "}" ]
This is a utility method which returns the type of Uri @param uri The Uri to test @return The type of the given Uri if available or SOURCE_TYPE_UNKNOWN if not
[ "This", "is", "a", "utility", "method", "which", "returns", "the", "type", "of", "Uri" ]
0b85879d51c5036d5e46e627a6651afefc0b971a
https://github.com/facebook/fresco/blob/0b85879d51c5036d5e46e627a6651afefc0b971a/imagepipeline/src/main/java/com/facebook/imagepipeline/request/ImageRequest.java#L339-L364
14,466
facebook/fresco
imagepipeline-base/src/main/java/com/facebook/imagepipeline/cache/CountingLruMap.java
CountingLruMap.getFirstKey
@Nullable public synchronized K getFirstKey() { return mMap.isEmpty() ? null : mMap.keySet().iterator().next(); }
java
@Nullable public synchronized K getFirstKey() { return mMap.isEmpty() ? null : mMap.keySet().iterator().next(); }
[ "@", "Nullable", "public", "synchronized", "K", "getFirstKey", "(", ")", "{", "return", "mMap", ".", "isEmpty", "(", ")", "?", "null", ":", "mMap", ".", "keySet", "(", ")", ".", "iterator", "(", ")", ".", "next", "(", ")", ";", "}" ]
Gets the key of the first element in the map.
[ "Gets", "the", "key", "of", "the", "first", "element", "in", "the", "map", "." ]
0b85879d51c5036d5e46e627a6651afefc0b971a
https://github.com/facebook/fresco/blob/0b85879d51c5036d5e46e627a6651afefc0b971a/imagepipeline-base/src/main/java/com/facebook/imagepipeline/cache/CountingLruMap.java#L56-L59
14,467
facebook/fresco
imagepipeline-base/src/main/java/com/facebook/imagepipeline/cache/CountingLruMap.java
CountingLruMap.put
@Nullable public synchronized V put(K key, V value) { // We do remove and insert instead of just replace, in order to cause a structural change // to the map, as we always want the latest inserted element to be last in the queue. V oldValue = mMap.remove(key); mSizeInBytes -= getValueSizeInBytes(oldValue); mMap.put(key, value); mSizeInBytes += getValueSizeInBytes(value); return oldValue; }
java
@Nullable public synchronized V put(K key, V value) { // We do remove and insert instead of just replace, in order to cause a structural change // to the map, as we always want the latest inserted element to be last in the queue. V oldValue = mMap.remove(key); mSizeInBytes -= getValueSizeInBytes(oldValue); mMap.put(key, value); mSizeInBytes += getValueSizeInBytes(value); return oldValue; }
[ "@", "Nullable", "public", "synchronized", "V", "put", "(", "K", "key", ",", "V", "value", ")", "{", "// We do remove and insert instead of just replace, in order to cause a structural change", "// to the map, as we always want the latest inserted element to be last in the queue.", "V", "oldValue", "=", "mMap", ".", "remove", "(", "key", ")", ";", "mSizeInBytes", "-=", "getValueSizeInBytes", "(", "oldValue", ")", ";", "mMap", ".", "put", "(", "key", ",", "value", ")", ";", "mSizeInBytes", "+=", "getValueSizeInBytes", "(", "value", ")", ";", "return", "oldValue", ";", "}" ]
Adds the element to the map, and removes the old element with the same key if any.
[ "Adds", "the", "element", "to", "the", "map", "and", "removes", "the", "old", "element", "with", "the", "same", "key", "if", "any", "." ]
0b85879d51c5036d5e46e627a6651afefc0b971a
https://github.com/facebook/fresco/blob/0b85879d51c5036d5e46e627a6651afefc0b971a/imagepipeline-base/src/main/java/com/facebook/imagepipeline/cache/CountingLruMap.java#L85-L94
14,468
facebook/fresco
imagepipeline-base/src/main/java/com/facebook/imagepipeline/cache/CountingLruMap.java
CountingLruMap.remove
@Nullable public synchronized V remove(K key) { V oldValue = mMap.remove(key); mSizeInBytes -= getValueSizeInBytes(oldValue); return oldValue; }
java
@Nullable public synchronized V remove(K key) { V oldValue = mMap.remove(key); mSizeInBytes -= getValueSizeInBytes(oldValue); return oldValue; }
[ "@", "Nullable", "public", "synchronized", "V", "remove", "(", "K", "key", ")", "{", "V", "oldValue", "=", "mMap", ".", "remove", "(", "key", ")", ";", "mSizeInBytes", "-=", "getValueSizeInBytes", "(", "oldValue", ")", ";", "return", "oldValue", ";", "}" ]
Removes the element from the map.
[ "Removes", "the", "element", "from", "the", "map", "." ]
0b85879d51c5036d5e46e627a6651afefc0b971a
https://github.com/facebook/fresco/blob/0b85879d51c5036d5e46e627a6651afefc0b971a/imagepipeline-base/src/main/java/com/facebook/imagepipeline/cache/CountingLruMap.java#L97-L102
14,469
facebook/fresco
imagepipeline-base/src/main/java/com/facebook/imagepipeline/cache/CountingLruMap.java
CountingLruMap.clear
public synchronized ArrayList<V> clear() { ArrayList<V> oldValues = new ArrayList<>(mMap.values()); mMap.clear(); mSizeInBytes = 0; return oldValues; }
java
public synchronized ArrayList<V> clear() { ArrayList<V> oldValues = new ArrayList<>(mMap.values()); mMap.clear(); mSizeInBytes = 0; return oldValues; }
[ "public", "synchronized", "ArrayList", "<", "V", ">", "clear", "(", ")", "{", "ArrayList", "<", "V", ">", "oldValues", "=", "new", "ArrayList", "<>", "(", "mMap", ".", "values", "(", ")", ")", ";", "mMap", ".", "clear", "(", ")", ";", "mSizeInBytes", "=", "0", ";", "return", "oldValues", ";", "}" ]
Clears the map.
[ "Clears", "the", "map", "." ]
0b85879d51c5036d5e46e627a6651afefc0b971a
https://github.com/facebook/fresco/blob/0b85879d51c5036d5e46e627a6651afefc0b971a/imagepipeline-base/src/main/java/com/facebook/imagepipeline/cache/CountingLruMap.java#L120-L125
14,470
facebook/fresco
imagepipeline-base/src/main/java/com/facebook/cache/disk/DefaultDiskStorage.java
DefaultDiskStorage.getSubdirectoryPath
private String getSubdirectoryPath(String resourceId) { String subdirectory = String.valueOf(Math.abs(resourceId.hashCode() % SHARDING_BUCKET_COUNT)); return mVersionDirectory + File.separator + subdirectory; }
java
private String getSubdirectoryPath(String resourceId) { String subdirectory = String.valueOf(Math.abs(resourceId.hashCode() % SHARDING_BUCKET_COUNT)); return mVersionDirectory + File.separator + subdirectory; }
[ "private", "String", "getSubdirectoryPath", "(", "String", "resourceId", ")", "{", "String", "subdirectory", "=", "String", ".", "valueOf", "(", "Math", ".", "abs", "(", "resourceId", ".", "hashCode", "(", ")", "%", "SHARDING_BUCKET_COUNT", ")", ")", ";", "return", "mVersionDirectory", "+", "File", ".", "separator", "+", "subdirectory", ";", "}" ]
Gets the directory to use to store the given key @param resourceId the id of the file we're going to store @return the directory to store the file in
[ "Gets", "the", "directory", "to", "use", "to", "store", "the", "given", "key" ]
0b85879d51c5036d5e46e627a6651afefc0b971a
https://github.com/facebook/fresco/blob/0b85879d51c5036d5e46e627a6651afefc0b971a/imagepipeline-base/src/main/java/com/facebook/cache/disk/DefaultDiskStorage.java#L226-L229
14,471
facebook/fresco
animated-drawable/src/main/java/com/facebook/fresco/animation/drawable/AnimatedDrawable2.java
AnimatedDrawable2.jumpToFrame
public void jumpToFrame(int targetFrameNumber) { if (mAnimationBackend == null || mFrameScheduler == null) { return; } // In order to jump to a given frame, we have to compute the correct start time mLastFrameAnimationTimeMs = mFrameScheduler.getTargetRenderTimeMs(targetFrameNumber); mStartTimeMs = now() - mLastFrameAnimationTimeMs; mExpectedRenderTimeMs = mStartTimeMs; invalidateSelf(); }
java
public void jumpToFrame(int targetFrameNumber) { if (mAnimationBackend == null || mFrameScheduler == null) { return; } // In order to jump to a given frame, we have to compute the correct start time mLastFrameAnimationTimeMs = mFrameScheduler.getTargetRenderTimeMs(targetFrameNumber); mStartTimeMs = now() - mLastFrameAnimationTimeMs; mExpectedRenderTimeMs = mStartTimeMs; invalidateSelf(); }
[ "public", "void", "jumpToFrame", "(", "int", "targetFrameNumber", ")", "{", "if", "(", "mAnimationBackend", "==", "null", "||", "mFrameScheduler", "==", "null", ")", "{", "return", ";", "}", "// In order to jump to a given frame, we have to compute the correct start time", "mLastFrameAnimationTimeMs", "=", "mFrameScheduler", ".", "getTargetRenderTimeMs", "(", "targetFrameNumber", ")", ";", "mStartTimeMs", "=", "now", "(", ")", "-", "mLastFrameAnimationTimeMs", ";", "mExpectedRenderTimeMs", "=", "mStartTimeMs", ";", "invalidateSelf", "(", ")", ";", "}" ]
Jump immediately to the given frame number. The animation will not be paused if it is running. If the animation is not running, the animation will not be started. @param targetFrameNumber the frame number to jump to
[ "Jump", "immediately", "to", "the", "given", "frame", "number", ".", "The", "animation", "will", "not", "be", "paused", "if", "it", "is", "running", ".", "If", "the", "animation", "is", "not", "running", "the", "animation", "will", "not", "be", "started", "." ]
0b85879d51c5036d5e46e627a6651afefc0b971a
https://github.com/facebook/fresco/blob/0b85879d51c5036d5e46e627a6651afefc0b971a/animated-drawable/src/main/java/com/facebook/fresco/animation/drawable/AnimatedDrawable2.java#L323-L332
14,472
facebook/fresco
animated-drawable/src/main/java/com/facebook/fresco/animation/drawable/AnimatedDrawable2.java
AnimatedDrawable2.getLoopDurationMs
public long getLoopDurationMs() { if (mAnimationBackend == null) { return 0; } if (mFrameScheduler != null) { return mFrameScheduler.getLoopDurationMs(); } int loopDurationMs = 0; for (int i = 0; i < mAnimationBackend.getFrameCount(); i++) { loopDurationMs += mAnimationBackend.getFrameDurationMs(i); } return loopDurationMs; }
java
public long getLoopDurationMs() { if (mAnimationBackend == null) { return 0; } if (mFrameScheduler != null) { return mFrameScheduler.getLoopDurationMs(); } int loopDurationMs = 0; for (int i = 0; i < mAnimationBackend.getFrameCount(); i++) { loopDurationMs += mAnimationBackend.getFrameDurationMs(i); } return loopDurationMs; }
[ "public", "long", "getLoopDurationMs", "(", ")", "{", "if", "(", "mAnimationBackend", "==", "null", ")", "{", "return", "0", ";", "}", "if", "(", "mFrameScheduler", "!=", "null", ")", "{", "return", "mFrameScheduler", ".", "getLoopDurationMs", "(", ")", ";", "}", "int", "loopDurationMs", "=", "0", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "mAnimationBackend", ".", "getFrameCount", "(", ")", ";", "i", "++", ")", "{", "loopDurationMs", "+=", "mAnimationBackend", ".", "getFrameDurationMs", "(", "i", ")", ";", "}", "return", "loopDurationMs", ";", "}" ]
Get the animation duration for 1 loop by summing all frame durations. @return the duration of 1 animation loop in ms
[ "Get", "the", "animation", "duration", "for", "1", "loop", "by", "summing", "all", "frame", "durations", "." ]
0b85879d51c5036d5e46e627a6651afefc0b971a
https://github.com/facebook/fresco/blob/0b85879d51c5036d5e46e627a6651afefc0b971a/animated-drawable/src/main/java/com/facebook/fresco/animation/drawable/AnimatedDrawable2.java#L339-L351
14,473
facebook/fresco
animated-drawable/src/main/java/com/facebook/fresco/animation/drawable/AnimatedDrawable2.java
AnimatedDrawable2.onLevelChange
@Override protected boolean onLevelChange(int level) { if (mIsRunning) { // If the client called start on us, they expect us to run the animation. In that case, // we ignore level changes. return false; } if (mLastFrameAnimationTimeMs != level) { mLastFrameAnimationTimeMs = level; invalidateSelf(); return true; } return false; }
java
@Override protected boolean onLevelChange(int level) { if (mIsRunning) { // If the client called start on us, they expect us to run the animation. In that case, // we ignore level changes. return false; } if (mLastFrameAnimationTimeMs != level) { mLastFrameAnimationTimeMs = level; invalidateSelf(); return true; } return false; }
[ "@", "Override", "protected", "boolean", "onLevelChange", "(", "int", "level", ")", "{", "if", "(", "mIsRunning", ")", "{", "// If the client called start on us, they expect us to run the animation. In that case,", "// we ignore level changes.", "return", "false", ";", "}", "if", "(", "mLastFrameAnimationTimeMs", "!=", "level", ")", "{", "mLastFrameAnimationTimeMs", "=", "level", ";", "invalidateSelf", "(", ")", ";", "return", "true", ";", "}", "return", "false", ";", "}" ]
Set the animation to the given level. The level represents the animation time in ms. If the animation time is greater than the last frame time for the last loop, the last frame will be displayed. If the animation is running (e.g. if {@link #start()} has been called, the level change will be ignored. In this case, {@link #stop()} the animation first. @param level the animation time in ms @return true if the level change could be performed
[ "Set", "the", "animation", "to", "the", "given", "level", ".", "The", "level", "represents", "the", "animation", "time", "in", "ms", ".", "If", "the", "animation", "time", "is", "greater", "than", "the", "last", "frame", "time", "for", "the", "last", "loop", "the", "last", "frame", "will", "be", "displayed", "." ]
0b85879d51c5036d5e46e627a6651afefc0b971a
https://github.com/facebook/fresco/blob/0b85879d51c5036d5e46e627a6651afefc0b971a/animated-drawable/src/main/java/com/facebook/fresco/animation/drawable/AnimatedDrawable2.java#L467-L480
14,474
facebook/fresco
fbcore/src/main/java/com/facebook/common/util/Hex.java
Hex.encodeHex
public static String encodeHex(byte[] array, boolean zeroTerminated) { char[] cArray = new char[array.length * 2]; int j = 0; for (int i = 0; i < array.length; i++) { int index = array[i] & 0xFF; if (index == 0 && zeroTerminated) { break; } cArray[j++] = FIRST_CHAR[index]; cArray[j++] = SECOND_CHAR[index]; } return new String(cArray, 0, j); }
java
public static String encodeHex(byte[] array, boolean zeroTerminated) { char[] cArray = new char[array.length * 2]; int j = 0; for (int i = 0; i < array.length; i++) { int index = array[i] & 0xFF; if (index == 0 && zeroTerminated) { break; } cArray[j++] = FIRST_CHAR[index]; cArray[j++] = SECOND_CHAR[index]; } return new String(cArray, 0, j); }
[ "public", "static", "String", "encodeHex", "(", "byte", "[", "]", "array", ",", "boolean", "zeroTerminated", ")", "{", "char", "[", "]", "cArray", "=", "new", "char", "[", "array", ".", "length", "*", "2", "]", ";", "int", "j", "=", "0", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "array", ".", "length", ";", "i", "++", ")", "{", "int", "index", "=", "array", "[", "i", "]", "&", "0xFF", ";", "if", "(", "index", "==", "0", "&&", "zeroTerminated", ")", "{", "break", ";", "}", "cArray", "[", "j", "++", "]", "=", "FIRST_CHAR", "[", "index", "]", ";", "cArray", "[", "j", "++", "]", "=", "SECOND_CHAR", "[", "index", "]", ";", "}", "return", "new", "String", "(", "cArray", ",", "0", ",", "j", ")", ";", "}" ]
Quickly converts a byte array to a hexadecimal string representation. @param array byte array, possibly zero-terminated.
[ "Quickly", "converts", "a", "byte", "array", "to", "a", "hexadecimal", "string", "representation", "." ]
0b85879d51c5036d5e46e627a6651afefc0b971a
https://github.com/facebook/fresco/blob/0b85879d51c5036d5e46e627a6651afefc0b971a/fbcore/src/main/java/com/facebook/common/util/Hex.java#L68-L83
14,475
facebook/fresco
fbcore/src/main/java/com/facebook/common/util/Hex.java
Hex.decodeHex
public static byte[] decodeHex(String hexString) { int length = hexString.length(); if ((length & 0x01) != 0) { throw new IllegalArgumentException("Odd number of characters."); } boolean badHex = false; byte[] out = new byte[length >> 1]; for (int i = 0, j = 0; j < length; i++) { int c1 = hexString.charAt(j++); if (c1 > 'f') { badHex = true; break; } final byte d1 = DIGITS[c1]; if (d1 == -1) { badHex = true; break; } int c2 = hexString.charAt(j++); if (c2 > 'f') { badHex = true; break; } final byte d2 = DIGITS[c2]; if (d2 == -1) { badHex = true; break; } out[i] = (byte) (d1 << 4 | d2); } if (badHex) { throw new IllegalArgumentException("Invalid hexadecimal digit: " + hexString); } return out; }
java
public static byte[] decodeHex(String hexString) { int length = hexString.length(); if ((length & 0x01) != 0) { throw new IllegalArgumentException("Odd number of characters."); } boolean badHex = false; byte[] out = new byte[length >> 1]; for (int i = 0, j = 0; j < length; i++) { int c1 = hexString.charAt(j++); if (c1 > 'f') { badHex = true; break; } final byte d1 = DIGITS[c1]; if (d1 == -1) { badHex = true; break; } int c2 = hexString.charAt(j++); if (c2 > 'f') { badHex = true; break; } final byte d2 = DIGITS[c2]; if (d2 == -1) { badHex = true; break; } out[i] = (byte) (d1 << 4 | d2); } if (badHex) { throw new IllegalArgumentException("Invalid hexadecimal digit: " + hexString); } return out; }
[ "public", "static", "byte", "[", "]", "decodeHex", "(", "String", "hexString", ")", "{", "int", "length", "=", "hexString", ".", "length", "(", ")", ";", "if", "(", "(", "length", "&", "0x01", ")", "!=", "0", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Odd number of characters.\"", ")", ";", "}", "boolean", "badHex", "=", "false", ";", "byte", "[", "]", "out", "=", "new", "byte", "[", "length", ">>", "1", "]", ";", "for", "(", "int", "i", "=", "0", ",", "j", "=", "0", ";", "j", "<", "length", ";", "i", "++", ")", "{", "int", "c1", "=", "hexString", ".", "charAt", "(", "j", "++", ")", ";", "if", "(", "c1", ">", "'", "'", ")", "{", "badHex", "=", "true", ";", "break", ";", "}", "final", "byte", "d1", "=", "DIGITS", "[", "c1", "]", ";", "if", "(", "d1", "==", "-", "1", ")", "{", "badHex", "=", "true", ";", "break", ";", "}", "int", "c2", "=", "hexString", ".", "charAt", "(", "j", "++", ")", ";", "if", "(", "c2", ">", "'", "'", ")", "{", "badHex", "=", "true", ";", "break", ";", "}", "final", "byte", "d2", "=", "DIGITS", "[", "c2", "]", ";", "if", "(", "d2", "==", "-", "1", ")", "{", "badHex", "=", "true", ";", "break", ";", "}", "out", "[", "i", "]", "=", "(", "byte", ")", "(", "d1", "<<", "4", "|", "d2", ")", ";", "}", "if", "(", "badHex", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Invalid hexadecimal digit: \"", "+", "hexString", ")", ";", "}", "return", "out", ";", "}" ]
Quickly converts a hexadecimal string to a byte array.
[ "Quickly", "converts", "a", "hexadecimal", "string", "to", "a", "byte", "array", "." ]
0b85879d51c5036d5e46e627a6651afefc0b971a
https://github.com/facebook/fresco/blob/0b85879d51c5036d5e46e627a6651afefc0b971a/fbcore/src/main/java/com/facebook/common/util/Hex.java#L88-L130
14,476
facebook/fresco
imagepipeline-backends/imagepipeline-okhttp3/src/main/java/com/facebook/imagepipeline/backends/okhttp3/OkHttpNetworkFetcher.java
OkHttpNetworkFetcher.handleException
private void handleException(final Call call, final Exception e, final Callback callback) { if (call.isCanceled()) { callback.onCancellation(); } else { callback.onFailure(e); } }
java
private void handleException(final Call call, final Exception e, final Callback callback) { if (call.isCanceled()) { callback.onCancellation(); } else { callback.onFailure(e); } }
[ "private", "void", "handleException", "(", "final", "Call", "call", ",", "final", "Exception", "e", ",", "final", "Callback", "callback", ")", "{", "if", "(", "call", ".", "isCanceled", "(", ")", ")", "{", "callback", ".", "onCancellation", "(", ")", ";", "}", "else", "{", "callback", ".", "onFailure", "(", "e", ")", ";", "}", "}" ]
Handles exceptions. <p> OkHttp notifies callers of cancellations via an IOException. If IOException is caught after request cancellation, then the exception is interpreted as successful cancellation and onCancellation is called. Otherwise onFailure is called.
[ "Handles", "exceptions", "." ]
0b85879d51c5036d5e46e627a6651afefc0b971a
https://github.com/facebook/fresco/blob/0b85879d51c5036d5e46e627a6651afefc0b971a/imagepipeline-backends/imagepipeline-okhttp3/src/main/java/com/facebook/imagepipeline/backends/okhttp3/OkHttpNetworkFetcher.java#L215-L221
14,477
facebook/fresco
drawee/src/main/java/com/facebook/drawee/controller/AbstractDraweeController.java
AbstractDraweeController.initialize
protected void initialize(String id, Object callerContext) { init(id, callerContext); mJustConstructed = false; }
java
protected void initialize(String id, Object callerContext) { init(id, callerContext); mJustConstructed = false; }
[ "protected", "void", "initialize", "(", "String", "id", ",", "Object", "callerContext", ")", "{", "init", "(", "id", ",", "callerContext", ")", ";", "mJustConstructed", "=", "false", ";", "}" ]
Initializes this controller with the new id and caller context. This allows for reusing of the existing controller instead of instantiating a new one. This method should be called when the controller is in detached state. @param id unique id for this controller @param callerContext tag and context for this controller
[ "Initializes", "this", "controller", "with", "the", "new", "id", "and", "caller", "context", ".", "This", "allows", "for", "reusing", "of", "the", "existing", "controller", "instead", "of", "instantiating", "a", "new", "one", ".", "This", "method", "should", "be", "called", "when", "the", "controller", "is", "in", "detached", "state", "." ]
0b85879d51c5036d5e46e627a6651afefc0b971a
https://github.com/facebook/fresco/blob/0b85879d51c5036d5e46e627a6651afefc0b971a/drawee/src/main/java/com/facebook/drawee/controller/AbstractDraweeController.java#L119-L122
14,478
facebook/fresco
drawee/src/main/java/com/facebook/drawee/controller/AbstractDraweeController.java
AbstractDraweeController.addControllerListener
public void addControllerListener(ControllerListener<? super INFO> controllerListener) { Preconditions.checkNotNull(controllerListener); if (mControllerListener instanceof InternalForwardingListener) { ((InternalForwardingListener<INFO>) mControllerListener).addListener(controllerListener); return; } if (mControllerListener != null) { mControllerListener = InternalForwardingListener.createInternal( mControllerListener, controllerListener); return; } // Listener only receives <INFO>, it never produces one. // That means if it can accept <? super INFO>, it can very well accept <INFO>. mControllerListener = (ControllerListener<INFO>) controllerListener; }
java
public void addControllerListener(ControllerListener<? super INFO> controllerListener) { Preconditions.checkNotNull(controllerListener); if (mControllerListener instanceof InternalForwardingListener) { ((InternalForwardingListener<INFO>) mControllerListener).addListener(controllerListener); return; } if (mControllerListener != null) { mControllerListener = InternalForwardingListener.createInternal( mControllerListener, controllerListener); return; } // Listener only receives <INFO>, it never produces one. // That means if it can accept <? super INFO>, it can very well accept <INFO>. mControllerListener = (ControllerListener<INFO>) controllerListener; }
[ "public", "void", "addControllerListener", "(", "ControllerListener", "<", "?", "super", "INFO", ">", "controllerListener", ")", "{", "Preconditions", ".", "checkNotNull", "(", "controllerListener", ")", ";", "if", "(", "mControllerListener", "instanceof", "InternalForwardingListener", ")", "{", "(", "(", "InternalForwardingListener", "<", "INFO", ">", ")", "mControllerListener", ")", ".", "addListener", "(", "controllerListener", ")", ";", "return", ";", "}", "if", "(", "mControllerListener", "!=", "null", ")", "{", "mControllerListener", "=", "InternalForwardingListener", ".", "createInternal", "(", "mControllerListener", ",", "controllerListener", ")", ";", "return", ";", "}", "// Listener only receives <INFO>, it never produces one.", "// That means if it can accept <? super INFO>, it can very well accept <INFO>.", "mControllerListener", "=", "(", "ControllerListener", "<", "INFO", ">", ")", "controllerListener", ";", "}" ]
Adds controller listener.
[ "Adds", "controller", "listener", "." ]
0b85879d51c5036d5e46e627a6651afefc0b971a
https://github.com/facebook/fresco/blob/0b85879d51c5036d5e46e627a6651afefc0b971a/drawee/src/main/java/com/facebook/drawee/controller/AbstractDraweeController.java#L259-L274
14,479
facebook/fresco
drawee/src/main/java/com/facebook/drawee/controller/AbstractDraweeController.java
AbstractDraweeController.removeControllerListener
public void removeControllerListener(ControllerListener<? super INFO> controllerListener) { Preconditions.checkNotNull(controllerListener); if (mControllerListener instanceof InternalForwardingListener) { ((InternalForwardingListener<INFO>) mControllerListener).removeListener(controllerListener); return; } if (mControllerListener == controllerListener) { mControllerListener = null; } }
java
public void removeControllerListener(ControllerListener<? super INFO> controllerListener) { Preconditions.checkNotNull(controllerListener); if (mControllerListener instanceof InternalForwardingListener) { ((InternalForwardingListener<INFO>) mControllerListener).removeListener(controllerListener); return; } if (mControllerListener == controllerListener) { mControllerListener = null; } }
[ "public", "void", "removeControllerListener", "(", "ControllerListener", "<", "?", "super", "INFO", ">", "controllerListener", ")", "{", "Preconditions", ".", "checkNotNull", "(", "controllerListener", ")", ";", "if", "(", "mControllerListener", "instanceof", "InternalForwardingListener", ")", "{", "(", "(", "InternalForwardingListener", "<", "INFO", ">", ")", "mControllerListener", ")", ".", "removeListener", "(", "controllerListener", ")", ";", "return", ";", "}", "if", "(", "mControllerListener", "==", "controllerListener", ")", "{", "mControllerListener", "=", "null", ";", "}", "}" ]
Removes controller listener.
[ "Removes", "controller", "listener", "." ]
0b85879d51c5036d5e46e627a6651afefc0b971a
https://github.com/facebook/fresco/blob/0b85879d51c5036d5e46e627a6651afefc0b971a/drawee/src/main/java/com/facebook/drawee/controller/AbstractDraweeController.java#L277-L286
14,480
facebook/fresco
drawee/src/main/java/com/facebook/drawee/drawable/ArrayDrawable.java
ArrayDrawable.getDrawable
@Nullable public Drawable getDrawable(int index) { Preconditions.checkArgument(index >= 0); Preconditions.checkArgument(index < mLayers.length); return mLayers[index]; }
java
@Nullable public Drawable getDrawable(int index) { Preconditions.checkArgument(index >= 0); Preconditions.checkArgument(index < mLayers.length); return mLayers[index]; }
[ "@", "Nullable", "public", "Drawable", "getDrawable", "(", "int", "index", ")", "{", "Preconditions", ".", "checkArgument", "(", "index", ">=", "0", ")", ";", "Preconditions", ".", "checkArgument", "(", "index", "<", "mLayers", ".", "length", ")", ";", "return", "mLayers", "[", "index", "]", ";", "}" ]
Gets the drawable at the specified index. @param index index of drawable to get @return drawable at the specified index
[ "Gets", "the", "drawable", "at", "the", "specified", "index", "." ]
0b85879d51c5036d5e46e627a6651afefc0b971a
https://github.com/facebook/fresco/blob/0b85879d51c5036d5e46e627a6651afefc0b971a/drawee/src/main/java/com/facebook/drawee/drawable/ArrayDrawable.java#L75-L80
14,481
facebook/fresco
imagepipeline/src/main/java/com/facebook/imagepipeline/producers/LocalContentUriThumbnailFetchProducer.java
LocalContentUriThumbnailFetchProducer.getThumbnail
private @Nullable EncodedImage getThumbnail(ResizeOptions resizeOptions, int imageId) throws IOException { int thumbnailKind = getThumbnailKind(resizeOptions); if (thumbnailKind == NO_THUMBNAIL) { return null; } Cursor thumbnailCursor = null; try { thumbnailCursor = MediaStore.Images.Thumbnails.queryMiniThumbnail( mContentResolver, imageId, thumbnailKind, THUMBNAIL_PROJECTION); if (thumbnailCursor == null) { return null; } thumbnailCursor.moveToFirst(); if (thumbnailCursor.getCount() > 0) { final String thumbnailUri = thumbnailCursor.getString( thumbnailCursor.getColumnIndex(MediaStore.Images.Thumbnails.DATA)); if (new File(thumbnailUri).exists()) { return getEncodedImage(new FileInputStream(thumbnailUri), getLength(thumbnailUri)); } } } finally { if (thumbnailCursor != null) { thumbnailCursor.close(); } } return null; }
java
private @Nullable EncodedImage getThumbnail(ResizeOptions resizeOptions, int imageId) throws IOException { int thumbnailKind = getThumbnailKind(resizeOptions); if (thumbnailKind == NO_THUMBNAIL) { return null; } Cursor thumbnailCursor = null; try { thumbnailCursor = MediaStore.Images.Thumbnails.queryMiniThumbnail( mContentResolver, imageId, thumbnailKind, THUMBNAIL_PROJECTION); if (thumbnailCursor == null) { return null; } thumbnailCursor.moveToFirst(); if (thumbnailCursor.getCount() > 0) { final String thumbnailUri = thumbnailCursor.getString( thumbnailCursor.getColumnIndex(MediaStore.Images.Thumbnails.DATA)); if (new File(thumbnailUri).exists()) { return getEncodedImage(new FileInputStream(thumbnailUri), getLength(thumbnailUri)); } } } finally { if (thumbnailCursor != null) { thumbnailCursor.close(); } } return null; }
[ "private", "@", "Nullable", "EncodedImage", "getThumbnail", "(", "ResizeOptions", "resizeOptions", ",", "int", "imageId", ")", "throws", "IOException", "{", "int", "thumbnailKind", "=", "getThumbnailKind", "(", "resizeOptions", ")", ";", "if", "(", "thumbnailKind", "==", "NO_THUMBNAIL", ")", "{", "return", "null", ";", "}", "Cursor", "thumbnailCursor", "=", "null", ";", "try", "{", "thumbnailCursor", "=", "MediaStore", ".", "Images", ".", "Thumbnails", ".", "queryMiniThumbnail", "(", "mContentResolver", ",", "imageId", ",", "thumbnailKind", ",", "THUMBNAIL_PROJECTION", ")", ";", "if", "(", "thumbnailCursor", "==", "null", ")", "{", "return", "null", ";", "}", "thumbnailCursor", ".", "moveToFirst", "(", ")", ";", "if", "(", "thumbnailCursor", ".", "getCount", "(", ")", ">", "0", ")", "{", "final", "String", "thumbnailUri", "=", "thumbnailCursor", ".", "getString", "(", "thumbnailCursor", ".", "getColumnIndex", "(", "MediaStore", ".", "Images", ".", "Thumbnails", ".", "DATA", ")", ")", ";", "if", "(", "new", "File", "(", "thumbnailUri", ")", ".", "exists", "(", ")", ")", "{", "return", "getEncodedImage", "(", "new", "FileInputStream", "(", "thumbnailUri", ")", ",", "getLength", "(", "thumbnailUri", ")", ")", ";", "}", "}", "}", "finally", "{", "if", "(", "thumbnailCursor", "!=", "null", ")", "{", "thumbnailCursor", ".", "close", "(", ")", ";", "}", "}", "return", "null", ";", "}" ]
stored thumbnails.
[ "stored", "thumbnails", "." ]
0b85879d51c5036d5e46e627a6651afefc0b971a
https://github.com/facebook/fresco/blob/0b85879d51c5036d5e46e627a6651afefc0b971a/imagepipeline/src/main/java/com/facebook/imagepipeline/producers/LocalContentUriThumbnailFetchProducer.java#L115-L145
14,482
facebook/fresco
imagepipeline/src/main/java/com/facebook/imagepipeline/producers/LocalContentUriThumbnailFetchProducer.java
LocalContentUriThumbnailFetchProducer.getThumbnailKind
private static int getThumbnailKind(ResizeOptions resizeOptions) { if (ThumbnailSizeChecker.isImageBigEnough( MICRO_THUMBNAIL_DIMENSIONS.width(), MICRO_THUMBNAIL_DIMENSIONS.height(), resizeOptions)) { return MediaStore.Images.Thumbnails.MICRO_KIND; } else if (ThumbnailSizeChecker.isImageBigEnough( MINI_THUMBNAIL_DIMENSIONS.width(), MINI_THUMBNAIL_DIMENSIONS.height(), resizeOptions)) { return MediaStore.Images.Thumbnails.MINI_KIND; } else { return NO_THUMBNAIL; } }
java
private static int getThumbnailKind(ResizeOptions resizeOptions) { if (ThumbnailSizeChecker.isImageBigEnough( MICRO_THUMBNAIL_DIMENSIONS.width(), MICRO_THUMBNAIL_DIMENSIONS.height(), resizeOptions)) { return MediaStore.Images.Thumbnails.MICRO_KIND; } else if (ThumbnailSizeChecker.isImageBigEnough( MINI_THUMBNAIL_DIMENSIONS.width(), MINI_THUMBNAIL_DIMENSIONS.height(), resizeOptions)) { return MediaStore.Images.Thumbnails.MINI_KIND; } else { return NO_THUMBNAIL; } }
[ "private", "static", "int", "getThumbnailKind", "(", "ResizeOptions", "resizeOptions", ")", "{", "if", "(", "ThumbnailSizeChecker", ".", "isImageBigEnough", "(", "MICRO_THUMBNAIL_DIMENSIONS", ".", "width", "(", ")", ",", "MICRO_THUMBNAIL_DIMENSIONS", ".", "height", "(", ")", ",", "resizeOptions", ")", ")", "{", "return", "MediaStore", ".", "Images", ".", "Thumbnails", ".", "MICRO_KIND", ";", "}", "else", "if", "(", "ThumbnailSizeChecker", ".", "isImageBigEnough", "(", "MINI_THUMBNAIL_DIMENSIONS", ".", "width", "(", ")", ",", "MINI_THUMBNAIL_DIMENSIONS", ".", "height", "(", ")", ",", "resizeOptions", ")", ")", "{", "return", "MediaStore", ".", "Images", ".", "Thumbnails", ".", "MINI_KIND", ";", "}", "else", "{", "return", "NO_THUMBNAIL", ";", "}", "}" ]
when scaling it to fit a view will not be significant.
[ "when", "scaling", "it", "to", "fit", "a", "view", "will", "not", "be", "significant", "." ]
0b85879d51c5036d5e46e627a6651afefc0b971a
https://github.com/facebook/fresco/blob/0b85879d51c5036d5e46e627a6651afefc0b971a/imagepipeline/src/main/java/com/facebook/imagepipeline/producers/LocalContentUriThumbnailFetchProducer.java#L151-L165
14,483
facebook/fresco
samples/scrollperf/src/main/java/com/facebook/samples/scrollperf/data/impl/ContentProviderSimpleAdapter.java
ContentProviderSimpleAdapter.getInternalPhotoSimpleAdapter
public static ContentProviderSimpleAdapter getInternalPhotoSimpleAdapter(Context context) { return new ContentProviderSimpleAdapter(MediaStore.Images.Media.INTERNAL_CONTENT_URI, context); }
java
public static ContentProviderSimpleAdapter getInternalPhotoSimpleAdapter(Context context) { return new ContentProviderSimpleAdapter(MediaStore.Images.Media.INTERNAL_CONTENT_URI, context); }
[ "public", "static", "ContentProviderSimpleAdapter", "getInternalPhotoSimpleAdapter", "(", "Context", "context", ")", "{", "return", "new", "ContentProviderSimpleAdapter", "(", "MediaStore", ".", "Images", ".", "Media", ".", "INTERNAL_CONTENT_URI", ",", "context", ")", ";", "}" ]
Creates and returns a SimpleAdapter for Internal Photos @param context The Context @return The SimpleAdapter for local photo
[ "Creates", "and", "returns", "a", "SimpleAdapter", "for", "Internal", "Photos" ]
0b85879d51c5036d5e46e627a6651afefc0b971a
https://github.com/facebook/fresco/blob/0b85879d51c5036d5e46e627a6651afefc0b971a/samples/scrollperf/src/main/java/com/facebook/samples/scrollperf/data/impl/ContentProviderSimpleAdapter.java#L47-L49
14,484
facebook/fresco
samples/scrollperf/src/main/java/com/facebook/samples/scrollperf/data/impl/ContentProviderSimpleAdapter.java
ContentProviderSimpleAdapter.getExternalPhotoSimpleAdapter
public static ContentProviderSimpleAdapter getExternalPhotoSimpleAdapter(Context context) { return new ContentProviderSimpleAdapter(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, context); }
java
public static ContentProviderSimpleAdapter getExternalPhotoSimpleAdapter(Context context) { return new ContentProviderSimpleAdapter(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, context); }
[ "public", "static", "ContentProviderSimpleAdapter", "getExternalPhotoSimpleAdapter", "(", "Context", "context", ")", "{", "return", "new", "ContentProviderSimpleAdapter", "(", "MediaStore", ".", "Images", ".", "Media", ".", "EXTERNAL_CONTENT_URI", ",", "context", ")", ";", "}" ]
Creates and returns a SimpleAdapter for External Photos @param context The Context @return The SimpleAdapter for local photo
[ "Creates", "and", "returns", "a", "SimpleAdapter", "for", "External", "Photos" ]
0b85879d51c5036d5e46e627a6651afefc0b971a
https://github.com/facebook/fresco/blob/0b85879d51c5036d5e46e627a6651afefc0b971a/samples/scrollperf/src/main/java/com/facebook/samples/scrollperf/data/impl/ContentProviderSimpleAdapter.java#L57-L59
14,485
facebook/fresco
samples/comparison/src/main/java/com/facebook/samples/comparison/MainActivity.java
MainActivity.getDisplayHeight
public int getDisplayHeight() { Display display = getWindowManager().getDefaultDisplay(); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB_MR2) { return display.getHeight(); } else { final Point size = new Point(); display.getSize(size); return size.y; } }
java
public int getDisplayHeight() { Display display = getWindowManager().getDefaultDisplay(); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB_MR2) { return display.getHeight(); } else { final Point size = new Point(); display.getSize(size); return size.y; } }
[ "public", "int", "getDisplayHeight", "(", ")", "{", "Display", "display", "=", "getWindowManager", "(", ")", ".", "getDefaultDisplay", "(", ")", ";", "if", "(", "Build", ".", "VERSION", ".", "SDK_INT", "<", "Build", ".", "VERSION_CODES", ".", "HONEYCOMB_MR2", ")", "{", "return", "display", ".", "getHeight", "(", ")", ";", "}", "else", "{", "final", "Point", "size", "=", "new", "Point", "(", ")", ";", "display", ".", "getSize", "(", "size", ")", ";", "return", "size", ".", "y", ";", "}", "}" ]
Determines display's height.
[ "Determines", "display", "s", "height", "." ]
0b85879d51c5036d5e46e627a6651afefc0b971a
https://github.com/facebook/fresco/blob/0b85879d51c5036d5e46e627a6651afefc0b971a/samples/comparison/src/main/java/com/facebook/samples/comparison/MainActivity.java#L503-L512
14,486
facebook/fresco
imagepipeline-base/src/main/java/com/facebook/imageformat/ImageFormatCheckerUtils.java
ImageFormatCheckerUtils.asciiBytes
public static byte[] asciiBytes(String value) { Preconditions.checkNotNull(value); try { return value.getBytes("ASCII"); } catch (UnsupportedEncodingException uee) { // won't happen throw new RuntimeException("ASCII not found!", uee); } }
java
public static byte[] asciiBytes(String value) { Preconditions.checkNotNull(value); try { return value.getBytes("ASCII"); } catch (UnsupportedEncodingException uee) { // won't happen throw new RuntimeException("ASCII not found!", uee); } }
[ "public", "static", "byte", "[", "]", "asciiBytes", "(", "String", "value", ")", "{", "Preconditions", ".", "checkNotNull", "(", "value", ")", ";", "try", "{", "return", "value", ".", "getBytes", "(", "\"ASCII\"", ")", ";", "}", "catch", "(", "UnsupportedEncodingException", "uee", ")", "{", "// won't happen", "throw", "new", "RuntimeException", "(", "\"ASCII not found!\"", ",", "uee", ")", ";", "}", "}" ]
Helper method that transforms provided string into it's byte representation using ASCII encoding. @param value the string to use @return byte array representing ascii encoded value
[ "Helper", "method", "that", "transforms", "provided", "string", "into", "it", "s", "byte", "representation", "using", "ASCII", "encoding", "." ]
0b85879d51c5036d5e46e627a6651afefc0b971a
https://github.com/facebook/fresco/blob/0b85879d51c5036d5e46e627a6651afefc0b971a/imagepipeline-base/src/main/java/com/facebook/imageformat/ImageFormatCheckerUtils.java#L24-L32
14,487
facebook/fresco
imagepipeline-base/src/main/java/com/facebook/imageformat/ImageFormatCheckerUtils.java
ImageFormatCheckerUtils.startsWithPattern
public static boolean startsWithPattern( final byte[] byteArray, final byte[] pattern) { Preconditions.checkNotNull(byteArray); Preconditions.checkNotNull(pattern); if (pattern.length > byteArray.length) { return false; } for (int i = 0; i < pattern.length; ++i) { if (byteArray[i] != pattern[i]) { return false; } } return true; }
java
public static boolean startsWithPattern( final byte[] byteArray, final byte[] pattern) { Preconditions.checkNotNull(byteArray); Preconditions.checkNotNull(pattern); if (pattern.length > byteArray.length) { return false; } for (int i = 0; i < pattern.length; ++i) { if (byteArray[i] != pattern[i]) { return false; } } return true; }
[ "public", "static", "boolean", "startsWithPattern", "(", "final", "byte", "[", "]", "byteArray", ",", "final", "byte", "[", "]", "pattern", ")", "{", "Preconditions", ".", "checkNotNull", "(", "byteArray", ")", ";", "Preconditions", ".", "checkNotNull", "(", "pattern", ")", ";", "if", "(", "pattern", ".", "length", ">", "byteArray", ".", "length", ")", "{", "return", "false", ";", "}", "for", "(", "int", "i", "=", "0", ";", "i", "<", "pattern", ".", "length", ";", "++", "i", ")", "{", "if", "(", "byteArray", "[", "i", "]", "!=", "pattern", "[", "i", "]", ")", "{", "return", "false", ";", "}", "}", "return", "true", ";", "}" ]
Checks if byteArray interpreted as sequence of bytes starts with pattern starting at position equal to offset. @param byteArray the byte array to be checked @param pattern the pattern to check @return true if byteArray starts with pattern
[ "Checks", "if", "byteArray", "interpreted", "as", "sequence", "of", "bytes", "starts", "with", "pattern", "starting", "at", "position", "equal", "to", "offset", "." ]
0b85879d51c5036d5e46e627a6651afefc0b971a
https://github.com/facebook/fresco/blob/0b85879d51c5036d5e46e627a6651afefc0b971a/imagepipeline-base/src/main/java/com/facebook/imageformat/ImageFormatCheckerUtils.java#L41-L57
14,488
facebook/fresco
imagepipeline-base/src/main/java/com/facebook/imageformat/ImageFormatCheckerUtils.java
ImageFormatCheckerUtils.indexOfPattern
public static int indexOfPattern( final byte[] byteArray, final int byteArrayLen, final byte[] pattern, final int patternLen) { Preconditions.checkNotNull(byteArray); Preconditions.checkNotNull(pattern); if (patternLen > byteArrayLen) { return -1; } byte first = pattern[0]; int max = byteArrayLen - patternLen; for (int i = 0; i <= max; i++) { // Look for first byte if (byteArray[i] != first) { while (++i <= max && byteArray[i] != first) { } } // Found first byte, now look for the rest if (i <= max) { int j = i + 1; int end = j + patternLen - 1; for (int k = 1; j < end && byteArray[j] == pattern[k]; j++, k++) { } if (j == end) { // found whole pattern return i; } } } return -1; }
java
public static int indexOfPattern( final byte[] byteArray, final int byteArrayLen, final byte[] pattern, final int patternLen) { Preconditions.checkNotNull(byteArray); Preconditions.checkNotNull(pattern); if (patternLen > byteArrayLen) { return -1; } byte first = pattern[0]; int max = byteArrayLen - patternLen; for (int i = 0; i <= max; i++) { // Look for first byte if (byteArray[i] != first) { while (++i <= max && byteArray[i] != first) { } } // Found first byte, now look for the rest if (i <= max) { int j = i + 1; int end = j + patternLen - 1; for (int k = 1; j < end && byteArray[j] == pattern[k]; j++, k++) { } if (j == end) { // found whole pattern return i; } } } return -1; }
[ "public", "static", "int", "indexOfPattern", "(", "final", "byte", "[", "]", "byteArray", ",", "final", "int", "byteArrayLen", ",", "final", "byte", "[", "]", "pattern", ",", "final", "int", "patternLen", ")", "{", "Preconditions", ".", "checkNotNull", "(", "byteArray", ")", ";", "Preconditions", ".", "checkNotNull", "(", "pattern", ")", ";", "if", "(", "patternLen", ">", "byteArrayLen", ")", "{", "return", "-", "1", ";", "}", "byte", "first", "=", "pattern", "[", "0", "]", ";", "int", "max", "=", "byteArrayLen", "-", "patternLen", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<=", "max", ";", "i", "++", ")", "{", "// Look for first byte", "if", "(", "byteArray", "[", "i", "]", "!=", "first", ")", "{", "while", "(", "++", "i", "<=", "max", "&&", "byteArray", "[", "i", "]", "!=", "first", ")", "{", "}", "}", "// Found first byte, now look for the rest", "if", "(", "i", "<=", "max", ")", "{", "int", "j", "=", "i", "+", "1", ";", "int", "end", "=", "j", "+", "patternLen", "-", "1", ";", "for", "(", "int", "k", "=", "1", ";", "j", "<", "end", "&&", "byteArray", "[", "j", "]", "==", "pattern", "[", "k", "]", ";", "j", "++", ",", "k", "++", ")", "{", "}", "if", "(", "j", "==", "end", ")", "{", "// found whole pattern", "return", "i", ";", "}", "}", "}", "return", "-", "1", ";", "}" ]
Checks if byteArray interpreted as sequence of bytes contains the pattern. @param byteArray the byte array to be checked @param pattern the pattern to check @return index of beginning of pattern, if found; otherwise -1
[ "Checks", "if", "byteArray", "interpreted", "as", "sequence", "of", "bytes", "contains", "the", "pattern", "." ]
0b85879d51c5036d5e46e627a6651afefc0b971a
https://github.com/facebook/fresco/blob/0b85879d51c5036d5e46e627a6651afefc0b971a/imagepipeline-base/src/main/java/com/facebook/imageformat/ImageFormatCheckerUtils.java#L65-L100
14,489
facebook/fresco
samples/comparison/src/main/java/com/facebook/samples/comparison/instrumentation/Instrumentation.java
Instrumentation.onDraw
public void onDraw(final Canvas canvas) { mPaint.setColor(0xC0000000); mTextRect.set(0, 0, mView.getWidth(), 35); canvas.drawRect(mTextRect, mPaint); mPaint.setColor(Color.WHITE); canvas.drawText("[" + mTag + "]", 10, 15, mPaint); String message = "Not started"; switch (mState) { case STARTED: message = "Loading..."; break; case SUCCESS: message = "Loaded after " + (mFinishTime - mStartTime) + "ms"; break; case FAILURE: message = "Failed after " + (mFinishTime - mStartTime) + "ms"; break; case CANCELLATION: message = "Cancelled after " + (mFinishTime - mStartTime) + "ms"; break; } canvas.drawText(message, 10, 30, mPaint); }
java
public void onDraw(final Canvas canvas) { mPaint.setColor(0xC0000000); mTextRect.set(0, 0, mView.getWidth(), 35); canvas.drawRect(mTextRect, mPaint); mPaint.setColor(Color.WHITE); canvas.drawText("[" + mTag + "]", 10, 15, mPaint); String message = "Not started"; switch (mState) { case STARTED: message = "Loading..."; break; case SUCCESS: message = "Loaded after " + (mFinishTime - mStartTime) + "ms"; break; case FAILURE: message = "Failed after " + (mFinishTime - mStartTime) + "ms"; break; case CANCELLATION: message = "Cancelled after " + (mFinishTime - mStartTime) + "ms"; break; } canvas.drawText(message, 10, 30, mPaint); }
[ "public", "void", "onDraw", "(", "final", "Canvas", "canvas", ")", "{", "mPaint", ".", "setColor", "(", "0xC0000000", ")", ";", "mTextRect", ".", "set", "(", "0", ",", "0", ",", "mView", ".", "getWidth", "(", ")", ",", "35", ")", ";", "canvas", ".", "drawRect", "(", "mTextRect", ",", "mPaint", ")", ";", "mPaint", ".", "setColor", "(", "Color", ".", "WHITE", ")", ";", "canvas", ".", "drawText", "(", "\"[\"", "+", "mTag", "+", "\"]\"", ",", "10", ",", "15", ",", "mPaint", ")", ";", "String", "message", "=", "\"Not started\"", ";", "switch", "(", "mState", ")", "{", "case", "STARTED", ":", "message", "=", "\"Loading...\"", ";", "break", ";", "case", "SUCCESS", ":", "message", "=", "\"Loaded after \"", "+", "(", "mFinishTime", "-", "mStartTime", ")", "+", "\"ms\"", ";", "break", ";", "case", "FAILURE", ":", "message", "=", "\"Failed after \"", "+", "(", "mFinishTime", "-", "mStartTime", ")", "+", "\"ms\"", ";", "break", ";", "case", "CANCELLATION", ":", "message", "=", "\"Cancelled after \"", "+", "(", "mFinishTime", "-", "mStartTime", ")", "+", "\"ms\"", ";", "break", ";", "}", "canvas", ".", "drawText", "(", "message", ",", "10", ",", "30", ",", "mPaint", ")", ";", "}" ]
Draws overlay with request state for easier visual inspection.
[ "Draws", "overlay", "with", "request", "state", "for", "easier", "visual", "inspection", "." ]
0b85879d51c5036d5e46e627a6651afefc0b971a
https://github.com/facebook/fresco/blob/0b85879d51c5036d5e46e627a6651afefc0b971a/samples/comparison/src/main/java/com/facebook/samples/comparison/instrumentation/Instrumentation.java#L105-L129
14,490
facebook/fresco
imagepipeline-base/src/main/java/com/facebook/imageutils/WebpUtil.java
WebpUtil.getVP8Dimension
private static @Nullable Pair<Integer, Integer> getVP8Dimension(final InputStream is) throws IOException { // We need to skip 7 bytes is.skip(7); // And then check the signature final short sign1 = getShort(is); final short sign2 = getShort(is); final short sign3 = getShort(is); if (sign1 != 0x9D || sign2 != 0x01 || sign3 != 0x2A) { // Signature error return null; } // We read the dimensions return new Pair<>(get2BytesAsInt(is), get2BytesAsInt(is)); }
java
private static @Nullable Pair<Integer, Integer> getVP8Dimension(final InputStream is) throws IOException { // We need to skip 7 bytes is.skip(7); // And then check the signature final short sign1 = getShort(is); final short sign2 = getShort(is); final short sign3 = getShort(is); if (sign1 != 0x9D || sign2 != 0x01 || sign3 != 0x2A) { // Signature error return null; } // We read the dimensions return new Pair<>(get2BytesAsInt(is), get2BytesAsInt(is)); }
[ "private", "static", "@", "Nullable", "Pair", "<", "Integer", ",", "Integer", ">", "getVP8Dimension", "(", "final", "InputStream", "is", ")", "throws", "IOException", "{", "// We need to skip 7 bytes", "is", ".", "skip", "(", "7", ")", ";", "// And then check the signature", "final", "short", "sign1", "=", "getShort", "(", "is", ")", ";", "final", "short", "sign2", "=", "getShort", "(", "is", ")", ";", "final", "short", "sign3", "=", "getShort", "(", "is", ")", ";", "if", "(", "sign1", "!=", "0x9D", "||", "sign2", "!=", "0x01", "||", "sign3", "!=", "0x2A", ")", "{", "// Signature error", "return", "null", ";", "}", "// We read the dimensions", "return", "new", "Pair", "<>", "(", "get2BytesAsInt", "(", "is", ")", ",", "get2BytesAsInt", "(", "is", ")", ")", ";", "}" ]
We manage the Simple WebP case @param is The InputStream we're reading @return The dimensions if any @throws IOException In case or error reading from the InputStream
[ "We", "manage", "the", "Simple", "WebP", "case" ]
0b85879d51c5036d5e46e627a6651afefc0b971a
https://github.com/facebook/fresco/blob/0b85879d51c5036d5e46e627a6651afefc0b971a/imagepipeline-base/src/main/java/com/facebook/imageutils/WebpUtil.java#L94-L108
14,491
facebook/fresco
imagepipeline-base/src/main/java/com/facebook/imageutils/WebpUtil.java
WebpUtil.getVP8LDimension
private static @Nullable Pair<Integer, Integer> getVP8LDimension(final InputStream is) throws IOException { // Skip 4 bytes getInt(is); //We have a check here final byte check = getByte(is); if (check != 0x2F) { return null; } int data1 = ((byte) is.read()) & 0xFF; int data2 = ((byte) is.read()) & 0xFF; int data3 = ((byte) is.read()) & 0xFF; int data4 = ((byte) is.read()) & 0xFF; // In this case the bits for size are 14!!! The sizes are -1!!! final int width = ((data2 & 0x3F) << 8 | data1) + 1; final int height = ((data4 & 0x0F) << 10 | data3 << 2 | (data2 & 0xC0) >> 6) + 1; return new Pair<>(width, height); }
java
private static @Nullable Pair<Integer, Integer> getVP8LDimension(final InputStream is) throws IOException { // Skip 4 bytes getInt(is); //We have a check here final byte check = getByte(is); if (check != 0x2F) { return null; } int data1 = ((byte) is.read()) & 0xFF; int data2 = ((byte) is.read()) & 0xFF; int data3 = ((byte) is.read()) & 0xFF; int data4 = ((byte) is.read()) & 0xFF; // In this case the bits for size are 14!!! The sizes are -1!!! final int width = ((data2 & 0x3F) << 8 | data1) + 1; final int height = ((data4 & 0x0F) << 10 | data3 << 2 | (data2 & 0xC0) >> 6) + 1; return new Pair<>(width, height); }
[ "private", "static", "@", "Nullable", "Pair", "<", "Integer", ",", "Integer", ">", "getVP8LDimension", "(", "final", "InputStream", "is", ")", "throws", "IOException", "{", "// Skip 4 bytes", "getInt", "(", "is", ")", ";", "//We have a check here", "final", "byte", "check", "=", "getByte", "(", "is", ")", ";", "if", "(", "check", "!=", "0x2F", ")", "{", "return", "null", ";", "}", "int", "data1", "=", "(", "(", "byte", ")", "is", ".", "read", "(", ")", ")", "&", "0xFF", ";", "int", "data2", "=", "(", "(", "byte", ")", "is", ".", "read", "(", ")", ")", "&", "0xFF", ";", "int", "data3", "=", "(", "(", "byte", ")", "is", ".", "read", "(", ")", ")", "&", "0xFF", ";", "int", "data4", "=", "(", "(", "byte", ")", "is", ".", "read", "(", ")", ")", "&", "0xFF", ";", "// In this case the bits for size are 14!!! The sizes are -1!!!", "final", "int", "width", "=", "(", "(", "data2", "&", "0x3F", ")", "<<", "8", "|", "data1", ")", "+", "1", ";", "final", "int", "height", "=", "(", "(", "data4", "&", "0x0F", ")", "<<", "10", "|", "data3", "<<", "2", "|", "(", "data2", "&", "0xC0", ")", ">>", "6", ")", "+", "1", ";", "return", "new", "Pair", "<>", "(", "width", ",", "height", ")", ";", "}" ]
We manage the Lossless WebP case @param is The InputStream we're reading @return The dimensions if any @throws IOException In case or error reading from the InputStream
[ "We", "manage", "the", "Lossless", "WebP", "case" ]
0b85879d51c5036d5e46e627a6651afefc0b971a
https://github.com/facebook/fresco/blob/0b85879d51c5036d5e46e627a6651afefc0b971a/imagepipeline-base/src/main/java/com/facebook/imageutils/WebpUtil.java#L117-L134
14,492
facebook/fresco
imagepipeline-base/src/main/java/com/facebook/imageutils/WebpUtil.java
WebpUtil.getVP8XDimension
private static Pair<Integer, Integer> getVP8XDimension(final InputStream is) throws IOException { // We have to skip 8 bytes is.skip(8); // Read 3 bytes for width and height return new Pair<>(read3Bytes(is) + 1, read3Bytes(is) + 1); }
java
private static Pair<Integer, Integer> getVP8XDimension(final InputStream is) throws IOException { // We have to skip 8 bytes is.skip(8); // Read 3 bytes for width and height return new Pair<>(read3Bytes(is) + 1, read3Bytes(is) + 1); }
[ "private", "static", "Pair", "<", "Integer", ",", "Integer", ">", "getVP8XDimension", "(", "final", "InputStream", "is", ")", "throws", "IOException", "{", "// We have to skip 8 bytes", "is", ".", "skip", "(", "8", ")", ";", "// Read 3 bytes for width and height", "return", "new", "Pair", "<>", "(", "read3Bytes", "(", "is", ")", "+", "1", ",", "read3Bytes", "(", "is", ")", "+", "1", ")", ";", "}" ]
We manage the Extended WebP case @param is The InputStream we're reading @return The dimensions if any @throws IOException In case or error reading from the InputStream
[ "We", "manage", "the", "Extended", "WebP", "case" ]
0b85879d51c5036d5e46e627a6651afefc0b971a
https://github.com/facebook/fresco/blob/0b85879d51c5036d5e46e627a6651afefc0b971a/imagepipeline-base/src/main/java/com/facebook/imageutils/WebpUtil.java#L143-L148
14,493
facebook/fresco
imagepipeline-base/src/main/java/com/facebook/imageutils/WebpUtil.java
WebpUtil.compare
private static boolean compare(byte[] what, String with) { if (what.length != with.length()) { return false; } for (int i = 0; i < what.length; i++) { if (with.charAt(i) != what[i]) { return false; } } return true; }
java
private static boolean compare(byte[] what, String with) { if (what.length != with.length()) { return false; } for (int i = 0; i < what.length; i++) { if (with.charAt(i) != what[i]) { return false; } } return true; }
[ "private", "static", "boolean", "compare", "(", "byte", "[", "]", "what", ",", "String", "with", ")", "{", "if", "(", "what", ".", "length", "!=", "with", ".", "length", "(", ")", ")", "{", "return", "false", ";", "}", "for", "(", "int", "i", "=", "0", ";", "i", "<", "what", ".", "length", ";", "i", "++", ")", "{", "if", "(", "with", ".", "charAt", "(", "i", ")", "!=", "what", "[", "i", "]", ")", "{", "return", "false", ";", "}", "}", "return", "true", ";", "}" ]
Compares some bytes with the text we're expecting @param what The bytes to compare @param with The string those bytes should contains @return True if they match and false otherwise
[ "Compares", "some", "bytes", "with", "the", "text", "we", "re", "expecting" ]
0b85879d51c5036d5e46e627a6651afefc0b971a
https://github.com/facebook/fresco/blob/0b85879d51c5036d5e46e627a6651afefc0b971a/imagepipeline-base/src/main/java/com/facebook/imageutils/WebpUtil.java#L157-L167
14,494
facebook/fresco
imagepipeline/src/main/java/com/facebook/imagepipeline/memory/BucketsBitmapPool.java
BucketsBitmapPool.alloc
@Override protected Bitmap alloc(int size) { return Bitmap.createBitmap( 1, (int) Math.ceil(size / (double) BitmapUtil.RGB_565_BYTES_PER_PIXEL), Bitmap.Config.RGB_565); }
java
@Override protected Bitmap alloc(int size) { return Bitmap.createBitmap( 1, (int) Math.ceil(size / (double) BitmapUtil.RGB_565_BYTES_PER_PIXEL), Bitmap.Config.RGB_565); }
[ "@", "Override", "protected", "Bitmap", "alloc", "(", "int", "size", ")", "{", "return", "Bitmap", ".", "createBitmap", "(", "1", ",", "(", "int", ")", "Math", ".", "ceil", "(", "size", "/", "(", "double", ")", "BitmapUtil", ".", "RGB_565_BYTES_PER_PIXEL", ")", ",", "Bitmap", ".", "Config", ".", "RGB_565", ")", ";", "}" ]
Allocate a bitmap that has a backing memory allocation of 'size' bytes. This is configuration agnostic so the size is the actual size in bytes of the bitmap. @param size the 'size' in bytes of the bitmap @return a new bitmap with the specified size in memory
[ "Allocate", "a", "bitmap", "that", "has", "a", "backing", "memory", "allocation", "of", "size", "bytes", ".", "This", "is", "configuration", "agnostic", "so", "the", "size", "is", "the", "actual", "size", "in", "bytes", "of", "the", "bitmap", "." ]
0b85879d51c5036d5e46e627a6651afefc0b971a
https://github.com/facebook/fresco/blob/0b85879d51c5036d5e46e627a6651afefc0b971a/imagepipeline/src/main/java/com/facebook/imagepipeline/memory/BucketsBitmapPool.java#L52-L58
14,495
facebook/fresco
drawee/src/main/java/com/facebook/drawee/drawable/RoundedDrawable.java
RoundedDrawable.setRadius
@Override public void setRadius(float radius) { Preconditions.checkState(radius >= 0); Arrays.fill(mCornerRadii, radius); mRadiiNonZero = (radius != 0); mIsPathDirty = true; invalidateSelf(); }
java
@Override public void setRadius(float radius) { Preconditions.checkState(radius >= 0); Arrays.fill(mCornerRadii, radius); mRadiiNonZero = (radius != 0); mIsPathDirty = true; invalidateSelf(); }
[ "@", "Override", "public", "void", "setRadius", "(", "float", "radius", ")", "{", "Preconditions", ".", "checkState", "(", "radius", ">=", "0", ")", ";", "Arrays", ".", "fill", "(", "mCornerRadii", ",", "radius", ")", ";", "mRadiiNonZero", "=", "(", "radius", "!=", "0", ")", ";", "mIsPathDirty", "=", "true", ";", "invalidateSelf", "(", ")", ";", "}" ]
Specify radius for the corners of the rectangle. If this is > 0, then the drawable is drawn in a round-rectangle, rather than a rectangle. @param radius the radius for the corners of the rectangle
[ "Specify", "radius", "for", "the", "corners", "of", "the", "rectangle", ".", "If", "this", "is", ">", "0", "then", "the", "drawable", "is", "drawn", "in", "a", "round", "-", "rectangle", "rather", "than", "a", "rectangle", "." ]
0b85879d51c5036d5e46e627a6651afefc0b971a
https://github.com/facebook/fresco/blob/0b85879d51c5036d5e46e627a6651afefc0b971a/drawee/src/main/java/com/facebook/drawee/drawable/RoundedDrawable.java#L101-L108
14,496
facebook/fresco
drawee/src/main/java/com/facebook/drawee/drawable/RoundedDrawable.java
RoundedDrawable.setPadding
@Override public void setPadding(float padding) { if (mPadding != padding) { mPadding = padding; mIsPathDirty = true; invalidateSelf(); } }
java
@Override public void setPadding(float padding) { if (mPadding != padding) { mPadding = padding; mIsPathDirty = true; invalidateSelf(); } }
[ "@", "Override", "public", "void", "setPadding", "(", "float", "padding", ")", "{", "if", "(", "mPadding", "!=", "padding", ")", "{", "mPadding", "=", "padding", ";", "mIsPathDirty", "=", "true", ";", "invalidateSelf", "(", ")", ";", "}", "}" ]
Sets the padding for the bitmap. @param padding
[ "Sets", "the", "padding", "for", "the", "bitmap", "." ]
0b85879d51c5036d5e46e627a6651afefc0b971a
https://github.com/facebook/fresco/blob/0b85879d51c5036d5e46e627a6651afefc0b971a/drawee/src/main/java/com/facebook/drawee/drawable/RoundedDrawable.java#L170-L177
14,497
facebook/fresco
drawee/src/main/java/com/facebook/drawee/drawable/RoundedDrawable.java
RoundedDrawable.setScaleDownInsideBorders
@Override public void setScaleDownInsideBorders(boolean scaleDownInsideBorders) { if (mScaleDownInsideBorders != scaleDownInsideBorders) { mScaleDownInsideBorders = scaleDownInsideBorders; mIsPathDirty = true; invalidateSelf(); } }
java
@Override public void setScaleDownInsideBorders(boolean scaleDownInsideBorders) { if (mScaleDownInsideBorders != scaleDownInsideBorders) { mScaleDownInsideBorders = scaleDownInsideBorders; mIsPathDirty = true; invalidateSelf(); } }
[ "@", "Override", "public", "void", "setScaleDownInsideBorders", "(", "boolean", "scaleDownInsideBorders", ")", "{", "if", "(", "mScaleDownInsideBorders", "!=", "scaleDownInsideBorders", ")", "{", "mScaleDownInsideBorders", "=", "scaleDownInsideBorders", ";", "mIsPathDirty", "=", "true", ";", "invalidateSelf", "(", ")", ";", "}", "}" ]
Sets whether image should be scaled down inside borders. @param scaleDownInsideBorders
[ "Sets", "whether", "image", "should", "be", "scaled", "down", "inside", "borders", "." ]
0b85879d51c5036d5e46e627a6651afefc0b971a
https://github.com/facebook/fresco/blob/0b85879d51c5036d5e46e627a6651afefc0b971a/drawee/src/main/java/com/facebook/drawee/drawable/RoundedDrawable.java#L190-L197
14,498
facebook/fresco
samples/showcase/src/main/java/com/facebook/fresco/samples/showcase/imagepipeline/ImagePipelineBitmapFactoryFragment.java
ImagePipelineBitmapFactoryFragment.createRainbowBitmap
private CloseableReference<Bitmap> createRainbowBitmap() { final int w = 256; final int h = 256; mOriginalBitmap = mPlatformBitmapFactory.createBitmap(w, h, Bitmap.Config.ARGB_8888); final int[] colors = new int[w * h]; for (int i = 0; i < w; i++) { for (int j = 0; j < h; j++) { final float hue = 360f * j / (float) w; final float saturation = 2f * (h - i) / (float) h; final float value = 1; colors[i * h + j] = Color.HSVToColor(255, new float[]{hue, saturation, value}); } } mOriginalBitmap.get().setPixels(colors, 0, w, 0, 0, w, h); return mOriginalBitmap; }
java
private CloseableReference<Bitmap> createRainbowBitmap() { final int w = 256; final int h = 256; mOriginalBitmap = mPlatformBitmapFactory.createBitmap(w, h, Bitmap.Config.ARGB_8888); final int[] colors = new int[w * h]; for (int i = 0; i < w; i++) { for (int j = 0; j < h; j++) { final float hue = 360f * j / (float) w; final float saturation = 2f * (h - i) / (float) h; final float value = 1; colors[i * h + j] = Color.HSVToColor(255, new float[]{hue, saturation, value}); } } mOriginalBitmap.get().setPixels(colors, 0, w, 0, 0, w, h); return mOriginalBitmap; }
[ "private", "CloseableReference", "<", "Bitmap", ">", "createRainbowBitmap", "(", ")", "{", "final", "int", "w", "=", "256", ";", "final", "int", "h", "=", "256", ";", "mOriginalBitmap", "=", "mPlatformBitmapFactory", ".", "createBitmap", "(", "w", ",", "h", ",", "Bitmap", ".", "Config", ".", "ARGB_8888", ")", ";", "final", "int", "[", "]", "colors", "=", "new", "int", "[", "w", "*", "h", "]", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "w", ";", "i", "++", ")", "{", "for", "(", "int", "j", "=", "0", ";", "j", "<", "h", ";", "j", "++", ")", "{", "final", "float", "hue", "=", "360f", "*", "j", "/", "(", "float", ")", "w", ";", "final", "float", "saturation", "=", "2f", "*", "(", "h", "-", "i", ")", "/", "(", "float", ")", "h", ";", "final", "float", "value", "=", "1", ";", "colors", "[", "i", "*", "h", "+", "j", "]", "=", "Color", ".", "HSVToColor", "(", "255", ",", "new", "float", "[", "]", "{", "hue", ",", "saturation", ",", "value", "}", ")", ";", "}", "}", "mOriginalBitmap", ".", "get", "(", ")", ".", "setPixels", "(", "colors", ",", "0", ",", "w", ",", "0", ",", "0", ",", "w", ",", "h", ")", ";", "return", "mOriginalBitmap", ";", "}" ]
Creates a new bitmap with a HSV map at value=1
[ "Creates", "a", "new", "bitmap", "with", "a", "HSV", "map", "at", "value", "=", "1" ]
0b85879d51c5036d5e46e627a6651afefc0b971a
https://github.com/facebook/fresco/blob/0b85879d51c5036d5e46e627a6651afefc0b971a/samples/showcase/src/main/java/com/facebook/fresco/samples/showcase/imagepipeline/ImagePipelineBitmapFactoryFragment.java#L132-L149
14,499
facebook/fresco
samples/animation2/src/main/java/com/facebook/samples/animation2/utils/AnimationBackendUtils.java
AnimationBackendUtils.wrapAnimationBackendWithInactivityCheck
public static AnimationBackend wrapAnimationBackendWithInactivityCheck( final Context context, final AnimationBackend animationBackend) { AnimationBackendDelegateWithInactivityCheck.InactivityListener inactivityListener = new AnimationBackendDelegateWithInactivityCheck.InactivityListener() { @Override public void onInactive() { // Forward the inactive callback to the backend if needed if (animationBackend instanceof AnimationBackendDelegateWithInactivityCheck.InactivityListener) { ((AnimationBackendDelegateWithInactivityCheck.InactivityListener) animationBackend) .onInactive(); } Toast.makeText( context, "Animation backend inactive.", Toast.LENGTH_SHORT) .show(); } }; return createForBackend( animationBackend, inactivityListener, RealtimeSinceBootClock.get(), UiThreadImmediateExecutorService.getInstance()); }
java
public static AnimationBackend wrapAnimationBackendWithInactivityCheck( final Context context, final AnimationBackend animationBackend) { AnimationBackendDelegateWithInactivityCheck.InactivityListener inactivityListener = new AnimationBackendDelegateWithInactivityCheck.InactivityListener() { @Override public void onInactive() { // Forward the inactive callback to the backend if needed if (animationBackend instanceof AnimationBackendDelegateWithInactivityCheck.InactivityListener) { ((AnimationBackendDelegateWithInactivityCheck.InactivityListener) animationBackend) .onInactive(); } Toast.makeText( context, "Animation backend inactive.", Toast.LENGTH_SHORT) .show(); } }; return createForBackend( animationBackend, inactivityListener, RealtimeSinceBootClock.get(), UiThreadImmediateExecutorService.getInstance()); }
[ "public", "static", "AnimationBackend", "wrapAnimationBackendWithInactivityCheck", "(", "final", "Context", "context", ",", "final", "AnimationBackend", "animationBackend", ")", "{", "AnimationBackendDelegateWithInactivityCheck", ".", "InactivityListener", "inactivityListener", "=", "new", "AnimationBackendDelegateWithInactivityCheck", ".", "InactivityListener", "(", ")", "{", "@", "Override", "public", "void", "onInactive", "(", ")", "{", "// Forward the inactive callback to the backend if needed", "if", "(", "animationBackend", "instanceof", "AnimationBackendDelegateWithInactivityCheck", ".", "InactivityListener", ")", "{", "(", "(", "AnimationBackendDelegateWithInactivityCheck", ".", "InactivityListener", ")", "animationBackend", ")", ".", "onInactive", "(", ")", ";", "}", "Toast", ".", "makeText", "(", "context", ",", "\"Animation backend inactive.\"", ",", "Toast", ".", "LENGTH_SHORT", ")", ".", "show", "(", ")", ";", "}", "}", ";", "return", "createForBackend", "(", "animationBackend", ",", "inactivityListener", ",", "RealtimeSinceBootClock", ".", "get", "(", ")", ",", "UiThreadImmediateExecutorService", ".", "getInstance", "(", ")", ")", ";", "}" ]
Wraps the given animation backend with an activity check. When no frame has been drawn for more than 2 seconds, an inactivity toast message will be displayed. @param context the context to be used for displaying the toast message @param animationBackend the backend to wrap with the inactivity check @return the wrapped backend to use
[ "Wraps", "the", "given", "animation", "backend", "with", "an", "activity", "check", ".", "When", "no", "frame", "has", "been", "drawn", "for", "more", "than", "2", "seconds", "an", "inactivity", "toast", "message", "will", "be", "displayed", "." ]
0b85879d51c5036d5e46e627a6651afefc0b971a
https://github.com/facebook/fresco/blob/0b85879d51c5036d5e46e627a6651afefc0b971a/samples/animation2/src/main/java/com/facebook/samples/animation2/utils/AnimationBackendUtils.java#L37-L62