Diaries List Activity - (b). Write Code

25 minutes
Share the link to this page
Copied
  Completed
You need to have access to the item to view this lesson.
One-time Fee
$15
List Price:  $69.99
You save:  $54.99
€14.25
List Price:  €66.52
You save:  €52.26
£11.87
List Price:  £55.40
You save:  £43.53
CA$20.95
List Price:  CA$97.77
You save:  CA$76.81
A$23.03
List Price:  A$107.48
You save:  A$84.44
S$20.16
List Price:  S$94.07
You save:  S$73.91
HK$116.74
List Price:  HK$544.73
You save:  HK$427.98
CHF 13.25
List Price:  CHF 61.85
You save:  CHF 48.59
NOK kr165.79
List Price:  NOK kr773.61
You save:  NOK kr607.81
DKK kr106.34
List Price:  DKK kr496.19
You save:  DKK kr389.85
NZ$25.57
List Price:  NZ$119.31
You save:  NZ$93.74
د.إ55.09
List Price:  د.إ257.07
You save:  د.إ201.97
৳1,794.03
List Price:  ৳8,370.95
You save:  ৳6,576.92
₹1,267.98
List Price:  ₹5,916.42
You save:  ₹4,648.44
RM66.97
List Price:  RM312.50
You save:  RM245.53
₦25,208.85
List Price:  ₦117,624.49
You save:  ₦92,415.64
₨4,173.39
List Price:  ₨19,473.08
You save:  ₨15,299.68
฿520.03
List Price:  ฿2,426.48
You save:  ฿1,906.44
₺518.27
List Price:  ₺2,418.28
You save:  ₺1,900
B$87.15
List Price:  B$406.67
You save:  B$319.51
R271.88
List Price:  R1,268.60
You save:  R996.72
Лв27.88
List Price:  Лв130.09
You save:  Лв102.21
₩21,018.13
List Price:  ₩98,070.61
You save:  ₩77,052.48
₪56.01
List Price:  ₪261.37
You save:  ₪205.36
₱885.96
List Price:  ₱4,133.88
You save:  ₱3,247.92
¥2,316.03
List Price:  ¥10,806.63
You save:  ¥8,490.59
MX$305.16
List Price:  MX$1,423.91
You save:  MX$1,118.74
QR54.74
List Price:  QR255.44
You save:  QR200.69
P205.08
List Price:  P956.94
You save:  P751.85
KSh1,938.75
List Price:  KSh9,046.20
You save:  KSh7,107.45
E£744.75
List Price:  E£3,475.04
You save:  E£2,730.28
ብር1,871.73
List Price:  ብር8,733.50
You save:  ብር6,861.77
Kz13,684.90
List Price:  Kz63,853.79
You save:  Kz50,168.88
CLP$14,607.30
List Price:  CLP$68,157.66
You save:  CLP$53,550.36
CN¥108.62
List Price:  CN¥506.84
You save:  CN¥398.22
RD$905.46
List Price:  RD$4,224.90
You save:  RD$3,319.43
DA2,003.84
List Price:  DA9,349.94
You save:  DA7,346.10
FJ$34.05
List Price:  FJ$158.89
You save:  FJ$124.83
Q115.89
List Price:  Q540.76
You save:  Q424.86
GY$3,140.87
List Price:  GY$14,655.30
You save:  GY$11,514.43
ISK kr2,074.50
List Price:  ISK kr9,679.61
You save:  ISK kr7,605.11
DH149.97
List Price:  DH699.78
You save:  DH549.80
L273.15
List Price:  L1,274.52
You save:  L1,001.37
ден877.29
List Price:  ден4,093.48
You save:  ден3,216.18
MOP$120.36
List Price:  MOP$561.60
You save:  MOP$441.24
N$272.29
List Price:  N$1,270.52
You save:  N$998.22
C$552.44
List Price:  C$2,577.69
You save:  C$2,025.25
रु2,026.37
List Price:  रु9,455.06
You save:  रु7,428.69
S/56.97
List Price:  S/265.82
You save:  S/208.85
K60.43
List Price:  K281.99
You save:  K221.55
SAR56.31
List Price:  SAR262.75
You save:  SAR206.44
ZK415.46
List Price:  ZK1,938.58
You save:  ZK1,523.11
L70.94
List Price:  L331.04
You save:  L260.09
Kč361.21
List Price:  Kč1,685.42
You save:  Kč1,324.21
Ft5,862.43
List Price:  Ft27,354.11
You save:  Ft21,491.68
SEK kr165.45
List Price:  SEK kr771.99
You save:  SEK kr606.54
ARS$15,040.97
List Price:  ARS$70,181.20
You save:  ARS$55,140.22
Bs103.96
List Price:  Bs485.08
You save:  Bs381.12
COP$66,203.61
List Price:  COP$308,906.07
You save:  COP$242,702.45
₡7,623.77
List Price:  ₡35,572.52
You save:  ₡27,948.74
L379.36
List Price:  L1,770.13
You save:  L1,390.76
₲117,571.75
List Price:  ₲548,589.81
You save:  ₲431,018.06
$U641.77
List Price:  $U2,994.50
You save:  $U2,352.73
zł61.98
List Price:  zł289.22
You save:  zł227.23
Already have an account? Log In

