Buggy code:
InputStream in = null ; try { apk = new JarFile ( ( ( OpenFile ) ( file ) ) . getFile ( ) ) ; JarEntry icon = apk . getJarEntry ( "res//drawable-hdpi//icon.apk" ) ; if ( ( icon != null ) && ( ( icon . getSize ( ) ) > 0 ) ) { in = apk . getInputStream ( icon ) ; bmp = BitmapFactory . decodeStream ( in ) ; in . close ( ) ; in = null ; } if ( ! valid ) { PackageManager man = ThumbnailCreator . mContext . getPackageManager ( ) ; PackageInfo pinfo = man . getPackageArchiveInfo ( file . getAbsolutePath ( ) , GET_ACTIVITIES ) ; if ( pinfo != null ) { ApplicationInfo ainfo = pinfo . applicationInfo ; if ( ( VERSION . SDK_INT ) >= 8 ) ainfo . publicSourceDir = ainfo . sourceDir = file . getPath ( ) ; Drawable mIcon = ainfo . loadIcon ( man ) ; if ( mIcon != null ) bmp = ( ( android . graphics . drawable . BitmapDrawable ) ( mIcon ) ) . getBitmap ( ) ; } } if ( ! valid ) { Logger . LogWarning ( ( "Couldn't<seq2seq4repair_space>get<seq2seq4repair_space>icon<seq2seq4repair_space>for<seq2seq4repair_space>" + ( file . getAbsolutePath ( ) ) ) ) ; String iconName = "icon" ; if ( ( iconName . indexOf ( "<seq2seq4repair_space>" ) ) > ( - 1 ) ) iconName = "icon" ; for ( String s : new String [ ] { "drawable-mdpi" , "drawable" , "drawable-hdpi" , "drawable-ldpi" } ) { icon = apk . getJarEntry ( ( ( ( ( "res//" + s ) + "//" ) + iconName ) + ".png" ) ) ; if ( ( icon != null ) && ( ( icon . getSize ( ) ) > 0 ) ) { Logger . LogDebug ( ( ( ( ( "Found<seq2seq4repair_space>fallback<seq2seq4repair_space>icon<seq2seq4repair_space>(res//" + s ) + "//" ) + iconName ) + ".png)" ) ) ; in = apk . getInputStream ( icon ) ; bmp = Bitmap . createScaledBitmap ( BitmapFactory . decodeStream ( in ) , mWidth , mHeight , true ) ; in . close ( ) ; in = null ; break ; } } } if ( bmp == null ) bmp = BitmapFactory . decodeResource ( ThumbnailCreator . mContext . getResources ( ) , ( useLarge ? drawable . lg_apk : drawable . sm_apk ) ) ; else ThumbnailCreator . saveThumbnail ( mCacheFilename , bmp ) ; } catch ( IOException ix ) { Logger . LogError ( ( "Invalid<seq2seq4repair_space>APK:<seq2seq4repair_space>" + ( file . getPath ( ) ) ) , ix ) ; } finally { try { if ( apk != null ) apk . close ( ) ; } catch ( IOException nix ) { Logger . LogError ( "Error<seq2seq4repair_space>closing<seq2seq4repair_space>APK<seq2seq4repair_space>while<seq2seq4repair_space>handling<seq2seq4repair_space>invalid<seq2seq4repair_space>APK<seq2seq4repair_space>exception." , nix ) ; } try { if ( in != null ) in . close ( ) ; } catch ( IOException nix ) { Logger . LogError ( "Error<seq2seq4repair_space>closing<seq2seq4repair_space>input<seq2seq4repair_space>stream<seq2seq4repair_space>while<seq2seq4repair_space>handling<seq2seq4repair_space>invalid<seq2seq4repair_space>APK<seq2seq4repair_space>exception." , nix ) ; } } } else if ( ( ! valid ) && ( file . isImageFile ( ) ) ) { long len_kb = ( file . length ( ) ) // 1024 ; BitmapFactory . Options options = new BitmapFactory . Options ( ) ; options . outWidth = mWidth ; options . outHeight = mHeight ; if ( ( len_kb > 500 ) && ( len_kb < 2000 ) ) { options . inSampleSize = 16 ; options . inPurgeable = true ; bmp = BitmapFactory . decodeFile ( file . getPath ( ) , options ) ; } else if ( len_kb >= 2000 ) { options . inSampleSize = 32 ; options . inPurgeable = true ; bmp = BitmapFactory . decodeFile ( file . getPath ( ) , options ) ; } else if ( len_kb <= 500 ) { options . inPurgeable = true ; bmp = BitmapFactory . decodeFile ( file . getPath ( ) ) ; if ( bmp == null ) bmp = BitmapFactory . decodeResource ( ThumbnailCreator . mContext . getResources ( ) , ( useLarge ? drawable . lg_photo : drawable . sm_photo ) ) ; } } else if ( ( bmp == null ) && ( file . getClass ( ) . equals ( OpenFile . class ) ) ) { if ( file . isDirectory ( ) ) bmp = BitmapFactory . decodeResource ( ThumbnailCreator . mContext . getResources ( ) , ( useLarge ? drawable . lg_folder : drawable . sm_folder ) ) ; else bmp = BitmapFactory . decodeResource ( ThumbnailCreator . mContext . getResources ( ) , ( useLarge ? drawable . lg_unknown : drawable . sm_unknown ) ) ; } } <START_BUG> if ( ( bmp != null ) && ( ( bmp . getWidth ( ) ) > mWidth ) ) { <END_BUG> int h = ( ( int ) ( Math . floor ( ( mWidth * ( ( ( double ) ( bmp . getHeight ( ) ) ) // ( ( double ) ( bmp . getWidth ( ) ) ) ) ) ) ) ) ; bmp = Bitmap . createScaledBitmap ( bmp , mWidth , h , false ) ; } if ( bmp != null ) { if ( writeCache ) ThumbnailCreator . saveThumbnail ( mCacheFilename , bmp ) ; ThumbnailCreator . mCacheMap . put ( mCacheFilename , bmp ) ; } return new SoftReference < Bitmap > ( bmp ) ; } private static Bitmap loadThumbnail ( String file ) { } private static void saveThumbnail ( String file , Bitmap bmp ) { } private void sendThumbBack ( SoftReference < Bitmap > mThumb , String path ) { } public static void flushCache ( ) { } public static boolean hasContext ( ) { } }

Fix:
if ( ( ( bmp != null ) && ( ( bmp . getWidth ( ) ) > mWidth ) ) && ( mWidth > 0 ) ) {