Coding Tutorial

Expense Manager App - Part 22 | Retrieve Income Data

Estimated read time: 1:20

    Summary

    In this video, Furqan Yasin demonstrates how to retrieve income data from a Firebase database for an expense manager app. The tutorial covers setting up a RecyclerView to display the income data within an Android app. Viewers learn about creating view holders and adapting a FirebaseRecyclerAdapter for displaying data. The video also explains how to sum up total income amounts and display them. With step-by-step guidance, Furqan showcases the importance of Firebase setup and proper event listening, concluding with a working demonstration of income data being successfully loaded and summed in the app.

      Highlights

      • Successfully integrated Firebase for data retrieval 🚀.
      • Displayed income data using RecyclerView with ease 🎨.
      • Used view holders for efficient data binding 🔗.
      • Calculated and displayed total income dynamically 🧮.
      • Ensured data is displayed correctly using FirebaseRecyclerAdapter 🛠️.

      Key Takeaways

      • Set up Firebase to handle income data efficiently ⚡
      • Implement RecyclerView for displaying data in a list format 📜
      • Understand the use of view holders in Android development 🧩
      • Learn to create methods for handling various data types 🎯
      • Sum total income effectively within the app 🏦

      Overview

      Furqan Yasin begins by illustrating the retrieval of income data from a Firebase database into a RecyclerView, an essential component for Android developers looking to display data efficiently. As he codes throughout the video, he explains the creation and use of view holders, making sure they bind data correctly to views.

        The tutorial digs deeper into the Android Firebase ecosystem, showing not only how to fetch data but also manipulate it by summing up integers to display a total income value. This offers a real-world application of handling monetary values in an app, enhancing the user experience by providing quick insights.

          By the end of the session, Furqan has successfully demonstrated a seamless integration between Firebase and an Android app, leaving the viewers with a fully functioning feature that summarizes and displays income data, making the tutorial not only educational but also practically applicable.

            Chapters

            • 00:00 - 00:30: Introduction and Setup The chapter focuses on retrieving income data from a Firebase database and setting it up with RecyclerView. It begins by guiding the reader to open the 'income fragment', change some aspects to 'view', and create an object of 'view', which will be named 'my view' to be returned later. The chapter then discusses integrating Firebase with RecyclerView, suggesting a simple approach by commenting out Firebase-related code.
            • 00:30 - 03:00: Firebase Database Integration In this chapter on Firebase Database Integration, the focus is on setting up and integrating the Firebase database into an application. The process involves several steps, starting with establishing a private database reference, referred to as "M income database" in the transcript. The chapter also involves configuring a RecyclerView, denoted as a private RecyclerView in the context of the transcript. Additionally, there's a mention of initializing Firebase Authentication services by getting the current instance and user, although details are fragmented. The chapter appears to concentrate on the technical setup and code structure for Firebase services integration within a project.
            • 03:00 - 08:00: RecyclerView Implementation In the chapter titled 'RecyclerView Implementation', the focus is on creating a unique user. This is achieved by obtaining the current user and retrieving their unique UID (User Identifier) using methods like `M user dot get you ID`. This UID acts as a unique key under which user data is stored. To manage this data, `M income database` is set equal to a Firebase database instance, where reference paths are obtained using the `get reference dot child` method, ensuring that names are consistent by copying the necessary strings.
            • 08:00 - 10:30: ViewHolder and Methods Creation The chapter discusses the implementation of a recycler view in the context of managing an income database. It focuses on setting a unique identifier (UID) for database entries, configuring the recycler view by finding its ID, and initializing it. The chapter also covers adding a linear layout manager for organizing the recycled views within the user interface. Overall, it's about setting up UI components in an Android environment using a linear layout manager to handle lists efficiently.
            • 10:30 - 12:00: Firebase Recycler Adapter This chapter focuses on the configuration of a Firebase Recycler Adapter in a mobile application. It explores various settings such as setting the reverse layout mode, adjusting start positions, and ensuring the recyclerview operates with a fixed size. The layout manager setup is emphasized to correctly display and manage data lists efficiently within the application. These settings contribute to the enhanced performance and responsiveness of the user interface.
            • 12:00 - 15:00: Total Income Calculation The chapter introduces the concept of managing a layout in a RecyclerView by setting up a layout manager.
            • 15:00 - 19:30: Final Implementation and Testing In the final chapter, 'Final Implementation and Testing,' the focus is on implementing a static class called 'MyViewHolder' which extends 'RecyclerView.ViewHolder'. The chapter guides on creating a constructor for this class and associating it with a view, represented by 'mView', which is equated to 'itemView'. Additionally, the chapter introduces a method for setup by specifying a 'private void setType' method that accepts a 'String type' as a parameter. The detailed steps are crucial for completing the view holder pattern implementation in Android's RecyclerView.

            Expense Manager App - Part 22 | Retrieve Income Data Transcription

            • 00:00 - 00:30 welcome back once again in this part we will retype our income data from firebase database and we'll set this data to our recycle our view so open income fragment and change this to view and create object of view my view and return this my view now in her we need to add our fire ways any recyclerview so we can simply comment out here firebase
            • 00:30 - 01:00 database and add private five Assad Ahmad private database reference is going to be M income database and private and we need to add recyclerview so private recycle our view is going to be recycle our view and in here you need to add a moth firebase ought not get instance now fibrous user and this is
            • 01:00 - 01:30 the risk for create unique user so M user is going to be M Walton dot and get current user and E string UID am user dot get you I didn't in this way we will get our unique user ID key and inside this unique user ID key we will store our data so now M income database is equal to firebase database dot get instance and or to get reference dot child and make sure that we added same name so copy
            • 01:30 - 02:00 this income database and what charge is going to be our UID so now I think all done and now we need to add our recycle of you secular view is equal to find view by ID my view dot find view by ID our daughter I did not recycle our I the income and added linear layered manager and is going to be layered manager is equal to new linear layered manager and get activity
            • 02:00 - 02:30 and you know this Laird manager so layout manager dot set reverse layout true layout manager dot set is tucked from into true and recycle of you Dorset has fixed as true and recyclerview dorset alert manager is
            • 02:30 - 03:00 going to be layout manager so we set our recyclerview and now we need to open our own estate method so open honest ed method and now we need to create a class so
            • 03:00 - 03:30 public a static class and we can call it my view holder extends recyclerview dot view holder and now we need to create an object create a constructor of this class and now again we need to add our view so view is going to be M view so boo is going to be ambu and this mu is equal to item view and now inside this class we need to create our method for our all this required field so private void set type and as a parameter we need to pass a string type and now we
            • 03:30 - 04:00 need to add our text view is equal to M type is equal to MU dot fine view by ID r dot ID dot type text income and these M type door set text is going to be type and now private Boyet set not in this note is going to be easting not and now in hell we need to a textview M naught is equal to MV dot fine view by
            • 04:00 - 04:30 ID r dot ID dot no text income M naught dot set text is going to be this note and profit by it saturday is going to be and pass parameter easting debt and textview m debt is equal to MU dot fine view by ID r dot r dot
            • 04:30 - 05:00 that text income so now M that dot set text is going to be this net and make sure that we add the same ID name was the ID for and it's income recycler and income recycler and we can see yet text income so there's good and you know we need to create one more method for our amount
            • 05:00 - 05:30 so we need to one more method for our amount who and we will retrieve and we also need to convert this amount boosting because we added inside our model class integer so first query method private void set amount and add not a string it was integers so integer amount and add text view is
            • 05:30 - 06:00 going to be M amount is equal to MU dot fine pew by ID r dot ID dog among texts income and this M amount and created esteem variable so esteem ST amount esteem dot value of and is going to be our amount so we need to convert our amount twisting now this MMO watch set text is going to be st amount so I think now all functionality done and now we need to retrace our now we need to
            • 06:00 - 06:30 add our firebase recycle adapter maybe you all know this how can we work with fire recycle adapter inside our honestl method we need to implement our fire way recycle adapter and our model class and our class name and create object adapter and new fireready cycle adapter and s-parameter and in Harrow need to add our model class name second parameter is going to be our layout our third player blood income recycle our data and third
            • 06:30 - 07:00 parameter is going to be our our my view holder class not our database name my folder dot class and last one is going to be our database name so you can see I'm income database and now this view holder dot setup method model dot cat-type DC we will get our type and this view holder dot set
            • 07:00 - 07:30 not model dodge get not and view holder dot said debt is going to be model dot get dead and behold a dot set em on is going to be model dot get amount now we need to set this adapter with a very secular view so recyclerview dorset adapter is going to be our adapter so I think now all done and now we can run our application so we successfully set
            • 07:30 - 08:00 all this required field on this required method functionality with a very secular view so now run this application and here we can see our lives now open this income fragment so now we can see our data we can see our data our tie our knot and our amount for xmas no data and income we can see our data now at 1:1 data
            • 08:00 - 08:30 just at and we can add some dummy text not her root word inside our amount input field and in her you test and in not
            • 08:30 - 09:00 I can alt any random that now cept is not open this income income fragment our data so now we have four data so you can see our data our title our note our amount but we did not set Baroda dinners or count all this a month and and now we need to count and we need to sum of all these integer data
            • 09:00 - 09:30 integer amount and then we need to set this data inside our income textview so how can we do this so I would like to count all this income how much the income and then you need to set this data inside our income fragment as total income so for doing this we need to add add value event listener with our M income database then we will be able to see how
            • 09:30 - 10:00 much data we have so inside our on create inside this inside this main method or what we call in fragment and in her before return my view we need to attach our at value even listener you so how can we do it so if we want to do
            • 10:00 - 10:30 this that abyss I mean combative a start add value even listener new Bolivian listener so it will keep us to method one is on data chance and one is on cancer so we will we need to work with on data chains so inside this on data change method we
            • 10:30 - 11:00 need to do for his loop so for let us snapshot create a club objective data snapshot so data's not shirt and you need to call it when you can college mice enough short my snuff shot
            • 11:00 - 11:30 you and this one is going to be this data snapshot dot get children so did a snapshot dot get children and we don't need to add semicolon here we can add a curly brace or a round bracket closing an opening bracket what
            • 11:30 - 12:00 we can call so in her called and in here we can call we need to create object of our model class so data is going to be data is equal to my snapshot
            • 12:00 - 12:30 get children I think we need to add not get children when you touch get value and inside this below our model class so air to get velu you and now we need to add our data class so data dot plus not gettin into
            • 12:30 - 13:00 and data dot plus-- you so data dot plus-- and now we need to count all these in them all these integer value from this model plus so for doing this we need to create an integer variable and inside this integer variable we need to count one by one so we need to do this for is for look
            • 13:00 - 13:30 for is that item that is inside our m income database so we can now we can call it integer you total value and it is - it will start from zero and then we will count all these our amount one by one so total value is going to be zero
            • 13:30 - 14:00 and this total value is equal to so now this total hello plus is equal to this object of our modeling class data dot get Amanda and this way we will we will count all this amount from our database one by one and is to read inside our total value integer variable
            • 14:00 - 14:30 okay maybe you understand this now we need to convert this value to easting so string call EST total below is a culture easting got value of you
            • 14:30 - 15:00 and we can call it total hello you so we said so we convert our data and now we need to set this data with our text view but we did not add this text view so now we need to define our text view we can call it text pure result how
            • 15:00 - 15:30 textview and it object so private can call it textview private takes pro is going to be income text and in inside this income text we need to set our total amount so I think instead of days we can call it income total that'll be more meaningful so you
            • 15:30 - 16:00 can call it income total sum and now open this and what was the ID make sure that we added the ID name and to need to open our income fragment no data so open income fragment so fragment experience and the Tonys fragment income so open this fragment
            • 16:00 - 16:30 income and our ID name was to open our second relative layout and this second relativelayout and our ideas ladies income tax - Reza okay so copy this one you
            • 16:30 - 17:00 so now in computer Sam you so now income total sum is equal to I'm income database first add to my view dot fine P by ID
            • 17:00 - 17:30 our daughter DDOT and our extra body name you and now we need to set this total sum with inside our takes P so income total Sam got set value
            • 17:30 - 18:00 dot set definite set value and it's going to be st total value you so I think all functionally done for our income fragment now we can run our application so here is our income fragment and now we can see our total summation of no perfect now it's working so successfully
            • 18:00 - 18:30 so we successfully did all the summation of our four input field for in the for recycling data that we added to our firebase database and we retrieve it and we say this and set it to textview so we successfully complete this okay for example let's create one more amount and we can call it eight thousand or add more
            • 18:30 - 19:00 and at few dummy text random text just for example and safe and open these - income fragment and now we can see total summation and a weed we also retype our data so that's it for this part