Jun 27, 2014

Android L Preview API Changes

src: http://developer.android.com/preview/images/l-dev-prev.png

Android L Preview Features

  1. A New Design - Material Design
  2. A New Runtime - ART (Android Runtime)
  3. Enhanced Notifications
  4. Project Volta- Increased Efficiency
  5. Support for OpenGL ES 3.1
  6. Android Extension Pack
  7. Camera API for advanced camera capabilities
  8. Storage - Directory selection
  9. Multiple network connections
  10. Bluetooth broadcasting
  11. NFC enhancements
  12. Scheduling jobs
  13. Enterprise - Managed provisioning
  14. Render PDF as bitmap
  15. Testing and accessibility improvements
  16. Easier switching between input languages
Android L Preview API Changes

TypeAdditionsChangesRemovalsTotal
Packages843051
Classes and Interfaces872320319
Constructors842086
Methods4086917494
Fields754221777
Total1341368181727
The overall difference between API Levels 20 and L-preview is approximately 3.77%.
New Packages
  1. android.app.job
  2. android.bluetooth.le
  3. android.hardware.camera2
  4. android.hardware.camera2.params
  5. android.media.session
  6. android.media.tv
  7. android.service.voice
  8. android.system

continue reading Android L Preview API Changes

Jun 21, 2014

Android Triangle Pager Sliding Tabs

TriangleTabs is extension of PagerSlidingTabStrip

Note: This is not a plug and play library that you can directly import in project and use. Triangle tabs is extension of PagerSlidingTabStrip library. In this article I will explain, how to modify PageSlidingTabStrip library to create Triangle Tabs.
Android Triangle Tabs Video 




Customise PageSlidingTabStrip

Step 1: Import PageSlidingTabStrip library in AndroidStudio.
Step 2: Let add new attribute for Triangle Tabs in attrs.xml (project -> res -> values). This attribute will allow developer to enable / disable triangle tabs.

<attr name="pstsTriangleIndicator" format="boolean"/>
Step 3: We need to modify Java code for Triangle Tabs.Goto source code and Open PagerSlidingTabStrip.java file
Step 4: Declare boolean variable above constructor, for pstsTriangleIndicator attribute.

private boolean triangleIndicator = false;
Step 5: Fatch pstsTriangleIndicator attribute, write following line in constructor

triangleIndicator = a.getBoolean(R.styleable.PagerSlidingTabStrip_pstsTriangleIndicator, triangleIndicator);
Step 6: Now it's time to draw triangle tab, goto onDraw method and add following code.

Original Code

canvas.drawRect(lineLeft, height - indicatorHeight, lineRight, height, rectPaint);
New Code, conditional code for triangle tabs

if (triangleIndicator) {
      Rect r = new Rect();
      int left = (int) lineLeft + (int) (((lineRight - lineLeft) / 2) - (indicatorHeight / 2)) - 20;
      int top = height - indicatorHeight;
      int right = (int) left + indicatorHeight + 30;
      int bottom = height;
      r.set(left, top, right, bottom);
      Path path = getEquilateralTriangle(r);
      canvas.drawPath(path, rectPaint);
} 
else {
      canvas.drawRect(lineLeft, height - indicatorHeight, lineRight, height, rectPaint);
}
Step 7: This is last step, declare getEquilateralTriangle() function. This function has code for triangle.

public Path getEquilateralTriangle(Rect bounds) {
        Point startPoint = null, p2 = null, p3 = null;
        int width = bounds.right - bounds.left;
        int height = bounds.bottom - bounds.top;

        startPoint = new Point(bounds.left, bounds.bottom);

        p2 = new Point(startPoint.x + width, startPoint.y);
        p3 = new Point(startPoint.x + (width / 2), startPoint.y - height);

        Path path = new Path();
        path.moveTo(startPoint.x, startPoint.y);
        path.lineTo(p2.x, p2.y);
        path.lineTo(p3.x, p3.y);

        return path;
    }

Usage

Step 1: Include the customized library as local library project or you can copy PagerSlidingTabStrip.java, attrs.xml and background_tab.xml in respective folders of your main project.
Step 2: Include the PagerSlidingTabStrip widget in your layout. This should usually be placed above the ViewPager it represents. Noticed pstsTriangleIndicator attribute

