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
€13.84
List Price:  €64.60
You save:  €50.76
£11.87
List Price:  £55.40
You save:  £43.52
CA$20.39
List Price:  CA$95.14
You save:  CA$74.75
A$22.97
List Price:  A$107.21
You save:  A$84.23
S$20.20
List Price:  S$94.29
You save:  S$74.08
HK$117.35
List Price:  HK$547.55
You save:  HK$430.20
CHF 13.58
List Price:  CHF 63.39
You save:  CHF 49.80
NOK kr161.46
List Price:  NOK kr753.41
You save:  NOK kr591.94
DKK kr103.28
List Price:  DKK kr481.90
You save:  DKK kr378.62
NZ$24.97
List Price:  NZ$116.54
You save:  NZ$91.56
د.إ55.08
List Price:  د.إ257.02
You save:  د.إ201.93
৳1,650.20
List Price:  ৳7,699.83
You save:  ৳6,049.63
₹1,250.38
List Price:  ₹5,834.28
You save:  ₹4,583.90
RM70.99
List Price:  RM331.26
You save:  RM260.26
₦20,950.50
List Price:  ₦97,755.03
You save:  ₦76,804.53
₨4,181.28
List Price:  ₨19,509.87
You save:  ₨15,328.58
฿545.71
List Price:  ฿2,546.30
You save:  ฿2,000.59
₺483.46
List Price:  ₺2,255.86
You save:  ₺1,772.39
B$74.65
List Price:  B$348.35
You save:  B$273.69
R283.28
List Price:  R1,321.80
You save:  R1,038.51
Лв27.10
List Price:  Лв126.46
You save:  Лв99.36
₩20,243.32
List Price:  ₩94,455.35
You save:  ₩74,212.03
₪54.91
List Price:  ₪256.23
You save:  ₪201.32
₱843.86
List Price:  ₱3,937.46
You save:  ₱3,093.59
¥2,268.04
List Price:  ¥10,582.69
You save:  ¥8,314.65
MX$249.48
List Price:  MX$1,164.09
You save:  MX$914.60
QR54.82
List Price:  QR255.79
You save:  QR200.97
P205.97
List Price:  P961.07
You save:  P755.10
KSh1,972.50
List Price:  KSh9,203.68
You save:  KSh7,231.18
E£708.60
List Price:  E£3,306.33
You save:  E£2,597.73
ብር854.26
List Price:  ብር3,986
You save:  ብር3,131.73
Kz12,543.16
List Price:  Kz58,526.40
You save:  Kz45,983.24
CLP$14,705.10
List Price:  CLP$68,613.99
You save:  CLP$53,908.89
CN¥108.38
List Price:  CN¥505.72
You save:  CN¥397.34
RD$889.29
List Price:  RD$4,149.44
You save:  RD$3,260.15
DA2,020.69
List Price:  DA9,428.56
You save:  DA7,407.87
FJ$33.79
List Price:  FJ$157.67
You save:  FJ$123.88
Q117.28
List Price:  Q547.27
You save:  Q429.98
GY$3,148.46
List Price:  GY$14,690.75
You save:  GY$11,542.28
ISK kr2,072.85
List Price:  ISK kr9,671.91
You save:  ISK kr7,599.06
DH151.60
List Price:  DH707.37
You save:  DH555.76
L264.59
List Price:  L1,234.61
You save:  L970.01
ден851.63
List Price:  ден3,973.74
You save:  ден3,122.10
MOP$121.16
List Price:  MOP$565.34
You save:  MOP$444.17
N$284.42
List Price:  N$1,327.13
You save:  N$1,042.70
C$553.43
List Price:  C$2,582.33
You save:  C$2,028.90
रु2,003.88
List Price:  रु9,350.11
You save:  रु7,346.23
S/55.65
List Price:  S/259.70
You save:  S/204.04
K57.54
List Price:  K268.50
You save:  K210.96
SAR56.25
List Price:  SAR262.50
You save:  SAR206.24
ZK382.30
List Price:  ZK1,783.85
You save:  ZK1,401.54
L68.83
List Price:  L321.17
You save:  L252.33
Kč350.19
List Price:  Kč1,633.99
You save:  Kč1,283.80
Ft5,464.37
List Price:  Ft25,496.77
You save:  Ft20,032.39
SEK kr158.94
List Price:  SEK kr741.62
You save:  SEK kr582.68
ARS$12,851.24
List Price:  ARS$59,963.93
You save:  ARS$47,112.68
Bs104.27
List Price:  Bs486.54
You save:  Bs382.27
COP$58,456.94
List Price:  COP$272,760.10
You save:  COP$214,303.16
₡7,577.20
List Price:  ₡35,355.24
You save:  ₡27,778.03
L371.18
List Price:  L1,731.96
You save:  L1,360.77
₲110,506.83
List Price:  ₲515,624.88
You save:  ₲405,118.04
$U567.20
List Price:  $U2,646.58
You save:  $U2,079.38
zł59.73
List Price:  zł278.71
You save:  zł218.98
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.