Posts

What is JS, React and JSX ?

If you are react developer and you are getting confused with above terms and you want to know a bit about it so let's discussed about the role of each one. JS : JS stands for JavaScript . It is a interpreted scripting language and widely used in web. It is used within the HTML tags. It is high level language. React : React is a JavaScript library developed and maintain by Facebook . React widely used to make the user interface for single page application. JSX : JSX is a pre-processor step and adds XML syntax to JavaScript. JSX provides the ability to use the tags within the react component which is easy to use. Like XML, it tags have a tag name, attributes, and children. You can also use react without it but it makes code easy to understand and good looking.

Quick Pop-up with Context Menu in Android

During the creation of an android application, sometimes it is required to show a popup menu to get quick action from the user. For example, when a user long presses on any view we have to show some options and the user is able to pick one of them, and based on the selection we have to perform some tasks. To show this kind of pop-up android provides context menu API. Let's check how we can use it with an example. The context  menu provides an ability to bind any view with it. You can also change the subject of the menu if it is required.   To show a pop-up menu first, you have to register that view with registerForContextMenu(). For now, Don't get confused with the method. Later we are going to check how to use it in the application but for now, just remember that to show the context menu we have to register it with the above method. Add Items to the Menu To add the items in the menu you have to override the onCreateContextMenu in the activity shown in the example below : ...

Which one to use Activity Context Or Application Context?

Many android developers get confused between activity and application context. Some types we are getting confused about which context we have to use and make the android resources a more efficient way. As we know two types of context application and activity context. Both the context are extending the super-class context. Activity Context It represents the current activity information and also depends upon the activity life cycle. If you want to perform some operation based on activity life span then we are using it. Mostly in the application when we need to start a new activity or show dialog than we can use this kind of context.  Application Context   The life span of this context is based on the application state. It does not depend upon the activity life span, So if the activity is killed or destroyed then it does not affect the application context. The context has become available when you are launching the application and have the value until the application not ge...

Animation with the Motion Layout in Android

As a developer, we know that the animation is pretty hard to manage and if we don't handle it properly it will hang the UI. Sometimes it will twice to thrice time than the UI design. The proper animation makes your app more attractive. To create the animation very easy and attractive way the android introduces a new Motion Layout. The key feature of this layout is you do not have to write a single line of code to perform the animation. Is it Great? Like me, you also want to add animation in the project but due to timeline or more code we avoiding to add it. So from now, you can add the animation with less and easily maintain code. MotionLayout is a layout class that extends from ConstraintLayout . MotionLayout has all the features of ConstraintLayout. Motion layout is providing the functionality to animate the view on interactive animations. I know we have talked a lot about this new layout and you want to try it. Let's check it with a simple example first. In t his e...

Kotlin Dependency Injection (Dagger)

Dagger provide dependency injection using the annotations.             1) @Inject             2) @Module             3) @Provides             4) @Component 1) Inject  defines which object you want to inject to your view. 2) Modules are responsible to provide appropriate object to the injected fields. 3) Provides returns the object from the method define in the module class. 4) Component is the bridge between injected object and Object class(Module). Now that we understand a bit, we can go forward with dependency injection exploration using one example. First you have to add the below gradle to your project :- Dagger implementation 'com.google.dagger:dagger:2.13' kapt 'com.google.dagger:dagger-compiler:2.13' Apply plugin   ...

How to use Sample Data in android Recylerview

Image
Dummy Data / Sample Data :   Many times while developing the application we need to check the UI before it actually renders on the device screen. In android, if you are using recycler-view or list-view, then it is very hard to check the UI. Sample data is a set of model data to help the developer to see the design without a run the code into the device and also does not require any code to see the output. You can verify the result you see is only visible in the design section and not visible into the device.  The main advantage is that it reflects instantly in the preview section so that you don’t want to run the build to check the result which saves  a lot of development time.  Add the below tag into your XML file. activity_main.xml                       <LinearLayout   xmlns:tools="http://schemas.android.com/tools" >    ...