Transcript

Next we're going to come over to a Gary's activity now, you can guess it's true. Of course it's going to be 200 of course our data is in a crib okay. So there is activity This is basically to rent our there is not a secret to fetch them and then printed them okay. This is it, let's check by rating inputs. So input hundred good content, context input hundred graphics lip color, then until because the vendor then until that is the tundra, then under that menu, then undred menu inflator, then under view, menu item, then unquote, do feel then teach it with apps, apps Western so we're going to continue and make all our inputs. Then public plus there is activity extents are completed.

Activity, then implements it, because now I can click this map. So let's look at the inputs of medical see, we have server imported widgets, we can put into copper. From under twice, we have our color, we have our context. Then you have the unpredict components like their activity, or syllable flow model providers, as well as our physical then communication to form our material. Then you have the date picker listener, as well as the horizontal. Pika, of course, which is a third party a pro.

Okay, so this is it, the universal have a couple of inputs, our custom classes right here. Now we've created activity. As you can see, it's implementing it's extending their productivity and then implementing the date picker listener. which is going to allow us to listen to of course, they did selection events, as well as the item click listener to listen to the click events. We now start by writing our instance views. So we're going to define our instance feels so private, recyclable, and free, then private horizontal picker picker.

The private edition will then become navigation view, the private section, expandable locker section, section layout, the pivot default page equal to true. And then there is a view model equal to model that private scrolling quote first. So we have our recycler view router, which is going to render our data. Horizontal picker is going to allow us to pick our bottom navigation field going to allow us to switch to different foods. Okay, great as well as a list, then 10 of cups, okay, then our section doctor. This is they wanted us to show sections as well as our data to our recycler view them default page.

This Boolean is going to allow us to know, of course, with the default pages actually shown, okay. Now the default page, we're going to have to use the default zeros at that page, which lists all our data. So we also have the data flow model, which is going to allow us to load our data. And then scrolling is going to allow us to determine whether these it's creating the RecyclerView writer, okay, so these are instances. We're now going to create, of course, a method where we're going to initialize This particular use so we're going to issue resolve just will come and say preferred food initially then RP find view by ID and replace it with emphasis. Then section layout equal to new sections, expandable layout helper, then this then this, then two which is count, then picker equal to find view by ID.

Id. Because this did set this 120 in the set of set seven, then the set the selected color, color gray, then the set that selected text color, color bitrate, then the set month and the text color. Color, that gray. Then that said today button text color Get resources get color or color primary. Then the set today, that text color, get resources get color, and color the primary then the set today the color, color query. Then let's set on selected date text color colored gray, then set the text color to gray.

Then the second selected the text color, get resources that get color as the primary text color in the shop today button through then the finish them because it's set background color, color gray and the picker that said that time then what communication view equal to flew by AD AD and navigation. So, basically coffee dissolve initially some jets including ours, and then said, of course, it also initialisms section expandable casita, recyclable. Then parcels parser, the number of grits that took the number of columns that children have in the RecyclerView. Then we also have our picker, richer horizontal picker. We set some of its properties as you can see later. Yeah, then we also have our bottom navigation view creature.

Okay, prevot good. Listen to bottom navigation clicks. So come on, say bottom navigation view. Let's set on navigation item selected listener. Then item, then switch the item to get item ID. Then is our ID action then differ pitch equal to true.

