idx int64 0 165k | question stringlengths 73 5.81k | target stringlengths 5 918 |
|---|---|---|
153,900 | private void applyFontToToolbar ( final Toolbar view ) { final CharSequence previousTitle = view . getTitle ( ) ; final CharSequence previousSubtitle = view . getSubtitle ( ) ; view . setTitle ( "uk.co.chrisjenx.calligraphy:toolbar_title" ) ; view . setSubtitle ( "uk.co.chrisjenx.calligraphy:toolbar_subtitle" ) ; final... | Will forcibly set text on the views then remove ones that didn t have copy . |
153,901 | public static Typeface load ( final AssetManager assetManager , final String filePath ) { synchronized ( sCachedFonts ) { try { if ( ! sCachedFonts . containsKey ( filePath ) ) { final Typeface typeface = Typeface . createFromAsset ( assetManager , filePath ) ; sCachedFonts . put ( filePath , typeface ) ; return typefa... | A helper loading a custom font . |
153,902 | public static CalligraphyTypefaceSpan getSpan ( final Typeface typeface ) { if ( typeface == null ) return null ; synchronized ( sCachedSpans ) { if ( ! sCachedSpans . containsKey ( typeface ) ) { final CalligraphyTypefaceSpan span = new CalligraphyTypefaceSpan ( typeface ) ; sCachedSpans . put ( typeface , span ) ; re... | A helper loading custom spans so we don t have to keep creating hundreds of spans . |
153,903 | public static String getScript ( String path ) { StringBuilder sb = new StringBuilder ( ) ; InputStream stream = ScriptUtil . class . getClassLoader ( ) . getResourceAsStream ( path ) ; try ( BufferedReader br = new BufferedReader ( new InputStreamReader ( stream ) ) ) { String str ; while ( ( str = br . readLine ( ) )... | return lua script String |
153,904 | private Object getConnection ( ) { Object connection ; if ( type == RedisToolsConstant . SINGLE ) { RedisConnection redisConnection = jedisConnectionFactory . getConnection ( ) ; connection = redisConnection . getNativeConnection ( ) ; } else { RedisClusterConnection clusterConnection = jedisConnectionFactory . getClus... | get Redis connection |
153,905 | public boolean tryLock ( String key , String request ) { Object connection = getConnection ( ) ; String result ; if ( connection instanceof Jedis ) { result = ( ( Jedis ) connection ) . set ( lockPrefix + key , request , SET_IF_NOT_EXIST , SET_WITH_EXPIRE_TIME , 10 * TIME ) ; ( ( Jedis ) connection ) . close ( ) ; } el... | Non - blocking lock |
153,906 | public void error ( final String msg ) { errors ++ ; if ( ! suppressOutput ) { out . println ( "ERROR: " + msg ) ; } if ( stopOnError ) { throw new IllegalArgumentException ( msg ) ; } } | Record a message signifying an error condition . |
153,907 | public void warning ( final String msg ) { warnings ++ ; if ( ! suppressOutput ) { out . println ( "WARNING: " + msg ) ; } if ( warningsFatal && stopOnError ) { throw new IllegalArgumentException ( msg ) ; } } | Record a message signifying an warning condition . |
153,908 | public static String formatByteOrderEncoding ( final ByteOrder byteOrder , final PrimitiveType primitiveType ) { switch ( primitiveType . size ( ) ) { case 2 : return "SBE_" + byteOrder + "_ENCODE_16" ; case 4 : return "SBE_" + byteOrder + "_ENCODE_32" ; case 8 : return "SBE_" + byteOrder + "_ENCODE_64" ; default : ret... | Return the Cpp98 formatted byte order encoding string to use for a given byte order and primitiveType |
153,909 | public static String formatPropertyName ( final String value ) { String formattedValue = toUpperFirstChar ( value ) ; if ( ValidationUtil . isGolangKeyword ( formattedValue ) ) { final String keywordAppendToken = System . getProperty ( SbeTool . KEYWORD_APPEND_TOKEN ) ; if ( null == keywordAppendToken ) { throw new Ill... | Format a String as a property name . |
153,910 | public static PrimitiveValue parse ( final String value , final int length , final String characterEncoding ) { if ( value . length ( ) > length ) { throw new IllegalStateException ( "value.length=" + value . length ( ) + " greater than length=" + length ) ; } byte [ ] bytes = value . getBytes ( forName ( characterEnco... | Parse constant value string and set representation based on type length and characterEncoding |
153,911 | public byte [ ] byteArrayValue ( final PrimitiveType type ) { if ( representation == Representation . BYTE_ARRAY ) { return byteArrayValue ; } else if ( representation == Representation . LONG && size == 1 && type == PrimitiveType . CHAR ) { byteArrayValueForLong [ 0 ] = ( byte ) longValue ; return byteArrayValueForLon... | Return byte array value for this PrimitiveValue given a particular type |
153,912 | public static void append ( final StringBuilder builder , final String indent , final String line ) { builder . append ( indent ) . append ( line ) . append ( '\n' ) ; } | Shortcut to append a line of generated code |
153,913 | public static String generateTypeJavadoc ( final String indent , final Token typeToken ) { final String description = typeToken . description ( ) ; if ( null == description || description . isEmpty ( ) ) { return "" ; } return indent + "/**\n" + indent + " * " + description + '\n' + indent + " */\n" ; } | Generate the Javadoc comment header for a type . |
153,914 | public static String generateOptionEncodeJavadoc ( final String indent , final Token optionToken ) { final String description = optionToken . description ( ) ; if ( null == description || description . isEmpty ( ) ) { return "" ; } return indent + "/**\n" + indent + " * " + description + '\n' + indent + " *\n" + indent... | Generate the Javadoc comment header for a bitset choice option encode method . |
153,915 | public static String generateFlyweightPropertyJavadoc ( final String indent , final Token propertyToken , final String typeName ) { final String description = propertyToken . description ( ) ; if ( null == description || description . isEmpty ( ) ) { return "" ; } return indent + "/**\n" + indent + " * " + description ... | Generate the Javadoc comment header for flyweight property . |
153,916 | public static Map < Long , Message > findMessages ( final Document document , final XPath xPath , final Map < String , Type > typeByNameMap ) throws Exception { final Map < Long , Message > messageByIdMap = new HashMap < > ( ) ; final ObjectHashSet < String > distinctNames = new ObjectHashSet < > ( ) ; forEach ( ( Node... | Scan XML for all message definitions and save in map |
153,917 | public static void handleError ( final Node node , final String msg ) { final ErrorHandler handler = ( ErrorHandler ) node . getOwnerDocument ( ) . getUserData ( ERROR_HANDLER_KEY ) ; if ( handler == null ) { throw new IllegalStateException ( "ERROR: " + formatLocationInfo ( node ) + msg ) ; } else { handler . error ( ... | Handle an error condition as consequence of parsing . |
153,918 | public static void handleWarning ( final Node node , final String msg ) { final ErrorHandler handler = ( ErrorHandler ) node . getOwnerDocument ( ) . getUserData ( ERROR_HANDLER_KEY ) ; if ( handler == null ) { throw new IllegalStateException ( "WARNING: " + formatLocationInfo ( node ) + msg ) ; } else { handler . warn... | Handle a warning condition as a consequence of parsing . |
153,919 | public static String getAttributeValue ( final Node elementNode , final String attrName ) { final Node attrNode = elementNode . getAttributes ( ) . getNamedItemNS ( null , attrName ) ; if ( attrNode == null || "" . equals ( attrNode . getNodeValue ( ) ) ) { throw new IllegalStateException ( "Element '" + elementNode . ... | Helper function that throws an exception when the attribute is not set . |
153,920 | public static String getAttributeValue ( final Node elementNode , final String attrName , final String defValue ) { final Node attrNode = elementNode . getAttributes ( ) . getNamedItemNS ( null , attrName ) ; if ( attrNode == null ) { return defValue ; } return attrNode . getNodeValue ( ) ; } | Helper function that uses a default value when value not set . |
153,921 | public static void checkForValidName ( final Node node , final String name ) { if ( ! ValidationUtil . isSbeCppName ( name ) ) { handleWarning ( node , "name is not valid for C++: " + name ) ; } if ( ! ValidationUtil . isSbeJavaName ( name ) ) { handleWarning ( node , "name is not valid for Java: " + name ) ; } if ( ! ... | Check name against validity for C ++ and Java naming . Warning if not valid . |
153,922 | private int generateFieldEncodeDecode ( final List < Token > tokens , final char varName , final int currentOffset , final StringBuilder encode , final StringBuilder decode , final StringBuilder rc , final StringBuilder init ) { final Token signalToken = tokens . get ( 0 ) ; final Token encodingToken = tokens . get ( 1... | Returns how many extra tokens to skip over |
153,923 | private void generateGroupProperties ( final StringBuilder sb , final List < Token > tokens , final String prefix ) { for ( int i = 0 , size = tokens . size ( ) ; i < size ; i ++ ) { final Token token = tokens . get ( i ) ; if ( token . signal ( ) == Signal . BEGIN_GROUP ) { final String propertyName = formatPropertyNa... | Recursively traverse groups to create the group properties |
153,924 | private void generateExtensibilityMethods ( final StringBuilder sb , final String typeName , final Token token ) { sb . append ( String . format ( "\nfunc (*%1$s) SbeBlockLength() (blockLength uint) {\n" + "\treturn %2$s\n" + "}\n" + "\nfunc (*%1$s) SbeSchemaVersion() (schemaVersion %3$s) {\n" + "\treturn %4$s\n" + "}\... | of block length and version to check for extensions |
153,925 | public static String formatScopedName ( final CharSequence [ ] scope , final String value ) { return String . join ( "_" , scope ) . toLowerCase ( ) + "_" + formatName ( value ) ; } | Format a String as a struct name prepended with a scope . |
153,926 | public static void main ( final String [ ] args ) throws Exception { if ( args . length == 0 ) { System . err . format ( "Usage: %s <filenames>...%n" , SbeTool . class . getName ( ) ) ; System . exit ( - 1 ) ; } for ( final String fileName : args ) { final Ir ir ; if ( fileName . endsWith ( ".xml" ) ) { final String xs... | Main entry point for the SBE Tool . |
153,927 | public static void validateAgainstSchema ( final String sbeSchemaFilename , final String xsdFilename ) throws Exception { final ParserOptions . Builder optionsBuilder = ParserOptions . builder ( ) . xsdFilename ( System . getProperty ( VALIDATION_XSD ) ) . xIncludeAware ( Boolean . parseBoolean ( System . getProperty (... | Validate the SBE Schema against the XSD . |
153,928 | public static void generate ( final Ir ir , final String outputDirName , final String targetLanguage ) throws Exception { final TargetCodeGenerator targetCodeGenerator = TargetCodeGeneratorLoader . get ( targetLanguage ) ; final CodeGenerator codeGenerator = targetCodeGenerator . newInstance ( ir , outputDirName ) ; co... | Generate SBE encoding and decoding stubs for a target language . |
153,929 | public void makeDataFieldCompositeType ( ) { final EncodedDataType edt = ( EncodedDataType ) containedTypeByNameMap . get ( "varData" ) ; if ( edt != null ) { edt . variableLength ( true ) ; } } | Make this composite type if it has a varData member variable length by making the EncodedDataType with the name varData be variable length . |
153,930 | public void checkForWellFormedGroupSizeEncoding ( final Node node ) { final EncodedDataType blockLengthType = ( EncodedDataType ) containedTypeByNameMap . get ( "blockLength" ) ; final EncodedDataType numInGroupType = ( EncodedDataType ) containedTypeByNameMap . get ( "numInGroup" ) ; if ( blockLengthType == null ) { X... | Check the composite for being a well formed group encodedLength encoding . This means that there are the fields blockLength and numInGroup present . |
153,931 | public void checkForWellFormedVariableLengthDataEncoding ( final Node node ) { final EncodedDataType lengthType = ( EncodedDataType ) containedTypeByNameMap . get ( "length" ) ; if ( lengthType == null ) { XmlSchemaParser . handleError ( node , "composite for variable length data encoding must have \"length\"" ) ; } el... | Check the composite for being a well formed variable length data encoding . This means that there are the fields length and varData present . |
153,932 | public void checkForWellFormedMessageHeader ( final Node node ) { final boolean shouldGenerateInterfaces = Boolean . getBoolean ( JAVA_GENERATE_INTERFACES ) ; final EncodedDataType blockLengthType = ( EncodedDataType ) containedTypeByNameMap . get ( "blockLength" ) ; final EncodedDataType templateIdType = ( EncodedData... | Check the composite for being a well formed message headerStructure encoding . This means that there are the fields blockLength templateId and version present . |
153,933 | public void checkForValidOffsets ( final Node node ) { int offset = 0 ; for ( final Type edt : containedTypeByNameMap . values ( ) ) { final int offsetAttribute = edt . offsetAttribute ( ) ; if ( - 1 != offsetAttribute ) { if ( offsetAttribute < offset ) { XmlSchemaParser . handleError ( node , String . format ( "compo... | Check the composite for any specified offsets and validate they are correctly specified . |
153,934 | public static Token findFirst ( final String name , final List < Token > tokens , final int index ) { for ( int i = index , size = tokens . size ( ) ; i < size ; i ++ ) { final Token token = tokens . get ( i ) ; if ( token . name ( ) . equals ( name ) ) { return token ; } } throw new IllegalStateException ( "name not f... | Find the first token with a given name from an index inclusive . |
153,935 | public int getTemplateId ( final DirectBuffer buffer , final int bufferOffset ) { return Types . getInt ( buffer , bufferOffset + templateIdOffset , templateIdType , templateIdByteOrder ) ; } | Get the template id from the message header . |
153,936 | public int getSchemaId ( final DirectBuffer buffer , final int bufferOffset ) { return Types . getInt ( buffer , bufferOffset + schemaIdOffset , schemaIdType , schemaIdByteOrder ) ; } | Get the schema id number from the message header . |
153,937 | public int getSchemaVersion ( final DirectBuffer buffer , final int bufferOffset ) { return Types . getInt ( buffer , bufferOffset + schemaVersionOffset , schemaVersionType , schemaVersionByteOrder ) ; } | Get the schema version number from the message header . |
153,938 | public int getBlockLength ( final DirectBuffer buffer , final int bufferOffset ) { return Types . getInt ( buffer , bufferOffset + blockLengthOffset , blockLengthType , blockLengthByteOrder ) ; } | Get the block length of the root block in the message . |
153,939 | public static void initialize ( AlbumConfig albumConfig ) { if ( sAlbumConfig == null ) sAlbumConfig = albumConfig ; else Log . w ( "Album" , new IllegalStateException ( "Illegal operation, only allowed to configure once." ) ) ; } | Initialize Album . |
153,940 | public static AlbumConfig getAlbumConfig ( ) { if ( sAlbumConfig == null ) { sAlbumConfig = AlbumConfig . newBuilder ( null ) . build ( ) ; } return sAlbumConfig ; } | Get the album configuration . |
153,941 | public static Camera < ImageCameraWrapper , VideoCameraWrapper > camera ( android . support . v4 . app . Fragment fragment ) { return new AlbumCamera ( fragment . getContext ( ) ) ; } | Open the camera from the activity . |
153,942 | public static Choice < ImageMultipleWrapper , ImageSingleWrapper > image ( android . support . v4 . app . Fragment fragment ) { return new ImageChoice ( fragment . getContext ( ) ) ; } | Select images . |
153,943 | public static Choice < VideoMultipleWrapper , VideoSingleWrapper > video ( android . support . v4 . app . Fragment fragment ) { return new VideoChoice ( fragment . getContext ( ) ) ; } | Select videos . |
153,944 | public static Choice < AlbumMultipleWrapper , AlbumSingleWrapper > album ( android . support . v4 . app . Fragment fragment ) { return new AlbumChoice ( fragment . getContext ( ) ) ; } | Select images and videos . |
153,945 | public ArrayList < AlbumFolder > getAllVideo ( ) { Map < String , AlbumFolder > albumFolderMap = new HashMap < > ( ) ; AlbumFolder allFileFolder = new AlbumFolder ( ) ; allFileFolder . setChecked ( true ) ; allFileFolder . setName ( mContext . getString ( R . string . album_all_videos ) ) ; scanVideoFile ( albumFolderM... | Scan the list of videos in the library . |
153,946 | public void setupViews ( Widget widget ) { if ( widget . getUiStyle ( ) == Widget . STYLE_LIGHT ) { int color = ContextCompat . getColor ( getContext ( ) , R . color . albumLoadingDark ) ; mProgressBar . setColorFilter ( color ) ; } else { mProgressBar . setColorFilter ( widget . getToolBarColor ( ) ) ; } } | Set some properties of the view . |
153,947 | public Returner currentPosition ( @ IntRange ( from = 0 , to = Integer . MAX_VALUE ) int currentPosition ) { this . mCurrentPosition = currentPosition ; return ( Returner ) this ; } | Set the show position of List . |
153,948 | @ RequiresApi ( api = Build . VERSION_CODES . LOLLIPOP ) public static void invasionStatusBar ( Window window ) { View decorView = window . getDecorView ( ) ; decorView . setSystemUiVisibility ( decorView . getSystemUiVisibility ( ) | View . SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View . SYSTEM_UI_FLAG_LAYOUT_STABLE ) ; win... | Set the content layout full the StatusBar but do not hide StatusBar . |
153,949 | public static boolean setStatusBarDarkFont ( Window window , boolean darkFont ) { if ( setMIUIStatusBarFont ( window , darkFont ) ) { setDefaultStatusBarFont ( window , darkFont ) ; return true ; } else if ( setMeizuStatusBarFont ( window , darkFont ) ) { setDefaultStatusBarFont ( window , darkFont ) ; return true ; } ... | Set the status bar to dark . |
153,950 | private static void setImageViewScaleTypeMatrix ( ImageView imageView ) { if ( null != imageView && ! ( imageView instanceof IPhotoView ) ) { if ( ! ScaleType . MATRIX . equals ( imageView . getScaleType ( ) ) ) { imageView . setScaleType ( ScaleType . MATRIX ) ; } } } | Sets the ImageView s ScaleType to Matrix . |
153,951 | private void updateBaseMatrix ( Drawable d ) { ImageView imageView = getImageView ( ) ; if ( null == imageView || null == d ) { return ; } final float viewWidth = getImageViewWidth ( imageView ) ; final float viewHeight = getImageViewHeight ( imageView ) ; final int drawableWidth = d . getIntrinsicWidth ( ) ; final int... | Calculate Matrix for FIT_CENTER |
153,952 | public static Widget getDefaultWidget ( Context context ) { return Widget . newDarkBuilder ( context ) . statusBarColor ( ContextCompat . getColor ( context , R . color . albumColorPrimaryDark ) ) . toolBarColor ( ContextCompat . getColor ( context , R . color . albumColorPrimary ) ) . navigationBarColor ( ContextCompa... | Create default widget . |
153,953 | private int createView ( ) { switch ( mWidget . getUiStyle ( ) ) { case Widget . STYLE_DARK : { return R . layout . album_activity_album_dark ; } case Widget . STYLE_LIGHT : { return R . layout . album_activity_album_light ; } default : { throw new AssertionError ( "This should not be the case." ) ; } } } | Use different layouts depending on the style . |
153,954 | private void showFolderAlbumFiles ( int position ) { this . mCurrentFolder = position ; AlbumFolder albumFolder = mAlbumFolders . get ( position ) ; mView . bindAlbumFolder ( albumFolder ) ; } | Update data source . |
153,955 | private void showLoadingDialog ( ) { if ( mLoadingDialog == null ) { mLoadingDialog = new LoadingDialog ( this ) ; mLoadingDialog . setupViews ( mWidget ) ; } if ( ! mLoadingDialog . isShowing ( ) ) { mLoadingDialog . show ( ) ; } } | Display loading dialog . |
153,956 | public VideoMultipleWrapper selectCount ( @ IntRange ( from = 1 , to = Integer . MAX_VALUE ) int count ) { this . mLimitCount = count ; return this ; } | Set the maximum number to be selected . |
153,957 | protected void requestPermission ( String [ ] permissions , int code ) { if ( Build . VERSION . SDK_INT >= 23 ) { List < String > deniedPermissions = getDeniedPermissions ( this , permissions ) ; if ( deniedPermissions . isEmpty ( ) ) { onPermissionGranted ( code ) ; } else { permissions = new String [ deniedPermission... | Request permission . |
153,958 | public String createThumbnailForImage ( String imagePath ) { if ( TextUtils . isEmpty ( imagePath ) ) return null ; File inFile = new File ( imagePath ) ; if ( ! inFile . exists ( ) ) return null ; File thumbnailFile = randomPath ( imagePath ) ; if ( thumbnailFile . exists ( ) ) return thumbnailFile . getAbsolutePath (... | Create a thumbnail for the image . |
153,959 | public String createThumbnailForVideo ( String videoPath ) { if ( TextUtils . isEmpty ( videoPath ) ) return null ; File thumbnailFile = randomPath ( videoPath ) ; if ( thumbnailFile . exists ( ) ) return thumbnailFile . getAbsolutePath ( ) ; try { MediaMetadataRetriever retriever = new MediaMetadataRetriever ( ) ; if ... | Create a thumbnail for the video . |
153,960 | public static Bitmap readImageFromPath ( String imagePath , int width , int height ) { File imageFile = new File ( imagePath ) ; if ( imageFile . exists ( ) ) { try { BufferedInputStream inputStream = new BufferedInputStream ( new FileInputStream ( imageFile ) ) ; BitmapFactory . Options options = new BitmapFactory . O... | Deposit in the province read images mViewWidth is high the greater the picture clearer but also the memory . |
153,961 | public static File getAlbumRootPath ( Context context ) { if ( sdCardIsAvailable ( ) ) { return new File ( Environment . getExternalStorageDirectory ( ) , CACHE_DIRECTORY ) ; } else { return new File ( context . getFilesDir ( ) , CACHE_DIRECTORY ) ; } } | Get a writable root directory . |
153,962 | public static boolean sdCardIsAvailable ( ) { if ( Environment . getExternalStorageState ( ) . equals ( Environment . MEDIA_MOUNTED ) ) { return Environment . getExternalStorageDirectory ( ) . canWrite ( ) ; } else return false ; } | SD card is available . |
153,963 | private static String randomMediaPath ( File bucket , String extension ) { if ( bucket . exists ( ) && bucket . isFile ( ) ) bucket . delete ( ) ; if ( ! bucket . exists ( ) ) bucket . mkdirs ( ) ; String outFilePath = AlbumUtils . getNowDateTime ( "yyyyMMdd_HHmmssSSS" ) + "_" + getMD5ForString ( UUID . randomUUID ( ) ... | Generates a random file path using the specified suffix name in the specified directory . |
153,964 | public static String getMimeType ( String url ) { String extension = getExtension ( url ) ; if ( ! MimeTypeMap . getSingleton ( ) . hasExtension ( extension ) ) return "" ; String mimeType = MimeTypeMap . getSingleton ( ) . getMimeTypeFromExtension ( extension ) ; return TextUtils . isEmpty ( mimeType ) ? "" : mimeType... | Get the mime type of the file in the url . |
153,965 | public static String getExtension ( String url ) { url = TextUtils . isEmpty ( url ) ? "" : url . toLowerCase ( ) ; String extension = MimeTypeMap . getFileExtensionFromUrl ( url ) ; return TextUtils . isEmpty ( extension ) ? "" : extension ; } | Get the file extension in url . |
153,966 | public static String convertDuration ( @ IntRange ( from = 1 ) long duration ) { duration /= 1000 ; int hour = ( int ) ( duration / 3600 ) ; int minute = ( int ) ( ( duration - hour * 3600 ) / 60 ) ; int second = ( int ) ( duration - hour * 3600 - minute * 60 ) ; String hourValue = "" ; String minuteValue ; String seco... | Time conversion . |
153,967 | public static String getMD5ForString ( String content ) { StringBuilder md5Buffer = new StringBuilder ( ) ; try { MessageDigest digest = MessageDigest . getInstance ( "MD5" ) ; byte [ ] tempBytes = digest . digest ( content . getBytes ( ) ) ; int digital ; for ( int i = 0 ; i < tempBytes . length ; i ++ ) { digital = t... | Get the MD5 value of string . |
153,968 | public void stopRecording ( ) { super . stopRecording ( ) ; mSentBroadcastLiveEvent = false ; if ( mStream != null ) { if ( VERBOSE ) Log . i ( TAG , "Stopping Stream" ) ; mKickflip . stopStream ( mStream , new KickflipCallback ( ) { public void onSuccess ( Response response ) { if ( VERBOSE ) Log . i ( TAG , "Got stop... | Stop broadcasting and release resources . After this call this Broadcaster can no longer be used . |
153,969 | private void queueOrSubmitUpload ( String key , File file ) { if ( mReadyToBroadcast ) { submitUpload ( key , file ) ; } else { if ( VERBOSE ) Log . i ( TAG , "queueing " + key + " until S3 Credentials available" ) ; queueUpload ( key , file ) ; } } | Handle an upload either submitting to the S3 client or queueing for submission once credentials are ready |
153,970 | private void queueUpload ( String key , File file ) { if ( mUploadQueue == null ) mUploadQueue = new ArrayDeque < > ( ) ; mUploadQueue . add ( new Pair < > ( key , file ) ) ; } | Queue an upload for later submission to S3 |
153,971 | private void submitQueuedUploadsToS3 ( ) { if ( mUploadQueue == null ) return ; for ( Pair < String , File > pair : mUploadQueue ) { submitUpload ( pair . first , pair . second ) ; } } | Submit all queued uploads to the S3 client |
153,972 | public void applyFilter ( int filter ) { Filters . checkFilterArgument ( filter ) ; mDisplayRenderer . changeFilterMode ( filter ) ; synchronized ( mReadyForFrameFence ) { mNewFilter = filter ; } } | Apply a filter to the camera input |
153,973 | public void handleCameraPreviewTouchEvent ( MotionEvent ev ) { if ( mFullScreen != null ) mFullScreen . handleTouchEvent ( ev ) ; if ( mDisplayRenderer != null ) mDisplayRenderer . handleTouchEvent ( ev ) ; } | Notify the preview and encoder programs of a touch event . Used by GLCameraEncoderView |
153,974 | public void startRecording ( ) { if ( mState != STATE . INITIALIZED ) { Log . e ( TAG , "startRecording called in invalid state. Ignoring" ) ; return ; } synchronized ( mReadyForFrameFence ) { mFrameNum = 0 ; mRecording = true ; mState = STATE . RECORDING ; } } | Called from UI thread |
153,975 | public void onFrameAvailable ( SurfaceTexture surfaceTexture ) { mHandler . sendMessage ( mHandler . obtainMessage ( MSG_FRAME_AVAILABLE , surfaceTexture ) ) ; } | Called on an arbitrary thread |
153,976 | private void prepareEncoder ( EGLContext sharedContext , int width , int height , int bitRate , Muxer muxer ) throws IOException { mVideoEncoder = new VideoEncoderCore ( width , height , bitRate , muxer ) ; if ( mEglCore == null ) { mEglCore = new EglCore ( sharedContext , EglCore . FLAG_RECORDABLE ) ; } if ( mInputWin... | Called with the display EGLContext current on Encoder thread |
153,977 | private void releaseEglResources ( ) { mReadyForFrames = false ; if ( mInputWindowSurface != null ) { mInputWindowSurface . release ( ) ; mInputWindowSurface = null ; } if ( mFullScreen != null ) { mFullScreen . release ( ) ; mFullScreen = null ; } if ( mEglCore != null ) { mEglCore . release ( ) ; mEglCore = null ; } ... | Release all recording - specific resources . The Encoder EGLCore and FullFrameRect are tied to capture resolution and other parameters . |
153,978 | private void releaseCamera ( ) { if ( mDisplayView != null ) releaseDisplayView ( ) ; if ( mCamera != null ) { if ( VERBOSE ) Log . d ( TAG , "releasing camera" ) ; mCamera . stopPreview ( ) ; mCamera . release ( ) ; mCamera = null ; } } | Stops camera preview and releases the camera to the system . |
153,979 | private void configureDisplayView ( ) { if ( mDisplayView instanceof GLCameraEncoderView ) ( ( GLCameraEncoderView ) mDisplayView ) . setCameraEncoder ( this ) ; else if ( mDisplayView instanceof GLCameraView ) ( ( GLCameraView ) mDisplayView ) . setCamera ( mCamera ) ; } | Communicate camera - ready state to our display view . This method allows us to handle custom subclasses |
153,980 | private void releaseDisplayView ( ) { if ( mDisplayView instanceof GLCameraEncoderView ) { ( ( GLCameraEncoderView ) mDisplayView ) . releaseCamera ( ) ; } else if ( mDisplayView instanceof GLCameraView ) ( ( GLCameraView ) mDisplayView ) . releaseCamera ( ) ; } | Communicate camera - released state to our display view . |
153,981 | public static int createProgram ( String vertexSource , String fragmentSource ) { int vertexShader = loadShader ( GLES20 . GL_VERTEX_SHADER , vertexSource ) ; if ( vertexShader == 0 ) { return 0 ; } int pixelShader = loadShader ( GLES20 . GL_FRAGMENT_SHADER , fragmentSource ) ; if ( pixelShader == 0 ) { return 0 ; } in... | Creates a new program from the supplied vertex and fragment shaders . |
153,982 | public static int loadShader ( int shaderType , String source ) { int shader = GLES20 . glCreateShader ( shaderType ) ; checkGlError ( "glCreateShader type=" + shaderType ) ; GLES20 . glShaderSource ( shader , source ) ; GLES20 . glCompileShader ( shader ) ; int [ ] compiled = new int [ 1 ] ; GLES20 . glGetShaderiv ( s... | Compiles the provided shader source . |
153,983 | public static void checkGlError ( String op ) { int error = GLES20 . glGetError ( ) ; if ( error != GLES20 . GL_NO_ERROR ) { String msg = op + ": glError 0x" + Integer . toHexString ( error ) ; Log . e ( TAG , msg ) ; throw new RuntimeException ( msg ) ; } } | Checks to see if a GLES error has been raised . |
153,984 | public static FloatBuffer createFloatBuffer ( float [ ] coords ) { ByteBuffer bb = ByteBuffer . allocateDirect ( coords . length * SIZEOF_FLOAT ) ; bb . order ( ByteOrder . nativeOrder ( ) ) ; FloatBuffer fb = bb . asFloatBuffer ( ) ; fb . put ( coords ) ; fb . position ( 0 ) ; return fb ; } | Allocates a direct float buffer and populates it with the float array data . |
153,985 | public static void logVersionInfo ( ) { Log . i ( TAG , "vendor : " + GLES20 . glGetString ( GLES20 . GL_VENDOR ) ) ; Log . i ( TAG , "renderer: " + GLES20 . glGetString ( GLES20 . GL_RENDERER ) ) ; Log . i ( TAG , "version : " + GLES20 . glGetString ( GLES20 . GL_VERSION ) ) ; if ( false ) { int [ ] values = new int ... | Writes GL version info to the log . |
153,986 | private EGLConfig getConfig ( int flags , int version ) { int renderableType = EGL14 . EGL_OPENGL_ES2_BIT ; if ( version >= 3 ) { renderableType |= EGLExt . EGL_OPENGL_ES3_BIT_KHR ; } int [ ] attribList = { EGL14 . EGL_RED_SIZE , 8 , EGL14 . EGL_GREEN_SIZE , 8 , EGL14 . EGL_BLUE_SIZE , 8 , EGL14 . EGL_ALPHA_SIZE , 8 , ... | Finds a suitable EGLConfig . |
153,987 | public void release ( ) { if ( mEGLDisplay != EGL14 . EGL_NO_DISPLAY ) { EGL14 . eglMakeCurrent ( mEGLDisplay , EGL14 . EGL_NO_SURFACE , EGL14 . EGL_NO_SURFACE , EGL14 . EGL_NO_CONTEXT ) ; EGL14 . eglDestroyContext ( mEGLDisplay , mEGLContext ) ; EGL14 . eglReleaseThread ( ) ; EGL14 . eglTerminate ( mEGLDisplay ) ; } m... | Discard all resources held by this class notably the EGL context . |
153,988 | public EGLSurface createOffscreenSurface ( int width , int height ) { int [ ] surfaceAttribs = { EGL14 . EGL_WIDTH , width , EGL14 . EGL_HEIGHT , height , EGL14 . EGL_NONE } ; EGLSurface eglSurface = EGL14 . eglCreatePbufferSurface ( mEGLDisplay , mEGLConfig , surfaceAttribs , 0 ) ; checkEglError ( "eglCreatePbufferSur... | Creates an EGL surface associated with an offscreen buffer . |
153,989 | public void makeCurrent ( EGLSurface eglSurface ) { if ( mEGLDisplay == EGL14 . EGL_NO_DISPLAY ) { Log . d ( TAG , "NOTE: makeCurrent w/o display" ) ; } if ( ! EGL14 . eglMakeCurrent ( mEGLDisplay , eglSurface , eglSurface , mEGLContext ) ) { throw new RuntimeException ( "eglMakeCurrent failed" ) ; } } | Makes our EGL context current using the supplied surface for both draw and read . |
153,990 | public void makeCurrent ( EGLSurface drawSurface , EGLSurface readSurface ) { if ( mEGLDisplay == EGL14 . EGL_NO_DISPLAY ) { Log . d ( TAG , "NOTE: makeCurrent w/o display" ) ; } if ( ! EGL14 . eglMakeCurrent ( mEGLDisplay , drawSurface , readSurface , mEGLContext ) ) { throw new RuntimeException ( "eglMakeCurrent(draw... | Makes our EGL context current using the supplied draw and read surfaces . |
153,991 | public void makeNothingCurrent ( ) { if ( ! EGL14 . eglMakeCurrent ( mEGLDisplay , EGL14 . EGL_NO_SURFACE , EGL14 . EGL_NO_SURFACE , EGL14 . EGL_NO_CONTEXT ) ) { throw new RuntimeException ( "eglMakeCurrent failed" ) ; } } | Makes no context current . |
153,992 | public boolean isCurrent ( EGLSurface eglSurface ) { return mEGLContext . equals ( EGL14 . eglGetCurrentContext ( ) ) && eglSurface . equals ( EGL14 . eglGetCurrentSurface ( EGL14 . EGL_DRAW ) ) ; } | Returns true if our context and the specified surface are current . |
153,993 | public int querySurface ( EGLSurface eglSurface , int what ) { int [ ] value = new int [ 1 ] ; EGL14 . eglQuerySurface ( mEGLDisplay , eglSurface , what , value , 0 ) ; return value [ 0 ] ; } | Performs a simple surface query . |
153,994 | public static void logCurrent ( String msg ) { EGLDisplay display ; EGLContext context ; EGLSurface surface ; display = EGL14 . eglGetCurrentDisplay ( ) ; context = EGL14 . eglGetCurrentContext ( ) ; surface = EGL14 . eglGetCurrentSurface ( EGL14 . EGL_DRAW ) ; Log . i ( TAG , "Current EGL (" + msg + "): display=" + di... | Writes the current display context and surface to the log . |
153,995 | private void checkEglError ( String msg ) { int error ; if ( ( error = EGL14 . eglGetError ( ) ) != EGL14 . EGL_SUCCESS ) { throw new RuntimeException ( msg + ": EGL error: 0x" + Integer . toHexString ( error ) ) ; } } | Checks for EGL errors . |
153,996 | private long getJitterFreePTS ( long bufferPts , long bufferSamplesNum ) { long correctedPts = 0 ; long bufferDuration = ( 1000000 * bufferSamplesNum ) / ( mEncoderCore . mSampleRate ) ; bufferPts -= bufferDuration ; if ( totalSamplesNum == 0 ) { startPTS = bufferPts ; totalSamplesNum = 0 ; } correctedPts = startPTS + ... | Ensures that each audio pts differs by a constant amount from the previous one . |
153,997 | public void adjustForVerticalVideo ( SCREEN_ROTATION orientation , boolean scaleToFit ) { synchronized ( mDrawLock ) { mCorrectVerticalVideo = true ; mScaleToFit = scaleToFit ; requestedOrientation = orientation ; Matrix . setIdentityM ( IDENTITY_MATRIX , 0 ) ; switch ( orientation ) { case VERTICAL : if ( scaleToFit )... | Adjust the MVP Matrix to rotate and crop the texture to make vertical video appear upright |
153,998 | public void drawFrame ( int textureId , float [ ] texMatrix ) { synchronized ( mDrawLock ) { if ( mCorrectVerticalVideo && ! mScaleToFit && ( requestedOrientation == SCREEN_ROTATION . VERTICAL || requestedOrientation == SCREEN_ROTATION . UPSIDEDOWN_VERTICAL ) ) { Matrix . scaleM ( texMatrix , 0 , 0.316f , 1.0f , 1f ) ;... | Draws a viewport - filling rect texturing it with the specified texture object . |
153,999 | public void stopBroadcasting ( ) { if ( mBroadcaster . isRecording ( ) ) { mBroadcaster . stopRecording ( ) ; mBroadcaster . release ( ) ; } else { Log . e ( TAG , "stopBroadcasting called but mBroadcaster not broadcasting" ) ; } } | Force this fragment to stop broadcasting . Useful if your application wants to stop broadcasting when a user leaves the Activity hosting this fragment |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.