<com.kpbird.triangletabs.PagerSlidingTabStrip
        android:id="@+id/activity_main_pagertabstrip"
        android:layout_width="match_parent"
        android:layout_height="45dp"
        custom:pstsTextAllCaps="true"
        custom:pstsIndicatorColor="#FF3F9FE0"
        custom:pstsDividerColor="#FF3F9FE0"
        custom:pstsUnderlineColor="#FF3F9FE0"
        custom:pstsTriangleIndicator="true"
        custom:pstsShouldExpand="true"
        custom:pstsIndicatorHeight="15dp"
/>
Step 3: In your onCreate method (or onCreateView for a fragment), bind the widget to the ViewPager.

// Declar variable 
private ViewPager pager;
private PagerSlidingTabStrip pagertab;
private MyPageAdapter pageAdapter;

// Inside onCreate
pager = (ViewPager) findViewById(R.id.activity_main_pager);
pagertab = (PagerSlidingTabStrip) findViewById(R.id.activity_main_pagertabstrip);
List fragments = getFragments();
pageAdapter = new MyPageAdapter(getSupportFragmentManager(), fragments);
pager.setAdapter(pageAdapter);
pagertab.setViewPager(pager);
Step 4: Compile & Run application



continue reading Android Triangle Pager Sliding Tabs

Jun 20, 2014

Microservice Architecture - A Quick Guide

