RecyclerView only show one element
There is not listview in more modern Android SDK. The replacement of this is RecyclerView, that is more flexible, you can set the layout manager, such as LinearLayoutManager or GridLayoutManager, even you can build your own. But that is more powerful, then that is harder to use. The first program I built, I found it only shows the first element. Then I found in the layout resource file of list adapter, the root element cannot set the height to be "match_parent", if you set "match_parent", the first element will be occupied the whole list, then no room for another elements. So the solution is to the height to be the fixed value or "wrap_content.
Android Orm - Room
There are a lot of ORM for Android. Previously, I have used Ormlite. That is quite good. I got a new personal project of Android App. This is a good to look around new framework I can use. I found Google has their ORM layer. That is not form the standard SDK. This ORM is from the Android Architecture Components. That is quite modern, and similar with others. It used annotations like this to define the mapping
Code
@Entity(tableName = "people") | |
public class Person { | |
@PrimaryKey(autoGenerate = true) | |
public int id; | |
public String name; | |
| |
public int eventId; | |
} |
But the Dao is a strange
public interface DrawingEventDao {
@Query("SELECT * FROM drawEvents")
List loadAll();
}
Because it is a ORM of sqlite. You still need to write the SQL like this. That is the things I do not really like. Maybe I have been LINQ for too long. That is not easy to go back the SQL. But that is still much better than connecting with Sqlite
Local DB for a small application in C#
I got some old applications which is using spring.net and nhibernation with sqlite. By these names, you can know those frameworks are very old. That is the time to modernize them. I have research some local database solution. You can use System.data.sqlite, that is very light weight, but that is a plain sql without ORM. Or you can use MSSQLLocalDB with entity framework. But the SQL Express is still required. Finally, I found liteDB. This is a local NoSQL framework. You can add a single DLL into your project, not even simpler, just use Nuget to install it. The code syntax is similar with MongoDB.
Moreover, it has GUI tool LiteDB Studio, you can query the db file. Lastly, I checked the latest git commit is only 4 hours only. The project keeps to be active
Angular CLI time out in .Net Core Project
I created the first project in Visual Studio 2019 in Mac. I have no problems, but when I tried to run it in my Windows box. But I got a runtime error for Angular CLI Timeout. I got exact same code of mac version. There should be no problems. After some investigations, because my windows box is old, that is a five year old laptop. Although mac book pro is 6 year old too, but that is still running better than my windows box. Thus, the angular CLI still can compile the client front end within the default angular cli timeout amount. Therefore, I just need to increase the timeout for Angular CLI. Then I tried it, to increase the timeout of Angular CLI, you need to change startup.cs at the root level of project. please add this line of code after spa.UseAngularCliServer(npmScript: "start"); (should be line 70)
spa.Options.StartupTimeout = TimeSpan.FromSeconds(500);
Then my project is working
Authentication for Angular .Net Core Project
I have used Angular since .Net Core 2.2. In the past, I still can use identity framework core but you have to link the Angular with your api by yourself, you need to jwt serialization. But in the .net Core 3 with Visual Studio 2019, you need to create the angular project with by selecting the individual user account. Then the basic identity framework core structure will be generated for you. The user login and registration user page are generated. That is so easy and saved at least an hour work for me too!