Wednesday, February 11, 2015

Android Material Design Open sources

Material Design Reference Projects:

  1. MaterialDesignLibrary This is a library with components of Android L to you use in android 4.0
    https://github.com/navasmdc/MaterialDesignLibrary#flat-button
  2. MaterialEverywhere Showcase of the new AppCompat 21, which includes new Material Theme, working in pre-21 devices.
    https://github.com/antoniolg/MaterialEverywhere
  3. MaterialWidget Android L design widget in Android 4.0 ~ 4.4.
    https://github.com/keithellis/MaterialWidget
  4. MaterialTabs Custom Tabs with Material Design effects. It requires 14+ API and android support v7 (Toolbar)
    https://github.com/neokree/MaterialTabs
  5. material-ripple Android L Ripple effect wrapper for Views
    https://github.com/balysv/material-ripple
  6. RippleEffect Implementation of Ripple effect from Material Design for Android API 14+
    https://github.com/traex/RippleEffect
  7. LDrawer Android drawer icon with material design animation
    https://github.com/ikimuhendis/LDrawer
  8. material-design-icons Material Design icons by Google
    https://github.com/google/material-design-icons
  9. AndroidMaterialDesignToolbar Android Sample Project with Material Design and Toolbar.
    https://github.com/tekinarslan/AndroidMaterialDesignToolbar
  10. MaterialEditText EditText in Material Design
    https://github.com/rengwuxian/MaterialEditText
  11. material-menu Morphing Android menu, back, dismiss and check buttons
    https://github.com/balysv/material-menu
  12. material-dialogs Not even AppCompat uses Material theming for AlertDialogs on pre-Lollipop. This is a beautiful and easy solution.
    https://github.com/afollestad/material-dialogs
  13. MaterialNavigationDrawer Navigation Drawer Activity with material design style and simplified methods
    https://github.com/neokree/MaterialNavigationDrawer
  14. MaterialDialog An Android library for conveniently building Material Design Dialog in Android version 2.2 ~ L.
    https://github.com/drakeet/MaterialDialog
  15. materialish-progress A material style progress wheel compatible with 2.3
    https://github.com/pnikosis/materialish-progress
  16. MaterialList An Android library aimed to get the beautiful CardViews that Google shows at its official design specifications
    https://github.com/dexafree/MaterialList
  17. android-floating-action-button Floating Action Button for Android based on Material Design specification
    https://github.com/futuresimple/android-floating-action-button
  18. Android-Material-circular-button Animated Material circular button
    https://github.com/glomadrian/Android-Material-circular-button
  19. material-drawer DrawerLayout implementation for Material design apps
    https://github.com/HeinrichReimer/material-drawer
  20. snackbar Snackbar Android Library
    https://github.com/nispok/snackbar
  21. Android-DialogFragments Various DialogFragments for Android.
    https://github.com/wada811/Android-DialogFragments
  22. material-range-bar Android widget for selecting a range of values.
    https://github.com/oli107/material-range-bar
  23. CircularProgressView A Material style circular progress bar for Android
    https://github.com/rahatarmanahmed/CircularProgressView
  24. RippleDrawable A port of Ripple Effect from Android L to non L devices
    https://github.com/ozodrukh/RippleDrawable

Wednesday, July 2, 2014

Insertion Sort in Java

For theoretical reference:
http://en.wikipedia.org/wiki/Insertion_sort


Java Program:


public class InsertionSort {

    public static void main(String[] args) {
        int[] input = { 2, 7, 4, 1, 5, 3};
        insertionSort(input);
    }
   
    private static void printNumbers(int[] input) {       
        for (int i = 0; i < input.length; i++) {
            System.out.print(input[i] + ", ");
        }
        System.out.println("\n");
    }

    public static void insertionSort(int array[]) {
        int n = array.length;
        for (int j = 1; j < n; j++) {
            int key = array[j];
            int i = j-1;
            while ( (i > -1) && ( array [i] > key ) ) {
                array [i+1] = array [i];
                i--;
            }
            array[i+1] = key;
            printNumbers(array);
        }
    }
}

Monday, June 30, 2014

Bubble sort algorithm using array in Java.

For theoretical reference you can see wiki link.

http://en.wikipedia.org/wiki/Bubble_sort

For programmatic reference you can check this.


public class BubbleSort {

    public static void main(String[] args) {
       
        int arr[] = { 2, 7, 4, 1, 5, 3};
        showAll(bubbleSort(arr));
    }
   
    private static int [] bubbleSort(int arr[]){
        while(true){
            int count = 0;
            for (int i = 0; i < arr.length - 1; i++) {
                if(arr[i] > arr[i+1]){
                    int temp = arr[i];
                    arr[i] = arr[i + 1];
                    arr[i + 1] = temp;
                    count ++;
                }
            }
            if(count == 0)
                break;
        }
        return arr;
    }
   
    private static void showAll(int[] arr){
        for (int i : arr) {
            System.out.println("" + i);
        }
    }

}

Selection Sort in Java

For theoretical reference you can see wiki link.
http://en.wikipedia.org/wiki/Selection_sort

For programmatic reference you can check this.

public class SelectionSort {
   
    public static void main(String[] args) {
        int [] arr = {3, 4, 2, 1, 5, 10, 99, 12, 1, 7};
        showAll(descSort(arr));
    }

    private static int [] descSort(int[] arr){
        for(int i = 0; i <= arr.length -1; i++){
            for(int j = i+1; j < (arr.length); j++){
                if(arr[i] > arr[j]){
                    int temp = arr[i];
                    arr[i] = arr[j];
                    arr[j] = temp;
                }
            }
        }
        return arr;
    }
   
