Looking for:
Looking for:
Expert android programming prajyot mainkar pdf free

These wireframing screens need not be same as the final UI for the app. They could be somewhat rough wireframes, which would give you an idea of what elements would be present on a screen. The easiest and fastest way to get started is to sketch out your screens by hand using paper and pencils. Once you begin sketching, you may uncover practicality issues in your original screen map or the patterns you use. In some cases, patterns may apply well to a given design problem in theory, but in practice they may break down and cause visual clutter or interactional issues for example, if there are two rows of tabs on the screen.
If that happens, explore other navigational patterns, or variations on chosen patterns, to arrive at a more optimal set of sketches. After you’re satisfied with the initial sketches, it’s a good idea to move on to digital wireframing, using software such as Adobe Illustrator, Adobe Fireworks, OmniGraffle, or any other vector illustration tools.
When choosing a tool to use, consider the following features:. Material UI for Android developers Material design for Android includes implementation of visual, motion, and interactive designs for your app on different devices.
Android now includes support for material design apps. To use material design in your Android apps, follow the guidelines defined in the material design specification and use the new components and functionality available in Android 5. Building meaningful motions In the following section, we will cover how to provide motions in our app to improve a user’s app experience.
The Android library provides many components for giving a material experience to the user. We will explain some of the components provided in the Android library in this section. They are distinguished by a circled icon floating above the UI and have special motion behaviors related to morphing, launching, and the transferring anchor point.
Floating action buttons come in two sizes: the default and mini. The size can be controlled with the FABSize attribute. As this class descends from ImageView, you can control the icon that is displayed via setImageDrawable Drawable.
The background color of this view defaults to your theme’s colorAccent. The FAB could be used to carry out different kinds of transitions on click. The following are a few images that show the different places where the FAB could be used:. Let’s take a look at how to use the FAB in our Zomato code. Consider the restaurant details screen where we have a FAB button present, as follows; the button can be used at various different places:.
The FAB animation has a button. Clicking on the button opens up the bottom menu and shows us the various options. Here, the transition from the FAB button to the bottom menu forms the major chunk of its material aspect. The following is the complete transition showing how the FAB gets converted to the bottom menu:. Let’s now look at how to implement FAB in our code.
Firstly, make sure that you have added the gradle dependency in your app’s build. The next step is to import and initialize it in your Java class: import android. If you are using Android Studio, the import will be handled automatically, and you don’t have to worry about it. Once it is initialized, you need to handle what will happen when you click on the FAB button: mFab. Now, the menu will appear when you click on the FAB button.
The code for the on click of the FAB is mentioned below. Refer to PlaceDetailActivity. Once this is done, the animation of opening the menu will be executed smoothly. Also, we need to close the bottom menu when clicking anywhere outside.
Implementing Search in Zomato The search screen in Zomato opens up when you click on the search icon on the Toolbar on the home page. Clicking on the search icon will produce a ripple effect, which helps a user to get a better experience:. Figure 1. When you click on the search icon, it opens up a new screen of search. When this screen opens up, there is a smooth transition that takes place as each of the components appears on the screen.
The search icon first opens up smoothly to form the toolbar:. The in-between transition when the search icon opens up smoothly. The search icon’s in-between transition shows that the ripple wave grows gradually until it completely covers the toolbar:. The search icon completely opens up to form the toolbar. Once the search icon translates to form the toolbar, the EditText translates down from the top to the bottom and the quick search options simultaneously translate up, creating a smooth transition effect:.
The Search icon completely opens up to form the toolbar. The major components on this screen are the EditText, for typing the text for searching. Another important component is the RecyclerView, which displays the list of all the details.
Here, we are concerned more about the way the UX for the search gives a smooth experience to a user. The showTop method makes the view visible. The view being passed to the method as a parameter is the searchViewLayout, which means that it makes the search view visible.
Then it adds the animation to that particular search view layout. Then, the animation is started using the start method. The following is the explanation of the showBottom method inside the enterViews method: private void showBottom View view, Animator. The showBottom method, similar to the showTop method, will do the same translation animation for the mightLike layout. This animation will have a listener, which will let you know when the animation starts and when it ends.
The exitViews method will be called when the search view has to be closed. In the hideTop method, the searchViewLay will be made to animate along the Y-axis in the opposite direction with respect to the preceding translation: private void hideBottom final View view, Animator.
Building the UX Design With the increased expectation of users who are becoming more accustomed to high quality apps, and as UX plays a very important part in making a user’s app experience better, it is necessary to build a proper UX pattern. Android library provides many ways and built-in libraries for building a good UX.
Besides these, you need to build your own UX patterns depending on the flow of your app. To build a good UX, you need to use animations in the right places. Understanding UX principles and how it’s different from UI The user experience is very important for keeping a user engaged with the app by making them understand what is happening on the screen. Here is another simple material aspect of UX, where a user gets a very good experience when they click on view on the screen; the UX shows a ripple effect when the user clicks on the view:.
The ripple effect starts from the point of contact with the screen. The ripple is high at the point of contact and gradually decreases its force.
Firstly, a user should know when they click on a button and should not have a doubt whether they have clicked or not. Having this effect gives a user a very good experience when they click on a button.
Let’s see how to integrate the ripple effect on the button click of any views. We will use the CardView as the outermost clickable view. The following is the code to do that:. An inset is used when you need a background that is of smaller bounds than the actual view’s bounds. We need to set a drawable for the inset. This drawable is a selector, which checks three states. It gives a color to the view, which is set is the colors.
The ffffff color set is a white color, and 96 is the alpha value set to give transparency to the white color. Here, the ripple is a built-in class, which defines the ripple effect. It needs to set a drawable and a color. The ripple color is the same one defined earlier. Summary Material design plays an important part in how a user is able to use an app easily, and hence it makes sure that they use the app more often.
In this chapter, we covered material design and followed with the material design animation. We then processed this animation to build animation in the app. In the next section, we will cover building the core features of the foodspotting app.
The idea behind this principle is to design a class that has one responsibility or various methods with unique functionality. According to this principle, a method should not do more than one task at a time.
Each function must be designated a unique task. The preceding code is the onBindViewHolder of the adapter of a recyclerView. It does not satisfy the single responsibility principle, as we are formatting the values as we are setting the text to the views. The onBindViewHolder of the recyclerView adapter is mainly responsible for binding the view with the values of its object class. In the preceding code, the onBindViewHolder is doing more tasks than it should.
If we have kept the same format in more than one place and there comes a need to make changes to the format, then we will have to make the changes everywhere and this may result in software logic duplication issues.
If we don’t update the code in some places, it may cause an error. If the code was a logical change that had been replicated, the entire flow of the app would change. To prevent this, we have to write the code in a way that we don’t have to make many changes if the features are changed. Now, as can be seen, the code checking and formatting are not done in the onBindViewHolder function but they are being done elsewhere. Due to this, the change of the functionality or format can be done in the common function instead of each instance of the code.
Software entities classes, modules, functions, etc should be open for extension, but closed for modification. This principle basically states that we have to design our modules, classes, and functions in a way that when a new functionality is needed, we should not modify our existing code but rather write new code that will be used by existing code.
Let us assume we are trying to calculate the area of some shapes. So let’s take the example of a rectangle and a circle. As can be seen from the preceding function, as new shapes are introduced, the calculateArea function will grow bigger and lots of handling and changes will be required. Both the rectangle and circle can implement this interface by which the method to calculate the area will remain inside the object class instead of the AreaManager.
Now, as the methods for calculating the areas are present inside the objects, the AreaManager will look something like this:. Now we can calculate the total area without ever needing to change the calculateArea method. The same shape interface can be now used in new classes to calculate the area without changing the AreaManager. According to this principle, a subclass should override the parent class’s methods in a way that does not break functionality from a client’s point of view.
According to this principle, if a class is extending another class, the functionality of the child class should not conflict with that of its parent. Here we have a rectangle. As we know, a square is also a type of rectangle, so it can extend the Rectangle class.
As can be seen from the preceding definition, we can get a rectangle also from the square implementation. Now if we try to get the area, we will get instead of 50, as a square has both the same length and height, which is not the case with a rectangle, and this violates the Liskov Substitution Principle.
An ArrayList implements a List but it does not change the basic functionality of the List. According to this principle, if an interface has too many methods, then we need to divide the interface into smaller interfaces with fewer methods. A simple example of this principle is shown next.
Now, while implementing this listener, we only want the onItemClickListener or the onItemLongClickListener; the others are not required but we still have to use them in the code. This violates the Interface Segregation Principle. Now we will only initialize the ClickListener and use its methods instead of the old interface where we had to utilize four methods.
Here we have segregated them into two different interfaces. High-level modules should not depend on low-level modules. Both should depend on abstractions.
The best way to explain this principle is by giving an example. Let’s assume we have a worker class that is a low level class and a Manager class that is a high level class. The Manager class contains many complex functionalities which it implements along with the Worker class, so the classes will look something like this:.
Here the Manager class has been implemented and is directly associated with the Worker class due to which changes in the Worker class directly affect the Manager class. If we have to add another class which would be a parent of the Worker class, and the Worker class does similar work to that of the Manager class, it will require lots of changes.
Now the both the worker and SuperWorker class implement the IWorker, while the Manager class directly uses the IWorker to complete its functionality by which changes to the Worker and SuperWorker do not affect the Manager class.
They are at times tough to put into practice when it comes to the usage of each individual principle, but making a habit of following these principles will keep your code readable, reusable, and easy to maintain. It is a style of coding by which we can manage various components of the system we are making. The MVC consists of three main components:. Model: The model represents the object in the application. This has the logic of where the data is to be fetched from.
This can also have the logic by which the controller can update the view. In Android, the model is mostly represented by object classes. View: The view consists of the components that can interact with the user and is responsible for how the model is displayed in the application. In Android, the view is mostly represented by the XML where the layouts can be designed. Controller: The controller acts as a mediator between the model and the view.
It controls the data flow into the model object and updates the view whenever data changes. In Android, the controller is mostly represented by the activities and fragments. All of these components interact with each other and perform specific tasks, as shown in the following figure:. Therefore, to solve this problem, we can use different design patterns or can implement MVC carefully by taking care of conventions and following proper programming guidelines.
To explain the MVC pattern components shown in the preceding code; the model here is LocationItem, which holds the name and address of the location. The view is an XML file, which contains a TextView, through which the name of the location can be displayed.
The activity, which is the controller, contains a LocationItem. It gets the name of the LocationItem at a specific position in the list and sets it up in the view, which displays it. It separates the view and model by using the presenter. The presenter decides what should be displayed on the view. Model: The model represents the objects in the application. View: The view renders information to users and contains a UI Component.
It does not have any other logic implemented. Presenter: The presenter layer performs the task of the controller and acts as the mediator between the view and model. But unlike the controller, it is not dependent on the view.
The view interacts with the presenter for the data to be displayed, and the presenter then takes the data from the model and returns it to the view in a presentable format.
The presenter does not contain any UI components; it just manipulates data from the model and displays it on the view. The interaction between the various components of the MVP are shown in the following figure:.
In the MVP design, the presenter communicates with the view through interfaces. The interfaces are defined in the presenter class, to which it passes the required data. The connection between the presenter and the view is one to one. In this example, we will show how the MVP design can be used to display a list into a recyclerview:. This is the LocationInteractorImpl class which is the model. This class interacts with the presenter to provide the list of locations. The loadLocations function is used by the presenter to interact with the model and fetch the list of locations.
The model LocationInteractorImpl then uses the listener. The LocationPresenter class is used by the view to communicate with the presenter. Depending on the functions called by the view, the presenter will communicate with the model and get the responses: public class LocationPresenterImpl implements LocationPresenter, LocationInteractor.
The LocationPresenterImpl class is the presenter class which communicates between the view and the model. This class implements LocationPresenter with which the view communicates with the presenter and the LocationInteractor.
OnLoadFinishedListener from which the model communicates with the presenter. When the view calls the loadLocations function of the presenter, the presenter interacts with the model and calls the loadLocations method of the model, indicating that the model is to return the list of locations to be displayed. The onSuccess and onFailed functions are then called by the model after the list has been fetched successfully or has failed.
Then the presenter communicates with the view through the locationLoaded function. The LocationListActivity is the view where all the interaction with the user will happen. The view implements the LocationInterface, by which it gets the responses from the presenter. It then calls the presenter. It is similar to the MVC model, the only difference being it has two-way data binding with the view and view-model.
The changes in the view are being propagated via the view-model, which uses an observer pattern to communicate between the view-model and the model. The view in this case is completely isolated from the model. The major advantage of using MVVM is it enables automatic changes in the view via the view-model:. View-model: The view-model helps in maintaining the state of the view and does changes to the model based on the inputs gained from the view. Many views can be linked to one view-model, which creates a many-to-one relation between the view and a view-model.
Also, a view has information about the view-model but the view-model does not have any information about the view. The view is not responsible for the state of information; rather, that is being managed by the view-model and the view and the model are only reflected via the changes made to the view-model.
In developer’s terminology, one can say that the view-model is the interface between a designer and a coder. Clean Architecture Pattern The Clean Architecture Pattern, in its simplest terms, means to write a clean code, by separating it into layers, with the outer layer being your implementations and the inner layer being the business logic. An interface connects these two layers, controlling how the outer layers use the inner layers.
This kind of code architecture pattern is also known as Onion Architecture because of its different layers, as seen in the following figure:. The inner layers have no idea about the outer layers. The outer layer uses the components from the inner layers based upon its needs, meaning the outer layers are dependent on the business logic implementations of the inner layers.
Hence, the dependency points inwards. Understanding the layers of Clean Architecture Understanding the various layers present in this architecture helps to achieve a code implementation that is clean and independent.
I will outline the layers in the figure, but focus more on the Clean Architecture core conceptual rules: The Dependency Rule, Abstraction Principle, and communication between the layers:.
Entities: Entities form the core of your app, which means they define what exactly your app is doing. Entities are basically objects created to make a data model to hold the business logic and the functionality that would be carried out on it.
Some of the entities for an app could be a user entity, a restaurant entity, a place entity, and so on. Use cases: Use cases are in the layer that forms objects using the core entities. The use cases may contain one or more entities based upon their use. The use cases are a direct object used for forming a business logic. A simple use case could be order, which books a restaurant for a user. Hence, this use case may contain entities such as user and restaurant.
Presenter: This layer is the one that presents a use case for its use. This means that it may have a business logic which would be using the entities to give an output data to the UI for rendering. UI: This is basically the output that you see and is formed by the components such as activities, fragments, views, adapters, and so on.
All of these components form the core of the architecture. This could be forming the way the structure should look like when things are being coded. But a Clean Architecture Pattern is formed only when some major principles are put to best use.
What it says is that the outer layers should depend on the inner layers. The inner layers should have no idea about the outer layers. But the outer layers can use, or can see, or know about the components of the inner layers, and, based upon their needs, could make use of them. It also means that the outer layers are dependent on the business logic implementations of the inner layers.
Hence, the dependency points inwards, as shown in figure 2. Abstraction Principle: The Abstraction Principle says that as you are moving towards the center, the code becomes more abstract as the inner circle contains business logic and the outer circle contains implementation details.
The inner layers are abstract because the outer layer does not know anything about the business logic used by the inner layers.
It only knows the key features of what it does. Let us have a simple example to understand this layer. Let us consider the case where a user can increase or decrease the brightness of the device. The brightness could be changed using a code that has already been written with some business logic that is completely abstract. But the feature that we know is that changing the slider values will increase or decrease the brightness of the device. Communication between the layers: The two layers need some kind of interface between them in order to enable communication between the inner layers and the outer layers.
From the Dependency Principle, we know that the outer layers should communicate with the inner layers, and to communicate with the inner layer, the outer layer needs an interface. This interface acts as a communication mode between the outer layers with the inner layers. As mentioned by the dependency rule, the dependency points inwards; that is, the outer layers communicate with the inner layers, but there is a small twist here.
The inner layers pass back the result to the outer layer after applying the business logic; that is, the inner layers have an output port. The inner layer will return a use case to the outer layer. The use case to be returned at the output port could be decided by the inner layer.
The inner layer would still not know, what the outer layer will do with it. To better understand the aforementioned principles, check out this code reference as an example to show the Abstraction Principle. Consider the following line of code: ratingTextView. This is a statement in Android code that displays the rating for a restaurant in a TextView in an Android app. It seems to be a complex one when you just look at it but would be really simple when split up in to sections.
The rating value to be set needs to be provided to this ratingTextView and is decided by restaurant. Here restaurant is an object of the entity Restaurant and.
Once you have roughly understood this line of code, let me now explain to you how and where the principles are being applied in this case. The formatRating is a function name that does the work of taking the rating value as input, applying some business logic to it, and giving back a result in the form of a specific rounded value.
Now this business logic is abstract to the outer layer. Hence, the Principle of Abstraction is applied. The inner layer is a formatRating function that would take input as the rating value and give output as a rounded value of the rating. The outer layer is just making a call to that function to get a rounded value and then display it. The dependency is from the outer layer to the inner layer, and the inner layer does not know what the outer layer is going to do with the rounded value.
Hence, the Dependency Rule is applied. The outer layer has to call the inner layer function that is written in the CommonFunction class. The CommonFunction class calls the formatRating function, which makes the communication between the outer layer and the inner layer.
The preceding example is applied at a code level with one statement. The same could be applied at different levels where the outer layer and inner layers would be different. Summary What you can learn from the architectural patterns described in this chapter, is that you keep the code segregated to avoid dependencies. What is asked from a user, what it does internally, and what is presented back to the user are all independent pieces of code that are linked to one another by a thin crust. All these patterns have some features in common.
Why do I code the way I code? Am I coding the correct way? Develop a fully functional dynamic Android application using the latest features of Firebase About This Book …. Today, software engineers need to know not only how to program effectively but also how to ….
Skip to main content. Start your free trial. Expert Android Programming by Prajyot Mainkar. About This Book Dive deep into Android development with practical hands on examples to help you in each stage. Develop smart professional grade apps for the latest Android N version and become a pro android developer. Unclog your development highway by utilising the industry standard best practices techniques.
Your SlideShare is downloading. Building Hybrid Applications using PhoneGap. Prajyot Mainkar. Next SlideShares. You are reading a preview. Activate your 30 day free trial to continue reading. Continue for Free. Upcoming SlideShare. Introduction to PhoneGap. Embed Size px. Start on. Show related SlideShares at end. WordPress Shortcode.
Share Email. Top clipped slide. Prajyot Mainkar Follow. Developing with Phonegap – Adobe Refresh More Related Content Slideshows for you Debugging and deploying with phone gap. Viewers also liked Pengontrol kecerahan lampu pijar menggunakan aplikasi android berbasis arduin Building modern web apps with html5, javascript, and java. What are the best 9 open source app development software solutions? If you want to create smart android applications which are fast, lightweight and also highly efficient then this is the book that will solve all your problems.
You will create a complex enterprise grade app in this book. You will get a quick refresher of the latest android SDK and how to configure your development environment.
Then you will move onto creating app layouts, component and module building, creating smart and efficient UIs. The most important part of a modern day app is how real time they are. With this book, you will create a smooth back-end for your app, ensure dynamic and real time communication between different app layers. You will implement effective testing techniques to make your app reliable and robust and finally you will learn to deploy it efficiently. The multiple stages of android development will also be simplified by giving you an industry standard set of best practices.
Expert android programming prajyot mainkar pdf free
Per-app mobile ms per packet: Shows the Radio-awake-time divided by packets sent – which means, since an efficient app transfers all its traffic in batches, the lower the value, the better it is for the app’s performance. Choose from the drop-down menu where you purchased this book from. If we don’t update the code in some places, it may cause an error. If a subclass uses only some of the methods and properties inherited from its parents, the unneeded methods may simply go unused.
Expert android programming prajyot mainkar pdf free
About This Book Dive deep into Android development with practical hands on Read it now on the O’Reilly learning platform with a day free trial. Android Application Development for the Intel Platform Book Cover of Prajyot Mainkar – Expert Android Programming: Master skills to build enterprise. free eBook in PDF, Kindle, and ePub formats from Manning Publications. Expert Android Programming Prajyot Mainkar Become a.