1. What is Architecture (Software)?
Architecture is the fundamental organization of a system embodied in its components (i.e. Web Server, Application Server, Databases,Storage, Communication layer, etc...), their relationships to each other, and to the environment (i.e. deployment environment shared server, dedicated server, cloud deployment, etc..), and the principles guiding its design and evolution.
2. What is microservice architecture ?
Microservice means developing a single, small, meaningful functional feature as single service, each service has it’s own process and communicate with lightweight mechanism, deployed in single or multiple servers.
3. Advantages of microservice architecture ?
  • Each micro service is small and focused on a specific feature / business requirement.
  • Microservice can be developed independently by small team of developers (normally 2 to 5 developers).
  • Microservice is loosely coupled, means services are independent, in terms of development and deployment both.
  • Microservice can be developed using different programming language (Personally I don't suggest to do it).
  • Microservice allows easy and flexible way to integrate automatic deployment with Continuous Integration tools (for e.g: JenkinsHudsonbamboo etc..).
  • The productivity of a new team member will be quick enough.
  • Microservice is easy to understand, modify and maintain for a developer because separation of code,small team and focused work.
  • Microservice allows you to take advantage of emerging and latest technologies (framework, programming language , programming practice, etc.).
  • Microservice has code for business logic only, No mixup with HTML,CSS or other UI component.
  • Microservice is easy to scale based on demand.
  • Microservice can deploy on commodity hardware or low / medium configuration servers.
  • Easy to integrate 3rd party service.
  • Every microservice has it's own storage capability but it depends on the project’s requirement, you can have common database like MySQL or Oracle for all services.
4. Disadvantages of microservice architecture ?
  • Microservice architecture brings a lot of operations overhead.
  • DevOps Skill required (http://en.wikipedia.org/wiki/DevOps).
  • Duplication of Effort.
  • Distributed System is complicated to manage .
  • Default to trace problem because of distributed deployment.
  • Complicated to manage whole products when number of services increases.
5. In which case / requirement microservice architecture best fit ?
When you need to support Desktop, web , mobile, Smart TVs, Wearable, etc... or you don't know in future which kind of devices you need to support.
6. Which products / companies are using Microservie architecture?
Most large scale web sites including Twitter, Netflix, Amazon and eBay have evolved from a monolithic architecture to a microservices architecture.
7. How independent micro services communicate with each other?
It's depend upon requirement, normally developers use HTTP/REST with JSON or Protobuf(Binary protocol) but are free to use any communication protocol.
8. Why is it that everyone are talking about microservices now?
It’s been nearly 15 years since the concept of Service Oriented Architecture really took hold. With the improvement of RESTful web service and JSON as a data interchange format has made it easier than ever to build easily interconnectable services simply and quickly.
9. Presentation
10. Video

11. Picture: Monolithic vs Modular vs Service oriented architecture
Reference:
  1. http://martinfowler.com/articles/microservices.html
  2. http://microservices.io/patterns/microservices.html
  3. http://www.infoq.com/presentations/Micro-Services
  4. http://yobriefca.se/blog/2013/04/28/micro-service-architecture/
  5. http://www.tomakehurst.com/microservices-and-monoliths-is-there-a-third-way/
  6. http://www.infoq.com/articles/microservices-intro
continue reading Microservice Architecture - A Quick Guide

NoSQL - A Quick Guide


NoSQL is buzz word now-a-days among the developers and software professionals.
1. What is NoSQL?
NoSQL database, also called Not Only SQL, is an approach to data management and database design that's useful for very large sets of distributed data.
2. Where to use NoSQL ?
Use NOSQL, When project has unstructured big data that require real-time or offline analysis or web/mobile application. i.e. Social Network app, Analytics app.
3. Advantages and Disadvantages of NoSQL DB.
Advantages of NoSQL
  1. Elastic scaling
  2. Big Data
  3. Ecomomics
  4. Flexible data models
Disadvantages of NoSQL
  1. Maturity
  2. Support
  3. Analytics and business intelligence
  4. Administration
  5. Expertise
4. Category of NoSQL
  1. Column
  2. Document
  3. Key-value
  4. Graph
5. How many NoSQL database are available in market?
More then 110 different (Open Source and Proprietary) NoSQL database available in market
6. If all NoSQL database fall under above category then what is purpose of having lots of NoSQL databases ?
Every NOSQL database has some special feature & functionality which makes it different, Base on the project requirement one can choose NOSQL database.
7. Can I use multiple NoSQL in my project / application ?
Yes
8. List of popular NoSQL database with usage.
Radis: For rapidly changing data (should fit mostly in memory). i.e. to store real-time stock prices, analytics, leaderboards and communication. And replacement of memcached.
MongoDB: When you need dynamic queries, defined indexes, map/reduce and good performance on a big DB. i.e. for most things that you would do with MySQL but having predefined columns really holds you back.
Cassandra: When you need to store data so huge that it doesn't fit on server, but still want a friendly familiar interface to it. When you don't need real-time analysis or other operation. i.e. Web analytics, Transaction logging, Data collection from huge sensor arrays.
Riak: If you need very good single-site scalability, availability and fault-tolerance, but you're ready to pay for multi-site replication. i.e. Point-of-sales data collection. Factory control systems. Places where even seconds of downtime hurt. Could be used as a well-update-able web server.
CouchDB: For accumulating, occasionally changing data, on which pre-defined queries are to be run. Places where versioning is important. i.e. CRM, CMS systems. Master-master replication is an especially interesting feature, allowing easy multi-site deployments.
HBase: Hadoop is probably still the best way to run Map/Reduce jobs on huge datasets. Best if you use the Hadoop/HDFS stack already. ie. Search engines. Analysing log data. Any place where scanning huge, two-dimensional join-less tables are a requirement.
Accumulo: If you need to restict access on the cell level. i.e. Same as HBase, since it's basically a replacement: Search engines.
Hypertable: If you need a better HBase. i.e/ Same as HBase, since it's basically a replacement: Search engines.
Neo4j: For graph-style, rich or complex, interconnected data. Neo4j is quite different from the others in this sense. i.e. For searching routes in social relations, public transport links, road maps, or network topologies.
ElasticSearch: When you have objects with (flexible) fields, and you need "advanced search" functionality. i.e. A dating service that handles age difference, geographic location, tastes and dislikes, etc. Or a leaderboard system that depends on many variables. you can replace your Solr with ElasticSearch.
Couchbase: Any application where low-latency data access, high concurrency support and high availability is a requirement. i.e. Low-latency use-cases like ad targeting or highly-concurrent web apps like online gaming (e.g. Zynga).
9. Can I have video tutorial to learn more about NoSQL?
Sure, Watch following video..


Reference & More reading...
  1. http://en.wikipedia.org/wiki/NoSQL
  2. http://kkovacs.eu/cassandra-vs-mongodb-vs-couchdb-vs-redis
  3. http://www.dzone.com/mz/nosql
  4. http://www.nosqlweekly.com/
  5. http://nosql-database.org/
continue reading NoSQL - A Quick Guide