    private static void showAll(int[] arr){
        for (int i : arr) {
            System.out.println("" + i);
        }
    }
}

Wednesday, June 5, 2013

Android Webview tricks to get alert and console.log() messages.

There are many tutorials to write a webview so i am not covering the ways to create a webview instead  i wanted to show how we can get the javascript consol.log('test'), and alert('message') from WebChromeClient api  which can be used to debug hybrid application.




private class SampleWebChromeClient extends WebChromeClient {

@Override
public boolean onConsoleMessage(ConsoleMessage consoleMessage) {
   Log.d("SampleActivity", consoleMessage.message() + " -- From line "
            + consoleMessage.lineNumber() + " of "
            + consoleMessage.sourceId() );

   return true;
}

@Override
public boolean onJsAlert(WebView view, String url, String message,
JsResult result) {
  Log.d("SampleActivity", message);
        //new AlertDialog.Builder(view.getContext()).setMessage(message).setCancelable(true).show();
  Toast.makeText(getApplicationContext(), message, Toast.LENGTH_SHORT).show();
        result.confirm();
        return true;
}

}


For KitKat > using the below code and you can debug inside the web view. For more details refer here.

  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
      WebView.setWebContentsDebuggingEnabled(true);
  }

Monday, November 7, 2011

Data Structure - Queue(JAVA) using array


For theoretical reference you check wiki.

http://en.wikipedia.org/wiki/Queue_%28data_structure%29

Java you can refer the code.



import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class QueueKrk {

 private static final int MAX = 3;
 private static int[] QUEUE = new int[MAX];
 private static int top = -1;
 private static int rear = 0;

 private enum Function {
  PUSH, POP, PRINTALL
 };

 private static void push() {
  if (top < MAX -1) {
   System.out.println("Enter the value to added to the queue");
   int value = readValue();
   QUEUE[++top] = value;
  } else {
   System.out.println("The queue has reached the maximum value");
  }
 }

 private static void peek() {
  if(top >= rear){
   rear++;
  }else{
   System.out.println("Nothing to Peek");
  }

 }

 private static void printAll() {
  if (top >= rear) {
   int i = 0;
   for (i = rear; i <= top; i++) {
    System.out.println(QUEUE[i]);
   }
  } else {
   System.out.println("The queue is empty");
  }
 }

 private static int readValue() {
  int input = 0;
  try {
   BufferedReader br = new BufferedReader(new InputStreamReader(
     System.in));
   input = Integer.parseInt(br.readLine());
  } catch (NumberFormatException nfe) {
   System.err.println("Invalid Format!");
   System.exit(0);
  } catch (IOException e) {
   e.printStackTrace();
  }
  return input;
 }

 public static void main(String[] args) {
  init();
 }

 private static void init() {
  System.out.println("For Push enter 0, Peek enter 1 and 2 to print all. For exit enter non number");
  int selection = readValue();
  optionSelection(selection);
 }

 private static void optionSelection(int selection) {
  Function function = null;
  try {
   function = Function.values()[selection];
  } catch (ArrayIndexOutOfBoundsException ex) {
   System.out.println("Enter either '0' or '1' or '2' for push, Peek , view all respectively");
   init();
  }
  switch (function) {
  case PUSH:
   push();
   init();
   break;
  case POP:
   peek();
   init();
   break;
  case PRINTALL:
   printAll();
   init();
   break;
  default:
   break;
  }
 }

}



Data Structure - Stack (JAVA) using array

For theoretical reference you can see wiki link. 
http://en.wikipedia.org/wiki/Stack_%28data_structure%29


Java Stack using array .

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class StackKrk {

 private static final int MAX = 3;// constant for the size of the stack.
 private static final int[] STACK = new int[MAX]; 
 private static int TOP = 0; // Flag for the stack position.
 private  enum Function{PUSH, POP, PRINTALL};
 
 public static void main(String[] args) {
  init();
 }
 
 private static void init(){
  System.out.println("For Push enter 0, Pop enter 1 and 2 to print all. For exit enter non number");
  int selection = readValue();
  
  optionSelection(selection);
 }
 
 private static void optionSelection(int selection){
  Function function = null;
  try{
   function = Function.values()[selection];
  }catch(ArrayIndexOutOfBoundsException ex){
   System.out.println("Enter either '0' or '1' or '2' for push, pop , view all respectively");
   init();
  }
  switch (function) {
  case PUSH:
   push();
   init();
   break;
  case POP:
   pop();
   init();
   break;
  case PRINTALL:
   printAll();
   init();
   break;
  default:
   
   break;
  }
 }

 private static int readValue() {
  int input = 0;
  try {
   BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
   input = Integer.parseInt(br.readLine());
  } catch (NumberFormatException nfe) {
   System.err.println("Invalid Format!");
   System.exit(0);
  } catch (IOException e) {
   e.printStackTrace();
  }
  return input;
 }

 private static void push() {
  if (TOP == MAX) {
   System.out.println("Reached the maximum stack value");
  } else {
   System.out.println("Enter the value to be pushed ::>");
   int value = readValue();
   STACK[TOP++] = value;
  }
 }
 
 private static void pop() {
  if (TOP == 0) {
   System.out.println("The stack is empty");
  } else {
   System.out.println("The poped element of the stack ::>" + STACK[--TOP]);
   STACK[TOP] = 0;
  }
 }
 private static void printAll(){
  for(int i=0; i<=TOP-1; i++){
   System.out.println("Value in the stack position["+i+"]  "+STACK[i]);
  }
    
 }


}