Create a Money management application in Android Studio | Meisam Mansourzadeh | Skillshare

Playback Speed


  • 0.5x
  • 1x (Normal)
  • 1.25x
  • 1.5x
  • 2x

Create a Money management application in Android Studio

teacher avatar Meisam Mansourzadeh, Professional Android Developer

Watch this class and thousands more

Get unlimited access to every class
Taught by industry leaders & working professionals
Topics include illustration, design, photography, and more

Watch this class and thousands more

Get unlimited access to every class
Taught by industry leaders & working professionals
Topics include illustration, design, photography, and more

Lessons in This Class

23 Lessons (8h 7m)
    • 1. Course Introduction

      1:36
    • 2. Create DtatabaseHelper class

      17:08
    • 3. Register Activity

      24:25
    • 4. RegisterActivity Continued

      20:20
    • 5. Testing RegisterActivity - Create WebsiteActivity - Start LoginActivity

      27:05
    • 6. Login Activity

      22:01
    • 7. MainActivity Layout

      20:53
    • 8. Toolbar AddTransaction Dialog

      20:49
    • 9. Get Transactions from Database Transactions Adapter

      22:32
    • 10. Cubic Linear Chart

      27:38
    • 11. Bar Chart

      22:15
    • 12. Customize the Bar Chart AddShopping Activity

      24:12
    • 13. PickItem Dialog

      21:22
    • 14. Finish AddShopping Activity AddInvestment Activity

      20:47
    • 15. Add Investment Work Manager

      20:52
    • 16. Finish Creating AddInvestment Activity

      21:43
    • 17. Show Investments in InvestmentsActivity

      23:07
    • 18. TransferActivity

      18:39
    • 19. Debug TransferActivity AddLoan Activity

      22:09
    • 20. Show Loans in LoanActivity

      29:51
    • 21. LoanActivity continued SearchActivity

      25:26
    • 22. Line Chart and Pie Chart in StatsActivity

      26:54
    • 23. Final Touches and Tips for Production Release

      5:35
  • --
  • Beginner level
  • Intermediate level
  • Advanced level
  • All levels
  • Beg/Int level
  • Int/Adv level

Community Generated

The level is determined by a majority opinion of students who have reviewed this class. The teacher's recommendation is shown until at least 5 student responses are collected.

154

Students

--

Project

About This Class

Master your skills in Android App Development by writing an entire application from scratch.

  • So you have been learning Android App Development for a while but you feel that you don't know how to use the knowledge you gained?

  • Or maybe you Just want to practice everything that you have learned and see your skills in action?

If that's the case this is the perfect course for you. 

In this course you are going to create a money management application from scratch. In this application:

  • Users can register, log in and log out of their account
  • Users can see their spendings and loans and other activities on theirs account in beutiful charts. 
  • Users can add a shopping
  • Users can Send or recieve money
  • Users can add their investments and an interest will be added to their accounts every month, similarly for the loans, the loan payment will be deducted from their accounts every month without the knowing about it
  • Users can search for a specific transaction based on different filters

And a lot of other capabilities

In this application you will learn:

  • How to draw beautiful charts, like linear chart, bar chat and pie chart
  • How to work with a SQLite database
  • How to Handle background tasks with Work Manager and AsyncTask
  • How to work with Recycler view and card view properly
  • and a lot of other things like working with activities, fragments and dialogs

As you can see there are a lot of topics covered in this 8 hour course and if you want to master the skills that you have gained this is a perfect course for you.

Buy the course now and Stabilize your skills in Android App Development for good.

By buying the course you will have access to discussion forums and you can ask your questions any time you want, you can also talk with other developers as well.

This course has 30-Day Money-Back Guarantee, meaning that if for any reason you don't like the course you can issue a refund within one month, But beside that if you still have hesitation about buying the course you can always watch the free preview and decide after that. 

Thank you for your time and see you in the course.

42f30f10

Sincerely, 

Meisam

Meet Your Teacher

Teacher Profile Image

Meisam Mansourzadeh

Professional Android Developer

Teacher

I studied pharmacy for 6 years but I'm passionate about tech world and it always excited me
I created tens of android apps and I love to teach.

I have been a pharmacist and an English teacher, but it's a few years now that I'm focused on android.
Internet of things, game development (specially for PS4), web design, python and java and Spring framework, German language and philosophy are my other passions

See full profile

Class Ratings

Expectations Met?
  • Exceeded!
    0%
  • Yes
    0%
  • Somewhat
    0%
  • Not really
    0%
Reviews Archive

In October 2018, we updated our review system to improve the way we collect feedback. Below are the reviews written before that update.

Why Join Skillshare?

Take award-winning Skillshare Original Classes

Each class has short lessons, hands-on projects

Your membership supports Skillshare teachers

Learn From Anywhere

Take classes on the go with the Skillshare app. Stream or download to watch on the plane, the subway, or wherever you learn best.

Transcripts

