The problem is that you did put your code directly in the class and not inside a member like a constructor:
public partial class App : Application
{
public App()
{
HarvestApp.GoogleAPIManager GAPImanager = new HarvestApp.GoogleAPIManager();
List<Event>todayCalendar = GAPImanager.GetCalendarEventsForDate(DateTime.Today);
HarvestApp.HarvestManager HAPIManager = new HarvestApp.HarvestManager();
Console.WriteLine("Entries found for Today :" + todayCalendar.Count);
foreach(Event todayEvent in todayCalendar)
{
var addEvent = new HarvestApp.Harvest_TimeSheetEntry(todayEvent);
EntryList.Add(addEvent);
HAPIManager.postHarvestEntry(addEvent);
}
}
}
When you say "This code is working with this payload:... but not with this one:..." that's expected and that's how it's suppose to work. In fact the error message tells you that while converting the json to a java object the call expected an array in the json but got an object instead.
This call:
@GET("Music")
Call<List<Music>> getMusicList();
expects a list of Music
objects, that's why it works with the json:
[
{
"login": "JakeWharton",
...
},
...
]
Because the json itself is an array of your Music
objects (Retrofit can convert between json arrays to java lists). For the second json you have just an object and not an array (notice the lack of [...]
). For this you need to create another call with another model that maps to that json. Let's assume you've named the model MusicList
. Here's how the call could look like:
@GET("Music")
Call<MusicList> getMusicList();
(Note that you might need to change the method name if you want to keep both the first call and this one).
The MusicList
model can look something like this:
public class MusicList {
@SerializedName("data")
private List<Music> musics;
// ...
}
I'm assuming that the data
array is a list of Music
objects, but I did notice that the jsons are completely different. You might need to adapt this as well, but I think you get the picture here.
Best Answer
We can create an attribute directive which accepts the color value and override default styles of
<mat-progress-bar>
for us.here is a working demo : https://stackblitz.com/edit/material-progress-bar-color-directive
here is a brief explanation:
If we inspect
<mat-progress-bar>
in developer tools. we will find that color of the progress-bar is defined in the::after
pseudo element like this.And as we already know that it is not possible to directly manipulate a pseudo element using DOM querySelector() method. But we can add new styles which can have rules for pseudo elements too. checkout this thread for more details. https://stackoverflow.com/a/21709814/1160236
So, we can make a directive which can take care of adding new styles for us.
as you can see that all that we are doing here is just making a new
HtmlStyleElement
and adding it just inside the host element.And inside
updateColor()
method we are updating theinnerText
of the style tag we have appended. notice that we are using an attribute selector here with a unique attribute to minimize the scope of the style to the host only. because we want to override the style only for that progress-bar on which we have applied our directive.you can use this directive in your template like this.
I hope this will help.