Then pick kiss our ID bit action or debts then default pledge equal to first and then bank and then brick. Then kiss ID, action exit, finish, then prick. Then button navigation few Let's set selected at mid action home. Basically in this case as you can see, we've just initialized our communication tool and then so if these are selected Of course the home we're going to buy in Darris and then set our default pitch to true if these are selects or let's open to buy, and then set default to first. If these are selects exit, we're going to exit by default. And these are stuff that we're going to set the home right here.

So private void, listen to the secret curse. At v look at on scroll snap the new recycler view that unscored slot, then activate then public void underscore state changed, then Atlanta RecyclerView recycler, who then introduced it, then so public underscore state changed, sacred Lu, then new state, then if new state equal to absolute will click on scroll listener that's close to touched knew when to say is calling equal to true then come out very public food on skirt the secret foo then in dx then each do I then so product unscored RecyclerView index then do I. Then if is calling if work on navigation will get visibility equal to visible. Then bottom navigation view, let's set visibility view is calling equal to force handler handler equal to new handler handler postulate Then our lambda expression, if bottom navigation field, just to get visibility equal to field, then bottom navigation field, etc visibility view book.

Then three seconds 2000 milliseconds. And that's it. So basically in this case, you're listening to this core defense for sacred. And in fact, what we want to do is that if the user is crawling our, we're going to hide temporary hide, of course, our bottom navigation film project, okay, we'll be hiding it. You can see chickens visibility, and setting it to gone. Then, of course, once the user has scrolled, wait for three seconds and show it okay.

So this is because in small screens, they both minification you can actually hide a portion of the content. So we just want to these are to score and then be able to view our before showing the view again. Okay? So this is actually optional economic design if you don't want that behavior. So this is it. Let's proceed.

So the next method we're going to look at is very important because it's going to allow us to bind our data to a recycler view. And those data is going to be actually section Okay, so we'll be having one section of Section deter bind it of course to our recycler view. So come and say private food bank that is the currency list that is equal to cashier manager. That order is memory cache, if default pitch then Picard set visibility viewed visible Then list to data is equal to utils that get that is for this date. There is the cashier manager that selected that. Then are released done equal to utils that get that is for this time of day.

Today there has been done ArrayList morning equal to utils that kid that is for this thing day to day there is then morning then our list afternoon equal to eaters that get the strength the day. Today there is the afternoon then ArrayList evening equal to you tears that get that is for this thing today. Today, there is the evening, then are this night, equal to you to get there is this time of the day. Today there is then light so what I'm doing right here Well, first you're checking if we're in the default page that is in the home page. If that is the case, we're going to show, of course, our horizontal picker. Then we're going to, of course, filter our data.

We've defined some static methods now utils class these are the methods certainties. These methods include, get there is for this date, or we need to do is to pass it the orthodontist and then the selected date. And then it's going to filter today there is now once we have dinner is for today, we're going to filter them based on pain. Okay? So for example, who didn't morning, afternoon, evening at night. We're going to filter them preacher.

Okay. Yeah. So we'll continue section protocol to know section expandable then this, then this then too Then Section A lot the ad section done, then plus them to size, credit and zero, then the size. Then done. Then section load look at section money, one input size is greater than zero, then money size. Otherwise empty the section left it at section, afternoon, afternoon the size of protest and zero, then you show afternoon the space those who show empty then of course, if anything in size is greater than zero.

In that case we should if we needed size, those who show empty then night night size is greater than zero. In that case we should make that size otherwise we should have zero errors because etc visibility food calm then ArrayList dot r is equal to utils that get out there is group by depth there is the section route equal to no expandable section expandable this then our fee then this then took them for list list that is list if list is equal to null and then string that section equal to list get get it the section look at section that section then list the C section layout look at traffic changed and because it okay so what have we Done preacher, where we've created a method bind for us our data. Okay, so you can see we've already explained this. And then you can see in this portraiture, basically we'll shoot a section without passing in our RecyclerView.

This is what is going to bind our data. Okay. Then of course, we'll add several sections. Now we're adding section, we're going to have that done. And then if they don't displace president zero, then you should displace, okay. Now, if it is not, then we're going to show empty the same thing with morning something afternoon.