1. Course Introduction: do you want to learn 100 up development? In a practical way, Do you want to practice your skills in 100 of development in a really bold application? Then this is the perfect course for you. Hi, my name is Mason Kleiman, online instructor. With more than 100,000 students in these courts, you are going to create an accounting application for managing users investments, loans, shopping and transferring money from scratch. In this application, users will be able to register, sign in and sign out. Users can search for different transactions based on different Fiedler's investments. Profit will be added to their accounts automatically in the background on loans. Interests will be deducted without them knowing they can see different charts like pie charts, bar charts and lean ER charts based on different activities on their account. Some of the topics that we are going to practice together are managing SQL databases, drying beautiful charts with beautiful animations, handling background tasks with facing task and ward manager recycle of you and it's adapter on so much more. But that's not all you will get by enrolling in the course. You will also have full lifetime access to more than eight plus hours off downloadable video contents to the state. More than 40 plus 1000 students have trusted my android app development tutorials, and you can check the reviews down below this page. This is a special project based course in retrieval practice a lot of your skills in hundreds of development enrolled in the course. Now on, Let's create a real world application together. Thank you for watching and see you in the course. 2. Create DtatabaseHelper class: Okay, lets start creating our application. I'm going to stick with the empty activity. For now. I'm going to name this project. Maybank. The package name is fine Location. It's fine Job for the language. I'm going to stay with 100 kids. Get for the minimum a level on since using 100 ext. Artifact are mandatory. So we are going to stick with that. Let's create our project. I'm going to start by creating my date of it. So I'm going to close all the activities on layout finds for now inside the package. I'm going to create another package. Let's name Despont. Data, please. On in here. I'm going to create my database helper class. We need to extend the sq like open help there before we create the construct. Er for this class, let me creates two constants. One for the name of my database and another one for that version of my data. So those would be private static. Final string. Let's colic TV name. Let's name this fund DB. Maybe another one for the date of his version. Private aesthetic final integer That's a TV version is equal to foreign etc. No, we can create our construct. Er, I'm going to press out plus insert. Let's stick with the first instructor on Let's minimize the project pain for now. I'm going to change these constructs there. I'm going to remove all of these, but the context on Downing here instead of name Let's pass our database name for the factory. I'm going to pass No for the version. Let's pass TV version We need to override the UN create on on operate method. So let's do that. I create on upgrade. Let's start by writing our own creating. First of all, let's have a look. I'm going to have multiple tables inside my database, one of which is the Users table, where I can save some information about different users off my application. So let's right the proper SQL a statement to create our user stable. Let's say stream, create user table. Is he called to and in here I'm going to write my SQL statement. Let's say create table users. We need to identify the columns. The first column is going to be an idea for the users. It needs to be primary key, and also it needs to be also increments. So let's integer primary key on a auto increments. After that, let's define the email. Call him its state of this text. We are going to have a passport for different users. So let's save that passport. Take, Let's go to the next line. We are going to have a first time last name. First name. Thanks. Last name. Thanks. We are going to have an address, So address text. We are going to have an image. You are You made your text. We are going to have another column inside this user stable called Remained amount. Basically, we are going to save the amount of cash that user plans in his account. This probably isn't the best practice, because inside this table we are going to save different information about the user on not anything related to his account. Later on, we will create a transaction table, which will save all of the users transaction. If you want, you can create another intermediate table between these users favor on that transaction table and saved the user's account information inside that table. But because of the simplicity, I'm going to put the remains amount in here. So let's say remained amount it needs to be done among all of these columns. We know that the idea column is not going to be no, because it's a primary key. But we need to make sure that the email and password is not know at any time as well. We can accept no for others, but for these two, we should make sure of that. For that. I can't not know at the end of each college let's go to the next life after the passport. Let's say not smell. Okay, now that we have our SQL statement, let's executed. I can say issue light database. Execute SQL. I can't pass my stream. Create user stable. Okay, let's greet our second table. The second table is going to be a shopping table. Let's say create shopping table. He called to that streak in this stable. We are going to save the shopping history off the user. So let's say create table. Let's call it shopping. Once again, we need an idea into jer primary key on a auto interment. Later on, we will create an item table which will save different information about items one off the columns off that table is going to be on idee on in here. We are going to use that item idea as the foreign key. So let's say I m I t on. It needs to be integer. Also, I'm going to save the user idea inside this table as well. It will be the idea off the user that has purchased these specific idea so lets a user i d . Once again, it's going to be an integer. Later on, I'm going to have a transaction table in which I view at different investment different loans on also different shopping's into that table as well. For that, I'm going to say the transaction idea here in case we want to connect these two table together the shopping on the transaction. So let's say transaction I d. Once again, it's going to be an interview. After that, I'm going to have a price. Call them. It needs to be double. After that, we are going to have a date. Let's save it, hasn't they? Let's also add a description. Call him in case the user want to add a description to this shopping. That's the sq in a statement for creating the shopping table. Let's just executed sounding here and I can see ask you, like database. Start execute SQL on I can fast my create shopping tape of the street. Let's create another table for saving different investments. I can say this drink. Create investment table the culture create table. It's called it investments for the columns I'm going to on I d. Call them like before. Integer on Primary Key on also auto interment. Let's have an amount. Call him in here. It stated type needs to be doubled. We are going to have a monthly are, or rate of interest Colin to calculate the interest off the user monthly, although I it stated type needs to be doubled once again. Let's also have a name for this investment in case the user wants to add the name. I'm going to save the in its date on finished eight off this investment as well. I'm also going to save the transaction idea for the initial transaction off this investment on also the user i d. In order to link the stable to the user stable if needed. So let's say use their i d integer on. Also, it's transaction I d integer. I'm not sure about all of the columns and details off every table. I'm not sure that if they are going to be needed, I'm also not sure that if we are missing anything, but that's totally okay because we can change the construct er off our database whenever, even so probably we will come back to the state of a cell for class later on. Okay, our SQL statement is ready. Let's just executed Ask your light day heavy stuff. Execute this here, create investment table streak. Let's create another table for saving users loans. Let's say it's drink. Create loan stable is the call to create table loans for the columns. I'm going to have the mighty call him incision, primary key and also increments. After that, I'm going to save the initial dick on also the finish day. So let's say in its state date at the state of type finish state once again date as a date that I After that I'm going to create another column for saving the initial amount of the loan. So let's say it amount. It needs to redouble. I have a typo in here. Let's fix that. After that, I'm going to save the remained amount of the loan. Let's also save the monthly payment off the loan. Mostly payment. Let's say double. I'm also going to save our I or rate of interest on this loan. So let's do that. That's a monthly on Roy. Once again, it needs to be double. Let's also have a name father for every loan it needs to be takes on. Also, I'm going to at the user idea here in case we want to connect to our users. Okay, let's execute this disc. Your statement as he like. Database that execute us here. Let's pass our create loan stable. Let's drink. Let's create another table for saving different transactions. Let's say it's during creates transaction table. Is he called to creates table? Let's call the transactions. First of all, I'm going to have a noisy calling into the American auto interment. After that, I'm going to have an amount column. It needs to be double for the amount of the transaction. After that, let's save the date off the transaction. I'm also going to have another column in here called type, so basically, I'm going to save all of these different transactions inside this transaction tape of different shopping's investment loans, all of them inside this table on by this type. I'm going to identify the type of that transaction made with the shopping, investment loans or any other point. So for that, let's have a typing here on its state of five nets to be takes. After that, I'm going to save the user I d. It's going to be an integer. Also, it's better to save the recipient in case you want to show the user who is the recipient off this transaction. For example, if we are saving alone, the recipient would be the bank. If we are saving a shopping, the recipient would be some shop so on for the investment table. Besides these three different recipients, I'm going to have another one as well. In case the user sent any money to another person. I'm going to save that receive payment in here as well. So let's say recipient on, let's say, takes as its data. Let's also have a description. Call them in case the user want to add any description. Let's execute this SQL statement. Danny, here s you like database, execute SQL create transactions. I'm going to create one more table for different shopping items so that we could have some information about that. I can, for example, an image, your description and also maybe the name of that item. So that's a string create high temps table. Is he called to creates a favor. Why, Tim's We need an idea color. We need a lame, which is a state of type, is going to be text. We need an image you are in here. Its data type is going to be takes once again. Also, let's add a description in here in case we want to have any description for our items. Okay, lets just execute this table. And I think we are done with our different havens. We are done with our database. Elbert Class. Let's just at some initial items to our items table. For that, I'm going to create another methadone in here. That's a private Boyd initial items. That's not a lot. In order to add some light into our table, we need to create a content values off. Let's call it. Values is equal to new content values for the parameters I'm going to say values that put first of all, I'm going to add a name for this item. So let's say a name for the key on for the manual, etc. After that, let's say values that put Let's have an image. You are l for our bike on the image. You currently have copied it from the Internet. Let's also add a description to this bike values that put description. Let's just say the perfect mountain bike. After creating this content values object, we need to add it to our database. But before that, we need to receive the sq flight data racing here on down in here. After creating the content values we can see tv dot insert, we can pass our table name. That's the items let's pass. Known for the no column back on. Also, that's past our values. We just need to call this method from inside on, create method after creating all of our tables. Let's see, at initial items on let's pass our SQL database just before I finish off this video, let's test our database inside the main activity. I'm going to do a curie on my database here. Let's create an instance off database class is the quarter new database helper. We need to pass the context, which I'm going to pass this. After that, we need to create a secure database that's a SQL database. That's quality D B is equal to date of a helper to get readable data ways. I'm sure that you know that this is not a good place to create a database on. Also, this is not the good way off creating a database. We know that we should do all the communications to the database inside another threat on. Also, we should avoid defend SQL exceptions. But since it's just for testing, I'm going to keep it simple on I'm going to do it. After that, we can say cursor cursor is he called db dot curie for the table name. Let's say items for the columns. Let's pass now. I'm not going to have any selection, and selection arguments are very too personal for both of them. We don't have any group by having no for them. And also let's pass now for the order. This is a very basic Yuri on. We are doing it just because we're going to test our database. After that, let's check if our cursor is no or not. You know nothing about our cursor. If cursor don't move first, let's either log up in here. Let's look the name off down in here. I can see lug d Let's see me last cursor. Don't get string being in the column index, which I'm going to pass cursor that get calling digs on the calling Indexes name. Okay, now we can test our database. Let's just run our application on. Let's open the look at in here. Inside. Look at you can see the name off the item, which is by Seems like our database has been created successfully, so let's move on. Okay, I'm going to finish off this video in the next video. We are going to start working on the reduced their activity on Maybe if we have time, we work on the logging activity as see you in the next with you. 3. Register Activity: Okay, lets start creating a register activity. But before that, let me close all of the classes inside my package. I'm going to create a new package called Authentication on Inside Death Package. I'm going to close my register on lugging activity. Maybe later on we will add some others to that package as well. So let's created your package. That's kind of authentication. Let's create a new activity in here. You're empty activity. Let's call this fund register. I think. As you can see in here, we are getting a red, are warning. It means that we need to import the art class. You can click on our end you campers alter plus enter in order to import that class. If you want to make sure you can check your imports in here and there's against our has been added. Okay, first of all, let's start by creating the exemplify the layout file. Let me minimize all these extra pains on Let's wish to take you. First of all that's changed is constantly out to relatively out inside the relatively earth . Let's create another relatively and threat content on draft content. Let's move it to center, something that's true We don't need any idea in here on. I think that's it. First of all, I'm going to define a new image view. I'm going to put my logo in here. You can prepare your logo on you can anything here, let's say 154. Defeat on 50 before the fight. Let's give you some idea. No, let's stress a logo for this image. I'm going to copy some image that I have prepared previously. I'm going to copy my mobile into my project. Inside the Meat Man folder. Resource says Meat MMA. That's pasty thing here. Okay, on, I think the name this fight okay, after I think that down in here I can say source on, I can address that. Okay, I think that's it for the image you. Let's add some text for the 1st 1 I'm going to receive the user's email. So for the eat sweets, Feinberg's a match trying it on for the high draft content. I need to move it to be loved. My image of you, I said. No go. That's also moved these logo to centering horizontal center for is in talks with Let's add some margins to this edit text. That's a margin Top trying TP margin left and right to 30 dp. Let's also have their hands that stress saving me. I'm going to define on input type Blister, say, takes the email address. I think that's it for this edit text. Let's just increase the margin. Talked to 50. Okay, let's add another edit text. I think I can copy this fun, but I need to change it a little bit on. Also, we didn't set any idea for the first edit text that said that. Let's just say he did txt for the 2nd 1 I'm going to decrease that margin. Top 10. I'm going to move it below my ttxt. I need to change the email to passport. I need to change the input. That's just a takes. The passport. And also that's it. Let's go with this one more time For the third edit text, I'm going to receive the user's name. So let's say name. We don't need to import I on. Let's change its idea to edit text name. We need to move it below our passports. Let's have one more edit takes for receiving the users actors. I need to change this fun off course. Let's move it below our name and it takes. Also, let's change its idea to edit takes address. We need to change the hands to address. You don't need this import type, but we do need to increase the light. I'm going to set the lines to two. I'm going to keep the registration simple. So I think this, for critics would be enough. After that, I'm going to add a relatively out. It's just a match ban for the weeds on draft content. For the height, we do need an idea in here. Let's say images relatively. Let's center it horizontally can say center present. All too true. Inside this relatively out, I'm going to put five different images on the user can select one of those pre different images to sit as he's or her profile image. In a real world application, you may want to give the user the option to select a photo from his gallery. Or maybe you may want to give him the option to take a new photo. But in here I just wanted to keep it simple, so I'm going to show to the use their five different avatars on the user can select one of them. But before that, I need to move this relatively to below my address. Sedatives, Let's say below are addressed. Editing. Before I think those five avatars, I'm going to copy them to my project once again. As you can see, I have prepared these five avatars. Let's copy them in tow. Meet my folder. Now that we have the images, we can add them in here. That's a image. You I'm going to say 50 before the with height. Let's give it on idea. But first image on for the source. Let's say, boy was the name of my image. Okay, As you can see, the boy has been added in here. That's it for the first image that's just changed this rule. If you play out its big to wrath content, that's also at the margin. Tough 10 50. Also, I'm going to move it to center. So let's say center horizontal. I believe I have defined hiss behaving here. That's at another image. I need to change its idea to second image. Let's also change its source to gear. We need to move this fun to write off the boy image. That's a right. Why the first image and also being either margin left? Okay, let's add another one. Let's coffee. This you need to change the idea to 30 minutes. You need to change its source to. That's a man they believe was its name on. Also, we need to move you to write off Second, another one. Let's add one final image. Okay, these are our five avatars. After this, relatively out, we need to add a button. Let's save button, grab content and wrap contents and resented. All too true what it takes, Let's say register for its idea. That's a VT and release their Let's move it below our image relatively out on. Also, let's add a margin top off or anything. I don't like this great background, so let's change that. You can navigate to our call. They re sources inside. The resource is values on colors that XML I'm going to define a new color. Let's put it this fun face sitting here. Let's change the name to I don't know. Let's say orange on. Let's change its value. Let's see, How does this one Let's save background hand? Let's address our cover that seems better. Okay, after this register button, I'm going to define and you takes to you. Basically, it's going to be some violent that we're going to show to the user in case something ground happens during their registering process. So that's the rap wanted Rap content Center for isn't true, but its text Let's just say warning for the time being. That's also changed the corner, too, or text color to color accent. I believe once the name of that specific color that's moving to be low our button, they are to be low Bt and register margin. Top, I believe, to any DP would be fine. Yes, for the time being, let's change the visibility of the stakes to come. We don't want to show any warning to the user in case if it's the first time that user is saying this registration for after the stakes view, I'm going to add another text view. Do you see Volume adding this rap rap on 10 text for its takes? Let's just see, have an account looking from here. I have a type of fear. Lister speaks that Let's move these Now let's move these takes to below are warning text. I believe we don't have any idea for this partner text. That's just added, Let's say txt down in here, I can see below Arctic Sea. Let's center it something horizontal to true. Also, let's change the color of the stakes. Let's say I don't think we have any blue color that's quickly at that. Once again, I'm going to pop the previous father. Let's change its name to Blue on. Let's change its value. I think this one would be fine. Okay, now I can address my color. It's the color blue. Also, let's add a margin. Top offense. A 50 BP. Yes, that's in spite. That's it for this text for you. I'm going to navigate the user to logging activity in case the user has an account on Want to navigate to the logging activity? I just need Von More takes view to finish off creating this layout, and I'm going to do that after this relatively in here, I'm going to say, takes you repentant on that content for its text. Let stressed State never looked by Mason. I had to make what does work. It's just the license text on it might help Brandy. Okay, after that sits alone. Parents brought him to true so that the movie to bottom off our layout, Let's center it horizontally on. Also, let's get a margin but him off 10. Let's also changed aside. Takes this slow to italic on. Also, let's give it on radio. Let's say txt license. Let's also give an idea to this takes to you often hear I forgot to do that. Not safety Eckstine. Luggage on. That's all we need to do in order to create our layout. Five. I'm going to press control off L in order to reformat my coat. Nothing has changed. Just the order of things has been changed so that later on, if you check the source code, your coat would be the same as much on by the way, you can check the source code and my website at make what? That order slash codes. I'm including the coats right after every video that I record. Okay, let's go to the register activity job. If I on initialize all of these items that we just defined in order to save your time, I have initialized all of these items. I'm sure you can do it by yourself. So we have these. Any fuse method where we address our layout finds nothing too special in here. After that, I'm going to set up on Click Listener for this on the button between registered, let's say between reduce their but said Sleepless in there, your click listener on. I'm going to do the job in sight. Another method. Let's say you need to register. Let's create this method down in here. Private Boyd produced there. You don't need to receive anything. Let's just add a long on. Let's say you start in this method. First of all, I'm going to get the value of all of this edit text, especially the edit text email on anything's possible because if you remember in the date of his helper class with me, open that in here. We have set the value off passport on email to not know, so we need the user to at least enter the inmate on passport. So I'm going to receive the email and password, and I'm going to check that if there's through, editing are empty or not. So let's say this drink he made is the call to text email. Don't get takes that to stream. Similarly for the passport down in here, I'm going to write an if statement if female that is equal toe on empty string. Or, alternatively, if passport is because who on empty streets. If each one off those condition is true, then we are not going to pursue. Instead, they are going to say DXC warning that said visibility to the civil so that we could see some warning. After that, we are going to change the text off this 60 vote. That's a text to, let's say, who has entered the password. But in the end, this case, first of all, I'm going to change. The visibility of this takes the warning to gun. It's maybe visible. So you need to change that first thing that said these immunity to gone. After that, I'm going to search for my database to see that if we have any user with this aiming register, if we found any user with that image, we are not going toe hello to the user to register with the same email. We are going to tell the user to enter another Amy, but because I'm going to connect to my database in here. I'm going to do that inside another threat on for doing the background test. I'm going to use the racing tasking here. So down here, let's create our basic test. Let's say private class does use there exist. It needs to extend the casing task for its parameter. I'm going to say a string as the influence because I'm going to pass the email address. I don't need any progress on for the result, I'm going to say Boolean, indicating if we have found any user or not. Let's implement that being back their own method inside this name background, I'm going to make my connection to my database. So I need any instance off my database helper class. But I believe we are going to use that class in different places in this producer activity . So I'm going to define that as a member. Valuable still. It's a private database helper. Let's college date of a silver before everything after this interview, I'm going to initialize that place is the call to a new database helper, you to pass the context, which we can't trust this on. After that insight, he's doing background method I'm going to write my try catch block in order to avoid the SQL exceptions. Notice that in here we have to kind of SQL exceptions this phone on the second we need the 2nd 1 that comes from Andrea Data Aries That's cashed that on for the debugging purposes. I'm just going to print its factories, either. Bring with factors inside the tribal. Look, I'm going to say s u of they have these. Let's call it D V is equal to database helper thoughts. Get readable data please. After that, I can create my cursor. Let's say cursor cursor is he called to debate that Curie for the table. I'm going to look to the users table for the columns. We don't need anything especial. Let's just get the idea and email off that music. What's in your string area? Let's get the I D. On. Also the for the selection. I'm going to say where he made is equal to a question mark on after that. I need to pass my selection argument. I can say new string area. Andi can't pass my email address speech I have received by the inputs off this method, I can't see the streams who tend index off. Zero. Let's out some interesting here in order to see the court better. After that, we don't need having and group I soon. It's fast. No, on also, we don't need any order. Now that we have our cursor, I can say if no is not called our cursor once again If cursor don't move first, Before we write this logic, I'm going to write else cases. First off, if the cursor is no, I'm going to close the database. So let's say we ve got close on. After that, I'm going to return. True if you remember the same type of the stream back on method is Apulia, which is exactly the data type off the result of this facing test, a tremendous bullion be passed to on post executing. Let's quickly over right that as you can see, the return type is a bona so in here we are passing through. Basically, we didn't find any user. So the cursor, But why are we passing through in here? Well, we didn't find any user from our database with this exact aiming that we have passed, but we weren't able to cure the database. And for some reason, our cursor is known at this point. So we are not sure that we have such a user with this image in our database or not. So I'm going to pass doing here later on in my own post execute method, I'm going to put a condition. I'm going to say that if the bullion is through, so don't pursue the coat on. Show some warning to the user. So for that reason I'm passing through here. Okay, Let's right the logic for the else case off this if statement in case the cursor does not move to the first element In that case, it means that we do not have any elements. So it means that we didn't find any user with such a made in our database, so we can safely return false. But before we sending, I'm going to close my cursor. After that, I'm going to close my database on. After that, I can return falls. Okay. Lets right alleging in here in case the cursor moved the first element in here. I'm going to check that if cursor does get a string with an index off cursor, don't get column index The index off the main column. If it is equal to the email that we have received, where the imports off this doing background method here, it means that we have user with this exact image. So if it is the quality of strings with an index off zero, first of all, we are going to close the cursor like before we are going to close the data vase. After that, we need to return. True because we have found such use it. The else case for this if statement is not necessary because here we have retrieved a record, which it's a maid, is not equal to the email. But if any, how we have retrieved a record from our database, which it's email is equal to the email that we have received where the stream backer method we are going to return falls. So let's right that this s case should never execute. But it's just for safety. I can copy these three lines from here. Okay, I think you are done with this dream background method. Just inside this catch block down in here, I'm going to return true because it means that something wrong happened so later on inside the on post execute method, we are not going to pursue the coat. Instead, we are going to show some morning to use it now that I'm returning in some value in any if case on even inside the catch block. I don't need to return this now because, as you can see, the warning in here says that it's unreachable a statement so we can safely do that. Okay, let's right The logic for the on post executing method After the super statement, I'm going to say if a Boolean is true, it means that if we have found any user or in case something wrong happened, we are going to show some born into user So I can say Take Steve Arning set visibility too visible after that. You Steve ironing upset text to let's say there is a user with this human. Also, let's say please try another Amy in the S case. First of all, I'm going to change the visibility off 60 warning to go on. So let's say said visibility gone after that, I'm going to add this new user to my data. These for that. Once again, I'm going to create another a sink task. But since this video is getting a little bit long, I'm going to do that in the next video. Just before I finish off this video once again, I'm going to say that you can check the source code at my website and make that orc slash codes. You can see the links under screen. And also, I would love to hear your comments about the court. Okay, See you in the next video. 4. RegisterActivity Continued: in the previous video. We have created this facing test in which we are checking that there is the user registered with this email that the new user has entered in the registration for in this on post execute, we are receiving a Boolean indicating that if there is a user or if there is not, if there is, we are showing some warning. And if there is not, we are going to create another a sink test to at the user into our database. So let's create that spacing test done in here. I can say private, less register user. It needs to extend the facing test for the parameters off this facing test. I'm going to pass void as input under the best void as the progress. But for the result, I'm going to pass a user. We haven't created this user class, so let's quickly create that inside the package. I'm going to create another package on a very condemning mothers. Let's create the user quest and say this mother back it. This user class needs to be identical to the users table. So in here I'm going to say private idee prizes string email, private street passport, Private stream. First name, private string. Last name private. This drink address right with the stream image you are on private. Double remains amount. Let's create to boast directors. One would receive all of them. I'm not sure we are going to use this one or not, but let's just created another woman into cost character. We are going to use this fun that's also create. Get there. That's it. After everything that stress created to string method for debugging purposes. Okay, this is our user Mother. Now we can switch back to our reduced their activity, and in here we need to import. That is a plus. That's overrated. Doing back down method once again in here I needed try cash blood in order to catch the issue. Exceptions. The one that comes from Angelito database package. Let's bring the stack Trace leaders, prints, factories. After that, I'm going to return. No, it means that something wrong happened and we don't have any user to resent. So I'm going to return No. In here. Well, site to try block. I'm going to create my sq like state of ways. That's polity. V is the call to date of a stepper. Let's get right about eight of a system because we are going to add the user to RV service . After that, we can insert our user to the database. But before that, inside the on pre execute method, I need to receive the value off those Eddie tastes. That's all right on to execute after the Super statement I can say is think Teammate is the call, and it takes. He may not get takes that to string similarly for the passport address and they but because I'm going to use all of these values inside linebacker on method, we need to save them as a member. So in here I can say with ST he made some love for all the others. For the name part. We are saving both the first and last name off the user inside our database. But we are receiving only warning by Avante detects, I'm giving the user the option to enter his or her first name, last name. And also, if he or she has a middling, he or she can put the middle name as well. For that, I'm going to change the name of this name to burst me on. Also, we need a last name here. Has you're gonna see the logic in a minute. But before that, let's set the value of all of these member variables to the value of all of these meditates . For that, I can say this that you may is de part to be made similarly for all the other fuels for the name part. I'm going to check that if the user has entered only his person ing or first and last night for that, I'm going to split this straining here. For that, I can see string area. Let's call it names. Is the call to name that split on for the character in here. I'm going to sit on the space because we know that when somebody is going to type his or her first name, they definitely put in a space. After that. I need to check the last off this names a string area. I can't say if name stuff is greater than our people to go on. It means that if we have at least two segments, But before I write this logic, let's right the logic for the else case. The S case means that the user has only entered bonding. It means that it's the first name off the user, so I can see the stars. First name is the part with names with an index of zero. But in case these names during area contains at least two segment, we are going to first of all, copy this line off court from here on. After that, we are going to take care off the middle names. For that, I'm going to create a form do, let's say, for I is the call to Von because we have took care of the first element within index up zero. After that, I can say less than names that dance, and after that you can see I hospitals in here. I'm going to say that if I is greater than but it means that if the user has a me building , so we are going to set the last name. This way I can see last name, plus equal some space, plus the names with an index off. But in the ends case, I'm going to say last name was equal names with an index off. I will review it in a minute. If you're around me. So let's talk a bit about this logic in here we are receiving the user's name. We are splitting the user's name with this rejects character in here with this space, if the length of this newly created a string area is equal to one or if it is greater number. First of all, we are setting the value our first name two names with an index off zero, which is the first element. After that, we are creating a four Lou, we are no longer interested in the 1st 11 So we are starting from the second element with an index of one in here. We are checking that if the index is one, it means that if we are looking at the second element off this string area, we are going to append this name to our Leslie, which at the moment is empty. But if the index is director number, which means that if you are looking at the third or forced element, we are going to append that element to our last name. Plus, we are I think this is spacing here, but in the ends casing here, if the user only interest bonding we are going to set that name as the 1st 1 That's all the allergic in here. Okay, that's all meaning inside this country. Execute method that switch back to doing background. So here inside the tribal, after initializing our database, I can create a content values object. That's a content values values is he called new content values. After that, I can put all of these values inside. My content values are against the values that foods. First of all, that's after he made on its Andreas out this stuff. Similarly, for all the others. If you remember, we had a column inside our user saver called Remained amount. Whenever a new user is really strength, I'm going to set that value to, let's say, zero. That's the remains amount, and let's set its value to 0.0. We have only one other column that we need to be worried about, and that's the image. You are all part. If you are creating a real world application, you need to take a photo from the user or maybe select a photo from his or her gallery. After that, upload that photo to your Web server. After that achieved you are off that image to your application on, Finally said that image you are in here inside this content values object, but we are not going to take a photo or selective photo from the user's gallery. Instead, we are going to use our own images, which are going to be saved locally inside the users device for death. I'm going to create a member valuable inside this register activities member valuables, something here I can say private this drink image you are. I'm going to initially set it to first image. Let's do that in here, but say image you are is equal to first. Later on, I will check this keyboard, for example, for 2nd 3rd 4th 5th on depending on that key, I'm going to show one of my five images to the user. But I need to sit on Colleague Listener for each one of these images. So let's create another method and creates my colleague listener for each one of these image views. I can't say and handle image joy. Let's create this method down in here for someone that's had a look on after that, that's a first imaged upset on quickness, learning New York witness. Now I can say imagery are ill people to, let's say first Similarly, for all of the others. Okay, now that we are sitting the image yard, we can pass it to our content values. Objects inside these doing background method off racing test. I can say values that put but see image you are on, Let's pass are enjoying. We know that this is not an image your but. But I named it immeasurable for you to understand the concept of this column inside our database. Okay, we have our content values, objects we can say TV that insert Miss Best user stable after that snow for the no call and back on. After that, you can pass. Our values are. We can also save the idea off. This user that is going to be added to our database has been seen here. The return type of this method is a long, and we can save that. That's a long user. I d. Is. It called that before everything. Let's just like the value of this use already. Now that we have added this user to our database, we need to retrieve it from the database in order to add it to our shared defenses so that the user won't have to liking the next time that he opens our application. Where that I'm going to create a cursory here, that's a first person. Is the call to DVD que area or of the table? That's a users for the columns that say no because we are interested in all of the columns after that for the selection. That's a look at where the I D is equal to a question mark on for the selection argument that's creating new string. Every after that, it's best String does value off our user idea that we have received or saved in here. Let's have an intern here. We don't need the group by having and sort or service past, nor for all three of them. After that, we can check that are cursory is no or not in case it's no, let's return No on. Also before that, let's close our date of its let's say TV does close. But in case we have a cursor that say, If care, sir, that's moved first. First of all, that's right. The in this case in the else please it means that we didn't achieve any user. So let's close the cursor that's close the database. After that, that's return now. But in case our person moves the first element we need to create a new object off find user . That's a user. You there is 1/4 new user on. Here is where that empty construct A is helpful. After that, I can see User that said I d to let's say care certain that get integer. That's the cursor that get Khanum index off the column. Why do we need to do the same for all the other fields? After we said all of the values off this user, we can return, you can see return Muser, But before that, we need to close our cursor on. Also, if you need to close, our data is. But now that we are returning something in all of different cases, we don't need this return now. This last statement in here because it's unreachable anyway. Okay, let's continue on now. It's the time to override on post execute method after the Super statement, personal what? We need to check that the user is no or not. In case it's not know they are going to show a toast message. Miss Jessie, User, with this inmate address has been added. Successful user does get you made plus forages start successfully. After that, we need to save this user into our shared preferences so that if the user come back to our application one or two days later, he or she wouldn't see the lugging activity bonds again. We haven't created the logging activity, but we are going to do that. And first thing that we are going to do inside the main activity is that we are going to check our shared preferences to see that if there is any luck in user, after adding the user to share references, we need to navigate the user to main activity. But before I write those coats, I'm going to write else case in the else case in case the user is no. I'm going to show a toast. Message on the toast is going to be wasn't able to reduce their to user. Please try again later. It means that something wrong happened in here and connecting to our databases. Honestly, there is nothing that we can do. You just can't expect the user to try again later. OK, let's right. The logic to add the user to share preferences. I'm not going to add the user to shape references in here inside this register activity. Instead, I'm going to create a utility class on Do the job there. So let's create that. Plus it's part of you inside this YouTube's class. I only need a context that's a private context context and also let's create plants director and received that context Where the construct After that, I can create a public method. Let's say public Roy I used to share for your friend says. Also, we need to receive the user that's receiving. Also, let's add a lock up in here on inside this user to share preferences method. Let's look to use their that we are going toe. Let's say I think, plus the user data stream that's minimized this project pain for now. Now I can create my shirt differences object. I can say shared differences is we call to context of get shared differences. I need the name for this certain differences. That's just a look in user, and after that, being the most which I'm going to pass more private. Let's edit our shit preferences. I can create an instance of those Interface editor. That's content editor. Is he called to share preferences that did it. After that, I'm good at the user to my shared differences. But in order to do that, I'm going to use the juice on library to convert. They use their to a Jason file on whenever I wanted to retrieve the user from the trade preferences on going to convert to Jason five to Java Class called User. For that reason, let's add the juice on library to our project. You can find the dependency for Jason Library in their guitar page at his father's com slash google slash Jason Down here, we should see the greater dependence that's ended inside our project. Great spirits Build that cradle module. Let's added talking here also, let's add a comment. That's a Nissan that sink our project on download. The necessary finds it seems like juice on luxury. Hasn't Bean added to my project successfully? I can go to this fight. I can invalidate my cash and we start my project. Let's do that. It's okay now that I invalidated the cache memory. I should be able to use juice on library here. That's a Gees on. Yes, that was successful. I'm saying you ji song. After that, I can see it is, sir, that's put lets a user for the key on for the value. Let's say juice on does to Jason on the need to pass our user after everything. Don't forget a ploy. You're changes to your editor in here. We have two options. A ploy and commit, commit will apply. The changes in the euro trip in the main trip on your user interface will be blocked onto this. Applying happens, but the apply itself will do the job in the background on your user interface. Wants people locked in this case for Arnett. This applies not so great to select that. Okay, that's all we need to do inside this you tips class. That's called this method from our register activity in here after we are sure that the user is not know we need to call that method. But before that, I'm great to create an instance of my utilize quest that you think is the culture near you teams for the context. I'm going to pass register activity of this. We can't pass this because we are inside. That facing task class on these would refer to the racing test, so we need to specify the register activity. After that, I can say YouTube start at user to shape references on. I can pass my music After adding the user to share preferences, it's time to create an intent on navigate the user to remain activity. Let's do that in here for the context. I'm going to pass register activity that this once again and for the destination. That's a main activity. That plus let's also set to flags for this intent. Let's say intense stuff, said flags. But the flex I can see intense thought flag activity, new task, this line, the intense stuff like activity clear. Does these two flags in here? We'll make sure that if the user presses the back button, he or she wouldn't go back to the register activity. After that, I can simply say start activity on again last night. Okay, I think that's enough for this video. In the next video, we are going to test this logic that we have wrote for the register activity also illegal, right? The logic to check that if the user is logged in or not in the main activity on, if you had more time, we work on the logging activity as we'll see you in the next video. 5. Testing RegisterActivity - Create WebsiteActivity - Start LoginActivity: okay. We have right proper logic to reduce their the user to our application. We just need to create an instance of this to racing tests on Call them from different parts for the first facing task, which its mission is to check that if there is a user in our database with that email or not the proper place to call it is inside the butter register, unclean, glistening. But before that, I'm going to add those two facing task as a member valuable off in here, Let's say private does there exist? That's name it does there exist on also for the other one. Private Rijs there use their Let's name this former, just their user. Let's execute this phone from inside the on click prisoner off this button. We are doing its job inside the other method that minimize thes extra cords in here. In case the user has entered the passport Dante made. We need to understand shit on execute that racing past, so I can't say it does. Use there exist is equal to new does use there exist. We don't need anything for its construct. Er, after that, we can say does use there exist that execute on. We need to pass the Amy, but for the second. But for the second facing test, we need to execute it from inside the on post execute method off the first facing test in here. After we make sure that there is no such user with this exact image in our database, we can say register user is equal to new register user on. After that, we can call it We're just their years there to execute. We don't need to pass anything for its imports. We just need to execute it. Okay, now that we have executed are facing test no. Okay, now that we have executed are facing tests, we need to cancel them in the proper place in order to avoid memory leaks. But before that, let me minimize all these unnecessary courts. The proper police to cancel these two facing test is insight on destroying. So let's override that in here. First of all, I need to check that if no is not equal to, does user exist facing tasks. Also, I need to check that if it's running or not. So if not, does use there exist, that is cancer. Then cancel it can say does. Is there exist that cancer on? We need to pass through. Similarly, for the second pacing task, that's all we need to do in order to avoid memory leaks. Let's go to the main activity on right proper logic to pop up the register activity. I don't need this connection to the database because this was just for testing. I can simply deleted. So inside this main activity, I need to check that if there is a user saved inside my share preferences or not on, I'm going to do that. Check inside the U Tales class in here. I'm going to create a public method that's a public void, these user life in instead avoid Let's pass a user on. Later on, we will see what that's at the log. We need to instance she are shared references like before I can say share preferences is equal to context. That's trade preferences or get your preferences. I need to pass this exact takes that I have used up in here. Let's pass it in here. After that, I need to set the mood to private. We don't need the editor in here. Instead, we need to create an instance off Jason after Jason is a call to new Jason on because we are going to convert adjacent to Java file. I need to greet a typing here. Let's say type. This interface that's called type is equal to a new type token. This fun for the typing here. I need to pass user after that, a pair of curly braces on. After that, I can say, Let's get tight. After that, I can create an instance off the user that's a user is equal to G son. That's from Jason for the text. I'm going to say shared differences that get the string for the key. I'm going to pass this user on for the default value. I'm going to pass. No. After that, I need to pass my type. So there is a potential that are user becomes not. For that reason later on inside the main activity or wherever we used this method, we need to check that if our user is null or not, after creating our user because simply return it. Let's also avoid this morning in here. It says that your statement is redundant. What I can do is to move this return toe above a statement instead of the finding a new user, I can simply return this statement. Okay, that's all we need to the inside this you teams classically thrown inside the main activity . First of all, I need to Instead, she ate my utilize class. I can say private you Thiel's that's calling you Thiel's on this. I don't create. I can say YouTube. Does he call to new YouTube's with the context of this? After that, I can say user user is equal to UT feels that his user lucky. So instead of passing a bullion, a true or false, we are going to pass null or a user so that we could use this user if there is a logged in user. This is the reason that I have said the return type off this method to use it. Okay, let's move on. So, first of all in here, I need to check that if no is not a call to our user For the time being, I'm going to simply show a toast message. Let's see, user like Dean, But in case the user is not, I'm going to open the register activity later on. I will change this month on, I will navigate the user to the logging activity. But since we don't have any logging activity yet, I'm going to navigate the user to register activity. So let's create our intent for the context. Let's say this on for the destination. That's a register activity, that class. We also need to set two flags in order to clear the back stacks so that if they use their press the back button, we don't navigate the user back to the main activity. I think I can copy those two firm here. Yes, I can copy these two from here. After that, I can simply start my activity. Okay, Our application is ready to test, so let's test it as you probably. So, first of all, the main activity launched, but since there was no user looked in instantly, the register activity opened. That seems to be perfect. Okay, let's test our reduce their process for the email. I'm going to pass. May some make with death board. Let's both a passport in here and name be ever of this name. We can put anything that we want. We can put a single name, the first name and last name or even we can put me their names. Okay, let's pass an imaginary address. That's just the L. A. For the simplicity. I need to select an image that's like the 2nd 1 on Let's go with the Register, as you probably saw. First of all, we saw that the user with the details has reduced their on. After that, we saw the toast that Mason has looked in. If we close the application on running once again, this time we shouldn't see the register activity. Let's run our application once again, as you can see this time, we are blocked in on no need to open the register activity that seems to work perfect. Let's also test the scenario in which we try to register any user with the same email. I don't have any sign out button in here. Let's greatly create one in my main activity layout, for I'm going to add that button. I will remove it later on because this is not a good place to put this button, but for the testing, I'm going to put it in here. That's greatly at some constraints on also Let's give an idea to our but but then two seems to be fine for this purpose. Let's initialize that button. Let's sit on on click Listen for this bottom treaty and that set on click listening, the on click listener In this Uncle Listener, I'm going to clear my share preferences. But since it's a communication to the shared preferences, I'm going to do that inside the UTX class. Let's quickly create a method for starting my shirt preferences. I think I can copy these two from here. Shared preferences on the editor. Let's copy them on after that, let's say, Editor, dots removed. We need to pass the key, which is the user, which you can see open here. After that, we need to apply these changes. That's a anything that commits this time because we need the results instantly so we don't use a ploy. After committing the changes to editor, we need to create an intent on navigate the user to maybe the logging activity or the register activity. The proper police is the logging activity, But since we don't have any logging activity yet, I'm going to navigate the user to register activity. So that's a new intent for the context on campus, my context and for the destination that's passed on for the destination that's best reduce their activity. That class. I need the flags in here as well. Let's copy those from the main activity. After that, I can say context that starts activity. I'm using context that start activity because we are not inside a context on. We need to start our activity this way. Okay, let's pass our intent. Okay, that's Allvine experience like this method that's just calling from inside the main activity from inside this one click listener, I can say YouTube's that sign out, user. Okay, let's run our application and see if everything is going to work. Fine or not, As you can see, we are locked in. That's press this button to sign out from the application. First of all, let's check the scenario where we don't put any Amy or password and click on register button. As you can see, we are seeing the warning in here, but we do need to fix this situation off these two texts in here they have overlapped on. That's not our desired behavior. We will fix that later Let's test the second situation where we put the same email in order to reduce their any user. Let's say, May Sam at Meiko dot work a passport, the name on address on something that you're let's click on religious there on this time. As you can see, there is a user with this aim a Please try again. Email. We are seeing the one that seems to be perfect. Okay, Lets fix the situation With this to text, we can go to our register activity. They out five on. We just need to decrease the margin. Top off this text in here. Let's switch back to text view. That's confound this to find it. Margin top is 50. That seems to be too much. That's decreasing to 20. Maybe that's what you that's running once again This time, if something happened, you can see that they don't have overlapped anymore. That seems to be fine. Okay, let's move on from this part. I'm going to sit on quickness now for each one of these two text for the blue nine. I'm going to open the logging activity, but of course, I need to create along in activity on for the grave on. I'm going to open a view activity in which we are going to show my website. Let's quickly do that. First of all, let me create another activity for the logging activity inside the package. Inside authentication. Let's right. Click on select new activity on Let's elect empty activity for this fund. I'm going to name it logging activity. Once again, we are seeing the red are warning. We can click on that and we can press all plus enter two important library. For the time being, I'm not going to do anything. I'm just going to navigate to the user to this logging activity. Let's switch back to reduce their activity. Onda Also, let's minimize all these unnecessary court for now inside the UN create after everything I'm going to say txt lugging That said on klieg listener, That's a new Uncle Glessner on in here. I'm going to create my thinking That's a new intense for the context. I'm going to say register activity that this after that for the destination, I can say lugging activity does class. We don't need any flag in here. I'm just going to start my activity. That's all we need to be in here. Let's also set on quickness and therefore txt license. That's a takes. The license thought said Frankly, Glessner, you want click Listener. But before I create my intense, I'm going to create a new activity. Let's do that in the main package. Let's select empty activity for this one. I'm going to say website activity for the layout of this activity. I'm going to create a view. Let's wish to that activity that's minimized these extra pains. For now, let's switch to the text. I'm going to change the constantly hour to a relatively out on inside the relatively out. I'm going to create my baby. Let's see much parent and much panned. You just need an I D. Let's say, if you on, that's all we need in here. Okay, let's initialize this view inside our website activity, you hear? First of all, let's have a look. That's a private that you view initializing down in here for this view. First of all, I'm going to define a new view clients because we don't want to open a browser. We want to show the website inside our application. For that, I can say view dot said review client on I Can Pass New Baby Your point? A simple as that. After that, I'm going to enable JavaScript for that. I can say review that. Get setting Start said Joe. A script unable to true. After that, we need to load. Are you are you can say view. That's load or load you are and we can pass our You are Let's say Http call them slash slash make of that orb slash That's all we need to do. In order to create our website activity. I'm going to override on back, dressed in order to enable on back dressed as well. So in here I'm going to check that if view that can go back, then you don't go back. But in the ends case, I'm going to put this super statement go back to very. But you're coming from mate with another activity or fragment or wherever that is our baby . You activity is ready. Let's just call it from inside the txt license. Uncle Englishness In here I can create an intense for the context. Once again, I can't mass produce the activity that this and for the destination that's a website activity. That class. I just need to start my activity and I can pass my intent. Let's run the application and see these two takes. Fears. Weaknesses. Okay, we are inside the register activity. Let's click on this license text. What? We are seeing some problem. And I think for this problem we need to add the Internet permission inside our manifest. Let's say uses permission. Internet. Let's run it once again on Let's click on this Next. Once again, we cannot see that the page yet on. I think there is a problem with this. Your let's change that has been in here. I think I need to add a S H T T P s and let's run the application one more time. Let's click on this text on this time we can see my verses. It seems to be working Fine. Let's click on one of these links and see if we can go back. Let's press on this back with him. Yes, it seems to be working for Okay, lets go back on. Click on this log in text. As you can see, we have navigated to somber. But since there is no indication of logging activity. I assume this is the Logan activity on. If you want to make sure you can check the logging activity, which is exactly empty. Okay, I think we have a few minutes left. Let's start by creating our lugging activity layout. Fine. Let's switch back to text view on in here. Let's change these constantly. Are two relatively out down in here. Once again, I'm going to create another relatively out, which it's with on height would be wrapped content. We need to center it in Paris on I don't believe we need anything else inside this relatively out. That's the final image. You. Once again, I'm going to put my logo in here. This time. That's a 300 dp to, Let's say 150 dp Let's give it an I D. That's a logo. After that, let's century horizontally, something horizontal to true. We also need to define the source for this image. Let's do that. Let's a source on, gets past. Make the image that I have, Corp it in a few videos ago below this image view, I'm going to put to edit text, let's say edit text for the bits. Let's a match Barron for the heart wrapped content idea. Let's say Ttxt, you made for the hint. Let's say you may. That's also movie to be. No, our image of you even leave. It was called logo and also let's at some margin from right and left that same margin left through 20 dp That seems to be fine on margin Right 20 dp. Let's also either margin talk that's also either margin talk to turn to defeat as well. Okay, let's create the next detect. I think I can copy the 1st 1 That's copy that we need to change the idea and the let's say , 80 ttxt passport on Let's change the name to Passport. Also, for this passport, I need to set an import type to take a passport. It's better to have an importer for this. Email has been like from I will show you why this is important for this. Email is important. Let's say text email the 2nd 1 We need to move its people. Our it detects in May. We need to move the second edit text to below our email and text. We just need to change this logo, too. Unity, extreme. It okay, Let's add a button in order to logging, let's say, but in crap content and wrap content by the lugging, let's also set a text that's a logging. After that, let's move it to be little. Our second edit text, which is passed for any text. Let's add a margin. Top off. 20 dp That seems to be fine. Let's center it horizontally on. Also, let's change the background color can say background. I believe I have to find the orange Father. Yes, okay, let's add the warning text in here as well. That's a text view, wreck content and that content symptoms horizontal through i d. Txt bargaining. After that, it's color. That's a color accent this fun, but its text. Let's a warning that's moving below our button between logging. Let's also either margin talk. Oh, let's say 20 p on. Let's find it for the moment, let's say visibility gone. That's all we need to do for this Takes view. That's at another one. In order to navigate the user to the register activity, let's a text view rep content and wrap content for its text. Let's say, don't have an account producer from here. Let's change its color to blue on. Also, let's move it to be low are warning text that's at the margin. Top off, maybe 20 dp. And also let's add a 90. Let's say txt register. We also need to move it to center in horizontal. Okay, let's add one more text view for the license text. Ralf Content. Unwrapped content text. Let's say developed by May. Some make that work. Let's center it horizontally on. Let's set a line. Parents brought him to true. Let's add a margin. Bottom off. 10 DP Let's give you template. The let's say txt license. Let's also changed its style. That's a text style to Titanic and that's all we need to do for these. Takes you. I believe if I moved his text for you to outside of this relatively out, that would be much better. Okay, seems like we have created this beautiful layout. Fine, let's quickly initialized all of these on Let's finish off this video inside the lugging activity. First of all, I'm going to add a look in order to save your time. I have initialized all of these you I elements Okay, I think that says for this video in the next video, we are going to start writing the logic for this logging activity. See you in the next video. 6. Login Activity: So in the previous video, we have created the layout five for the logging activity on also at the end of the previous video. We have initialized all of your items inside the Java class. Now it's time to write the proper logic to handle lugging a Let's start by creating and my colleague listening for this takes the license and the experience. That or the license. Once again, I'm going to open the website activity on for the takes. The register. I'm going to open the register activity. So let's do this through in here. I can't say txt license. That's it's unclear Glessner, The New York Legal is there on. Let's create our interns object or the context. I'm very to save Le Guin activity that this on for the destination. That's just the website activity. That quest. I think I have a typo in the world license that's going to fix that by pressing shift. Plus F six can fix my type of Okay, then here. Let's just start our activity. I don't need any extra flak, so that's just past our intent. Similarly, for our takes, the register that's a that's it on click listener in the enclave listener. We need to enchant for the context. Once again, that's a lugging activity that this on for the destination that's a reduced, their activity, that class. After that, we just need to start directive. Okay, let's sit on a click listener for this button. For this beauty and looking standing here, I can see between looking that's it's unclear. Glessner. You want Click Listener on Let's do the job, insight another, that's a in its leg. That spirit said methadone in here. Privately, it's lugging. Let's have a look first thing inside this method. First of all, I need to check that if the user has entered any email and password or not, I can't say if it takes emails that get take stuff to stream. If it's not because to an empty string ideal at question must in a second, first of all, let's right the else case in the else case. I'm going to change the visibility off, explaining to busy bill on. Also, I need to change the text off the 60 politics Steve Ironing. Let's say that's a text. Let's just say please enter your evening. But in case the user has entered something as the email. You need to check that if there is any passport or no for that, I can see if it takes meaning that get text up to stream is not the corpse and empties drink. Then we can pursue what a court. But before that, let's right the else case in the STS. I am going to change the visibility after explaining to visible on. Also, I'm going to set its value to, Let's say, please enter your passport. But if we have the email on Passport in here, first of all, we need to change the visibility off the exit warning to gone. So let's say said visibility. After that, we need to cure ER. Date of is in here. I'm going to be a little bit precise with the warning that I'm going to show to the user. I mean, first of all, I'm going to curate the database for the aiming on. We are going to look at different users with this exact A May on if there is no such user. With this email, we are going to tell the user that there is no such use everything, Amy. But if we found a use every this exact email. We are going to puree the database one more time on. We are going to make sure that the passport is correct for this exact use it. So if the password is not correct, we are going to tell the user that your email is right. But it seems like your password is in Cardiff for that reason. Inside this logging activity, I'm going to create to a sing tasks because I'm going to Curie the date of his toys before we creating our first lacing task. That's just attitude doing here. Let's say execute basing tasking here. Let's minimize all these extra methods. For now, we don't need them. And also, we don't need this defuse. For now, let's say private less. Let's name it. Does email exist? It needs to extend the racing task for the parameters. I'm going to say the string for the input data tie voice for the progress on Julian for the result off this racing cast, you'll see why I'm sitting all of this. That's all right to do background method inside the steam background method. First of all, I'm going to put my try, catch, block in order to cash this year. Exceptions, let's just say feed those prints factories for the reasons that I have talked about inside the reduced their activity. After printing this tractors, I'm going to return falls. So to have a quick review, the return type of this doing background with it is a 1,000,000,000 on the bullion indicates that if we have found any user with this exact m A in our database or not, they joined inside on post execute method. I'm going to create an if statement depending on this exact opinion that is going to be passed to that method. In case it's true, we are going to continue with our foot. But in case it's parts, we are going to tell the user that there is no such user with this exact image. So for that reason, I'm directive passed falls in case we have any history of exception. Okay, let's move on inside the tribal. Look, I'm going to initialize my database, but before that, I need an instance off my database Helper, I believe we are going to use the date of a cell for in multiple places. Inside are logging activity, so I'm going to define that as a member of idea, Let's say, private database helper that's naming database helper in here inside this tribal look or maybe even inside on pre execute, maybe a good place to initialize that they have a supper. We can even do the initializing insight on creating with it, but that seems to be finding here as well. That's a date of a cell for Is the culture new data every cell for? And they need to pass the context, which I'm going to pass logging activity that this okay lets Ron inside the tribal. Look, we need to initialize my database. I can see miss you like State of race. Let's go on the TV. Is he called to database temper? Don't get readable data rates. After that, we can create a cursor object that's a first cursor. Is a call to DVDs Curie for the table. I'm going to see users. I'm not interested in all of the columns. Instead, I'm just going to retrieve the email column for that. Let's see you made in here for the selection. I'm going to say, Look for records with this, exactly me for that, I'm going to define an email is the club's question mark in here and after that new string Gary, which it's only element, is going to be a string that have been passed to this doing background with. I'm talking about these arguments in here. I can't say the streams with an index off zero that's at an entering here, and let's continue our food inside the second line. I don't need anything for the group by having or sort or there. So I'm going to test now for all the trouble after that, we need to check that the person is in love or not. If it is now, I'm going to close my database. So let's say DVDs, clothes. After that, I'm going to return false for the same reason that we are going to return false from here. But in case the cursor is not no, I'm going to say if cursor that move the first first, though, let's write that. In this case, in case cursor does not move the first element, it means that there is no I think it means that there is no user with this email in our database. So first of all, I'm going to close my cursor. That's a cursor death close after that TV that flows. Then after that, let's return falls. But in case it does move the first element, we need to close our cursor. That's a cursor that close. Do you see that? Closed on after that? In here? We need to return. True. Now that we have set the return statement in every case, we don't need this last one here. In fact, it's unreachable, so we can safely agility. Okay, lets override on post execute method in here. But it seems like we can't override on post execute, and that's because we already override it up in here. I've wanted to override the unpretty execute method, but mistakenly I have override it on post execute. Sorry for that. Let's already on pre execute method on. Let's move this line to that so I can say control eggs on down here. That's safe in trouble. Okay, also, let's move these unforced execute at the end of our racing test so that we could see or follow our good better. Okay, inside this on post execute method. First of all, I'm going to define my if statement if a 1,000,000,000 is true. First of all, let's right. The in this case, the s case means that there is no such user in our database with this, Amy. So I'm going to say txt violent that set visibility to visible on for its text. I'm going to say there is no such use it. But in case there is a user with this email address, I'm going to create another racing task and I need to execute it in here. So let's add it to do for now. But see, I execute facing test. Okay, Let's quickly create that spacing task as well. Down in here. Private class, let's name this plus lugging user, it needs to extend facing task spots again for the parameters in here. I'm going to passport as the input void as the progress on the user as the result, I'm passing user as the result, because I'm going to add the user to share defenses after we are done with this facing test . Okay, lets override doing background this it. But before we work on this team background method, let's over right on pre execute method on. Let's get value off gaming on passport credit takes inside on three executing. I need to create two member variables, right? Was drink. You may on private string passport. They try and say This method I can say this that you made is required to that it takes demain that get takes that to stream Similarly for the password. Now that we have the email and password, let's continue on inside, doing back on with it like before. I'm going to create my try cash block, and they need to catch issue exceptions, but spring this factories after death. Let's return. No, I have talked about returning this reason few times, so I'm not going to explain anything here. I mean it. Instead, she ate our database. India, that's a sq like database. Devi is because to take up his helper, not get reader. This data is we are not going to write anything to our data is after that? You can say cursor cursor is because DVD Curie for the table name. I can say users, but this time I'm not going to specify any column. Instead, I'm going to pass not because I'm going to retrieve all of the columns for the selection. I'm going to say, Look for the records which they image is a question mark. Later on, you passed these question marks on Also the passport is the call to another person, so you need to pass to arguments for the selection argument. Let's in us during area and in here we can pass. He made on a fastball that's other entering here and let's continue on. I'm going to pass now for on the tree. Others group by having on source order like before. We need to check that are cursor is no or not. In case the cursor is no, I'm going to return now. But before that I need to close my data vis. I can say TV that close. But in case the cursor is not no, I'm going to say that if cursor that moved first, that's right. The else case first in the end skis. First of all, I'm going to close my cursor. They're sort of close after that TV that closed after that return. No, basically, discounts Case means that we didn't find any record in our database that met these two conditions. OK, but in case the cursor moves to the first element we need to create an object off kind user . Let's say use a user, his equality, new user. After that, we need to set different values for the user. For example, I can say user ducks set by the I believe you have all of these inside and register activities, so that's copy them from there inside the second a sink test inside this regis their user racing test. I believe you have something similar, so let's take a look at that inside the doing background method off this facing test. If you scroll down, we have all the codes that we need, So let's copy all of them inside the London Expediency, we can face them all on. After that, I can't close my cursor. That's a person both close after that. We need to close our database. Do you without clothes on after it has been to return the user that you just created once again because we are taking care of every return statement. We don't need this return off at the end so we can do that. Let's override the on post execute meant that first someone meaning to check that if the user is no or not. Let's say, if you know, is not recall to user in case it's not know we need to create an instance off our YouTube. Plus, let's say you feels you. Thiel's is the call to new tips for the context. I can pass logging activity that this after that I can say you things the user to share three fences. But in case the user is no, I'm going to show bargaining to the user. That's a fixed, the violent. That said visibility the visible. After that, that's a txt bargaining. That said, text to your passport is wrong or encourage. In the first case, after adding the user to share preferences, I also need to navigate the user to main activity. So let's create that intent lugging activity that this as the context on main activity, that class as the destination in here. We also need to flags that say intense love set flags too intense stuff for that activity. New tasks on you tent not for like activity clear test. These two will near the backstage. Let's start activity and pass. That's all we need to do inside these to a think test. Let's just call them for this logging user. I'm going to call it from here from the UN Post. Execute off the first facing test, as you can see the two doing here. But before I call this lugging user, I'm going to define it as a member variable so that we put avoid memory leaks later on inside the understory with it. So let's see, Like in user, that's name is logging user that's also defined. It does emit exist facing task as well. That's a private does. He may exist. Does email exist? We can initialize thes two at proper police is for the 1st 1 This seems to be the right place inside the UN post. Execute off the does he made exist. Facing test, I can see lugging user is he called you lugging user. After that, they can execute it. Let's say lugging user that execute and we don't need to pass anything. Now that we have executed are racing cast, I can delete this too, but for the other wanted does he may exist, they think task. I can initialize it insight that in each lugging method, as you can see, if you have a two doing here. So let's say that exist made is a call to new doesn't exist, and after that you can say it does. He may exist, exist. We need to pass our remaining here, which I'm going to pass, and it takes emails that get text up to strength. Okay, let's minimise these two racing tasks for now. We don't need them anymore. On also, let's worry un destroying with it on. Take care off. The memory leads, Let's see destroy. We need to check that. If does email exist. Facing test is no honor, so that, if you know, is not equal to does. He may exist on also going to check that does he may exist, is not canceled. Then we need to cancel it. Let's say, does he may exist out cancer, and then it passed through in here as well. Let's do this thing nothing for the other racing task if you know it's not recall to lugging user. If lugging user is not canceled, let's cancel the lugging user that cancer on. True as making truck you from Okay, I think that's it for the logging activity. Just before we test our application, we need to change a little thing inside the main activity. That's good there. If you remember in here, when we have created our intent in case we didn't find any user logging in our shared preferences, we have navigated the user to this register activity. At the time, we didn't have any logging activity partner that we have it. We need to change this pond to logging activity. Okay, lets just our application. Okay, we are seeing the lugging activity. We have register some users previously, so let's use them. First of all, I'm going to check the case that there is no such user with this email in our victories. So that's at some random emailing here, for example. Let's say may some 123 that's make that work on. Let's add some Brandel passport. Okay, let's try to logging. As you can see, we are seeing the error. There is no such user with this email address that seemed to work Fine. Let's also test the empty edit text. I mean, this passport on this email. If we don't put anything I'm trying to lugging, we should see a mother hardening down here. Okay, lets say, bugging. And as you can see if you are saying that morning, please enter your email address. But if you put the right Amy on, put the wrong password, we should see another warning down in here. Let's do that. We have an email address registered with this application called May Some make what does or on the password was 123456 So if I typed, want to tree, I try to lugging. You can see that the warning says your password is inquiry. So if I put 456 in here and added to the von two tree on, try to bugging, we are logging into the activity safely on. Also, there is an interesting point in here. This little pop up in here is the exact reason that we have set import types for our meditates. Now that we have defined the email editor text input as text email address and also for the passport takes the passport. The android system, by the help of my Google account, has been locked into. This account knows those two as the combination of user name and password, and it's suggesting you to save that combination. If you do that the next time that we try to log into application, that would be a lot easier in here. I'm just going to say not now, Okay. This was the logging logic for our application. In the next video, we are going to start working on the main activity. See you in the next video. 7. MainActivity Layout: Okay, let's create our main activity. I'm going to start working on Main activity layout for so let's open that file. We don't need this button on this takes you This button was just for debugging purposes on this text has been produced automatically by hundreds City. So let's do the both of them. Let me minimize this pain. For now on, let's to be both of the stakes here, and but also you need to do it the button from inside the Joe off lesbian and then, in your view, to limit the button on its A list. Okay, let's respect to the layout. Fine. First of all, I'm going to change this constant layer to a relatively up. Next. I'm going to create a custom toolbar for my activity. So let's see to mark the one that comes from and retakes that comfort digit. But its bits, let's say match Ban on for the height. Let's see rap content. Also, let's give a 92 hour to bar. Let's say I d that's name right now. The color off our toolbar is bite. I don't like that and I'm going to change that. So let's quickly create and examine file inside our driver for their that's in you drive a resource by its name. Despond background to both. That's minimize the project. Painful now on. Let's change the selector to shape inside this shape element. I'm going to define a color for the finding, a color we have seen solid previously, which will create a solid color. For example, if you say color, that's a blue. If you create this solid color for us, this is okay if you want this, but in this case I'm going to create a great and color, so that's a great him. We can define three colors for our ingredients, color that start colored the middle color and also the end color. So let's briefly create those colors. But for now, let's do the history again. Unless the find three new colors inside values covers that XML. I'm going to copy this blue brother. Let's name the 1st 1 Great, the second light gray and the third fun. That's name it's white. Also, let's change the value of each one of these cars, but the gray I think something like this would be fine. Light gray on also divide. Okay, let's pass these three colors to our banker to borrow item. You know, I can't say Great dance. That's a start color. Too great. As you can see, we are seeing the great radiance color already. Let's define another caller, the center color, but see light agree. After that, let's define the end color as which is going to be right. I don't like it to be like this horizontal. I'm going to change it to vertical. For that, I have an angle attribute in here bitchy fight to find. It's a 90 degree. It's milk rotates the great and color 90 degrees. But I think I should stay with negative 90. Okay, that seems playing. I'm also going to define a border for this background color. For that, I can see a stroke, but its color. I can say black or its six of the civil value, which is going to be hash 000 After that, I need to define the bids for this color. I think one DP would be fine. Let's change it to have to. Okay, that seems to be fine. Let's finish creating our stroke on Let's pass this background to a part of our two years. I haven't answered shooting here called Background, which I can't pass my background inside the driver for the I think if we remove the center color and changed the start color to maybe a lighter great that seem nicer. Let's try that. Let's remove the center color and that's changed a start. Color to light. Let's take another look. Yes, this seems much better. After creating this toolbar, I'm going to create a floating action, but also a bottom navigation you. But for both of them, we need the Material design library in our project. So let's report that into our project. You can find a library by searching for material designed for hundreds. That says, for that, the first link from material that I is probably are needed Lee. And in here you can see the instructions for implementing the Material Design Library into a project. Copy that line on bases inside your greater that's bute modular, but we need to change that. That's copied. We need to change the version in here to the suggestive version, which is one point open or on. Also, we need to make sure that the Google NJ Center repositories has been added to our project as well. Let's check that those are inside. That being that great a project module in here we have Google NJ Center. That seems to be fine. It's time to sink our project. It seems that the dependency has been added. So let's close these two finds. From now on, let's minimize the's on projecting in here. First of all, let's create the bottom navigation you. But sometimes like this, after adding some dependence is to a project those dependencies within. For unless you restart your Andrew distant here or in some pieces, you can invalidate the cash. So let's do that in here. I can say invited the cash Andrea stuff. Now we should be able to use my two year old design. Lavery. Let's try that. Let's see. But navigation you? Yes, we can you for the vits. I'm going to say match, parent on for the height, let's say 50. That's also give you an idea to our but a navigation view that's college, part time navigation. You We also need to move this bottom, navigation you to the bottom off our activity or death. I can say a line parent, but him to through. It's also good to have a background. Let's use the Backer toolbar for the button navigation view. Asthma that's his background on background to that seems to be fine. We also need to create a menu resource file on address at menu from inside this button navigation view. So let's we could create that. First of all, in our project, pain in the resource is folder. We need to create another directory. Let's select 100 Resource Directory. On inside this new directory, we need to create a new menu resource file. Let's name despond bottom Navigation menu. We need to switch to the text view and in here we can create our menu items. Let's see him. First of all, be needed title for this item. That's name the first on stats. We also need an idea. Let's see many white and stats they also need. And I come for each one of these items inside our bottom navigation. You're so let's greatly at them. You say our project pain inside driver pull there, but seeing you image asset, let's use to action bar tab icons. Let's name this fund. I see stats. Then let's select an image. I'm going to select this chart. I can't in here for the stats. And also let's change the color. Let's sleep on next and finish. I'm going to add four more icons on going to escape that process because it's really a simple purses. As you can see, I have added five icons in here. Prices stats. I see low icy transaction. I see investment on bicycle. Let's continue on with our many resource by Yeah, you can see Icahn on for the first item. I can't pass Isis that they turned to see the users off every one of these items. For the second attempt, I'm going to name a transaction. Let's also add three more items. Now that we have created this manual file, we can pass it to our bottom navigation. You inside the main activity layout. Let's say menu on, Let's pass our bottom navigation Human. In some cases, like in here, you won't see the immediate effect in your preview. You may want to invalidate the cash from here from this point topping here, invalidate your cash or in some cases, you may need to restart your Andrew studio. I know for a fact that I have the bottom navigation menu items, so I'm not going to restart it. I'm just going to ignore the fact that I can't see any item in here. Okay, let's move on. The next thing that I'm going to create is the floating action button, and that's coming from the material library. And for its wits and height, let's say, for two DP, let's give an idea to our floating action, but I'm going to see if the transaction let's also move. It's down below and to the right of our screen. For that, let's see Elaine, Pam, but him too true and also a line parent right to through as the. But this is not a good place for our filleting action, but let's move it to above our bottom navigation beer on. Also, that's at some margins. For that, I can say margin buttons to 60 anything because the size of our bottom navigation do this 50 on. We are giving 10 deep in margin for the splitting action button and also margin rights. It's ndvi as well. Let's also add an icon for the splitting action button for bet. I'm going to quickly create any icon inside my driver resource by now that we have other daikon became passage in here. We can't say source. Then we can pass. I see. I believe these floating action, but in shouldn't look something like this. It should be circular. It's with have some colors. Andi, I believe if I invented in my cash were you start my Andrew studio. I should see better. So let's do both of them right now. I have tried invalidating the cache memory, and also I have tried to your starting Andrija studio. But none of them seems to work in here. But if you run your application like I did in here, you can see their bottom navigation view and also the floating action button, which seems different. I don't know exactly what is the problem with this preview in here. It's maybe a book or something. I'm just going to ignore the fact that it's not accurate at the time. But as you can see inside our emulator, this plus icon is not centered. For that, I can add another attribute to our floating action button on that is five custom size. I can change these 2 40 p on now it seems like our view is working fire. Let's also run the application once again and see the difference in our emulator. As you can see, the plus I can't has been centered. That seems to be fine. Okay, let's move on from this part. I'm going to tear enough Miami later for now. So if you want to center the icon inside, they're letting action. But and this is the attribute that we need to add to your living action button. Five. Custom size on. You need to set it to 40 dp Okay, let's move on are to bar doesn't have any icon at the time being. I'm just going to leave it for now. Later on, we will ask any icon that we need. But for the rest of the layout, I'm going to, first of all, at relatively out. Let's say my spirit and match ban for the bits and height that's movies below are too far on. Also lets at the margin button off 50 dp So that's been moving above our bottom navigation here. Margin. Bottom 50. Inside this relatively out, I'm going to create a nest of the school of you. Let's see my parents and my Spanish Once again, we know that every ness of the school you can have only one child, So let's great another relatively out in here management and Mashburn. I think they don't need an I d. So let's get in you roids below this toolbar in here. I'm going to add a welcome message stopping here and also the remained cash inside the user's account. For that, I'm going to create another relative layout for the beats. Let's a match parent for the height rap content that's also given idea to this relatively out. That's the first thing there. Let's on the first text text you were appointed and Rep intent for its taste would say they'll come to me bank. Let's also change. The style of this text takes the style, too. Oh, on also, let's increase the size of mistakes to, let's say, 20 SG. Let's give an idea to the stakes for you. Let's say txt Welcome. That's it for the 1st 6 view, but at another one takes to you grab content and wrap bunten, but its text. Let's at a place for there for the time being, let's say 0.2 Let's move it to the right of our screen. Let's see a lone parent right to true. That's also changed a color. I don't know if they have any green color in our resource file. It seems like we don't have lets people at on. I'm going to change the name to Green. And also let's change the value to a green color that seems to define Hey, let's move on being here. I can see color on, Let's pass our green. Let's also increased the size. That's a size NTSB. Let's add three more attributes. Let's change this time to vote. Let's add a margin right off 10 VP and also that's given authority to our taste. That's a txt amount that support the first relative day out in the second relative lead. I'm going to add to charts in here. Onda Library that I'm going to use is called MP Andrey chart. It is a very powerful library. The developer has done an amazing job, and we are going to use that you have all sorts of options. You can create bar charts, we can create lean er charts, and also you can create pie charts on Do you have a lot of options for animating different values and everything? We'll talk about these MP Andrey Charts library later on in view videos later. But for now, let's at the dependency into our project for, I think, the dependency we need to search for MP Andrey chart. This is the get ha page Seal J seems to be the name off the author of this library. Let's go to the beautiful page on down in here. We should see the dependency for the greater Let's add this to our project inside a great deal of screens being that creative module minutes after dependency. But before we sink our project, you need to add one more thing on that is this may be a repository. We need to copy that on, Paste it inside our bill, that greater project money. We need to paste it inside these all projects elements down here. They love the J Center. That's copy that maven repository and let's sink our present. It seems like the liver has been added to our project successfully. Let's see if you can use it. They probably can't use it unless various that understood. Let's create another other team layout match. Fine for the beats on rap concert for the height that's also given idea to respond. Let's say chart, Really? That's also movies relatively at two below our first Minniti things. Let's save the love first relative they have. Maybe a margin would be fine as margins off, Let's say, 10. I'm going to add to chart in here a line chart on a bar chart. We will see how we can develop these two charge later, but for now that's on them. That's a line chart for the bits on height, let's say 150 DP. Let's given already for the 1st 1 That's a line chart. For now, let's either margin left off duty and let's at the second chart as the The 2nd 1 is going to be a bar chart this one 151 150 for the San Fight for the idea. Let's be a bit smart. Descriptive. This chart is going to show the prophet in different monsters, or maybe days. So let's name the profits charts. Let's movie to write off our line chart, which I need to change the I D to Let's say or daily spent Shark. Let's move the 2nd 1 to the right of this chart to write off They spent sharks. Let's move these chart to the right of our screen. Let's say a line planet right to true. And also let's add a margin right off 20. Okay, that's it for our charts. Relatively out. That's greatly at another relative layout. In the next, relatively out, I'm going to create a recycler view, which so different transactions in here. So let's create that relative. May out match for the beats and trap content for the height. For the idea, Let's say transaction with layups that's moving to be low. Our charts relative, they are. That's at the margin. Top off, maybe 10 dp. That seems to be fine for someone. Let's at it takes to you were affronted on draft content. Put it sticks that say transactions. Let's give an idea to this text. Next, the transaction that's changed its style to both That's increased the size 2 16 sp maybe, And also, let's add a margin tough in here as the marching top off 10 dp Next. Let's an hour cycler view for David's not saying mash band Trap Contents. Let's give an idea to it. Let's say transaction rescue. Let's move. It's below. Are takes the transaction on. Also, let's add a margin Top off 10 D and that's it for our layout file for the main activity. Let's just first control on L in order to reformat are quote okay, I think that's it for this video. In the next video, we are going to initialize all of these items inside our main activity. That's Joe. If I just before I finish off this video, let's an emergent for this text hearing here. That same margin left off to also let's add margin for this transaction takes on also this recycle of you as well. Control out once again to reformat the coat and that's it. See you in the next year. 8. Toolbar AddTransaction Dialog: before I start working on main activity, that's gel. If I I'm going to add a margin top to this relatively out in here, let's find that it should be this one. First reality they are, Let's say margin Tough off 10 also, because we are using our own to Barbie to change the style and the team off our main activity inside the manifest file in here for the main activity, you need to add another attributes. That's a theme on. Let's add the no action barking in here because we are not going to use the default action bar that has been set for our main activity. Let's continue on. I'm going to open my main activity that drove up for him in here. First of all, let's initialize our euro elements in order to save your time. I'm going to escape this process. I have added all of these your eye elements down in here. I have created this unit use method. Andi have initialized all of these items. I just think that I have a type of in disporting here. Daily spent chart. Let's change that by pressing shift plus F six. You can change that let's say Davy, his phone short. Okay, let's move on. Next thing I'm going to end its my bottom navigation view. Let's do that in another method. That's a bottom navigation view on. Let's create that method than anything before that that's minimized these interviews method . First of all, I'm going to change the selected item inside the bottom. Navigation you because we are inside the main activity. I'm going to change that to the home item. For that, I can say bottom navigation You that said, Selected Item I D on. I'm going to pass the idea off that item, which is our that I did that many items home. After that, I'm going to sit on unclean listener for each one of the items inside the bottom. Navigation you or Death. I can say bottom navigation view. That's it on navigation item selected listener, but saying you're a navigation item selected listener in here. Let's create the suit, a statement which will act on this many items that get item i D. In case it's a stats or in case it's our that idea that menu item stats do something for the time being, I'm going to create it to doing here. Let's say complete this logic. That's right. The similar logic for all the other items. We will complete this such a statement whenever we have created all the activities for the time being, let it be like this between that's move on from this part. After initializing all of the elements and bottom navigation view, I'm going to handle the two of our situation. For that, I can see, said Support Action Bar, and I need to pass my tuba after that, that's handled the situation for the sticks. The amount for that I can create another method in here that's a set up a month. Let's create this method by pressing all 10 30 you can use in today to create this method for you in here. First of all, I'm going to check that if we have any user luck for that, I can see user is equal to YouTube stuff these user looking. If you remember, this method will return a user in case there is a user log personal. We need to check out Theis User is not to know. Then we need to create an aging task in order to connect to our date of its. That's we can create that down in here. That's a private class to get account amount. It needs to extend the A sink task class. But the parameters, first of all, I'm going to pass integer. This interview is going to be the user i d. Later on. It will be helpful when we connect to our database for the progress that's avoid on for the result, let's say double, which is going to beat the amount off the users cash in that camp that's already doing background. First of all, in order to connect our database, we need an instance off the database helper quest. I believe we are going to need it in multiple places. So let's add it as a member various topping here I can say private, they have a self birth. This class that's name is the obvious help. First thing. Before we call this set amount method, we need to initialize that class. Let's say they have a cell for is equal to a new date of a cell, for we need to pass a context which I think the best this okay after that. Inside the doing background method I need to create the try catch block in order to cash this. You'll exception. The one that comes from Andrew that database. Let's bring the stack trace on. After that. Let's return now. In here, I can see SQL databases. Let's call it Devi is equal to database Alpert that get readable data Ways we don't need to write anything to. Our data is so readable. Database would be fine. Let's do a curie on our database can say cursor cursor. Is he called to DVD Key? Very. And for the Curie. First of all, many to pass the stabling, which is going to be users. We are going to cure the user stable for the column. I'm going to define the newest during area we are only interested in von. Column on That's remained amount. If you want to make sure you can check your date of his helper class in order to see that exact Colin, then here we have a user stable, this one on. We have a remained amount column, which its status I is double. That seems to be fine. We are only interested in this column for the condition. Let's say look for all the columns with this idea that has been passed to this racing task . For that, I can say that idea is equal to a question mark. Let's go to the next line Korda selection argument. Let's say in the US, during every let's see string the value off integers with an index of zero, which is essentially going to be the idea off our users for the having on Group I. Let's best enough. Also, let's pass now for the order. But after deaf, you need to check that our cursor is no left. If it is no, let's return now. Before that, let's close our database, be beat up close. But in case it's not know, you need to move the cursor to the first element. Let's say if Carson move the first in case it does not move the first element, it means that it didn't find any user with this i d. So let's close our cursor on database on After that. Let's return now, both in case Carter moves to the first element. Let's get the remains amount. I can say double amount is equality cursor. That's get double for the index on very to past cursor. That column index beat the name remains amount. After that, let's close our cursor and eight of these on after everything. Let's return that amount. You know that this amount will be passed to one post execute method. That's over right there. But before we work on this one coast execute method that remove these return not from here , because we have handed all the cases and we don't need this return all at the end of our doing, Bagger. So we can safely remove that after the Super Statement, we can check if a double is no or not. Let's say love is not people to pay double. Then let's set the text off the takes. The amount to this value in here that said ticks to string that value are double plus, maybe a dollar sign. But in case it's no, I'm just going to set the value of these takes 20 Okay, that's it for this. A sing task. We just need to call it from inside the set up amounts method. But because we need to be careful about the memory leaks, I'm going to define this get account amount facing task as a member valuable hoping here I can see. All right, this get account a month, That's name it. Get account amount. I'm down here. I need to initialize thes class. That said, Get account amount is equal to you. Get account amounts. I'm after that You need to execute this a sink tests. That's a execute. We need to pass the user idea which I'm going to pass. User thought Get idee. That's it. For this method, we are done with it. Let's minimize this method beside the UN create method. We need to call this set up amount method from on resume on on start methods as well, because later on, we are going to at different dialects to our application on in those dialects. User can add different transactions so they remain amount in user account can change even if we don't destroy our activity. So we need to call this set up amount inside the on start on resume as well. That's override those two methods. Let's call set up amount method similarly for the on start method. Okay, that's it for the txt amount. Let's add different league listeners for this Txt. Welcome up in here and also are floating action button in case the user clicks indistinct the welcome I'm going to show on Alert Taylor in which the user can see the developers license on. Also, he or she can navigate to our website for the floating action. But then I'm going to open another dialogue in case I'm going to give you their some options to add different transactions. So let's create that mess it down here, let's say set on sleeplessness. Let's create this method. It's very some type needs to avoid. That's a txt welcome that said Uncle English there New York listener. I'm going to create an instance off alert. I like that. Build their object. Let's come feel there. Is he caught in your other day like that? People there. We need to pass a context, which I'm going to pass main activity that this after that, it's a title. Let's see. May back after that, lets with a message, let's say, created and developed by May Samet maker that or let's also and two buttons to our other Taylor for the negative button I'm going to say dismiss on for it's unclear listener. I'm going to create an empty uncle glistening. I'm not going to do anything so that the user can easily dismiss the dialog or deposited button. Let's say visit on. Let's create in your own Click Glessner, in which I'm very, create immunity. Incense. It's context is going to remain activity that this it's this the nation is going to be the activity that class. After that, you just need to start their activity from here. Mr. Activity and me to pass a ringtone. That's it for our alert. A look that's just show it. I can say builder dot True, A simple as that. Next, I'm going to create an unclean prisoner for my floating action button. That's a FBI transaction. That's it. Unclean. Listen there, the young klieg listener. Before we start working on this one click method, we need to create a custom dialogue. Let's quickly do that. First of all, we need to create layouts falling for our dialogue. That's saying you they have three source file and let's name style. Look at transaction. Let's wish to text you in order to save your time. I'm going to paste the code that I have written before. As you can see It's really simple on. You don't need to have any sort of special ask you to write this court. It consists of a bunch of relatively out with only an image here, and it takes to be a But in case you want to check this code that I have everything in here , I will upload the source code at my website at the link that again see under screen. So make sure to check that if you need. But that's also change of these icons from here for the shopping and sending and receiving money. I don't have any icon lets greatly at them in our driver holder. New Image Asset. Let's do the same thing for sending and receiving money. New images for the shopping that's past our icon. It's inside our driver full there, so I need to change this one to let's say, I see Carter, I believe, was its thing. But I need to increase the size to, let's say, 50 dp. So first, let's quickly at the icons for others as well. Okay, that's it for the layoffs. Fine for our joy. Look, let's greatly create their related drama for you inside my package I'm going to create a new directory on. I'm going to place all my dialogues there. Let's name these packaged Oilers. Let's create a new Jell O FOI. Let's name this fun at transaction in here. We need to extend the dollar fragment, the one that comes from Andrew Extra Pregnant, that after dialogue pregnant. After that, we need to overwrite on create dialogue method before we work on this one creates dialogue . Let's initialize argue elements. Before that lives on the line. We basically had four different relatively up, So let's at them before returning. Anything I'm going to create have you object in here? Let's save you. You're is equal to get activity. Let's get the outing for later. Does inflate. We need to pass our layer five in. Here are the layers stuff. Do I look at transaction on? We don't need to pass anything as there, so that's a pass that lets minimize project clean for now. After that, we need to initialize all of these relatively for the shopping. Let's say equal to view that finds you by i d are the idea shopping relative seeming largely for all the others. So essentially I'm going to give the user the option to add different shopping's investments loans on different transactions, which by transaction I mean sending and receiving money. And for each one of these options, I'm going to create a new activity. So I need to create on klieg listener for each one of these relative lands on later on. When I have created related activity, I will navigate the user to death activity for the time being. Let's just create the uncle listeners. For now, I'm just going to add it to do in here. Let's say navigate the user to the activity. Let's do the same. Nothing for the other three options. After sitting different on league listeners, I need to create an instance off other they like the builder on. We will see why in a minute that's funny. Fielder is he called your other tyre like that. People there, we need to pass a context, which I'm going to basket activity. I'm going to set a title for the other day luck. So let's say said so you tell to a transaction After that I'm going to set a negative button, so that's a said negative button, which is going to dismiss the dialog New York leaderless There on in this unclean listeners , we are not going to do anything after that. I'm going to set a view, and the view is going to be exactly this view that we have commuted up. So that's pass it down in here and that's it, for I would build their object on instead of returning this super statement in here, I'm going to return well there. That creates That's it for our day look. So to have a quick review, we have initialized all of our your eye elements. We have Seth different league listeners for each one of these relatively ads on. After that, we have created on returned our alert toy like objects. Okay, let's move on to our floating action button. Unclear Glessner In here. I need to show the nearly created dialer so I can see at transaction dialogue. That's name it at Transaction Door Look, is it called a new transaction dialogue. After that, I can say at transaction dialogue don't show which I need to pass my support fragment manager. It supports pregnant manager and I need to pass attack. It's for debugging purposes. I'm just going to see at Transaction Diver. Okay, I think that's enough for this video. Just before we finish off this video, I'm going to test everything that we have done so far. So let's run the application. And as you can see, we are getting a crash. If you take a look at our luck, it you can see that we have a problem in like 209 It's related to this par shirt on the air in here says that line chart cannot be cast to a barter. It seems like I have made a mistake in naming my bar chart on line chart. Let's go to our main activity layout file in the text view. I think I should change the idea off this one to this fund this fund for the 1st 1 So let's quickly change that for the bar chart. I'm going to set the I D to Bega spend chart, and for the second bump, let's say profits chart. We also need to move this month to write off our profit chart. So for that, that was my mistake. Okay, now let's run the application. It seems like this time we are populating the layout find the title is up in here. The button navigation view is working fine. I'm not sure if you can see this, but the home icon in here is highlighted. But color of highlight is light. We are going to change this fund in the next video. But for the time being, we are populating the button navigation view. We have the floating action button which barely its color is changing. We have the amounting here which is 0.0, which is accurate At the time of creating a new account at Maybank, we didn't have any initial amount. So this is true if we click on this Welcome to Maybank text. We should see that they look if we can't dismiss the Dalek should be dismissed. And also if we click on visit, we should be navigated toe review activity which is working fine. We are seeing my website. Let's go back. Let's also click on this button navigation. You and we are seeing the dialogue. It seems to be fine. We can dismiss it easily. Okay, that's it for this video. In the next video, we are going to work on this transaction recycle of you on its adapter. See you in the next video 9. Get Transactions from Database Transactions Adapter: in this video, I'm going to work on this transaction recycler view on also it's adapter on. Also, I'm going to work on getting different transactions from the database, but before doing all of this, I'm going to fix the situation with this bottom navigation view. As you can see, even one item is selected. Its color is somehow fight on. It's not a good color for our background color in here. I'm going to change this first thing in this video, so let's start working on that in order to have different colors. When our items inside our bottom navigation view is selected or is not selected, we need to create a new directory inside our resource is Father in here. I need to create a new Andrea Do source directory on. I need to name this pond color on inside that I need to create a new color resource by let's name respond bottom naff color. As you can see, we have a selector element in here and inside that selective. We need to create two items for the 1st 1 When the item is selected, I'm going to pass this color accent on. I need to set another attributes in here as well. The state check, if I said, is true. It means that our item is selected. That's it for the first item. That's to find another one. For when the item is not selected, I'm going to select this blue color on. Let's also change the state's chick to falls that seats for our call a resource by. We just need to pass this month to our bottom navigation view. Let's go to our layers folder Inside the activity main that external fire. Let's use to text view on Let's find our button navigation view in here. We need to define to new attributes. The 1st 1 is item text color. This is for the text off our items. I can set it to the newly created Item Resource file. Let's say for button navigation color on. Also, we need to define another attributes item I can't eat. This one is for the color of our icon. Inside our button navigation view. I can pass my color once again, but as you can see, we can no longer see different icons in our bottom navigation view on. That's because off the problem with this preview If I run the application, I should see different colors. Van one item is selected or when while item is not selected. As you can see, this problem has been fixed. Let's work on the transaction recycler view in order to create a doctor for our transaction . Recycle of you. First of all, I need to create a layout five for every item you cite that adapter. So let's we could create that. I'm going to name this fun least item transaction in order to save your time. I have prepared the stakes, so let's copy typing here. As you can see, it's a really simple layout file. It's basically a card view containing different takes. Two views on for the takes views. I'm great to show the amount of transaction description if user interest anything. The sender, in case it's a deposit on, also were shown receiver in case it's a vitro. We have added the date on transaction idea in here as well as against. It's just a bunch of text used nothing special in here, but in case if you need to check the source code, I will upload the source code after recording every video, so feel free to check that, if unique, on. Also, I would like to see your comments down below every source code. Okay, let's move on. I have created this list item transaction. Let's create the related fire for the adapter for different adapters. I'm going to create a new directory, a new packet. Let's call this fun adapters on inside these adapters. I'm going to create a new Java class. Let's name this one transaction at that. First of all, I'm going to create the view holder class. That's a public less you holder. It needs to extend the recycle of you dot Do you holder? We need to create a construct. Er so let's do that. After that, we need to initialize are your elements in order to save your time? I have written this court previously, and I have copied is in here just because we are not inside the main package, we need to re import this art class In order to import the art class, you need to click on it on by person off, plus enter. You can select import class. Okay, let's move on from here. But before that, let's minimize the project pain Now that we have the your holder class, we need to extend the recycle every dot adapted. That's the extent recycle every and that, sir, and we need to pass our view holder. After that, we need to over three methods on creating holder on buying beer holder on get item count. Before working on these dream methods, I'm going to create a mother for every transaction on that model is going to have all the properties off different transactions inside. My date of is so First of all, let's check the date of his helper class. You cite the transaction table, we can see that we have an idea. We have amount. We also have a date type user I. D. C Pant on description for every transaction. So let's greet our mother. You say that package behind a mother's package. You can't create unusual a class in here. Let's names respond Transaction. Okay, these are all the fields that I'm going to put inside my transaction model that's Weekly creates through constructors. One will receive all the elements on another one well received. No elements, no arguments. Let's select none on also, let's create different getters as centres for all different foods after everything for debugging purposes. Let's just at a two string method. That's it for the transaction, mother that switch back to our transaction at after. First of all, let's create on a radius of different transactions even before that. Let's at attack. Let's save privates. A release off transaction that's called Transactions is 1/4 new aerialist. After that, we need that empty construct er inside the get item count. I'm going to return the size of these, very least, so let's see transactions that size inside the uncreative your holder method. I need to create a view holder object, but before that, I need to create a view. Object is equal to layout inflater that from our parents that get context after that inflate are the layouts that the state of transactions parents on false as the attention to root. After that, I need to create my view holder object. Let's call it holder is equal to Noumea, Holder on the need to pass our view. After that, we just need to return on Holder insight on buying view holder method. That's where the magic happens. First of all, let's have a look in here. Let's set different values for different text views inside the least liked him. Transaction. They outside, I can say holder dot txt date. That's a text to, let's say, transactions that get you need to pass the position that's get the similarly for on the others that seat for four different text views. Just be careful about this transaction. I d. U need to cast it to a stream because it's going to be an integer. We also need to set the text for different amounts. But for that, first of all, I'm going to receive that amount. Let's say amount is equality transactions that yet position the gift amount. After that, Things to check that amount is greater than zero or not. If it is greater than your first of all, we need to change the color off our text to a green text. Maybe on if it's less than zero, we are going to change the color to maybe a red color. We are also going to add a plus or maybe a minus at the beginning of this amount as there. So if amount is greater than zero, we can say holder. That amount takes the amount. That's it. Text. So plus the actual amount. After that, we can say for their sticks the amount that's a color or says text color to, let's say, color that green this fun. Similarly, in the else case, we can copy this, too, but we need to change them a little bit. First of all, we need to change the corner to a red color, and also you need to change the plus into a minus sign. OK, that's it for a recycler view. And after, let's initialize a recycler view inside the main activity. Let's go to main activity. Let's minimize all the unnecessary methods in here. First, someone we need to create an instance off Ari Circular view adapter. I believe you are going to use that in multiple places, so I'm directed to find that as a mom, they're valuable. That's a private transaction at that, sir. Let's call it adapter on Let's initialize insight another method. But before that, inside the UN create method. After everything that's called that method Mezei in its transaction risk here, let's create that method that's either look first thing on down in here. Let's say adapter is the culture in your transaction that, sir, we don't need to pass any context or anything after definite to send this adapter to a recycle of you, you can say transaction dispute. That's it. A doctor to our adapter. After that, we need to set a layout manager for every cycle of you, I can say transaction cycle of you. That's it. They asked Manager, newly nearly out manager. We need to pass a context, which I'm going to pass this. After that, we need to get data from the database on Set the data to our adapter. But I just remember that inside our adapter class, we need to create a several method as well. So let's quickly create that down in here. After the gift item count, I'm pressing all plus insert in order to create that center for my transaction and released . After that, I need to notify the data set changed as the Okay, that's it for the transaction. A doctor for getting different transactions from database. I'm going to create a new racing task on do the job in there. Let's create that. After this Get account amount facing tests, let's say private class gives transactions. It needs to extend the racing past class for the parameter, for input on, very to, say integer. It's going to be the user I d. We don't need anything for the progress. So let's pass, boy. But for the result, I'm going to pass on a realist off different transactions on later on. Inside on post execute method, I'm going to pass this area leased to my adapter, so let's see are released off different transactions. Let's overwrite the doing background method before everything. Let's create our Troy cash block and let's catch our SQL exceptions after catching SQL Exceptions. Let's return, though inside the tribal look, let's instead, she have database that's a sq like database that's college TV is the call to database. Have heard that get readable data. Always after that lets the security on our database. I can say cursor cursor is called two db that curie for the table. I'm going to see transactions for the columns. Let's pass. No, we're going to retrieve all the columns for the selection that say, look for different columns. They use their i d off a question mark, which I'm going to pass the question mark in the next line that same year. String area on for the values. Let's past integers with an index off zero, which is essentially going to be our user, i d. We can say its string that value off integers within index off zero for a group I am having that's fast enough, but this time for the sort order, Let's pass something on. I'm going to sort different transactions by the date. Okay, that's our care, sir. Let's check that if it's null or not. If cursor is not know, first of all, let's right the else case in the X case. Let's close our databases TV Death close. After that, let's return now, in case the cursor is not know that strict that if cursor can move to the first element or not, in case it's not able to move to the first element, let's close our cursor after that. Let's close our data vase. After that, let's return. No, But in case the cursor does move to the first element, let's create a new areas is off different transactions that's college transactions is equal to your released. After that, let's create a four loop on it right through different items or different transactions in our cursor, I can't say, for I is equal to zero eyeless than cursive of his count and I Plus Plus, inside these four groups, let's create a new transaction. Elements that's called the transaction is a call to new transaction. After that, let's set different values for these terms. Action, I can say transaction. That's it. Ivy two cursor that get into jer with an index off person that get column index off idea. We need to do the same thing for all the other fields. Okay, that's it's for different fields off our transaction. After we have created our transaction object, we need to add it to our transactions. I read list. I can see transactions that at our newly created transaction after that we need to move the cursor to the next element. I can say cursor that moved to mayst on after the four look. When we have created our realist, I can return that released. But before that, I need to close my Kerson. I can see her served up close. After that, they have a stuffed closed on after death. I can see return transactions. But now that I have to care of this return statement. In every case, I don't need this return now at the end of this doing background method. After that, I'm going to override on post execute method on handle this transaction in here. First of all, I need to check that transactions released is no owner. So let's say you know it is not part of transactions. Then let's say at after dots that transactions on Let's pass our transactions But in case it's no, but see a doctor, that's the transactions to a new aerialist off transaction. As simple as that. Okay, that's it for our A C task. We just need to call this fun from different places. We're calling this a sin task. I'm going to create a new method on going to college from inside the any transaction recycler view methods. Let's call that method, get transactions, and let's quickly create that method because I'm going to take care off memory leaks off this a sink task. I'm going to define that as a member valuable. So let's add it up in here. Inside the feuds that's a private get transactions. That's call it, get transactions, and let's initialize thes class insight are get transactions. Method down in here I can see good transactions is because when you get transactions on after that, I need to get the currently locked in user. I can say User User is called to you teams. That is user luck in. After that, I need to check that user is no or not. So let's say, if no is not a call to user, then let's execute our get transactions a sing task we need to pass user that get either That's it for this get transactions method beside calling it from inside these in the transactions recycler view. I need to also call it from inside the UN resume on gonna start method as well, for the same reason that we are calling get amount method from inside those two methods. If you forget, we are going to create different dialogues on from inside those dialogues. We are going to add different transactions so the user can add different transactions even without destroying the main activity. So if the user dismissed the dialogue, we can have newly had transactions. For that reason, we are going to be updated, so we need to add this. Get transactions method inside the on resume on on start methods. So let's do that inside the UN resume. After calling the set up amount, I'm going to call Get transactions method similarly inside on a star. Okay, that's it for our main activity. There is just one last thing that we need to take care of on. That's the memory leaks that can be caused by these different facing tasks. And we are going to take care of that. Memory leaks inside the understory method. That's over right that after the Super Statement, we are going to check that you know, is not. We called to get transactions a sing tasks. Then we need to check that you get transactions is not canceled if it's not cancelled in under strict your great to cancer, let's get transactions that cancer we need to pass. True as the argument here, we need to do the similares think for get account amount as there. Let's say, if no, it's not because to get account amount If get account amount is not canceled, then get accounts, amount stuff, cancer. In our main activity, there is just one last thing that we need to do, and that's handling these different charts in here. They will take care of these two later on. But for now, in order to test our application on these different transactions, let's greatly add one transaction manually in our database. I'm going to do that inside my date of his helper class. Inside this on creates method. After everything. Let's create another method. Let's see test transaction. We need to pass our data reason here as well. Let's quickly create that method. It's return type is going to be void. First of all, in here on break at the love that say it started after that. Let's create content values, objects that's called values is 1/4 new content values after that, the values that put essentially we need to pass different fields for different transactions . OK, that's it for our content values object. After creating that, we need to say yes, you, like database that insert we need to pass our table, which is transactions. After that, you need to pass, nor for the no call them hack on. We need to pass our values. Let's also save the return type of this insert, which is going to be a long, which is essentially going to be the I d off the new Nero and it That's a long new transaction I be. Does he call to death on that smug It's on, Let's run on application. But because we have changed our database, we need to uninstall and install our application. Let's quickly uninstalled application on Let's run our application once again. But because we have uninstalled application, the data for different users has been removed as well. We need to create another account in here. We are lucked into our application on. As you can see, we are seeing That transaction that we have added manually in our data is that seems to be perfect. Okay, that's it for this video. In the next video, we are going to start working on these two different charts. See you in the next video 10. Cubic Linear Chart: As I said at the end of the previous video, in this video, we are going to create some charts, so I have considered creating two charts. One is a cubic linear chart that you show the users profits from different investments. Another one is a bar chart that we show the users spendings. For example, if the user, by some item from a store, we are going to show that in a bar chart in the main activity later on inside the statistics activity, we are going to show some other charts, for example, a pie chart. But more on that in future with views. As I mentioned previously, we are going to use an external library called MP Andriy Chart in order to create different charts. It is a powerful library. It is a beautiful livery on. The developer has done a great job before we jump into work with this MP Andrew truck. Let's have a quick look at the detail page of this library. You can easily search for MP Andriy chart on. You can see the developers get help Page. Let's there's that in 300 chart, the first link from Beautiful. These probably are needed on here is the guitar page. As you can see in here in this page, we have different options become there are different line shores. Cubic. Like this fund that we are going to draw in our main activity. We have all sorts of bar charts. We have also pie chart. We will work with this in a statistic activity later on. And as you can see, we have all sort of different charts that we can drop. Also, there is a video, and there is a documentation in the space that you can check if you're interested. This library is a really powerful Lavery and we won't have the time to cover it all. You will have the options to animate different charts. You have the option to zoom in, maybe change the labels off different axes. You have all sorts of options in this session. We will take a look at a few of those options. But if you want to look deeper, I'm recording a new course on these MP Andrew chart on you explain everything in detail about this libraries and I believe the course will be released in two weeks, so make sure to check that, if you need. Okay, let's switch back to under the studio. So far, we have added dependency for this library on. We are ready to use it. Let's use to our main activity. If you remember in the main activity we had a line chart in which we are going to show different profits from different investment. We are going to give the user the ability to add some investments on with the help of some background tests, for example, a service. We are going to calculates the profit off every month on every month. We are going to add a new transaction in our transaction table in our database. If you remember from the date of his helper class, we had a transaction table on inside that table. We had a column called Type for this exact kind of transactions. We are going to change the type to profit, so we need to get different transactions from this table with this exact type. Okay, let's switch back to main activity because I'm going to connect to my database. I need to create on facing testing here. But before that, let's create another method in here. Let's say in its line. Char. Let's create that method but have a look for so on. Let's minimize all these unnecessary methods for the time being. Let's added to do in this method on later on, we will execute are facing transform inside this method. Let's say to do execute. Okay, let's create our racing past down in here After the transaction facing test, let's say private class, let's name this one. Get profits. It needs to extend a sink test for the import type. I'm going to say integer I'm going to pass User I d later on. We don't need a partner, So let's pass boy on. For the result of this aging test, I'm going to say I really stuff different transactions. If you remember inside our model package in here we had a mother for different transactions . On the result of this, A sink test is going to be really stop those transactions. Okay, lets override to doing background. First of all, we need to create our try cash block in order to cash SQL exceptions right after printing the stacked race. Let's return now. In case something happened, we faced this cash Look. Okay, let's move on in here. I need to. Instead, she ate my database. So let's say it's too late. Database. That's college. Devi is he called to database helper thought. Get rid of a state of it. After that, let's create our cursor. Is the call to divvy that? Q. Eri The table is going to be transactions. We are interested in all of the columns, So let's pass. No, I think I have a typo in here, So let's speaks that for the selection off this Curie, I'm going to say, Look for different records with the user I D. That we have passed through this method on also with the type off perfect. So let's say, look forward to records with the user idea of a question mark and and look for different records, which they're type is equal to another question mark for the selection argument. I need to pass these two arguments. Let's create a new restoring area on Let's Pass our user i d String that value are integers with an index off zero on. Also, let's pass the typing here, which is going to be profits. After that, we need to pass no for group by having on also sort order. We don't need any of them. After creating our cursor, we need to check that defined cursor is null or not. So let's say, if no is not because you are here, sir. Personal. Let's right. The else case in the else case I'm going to close my database. After that, I'm going to return. No, But in case the cursor is not know, let's check that if cursor can go to the first element, move the first. Let's right, the in this case similar to the nal case, that's a her sir that close. Let's a DVD close on after that. Let's return, though, but in case the cursor moves to the first element. First of all, we are going to treat on a really stuff. Different transactions that's Carly Transactions is equal to new released. After that, let's create a for loop and let it right through different items inside our person for anti is equal to zero list and cursor that get camped like less blessed. Let's create a new transaction transaction transaction is a quote, a new transaction. Then we need to set different values for this transaction. That's a transaction That's it. I d. We need to pass purser that get in for the index we can pass person that get follow em index where the index is i d. Similarly for all the others, make sure toe at all different features for different transactions. We have added seven features. Let's go to our database upper class and inside this transaction table, we have I D amount, state type user idea, Asi, Pam and description. These are seven, so you have added all of them after adding different transactions. We need to add this transaction toe. Our transaction are exist. We can say transactions that transaction. After that, we need to move our cursor to the next element. So that's a cursor. Don't move to news after the four do. We can't close our cursor. We can close our database or we should close our database. After that, we can return our transactions and Revis OK, that's it for the doing background method. Let's override the on post execute meant, but before that, let's remove this return. No, because we have take care off every case and we have returned the proper bed. That's a unforced execute. First of all, we need to check that our transaction already. This is no or not. In case it's no. I'm going to simply look a message. Let's say transaction are at least was low, but in case the transactions irises not. No, it means that we have some transactions with the type of perfect. But how we can pass these transactions are released toe our line chart. Well, we can create an object off kind entry. Let's see what that is we can treat on. I really stop different entries. Make sure to import the proper Mondawmin that comes from our library. Despond. Let's call it entries. Is the culture in your area this on? We need to pass the amount off every transaction to these entries. Let's see how we can do that because the user can have multiple investments. For example, a real estate investment, a bank investment on an investment in someplace else. I'm going to group. All different profits from different months is on. I'm going to show them in one data who are doing that? You have multiple options. First of all, you can change the data structure in your date of its for example, in our database helper classman. We have created our transaction table instead of the finding a date's table because I have been more specific because I have to find a year, a month and a day column in here. But I don't want to change my data structure. I'm going to use this date that has been saved inside our table. So let's see how we can group different values by the month. First time I'm going to create a for each loop. That's a for transaction T inside. Our transactions are at least after that, I'm going to get the date off every transaction. But the date has been saved as a stream in our database. We need to part is that in the dates Jova class for that I can say date them on. That comes from java dot you to you. What's college dates is the call to mere simple date formats, the one that comes from Java package. We need to pass the pattern in here. The pattern I'm going to use is like this for vice for four different digits off every year , and dash um, it's important that these to be large, large games for different months is on two D for different days. After that, I can say that cars and I can pass my strength, which is going to be teeth out. Get the He's the name of this transaction that you're looking, but this parts in here is going to throw some exceptions. Let's press out, plus enter in order to see what that is. Let's around our code with a try catch block. And as you can see, we are catching pars. Exceptions. That's okay, Let's move on next. We need to subtract the months from the state for death. I can create an instance off calendar once again the one that comes from Java package. Let's call it calendar is equal to calendar that get instance. It's a single time, so we should define it like this right now. If you leave it like this, it will set the calendar time to the current state. We don't want that. We want the cannon their time to be the date that, despite him, this transaction has been added to our database. For that, I can say calendar, that's it time and I can't pass my date. After that, I can say in a month is equal to calendar that get Andi. I can pass calendar that month as the constant to get the month off. This date there is a certain type of this get method is an integer. If you want to take a look at it on, the integer is going to represent different Moses. But it's very important to know that the months is that are going to be returned with this get method, are going to start from zero, which means that we need to add a plus month in here in order to get the actual value off every month. It's also at the value of month in here on later on, we will take a look at that's a month, and that's pretty good. But there is one thing that we need to be careful about in here on. That's different years. If the user is using our application for some years, we don't want to calculate the perfect off. All the month is in different years. For example, all the profits from July in Von column. We need to take care off the year in here as well. For that, I'm going to show the data from the current here in my line chart only in order to get the current year before setting the time for this calendar. If you remember, I said that if you live the calendar like this, it's well said the time to the card in time. I can get the current year from this calendar before setting the time like this I can say in here is because two calendar that get and this time for the constant I can pass calendar that year. This page. We can get the current here on after our look when we have get the months. We need to check that. If the year of this transaction is he called to the current here for that, I can create on if statement in here. Let's say if Callendar thought gets once again many to pass our constant candor dot year after setting the dates this year is going to be the year of this transaction. If it's equal to year, then we are going to continue. If our court reaches to this point. Perceval, we are going to look at the entries so that we don't add a month to time for that I'm going to create a four look or for each loop or entry bounce again them on. That comes from the MP Andrew Charts Library for entry, The inside Our Entries Before this for Luke, let's create a bullion. Let's name this bullion. Does Mama exists? Let's initialize it 2/4. Okay, that's good. Are for each new every entry inside a line chart as to values X value for the X axis on. Also avoid value for the voy access. In our case, that X axis is going to rippers, and different months is on. The Y axis is going to represent the perfect off that month, so if you can check that you've need that get X X is get ticks if it is equal to our month , the month that we have get from the calendar. If it is the call, so it means that does exist. Bullion should be true on Also, it's important to know that the values inside the eggs on y axis are going to save as on integer or to be precise as afloat. Later on, we will see that we can't use different integers or even doubles as the values off these eggs and boy access. But in the S case, I'm going to change the value of this. Does MMA exist too fast? So let's say else does my exists. Is the call to fuss after this for look, I can check that if does month exist, is not because the truth. Then I'm going to add a new value to this eggs in here or to the precise. I'm going to add a new entry inside. My entries are released. So let's say, if does not exist, is not quite true. Then let's say interests that we need to create a new entry in here for the X value I'm going to past month on for the value. I'm going to pass the transaction amount. If you remember, we are saving the amounts as a double inside our transaction. Let's see if we can save that in here. I can say t that get amount. As you can see, we are getting a warning. And if you take a look at the warning, it says that you can't use doubles. You should use float. We need to cast this tour flux. We can do that like this. We can other practices and we can type float. I don't know why this behavior is like this in here. We just need to cast this double as it looked. But in the end, this case, it means that we have the month in our entries. Instead of adding a new entry once again, we need to eat right through our entries. Aerialist on Find that in tribute that month on at this value off transaction amounts to the current value. So let's say for entry inside are in trees. Let's say if he that get eggs is the call to our months, then let's say either sit boy to either get by, plus the amount off these transactions. Once again, we need to pass that float. So let's do that first, musty that hit amount. So to this point, we have added transaction amount to the right entry. So after this four look, we have on a realist off different entries. We can minimize this on. Let's continue with our really stuff next. In order to pass these interests toe our line chart, we need to create a line data set in here as well. Let's also create that nine data set this fund that comes from our MP Andrey Chart Library . Let's call it Data set is the port of New Line data set. This line in here is also important for different charts. You need to create different data sets. For example, for bar chart, you need to create a bar data sit more on that in future videos. But in here we need to pass two things. First of all, we need to pass our entries aerialists, and after that, we need to pass a labor for this data set on the label in here is going to be profit chart . After creating a line data set, we need to create a line data object that's also create that nine data that's named data is the call to new line data on. We need to pass our data set as simple as that. After that, we can pass this data to our line chart. I can say line charts. That's its data. As I can't pass my nine day Tom. This is going to create a really basic line chart for us. But in order to see what it's going to look like, I'm going to add some data into my date of a self, our quest so that we could see what we are doing being here inside the UN create method. I'm going to add another method or call another message. That's a scientist. Profits We need to pass out issue like these always has been. Let's greatly create this method. They return type is void. That's point. Let's change the name of the state of this two D. First of all, let's either look that she started and in orderto different profits, I'm going toe. Add them inside the transaction Table Beach. For that, I need to create some content values after that's a first, values is equal to new content. Manu's. After that, I need to put different daytime. I'm going to skip the part that I have different values for this content values object. As you can see, I have created three different content values on bond. Webvan. I have added them inside my transaction tables, first value second values and third values. Perversely, I have set the date for the 1st 2 of these content values to the month of August so that we can see so that we could see if we can group the profits from these two months in sight. One single value in our ex taxes off our chart on for the 3rd 1 in the mouth is July. I have added all of these to my database, but because I'm calling this method from inside the UN create method in here, it means that we have changed the database, so we need to uninstall the application on Install it once again. So let's quickly do that less quickly uninstalled this application on running once again. But because we have uninstalled application, the data about the user's have been lost as well. First of all, as you can see, different transactions have been added to our database on. We are seeing them inside this transaction recycle of you. But it's good. That, we have added, is because our recycler view at Afters Layout five has some problems. We will fix this problem later on, but for now let's stick with our chart. I think I have forgot to execute my icing task. Because of that, I'm not seeing any data inside my chart. Let's see yes, in here. They never executed this get profit facing test. Let's quickly do that if you remember we had to doing here. Execute. We need to execute the racing past from here. But because I'm going to avoid memory leaks, I'm going to add my skin test as a member of a river. So let's add it up in here. Let's save private, get perfect. That's called it. Get profits on inside this method. Let's initialize that pacing test. Get perfect physique. Walton. You get perfect After that, I need to get the user or the currently logged in user can say user user is equal to you. Thiel's that these lug in user. Then I need to check that. If there is, there is no or not In case is not know, then we are going to execute our ace in tests. Get profit that execute on. We need to pass our user i d. Let's also take care of the memory leaks off these a sink, passing our on the story method in here like these two racing past. We need to check that if our racing test is no or not. If no is not a call to get perfect if our get profit Asian cast is not canceled then we are going to cancel it. But they get profit, that cancer, and that's passed through in here. We also need to call this innit line chart method from inside the UN resume on the start methods as well, for the same reason that we are calling these two methods because we want our data to be referenced on new. So that's called in its line charts from here and also from inside the honest start. Okay, once again, let's run the application and see how does it look? As you can see, we are seeing some charting here, but this is not what we want at all. But nobody's in here. We can do all sort of modifications on this line. Chart lets you feel them on post execute method off are facing tests in here. First of all, we can change the data set in here. First of all, I said that this is going to be a cubic line charts. So for that, I can see data set. That's it. Moment. And I can pass Cubic busier or something like that in here. This is the moment that we will make our line chart. Cubic. We can also colorize the data below this line. Char Let's see what that those look, we can say data sit. That's it. Draw a few on we can pass through in here. We also have too many access for our charting here. We don't want all of them. For example, I'm going to remove these right by access from here. I'm going to remove the each access and also I'm going to remove this great layer. Discrete lines from the background off my chart were all of those, first of all, for removing the access I need to get the access. For example, I can get the X axis of my line chart like this. I can say X X is the one that comes from our library. Let's call it X Axis is Bacall, too? Line charts that get eggs axis. Then I can have different modifications on this eggs access. For example, I can disable this exact sis by saying eggs axis that's that enabled, and I can best false this feel disabled that it's access. Let's see, What does it look as you can see, the X axis have been removed. Let's also removed the right by access in here. I can get the Via axis like this. Let's say my exes, let's name it by access is the call to line charts. That's get access, right? This funding here you can. The seventh respond like we have disabled the execs is we can save my access. That's that the neighborhood and we can't fastballs. That's run the application once again, as you can see the right why access has been removed. Okay, let's also removed the great lines in here as well. For that, I can get the left by axis like this, Let's say by access that's named Despont. Left access is the call to line chart. Don't get access left. After that, I can see left Axis. That said, there are great lines this funding here and I can pass false. Let's run the application and see if we have successfully removed agreed Miles. As you can see, we no longer can see the great lines. Also, if you take a closer look in here, it says description labeling Here, if you want, you can change this. Let's see, How does that look for the line charts? I can say line chart. That's it description this fun on? I need to pass a new description here. Let's create that description before this line off. That's a description description is a call to new description. After that, I can say description. That said, text on. I can ask my text in here. Let's pass a dummy text in here on. After that, it's past our description to this line chart. That's a description method. Let's see if you have successfully changed the description. As you can see, the description has bean changed. But if you want to remove these fun completely, you can pass No for this description, we no longer need this to line off. So I'm going to come in them for now. On gets past nor for dissent description with Let's see, how does that work? As you can see, the dispute has been removed. Okay, all of these beauty stuff have been solved successfully, but the most important thing in here is that we are not seeing our data inside this line chart. This seems like a serious problem, but this video is getting a little bit long. We are going to solve this issue in the next video. So see you in the next video 11. Bar Chart: Okay, lets see why we are not seeing the different data inside out chart. I have checked the court, and it's not that big of a problem. If you want to make sure you can run the application on, open the lock at once again. If you remember, we have logged the value off month in our own post execute method. On in here we are seeing to 18 here, representing the month off August on 17 representing the month of July. The reason we are seeing at thes Martha's two times or to be precise three times is because we have executed are racing test three times in one create on resume on gonna start method . It means that we are successfully retrieving the data from the database. And if you want to be 100% sure after the Ford Blue in here, you can lock the value off its envoy from different entries. We can create the four looping here, Let's say for entry inside our entries, let's look the value off eggs Envoy. Let's say either get picks, Plus, with the value off you don't get if you want, you can look this as but Let's open the Luckett on in here. You can see that is eight, which is the month of August. Envoy is 40 which is the sum off these two transactions in here? 15 on 25 and also for the month of July. Why is 32 which is the only transaction that we have done in the month off July. So we are successfully saving the entries. But boy, aren't we seem different values inside our charts? Well, the reason for that is because the data inside the X axis is being saved inside different floats. Let me enable the X axis for a second and let's see what I'm talking about. I'm going to pass through in here on. I'm going to run the application once again in order to see different peaks access. As you can see, we are starting from seven, which is the month of July on we are increasing the number by two decimal points we are interested in every month is perfect. So this is not a good behavior for our need. Devens thes data to be increased run by boat from 7 to 8 to nine and saw. So that's the savior of the X axis for now. But before disabling the X axis, I need to defined the minimum and maximum space in here manually. I can say it's access that said, the space minimal and I can pass VON as a whole number. Also, I can define a maximum of space in here as well. I can say X axis thoughts that the space maximum on. I can passive on in here as well. Let's see what difference these two attributes in here make in our chart. As you can see this time, we are seeing different data for the month of July on month of August. Also because we want to see the whole yearning here, we want to see the value for 12 months in here, you need to set the maximum value for the X axis as well. For that I can say each axis that said access maximum and I need to pass 12 in here for 12 months. That's around the application once again and see the difference. You can see this time the interval within these two months has been decreased. Okay, now that we are seeing the data in our chart, we can do all sorts off modification in here as that, for example, we can change this color from blue to another color, maybe a green color. For that, I need to change the color inside the data set in here. I can see data set. That's it. Feel color this month, and I can pass my customized color. I can see color thought green. Let's run the application and see the difference. As you can see, the color has been changed to green. Also, I don't like the fact that the maximum value in our chart is equal to the maximum value off piece by access. I can change that by coming in here and set another attribute for these left axis. I can say Left Axis. That said, excess maximal And I can't pass any number that I want. For example, 50. Let's run the application and see what difference does it make? As you can see this time, the maximum value has been decreased. We can also set a minimum value for this by access as well. Let's say, left access that said access minimal. Let's find that access minimum, and I can't pass 10. For example, in here that's run the application once again, and this time we can see much better. Let's increase the value off by access maximum to, let's say, 100. This time it's much better. We can also animals showing these data as well. For example, in here I can say line charts does an image we can animate both each envoy access. But in here I'm going to just animate the Y axis. We need to pass the duration in here, which I'm going to pass 2000. Let's run the application and see. How does it look? As you can see, we are seeing some animation that seems to be perfect. Besides all of these attributes, we have a lot more attributes that we can apply to this line charting here on If you want to see a holy stuff options, I suggest you take a look at the documentation, but if for some reason you prefer video to 30 hours, I am recording and you tutorial for these MP Andrew chart on. I'm explaining everything in detail about this library. It's will be released in, I believe, two weeks, so make sure to check that if you need okay, let's move on. Let's work on this part shirt at the writing here. This chart is going to represent different shopping's off the user. So for that, let's create another method on. Also, let's create another erasing test before everything. Let's minimize the current tasing task. We are done with it, and also let's minimize all the unnecessary methods. For now, let's call that method from inside the UN Create method. Let's say units, part shark. Let's quickly create that method. Void is fine as they return tight. Once again, Let's added to doing here. Let's say execute. And also I believe we should remove these to the farm here because we have to take care of its successful. Okay, let's create the icing task down in here. That's a private glass. Get the spending it needs to extend a sink task class for its parameter. For the import type. I'm going to pass into your pants again. I'm going to pass the user I d for the progress. I don't need anything. Let's past boy. But for the result of this aging task, I'm going to pass on a realist off different shopping's. If you remember inside our database, upper class. We had a table called shopping. Let's quickly create a model for this shopping inside our mother package. We can create that mother for this shopping. We have a new I. D. You have a user I d. We have on item I D v have a transaction, I d. We have a price. We have a description, and also we have a date. So I'm going to skip the part that I write all of these fields. Let's greatly create two constructors. One will receive all of the fields. Another one would be an empty construct. Er, I believe it. You'll be helpful after that. Let's greet all the Gators and suffered. I'm not sure that we are going to need all of them, so I'm just going to create them. And also I'm going to create a two string. I believe this one would be helpful as well. Okay, now let's switch back to our main activity, a Z, the result of this aging task. Let's pass. I really stuff different shopping. Let's created the background method before everything. Let's create to try cash block and cash tissue exceptions on. After printing this factory's let's return no inside the tribal. Look, let's initialize our rescue lights database. That's college TV is equality. Date every cell for dot get readable data Aries. After that, let's create our cursor Is the culture db dot curie The table is going to be shopping. I'm not sure about this spelling. Let's switch back to our database, help our class. And in here, Yes, the name of the table is trouble. Let's get all of the columns. I believe we are not going to need all of the columns. Similarly, we didn't meet all of the columns inside the get profit, but we have passed. No. Anyway, I believe the only columns that we are going to need are going to be priced Sunday. So let's pastors to let's say thanks on price. After that, let's pass our selection. The selection is going to be user I d. That's a user ideas we called a question mark. And for the selection argument, let's create another string every on its past history that value off integers with an index off zero, which is going to be the user idea after that, let's fast enough for the group by having on sort order you know what we should do next. We need to check that if the cursor is no or not. So let's say, if no is not recall to cursor. First of all, let's right the else case in the else case we need to close our database. After that, we need to return now, in case the cursor is not know. We need to check that. If cursor that move to first element before that, Let's right the else case. In the end space we need to close our cursor. You need to close our database. We need to return now, in case the cursor does move to the first element. Let's create an really stuff different shopping that's called it shopping's busy quarter new aerialists. After that, let's create our for Luke for int by is equal to zero less than cursor that get counts by plus. Plus, we have done all of these 1000 times, so I'm not going to explain any of these inside this for look, I'm going to create a shopping object that's called it Shopping is the felt A new shopping here is where the empty construct er is helpful. After that, I can say shopping. That said Date two cursors dot get string cursor that get column index where the index is going to be date. We are only receiving the date on price. I'm just going to set those two after death. Let's at the shopping to our shopping's released on the Natural Shopping's is a word or not . That's a shopping. After that. Let's move the cursor to the next element after the four loop, let's close our cursor. After that, let's close our database after death. Let's return our shopping area, Please. We need to remove the return now from down here, and that's more were right on post executing. First of all, we need to check that if now is not equal to our shopping's released in the else case, I'm going to lock something. Let's say Shopping's aerialist is no, But in case the shopping's a realist is not know we need to create on I really stuff bar entries. This time you can see that entries for different charts are different. For the line chart. We had entry for the bar short. We have bar entry that's called this one entries is important. New areas similar to profit chart where we have groups different perfect by the month. I'm going to group different Shopping's by the day on. I'm going to show only the last month is shopping in my chart. For that, I need to create a four loop and ETrade through my shopping's aerialists for that against their shopping s inside My shopping's released and in here. Once again, I need to get dates off every shopping. For that, I can say date. Date is reported. New simple date for math. I need to pass the pattern in here. Once again, I'm going to pass the previous pattern. Bye bye bye boy, Tash in em dash DD does pars and in here I'm going to pass their start. Get date. Once again, this part is going to throw. Some exception. Lets cash that it's a parts exception. That's fine. After getting the date off these shopping, I'm going to create an instance off the calendar object That's a calendar calendar is a calendar that get instance right now, it's going to save the current state. Let's get the current month. That's a each month. Is he called to calendar dot Get calendar dot mom off course, plus one is neither than here because Martha's are going to start from zero in our calendar after that. That's at the date off our calendar to the state that we have received from the shopping. I can say calendar that set time and I can't pass my date after that. Let's get the day off These shopping, I can't say today is equal to calendar that gets this time for the constant. I can't pass calendar that day off a month. This funding here. We also need a plus one in here as the After that, I'm going to check that if the current month is equal to the month off this shopping for that, I can't say if calendar Duck gets candor dot month plus one. If it is the call to our month for our current month, then we are going to continue similar to profit because I'm going to show on leave on bar for every day inside my chart. I need to check that if we have this day saved inside our entries or not, I'm doing this because if the user by multiple items in Monday, so we don't add multiple bars for that I need to create a four looping here for bar entry. Let's call it a inside our entries before our four look. We need another bullion in here. Let's say bullion, Does they exist? That's initialized to fuss on in here, I can say if he does get X is equal to our day, then let's change the value off that bullion to true. But in the else case, let's change it to falls after our four look. You need to check that if this 1,000,000,000 is true or not, we can say that if does William exists is not called truth then. But at a new entry, I can say in trees, the that that's in your bar entry for the X value of its past day on for the value. Let's pass the shopping's price. I can see as that get France, but of course it's a double, and I need to cast it to have a look. But in case it does exist in our entries, aerialist, I can say for bar entry inside our entries. If it does get X is equal to our day, then let's at this price, I can say either, said by, Let's say, either get by plus the float value off that price. Let's say s that, Get price. Okay, that's it for our four. Look, we can minimize it. We're done with it after this for look, we have our entries or to be specific behalf our bar entries. Then we can create our bar Data said. I can say far deficit. That's candidate us. It is the cult. A new bar Data says I need to pass my entries on also a label in here as well. Let's say shocking chart. After that, I need to create my bar data. I can say bar data. That's quality data is equal to new bar Daito, where I need to pass my data set. After that, I can set this data to my bar chart. You can say part short that said they thought and I can't fast mate date. Also, there is another attribute in here that I have forgot in the line chart as well, and that's invalidate bar chart that you validate. This invalidate is like notified Data's had changed inside a recycler view a doctor. It's well referenced the bar chart. It's going to be helpful for keeping our data inside our charts off dead. So let's quickly at this invalidate toe our line chart as well. Inside the UN post execute method off these facing tasks where we have set the data. After everything I can say line chart that invalidates. Okay, that's it for the line chart modifications. Let's minimize the racing test. Let's run the application and see if we can see the barter. We are not seeing anything, and that's because our database at the time is empty. We need to add some data to our database to see some barter. That's quickly at some test data inside our database helper class. Inside, on Create method. I'm going to call a method called test shopping. Let's create that method. Boyd is fine. Lucky started Once again in here, I'm going to create some content values. Object. I'm going to skip the process off creating this content values object. I have created the content values, but we need to receive a database in here in order to insert this content values in our data raise. So let's receive that sq like database and in here for you to receive that as well. Issue like database. Let's call it D. Be okay for these three different content values. I have said different items representing three different shopping's. None of these features method unless the price on the date the price is different for every counted values on. Also, for the date, I have intentionally set the date off the 1st 2 content values. Similar. Both of them are happening at the same day because we are going to see that if we can group these two shopping from one day or not, and for the third content values, the date is different. I think if we change this fund to maybe the second of October, we could see the Parcher visit that doesn't make any difference in the actual value. It's just with her for visualization purposes. Okay, we are done with this class. Let's understand the application on installing. Once again, let's quickly create another accounting here. We are not seeing any data in our bar chart, and the reason for that is because I never executed this Asian tasking here. That was my bets. Are you guys let's quickly executed inside these in its bar chart method, but because I'm going to avoid memory leaks. Let's add it as a member, right? Even let's say private, get shopping or get a spending was its name. That's initializing insight on this. In a bar chart method that's a gets shopping or get spending is the question. You get spending after that. We need to get the luck. In user, you can say user equality. You Thiel's that is user like me. After that, we need to check that. If no is not a call to our user, then we can execute. Are racing test? Get spending that execute we need to pass. Our users don't get fighting similar to all the other a sink task. Let's under the memory league situation on. Also, let's call this method from inside the on a start on on the resume methods. As we're inside the UN resume, I can say in its bar chart method departure inside the on the start Soon. Our thing he needs bar chart. We are going to refresh our data on we're going to keep our data updated. For that reason, we have called that method inside. On a start on resume on inside understory method, we need to take care off the memory lease. You can say, if no is not because to get spending then we can say you get spending is not canceled, then cancer to get spending death, cancer. Let's run the application once again and see if you can see any data. Okay, this time we are seeing the bar chart, which is a good sign. But we are not seeing the actual bar data. But this video is getting a little bit long. In the next video. We are going to debug this problem on. We are going to figure out why we are not seeing any data inside this Parcher. See you in the next video. 12. Customize the Bar Chart AddShopping Activity: Okay, let's fix the problem with this Parcher. And that's why it's not sharing our data inside to get a spending a sing task inside the UN Post execute method inside the for loop. I'm talking about this for being here when I have to find this. If condition in here, I have put this plus one in the wrong place. Right now, it's adding to the constant on. This is not our desired behavior. We need to add this plus phone after this, Francis's to the month itself. Actually, come to think of it, this responding here is not necessary at all because we are not showing it to the user. We are just going to check that if the shopping month is equal to the current month so we can delete this plus bon from here on, also from above here. But let's leave it being here and let's run the application and see if you can see the data at this time in our bar chart. As you can see, this time, we are seeing the data. Let's also apply some modification to this part chart as well. First of all, I'm going to remove these to access from here, this X axis and also this right? Why exes for that in here before? Said Data, I can say bar charts does get access, right? That's it. A neighbor on I can has false for the right boy exes for the X axis, I can say X X is that's college eggs. Axis is because two bar charts that get beach access. After that we can see it's access the set the neighborhood. I can't pass false in here as well, but before I disabled this, it's access. I'm going to add some other attributes to it as well. For example, that's the X axis. That's it. Access maximum responding here on gets past 31 for 31 days in every month. We can also change the color off bars in here on this data set as the I can say data sit. That said, color on. I can pass any color that they want in here, For example, let's see color dot rip. Okay, let's run the application and see if these changes are going to make any difference or not . As you can see, the size off the bars has been reduced enormously and also the color of bars have been changed to read. Let's also increase the maximum size off these boy access here as well. For that I can create my boy access that say, why access that's calling my access is because, too bar charts that get access left this time after that. Let's see by excess that said maximum or said access maximum on Let's pass 100. Also, let's set a minimal value in here as the Let's say, my exes. That's it. Access minimal on Let's Pass 10 for example. That's on the application. 100 seems to be too much. Let's decrease it to 40. That seems a lot with her. Let's also removed the great lines from the background as well. For that, I can save my exes. That said, there are great lines on, like on passed balls before running the application that's also disabled. The description in here as well. I can say bar charts that said description, and I can't fast no record of execution. Let's run the application one last time and see all the differences. This seems much better, Okay, now that we have created our different charts, let's fix the situation with this transaction. Recycler view layout. Fine. If you remember, we had the layout file called. Least item transaction inside a resource is folder inside out layout folder. This item transaction dot xml The dispute shin can be too long. So we are going to move it to left off this sender, which is not a good name. Also, let's say to left off, I didn t x descend That I believe was its i d. Also, I don't like it to be right to the left of this fun so I can see a line parent left on. Like I said, it's true. That seems much with it. Also, if you take a look at the application, you can see the transaction already in here, but it doesn't have any explanation on. Really. It doesn't mean anything inside my recycler. We read after I'm going to add a text to this funding here, for example, I'm going to say transaction. I d call him on. After that. I'm going to put the actual transaction I for that. Let's switch to transaction. Adapt, sir. On inside on buying view Holder method, where we have set the transaction. I d in here. I'm going to say this text lost that transaction. That's a transaction fee. Most common. Let's run the application and see if we have fixed those problems. The problem with the description seems to be fixed on. Also, we have added the transaction idea in here, as that seems to be perfect. Okay, let's move on to the next part. Next, I'm going to add a menu item in here, talk in my tool, work on. By clicking on that many items, I'm going to open a new dialogue, and in that day, like I'm going to show the license text once again, I'm going to add to butt into that dialogue with one, the user can visit the website on with another one. The user can invite other friends or other contacts to be precise to the application. So let's quickly at that menu item in here for that. First of all, I'm going to close all the opening files. I don't need them anymore. I'm going to create a new many resource fire. Let's name this fund Main Activity two of our menu. Let's switch to the text here on Let's at only one item before I add this item in here because I know that this item is going to need an image. I'm going to add an image inside my meat map folder. I have prepared an image for that purpose. That's quickly copy that in our project. Inside the meat, the name is fine. I guess that's press, OK and OK, okay, now in here, every country are right for its title. Let's say make put for its i d. Let's say let's say menu may quote Sandra, it's passed on. Icons here has been I have two images inside my me laugh older makeup on a make with a square. I'm going to use the make with respect. I'm going to sit another attribute ng here on that show as action. If you remember, this fund is going to define that if our icon should be topping here or not, we have three options. Always, never. And if room I'm going to select always. Okay, that's it for our item. Okay, now that we have created this, let's added to our main activity inside my main activity. That's Joe. Fine. I'm going to first of all, minimize all these extra methods and classes. After that, I'm going to override a method, and that's called on Create option menu. If you remember, this one is responsible for creating many options on the way you do that is like this. You call. Get many inflater that inflates method. After that, you need to pass the address off your many resource fine, which in my case is artist menu dots main activity to learn menu. And after that you need to pass this many items that has been passed to this method, but its past that in here, after everything instead of returning the Super Statement, know that we have inflated our menu. We need to pass through here. This method is responsible for inflating the menu items, but there is another method responsible for creating different event listener or to be specific, click listeners for our many items. That's over right that as and that's on option items, selected, listening or on option items selected before the return. The statement we need to create a switch statement. Switch on item does get item i d. In case it's our idea that many you may coat this one. We are going to do something after death any to break out of the loop. Let's also added default. Case in here has them in case if the item is menu make good, I'm going to generate a new alert style look for that I can see the other day. I, like, does feel there. That's college bills. There is because in your other turn like that being there, we need to pass a context, which I'm very capacities after that. That said, it's vital for these other dialogue. That's a seven Tyto on Let's say make. After that, we need to send a message once again, I'm going to say, Developed by Mason that may quote that. Let's also add two buses in here that said, It's not actually a negative button, but I'm going to say negative anyway for the negative button. That's a visit that's at unclear glistening here as well. For the visit button, I'm going to open the website activity, so let's create an intent in here new your intense for the context, the same main activity that this for the destination, let's say website activity that we don't need to set any flak for this intent. That's just a start. Start activity and let's pass are into after that lets it a positive button. But its text. Let's say Invite friends. Let's also sit down Uncle Inglis in there and you on Click this in there in here. I'm going to create an intent on I'm going to open the messaging application on. I'm going to give the user the ability to send some messages to his or her contact. For that, I'm going to create and urine testing here. That's a new Internet on for the action, I'm going to say intense that actions send. We need to put the message inside this intent, as the let's say, intense thoughts was extra for the keying here. I'm going to say intense the extra text I will create. This takes part the time being. Let's just passed on empty strength because these actions and does not have any idea off the type of data inside this intent, we need to specify the type of detail in here as well. For that I can say intense. That's it's tight and for the type I can pass that takes and to be specific, plain text. You know that ticks can be HTML as there or some other takes times after that, I'm going to open a chooser for the chooser. I'm going to create a new intent that's called the choose their intent. I don't believe we have seen this true. Their intent. It's basically going to give views or some options. For example, if it's a text, the user can send the text where the messaging application also via I don't know what's up or whatever that is available on peace or rare form. This true, their intent is going to give the user all those options on the value defined that is like this, you say intense, that creates chooser this phone. You need to pass your actual intent with the data, which in this case I'm going to pass intent on. Also, you need to set a tighter for this. True there as well. Let's say, sent message of video. The college that's it for our choose their intense. We just need to fire. You can say start activity and we can pass our chooser intense. I'm going to copy a message in here before creating this intense onda messages saying Hey, how's everything? Check out this new awesome happy it helps me manage my money and stuff Onda. After that, there's a link to our application. In this case, I'm putting the link to my website in here. But if you have published your application in the play store, you may want to include that in here. Okay, now let's pass. That message is stream instead of these empty string. After creating this other day like that builder adjusted to show, I can say Builder Dutch of Okay, let's run the application on. That's if we have successfully populated the many item. And also, if we have successfully said these Uncle Ignace there for our menu allies, we have populated the many I templates. Click on it. You can see the dialogue difficult can visit the website. Activity should be opened on the are seeing my website that seems to be perfect. Let's also click on the invites friends. As you can see, this is the chooser intent where you can select within different application in this case Gmail application who go drive application messages on other stuff. Let's select messages. In here you can select different conversations or different contacts. I have only von contact in my phone with a fake number. This is not a real number, so don't try that, please. That's selected new Mrs In here. I believe I should have another contact in here. Yes. This is also a fake contact on the Here is the text message. If we try to send this, this is a ritual device, so it's not going to send it. But you get the idea. You can see the linking here if we click on it on. If you try to open it, we are successfully opening it inside another browser. That seems to be perfect. Okay, now that we have to care of our main activity, for the most part, let's start working on these different activities in here. First of all, I'm going to start by shopping activity right now. It doesn't do anything if you click on disrupting. Let's quickly create a shopping activity on. Start working on that. So I'm very close. My main activity inside my package I'm going to create a new activity that's called this fun shopping excuse. First of all, I'm going to start working on the layout file on in order to save your time, I have prepared the layout. Five For these activity. It's really a simple layout five, and you will see that in a minute. So let's base that in here. As you can see in this preview in here, it's all basic stuff. And if you want to have a reviewing here, let's start from the beginning. It's a relatively out right after that I have created Unless of the school of you beach, it's beat. San Height is much parent. You know that every ness of the school of you can have only one element or one child. So I have created this relatively out in here inside this relatively out. First of all, I have this button in here, which is this Parton at? As you can see, it's below everything. It's basically beloved this description in here. You will get to that description as the after that we have the state relatively has consist off another, relatively out on. Also, it takes you if you want to see the relative that it's basically this date edit text on also this select eight. But, um, basically, I'm going to open a date speaker dialogue by clicking on this button in here on after selecting a date. I'm going to paste that in here. Also, the user can enter the dates manually in here as well. On the text is just the state takes in here as a distribution. After that, we have another relatively acting here, a story reality layouts. So basically, this is going to be WalMart, or maybe some other story in here the user can into its optional in here, and it's not necessary. It's consisting of the sped it text speeches. Exactly these Inditex and also this startext view, which is kind of this gritty. After that, we have the spiritual relatively out, which is containing on edit text on. Also it takes to be for the edit takes the number of lines is too. So if the user wants to add a long description here, she would be able to do so. After that, we have this item relatively outing here. It's containing a button, which is this exact button that you can see in here on also hidden relatively out, as you can see this relatively out. But if you want, you can change the visibility visible in here. So basically, by clicking on the speak item I'm going to open another dialogue in which the user can search for different items. By selecting one of those items, we are going to add a callback in which the dialogue would be dismissed on the image on the name off. The item would be updated in here, and also we haven't any Texan here, which is a price the user can at the price manually. In here on the price is mandatory user shortened three. Okay, that's changed. The visibility of respond to have gone for now. As you can see the edit text, which is priced the image you the item name. After that, we have to text you topping here, which is at shopping. It's just a scripted and also we have another. He didn't text viewing here. If you want to see that, we can change the visibility to visit Bill. It's just for bargaining purposes. It's basically going to tell the user toe at the price or maybe date on dispute Shin and okay, let's change its visibility. I hope that review helps you to understand this layout fine on right it by yourself. But if you need to check the source code, I will upload the source code at the end of every video at my website at Meiko dot or with slash court. So make sure to check that, if you need Okay, let's move on from this part. I'm going to initialize all of these you high elements inside the shopping activity that Java five. First of all, let's close this manifest. I don't know why that is open or gave us again in order to save your time. I have initialized all of these your eye elements. Nothing special is happening in here. Okay, Before I start working on this shopping activity, I'm going to add the intent inside my transaction. So I look so that we would be able to navigate to this activity if we take a look at that transaction. Don't look, we had it to do up in here for the shopping. We can create our intent here. That's the intense is equal to near intent for the context. Let's they get activity for the destination shopping activity. That class read only any flag. So that's a start activity and it's passed out a super list there. This video is getting a little with long. I'm just going to work on this part and pick date on your finished this video after that for selecting the date. I'm going to use date speaker dialogue. But before I created that dialogue, I need to create a listener for data, even see how exactly we are going to use that. But even before that, I'm going to create an instance off the calendar, which gets the currents. They Let's say calendar is because calendar don't get instance. So basically, this is going to be the date that we are going to show when we opened the date picker Doyle . Look, in this case, it's going to be the car in states. Let's create the date speaker, that listener we can save private, they speaker dialogue That's on dates, said Listener. Let's call it State, said Listener is a cultural new date. Spickard. I lucked out on dates set listener. Let's finish our sentence before everything. This is the listener for our date speaker. There look, and it's going to be helpful when we select a date from that date, for example, in here I can say calendar that set for the key. I can say calendar that year on for the value. I can pass this pie in here. I don't know why they didn't use any more descriptive name, but the 1st 1 is the year. The 2nd 1 is the month on. The 3rd 1 is the day off the month so I can pass All right in here for the month. I can say calendar that set for the constant. I can see Canada dot month on for the value. I can see one. Let's also add the day in here as well. Calendar got set calendar that's day off a month. Hamlets passed by two as the men. After that. If you remember, I said that we are going to change the text off our date edit text as well. When the user select a date from our date speaker dialogue certain here I can see and it takes date. That's a text to, let's say, new simple date format. We have a simple for mother in here on. We have a simple date for months. This is the one that we're going to need simple date format. We need to pass a pattern in here, which I'm going to pass the previous pattern that you have used for rising here and dashed to em to Capitol limbs after that to these. After that, I can say that format, Andi, I can pass my calendar that's gets time, which is going to return a date. Now that we have created this listener, we can create our date speaker Diver. I need to do that in here. Inside, on Create method. I can save ET and PT Date. That's it's unclear Glessner that seem the uncle listener in here, Let's say New Day Speaker. Do I Look, we need to pass a context which I'm going to pass shopping activity of this. After that, you need to pass our listener, which I'm going to pass date listener. After that, I need to set the initial date for this date picker dialer. And for that I can use my calendar object. I can see calendar that get and for the constant I can see calendar year. First of all, after that, I need to pass month on the day off. The mouth has been, so let's quickly pass them. That's a Canada Dot gets for the constant. Let's say Canada does month after that, it's past the day calendars us yet can in there does day off month. That's it for our date speaker dialogue. We just like to show it with the Dutch room method. Okay, lets test application. And if you did for we will finish off this year. Let's elect our fluting action. But then let's elect shopping. Andi in here. Let's select date. We can see the day speaker dialogue. I don't know if you can see the card stating here, but it's October 6. Andi in here. We have initially set the value off the states. We care to October 6. Let's select a day thing here, for example, fourth of Observer and let's like, Okay on. As you can see, that date has been added to the state at the text in here as we formatted it up in here. Okay, everything seems to work. Point. Let's finish off this video in here on. Let's work on the rest of this activity in the next video. See you in the next with you 13. PickItem Dialog: Okay, let's continue creating our shopping activity. First of all, I'm going to start working on this button pick item. As I mentioned in the previous video, I'm going to show a dialogue in which the user can search for different items on if the user select one item I'm going to make that item relatively are visible on. Also, I'm going to set the name and image off the items inside the shopping activity layout file to the item that user is going to select from that toilet. So before everything, I'm going to create that toy look that will be open when the user click on this button. Pick items. First of all, let's create the layout fund for Destiny. Look inside my resource is folder inside the layout. Fuller. I'm going to create a new layout. Five. Let's name this found dialog. Select items. It's a really simple layout file, and I'm going to copy the code that I have written previously. So it's basically a linear layout with edit text in Visual User is going to enter the name off the item on also every cycle of you, that's all. Let's quickly create the gel. If I for the styling Inside my job folder. Inside the package, we have a dialogue directory that's basically create a Jolla fight in here. Let's name dishpan Select Item dialect. Let's minimize the project pain for now on, let's extend the dialogue fragments First level. I'm going to overwrite UN creates dialogue method on before the return statement, I'm going to create my view. Object. Let's save you view is because, too get activity. Thoughts get layout if later that inflate. Are that layouts? That dialects select item. This morning here, Onda expressed no as the root after that, let's greatly initialized Are you? I elements. First of all, I'm going to other look, let's say private as it text edited. Txt fightem name. After that, let's say private recycler view that's named this one item recycler view on. Let's initialize the stool inside out on creating dialogue method. After initializing these two items, I'm going to create my other dialect that build our object that's called this one builder is he called the new other day, like that builder get activity as the context. That's it view that's past our view. After that, let's also said the title, Let's say Select an item that suit Porter. Build our object in the return of statement. Instead of returning the Super Statement, I'm going to return biller dot communities. Before working further on this dialogue, I'm going to create the recycler view adapter for different items. But even before that, I need to create a mother for different items. So let's greet. We create that mother inside our mother directory. Let's name this class item inside this class, we are going to have an i D and name on image Jarrell on also a description. So let's quickly create those. Let's also create to construct Tres Bon will receive all on one will receive. Not after that. Let's create the givers and centers on. You know for sure that we are going to need to a string method. Okay, let's quickly create their cycle of you adapter. But before that, let's close all of these fights insight that that there's package. Let's create a new job class. Let's name this fund items adapter before everything. Let's create our view holder class, public less. Do you hold there? It needs to extend the recycler view that view holder. Let's create the cost director. Inside this class, we are going to initialize all of our you I elements. But before that, we need to create a layout. Find for every item inside our recycle of you a doctor. For that, let's go to our resource is full there and quickly create that. Lay out. Five. I'm going to name this font least item items. It's really a simple layout file on. I'm going to copy thing here. As you can see in here, we have a card view in Beach it has on elevation off. Five dp, a card coordinator reduce off five dp and also it has an idea off parents Inside that car view, we have a relatively out on the inside that relative layers. We have an image view and also a text. You just for the name on the image off that item. Okay, let's quickly initialize one of thes inside our view holder class in here. I'm going to say private image view. That's name just one image. Private text. You. Let's name this fund name and also private car to you. Let's name this pond parent. Okay, that's it for our view holder class. That's extend the recycler view that adapter above. In here. Let's implement three methods on Create your holder on buying beer holder on get item count . But before working on each one of those methods, I'm going to create an aerialist off different items. Let's call this area list items is the part new aerialist and also because I'm going to show different images on I'm going to use Glide. I'm going to need context for that. I'm going to say private context, its name just one context on. I'm going to receive these contexts where the construct and also I'm going to need an empty construct er in order to avoid null pointer exceptions. First of all, let's handle the get item counting here. I'm going to return items that size that's also create a safer method in here for different items inside our A list. After death notified, the data's had changed. Let's create the UN created the older method. That's a view view is equal to layout Inflator does from our parents. That context after that inflates are that they have start the sight of items hands on false , like we did it 1000 times. Okay. After that, we need to return, and you you hold their object in which we need to pass the view for its construct. After that, let's work on this on buying view holder. Nike started. But before that, we need to added locked up in here. So let's say Holder, but name. That's a text. Two items that gifts position, stuff gets name. I'm going to show different items images in here on. For that reason, I need to add the light dependency into my project. So let's quickly find that I can search for glide dependency. Um, the dependency should be in there. Get help. Page. Let's add this to line up good in our project. Okay? It has been added successfully. Let's move on from to spark in here, I can say light. Don't be. I need to pass context after that as bit math that load items that get position, not get image. You are after that into older that after that I'm going to set up unclear Glessner for my car. To you, I can say Holder, that parents that's it. A click listener, new uncle, listener. And in here I'm going to create a call back and I'm going to pass the selected item to the dialogue on from there to the pirate activity. For that, let's quickly create an interface above in here. Let's save public interface that's named This fund gets item. It's going to have only one life, it void on getting itineraries up. We need to pass item in here. We need to create an instance off this interface that safe, private, get like him. Get item on. We need to initialize it inside. This uncle agrees that but because I'm going to first all past this item to the dialect, I'm going to receive that dialect in here as well. There isn't that I'm passing this item to dialogue first. Is that because I'm going to dismiss the dialog? If I pass the item directly to the activity, the dialogue won't be dismissed For that reason, that's quickly received the dialogue in here as well. Later on, I will implements thes interface inside the select items dialogue. So let's receive a dialogue fragment in here. I'm going to receive if I out the construct. So I'm going to remove this, construct er and create a new one later on inside the on click listener I can see Try catch in order of the cash glass cast exceptions and I can cast that in their face to that toilet . They can say get item is because too gets item. I don't look fragment. After that, I can save get item does I'm getting I can result on I can pass my Aiken They can say items that get and they can pass my position. That's all I need to do inside these items that after that switch back to our daily in here . First of all, I'm going to implements that interface that I just created implement, get item. But of course I need to override that method. Is that first of all, let's look the value off this item. That's a item, Doctor Stream. After that, I'm going to create an instance off that interface in here as well. I can say private get item. That's college. Get item inside implemented method. I can say get item is because too get item on. I can pass my get activity later on inside the activity. I will implement this method as well. But of course I need to surround this fun. We destroy catch block has. After that we can see get item that on getting item results on. I can't pass my on right after that I can't dismiss my that's all for now. Let's instead she are items adapter in here. I can say private items that let's call it adapter on inside on create style look method. I can see a doctor. Is he called to new items at that there. I need to pass a context which I'm going to pass Get activity on. I need to pass a dialogue fragment which I'm going to pass it this for that. Once again, this refers to the current object on the art insight dialogue fragment. After that, I need to set this adapter to these items recycling you. You can see I can recycle of you. That's that adapter can't pass me adapter. After that, I can say I temper cycle of you that said layout manager on I can't pass new linear layout Manager Beach for the context, I need to pass get activity. Also, after that, I'm going to set a text butcher for these edit text because I'm going to set for different items inside my database whenever the text changes. So for that, let's say anything's item named that that takes changed listener. In reaching here, I need to pass a text butcher. I'm going to pass new text Butcher. I don't need all of these methods. I just need the intakes change method once again because I'm going to collect my database. I need to create an facing tasking here on I need to call it from here That's created to do for now on. Let's greatly create our racing test down in here, I can say private class I need to create to a sink tasking here one for searching for different items on bond, forgetting all the items because even if the user don't search for any item, I'm going to show him or her all the items available in our database. First of all, let's create a sing test, forgetting all the items. So let's a private class get all items it needs to extend the racing test class. I don't need to pass anything specific for the input for the progress as well, but for the result, I'm going to pass on a realist off different Oh, you thumbs. That's overrated. Doing background before everything. Let's create a try catch block and that's cash. SQL exceptions quickly after printing US factories. Let's return now. I'm going to connect to my database so I'm going to need the database helper class. Let's quickly create that here. Private database helper. Let's call this one date of the super and Let's in San. Shayt sits down in here state of his helpers. He called a new database helper. I'm going to pass get activity as the context in here Inside this doing background method, I'm good to see. Issue like database that's called a TV. Is the call to date of his helper. Get readable data vase. Right after that, we need to create our cursor. Is he called to database that Curie? The table is going to be items. If you remember inside our date of his helper class, we had a new items table. That's they Look at that in here. We have a table called items. Okay, let's move on from this part. I'm going to pass. No, because I'm going to receive all of the columns. I'm going to pass now for all the others because I'm going to receive all of the items, so I don't need to specify any specific condition in here right after that. I need to check that the cursor is not or not personal. Let's right. The else case in the else case. I'm very to close my date of ease. After that, I'm going to return now. But in case it's not know if person that moved first, let's right. The else case first in the X case. Cursor that close. Do you read us? Close returned up in case cursor does move the first element on a realist off items That's quality items this report New aerialist. After that, let's create a formula for in eyes he called zero eyeless than cursor that get Count Andi. I just lost. Let's create an item object in here. Busy part, you know? Item on. Let's it all of the fields for this item item That's it. Ivy cursor that. Get in here, Sir, That good column In days on, we need to pass by similarly, for all the others. After that, you need to add this item to our items aerialists on. Right after that, we need to move our cursor to the next element after the four Luke, we need to close our cursor. We need to close our database on. After that, we need to return our items. Aerialist. That's over right on post execute method. But before that, let's delete this return now from here on post, execute inside this method. First of all, we need to check that if our items is no or not. If it is no, I'm going to sit on empty items area leased to my adapter. I can say that after that's it items on. I can't pass the new areas, but in case it's not no, I'm going to say adapter. That said items as I'm going to pass my items. That's it for the first Asian Casca. Let's quickly creates the second facing tasking here husband. I'm explaining all of these very quickly because we have talked about all of these 1000 times. That's named response Search for items it needs to extend the racing task class for the import type. I'm going to receive a string roid for the progress on a realist off different items as the result. Steam backgrounds, Our famous try cash look after printing the snack trays. Let's return? No, I'm setting the result off this. A sink tests to I really stuff different items because I'm going to use the like. He worked in my SQL a statement so there can be multiple items that can have the similar name that the user has searched for. So for that reason, I'm putting I really stuff items for the result of these facing test. Okay, let's create our rescue like database in here. Devi is because to date of his helper, tough get readable database. Let's greet our cursor, give you the Q eri items table for the columns that's best know for the condition or selection that's passed name like a question mark after that for the selection argument. That's fast. Newest during airy Let's past strings with an index off zero. After that, let's past none for the group by having and sort order. If no is not a call to our cursor in the is case, I'm going to close my database and after that return, now that's a TV death. Close return? No, But in case if the cursor is not know that, say if cursor that moves to first in the else case once again was the cursor closed. The heavies. Let's create our released in here. I think I can copy some off the logic from here. Yes, I can. They can't copy all of these. I can even copied on post execute method from here as well. Let's copy all of this. Myth it and let's face it down below, in here. But before that, let's remove this one. Okay? That's our second facing test. We just need to call these two in the proper place before everything that's at both of them as member valuables. Right. But get all items on private search for items the proper place for executing. Get all items. A sink test is in sight that one creates dialogue. Let's do that. After setting takes pleasure for our edit text. I can't see Get all items is because you get all items. After that, I can execute it. I can say get all items that execute. We don't need to pass anything. And that's already to do on the proper police for executing the search for right. Amazing test is inside the intakes change off. This takes pressure off these Eddie takes. So here I can see search for item is he called the new search for item. It's very important that you instance sheet these facing tasks inside this one takes change method because every racing test is executed will only once. And if you instance, she ate this a sink that's outside of this method, for example, in here, whenever the text changes, we are going to connect to our database on. We are going to execute the racing tasking here. You will definitely get some exceptions, so make sure to instead initiate your racing past whenever you need it. For example, in this case, we are going to instance she ate it inside this context change method, So that's a sight, notes. Let's execute this method from here. Search for items that execute. I need to pass this charge sequence, but it's not going to accept about. I'm going to start to stream with. We just need to take care off the memory leaks that's over right on destroying method above in here, let's say if now is not recall to our get all items give all items is not canceled there can salute similarly for the other one for the sins for items. Okay, I think that's enough for this video. In the next video, we are going to test this subject item dialogue on also reveal finish our that shopping activity. See you in the next video. 14. Finish AddShopping Activity AddInvestment Activity: before we test our application, we need to call this story look. But even before that, we need to implement this interface in our at shopping activity. So lets you should have activity it first named shopping Activity. I've been here. I need to implements that interface. But of course I need to implement that method as well on getting item results before everything. Let's look this like him. I believe we are going to use this item in multiple places in this activity, so I'm going to save it as a member. Valuable. That's a private Tim. I'm going to name it Selected item on after that. Inside this method, I'm going to. Instead, she ate the selected items. I can't say selected item is equal to our. After saving the selected item, I'm going to change the visibility off my item relatively out. Too visible. So that's a item. Relative layoffs that said visibility on Let's say visitor. After that, I'm going to show the item image. For that, I can say good light that be we need to pass a context which I'm going to best this after that, stood as bit man the load like him that gets image yard after that came to our items image . Let's also set the name and description for our item has been I can say item name the edit text that said text to our rights and just get me similarly for our description. It takes description. That's a text through our items. Don't get description. That's it for this method. Let's call our dialogue from inside the unclear Glessner off this between pick items. But before that, I need to sit down on the witness stand for that. The 10 pick items, that's it on quickness, learning the on click listener. Let's create an instance off this elect item diver, new select items like. After that, I can say so that items I liked the show and they need to pass my fragment manager, which I'm going to pass, Get support pregnant manager and also we need to attack. That's a city Before we go further. Let's test our application and see if we can select any item. Let's try adding in your shopping. Let's open the shopping activity in here. Let's select this peak by Templeton. They have only one item in our recycler. Be right now and we are seeing the least off all the items inside this recycle of you before we search for that item. Let's try searching for that item. If I type bike, I should see that item. I can see that. That's perfect. Let's select this item on. As you can see, the visibility off this item relatively has been changed. We are seeing the name on also the image off that item. We should also see the description that is perfect. Okay, let's move on. Let's at unclear prisoner for this Between in here, I'm going to save between. Does it unclear glistening New York bleakness Now on, Let's do the job insight. Another method. Let's say he needs that. Let's quickly create that method down in here. But before that, let's minimize this in interviews. Method. First of all, we need to check that if r selected item is no or not. So let's say you know it's not. We got our selected I can First of all, let's right the ends case in that else case, I'm going to change the visibility off. Take Steve in the end, States, I'm going to change the visibility Mystics dividing too visible. And for the morning I'm going to say we select an item. After that, I'm going to make sure that the user enter some price for this item. So let's say if and it takes price, don't get text that to string is not be call to an empty string. First of all, let's right. The in this case, let's say please either, Price. Also, we need to make sure that the user enter something. So let's say if I take ST that get text to stream is not equal to an empty string in the else case, we are going to show another warning. Let's just say please select a date. But if all of these conditions are met, we are going to execute our racing test, and we are going to add this shopping to our database for the time being. Let's attitude in here. Okay, let's quickly right facing task down in here. I'm going to say private class. Let's name it at shopping. It needs to extend a sink passed on. We don't need any specific permitted. We are going to get the user idea inside the UN pre execute method of these class, so before everything. Let's right, the UN pre executing method. First of all, let's at some member variables bone for select in user. That's a private user like in user. I believe you also need price date on also the store in here as well. So let's save them private string days, private double price. We also are going to need to description. So let's receive that here inside, on pre execute after the Super Statement. First of all, I'm going to create an instance off my utilize class in order to get the look in user. Let's say in the year, your tails and for the context I'm going to pass shopping activity that this after that I'm going to say, Look, in user is equality. You feels that these users looking after that. Let's get all of the values for all of these views. I believe these un pre execute method is a good place to in Stan. She ate our database Hedberg class. As so let's create a member valuable off our database helper class up in here, let's say private data be self for the sake of yourself for Let's Dunstan. She ate it inside these on pre execute method. That's a they have. His helper is because two new date of December for the context. Once again, I'm going to pass shopping activity about this. Okay, let's move on to our duty background. That said, We need That's right, Cash block. Let's create an instance off our database. That's you. Like the movies TV. Is he called to date of a cell for that? Get right about the dummies. We are going to add this shopping in two different tables. First of all, we are going to add it in the transaction table. After that, when we get the transaction, I think we are going to add it to the shopping table as well. We also need to change. The remained amounts off the user's account in here as well. We are going to deduct the price off despite him from the remained amount off the user's account. But in order to add this item to the transaction table, first of all, we need to create a content values object that's funny transactions values. I'm going to put all of these values inside. This transaction values the amounts description user I d type date on recipient for the type I have added it manually. It's a shopping, so I have defined it as shopping. After that, I just need to insert this content. Values object into my transaction table, so let's on deck. That's a DVD insert for the table. Let's say transactions. Let's pass no for the no column hack. And also let's pass our transaction values. This insert method will return the idea off the newly added raw. So let's say that that's a long idee. Is equality dividend inside? We are going to need this idea. Let's create another content values for our shopping table as the I have put all of these into my shopping values, the item i d. The transaction idea, which is this idea that we just received in here. The user i d. The price description on also the date. Let's add these values into our database as well. I can't say db duck in, sir, for the table. Let's say shocking. No for the no column hack. And also let's pass our shopping venues. We don't need the idea of this shopping both for the debugging purposes. Let's dress receiving. I can't say long shopping. I d is equal to death. Statement on Let's like It after I think this, we need to change the remain amount off the user's account in here as well. But for that we need to first of all, get there remained amounts from the database. For that. I can create the cursor in here. That's a cursor is equal to tv dot curie for the table. I'm going to say users for the columns I'm just going to pass There remained Amount column for the selection. Let's say Look for the Rose, where the user idea is because to our use a righty. So let's see where the i d Z culture question mark and for the selection argument that's past our views are writing in the format of a street string. Does value off love in user dot Get idea. Let's on entering here so that we can see everything better after everything. I'm going to pass three nights for Group I having on sort order. Let's do the routine for our cursor. First of all, we need to check that if our cursor is no or not. In case it's not know, let's move the cursor to the first element on Let's save the remain amounts. That's a double remained amounts the support of person that gets double return to index off cursor that get column index renamed. After that, we need to create another contents values for updating this value inside our databases. Let's call this one amounts values I'm going to put on leave one value in here, and that's going to be This remained amount minus the price off this item. So let's say amount values that put remained amount as the key. And for the value that's a remained amount. Miners the price. After that, we need to update our database. I can say db that update for the table. That's a users. After that, we need to pass our amount values. After that. Maybe the selection and selection or human. Let's see ideas, culture, question mark. And after that, let's past our user idea. That's all we need to do just for debugging purposes. Let's receive their number of rows affected in here that Satan affective draws. Does he go to that statement on Let's look, let's also add an intern here. It's very important to close your cursor on database after you're done with them. So let's close our cursor after everything. I'm going to close the cursor, even if the cursor does not move to the first element in case we don't have any values for this user with this specific idea. So I'm going to say cursor closing here on. I'm going to close my database outside of this. If statement, we don't care if the person is not or not. We are going to close our data vase after every TV does close, we are almost done with our racing task. We just me to navigate the user to main activity after adding all of these to our database on the proper place for doing that is inside on post execute method in here. First of all, it's at the toast message in here. Let's say selected item that gets name plus at its success for me. After that, I'm America great and intense. Newington Shopping activity for the context spend main activity that class for the destination. We also need to add the flags intense. That's it flags. Let's say intense that new test on intense that clear start activity on its past. We just need to call this a sink passed from the part that we have added it to do. But even before that, let's at this facing test as a member valuable in order to prevent the memory leaks that's headed up in here. Drive it. That's shopping. And we need to instance she ate it inside the admit. It's very hard to do, let's say, at shopping, busy part in your out shopping. After that, you need to execute at shopping that execute. Let's overwrite on the story method as well. Let's say, if no is not before toe are disrupting gazing past. If our actual thing is not canceled, let's council Okay, I think we already to test our applications. So let's run the application. That's try adding a new shopping. First of all, let's select an item I'm going to select. Despite let's also set the price for this item. I'm going to say 3 15 after that, let's select the date I'm going to say Observer. 13. Let's see what else? Divinity. I think we should decrease the size of this image here as well. We will do that later on. Let's other storing here. Let's say well more on. Let's try adding our shopping. We have been navigated to our main activity on if you scroll down to the bottom in here, you can see these transactions. It means that has been added to our transaction table successfully. I don't like the fact that this transaction has been added to the end off my recycler view . And for that, I'm going to change the sort order off this transaction cycler view inside my main activity for that message to our main activity on let's open our get transactions facing test in here when we have created our cursor, we have to find this order in here. But it is by default ascending. I'm going to change that to descend. Let's try running our application once again on Let's see if you have to the extent successful as you can see this time, this new transaction has been added to the top off my recycler. That seems to be perfect. You can also see that topping here. The remaining amount off the user's account is some negative number, and that's because the previous remained amount in the user's account was zero and we have deducted $350. Okay, dispose the person's off, I think, and you shopping. I'm going to create another activity for adding a new investment That's quickly at that in here. But before that, let's close all of these classes on. Let's create another excuse in here, me or empty activity that's named despond at investment activity. First of all, let's work on the layout file. I have prepared a layout. Fine. It's really a simple file. I'm going to pay sitting here. As you can see, it's a bunch of text views on edit text on also some buttons. So in order to add different investments, we are receiving the investment name. We are receiving the initial amount of the investment we are receiving the monthly are or rate of interest. We are going to calculate this interest on. We are going to add a profit in our transaction table every month, so we are going to need this monthly, are I? After that, we are receiving two dates initial date and finish state later on. In our investment activity, we are going to calculate the expected profit from every investment, so we are going to need both of these states. After that, we have this at investment on after everything we have this warning stakes here, which its visibility is gone by the time. If you want, you can shake. That has been. You can see that it's just a simple takes view. I've you offload the source code at my website at Make with that organ slash courts if you want to check this exact quote, but it's really a simple layout for a bunch of relatively outs. Edit text on Also to excuse. Okay, let's initialize all of these insight that on investment activity job as you can see in order to save your time, I have initialized all of the items inside these units. Views method. You can see that it's really a simple Parsis, and I just wanted to save your time Before I finish off this video, I'm going to set on a click listener for this to button your between pig in its date on Alsop. 10. Pick finished it. So let's quickly create startling listeners for this, too. In order to open the date picker dialogue, I'm going to need to date set listeners in here as well. So let's greet me, creates those to listeners. Let's say private date speaker dialogue. The date set Usinor's for the 1st 1 That's a you need, states that listener is. He called the new date picker dialect that on dates that listener before everything, let's on the calendar up in here for the initial D. Let's say Private calendar. Let's name it in your calendar and let's instance she ate it in here like calendar dot get instance. They are going to need another calendar in here as well. Let's say private calendar finish calendar is equal to calendar that get instance. I believe we can happen some logics from inside the at shopping activity. So let's switch to that activity. Yes, we can copy all of these from here. That's pasty. Think here. But of course, we need to change the name of this calendar to you need calendar on. We also need to change this any text date, too, at the text in your state. Let's copy this whole listeners one more time on Let's at the finish date listening. Now that we have these two listeners, let's create the on click listener for these two buttons down in here. Inside on 38 method, I'm going to create another method on I'm going to name it set on the business. Let's say B TN peak anythings. That's it. Uncle Ignace, now New York League listener In here, I'm going to say you date speak our dialogue. We need the context in here, which I'm going to pass at investment activity like this. We need to listen there, which was named in its states listener. After that, we need to set the year, month and day off the month in here as well. For that, I can say in its calendar, thoughts get calendar that year similar for the month and also day off. That's it for the first button. Let's quickly at the other listener in your husband. I think I can copy these two line off course from you, but of course I need to change it. We need to change this unit date set listener to finish states that listener. And also really to change these need calendars to finish calendars. Okay, I think that's it for this video. In the next video, we are going to continue our work on this at investment activity. See you in the next video. 15. Add Investment Work Manager: Okay, let's continue on that's create and Uncle Nick, listener for thespian at Investment. I'm going to create that on Khalid Listener. Inside this set, Uncle Listeners Method, Let's say between at Investment that said, I'm quickly snack New York leaderless there in here for several. I'm going to check that if we have received all of the data from the user. So I can say if validates data I view creates that method in a minute. If validate date Isakov truth, then we need to change the visibility off. Txt. Warning to go on. Then I'm going to continue my coat. I'm going to create another method called Unit, adding I will create both of these methods in a minute. But in the else case, I'm going to change the visibility off. My morning takes too visible on. Also, I'm going to change the text off this txt warning to, let's say, please feel other lands. First of all, let's right. The validated data method. Its return time needs to be a 1,000,000,000 so we could check it inside to see if statement I'm going to say private building validate data. We don't need to receive anything. Let's say you edit takes name, not get fixed is that to strength does equals to an empty string, then return for us. It means that our name meditates is empty, similar for all the other edit tastes on After everything, if we have passed all of these cases, I'm going to return to. That's all I need to do inside this vital data method. That's right, the unit adding method That's a private void when it's standing. So the adding processes like this. First of all, I'm going to add any transaction into my database on I'm going to deduct the amount of this investment from the remained amount off the user's accounts. After that, I'm going to save the I D off that transaction on with help up that idea. I'm going to add a new investment inside my investments table, so I need to connect to my database two times in order to at the transaction. We need an facing test for the time being. Let's add two doing here. Let's say exactly, let's quickly right the racing past for adding the transaction. I'm going to say private class A transaction extends the racing past for the promise er First of all, I'm going to receive the users. I d for the progress. I don't need anything, but for the result, I'm going to say integer in here. This integer is going to be the i D. Off the new, the other transaction. Later on, we will use thes integer in orderto at the investment to our database before working, Understood in background. I'm going to override the UN pre execute method on. I'm going to receive the date, the name and also the amount off this investment. I'm going to need them in order to add a new transaction. So let's greatly receive them. Private. The string date on. Also name privates double Um uh, let's see this. That date is the coffee at it takes initial date. It takes not to similarly, for the name an amount. In order to create an instance of my database, I'm going to need the date of a self her class so that sprite it above in here. Private database helper. And also let's anistan shaded in sight the uncreative then here inside to be background method. First of all, I'm going to write a trite cash block after printing their stack trace. I need to return No. Inside the tribe. Look, let's see SP light database. That's funny. D V is equal to date of a cell for that gets write a bill database. After that, we need to create a content. Values are, let's, say, values that put for the amount. That's both argument. And similarly, for all the other data in our database for the recipient in here, I'm going to pass this name. This name is the name of our investment made be the bank or may be the real estate or stocks or whatever. I'm going to pass it as the receive that's also passed the date and use that put. They think we also need a description values that puts the spiritual for the description. I'm going to say initial amount for this exact investment with this name. So let's see, in your shell amount four. Plus the name lost the investment. We also need the user i d values that put user ivy on for the user idea. I'm going to pass my integers with an index off to you. There is one last thing that you need. That's the type of this transaction I can see values that put, Let's say time and for the tight. Let's past investment. That's double check our bakery sell for class inside the transaction table. We have this idea, which is auto generated. We have the amount they IAP user I D received and on disputed. We have added all of them into our contest winners. After that, I can say long I d is equal to TV that insert inside the transactions. Tebow No, for the no column hack on our values. After everything, we can return the integer value off this idea. Let's deal with the UN Post execute method. Before that, we need to remove these return on statement from here on its overwrite, our own course execute. First of all, we need to check that if our integer is not know in case it's not know we are going to execute the other erasing test for adding our investment. That's added to do for the time being in here. Let's say execute. That's quickly right? The other racing tasking here as the privates waas at the investments extends the Asian cast. We just need to receive the idea off this transaction on we don't need anything for the progress or the result of these A sink tests before working. Understand background method that received all the data from the edit tastes. That's a private means user i d. Personal. We are going to need that private stream. Initial date on Finished eight. We also need the name of this investment. After that, we have to. Dover's on for the monthly are Roy and the other one for the amount of this investment. Let's receive all of them inside the UN pre execute metal. All of the values are said. We just need the user idea. Let's quickly get there from the U teams class, but in order to get the user from the U teams class, but he probably needed as a member variable, let's say private, you tails your sales and also let's stand. She's about between uses. The cartoon using it is down here. Inside on creates acute method. You can say user use. There is a call to util start easier. Their luck in now is not people to our user. Then let's say thesis that user i d. Is, he called user start Get in the else case. That's past negative on for Use their ideas so it won't be no. Let's say this, that user i d. Busy cultural negative. That's it for the UN pre execute method. Let's continue inside the doing background with it in here for someone we need to check that if our user I d. Is because negative one or not, we are not going to do anything in the else case right after the if statement, it's going to return. No, But before that, let's instance sheet our database on Let's cash to steal exceptions. Let's say sq like State of Ace DVD is equal to date of a cell for that Get write a bill Data is after that, we need the content values for adding this investment. That's a values is important new contents, values and let's at all of the men's. That's a values that put we have the name that's earning and similarly, all the other rallies. I just added all of the values we have. The initial date. The finish states the amount the Mark Foley Arli user i d. On the transaction idea which we are receiving by these. Integers off this facing tests. Let's double check in our database. Helper class Insight. The investment table. We have this idea, which is auto generated. We have the amount monthly are named in state, finished a user I D. And transaction. We have added all of us after that. Let's say Long I d is equal to our database that insert inside the investment stable? No, on our friends. After I think this investment to our database, we are going to deduct the initial amount of this investment from the user's remained amount. But before we deduct any amount from the user's account, we are going to make sure that this investment has been added successfully to our database . This idea in here is going to be the I D off the nearly added investment in our database. But if for some reason we couldn't at this investment to our database, this idea is going to be negative on. If you want to make sure about that, I can provide you a link. It's about this deserve method, as you can see down in here in their returns, it says the royalty off the newly inserted row or negative one if an error occur, this is going to be the return off these insert method, so it's going to return negative on and we can use that. We can say, If I d is not he called to negative on, then we are going to deduct the amount from the user's account in here. First of all, we need to get the current remained amount off the user's account. For that, we need to create the cursory. Here is a call to date of a start security. We are going to carry the user stable. We are only interested in the remained amount. Call them. So let's pass Stack in here for the selection. That's a ideas you call to a question mark on for the selection argument that's passed in your string. Every which it's only value is going to be. Mr Ring does value off our user idea. We don't need anything for the group by having on sort order. So let's pass no for all trio of that, let's say if no is not because our care, sir, If cursor that moves to first in the else case, let's close our cursor. That's a double scarrans remained. Amount is he called the cursor that gets double with an index off person that get column index off remained amount color after that. Let's close our cursor on after that. Let's create a new content values on update our database. That's a new values. Is he part in your conscience? Value on Let's just pass the VON Value in this content values on. It's a new values that puts remained amount. And let's pass our current remains amount miners the amount of this investment. After that, let's say TV, that update firm inside the users table for the values. Let's pass our new values for the very close. Let's say, for the I D. Is a culture question mark on after that? Let's pass the user right. That's a string that value are our users. Let's also logged a number of affected rose for that, I can say means affected throws is a part of that statement on Let's Nugget after that's it for the doing background method. Let's just close our database before the cash statement. After everything I'm going to say, db dot clothes that's also over the on post execute on. I don't like about why I'm overrating this method so up to this point, we have added a new transaction for this investment. We have added this. The investment in our database on also we have deducted the amount of this investment from the user's remained amount. After that, we need to take care off the monthly profit off this investment. We are going to add a new transaction in our database every month, depending on the initial amount on the monthly. Our eye off this investment for I think that transaction every month we are going to need some sort of background task, and we have multiple options. First of those option is to use different services on bound or bound services. Bound services is not good for this particular purpose in here because we are going to add the perfect in our database even if the application is not open. So that's out of the question. On bound services are good for this purpose, but there has been a lot of restrictions upon them. You can no longer run different background tasks if your application is not in the foreground. There is a way to overcome those restrictions. For example, in here you can use a combination off on bound services broadcast receivers on alarm manager. With the help of these three, you can get around those restrictions, but that really complicates everything. And we don't want that kind of complication in our application. So we want you services in this application. The other option is to use job scheduler Job Scheduler is a great option. You can schedule different jobs, for example, for every month. But there is just one limitation with jobs schedulers on, that's it's only usable from April 11 21 on higher. The minimum AP high level for this application is 19. You can check that in your greater fine if you want in great dollars groups build that cradle module above. In here, you can see the minimum mystic. A version is 19 so we have level 19 and 20 not supported by job scheduler. The other option is to use Vork. Manager Bork Manager has been developed for this exact problem. It's compatible off to a Level 14 and we can use it in our project. So that's the perfect choice for background tasks in this application. With this exact purpose, let's quickly at the dependencies for work manager in our application for that Let's search for work manager dependencies. This link in here from the official 100 developers is probably are needed Link. If we a squirrel down, we can see the dependence is we don't need all of them. We just need the job of on. There also has been some versions released for cuddling for testing for our X travel to on this one in here has been added into the work manager dependencies in the latest version that's just copy to Jova and work version in our great Don't let's add it, evolving here before Jason. That's at that. And let's also delete this comment from here. Okay, let's sink our project now that we have added the work manager dependency. First of all, we need to create a class for our worker off. Let's quickly create that in our package. Let's name respond investment worker. It needs to extend the worker class this fund that comes from 100 extra for we need to override the do work message, and also we need to create our constructor. We are going to connect our database so we will need the database upper class. First of all, it's added as a member variable above. In here. That's a private date of a cell for database helper, for instance, creating two state of a self. We are going to need the context on. We have a context in here received in this construct. So we are sitting here you can say date of a cell for is the corpse of a new database helper. And we can pass our countries. That's it for the state of his helper that's jumped to do work method. Let's minimize this project pain for now in here first about I'm going to either look, But before that, let's have a look above in here. Don't say lucky. Oh, after that, I'm going to receive the inputs data. Later on, I will create a work request on I've you pass some data to it. That data will be passed to this do work method in order to get that data I can see they talked about that comes from Andrew Extra work. That's kind of data is the car to get imports data inside this data object, I'm going to put the values for adding a new transaction into my database. For that, I'm going to get all of those values. For example, that's a double amount physical to data that, yes, double the king here will be amount on the default value would be zero. Let's also get there, see pan description on use their idea in here as but just for the user idea, I'm going to pass negative on for its default value or, I think, a new transaction. We also needed a type as well, because this worker in here is going to be only usable for adding different profits. I'm going to add that type manually in here. I can't say it's drink. Time is equal to perfect. They just need the dating here in order to add this transaction to our database. For that, I'm going to get the current state or to a specific that dates that this do work method will be called for. That I can see Calendar is a call to calendar that get instance after that. I need to create a simple date format object that's calling SDF is because new simple date for meth, but it's Pathan. Let's best our previous pattern. After that, I can say it's drink. Date is the culture s the after format. Our calendar the good time. If you want to make sure you can check your day, have a cell for class for the transaction table. We have amount. They I use their idea recipient and description. They are receiving all of them inside this do pork method. Okay, Now we are ready to end this transaction to our database part because this video is getting a little bit long. I'm going to do that in the next video. See you in the next video. 16. Finish Creating AddInvestment Activity: okay, now that we have received all of these data inside this do work method, let's create a content value on Let's add that into our database. That's a content values. Values is equal to new content values on. After that, let's at all of these into our values. Object. After creating this content values object, we need to create an instance off our database. For that, we are going to need a try cash block in case something wrong happens on we reached this catch block. I'm going to return result that failure in here As you can see the return type off these to work method is some result. It has some flags. I can return result This fund that comes from 100 X that worked at listenable torture. That failure. We also need to return result that success In case our coat reaches to the end of this method, they can see the result. Don't success. Inside the tribal look, you can see rescued lights database. Let's call it TV. Is he call to update of a self care get writer Bill databases. After that, I can't say Devi does insert into our transactions table no, on values. Let's also save the idea of this transaction. We can see long I d is. He called to that statement. I have a toy going here after that. I need to check that if my idea is negative on or not. If I is not recall too negative on, then let's continue in here. I'm going to update the remained amount off the user's account on. I'm going to add this profit to that remained amount for that. First of all, I need to get the country mate amount. That's a cursor. Cursor is equal to DVD. Curie Curie in our user stable for the columns, Let's say new string area on that's passed. I remained amount called for the selection. Let's say ideas, culture, question Mark. I think I have a tight going here. Let's speak staff for the selection arguments. Let's pass in you string area on. Let's pass our user I d. String that value off user I D. That's also passed now for group by having and sort order after that, our usual routine for our curses, if no is not a call to our cursor. If cursor dot moves to first in case it does not. Let's close our curse there. I think I can copy some of the logic firm inside the at investment activity from here. I think I can copy all of these just after everything before the cash statement. We need to close our database. I can say TV that close. We are done with this investment worker class. We just need to change this user i d to user underscore 80. Let's closed these class and let's continue on from here inside this one post execute method off the at investment facing task we need to create our work request on We need to a schedule in here. I have two options. I can create a von time request. Andi. I can create a periodic request. You may think that because it's a repetitive work, we are going to need periodic working press. But that's not option that we are going to consider in here on. The reason for that is because periodic work request is going to a schedule a new work on a time basis, for example, every day or every month. But that's not exactly what we want in here. We want to add a new perfect into our transaction table for a number of months. For example, if it's a von your investment, we are going to add that profit for 12 months. Of course, you can create a back off criteria for your periodic work request, but that will complicate everything. Instead of that, we are going to create a Valentine work request. Multiple times for that reason, we need to calculate the different month is that we are going to add a new transaction into our table in order to do that. First of all, let's create an instance off our calendar. You will see why I'm in stash eating in your calendar. That's a calendar. Don't get instance. After that, I'm going to need a simple date format. Let's call It s the F is he called a new simple date format on Let's pass our person. After that, I'm going to get the initial and finish date for this investment. For that, I can say date. Let's say you need State is the call to let's say sdf the pars and let's pass our extreme. The string is going to call from in its state edit text. Let's say that get text that history. This part's method in here. He's going to throw some exceptions. Let's get the cash. That exception. It's a parts exception, so this vaguely are getting the initial date for our investment. After that, we need to set the time of our calendar to this initial date. I can say calendar don't set time. As you can see, the imports type is a date which I can pass. My need state. After that, I need to get the month off. This initial date for that, I can say in two months is is equal to calendar that get and I can't pass calendar dot month. We are going to change this one little bit parts. I will talk about that in a minute. After that, we need to get the finish date in here as well. That's eight days finish. State. Is he called to STF that pars, and we need to pass our edit text, finish state tough get, take, start to stream. After that, we need to change the time of our calendar. We can say calendar. That's the time on. We can pass our finish date similar to initial that we need to get the months is in here as well. That's a finish. Monster is he called Calendar that get calendar dot month. Let's also change. The name of this month is too in its month. This what's there is a potential problem in here. Imagine that you are, I think, a new investment in the month of October on the finish date for that investment that say is going to be the month of May. In that case, that initial month is for the month of October is going to be 10. Or, to be precise, it's going to be nine because the Martha's are going to start from zero on the finish. Martha's because it's the month of May is going to be four. In that case, if we deduct the initial months from the finish month, we are going to have a negative number. Or imagine in another case. Imagine if we are, I think, an investment for multiple years for two or three years. In that case, these calculation is not going to be precise. For that reason, I'm going to calculate the value off every year in here as well. Let me show you what I'm exactly talking about I can say calendar that yet let's say calendar dot year and I'm going to multiply it by 12. After that, I'm going to add it to their current month is this way. We are going to calculate the year on also the month. We also need to add this down in here for the finish state as well. So after all of these, I have the initial monsters and finish monsters in here. I can't say difference is equal to finish Martha's minus in its martyrs. This difference interfering here is going to be the number of times that we are going to is casual our work. For that, I'm going to create a four looking here. But before that I'm going to create another integer called Days on I'm going to. Instead, she ate it to zero. Later on, we will see why I'm creating these days. Let's create our four loop for into I Is it called zero Ali Liston difference and I plus plus. First of all, I'm going to add 32 these days in here. Once again, I will talk about in a minute. That's eight days plus equal 30. So when we create Avanti work request we can set on initial delay for our work on the initial delay is going to be the number of these days. For example, if I just added the investment, I'm going to add a new profit Von months later or to be precise 30 days later, Similarly, for two months from now, every time that I'm going to look, I'm going to add 30 days to these days integer I know that this 13 here is not accurate. Some months is our 31 days. But for the sake of simplicity, I have said 13 here. If you want, you can be more precise. You can create another method and calculated days for every month. But in here for the sake of simplicity, I have put 30. Okay, After that, I'm going to create my work request for that. I need three things. First level. I'm going to create a data object on Bill passed all the data for different transactions to that date. Object. Later on, we will receive that data inside the worker class. Second, we are going to create an instance off the constraints object. That constraints, as we talked before, is going to be the conditions that our work will be executed on. After everything we can create our work request object. So let's create all those three. First of all, I can say data. As you can see, there are multiple daytime here. Make sure to import of on that comes from 100 extra work. That's college data. Is he culture? New data, That builder. Inside this data, I'm going to pose for different values. First of all, it's on the amount. That's a foot double that's past amount on. After that, let's pass the actual amount, which is going to be the initial amount. Or I believe you have called its amount above. In here inside the UN pre execute. I'm talking about this one. That's a amount times monthly are Roy divided by 100 because it's going to be a percent number. So we are calculating the amount of perfect on. We are putting it inside the state object. After that, I'm going to put a description that's a description, and for its value, let's say profits for plus the name of our investment. After that, I'm going to put the user I d that say that puts into, let's say, user, I d. I'm not sure about these keys in the real world application. You probably would want to create different constants, but I have added them all over the application manually, and I have hard coded all of them. I will double check this use already. Let's pass our user idea after everything. We just need to put the recipient that's they put this drink but say you receive can't on for the recipient. I'm going to pass the name after everything. I just can't say that Built in order to build my data object, let's quickly check the worker class. Yes, the key was user right. Or, to be precise, the keying here is user. I'd be OK. Let's quickly create a constraint object. That's a constraints, the one that comes from Andrew Extra work. That's call it constraints. This one in here is not mandatory, and we are just going to do it because we don't want our application to drain the battery life similar to date on. That's a new CONST rents. That's wielder, and let's just pass born from strings. Let's say that said required battery not low on Let's pass through after that. Let's just say that beauty after everything, it's starting to create our work request. I can say Von time Borked request. That's call it request. Is he called to Newmont? I worked Request. That's bill there for this builder in here. We need to pass our worker class, which I'm going to pass an investment worker. That class after that lets it the initial data or let's say inputs data on Let's pass our data off. Let's also said the constraints. That's a sieve constants, and that's passing our constraints. After that, let's said initial delay that I was talking about, Let's say, said initial delay. Let's past days in here. Then after that, we need to pass a time unit, which I'm going to pass time. You need start days. That's it for our requests. We just need to build it. It's also useful to have attacked for different requests. Later on, we will see how it will be useful. Let's see that at the tank on, Let's pass attack, Let's say perfect after everything. Don't forget to in cure your request, you can increase by saying work manager don't get instance. It's a single tone we need to pass a context. Right now. It's deprecate ID. If you live it like this for the context, I'm going to say at investment activity that this after that I can say that thank you and I can pass my request That simple. Is that okay? That's it for our investment. A sink task. We just need to navigate the user to, Let's say, the main activity this will be the end points off adding our investment. Let's create the intent down in here for the context. Let's say at investment that for at investment activity that this for the destination, that's a main activity. That class that's also said different flags for this income as well. On Let's start our activity. Let's quickly execute are racing tasks from different places. But before that, let's minimize all the nest unnecessary codes. For now, I'm going to add both off the racing task as member valuables. That's a private no transaction that's quality transaction on. Similarly, for the at investment, the proper place for executing this transaction is going to be inside this innit, adding where we had to do let's say at transaction is equality in new transaction class. After that, let's say a transaction that execute. But if you remember in here, we need the user idea. Let's quickly get the user. I d lets a user user is. We call to you Thiel's that is user like mean. If no is not recall to our user, then let's execute are racing tasks on let's pass user that get fighting? We can safely remove this to do farm here on the proper police for executing and at investment is inside the UN Post. Execute off this transaction. A sink tests. I mean here he has it to do. Let's say at investment is because you knew at investment. After that, I can say at investment execute on. We need to pass the idea off the nearly either transaction, which we are receiving by the input of the's own post execute method that's past that integer on. We can remove these to do from here. Let's quickly override understory method down in here and let's take care off. The memory leaks off these two racing tests that say, if now is not the call to a transaction, if at transactions, that this cancer is not a call to true, then let's say a transaction cancer, and that's passed through similarly, for at investment facing tests. Okay, I think our application is ready to test, So let's group you test it. That's click on this floating action bottom. Let's click on this investment. I believe we haven't set on a league listener for these investment inside our Doyle. Look, that's greatly at that. I don't remember the name for that. I look. It should be at transaction. Do I look inside this investment I need to create in your intent? That's a new intense for the context. Let's pass. Get activity for the destination at investment activity. That class that's a start activity, and that's past our intern. That's run our application. Once again. Let's try it one more time. The investment, this time, the investment name. I'm going to say Bank of America, for the initial amount. Let's say Vontaze and dollar for the monthly are delighted. Let's see 0.3%. Let's also selected initial and finish dating here as well. There seems to be something wrong with this pick dates button in here. Let's go to check that. Let's see, Very have sitting on click Listener 40 speak initial dates button in here in new date speaker dialogue. We never showed our dialogue after everything. We just need to cause that. True. Similarly, for our between pick finished eight. We need to call, don't you? That's running for more time. Let's add a new investment Bank of America once again. This time, if we click on the spectate, we can see the dialogue. That's fine. Let's say initial date is going to be October 17 for the finish date. Let's save one year from now. Let's elect October 17 off 2020. That Senate Okay on Let's have our investment. It has been added successfully. As you can see, we are seeing the transaction in here. But there seems to be something wrong with this transaction adapter because it should be in red because, as you can see up in here, we have deducted the amount from the user's account. But it's in green. We have said the transaction adapters so that it changed the color to red and also this plus to a minus in case we deduct some amount from the user's account review, fix that in future videos. But the other things seems to be fine. The initial amount for Bank of America. This is the description. This is the date, and this is the transaction. I d. And also this is the name. Everything seems to be fine. Let's also check that if we have successfully a scheduled of work or not, I'm going to do that inside my main activity. It's like the UN create method. Let's quickly find that after everything, I'm going to other logging here. Let's say lucky work on in here. We are going to use that tank we have set for our work. We can say work manager that get instance we need to pass the context, which under active pasties. After that, let's say Get working for by Tank and we need to pass our tag. Which bus profit? Let's run the application months again. Let's check the look it Let's search for working here. As you can see, Von working here has been a scheduled, and as you can see, it's the status is impending. And the reason for the spending is because we have said the initial delay to one month from now or 30 days from now. I believe other works will be a scheduled one at a time when the 100 system finds the required resource is That seems to be perfect. Okay, I think that's enough for this video. In the next video, we are going to work on the investment activity and we are going to show different investments. See you in the next video. 17. Show Investments in InvestmentsActivity: okay, It's time to create our investment activity. That's quickly create that in our package. That's in your empty activity. That's name it. Investment activity. First of all, let's start working on its layout before that. Let's minimize the build pain from here. It's Lab is going to be really simple. It's going to have a recycle of U and also the bottom navigation view, which we can copy from. The main activity that's changed is constantly hour to a relatively out before everything that's at a recycling of you. Match Ban for the wits on rap Constant for the height. That's give it an I. D. Let's say investment. Rest of you That's also other margin button off. 50 dp This is going to be helpful when we create our bottom navigation view. Let's go to Main activity layout Fine on Let's copy are but navigation view. From there, I can copy this part of navigation view elements from here. I'm paste it down in here. Okay, let's initialize both of these insight out Java. I think you can copy that logic for initializing the bottom Navigation were from inside the main activity as well. Let's go there and in here we have in each person navigation view method. Let's copy that on. Let's face it, let's see what we have in here. First of all, we need to change this set selected item I d to our menu investment menu items, investment. After that, we need to remove this to do harm here on inside the home activity, because that's the only activity that we have. Right now, we are going to create a new intent on. We are going to navigate the user to main activity for the context that say, investment activity. And for the destination, that's a main activity. That class. We are going to need the flags in here as well. That's all we need to do in order to initialize our bottom navigation. You. We just need to call this method. Let's do that after the initializing off different views. Now it's the time to create on adapter for our recycle of you in order to do that. First of all, we need to create a layout file for every item inside our adaptive. Let's name this monthly slighting investment. This funding here is going to be a simple layout file and I have prepared to coat. And as you can see, it's a bunch of takes use. First of all, we have a card view. We have a relatively hours for all off the card for you. We have a linear layer for every investment information, for example, name in the shell date monthly are Roy. As you can see, there are a bunch of these linear layouts, and that's really we don't have anything, especially in here. So if you want to take a closer look, we are showing the name off the investment. Initial data off the investment monthly are Roy Investment amount total expected profit. We don't have this one in our database. We are going to calculate this perfect amount in a recycler view adapter on After everything, we have the finish date. Okay, let's create the adapter inside my adapters package. Let's say investment of that, I'm going to do the routine. First of all, we need to tag in here After that, you need to be a holder class public class, you holder extents. They recycle of you that you, holder. We need to construct er in here and let's initialize are your eye items inside thes your holder class. I'm going to skip the part that I initialize all of the u I items because it's a really simple persons. Now that we have the view holder class, let's extend that recycling view that adapter on its past. Have you called? We need to implement three methods in here. Before that, we need to create an AERIALLY stuff. Different investments. Let's say private are released off the investments. I think we don't have a modern for investments. Let's quickly create that in our mothers. Yes, we don't have any mother for investment. That's we could create that. According to our database effort class, we have an idea for every investment, Let's say private until your i d. On D. I have copied the rest of features for every investment. The user I d transaction I d. Name amount in a shell date. Finished eight on monthly. Are I? Let's quickly create to call instructors when we receive all on one we received No, after that, centers on getters. I believe we are going to need all of them on after everything that's also created to a string with it. That's it for our investment Mother that's create are realists off different investments in here. Let's quickly create on empty constructor in here. This construct ER is going to be helpful for avoiding knowledge. Winter exceptions inside to get I can count with it. Let's return. The signs off are released like before inside the uncreative you holder. Let's increase our view holder object on Let's return it. That's a view. Views equal to very active later, that's from are part of the kid context. Inflate our that play after the sighting. Investment parents on phones After everything, let's return New view Holder, which we need to class every object. That's it for this uncreative your holder method that's used to on buying your holder in here. Let's say Holder, that's name. That's a text to investments that get position The gets name. Similarly, for all the other features for the initial dates Finished eight amount on monthly or Roy After everything. We just need to calculate the total expected profit for that. Let's say holder, that profits. That's a text on Let's do the job in sight. Another method. The return type of that method is going to be a double value on in here we need to pass the string that valuable. Let's name that method. Get total perfect for that method. We need to pass our investments. That's quickly passed back in here. You can say investments that get on. We can pass our position. Let's quickly create this method down in here. That's a private double. Get yourself perfect. We need to get an investment in here. Let's get that. That's a calculating. Those are perfect for this investment for calculating total expected profit for every investment we need to get. The different month is that we are going to give some profit to the user. For that, we need to once again create an instance off the calendar object. That's a calendar that get instance after that. Let's create a simple date format object Is the culture news simple date formats on? We need to pass our path earning here. After that, we can save calendar. That's a time, and we can pass this the after cars on for the time we can pass our investment that get in its date. This partisan here, once again is going to throw some parts exception. That's greatly cash there. Like before. Let's get them month. From this candor we can say in its month is, is the call to calendar. Don't get once again because we can't have different years in here. First of all, I'm going to get the year times 12 for to have Masses in every year. Clause calendar. Don't get calendar dot month. This is the initial month is let's change the cannon their time through finished eight. That's a calendar. That's it. Time and let's pass is the f the part. Let's say investment that get finished. Eight. Let's get the Finnish Mosses in here. That's a paint finish. Martha's is he called Calendar that get calendar year times to our plus calendar doesn't get can in their Dutchman. After that, we can calculate the difference between this finish Martha's and in its models. Let's see into difference. Or let's say it's Martha's. That's a better me. Is it hard to finish Martha's miners in its mother's? After that, let's create a four loop for in Isaac off to zero less than Martha's I plus plus before our four Luke. Let's create a double. Let's say double profit, let's say, is equality 0.0 after that inside the for loop. That's a profit. Most people let's say investment that get insured amount or get amount times investment. Don't get monthly. EIroy divided by 100 This faith. We are adding the monthly profit for every month to this problem. If we change the location off this perfect to, let's say, outside of the try block evolving here, you can return it safely after the catch. A statement. Let's say a result. Profit. Okay, that's it. Forties. Get total perfect method. And I think that after Israeli, we just need to create a Southern method for our investment. A realist. Let's quickly do that. That's a safer investment on Notify. Data's had changed. Okay, let's reach back to our investment activity and in here. Let's create an instance off our adapter. Let's say private investment of Accer that's calling it after. And let's initialize it down in here. Let's say that after is equal to new investment adapter, we don't need to pass anything that's a recycle of you. Don't sit on that, sir, to our adapter and also recycling you don't sit on the outs. Manager to a newly nearly as manager. They need to pass a context, which I'm going to pass this After that, we need to connect to our database on get different investments from the database. For that, I need to create a nascent task down in here. But before that, let's minimize this any to use method. That's a private class. Let's name this fun. Get investment. It needs to extend the racing past class for the parameter in here, I'm going to say integer for the import. It's going to be the user I d void for the progress on a realist off different investments for the results. Let's create an instance off our database. Upper class above. In here. That's a private database helper that's naming database Otpor on. Let's instead initiate it down in here. Let's say Database Helper is he called the new Database Helper. And that's best this as the context Now down in here, we can insane shit our databases. That's a try. Catch the issue of exception. Let's bring the stack trace on. After that, let's return. No, let's say s you like database. DVD is equal to database helper dot get readable data ways. We don't need to write anything. After that. I can see the We got Curie from the investments table. We are going to need all of the column. So let's pass. No, All for different columns was for the selection. That's a for the user i d. Is he called to a question mark on Let's Pass their selection argument in the next line that same year. String area a string that Maddie off integers because index off zero after everything. That's fast enough for the group I am having. But for the sort or that, let's say, sort different values by the state in a descending manner. Let's also save the value of the security method into a cursor. That's a cursor cursor. Is he called to death statement after that? We need to check that if no is not a call to our cursor in the else case, let's close our database on Let's return. No, But in case it's not know, let's say if cursor that moves the first in the else case, we are going to return. No. But before that, we need to close our database on also Kerson. That's a cursor that close on D. V does colors, but in case the cursor does move to the first element. First of all, we need to create an released off different investments. That's quality. Investments is a bottom. You are released after that. We need to create a for loop for means, Isaac all 20 i Liston cursor that get count and I was Plus that's create an investment objecting here. Let's name it. Investment is a call to new investment. Here is the part that we are going to need the empty construct er. After that, I can say investment. That's it. Idea to occur, Served up. Get integer That's past care so that get column index for the idea. Similarly, for all the other features off different investments, they use their i d transaction I d amount finished eight in its state monthly. Are I and me? After creating our investment objects, we can say investments that at, and we can pass our investment. After that, we need to move our cursor to the next element. That's a cursor that moved to next. And after the four glue. We can't close our cursor. That's a person that close after that. Devi does close after that. Let's say return investments. Let's over. I don't post execute method before that. Let's remove this return non statement from here. That's a on post execute. That's check that if our area is no or not, in case it's no, we are going to set a new area leased for our adaptive Let's see adapter. Lots of investments to a new are easily stuff different investments. This line of code in here is not necessary, but we want our code to be more readable. Okay, in case it's not. No, I'm going to say and after, that's it. Investments on your passing, my investments. That's it for our racing task. We just need to call it Let's I did as a member. Valuable. That's a private Get investments, investments. Let's instance she ate it before calling. That's a get investments is equal to you. Get investments. After that, we need to get the look in user. Let's say you Thiel's is equal to new. You tails. You need to pass a context. After that, you can say use their user. Is he called to you till stud is user like in after that? We need to check that if no is not a call to our user let's say, get investments that execute. We need to pass our user, not get idea. Let's quickly override the understory method on Let's take care of these facing tasks. Memory leak. That's it for the investment activity. We just need to add the on click listener inside the main activities. Bottom navigation view in case they use their quicks on the item investment in it. Security intent in here Let's say intent. Is it often your intent for the context, that same in activity, that this for the destination? That's a investment activity the glass. We are going to need the flags in here as well. Let's start our activity. Let's run our application and see if everything works fine. Let's go to the investment activity in here. We can see von Investment, which we have added at the end of the previous video. You can see every information the monthly rise 3%. That amount is 1000. On the total. Expected profit is 36% which I believe is correct because this is a von your investment on . With 0.3% off the investment, it's going to be 3.6% and 3.6% of the 1000 is $36 seems to be perfect. But I kind of don't like the background color off this card viewing here, especially if we had multiple investments in here. That's greatly at another investment. And let's see what I'm talking about. That's name Despond Vanguard. It's a stockbroker investment, Let's say 500 this time with a 0.5 investment monthly. Are I? Let's speak some dates from October's extends to, Let's say, May off to town 2020. Let's say to any off me, I had the investment. It has been added successfully. You can see it in here. Let's wish to investment activity. This is what I'm talking about. We cannot differentiate between different investments. For that reason, I'm going to change the background color off different investments. For example, the 1st 1 is going to be green. The 2nd 1 is going to be blue, and the 3rd 1 is going to be green and so on and so forth. For that. Let's greatly at two colors inside our colors. Resource is, let's copy this green from here. The 1st 1 I'm going to name its lights green on the 2nd 1 That's a light blue. Let's change the value of these colors for the green one. I guess this is Ah, find color. You can add any color that you want, but I'm going to save with these colors. Okay, I think this is fine for the lights Blue Inside my investment adapt their I'm going to create a new member valuable on the Savoy. I'm creating this, Let's say private into your number on Let's instead initiated as negative. We are also going to need a context in here on. The reason for that is not going to be clear in a minute. Let's say private context context. We need to receive these contexts from the constructor. Okay, after that, inside the on buying view holder method. Wherever that is in here, I can check that if the number is called to negative one or not. So let's say if number is equal to negative on in case it is negative on, I'm going to say Holder, that's parent is the idea off that card view. Let's say that's if background color or said cart background color, and here is the place that that context is going to be useful. You can say context that get resource is that get color in order to get the two colors that we just define in our color. Resource is, I can say are that color That's, let's say light green. After that, I can say number is equal to one. We are changing the value off that number on in the In this case, I think we can copy this line from here. Well, it's We just need to change the color to, let's say, light blue. After that statement, we can say number is equal to negative one. So basically, we are flip flopping. We are changing the value of this number every time that this on bind beholder method is going to be caught on for every other investments, we are changing the color off the car to you. I believe if you're test application and see the difference, it will be much more clear. But before that, because we are receiving the context via the construct er in here, we need to pass this context inside our investment activity. Wherever we have initialized are adapted. I'm talking about this funding here, ready to pass the context. Let's run the application. Let's switch to investment activity. And as you can see, the colors have been changed beautifully. The 1st 1 is green. The second money's somehow light blue on. If we add 1/3 1 in here, it should be angry. That seems to be perfect. Okay, I think that's enough for this video. In the next video, we are going to start working on sending and receiving money. I'm talking about this funding here. See you in the next with you. 18. TransferActivity: As I said at the end of the previous video in this video, we are going to start working on transferring money. I mean, that sent or received button that we had in a transaction diver. So let's start working. First of all, I'm going to create a new activity and you empty activity. Let's call it transfer activity. First of all, let's start working on its layout, for I have prepared to lay out fine, and it's really a simple file. And as you can see in here, we are receiving some general information for, I think, a new transaction into our databases. We are receiving the amount they receive pants, the date description, and also you have a radio group in here, which will indicate if we want to receive or send some money. I'm sure you can create this layout, find by yourself, but if you need to check out the source, but I will upload the sore sport after this video on my site at make with that work slash boats, so make sure to check that we also have a takes the warning in here which its visibility is done. If I change it to visible. You can see that it's just the simple text. You The only difference in this layer fun from the previous layout funds is this radio group in here on its radio buttons. If you want, you can shake that in here We have a radio which has annoyed id'ing. Here. We have to read your buttons. One of them. It's check. The status is true. Okay, let's start working on the job of mine. First of all, I'm going to initialize all of those your elements before that. That's either luck, because it's really a simple process. I'm going to skip the part that you initialize out of the Euro elements we have for edit text in here Bon for receiving the amount on for description on for the recipient and also one for the date this received. Handing here is not a good name because if you want to receive some money from someone BRD recipient. But honestly, I didn't know what to name this one I received, and I mean the person on the other side of the transaction. If you can think of a better name, feel free to change this pond to whatever you want we have a takes the warning here for showing different warnings. We have a button pick dating here in which, by clicking on it, people showed that they speaker dialogue. We also have a between at NBC video at the transaction into our date of its We have a radio group in here as well. Okay, let's start working by sitting on a sleepless night for this beauty and pick date. I'm going to do that inside another method. That's a set on click listeners. Let's say between peak days, that's it on. Colleague Listener Me on ridiculous there in here before I show my date speaker there. Look, I need a date listener in here in which I can copy from my at investment activity I believe we have on there. I can copy this fun. We also you'll need a calendar. I do create that in a minute. That's a private calendar. Calendar is because the calendar don't get instance after that. Are the speaker and I lucked out? Undated Listener We need to change the name of this calendar to calendar on. Also, we need to change the name of our politics to meditate state. Now that we have the state listener. We can show our date picker. Darla. I think I can copy that from inside this at investment activity as well. From here, I'm going to copy all of these, but off course, I don't need to change the name off the calendar. And also the name of this context which is going to be transferred Activity. Not this. Let's change the name of these calendars. Make sure to show your don't like after creating it so that we don't get the previous error that we had. Okay, let's set on a league listener for this beauty and at above in here that saved between that's it, punk leaderless. There young Cleveland there like before. First of all, I'm going to validate that the user has entered all of the data that we need. So here I'm going to say, if validates data, we don't have this method you created in a minute. If that's true, I'm going to say txt warning. That's it. Visibility. Let's take on on after that. Let's say you need you create this method as well. In the else case, I'm going to change the visibility of this txt warning to, let's say, visible on after that. Let's change it sticks. That's a txt warning. That said, text two. Police feel our little errands. First of all, let's create the validates data method that's created down in here. Its return type needs to be Boudia. Let's say if any takes amounts that give text that to stream is equal to an empty string. Let's return false. Similarly for the receive hand on the date, I'm not going to force the user to add a description. I'm going to give that as an option to the user. So let's right the case for the receive plan on for the date after everything just returned through. That's it for this method that's minimized this fun and also the any two years method. Okay, let's quickly create that, innit? Adding method in here. First of all, I'm good instead, in shape by utilize glass is equal to you know you tails because I'm going to get the user after that. The user ID's that's a user user is the culture you teens that is user liking. After that, let's check that you are user is null or not, in case it's not know we are going to connect our database on at this transaction. For that, we need to create another racing task. But for now, let's attitude you in here. Let's quickly create Are racing past? That's a private glass. Let's name it, pat transaction. It needs to extend the racing past class or the parameter that's received the user i D. And we don't need anything for the progress on the result of this method doing background. But before working on that, I'm going to override the own pre execute method on I'm going to receive all of the daytime here. That's a private double amount. Private string Chrissy Pan The description on Also, I'm going to define the type of string in here as well. Depending on the radio button that is selected, I'm going to change this type to send or receive. That's nothing especial in here. Okay, let's initialize on off these. Let's say this. That amount is equal to double that's value off our amount. Edit text stuff. Get text stuff to string. Similarly, for the daytime disputes in and also the received for the typing here, I'm going to set on unchecked changed listener on the radio group from here. That's a radio group type that said on Chek Change Listener that saying You're unchecked changed listener. Let's create issued a statement on the I. Basically, I was going to be the I d off that radio button. Let's say in case it's part of idea that's beat and received. Let's change the type two that's a received. After that, let's add a bridge. I think it's better to not to capitalize any letter in here, So let's say it's far. But in case it's are that I d that button send. First of all, I'm going to change the value of type two. Let's say sand on. After that. I'm going to make the value of this amounting here. Negative because we are going to deduct firm. The users remained amount. Let's say amount is equal to negative amount. Let's add our break on default case. That's it for the UN pre execute method. Let's start working on doing background. Let's create outright catch block cash askew of exceptions. Let's say the that Prince stack trace after that issue, like database TV is equal to We need the date of a semper in here and I believe it's the only place that we are going to need it. So let's instead initiated above in here, let's say privates. Database helper. That's name is date Every summer on Lives in Stash eight inside on three. Execute method they have a cell for is equal to a new database helper. And for the context, let's fast transfer activity. Thought this. Okay, let's move on that. Say they have a cell for Does get Write a bill databases. We are going to add a new transaction into our transaction table, so we are going to need a new content values that scene you contents values. After that, you need to put all of these values in here into that content values. You can say values that foot, let's say amount and expressed the starts amount. Similarly for all the others, we have the received and state type description user. I make sure to check your database upper class so that you at all of these into your value content values are. After that, it's time to insert it into our database. That's a long I D. Is equal to the we got insert. Let's take into our transaction stable. You don't need anything for the null column. Hack on. Let's pass our values. Let's lock the value of this, I D. That's a new transaction I D. Most are. After that. We're going to check that if our ideas not recall to negative long, let's continue on by Continue on me. You are going to change the remained amount off the user's account. If this is sending some money, we are going to deduct from the user's account on If this is a receiving transfer, we are going to add to the users. Remain amount. So first of all, we need to get the current remained amount off the user's account. Let's say cursor is equal to tv dot curie. I believe the hot this logic somber inside the investment work here. Manager. So let's go there and talk to some of the court. Yes, we have everything here. You can copy all of these firms, but instead of user I D in here. I'm going to fast integers with an index off zero. We have a user I d in here as a so basically we are getting the current remained amount. As you can see, we have the stubble in here. After that, you're closing our cursor. We are creating a new content values on. We are putting and you remained amounting here. The only difference in here from the investment worker manager is that we need to change this negative to applause. We are going to add this amount to the current remained amount. If you remember in here above inside on pre execute method in case it's ascending transfer , we are making the value of this amount to a negative value on its receiving some money. We are not changing to Emma, so in here we can safely ad this amount to the current remained amount. If it's sending money, it will be deducted. If it's receiving money, it will be added to the remaining amount. After that, we are just updating our database. We are updating the user stable. We just need to make sure to close our cursor and databases in the proper place. First of all, let's see what else cases in case the cursor doesn't move to the first element, we are going to close our cursor. After that, we need to close our data ways also in case it does move to the first element. We are closing the curson in here. We also need to close our database after updating the users table. You can say TV that close. Let's check out of the statements in case the cursor is no in the else case. You know that we can't close our fair, sir, because we don't have any car, sir, you just need to close our databases on. Also in case the transaction idea is negative one. We need to close our database as well. That's a TV that most that's it for our doing background method. So let's review its personnel will be we are adding in your transaction. After that, we are making sure that we have added transactions into our database successfully. After that, we are getting the current remain amount on. We are, I think, or deducting the amount in here on. We are updating the users remained amount. We are closing our cursor and database at proper places on it's time to override the on post execute method inside on post execute. I'm not going to do anything especial. I'm just going to navigate the user to the main activity. That's a intent Is the culture new intent? That's a transfer activity that this on main activity, that class. After that, we need to set different flags. That's a intense thoughts. New task on intense dot clear tasks Let's start directive. That's it for our racing task. We just need to execute it from where we had to do. That's minimize the whole lacing test. And in order to avoid memory leaks, I'm going to define it as a member valuable above in here. Mezei Private at Transaction A transaction. I am very instant shooting inside these minute having method, Let's say at transaction busy quoting the your transaction. After that, we to say transaction to execute on the next pass user dot Get idea that's overwrite the understory method down in here That safe no, is not the fault a transaction. If that transaction is not canceled, then that's cancer. We are done with this transfer activity. We just need to define and likely Glessner Force and then received button inside the transaction. That's good to do that in here inside the transaction to create on intent but seeing urine test get activity as the context on also transfer activity that class as the destination. Let's start our activity. It's time to test our education. So let's run it. Let's see if we can add a new transfer, send and receive. But in in here for the amount, let's say $70 for the recipient. Let's say, if you live I think I have made a mistake when I have created the layout find because the import type seems to be on the decimal number, that's quickly changed. That that's fully conscious, received and read the text. And, yes, the import typing here is number. The symbol. Let's also check the date on description. Yes, for the day date, we have the info type number this Emma for the description. No, it's right. Okay, let's run it. Once again, let's see if we can add a transfer this time. Send and receive $70. She was, If let's say, Let's speak a date. Uh, let's say, looks over a few things for the spirit shin that say the money on Let's save it. Receiving this case, that's at the transfer. Let's check in here. Guess the transaction has been added successfully. Let's add another one and let's try sending this time let's say $100 for the received. And this time, let's say, Jerry, that's speaking days on that same 19 of October. We don't need any descriptions, so let's click on Descend on. Let's add The transfer on the transaction has been added successful in here, but there seems to be something going because this is a plus 100. I'm not sure if you have deducted or added 100 from here. So that speaking at another one, let's say, send and receive $50 this time for the recipient. That's a Tom that speaking date 17th of October. We don't need any description that's try. Sending the number was negative 16 80. So if you add the transfer, it seems like the $50 has been added to this number. And there seems to be something wrong with our coat that's used to transfer activity on. Let's look the value of this amount before adding to our transaction. That same buck D let's say amount lost. This that amount. Let's open the market on bets. Run our replication. Waas again. Let's try, I think, and you transfer 150 time. They no description. Try sending before that. Let's clear the look at on. Let's add the transfer. Let's search for amounting here. From inside doing background, the amount is 150 feet. A positive value because we are sending money. This number in here should be a negative number. We need to fix this. Okay. We will fix this air in the next video. See you in the next video. 19. Debug TransferActivity AddLoan Activity: we had a problem be transferring money on. The problem was when we sent some money, the money would be added to the users. Remained amount on also inside the transaction that after you can see that we have a plus sign in here, it means that the money has been added. It should be deducted when we send some money on. The problem is inside are facing test inside transfer activity. Let's take a look at that. Inside this transaction racing test, we have the finest set unchecked change listener for this radio. This is nothing good place for something and completely snare for all radio. Go because this aging test is going to be executed. Ven ve click on the button on unless we don't click on that button. We don't have any sent or received, but we can do Is to move this listener to, let's say, inside on create method. But there is a better option in here. You can say radio button I D. Is equal to a radio that get checked. Radio button idea on. After that, we can create our suitor statement depending on this radio button idea. That's copies from here you need to change this I two radio button idea. Now that we have this logic in here, we can safely remove our radio group that set on Chek Change listening. Let's test our application and see if this solved our problem. Let's try, I think when you transfer Sam piracy for the amount, let's say 250 home. That's speaking date. You don't need a description that's try sending the money this time. As you can see, the amount has been deducted from the user's account on. Also, as you can see inside the transaction at after we are seeing the number as a red number, it means that we have deducted the number successfully. Also, we have an extra minus in here, and that's because inside transaction adapter, we have added this minus manually, you can safely remove. But now that we have removed this minor, spin it to cast this amount to a stream, you can say string that value off that amount. That's run our application once again. This time, as you can see, the extra minus has been removed. Also, if you remember, we had a problem with our transaction. A doctor in here let me show you the problem, Ben. We added a new investment or in your shopping, let's try shopping, for example. Let's say $100 for despite that's selected date and also store. Let's add this bike. If you scroll down, you can see this transaction in here on its positive in here we have deducted the amount from the user's remained amount. It was 15 30. It's now 16 30. It has been deducted successfully both in here inside transaction that actually we are seeing it as a positive number that's quickly fixed this as well. Inside the at shopping activity when we have added shopping as a transaction to our transaction table, we need to change the value off this price to negative value inside, at shopping a sink fast. When we have initialized our price, we can simply put a miner's in here. We had a similar problem when we have added a new investment. If you remember when we were adding any investment first, I will be added as a transaction. After that, we have deducted the amount from the user's account on after everything we have added this investment into investment table, being it to add a negative, like in here inside the at investment activity as well. Let's go to that activity on, uh, let's find a transaction racing past in here when we have initialized the amounts, we just need to add a negative signing here. Let's try running our application. Once again, let's add a new shopping that's a shopping and you bike that saved $150. This time, let's pick a date. That's the finding. You starting here, let's say eBay on Let's antes shopping to our transaction adapting. As you can see this time, it has been added within negative side. That seems to be perfect. Okay, let's move on from all of these. Next, I'm going to start working on this loan option in here. We are going to add a new long, and after that, we are going to show those loans inside the loan activity. For that, let's quickly create another activity. But before that, let's close all of these that's creating the activity. Empty activity, that's name respond at lone activity. First of all, let's start working on the layout file. I have reportedly outfight, and this is something like this, I think alone is a lot like, I think, a new investment. First of all, we have the loan name. We have initial amounts we have monthly our toys. There is one key difference in here, and that's this monthly payment. We are going to give the users the option to add the amounts that he or she is going to pay monthly. After that, we had initially on also finished. I will upload the source code at make, but that organ slash boards, in case you want to check the source with but it's really a simple layout file, a bunch of takes views Eddie takes on buttons. Okay, let's quickly initialized all of these in our job. Initializing your eye elements is a really simple process, so I have escaped that part. So in here we have an edit takes name and it takes initial amount, edit, text are, or rate of interest that it takes initial date and it takes finish state and it takes monthly payment. After that, we have two buttons. We can pick initial date, but in peak finish, take on button at law. After everything we have to stick Stephen Barton. As you can see, I think alone is a lot like adding any investment, so you can copy a lot from at investment activity. Let's quickly copy the dates at this, nor for these two buttons in here. Let's go to add investment activity. First of all, let's copy these two calendar from here. After that, let's copy the date set prisoners. That's quickly set on Arkalyk Listener for these two buttons. I'm going to do that inside another method. That's a set on colleague listeners. I think I can copy the unclean listeners from inside at investment activity as well. I need to copy these two firm here. We just need to change the context. Let's say, at lone activities, let's sit on one click listener for beauty and that's a became Adlan. That said Unclip Desler York leaderless There let's copy data logic from inside at investment activity as well. We have it in here adjusting to create these two methods, but the data on any addict we can coffee the value the data from inside that investment activity as well. Let's minimize all of these extra methods and classes. Let's coffee, Hispanic Day taking, Of course, we will need to change it a little bit. One change is going to be edit. Takes monthly payment. Should that be empty as well? Let's say you and it takes monthly payments that get takes that to string. If it's equality, an empty string, then let's return falls. That's it for this method. That's right, that unit hiding method that's a private void in it, adding In here. First of all, let's get the logged in user. I believe we are going to use you. Tim's in multiple places live, so let's add it as a member. Variables. That's a private Eugene's your themes. Let's initialize it inside the on create method utilizes department Knew your tails That's past the context. Then here, inside adding method. That's a user newser is. We call to you tills that is user. After that, let's take that diffuser is now or not. In case it's not know we are going to add this loan as a transaction in our transaction table. For the time being, that's had to do on Let's quickly rise that facing test that's a private class. That transaction it needs to extend 18 task for the input under, say integer. It's going to be the user I d avoid for the progress on integer for the results. Before working on this A sink task. Let me talk you about the process off adding a new law first level. We are going to add this loan as a new transaction in our transaction in a table. After that, we are going to increase. The users remained amount. We are going to add the initial amount of this loan. After that. It's the time to add this loan into loans table. And after everything, we are going to create a worker manager in order to deduct the monthly payment from the user's amount every month. That was the process off adding a new loan, and this interim here is going to be transaction I d. They try, and we are going to need it inside the at Learned a sink test. Okay, let's start working. But before working on this dream background, I'm going to overwrite on pre execute method on initialize the date, the name and also the amount of this look. That's a private double amount on also private stream date on me. Let's initialize them inside on three. Execute. Let's say this that amount is going to be double. That's value off our initial amount of the textbook. Get text Dr ST Similarly, for the data on me, you are doing background method. First of all, we are going to instead she our database. But in order to do that, we are going to need a database helper object. So that's creepy at that. As a member of valuables, that's a private database suffer date of his helper on Let's initialize it. After initializing our views, they have a cell for you. Date of a cell for Jane to pass a context inside the doing background method. Let's instance she ate our bakeries after printing this factory's Let's Return. Let's say sq like state of a Stevie is because to date of a cell for that get right about database. After that, we need to create our content. Values are, let's put the values for adding a new transaction. That's a values that put can say amount, and it's fast our amount. Similarly, for all the other features, they're a sea Panther date user idea, which we are receiving by the input of this method. Also that for the description I have prepared this text received amount for this long and also for the type of this transaction I have said Law. Okay, we are ready to add this transaction into our database. That's a transaction I d is equal to divvy that insert that's past transaction as the table No, on our phones. That's it for this method adjusting to close our database and after that, returned the transaction 90. But this transaction I d needs to be casted in time. Integer Now that we have take care off the return the statement in both of these conditions , we don't need this return now. From here, we can safely remove. That's all right, the own post executed. First of all, let's trick that if no is not goingto our integer. If it's not, we are going to execute the Athlone facing test that's created to doing here on that same execute that's quickly and write the other basic task in here. That's a private last, uh, low extends facing task. That's a integer for the input. It's going to be the transaction Ivy avoid for the progress on integer for the result. This integer is going to be the loan idea later on, we are going to need it inside our worker manager Les once again before working on the doing background. Let's overwrite the UN pre execute method on Let's take care of the initializing off all of the values. First of all, we are going to need the user i d. That's a private use their i D. And also we need the name initial date finish state initial amount monthly are Roy and monthly payment. Let's initialize all of the's inside on pre execute method. They have done this initializing 1000 times, so I'm going to pace the coding here. Basically, we are getting the values from the other texts just for the user i DVR getting logged in user from the utilize class in case the user is now, we are setting the value off the user, writing too negative nature on inside the doing background. First thing, nothing to check is the user i d. Let's say if user ID's lefty called negative blood, let's continue with our coast. That's instance she our database also in case the user i d is negative on, we are going to return. No, you can return negative warning here as well, but I'm more comfortable, but no. Okay, lets say yes, unites database TV is equal to date of a self heard that gets right level data ways. After that, we need to create our content values option. Let's say values that goods that's past the name off this loan on expressively, let's check the date of a cell for class on. Let's see what to be needed here. Insight the long table. First of all, this idea is auto interment, so we don't need to be worried about that. You have initial date. We have finished eight. We have initial amounts. Take care of the spelling in here. We have also this remained amount inside the lone table as we didn't have this one inside the investment table. So basically, whenever we are deducting this monthly payment from the loan, we are going to deduct it from this number in here. After that, we have the monthly payment. We have two monthly or Roy. We have the name and also use already. Also, I think it's better to have the transaction idea in here as well. Like inside the investment table. We had this transaction. I d I believe if we added in here, it will be useful. Somber. That's a transaction I d. Integer. But now that we have changed the structure of our databases, we are going to need uninstalled application on instead, it once again okay, lets all of these values into our content values order. Once again, I'm going to taste all of the values we have. The initial date finish state initial amount and for the remained amount for the time being , I'm going to set it to initial amount because at the time of getting this loan, the initial amount Andi remained amount should be called the Monthly. Are I monthly payment user I d. On the transaction idea which we are receiving by the input of this method. After everything, we are ready to insert it into our database. That's a long, lone i. D. This is a culture TV that insert inside the lows table No, on our wells. Now that we have inserted this loan into our database, we need to change the remain amount off the user's account for So let's check that if no idea is equal to negative on or not, in case it is first of all, let's close our database. And after that, let's return. No, but in case it's not, we are going to create the cursor. That's a cursor. Is the call to duty that Curie inside the loan? Staver. We need to create a cursor in here. That's a cursor. Cursor is the call to tv dot curie inside the user stable. We are only interested in the remains amount for them. So let's say you're a string A On its past remained amount for the selection. Let's say ideas. He called her a question mark on for the selection argument. Let's past year string area where it's only value is going to be to strain that value off our user writing. That's past love for the group by having on also the sort order, if now is not because our cursor, in case it is, let's close Ardika vase. Give me that close and returned now, in case it's not if cursor that moves to first in case it does not. Let's close our cursor after that. Let's close our database on after everything that's returned Now, in case it does move to the first element, let's say of a current remade amount is, he called the cursor that gets double care. Sir. Don't get column index remained amount after that. We need to create a new content values that saying your values was a part of new content values. That's a new values that put remained amount on its past card in three main amount, plus the amount of this loan or initial amount of this loan. After that, we can say TV that updates. That's update the user stable. After that, that's past our new values. After that, for the work was, Let's see where ideas. He called her a question mark for the selection argument. Let's in us during a very string. Does value off our user, i d. After that, you can say few clothes are cursor and also our database on. We can simply return the long idea, but loan idea is along. We need to cast it to an integer that's quickly all right, on post execute method as But before that, let's move removed this return off. Let's say if no is not, people toe are integers and here is the place that we need to thank you are work request on the work is going to deduct the monthly payment from the user's account every month. So first of all, we need to calculate the number of months for that. That's a calendar is we call to calendar docket Instance. Simple date format. That's a SDF is the culture new simple date format. We have done all of these for the investment, so I'm not going to explain them in here. Let's pass our pattern. After that, let's say date in in ST is equal to Ste. After ours. Let's past these stuff in it, state. But of course, this partisan here is going to throw some exception. That's canister. After that, I can say calendar that set time. Let's past our interstate after that. Like before I can say in its month is, is he called to Calendar that yet that's a Canada that year. Times 12. We have done all of this before, plus Calendar that get Canada dot Mom. You needed to the same thing for the finish date as the that's safe date. Interstates is equal to STF that heart. Let's past this that finished. After that. It's a calendar the same time on its past are finished after that, let's say finish Martha's is the call to calendar. I think I can coffee. It's on here. Okay? After everything that's calculate the Martha's, let's say month this is equal to finish month as minors in its months. Okay, I think that's enough for this video. In the next video, we are going to write the word manager class, and we are going to create our work requests in here senior in the next video. 20. Show Loans in LoanActivity: at the end of the previous video, we have reached to the point that we have the number of months that we need to deduct the monthly payment from the user's account. Let's continue on from here. First of all, I'm going to create a four do 14. I easy call to zero. I'd list a number of months on I Plus Plus, like before, we are going to need an integer called Days. If you don't remember, it's giving clear in a minute. First thing inside this form do I need to increase the number of days by 30. That's a plus for 30. This is going to be the initial delay for every board request. After that, we need to create our data object of on that comes from and with extra work. That's a data. Is the cultural new data that feel there on? Let's put our values into this data object. First of all, I'm going to put the idea of this loan. So let's say that put into that's a long idea on Let's pass our interview. If you don't remember, we are receiving this interview by the input of thes on post execute method this is going to be the loan i d. Later on, we are going to use it inside the worker manager clasp, even see how exactly you're going to use it. After that. Let's put the user I d. That's safer, user I d on. Let's pass our user. I see which is a member valuable off this racing tasks. Also, let's pass the monthly payment, which is going to be a double. Let's a monthly payment and let's pass our monthly payments after everything. Let's also pass the name of this along. This is going to be the description into our transaction table. Let's say that with this drink name for the key and name for the value after everything, we just need to call that build method. Let's also create constraints. Object is the call to new constraints that well there we are going to define only one constraint that say that said required battery not low under city. True after everything. Once again, that's called a tribute method. After creating this construct, er, it's time to create a voluntary work requesting here. But for its builder, we are going to need our worker class, so let's quickly create that. But before that, let me close all of these into our project into our package. That's creating you. Djelic less that's named respond Loan Border. It needs to extend the worker class, the one that comes from Andrew X. That work they need to construct er in here on. Also, we need to do work myth inside the constructor. First of all, let's substantiate our database. Elbert Plus, But before that, let's look off in here. That safe private database helper that's name date of his helper. After the Super statement off this construct, er, that's a state of itself. There is the CO two new They have a supper, and let's pass the context as its context. I believe we are not going to meet this return now, so let's delete it. First of all, let's get our data. That's a they thought was because to get input data, it's also worth noticing that this data is never know, so we don't need to check for its no values after that. Let's receive all of these four values that we have put inside this data. Okay, inside out, working last because say means no, I D. Is he called day tough that get integer. That's best known. Ideas are key. We also need a defense value that's a negative. Similarly, for the user, i d. We also need their monthly payment. That's a monthly payment. Is he cultures? Data that gets double. Let's past monthly payment on Let's Pass zero for its default bedding. Also, we had the name That's a string name is equal to data that get extreme candidates. Best Army. First of all, I'm going to check for all of these different values. I'm going to say No, no, I d is default negative on or if use their i d Is equality negative on? Or if the monthly payment is because 0.0 in case each one of these happens, I'm going to return results. That's failure, this tagging here. If you pass these checkpoints, we are ready to create our data bits that minimize this project pain. For now, let's create our try cash flows in case an exception happens on Great Pretender stacked race, and after that, that's return result of stay here muscle. That's a issue like database deviously called database helper that get right above database . So the processing here is like this. First of all, we are going to add a transaction into our data. Ways on the amount of the transaction is going to be equal to this monthly payment. After that, we are going to deduct this monthly payment from the user's remained amount. After that, we are going to deduct this monthly payment from inside the loan stable. If you remember from inside the date of a separate class inside this loan stable, we had a remained amount column in here as we are going to deduct the monthly payment from this one as well. So we need to connect our database three times. First of all, that's at the transaction. That's a content values transaction. Values is he called the new content and used for the amount of it's a transaction values that put that's past amount and for the amount I'm going to pass negative monthly payment. We are passing this negative in order to avoid that problem that we had with the transaction adapted. Okay, lets past all of the other feuds. As you can see for the type I have passed known payment, nothing especial just a simple text for the description I have created. This takes with the help of the name of this transaction or the name of this loan on for the received. And I have passed the name as well. Okay, lets say long transaction I d. Is a call to give me that insert. Let's say transactions. TVA No, our transaction by this we also need to pass date in here as But if you want to make sure once again you can check the database Upper West inside the transaction table. We have these amounts. We have passed it. We have passed all the others. I user, I d receive camp and description adjusting to pass this day in order to get the dates once again, I can see can under Canada is equal to calendar, not get instance after that. It's a simple date for matter. Miss the F is because when you simple day format, we need to pass our other than here. After that, I can say it's drink. Date is equality s. They have thought format that's past calendar don't get after getting the date. That's a transaction values that puts date on state Now that we have to transaction values . We can add it to our data. Please. Let's say long transaction I D. Is equal to divvy that insert transactions table. No transaction business. Let's check that If this transaction idea is negative on or not transaction I D. Is equal to negative one. In case it is, we are going to return results that failure. But in case it's not, let's deduct the monthly payment from users. Remained amount. But before that, I think I have a toy point here that speaks that. First of all, let's get the current remained amount because I have done this process a few times. I'm going to pass forward the process of writing like before. First someone we are creating our cursor. You're checking that If Corsair is not know if it is, we are closing our database, and after that returning result that failure, in case it's not know we're checking that. If course it does move to the first element. If it doesn't, we are going to close our cursor and database on after that. Once again, you're returning results as failure, but in case it does move to the first element we are getting, the current remained amount. After that, we are creating this content produce on. We are only adding bond value to this values with the key off remained amount, and for the value we are deducting, the monthly payment from the current remained amount. After that, we're updating our database. Nothing is special in here. After doing this, we need to update their remained amount from the loan stable as well. For that, once again, I need to create another cursor that's namely small second Kerson, Let's say, db dot curie on our lawn stable, we are only interested in Bonn Qala on That's the remained amount, calling for the selection that say ideas, quarter question more. And here is the part that that lonely is going to be useful. That's a new string I on. Let's pass a string that value off our lawn, hoity for the group. By having and sort order that's personal. I'm going to do the ritual for every cursor once again, so I'm going to pass forward anything. Once again, we are closing our person in every step that is needed also for the database. In case something wrong happens, we are returning results out failure. We are creating a new content value object on. We are updating the remained amount off the loan inside the loan stable. We just need to close our second cursor on also the database in here. That's a TV that close on after everything. Let's return Result of success. I think everything you set adjusted to close our first cursor in here as well. I have forgot to do that after updating the database after updating the user stable, we need to close our person. Okay, that's it for the scorecard class. We have take care of everything. Let's reach back to add loan activity and let's write our work rivers. That's a one time worked request. That's name it request. Is the culture New von Time work requested? Builder for the builder. You need to pass our lone worker class that we just created. After that, we can say that, said input data. We can pass our data. Let's say that sit constraints on past our constraint. After that, that's it. That's it. Initial delay in here. Let's pass our days plus a time unit off days after that. It's also add attacking here as that's a loan payment. After everything we just need to deal this request. After that, we can say work manager that get instance we need to pass our context, which I'm going to pass at Lone activity that class or that this, to be precise. After that, I can say that. Thank you, Andi. I can pass my request. Simple as that. That's it for our racing task. That's minimize it on Let's execute are facing task from different parts. First of all, I'm going to execute this APP alone from here where we had it to do. But before that, we need to add both of these racing tasks as member valuables. Let's quickly, let's say private that transaction that's transaction on also private as low. Let's name this fun at known as well. The proper place for calling at Lone is inside these unforced execute method. Off this a sink test, Let's say at alone, is the court in New Athlone after that? Let's say at long that execute I need to pass this integer, which is the transaction I d. For this nearly at the transaction that's past our intelligence, we can safely the witness to the and also the proper place for executing this transaction. A sink task is inside this unit. Adding method once again, Very hard to do. Let's say at transaction is according your transaction. After that, we can say a transaction toe execute minute to pass, user thought Give idea we can safely deal. It is to do as well. Okay, lets all right understory method on take care of the memory leaks as bad. Okay, I think our application is ready to test. We just need to add on my quickness now, inside the transaction. Don't look in order to navigate the user to this At lone activity inside the transaction, don't look inside these lone Ducks. That Uncle Riesner, I need to create an intense That's I get activity and at lone activity, that class start activity and we need to pass our okay. Let's run the application on. Let's test everything. If you remember, we have changed the data structure in our database Helberg class for that. First of all, we need to uninstall this application in studied once again. So let's quit to do that. Let's turn our application once again. Off course we need to create in your account because all the data has been removed that same May some that make that work. And let's try, I think, a new law. Let's elect known this time for the long name. That's a paper for the initial amount. Let's say 3600 for the mostly art oil, let's say 1% for the monthly payment. Let's say 336. This 36 is going to be the interest that the user is going to pay. Let's cynic an initial D and finished eighth as well. For Danish out date, let's say October 20th and for the finish state, Let's go one year from now. Okay, let's add this loan. I believe this shouldn't do anything because we didn't create the intent to navigate the user to main activity. But the loan itself on the transactions would be added successfully. Okay, lets added on, Let's quick, quick, create the intent for navigating the user in here Inside on post execute method off the Athlone facing test that's a intent is a cult in the your intense at lone activity that this main activity got class they need the flags in here has been okay, let's run the application one more time you can see that the transaction has been added successfully and we have 3600 in our account. You can also check these transactions from here. Received amount for paper alone. That seems to be perfect. Let's try, I think, a new transaction. Let's try, I think, in your loan. But before I do that inside the main activity on going to add a lock in order to validate that the work has been executed, successful let's go to main activity inside the UN Create method after everything. If you remember, we had a look for logging divorce for, I think, a new investment. Let's quickly at one for adding a new law. Long work plus work manager that gets instance, me to pass a context. Let's say that get working for by Tak. I don't remember the tag. Let's copied from the Athlone activity. It was a loan payment. That's pace Sitting here next opened the locket on. That's just our application. Once again, let's try, I think, in your loaning here. No, this time, let's say Bank of America, that's a 2000 for the monthly. Our rivals again, that's a 1% for the monthly payment let's say 11 20. It's the amount with its interest for a one year payment. Okay, let's select on initial date and also finished dating here as well. Let's add this law on. Let's check our knocking. That search for work, as you can see too long works has been added in here, and I believe the rest of them will be added one at a time when the 100 system finds the required resources. Okay, everything seems to work fine. Let's move on from this part. Next, I'm going to start working on this loan activity in here once again. It's going to be a really simple activity. It's a lot like the investment activity that we had in here. Right now. We don't have any investment, so it's empty. Basically, it's going to be a recycler view on this bottom navigation that's going to create. But before that, let's close all of these in our package, let's say new empty activity that's named this fun. No, next week. First of all, let's start working on the layout. Five. As I said, it's really simple. That's changed, is constantly hour to a relatively up. Let's add a recycler viewing here match firing for the beats on background. For the height, let's have an I D. That's a loan rescue. Let's also either margin bottom off. 50 dp Because we are going to What's the bottom navigation doing there? It's also helpful to have a takes. Fear in case they recycle of you adapter is empty, so let's quickly at that. Let's say text you for its text. That's a loan activity that's giving tonight. Let's make it sent their horizontally on. Let's increase its size and also you to style on Let's move. I recycle of ubi logistics. That's also give it a margin tough. It's helpful to have a padding for this relative layers. That's a padding off. 10 dp on. After everything, let's add our bottom navigation. I'm going to copy that from the activity. May. Let's copy this bottom navigation view on Let's face sitting here, it's better to have the padding for the recycle of you and not for the whole relatively out . So let's greatly change that. Okay, let's press control All still, in order to reformat a coat on Let's move on from this part. Let's go to our Joe file and initialize thes two items that's also initialized our bottom navigation you. Once again, I'm going to copy that from inside the main activity. Let's quickly find that method. I believe this is the bond, that clinic. That's Facey thing here. But of course we are going to change it that it's a first of all. We are going to change the default item, that same menu item, love. After that, we need to write a bunch of intense. First of all, let's change this context. That's a known activity that's also changed the name of this intense to, let's say, investment. I need to create another intent for inside this many I temple. That's it for this. Any bottom navigation we were adjusting to call this method that's weekly. Do that. Okay, it's time to create an adapter for our recycling You. First of all, I'm going to work on the layout, one that's nameless finally sytem bones. Once again, I have prepared the layout file on I'm going to pay, sitting as you can see, it's a lot like the Stichting investments, but a few difference. First of all, instead of total expected profit, we have total expected loss in here, and also we have a monthly payment in here as well. So this is the key difference. It's a bunch of many are layers with a bunch of text use. Nothing is special in here. The whole thing is a card view with an idea off. In case if you need to check this court, I will upload the whole application at my website at Makeup, that organ slash coat. Okay, let's move on. Let's create the job for our adaptive. I'm going to do that inside the adapter. But even before that, I'm going to need a mother for different loans. That's name this class known a doctor. First of all, let's kind of look, that's a probably class you holder, Ignatz, to extend the recycling. You just your holder. We need to construct ER, and instead of talking, I'm going to fast forward the part that I initialized all of the elements. So in here we have the name of our long. We have the initial and finish state of our loan. We have the oil or rate of interest. We also have this loss is going to be totally expected loss. We have the amount of this long, and also we have the remained amount off the loan as well. After everything we have this parent. We are going to use this card view in order to change the background color for every item in our adapted. Okay, let's extend the recycler. You got adapter in here. Let's say extent recycling view that adapter on. We need to pass our view holding. Let's implement three methods before working further. Let's greatly create a mother for different laws. I'm going to do that inside the mother's package. That's made me to know, and I'm going to skip the part that I write all the fields for this quest. Make sure to compare all of this with your database. Elbert. Plus, that's greatly right. Two constructors like before one would receive all of them and we received non leave. Both of them would be useful getters and setters for all of the fields on also down below. Everything that's right to to string method has been okay. This is our model switch back to our adapter. First of all, let's receive a context in here private context on Let's receive It by a construct. They also need an empty construct. Their that's initialized are released off different loans. Let's move on from the spark. First, I'll get item. Count with it that's returned. Knows that size on gets minimized this beholder class for now. Let's also right to set their method for our released as well, says her. For I really stop bones. Notify Data's had changed inside the uncreative you holder. For someone, let's create our the object, the layout inflator. That's from current that gives context that's inflates artists. They are that the site and loans, currents and force. After that, that's just returned a new view holder with the view that we just created. Okay, let's move on to the unbind view all their method. First on, that's either. Look, let's set all of the values into our your elements. That's a holder. That's name that said text to, let's say, launched that gets position that's gets his name. Also, for everything else. Michelle, they finished eight amount are and remained amount just for the less I'm going to calculate the total expected loss. Let's say Holder does must lead, said text to a string dust value off. Get Totalus. You create that method in a minute. Let's also copied the logic for changing the color from you. Cite the investment that, if you remember, we had this logic barely changed the number one by one in order to change the color off every element in our adaptive adjusting to define an integer called number above. In here, that's great. Do that. Let's see privates into number. Is he called to negative? Okay, let's quickly right this method and finish off the street. Let's say privates, I will get total us They need to receive alone in here. Also going to change to respond from here. But let's past loans that gets with a position off position that's receiving down in here. Let's see started for this low non that history. Let's define a double in here. Double loss is equal to 0.0 after that. Once again, we need to calculate different month. As for that, let's say calendar calendar is equal to calendar that get in stance. After that, that's a simple date format. This the F is people to new simple day format. We need to pass our president in here as well. I think we can copy some of the logic from inside the at lone activity. That's quickly and see that you can't copy these logic from. But of course, we need to surround our method. Be the try catch in our adapting. He will do that in a minute. And also going to change this stuff dates to, let's say, loan that United States get anything. And also this one to load that gets finished. As you can see we need to sound are Methodists. Try catch. You do that, you know. Let's move all of these in tow. That cash book, after calculating the month, is I can create my for loop that safe working Isay called zero. I'm less than Martha's on I plus. Plus, it was better that we had a method in our YouTube's class on. Don't write all of the's ourselves every time that we need them. But now that we have reached this point, it's stress one more time. Let's say lost. Most people load up, get monthly payments times love that get mostly are Roy. We also need to divide this number by 100 after everything, we can safely return loss. Okay, that's it for our adapter. That's quickly switch back to our loan activity and pass it to our recycling. But before that, you need to stand. She ate it. Let's say Privates, Loan adapter. Let's call it adapter. Let's say adapter is called in your loan adapter and you need to pass our contacts after that, let's say recycler view dot said that there has our adapter. Also, let's set the recycler view. Doesn t at manager. That's best newly nearly out manager and our contents. Okay, I think that's it for this video. In the next video, we are going to connect our database on get different loans from the database. After that, we work on the transaction activity. See you in the next video. 21. LoanActivity continued SearchActivity: Okay, let's be quick. Curate the racing task on Get different bones from our data, please. They can't say private class. That's name get loans. Extends the A sink passed less for the parameters that say interview for the input. It's going to be the user I d void for the progress on on a really stuff different loans. For the result of these basic tests, we are going to need the database upper class. So let's insane. She ate it above in here, Let's say private database L for that's name, database Helper, and it's gonna stand. She ate it down here inside the doing background method. That's instead she our issue. Late database. We need to do that inside the try cash flow after everything that's just returned. Not, let's say, estimate they have aces. That's body TV is a call to date of a semper that get readable data raise. After that, let's create our cursor. Cursor is got to di Vita Curie incited loan stable. Let's past no for the columns. We are going to get all of the problems for the selection. That's a user ID's. He caught a question mark on for the selection argument. Let's say use during every which. It's only value is going to be a string that Manu off integers with an index off. Zero Let's pass. Known for the group I am having, but for the sort or their let's say in its state in a descending manner, let's check that if our cursor is not or not. If it is no, we are going to return now. Before that, we need to close our database. Let's move the cursor to the first element. If it doesn't move to the first element once again, we are going to close our purser. We are going to close our database. After that, we're going to return. Now let's create an area, the stuff, different loans in here. It's going to be on empty. I release for now on. We are going to have different loans to these areas. That's period the for loop for eyes. We got zero. I Liston here is they're not get count and I plus Plus, let's create a new loaning here alone is the culture, you know, after that, let's at all of the values to this law. No, no, that's that I d. That's a cursor, Dr Ink Cursor Get column index, which it's Index is going to be hiding. Let's and all of the other futures user i d Transaction I. D. Name Initial date Finished. Eight initial amount monthly. Our monthly payment on remained amount dressed for the monthly Army. I think it's different from our You can check out database upper class in order to make sure of that inside our loan. Stable it smartly, all right, You need to fix that after sitting. All of these values we can safely at this long toe are loans aerialist. That's a loans that, let's add our long after that. You need to move out here, sir, to the next element outside of the four. Look. First of all, let's knows our cursor After that, let's close our data V's. After that, let's recount loans, areas we need to remove this return all from here because it's an unreachable. The statement. That's all right on post execute in here. First off, you need to check that our loans there really is no or not. In case it's no, we are going to sit on empty. I release for our adapted. Let's say that's it loans new aerialists off different loans. But in case it's not know that's a adapter, that's it knows that's past our loans. That's it for this. A sing fast that's groupie called I'm Going to instance she ate it above in here as a member. Valuable. That's a private get loans. Yes, loans. We need to instance she ate it down in here. But before that, first of all, you need to get the user i D. But before that, we need to instance, sheet our routines class this you tails class probably would have been better to be a static, but now that we have used it so far, we are going to stay this pain. That's a new YouTube's. This as our context after that user is equal to Eugene stuff is user knocked in. Let's say you know is not because our user let's say, get loans busy courting you get loans after that, that's a get loans to execute on going to pass user that idea. That's also override on the stream with it down in here. Okay, that's it for our loan activity. Let's get to test our application and see if it's working right Let's switch to our loan activity. It seems like we haven't defined on our police there in our bottom navigation view in the main activity. That's quickly do that that switch back to main activity in here. Inside that, in its bottom navigation view. Inside the menu items don't we need to create another? Let's say intense loaning terms. Is it part of your incense main activities that this loan activity does last? After that, we need to set the flags. After that, we need to start directing. Let's run the application of us again and let's go to our loan activity. This time you can see different lows. There seems to be something wrong with our adapter because first of all, we haven't said this text. You hear this monthly payment, you need to fix that in our loan adapter and also distorted. Expected. Last in here seems to be wrong. Let's reach back to loan it out there and see what's the problem inside this. Get caught on this. First of all, this is my first mistake. I have calculated this last wrong. I need to pass loan that get initial payment on not alone, that get monthly payment. Let's fix that on. Let's also sit a text to our monthly payment takes to you. It seems like I have forgot that let's say on there that's months became in it seems like I haven't defined. It takes view that's People do that down here inside of your holder class. We don't have any monthly payment. Let's added in here, I believe we have the text of you that's wish to our least item long. This payment in here, innit? It's idea. That's Cokie from here on down in here. Let's initialize argue. I element now that we have is we can set a text for it above in here inside the on buying beholder method. That's a holder, that monthly payment. That said text to, let's say, Lance that yet position that get monthly payment. But probably we need to cast this one. Deposits of over. Okay, let's run the application once again that's used to lan activity. This time we can see the monthly payment that seems to be correct, and also it seems like we have fixed the loss. If you want, you can open your calculator and calculates the loss. You have to have $1000. That's a 2000 times months PR rise 1%. That's a fun person divided by 100. It's want to any on because it's a one year loan from 2019 to 2010 we can safely multiplied by 12 and this is our expected lost. That seems to because okay, let's move on from this part. Let's work on this transaction activity. But before that, let me close all of these. Let's create a new activity on name. It's transaction activity. First of all, let's start working on the layout. Fine. I have prepared the layout. Fun. Let's face it in here on Let's review. But we have created in this layout by first of all, it's a relatively out down below. It's a nest of this girl of you inside that we have only one child relatively out. The insight that we have this takes two year After that, we have this relatively out. You can see the whole size off this relatively out insight that relative glad we have this radio group, which its orientation is vertical and we are going to future different transactions. We are going to fit their shopping investment profit, long known payment send and receive transactions. Also in here we have the stakes view and edit ticks. We are going to give the user the ability to search for transactions with amount larger than the amount that he or she put in here. After that, we have this transaction takes few. Let's point that on. Also, I believe this one in here should be greater than not more than Okay, let's find this takes view. After that we have a recycle of you and also we have this text fearing here, in case we don't have any transaction to show we are going to show this takes view. Let's change its visibility to Let's take on. And after everything we have our bottom navigation. You reach for some reason we can see in here, but I believe it will be shown in the wrong time. I will upload the source quote. That's my website at Make with that or slash boats and make sure to check that if you need . But it's really a simple layout for on, and I'm sure you can do it for yourself. Okay, let's reach to our gel if I on that's initialize all of these your eye elements. Just the simple initialization. Nothing is special in here. Let's quickly deal with our bottom navigation view. I think I can copy the method from inside the main activity. Let's minimize this and let's go. Let's minimize this in a few years. Method on its paste, our in its bottom navigation view method in here. But of course, we need to change that. First of all, we need to change the selected item in here. I'm going to say many whites him. That's a transaction. After that, we need to add an intense in here inside the item home. Let's say home intense music culture in your intent. We also need to change these main activities to, let's say transaction. Okay, that's it for our bottom navigation. You. Let's minimize it for now. And that's call it from inside on creating method. First of all that said the doctor for our transaction recycle of you. If you remember, we haven't adapted for our transactions. Let's quickly take a look at that. We have this transaction adapter and we are using it inside our main activity so we can use it in here as well Let's quickly define our adapter above. In here. That's a private transaction. And after that's contact adapter on down in here, let's see. Transaction recycler view. That's it. Adapter. It's past our at that. But of course, before that thing to initialize our adaption, that's a new transaction. A doctor, they believe we don't need any context or anything. After everything, you can't say transaction recycle of you. That's it. Layout manager. We need to pass a new senior layout manager on. We can pass our contents after that. Let's create on you need search method on. Let's start searching for different transactions. Once again, I'm going to connect to my database so I'm going to need an facing cast. But before that, I'm going to need a date of a cell for class, so it's greatly create that thing here as well. Let's initialize it before calling this in its search method. That's if they have a self Percy called the new date of a cell for you to pass the context as well. Let's create our racing task. Greg last get transactions Next tense facing task that's passed in future for its name put , it's going to be the user I d on. Let's fast release off different transactions for its results. We're so let's overwrite the on pre execute method I'm going to define to remember valuables in one would be private string type. We'll see why I'm doing things that's initializing to all. And also you need a private double minimum or let's see me that's initialized. These fun to zero inside are on pre execute method. First of all, let's deal with this minimum. Let's say this, that me is the call to It. Takes me left, get fixed, start to stream. But of course, we need to cast this one because it's going to be a double. That's a double the value of that text on after that. Let's take care of this type in here. So once again, like I have explained it when I created the layout, find this minimum is going to give the user the ability to social transactions with this minimum amount, and also this type is coming from all of these radio buttons in here. I'm talking about all of these for that. I'm going to create a switch statement, depending on the radio group type look gets checked radio button I D. Let's say in case it's our that idea, that radio about an investment, let's say type is because of investment. That's at a breaking here on Let's right the other cases. This is our sweet a statement. If you remember in every part of our application, when we have added a new transaction into our data series, we have to find the type and sitting through one of these values in here. If it's alone, we have said long, if it's a loan payments, we have been sitting like this and so on and so forth. As you can see, I haven't said the case for our that idea that radio button all. Instead, I have said this default on in the defense case, we are changing the value of this time to all. Okay, that's it for our own P execute method. We have set the type and also the minimum for our search. Let's create Arcuri than but before that, we need to instance shit our rescue light on data ways. Let's say s united data ways. That's college TV is calling to date of itself. Get Rid Ament database. After that, let's create our curses. But this cursory in here is going to be a little bit different from other cursors that we have created so far. I'm going to define an if statement in here. I'm going to say the time that he calls. Well, it means that if we are interested in all of the transactions, then I'm going to define on s case in here as well in case type is equal to all. Let's create our cursor. I'm going to say cursor is called db dot curie that security on transactions to, uh, Kanaan for all of the columns. But for the selection in here, I'm going to say Use their I. D. S a culture question mark. And it's like the selection argument. I'm going to pass that user idea. That's a string dust value off integers with an index off zero. It's best known for group I am having, but let's pass a date in a descending manner for sort order. That's our cursor in case type is he called all of them. But in case the type is not all, we are going to create another person. Let's say devi dot Curie once again on the transaction stable? No for all columns. Our selection in here is going to be different. Let's say type is the culture question mark. Andi User i d. Is the call to another question. We need to pass both of these arguments in the selection arguments for the 1st 1 That's a time. But for the 2nd 1 that's a string that value off integers with an index off zero once again began past. Nor for group I am having but dates for the sort order in a descending manner. We haven't passed the amount in here on. We haven't used this. A minimum big will survive. I'm not using getting here because if you remember, the amount inside our transaction stable can be negative. Andi, for example, we define another casing here. Let's see amount greater than another question mark. This is not going to work because our amounts can be negative. There is a method in S u light called absolute or a B s, which we can pass on inter during here. This method will calculate the absolute value off some integer or some number, and we'll return the positive value off that number. But this is not working in here. I have tried it multiple times, but it seems like you can't put it inside a condition or inside an operation like this in here. Instead, we are going to get all of the transactions with these two conditions. And after that, when we have retrieved them from the date of its we are going to calculate the absolute value off this transaction amount inside the Java code. So in here, I'm going to remove this part. Feel free to play around with that absolute method, and you will see by yourself that it's not user building here. Okay, after we have instance created are cursor. Once again, we can check that if no is equal to our cursor or not. In case if it's now, we're going to close our database and we're going to return. Now let's say if cursor don't move to first in case it doesn't let's close our cursor. Let's close our database. Let's return now, in case it does move to the first element. Let's create on a really stuff. Different transactions that's college transactions is a part of a new aerialists. After that, let's be our whole look for in Isaac are 20 i Liston cursor that get count and I plus Plus , Let's be our transaction are objecting. First of all, let's set all of the values for this transaction. We have seven values in here. I d user I D. Type description recipient date on amount. You can also check your date of a supper quest to make sure of that. Inside the transaction Stable. Alrighty, amount, date type. Use our idea. Receive pants on disputed. That seems to be fine. Okay, let's move on from this part. And here is the part that you need to calculate the absolute value off this transaction amount. For that, I'm going to define a new double in here. Let's call this fun absolute amount. Let's in, Stan. She ate it to transactions. Get amount. After that, you need to check that absolute amount is less than zero. Then we are going to make it positive. That's an absolute amount is equal to negative. Absolute. After that, we need to create another if statement in here that say, if absolute amount is greater than this, that mean, then we are going to add this transaction to our transactions. Are released, Let's say, transactions that had done this past transaction after everything. Let's move our cursor to the next element. That's a cursor that move to next. This way of calculating the absolute amount in here is probably not a good way because it will slow down the speed of Arcuri. We should do it inside, are issuing a statement, and I'm sure there is a way to do that. Andi, I encourage you to find that. But in here we are fine with this because the size of our database is really a small and it doesn't affect our curious Pete that much. Okay, let's move on from this part. After everything you need to close our cursor, we need to close our database. We need to return our transactions raises. That's all right. The on post execute method. Before that, let's abilities Original statement. That's a post execute seen here first, solving to check that if no is not a call to our transactions in the else case, I'm going to show that the transaction to show message. Let's say txt. No transaction took set visibility, Let's say visible. Let's also fasten empty. I released to our adapter that, say, a doctor that's transactions new. I really stop different transactions, but in case no is not a call to our transaction. First of all, we need to hide this. Take your that's pass it in here on. Let's change in visibility to God. After that, I can say adapter. That's a transactions through our transactions. That's it for our racing task that's quickly executed. But before that, let's minimise these extra large facing tasks inside are in its search methods. 1st 11 2 instance sheet are beauties class. That's a utilizes the culture, new details You need to pass out context. After that, we need to create our user. That's a user. Is the culture mutinous? That is you. Their luck in Let's say, you know he's not a call to our user After that, we need to execute target transactions, a sing tests. But in order to do that for someone, that's I did as a member of get transactions on our search method, you can save get transactions is a culture. Music transactions after dental etc. Get transactions that execute on its past. Our users don't get I d. That's quickly overwrite. Understory method has been That's almost it for our transaction activity. But beside calling this in session with it from inside the UN create method, we need to call it from two more polices. First of all, we need to call it from inside the button search. That's it on Click Listener Method. And also we need to call it from inside radio group that unchecked change listener. So let's quickly do those two. That's a beauty and search. That's it. I'm sleepless there. You're completely sir. And it's called our method After death. Let's see Radio group type That said Unchecked Changed Listener New Unchecked change listener on Let's start our search. Okay, I believe that's it for our transaction activity. Let's quickly tested on Let's finish off this with you. Once again, I have forgot to sit on unclear Glessner for this transaction in our main activity, that's quickly do that inside are in its bottom navigation you inside many items transactions. We need security. Another intense. Okay, let's run our application. But more time and see How did we do? Let's go to our transaction activity right now they're all radio button is selected on. We are seeing all of different transactions. Let's see if we can filter it anyway. Let's select shopping. This time we are seeing only discursive shopping. Let's search for investment. No transactions to show her office. We have added these profits manually. I believe. Let's search for loans. We have Bondo or two longs in here known payments non sent on received? Not okay. Let's once again search for all of different transactions on Let's limit them to, let's say, 100. That's sash for different transactions. And this time you can see that we are seeing only the numbers above 100. Also, we need to fix this bottom navigation situation in here as we will fix that in the next video, they signify need to add two more attributes to this activity inside our manifest five. Okay, I think that's it for this video. In the next video, we are going to start working on the final activity, which is on the statistics activity. See you in the next video 22. Line Chart and Pie Chart in StatsActivity: before we go further, let's quickly feats This situation with our keyboard on our bottom navigation you inside are manifested by inside the transaction activity in here. We need to add another attributes on that attribute. Is this window soft in put mud? We need to pass two attributes in here. Just pond on. Also just resize this too. Let's run our application loss again this time. If we go to transaction activity on If you click on this, you can see that bottom navigation view is not shrinking here, which seems perfect. Okay, let's move on. Let's work on this. The statistics activity for that. First of all, I'm going to create another activity in my package that's called this one s. That's activity. First of all, let's work on its layout five. I'm going to put two charts in this layout. File One would be a bar chart showing different activities in our account. Basically, we are going to use the transactions in our database for the data for that drug. The 2nd 1 is going to be a pie chart on for the daytime. That chart we are going to show different loans on they remained amount I did want to add another charting here, but I couldn't think of anything valuable to showing different charts. But after this video that you know how to use bar charts, pie charts, on line charts, you can add any charts that you want in your application. It's just for practicing on. You can do whatever you want me to your excuse. Okay, let's change these constantly out to a relatively out. Then here. Let's greatly at a Borchert. First of all, the one that comes from the library that we have added to our project the MP Andrey chart. But it beats, let's say, 300 dp as the less for the height. Let's give it on I d. Let's say far short activities. Let's century horizontally on. Also, let's add a margin top off, maybe 20 p. So that's the size of our board Shark. Let's we can add a pie chart in here as well. For that funds again, I can use MP Andre Library. That's a 300 leaping on 300 BP for its with on height. Let's give it some I D. Let's say five chart loans a margin top, maybe off 10 TV also let's move it big blowout bar chart. Let's also make these funds center horizontal as But let's also add a margin bottom off. 50 dp for our bottom navigation beer. Also, because we may have different conflicts for different experience sizes. Let's move all of these into a nest of the school abuse so that the user can. This girl, if on these two bars don't feed him on the screen, that's quickly administered. Score. View my parents on my parents. We don't need any idea or anything inside the nest of the school. Bubenik on Leave on Child. That's a relatively out on Let's move our two charts into death relative. Okay, that seems better. Let's briefly copy the bottom navigation you firm inside the main activity layout. Five. I can pace that down below. In here after the nests of this world, we also I think if you give this margin bottom to necessary score view, that would be better. Let's copy that or let's caught that. And let's face it in here, that's reformat. Our put by first in control all stand. I will upload the source code at the end of every video, so feel free to check them if you need. Okay, let's switch back to ours. That sticks activity on. Let's initialize thes three items. Let's copy the quotes for initializing our bottom navigation. You're from inside the main activity. That's copy this whole method, but of course we need to change that. First, I want you need to change this main activities to, let's say, start activity on. Also, we need to add another intense in here for navigating two main activities. That's also changed the default option selected for our bottom navigation view to Let's a Menu item stats. They also need to add unclear Glessner for the many items stats in our main activity so that we could navigate through statistics activity from our main activity. Let's quickly add that in here. Let's copy this one. Okay, that's it on. We can close our main activity. Let's switch to our stats activity adjusting to call this in its bottom navigation. Your farming site on creates method. So for the bar chart, we are going to get different transactions from our database and after that we're going to show them inside our border. For that, we are going to create another a sink asking here, That's a private class. Get transactions. Extend the pacing task. Last integer for the import. It's going to be the user I. D. Andre released off different transactions for the result of these a sink tests. First of all, let's create the database upper class. We are going to need that. That's a private database helper. It'll be semper. I believe we are going to need the U teams class as well. So let's groupie create that. That's insane. Shit, both of them down here inside the doing background method Off this glass. Let's a try catch in order to at SQL Exceptions. After printing this factory's Let's Return. No and inside the tribal Look, let's say this your database devi is a call to database helper that get redevelop database . After that, it's a cursed of care certain because to tv dot curie for the curious, you can save transaction table, but we don't need anything for the selection selection argument columns having through a pipe on sort order so we can pass No, for all of after that, you can check that are cursor is no, not if it is. Now, let's close our database on Let's Return Now, In case it's not know, let's say if cursor don't move so first in case it doesn't move to the first elements we need to close our cursor. We have done all of these 1000 times. That's a TV got close after that return off. But in case it does move to the first element that's create an area just off different transactions, let's call it transactions is called from new Aerialist. After that, we need to create our four look for int. I is equal to zero. I'd list than cursor that get count and I plus Plus inside the sport of first sold. We need to create our transaction like him. Let's say easy culture, new transaction. After that, you need to set different values. I believe we can copy some of the court from inside the transactions activity. Let's go to that activity inside this Get transactions are released. We can coffee. All of this after definitely to add this transaction to our transactions exist, you can say transactions. That aunt that's passing transaction. After that, we need to move our curses after the four look, we need to close our cursor we need to close our database on. We need to return our transactions areas. That's it for doing background. Let's delete this return now is unreachable. The statement from here, and that's over right on post execute method in here. Let's say if no is not a call to our transactions area at least first of all, let's get the current state. It's a calendar. Is he called to calendar? Don't get instance. We are going to need the month on your later on. We will see what we are going to need them. That's a in math is the call to calendar that get calendar dot Mom. Let's also get the year as the that's changed the name of these two to current month on current here. After that, let's create a simple day Formatting here that's called SDF is he called the new Simple Date format, and it's past our pattern. After that, I'm going to create and release the bar entries. Let's call it in trees. Is the culture new Erin's? Let's create our four do. Let's say for transaction see inside, our transactions are released. First of all, let's get the date of this transaction I can say date safe is equal to STF. The part we need to pass. He don't get this. Of course, we need to get the exceptions that can be caused by this parchment. Okay, after that, we need to set the states to our calendar. We can say calendar that set time on. We need to pass our date. Let's get the month year on, day off these terms Action. If you remember, the day off month will start from zero and I'm adding this morning here so that we could see the actual day. I'm going to show different transactions from the last month in my chart. So first of all, I'm going to create an if statement in here. Let's say if month is equal to the current month on also, if a year is the call to current here, if both of those conditions are met, we are going to add this transaction toe. Are entries a racist? But because I'm going to group different transactions by the day, First of all, I need to check that if this day exists in our entries or not for that first all, I'm going to create a 1,000,000,000 in here. That's a brilliant. Does they exist? That's initializing to false. After that, I'm going to create a for loop for barred entry. That's name inside our entries. Let's say you've eat that. Get thanks is equal to our day. Then we need to change the value of this bunion that say that say,