Skip to main content

Posts

Showing posts from 2017

Android Customized-FloatSeekBar

A SeekBar is an extension of ProgressBar that adds a draggable thumb. The user can touch the thumb and drag left or right to set the current progress level or use the arrow keys. Placing focusable widgets to the left or right of a SeekBar is discouraged. SeekBar support only int values for progress: void setMax(int max) Set the upper range of the progress bar max. void setMin(int min) Set the lower range of the progress bar to min. void setProgress(int progress) Sets the current progress to the specified value. int getMax() Return the upper limit of this progress bar's range. int getMin() Return the lower limit of this progress bar's range. int getProgress() Get the progress bar's current level of progress. In some scenario we would need floating point seekbar progress, which is not supported by default in android. Here the floating seekbar which supports floating point value: You can download the full sample and library from https://github.com/yuvaraj119/Cus

Etcher - Burn. Better. Burn images to SD cards & USB drives, safely and easily.

I was searching for good image burner for writing SD card for Raspberry Pi this was first time i am gonna use Raspberry Pi and i don't wanna it to go in wrong way. I searched for tool which is easier and smarter which is the Etcher i come to know about this. https://etcher.io/ I liked the look of Etcher’s clean and simple interface which is platform independent works on any platform. Its simple 3 step interface:  STEP 1: You browse to the image file from your system. Select a drive SD card or USB drive.  Now lets hit the Flash button to start the burning image on SD card or USB drive. STEP 2:    Now wait for few minutes to burn the image on SD card or USB drive. Once its done it will start validating whether its burned correctly. STEP 3: Once the process has finished you have the option to burn the same image again or to choose a different image.   When selecting image files you can select IMG and ISO files as expected but also Zip files. This a

Kotlin Returns and Jumps