In the same thing if eating the same thing the night? No, that is if when the default pitch, so if we're in, of course, the archived pitch, then you're going to hide the horizontal and then get all this content group they did. Okay, so then we prepare our are expendable. Then we're going to look through the list of lists. So we check if the current list is not equal to null and its size is greater than zero. Then, of course, we'll take the debt, who said they did?

And then we pass that particular list of berries. We added, okay, for that particular section, then at the end of the day, we're going to notify our data changed, okay? Yeah. Where that method we just looked at was actually looking or binding or detract from our cache. Okay. Now what about if we want to refresh or reload the data from escalate where let's click on that for us.

So we'll come and say private food reload, there's, they'll come and say their resume or group get, then get dirty slate to target groups have done this then There is then if there is not equal to null, and that is the same as credit zero, the cashier manager or more ricochet equal to Doris, then cashier manager is that the first then pain Okay, there is cache manager, or there is memory cache clear. And that's it. So basically it is a method that is going to allow us to reload our data is okay. If we have some days, we're going to add them to a cache. Now, if we have none, that will clear our cache. Okay, so the next thing we're going to read the methods which is going to allow us to fit our menu as well as listen to the selected menu items.

So extroverted public button on click Options menu, menu menu, then menu In flutter in flutter equal to get menu inflator, then inflated input menu there is pitch menu, the menu, then return true activity rate, then public Boolean on options items selected, menu item item, then switch item get item ID, then case ID, actually, then you choose this option activity, this credit activity and finish return true. Kids undertake the action to push them through and then return true. Kids undertake the actions which will then default pitch equal to not default pitch then by the Harris they improve Ctrl kiss did it actually exit this did finish return true okay return super options item selected item. So as you can see basically cause to be flooded or Darris pitch menu so there is pitch menu of course you have to be aware that we've created the creature under the menu so if you have interpreted it just clicked of course an XML file, there is pitchman then you are different quadrature This is the code for our menu.

You can see we have our menu items. New Of course, add refresh as well as the switch few right here. Okay. Yeah. So protected void, attach this context context snoopers then super detached this context and food pump pick apart the crop, the new base in a torrid fabric fade on back pressed, then super on back pressed, then this finish. So basically we just have already been two methods.

First attach this context. In this case, of course, we're going to this will be for the sake of font, custom fonts and the custom fonts within this activity. Okay? Now we'll copy them and dissolve on pressed if you press the back button, we're going to finish the current activity. Okay, so you guys could remember that we had actually implemented two interfaces, okay, the first date because left so this typically, it's going to force us of course, to vary the least one method they wanted selected. So let's come and do that one.

So accelerate public void The selected date time date selected, then string the equal to string the value of that selected get the string month equal to string that will have that selected month of year, then string day equal to string that will have that selected day of month. Then if that selected month of year is less than 10, then month equal to zero plus month if that selected get day of month is Denton, then they equal to zero plus the cashier manager is selected equal to the year plus dash plus month plus dash plus the if cache manager. There is the T then loader is at the waist. Bye, Daddy's Okay, you can see this declared to have been forced to pin the month anti strings, things check if they are the month of year for example, let's say it's August, okay? Now Okay, that is eight.

So what you want to show instead of having it as a to want it to be 08. So this is troubling. Okay, if it is less than 10 the same thing with the day of month, if like it's second, instead of having just to want it to be 02 then we cetera Yeah, man can be customer crusher managers just selected it for a book. Now if our cache manager there is that we're going to reorder there is a device. We're going to bind our where remember of course on next interface the item quickly slainte office, you can see we have a creature so this interface is Come they look for in some of its methods. So we come and say they're too worried then public quit, I can quit dairy, then utils center activity, this dairy, then detail activity class across public food item click section section, then utils let's show this section get name plus clicked activerain critical food concrete, then under city sunset and public unclip save instance state, then set content view then arbitrary activity that is the entire review model equal to view model providers of the get the review class.

Then this issue is then this little lesson to work on patient clicks. Then this debt listen to receipt of his crops and does it a case such a low class feature. However, this is very important class for us because as we've seen, it's going to allow us to load our data of course, lower their interest level and then because that that is going to be section also listening to various that selection events and then reading appropriate for this for this particular edits, okay. So this is the creature. This is our full there is activity receptivity the Java let's move to the next

Sign Up

Share

Share with friends, get 20% off
Invite your friends to LearnDesk learning marketplace. For each purchase they make, you get 20% off (upto $10) on your next purchase.