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.40
List Price:  €67.23
You save:  €52.82
£11.74
List Price:  £54.79
You save:  £43.05
CA$21.49
List Price:  CA$100.29
You save:  CA$78.79
A$24.02
List Price:  A$112.09
You save:  A$88.06
S$20.25
List Price:  S$94.52
You save:  S$74.26
HK$116.56
List Price:  HK$543.88
You save:  HK$427.31
CHF 13.27
List Price:  CHF 61.94
You save:  CHF 48.66
NOK kr169.03
List Price:  NOK kr788.73
You save:  NOK kr619.69
DKK kr107.59
List Price:  DKK kr502.03
You save:  DKK kr394.44
NZ$26.53
List Price:  NZ$123.81
You save:  NZ$97.27
د.إ55.09
List Price:  د.إ257.07
You save:  د.إ201.97
৳1,789.65
List Price:  ৳8,350.53
You save:  ৳6,560.87
₹1,280.96
List Price:  ₹5,977
You save:  ₹4,696.03
RM67.30
List Price:  RM314.04
You save:  RM246.74
₦23,183.99
List Price:  ₦108,176.53
You save:  ₦84,992.53
₨4,169.33
List Price:  ₨19,454.09
You save:  ₨15,284.76
฿512.55
List Price:  ฿2,391.55
You save:  ฿1,879
₺527.92
List Price:  ₺2,463.31
You save:  ₺1,935.38
B$95.64
List Price:  B$446.27
You save:  B$350.63
R281.25
List Price:  R1,312.34
You save:  R1,031.08
Лв28.20
List Price:  Лв131.59
You save:  Лв103.39
₩21,858.89
List Price:  ₩101,993.60
You save:  ₩80,134.70
₪54.74
List Price:  ₪255.42
You save:  ₪200.68
₱879.90
List Price:  ₱4,105.61
You save:  ₱3,225.71
¥2,357.62
List Price:  ¥11,000.67
You save:  ¥8,643.05
MX$302.46
List Price:  MX$1,411.29
You save:  MX$1,108.82
QR54.46
List Price:  QR254.14
You save:  QR199.67
P207.99
List Price:  P970.50
You save:  P762.51
KSh1,935.60
List Price:  KSh9,031.50
You save:  KSh7,095.90
E£762.51
List Price:  E£3,557.88
You save:  E£2,795.37
ብር1,906.82
List Price:  ብር8,897.26
You save:  ብር6,990.43
Kz13,680
List Price:  Kz63,830.88
You save:  Kz50,150.88
CLP$14,839.35
List Price:  CLP$69,240.40
You save:  CLP$54,401.05
CN¥109.48
List Price:  CN¥510.85
You save:  CN¥401.37
RD$912.26
List Price:  RD$4,256.60
You save:  RD$3,344.34
DA2,026.51
List Price:  DA9,455.74
You save:  DA7,429.22
FJ$34.77
List Price:  FJ$162.28
You save:  FJ$127.50
Q115.35
List Price:  Q538.26
You save:  Q422.90
GY$3,133.26
List Price:  GY$14,619.81
You save:  GY$11,486.55
ISK kr2,093.25
List Price:  ISK kr9,767.10
You save:  ISK kr7,673.85
DH151.02
List Price:  DH704.68
You save:  DH553.66
L276.31
List Price:  L1,289.28
You save:  L1,012.96
ден886.39
List Price:  ден4,135.94
You save:  ден3,249.54
MOP$119.80
List Price:  MOP$559.01
You save:  MOP$439.21
N$278.46
List Price:  N$1,299.34
You save:  N$1,020.87
C$551.07
List Price:  C$2,571.30
You save:  C$2,020.23
रु2,039.66
List Price:  रु9,517.06
You save:  रु7,477.40
S/55.76
List Price:  S/260.20
You save:  S/204.44
K60.78
List Price:  K283.61
You save:  K222.83
SAR56.32
List Price:  SAR262.82
You save:  SAR206.49
ZK414.46
List Price:  ZK1,933.89
You save:  ZK1,519.42
L71.76
List Price:  L334.85
You save:  L263.08
Kč362.72
List Price:  Kč1,692.49
You save:  Kč1,329.76
Ft5,922.40
List Price:  Ft27,633.93
You save:  Ft21,711.52
SEK kr163.23
List Price:  SEK kr761.65
You save:  SEK kr598.41
ARS$15,406.31
List Price:  ARS$71,885.87
You save:  ARS$56,479.55
Bs103.48
List Price:  Bs482.86
You save:  Bs379.38
COP$66,192.11
List Price:  COP$308,852.42
You save:  COP$242,660.30
₡7,604.09
List Price:  ₡35,480.70
You save:  ₡27,876.60
L380.50
List Price:  L1,775.44
You save:  L1,394.93
₲116,798.31
List Price:  ₲544,980.94
You save:  ₲428,182.62
$U666.61
List Price:  $U3,110.44
You save:  $U2,443.82
zł61.41
List Price:  zł286.56
You save:  zł225.15
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.