Tuesday, April 10, 2018

Swift Data Types



                       




Data Types:
As we discussed in the previous lesson, about variable and variable we have seen that, when we try to assign the String to Int type it was showing error message cannot assign, Here what String and Int are?.

Let discuss then
As shown and described in the above image, different types of datatypes in Swift, commonly used. Reason why there are many datatypes? Is this because system stores different types of data differently.



As we see in above picture variable that we declared as 'str'  and it is declared as to store only data of type string 'Hello, playground test' by a system.

To declare the variable we basically use
var str = "my test home"  here str assumes it should hold data of type string


The other way to declare is 

Saturday, April 7, 2018

Swift Variables, Constants

Variables: In swift, a variable holds some data, now its data could be a value, it could be a reference to an object or it can even point to a function.

Variable has a couple of distinct parts, let's break it down, them here



var str = "Hello, playground"

Variable need to be declared before they can be used, so this 'var' keyword is used to declare a new variable, following the var keyword you have the variable name 'str' that's it.

Now taking look at the whole line, what we have on the right-hand side there, that's some data,  we didn't say that variable hold some data, Here = sign in between variable name and piece of data that mean assignment operator.  That means assigning that str with data.



In above line, the playground shows the error because the data is not matching.
Let's start learning about the data types.

Before starting data types, let's discuss briefly naming conventions, naming variable we usually follow the camelcase.


Constants: Like the variable except it can't be reassigned new data after the first assignment.
Uses the 'let' keyword instead




Why would I or everyone use constants, if it more limited it's in functionality, instead if I declare everything in the variable I have all the flexibility I want.

Well, there are a couple of reasons why you would want to use constants, when making sense, for one thing, it helps computer works little more efficiently because it knows exactly what that constant will be and that not going to change.

Next chapter Data Types

Thursday, March 29, 2018

Flutter in Native Apps

                     

Flutter has some of the interesting features for native apps, the developer can easily use Flutter to enhance the UI experience.


Flutter is an open-source mobile application development SDK created by Google.

It is used to develop applications for Android and iOS, as well as being the primary method of creating applications for Google Fuchsia.


Google's mobile UI framework for crafting high-quality native interface on iOS and Android in record time.

Flutter works with existing code, is used by developers and organizations around the world, and is the free and open source.  

Wednesday, February 14, 2018

Kotlin getting started and Coding conventions

                  

How to initialise 
the class in Kotlin
Standard class CLASSNAME : PARENTCLASS, INTERFACE{
}
Example :
class SelectPicActivity: GalleryActivity, CallBackInterface{
}


How to initialise/declare the variable in Kotlin

private var uriString : String? =null
private var mCurrentPath = ""
private var REQUEST_IMAGE_PIC = 2
private var REQUEST_IMAGE_SELECT = 1


How to create method/function in Kotlin

Standard :
fun methodName(): Return{
}
Example : fun getFileName() : String{
//Write your code here var = "sd/test/stpe.jpeg"
return var
}

How to initialise the Arraylist/collections 

val mylist: ArrayList<T> = ArrayList<T>() //Add elements to mylist mylist.add("text")
println(mylist)
Continued

Wednesday, January 31, 2018

Face recognition in android using microsoft face API's

                            

Microsoft has given various API's for object recognition, extract the rich information from an image and process the visual data. Gives back image description, tagging, color, category and level of confidence. Some the services given by MicroSoft for object detection are.



1.  Analyse an image

2. Read text in an image



3. Preview Handwritten text from an image

4. Recognise the celebrities and landmarks

5. Analyse the video near in real time

6. Generate a thumbnail. 


Lets start learning some little deep into the above concept and how to use them, taking a sample android app.
Here is the sample app screen shot(ss)

                    
For sample app code please visit this here

Step to set up above app are

1. Download code from link

2. Click here and create a Microsoft azure account or login with Linkedin 

3. Click on get API key for  Computer vision API

4. Once you successfully enabled the API, on dashboard of azure account

    user would be able see the following information
 

   End point : http.....
   Key 1 : **********************
   Key 2 : 
**********************

Put the subscription inside the string file in android studio, and run the app.




Android app for FACE RECOGNITION

               