Returns and Jumps Kotlin has three structural jump expressions: return . By default returns from the nearest enclosing function or anonymous function . break . Terminates the nearest enclosing loop. continue . Proceeds to the next step of the nearest enclosing loop. All of these expressions can be used as part of larger expressions: val s = person.name ?: return The type of these expressions is the Nothing type . Break and Continue Labels Any expression in Kotlin may be marked with a label . Labels have the form of an identifier followed by the @ sign, for example: abc@ , fooBar@ are valid labels (see the grammar ). To label an expression, we just put a label in front of it loop@ for (i in 1..100) { // ... } Now, we can qualify a break or a continue with a label: loop@ for (i in 1..100) { for (j in 1..100) { if (...) break@loop } } A break qualified with a label jumps to the execution point right after the loop marked with that label. A contin

Kotlin Control Flow

Control Flow If Expression In Kotlin, if is an expression, i.e. it returns a value. Therefore there is no ternary operator (condition ? then : else), because ordinary if works fine in this role. // Traditional usage var max = a if (a < b) max = b // With else var max: Int if (a > b) { max = a } else { max = b } // As expression val max = if (a > b) a else b if branches can be blocks, and the last expression is the value of a block: val max = if (a > b) { print("Choose a") a } else { print("Choose b") b } If you're using if as an expression rather than a statement (for example, returning its value or assigning it to a variable), the expression is required to have an else branch. When Expression when replaces the switch operator of C-like languages. In the simplest form it looks like this when (x) { 1 -> print("x == 1") 2 -> print("x == 2") else -> { // Note the

Kotlin Basic Types

Basic Types In Kotlin, everything is an object in the sense that we can call member functions and properties on any variable. Some types are built-in, because their implementation is optimized, but to the user they look like ordinary classes. In this section we describe most of these types: numbers, characters, booleans and arrays. Numbers Kotlin handles numbers in a way close to Java, but not exactly the same. For example, there are no implicit widening conversions for numbers, and literals are slightly different in some cases. Kotlin provides the following built-in types representing numbers (this is close to Java): Type Bit width Double 64 Float 32 Long 64 Int 32 Short 16 Byte 8 Note that characters are not numbers in Kotlin. Literal Constants There are the following kinds of literal constants for integral values: Decimals: 123 Longs are tagged by a capital L : 123L Hexadecimals: 0x0F Binaries: 0b00001011 NOTE: Octal literals a

ExifInterface in Android

ExifInterface is a class for reading and writing Exif tags in a JPEG file or a RAW image file. Supported formats are: JPEG, DNG, CR2, NEF, NRW, ARW, RW2, ORF, PEF, SRW and RAF. Attribute mutation is supported for JPEG image files. In clear way we can say: Exif is a specification for supporting metadata in a file, mostly used for JPEG, TIFF, and other image formats. The TAG_-prefixed constants on ExifInterface identify common tags, though not every image will have every tag. Tags that are popular among developers include TAG_ORIENTATION (indicating the orientation of the camera when the image was captured) and the TAG_GPS_-prefixed family (for geotagging). With the release of the 25.1.0 Support Library, there's a new entry in the family: the ExifInterface Support Library. With significant improvements introduced in Android 7.1 to the framework's ExifInterface , it only made sense to make those available to all API 9+ devices via the Support Library's ExifInterf

Changes to Device Identifiers in Android O

Android O introduces some improvements to help provide user control over the use of identifiers. These improvements include: limiting the use of device-scoped identifiers that are not resettable updating the Android O Wi-Fi stack in conjunction with changes to the Wi-Fi chipset firmware used by Pixel, Pixel XL and Nexus 5x phones to randomize MAC addresses in probe requests updating the way that applications request account information and providing more user-facing control Device identifier changes Here are some of the device identifier changes for Android O: Android ID In O, Android ID (Settings.Secure.ANDROID_ID or SSAID) has a different value for each app and each user on the device. Developers requiring a device-scoped identifier, should instead use a resettable identifier, such as Advertising ID , giving users more control. Advertising ID also provides a user-facing setting to limit ad tracking . Additionally in Android O: The ANDROID_ID value won&#

Flexbox inside the RecyclerView as a LayoutManager (FlexboxLayoutManager).

Currently google has release the Flexbox which can be used for building flexible layouts using FlexboxLayout, it can be interpreted as an advanced LinearLayout because both layouts align their child views sequentially. For more detail on this flexbox-layout But here we are gonna work on Flexbox with RecyclerView. Flexbox with a large number of items in a scrollable container! Let's first see what are the Supported attributes / features comparison Due to some characteristics of the RecyclerView, some Flexbox attributes are not available/not implemented to the FlexboxLayoutManager. Here is a quick overview of the attributes/features comparison between the two containers. Attribute / Feature FlexboxLayout                FlexboxLayoutManager (RecyclerView) flexDirection flexWrap (except wrap_reverse ) justifyContent alignItems alignContent - layout_order - layout_flexGrow layout_flexShrink layout_alignSelf layout_fl

Image Compression like WhatsApp in android

How to compress the image without loosing the quality. You can compress the image just like whatsapp like quality. File externalFile = new File(Environment. getExternalStorageDirectory () , " ProfilePic /helloimg.jpg" ) ; Uri externaluri = Uri. parse (externalFile.getPath()) ; compressImage(externaluri.toString() , "helloimg" ) ; // Method to compress Image Compress image public String compressImage (String imageUri , String imagenameName) { String filePath = getRealPathFromURI(imageUri) ; String fileName = imagenameName ; Bitmap scaledBitmap = null; BitmapFactory.Options options = new BitmapFactory.Options() ; //by setting this field as true, the actual bitmap pixels are not loaded in the memory. Just the bounds are loaded. If //you try the use the bitmap here, you will get null. options. inJustDecodeBounds = true; Bitmap bmp = BitmapFactory. decodeFile (filePath

How to reduce the image size without loosing the quality using WebP Images

WebP is an image file format from Google that provides lossy compression (like JPEG) as well as transparency (like PNG) but can provide better compression than either JPEG or PNG. Lossy WebP images are supported in Android 4.0 (API level 14) and higher, and lossless and transparent WebP images are supported in Android 4.3 (API level 18) and higher. This page shows how to convert images to WebP format and how to convert WebP images to PNG format. Convert images to WebP: Android Studio can convert PNG, JPG, BMP, or static GIF images to WebP format. You can convert individual images or folders of images. To convert an image or folder of images, proceed as follows: Right click on an image file or a folder containing a number of images files, and then click Convert to WebP . The Converting Images to WebP dialog opens. The default settings depend on the minSdkVersion setting for the current module. Figure 1. The Converting Images to WebP dialog. Select either lossy

Pick Color from Image

Picking the Color from the Image in Android in HEX and RGB In android we use HEX for color code and in ios we use RGB so here we are gonna work on both. You can download the full source code from github PickColorFromImageAndroid . ImageView picked_imageView ; picked_imageView = (ImageView) findViewById(R.id. imageView2 ) ; picked_imageView .setOnTouchListener( this ) ; picked_imageView .setImageBitmap(bitmapImage) ; OnTouch of picked_imageView we can get the color code in onTouch method. When we touch the imageView we will get the color code from the image and here you can format it in HEX and RGB. @Override public boolean onTouch (View v , MotionEvent event) { Matrix inverse = new Matrix() ; picked_imageView .getImageMatrix().invert(inverse) ; float [] touchPoint = new float [] {event.getX() , event.getY()} ; inverse.mapPoints(touchPoint) ; int x = Integer. valueOf (( int )touchPoint[ 0 ]) ; int y = Integer. valueOf (( int

Vertical AutoScrolling TextView in Android

In android by default we can scroll the text in horizontal using marquee in layout, but if we want to scroll the text in vertical its not possible by default. So here we will learn to create a custom TextView which will auto-scroll in vertical direction. Source Code:  VerticalScrollingTextView-Android Create a AutoScrollingTextView.class which extends TextView: @SuppressLint ( "AppCompatCustomView" ) public class AutoScrollingTextView extends TextView { private static final float DEFAULT_SPEED = 65.0f ; public Scroller scroller ; public float speed = DEFAULT_SPEED ; public boolean continuousScrolling = true; public AutoScrollingTextView (Context context) { super (context) ; init( null, 0 ) ; scrollerInstance(context) ; } public AutoScrollingTextView (Context context , AttributeSet attrs) { super (context , attrs) ; init(attrs , 0 ) ; scr