Skip to content

Commit 6454aa6

Browse files
committed
model class extended.
1 parent 65b5bd3 commit 6454aa6

File tree

2 files changed

+98
-18
lines changed

2 files changed

+98
-18
lines changed
Lines changed: 86 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package io.syslogic.github.model;
22

33
import androidx.annotation.NonNull;
4-
import androidx.annotation.Nullable;
54

65
import com.google.gson.annotations.SerializedName;
76

@@ -12,27 +11,104 @@
1211
*/
1312
public class Workflow {
1413

14+
@SerializedName("id")
15+
private long id;
16+
17+
@SerializedName("node_id")
18+
private String nodeId;
19+
1520
@SerializedName("name")
1621
private String name;
1722

18-
@SerializedName("jobs") // ?
19-
private WorkflowJobs jobs;
23+
@SerializedName("path")
24+
private String path;
25+
26+
@SerializedName("state")
27+
private String state;
28+
29+
@SerializedName("created_at")
30+
private String createdAt;
31+
32+
@SerializedName("updated_at")
33+
private String updatedAt;
2034

35+
@SerializedName("url")
36+
private String url;
37+
38+
@SerializedName("html_url")
39+
private String htmlUrl;
40+
41+
@SerializedName("badge_url")
42+
private String badgeUrl;
43+
44+
public void setId(long value) {
45+
this.id = value;
46+
}
47+
public void setNodeId(@NonNull String value) {
48+
this.nodeId = value;
49+
}
2150
public void setName(@NonNull String value) {
2251
this.name = value;
2352
}
24-
25-
public void setJobs(@NonNull WorkflowJobs value) {
26-
this.jobs = value;
53+
public void setPath(@NonNull String value) {
54+
this.path = value;
55+
}
56+
public void setState(@NonNull String value) {
57+
this.state = value;
58+
}
59+
public void setCreatedAt(@NonNull String value) {
60+
this.createdAt = value;
61+
}
62+
public void setUpdatedAt(@NonNull String value) {
63+
this.updatedAt = value;
64+
}
65+
public void setUrl(@NonNull String value) {
66+
this.url = value;
67+
}
68+
public void setHtmlUrl(@NonNull String value) {
69+
this.htmlUrl = value;
70+
}
71+
public void setBadgeUrl(@NonNull String value) {
72+
this.badgeUrl = value;
2773
}
2874

75+
public long getId() {
76+
return this.id;
77+
}
78+
@NonNull
79+
public String getNodeId() {
80+
return this.nodeId;
81+
}
2982
@NonNull
3083
public String getName() {
3184
return this.name;
3285
}
33-
34-
@Nullable
35-
public WorkflowJobs getJobs() {
36-
return this.jobs;
86+
@NonNull
87+
public String getPath() {
88+
return this.path;
89+
}
90+
@NonNull
91+
public String getState() {
92+
return this.state;
93+
}
94+
@NonNull
95+
public String getCreatedAt() {
96+
return this.createdAt;
97+
}
98+
@NonNull
99+
public String getUpdatedAt() {
100+
return this.updatedAt;
101+
}
102+
@NonNull
103+
public String getUrl() {
104+
return this.url;
105+
}
106+
@NonNull
107+
public String getHtmlUrl() {
108+
return this.htmlUrl;
109+
}
110+
@NonNull
111+
public String getBadgeUrl() {
112+
return this.badgeUrl;
37113
}
38114
}

mobile/src/main/java/io/syslogic/github/recyclerview/RepositoriesAdapter.java

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
import io.syslogic.github.Constants;
3232
import io.syslogic.github.R;
3333
import io.syslogic.github.activity.BaseActivity;
34-
import io.syslogic.github.databinding.CardviewRepositorySearchBinding;
3534
import io.syslogic.github.databinding.CardviewWorkflowBinding;
3635
import io.syslogic.github.databinding.FragmentRepositoriesBinding;
3736
import io.syslogic.github.model.Repository;
@@ -114,20 +113,28 @@ public void onResponse(@NonNull Call<ArrayList<Repository>> call, @NonNull Respo
114113
if (response.code() == 200) { // OK
115114
if (response.body() != null) {
116115

116+
/* Updating the adapter with the initial response already. */
117117
ArrayList<Repository> items = response.body();
118+
getItems().addAll(items);
119+
notifyItemRangeChanged(positionStart, getItemCount());
120+
118121
for (Repository item : items) {
119122

120123
Call<WorkflowsResponse> api2 = GithubClient.getWorkflows(accessToken, username,item.getName());
121-
// if (BuildConfig.DEBUG) {Log.w(LOG_TAG, api2.request().url() + "");}
124+
if (BuildConfig.DEBUG) {Log.w(LOG_TAG, api2.request().url() + "");}
125+
122126
api2.enqueue(new Callback<>() {
123127
@Override
124128
public void onResponse(@NonNull Call<WorkflowsResponse> call, @NonNull Response<WorkflowsResponse> response) {
125129
if (response.code() == 200) { // OK
126130
if (response.body() != null) {
127131
WorkflowsResponse items = response.body();
128-
assert items.getWorkflows() != null;
129-
for (Workflow item : items.getWorkflows()) {
130-
if (BuildConfig.DEBUG) {Log.d(LOG_TAG, "has workflow: " + item.getName());}
132+
if (BuildConfig.DEBUG) {
133+
if (items.getWorkflows() != null && items.getWorkflows().size() > 0) {
134+
for (Workflow item2 : items.getWorkflows()) {
135+
Log.d(LOG_TAG, "has workflows: " + item2.getName());
136+
}
137+
}
131138
}
132139
}
133140
} else {
@@ -144,9 +151,6 @@ public void onFailure(@NonNull Call<WorkflowsResponse> call, @NonNull Throwable
144151
}
145152
});
146153
}
147-
148-
getItems().addAll(items);
149-
notifyItemRangeChanged(positionStart, getItemCount());
150154
}
151155
} else {
152156
/* "bad credentials" means that the provided access-token is invalid. */

0 commit comments

Comments
 (0)