android10 / android10/Android-CleanArchitecture

Models for list view item and detail view

Đang mở
#169 6 bình luận 0 reaction 0 người được giao Xem trên GitHub
discussion question
Ngôn ngữ chính
Java
Star
15.5k
Fork
3.3k
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

I'm fetching some data from 3rd party library to access their API.

For example, i created two use cases(FetchUserList and FetchUserDetail) to fetch user list and user detail.
The user list will be displayed in recycler view but only the user name part. And in user detail view, user name and company name will be displayed.

The model received from the server(API model, as in the library) as follow:

```
class User {
String name;
Int companyId;
...
}

class Company {
Int id;
String companyName;
...
}
```

What model should i create in my domain layer?

Should i create two models, one for the fetch user list use case and another one for fetch detail use case?

Seems the result model will be dictated by the view, in recycler view i don't need company name(exclude unnecessary data), but in the detail view i need to display more data.

I'm thinking something like below, but in the user list view case i do not need the `Company` data

```
class UserModel {
String name;
Company company;
}
```

What would you suggest?

Thank you.

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.