To set up the face recognition app, please follow the following steps

1 . Download the code from link

Monday, January 8, 2018

How to add Google Assistant to Existing app(Create our own assistant app with Google assistant API's)


                             

Kotlin Assistant app has many features to build, as per our business needs.
Some of them are

1. We can localize the app language



2. Customise the app for our business needs ex: E-Commerce, Healthcare Assistant

3. Customise the app for Families
Customise







Monday, December 25, 2017

Kotlin for Android


 
                              

Kotlin is an opensource language with its own community and documentation, Kotlin is the better fit for developing Android applications, Kotlin does not provide any restriction while using in android platform.




Major reasons why Google introduces Kotlin to android


Compatibility : Kotline applications can run on older versions of android without  any restrictions, also kotlin tool is fully supported into Android studio and compatible with android build system

Performance : Kotlin also has bytecode structure as like Java. With kotlin support for inline functions code using lambads often runs even faster than the same code written in java


Interoperability (Able to switch) : Kotlin is 100% interoperable with java, allowing using the all android libraries in kotlin application, this includes annotation processingm, so databinding and dagger work too.

Compilation Time : Kotlin support incremental compilation, so some additional overheads for clean builds.


Installing the kotline plugin



kotlin plugin is bundled with Android Studio 3.0, if you're using the earlier version you have to install manually,

Goto Preferances > Plugin > Browse Repositories > type Kotlin > Install 

Safer Code 

Write safer code and avoid NullPointerExceptions in your app.

var output: String
output = null   // Compilation error
==================================

val name: String? = null    // Nullable type
println(name.length())      // Compilation error
Readable and Concise 

Focus on expressing your ideas and wirte less boilerplate code.

// Create a POJO with getters, setters, equals(), hashCode(), toString(), and copy() with a single line:
data class User(val name: String, val email: String)

Lambdas

Use lambdas to simplify your code.


button.setOnClickListener(new View.OnClickListener(){
    @Override
    public void onClick(View v){
        doSomething();
    }
});
          


button.setOnClickListener { doSomething() }
          
Default and named arguements

Reduce the number of overloaded functions by using default arguments.
Call functions using named arguments to make your code more readable.


fun format(str: String,
           normalizeCase: Boolean = true,
           upperCaseFirstLetter: Boolean = true,
           divideByCamelHumps: Boolean = false,
           wordSeparator: Char = ' ') {
        
    }
==================================
// Call function with named arguments.
format(str, normalizeCase = true, upperCaseFirstLetter = true)
Say Goodbye to findViewById

Avoid  findViewById() calls in your code. Focus on writing on your logic with less verbosity.


import kotlinx.android.synthetic.main.content_main.*
class MainActivity : AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
        // No need to call findViewById(R.id.textView) as TextView
        textView.text = "Kotlin for Android rocks!"

    }
}
   

Extend functionality without inheritance


Extension functions and properties let you easily extends functionality of classes without inheriting from them. calling code is readable and natural.


// Extend ViewGroup class with inflate function
fun ViewGroup.inflate(layoutRes: Int): View {
    return LayoutInflater.from(context).inflate(layoutRes, this, false)
}
==================================
// Call inflate directly on the ViewGroup instance
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
    val v = parent.inflate(R.layout.view_item)
    return ViewHolder(v)
}
 
100% Interoperable with Java

Add as tittle or as much of Kotlin as you want. Kotlin is a JVM language that's completely interoperable with Java.


// Calling Java code from Kotlin
class KotlinClass {
    fun kotlinDoSomething() {
        val javaClass = JavaClass()
        javaClass.javaDoSomething()
        println(JavaClass().prop)
    }
}
==================================
// Calling Kotlin code from Java
public class JavaClass {
    public String getProp() { return "Hello"; }
    public void javaDoSomething() {
        new KotlinClass().kotlinDoSomething();
    }
}
     



Building and Publishing the Kotlin application for android

This works same wa as in java. You can make a release of the application and sign in similarly to way what you do applications written in java

Kotlin has a rather small runtime file size :  the library is approximately 932KB. this means kotlin adds just a little to .apk file size.

Kotlin compiler produces bytecode, thus there really no-difference in look and feel of kotlin applications verses those written in java