Skip to content

Commit 7656cf2

Browse files
author
Pawel Szymanski
committed
Merge branch 'develop'
2 parents cc7d6f3 + f71ad0d commit 7656cf2

14 files changed

Lines changed: 170 additions & 44 deletions

File tree

api/src/main/java/com/creatubbles/api/model/Meta.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import java.util.Date;
1010
import java.util.List;
1111

12+
import static java.util.Collections.emptyList;
1213
import static java.util.Collections.unmodifiableList;
1314

1415
public class Meta {
@@ -20,16 +21,16 @@ public class Meta {
2021
private Integer totalCount;
2122

2223
@JsonProperty("user_bubbled_creations")
23-
private List<String> userBubbledCreations;
24+
private List<String> userBubbledCreations = emptyList();
2425

2526
@JsonProperty("user_bubbled_users")
26-
private List<String> userBubbledUsers;
27+
private List<String> userBubbledUsers = emptyList();
2728

2829
@JsonProperty("user_bubbled_galleries")
29-
private List<String> userBubbledGalleries;
30+
private List<String> userBubbledGalleries = emptyList();
3031

3132
@JsonProperty("followed_users")
32-
private List<String> followedUsers;
33+
private List<String> followedUsers = emptyList();
3334

3435
@JsonProperty("total_unread_count")
3536
private Integer totalUnreadCount;
@@ -41,7 +42,7 @@ public class Meta {
4142
private Date lastViewedAt;
4243

4344
@JsonDeserialize(using = AbilitiesConverter.class)
44-
private List<Ability> abilities;
45+
private List<Ability> abilities = emptyList();
4546

4647
@Nullable
4748
public Integer getTotalPages() {

api/src/main/java/com/creatubbles/api/model/content/Content.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import com.creatubbles.api.model.ObjectType;
77
import com.creatubbles.api.model.creation.Creation;
88
import com.creatubbles.api.model.gallery.Gallery;
9+
import com.creatubbles.api.model.partner_application.PartnerApplication;
910
import com.creatubbles.api.model.user.User;
1011
import com.fasterxml.jackson.annotation.JsonCreator;
1112
import com.github.jasminb.jsonapi.annotations.Id;
@@ -33,6 +34,9 @@ public class Content {
3334
@Relationship("gallery")
3435
private Gallery gallery;
3536

37+
@Relationship("partner_application")
38+
private PartnerApplication partnerApplication;
39+
3640
@JsonCreator
3741
public Content() {
3842
super();
@@ -63,6 +67,11 @@ public Gallery getGallery() {
6367
return gallery;
6468
}
6569

70+
@Nullable
71+
public PartnerApplication getPartnerApplication() {
72+
return partnerApplication;
73+
}
74+
6675
@Override
6776
public String toString() {
6877
return "Content{" +
@@ -71,6 +80,7 @@ public String toString() {
7180
", creation=" + creation +
7281
", user=" + user +
7382
", gallery=" + gallery +
83+
", partnerApplication=" + partnerApplication +
7484
'}';
7585
}
7686
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package com.creatubbles.api.model.partner_application;
2+
3+
import android.support.annotation.NonNull;
4+
5+
import com.creatubbles.api.model.ImageLinks;
6+
7+
/**
8+
* @author Pawel Szymanski
9+
*/
10+
11+
public class Background {
12+
private ImageLinks links;
13+
14+
@NonNull
15+
public ImageLinks getLinks() {
16+
return links;
17+
}
18+
}

api/src/main/java/com/creatubbles/api/model/partner_application/PartnerApplication.java

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
import android.support.annotation.NonNull;
44
import android.support.annotation.Nullable;
55

6-
import com.creatubbles.api.model.ImageLinks;
76
import com.creatubbles.api.model.gallery.Gallery;
7+
import com.creatubbles.api.model.user.User;
88
import com.fasterxml.jackson.annotation.JsonProperty;
99
import com.github.jasminb.jsonapi.annotations.Id;
1010
import com.github.jasminb.jsonapi.annotations.Relationship;
@@ -16,7 +16,7 @@
1616
/**
1717
* @author Pawel Szymanski
1818
*/
19-
@Type("partner-applications")
19+
@Type("partner_applications")
2020
public class PartnerApplication {
2121

2222
@Id
@@ -30,10 +30,10 @@ public class PartnerApplication {
3030
private String shortUrl;
3131

3232
@JsonProperty("header_bg")
33-
private ImageLinks headerBg;
33+
private Background headerBg;
3434

3535
@JsonProperty("body_bg")
36-
private ImageLinks bodyBg;
36+
private Background bodyBg;
3737

3838
private String description;
3939

@@ -106,6 +106,9 @@ public class PartnerApplication {
106106
@Relationship("gallery")
107107
private Gallery gallery;
108108

109+
@Relationship("user")
110+
private User user;
111+
109112
@Relationship("related_apps")
110113
private List<PartnerApplication> relatedApps;
111114

@@ -133,12 +136,12 @@ public String getShortUrl() {
133136
}
134137

135138
@Nullable
136-
public ImageLinks getHeaderBg() {
139+
public Background getHeaderBg() {
137140
return headerBg;
138141
}
139142

140143
@Nullable
141-
public ImageLinks getBodyBg() {
144+
public Background getBodyBg() {
142145
return bodyBg;
143146
}
144147

@@ -270,6 +273,14 @@ public Gallery getGallery() {
270273
return gallery;
271274
}
272275

276+
/**
277+
* User profile of application owner
278+
*/
279+
@NonNull
280+
public User getUser() {
281+
return user;
282+
}
283+
273284
/**
274285
* Other apps from the same owner
275286
*/
@@ -318,6 +329,7 @@ public String toString() {
318329
", createdAt=" + createdAt +
319330
", updatedAt=" + updatedAt +
320331
", gallery=" + gallery +
332+
", user=" + user +
321333
", relatedApps=" + relatedApps +
322334
", appScreenshots=" + appScreenshots +
323335
'}';

api/src/main/java/com/creatubbles/api/repository/GalleryRepository.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ public interface GalleryRepository {
1919

2020
void getPublic(@Nullable Integer page, @Nullable GallerySortMode sort, @Nullable ResponseCallback<CreatubblesResponse<List<Gallery>>> callback);
2121

22+
void searchPublic(@NonNull String query, @Nullable Integer page, @Nullable GallerySortMode sort, @Nullable ResponseCallback<CreatubblesResponse<List<Gallery>>> callback);
23+
2224
/**
2325
* Get current user’s favorite galleries.
2426
*/

api/src/main/java/com/creatubbles/api/repository/GalleryRepositoryImpl.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,14 @@ class GalleryRepositoryImpl implements GalleryRepository {
3636
public void getPublic(@Nullable Integer page, @Nullable GallerySortMode sort,
3737
ResponseCallback<CreatubblesResponse<List<Gallery>>> callback) {
3838
String sortParam = sort != null ? sort.toString() : null;
39-
Call<JSONAPIDocument<List<Gallery>>> call = galleryService.getPublic(page, sortParam);
39+
Call<JSONAPIDocument<List<Gallery>>> call = galleryService.getPublic(null, page, sortParam);
40+
call.enqueue(new JsonApiResponseMapper<>(objectMapper, callback));
41+
}
42+
43+
@Override
44+
public void searchPublic(@NonNull String query, @Nullable Integer page, @Nullable GallerySortMode sort, @Nullable ResponseCallback<CreatubblesResponse<List<Gallery>>> callback) {
45+
String sortParam = sort != null ? sort.toString() : null;
46+
Call<JSONAPIDocument<List<Gallery>>> call = galleryService.getPublic(query, page, sortParam);
4047
call.enqueue(new JsonApiResponseMapper<>(objectMapper, callback));
4148
}
4249

api/src/main/java/com/creatubbles/api/repository/UserRepository.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,4 +137,9 @@ public interface UserRepository {
137137
* When changing manager's password you have to provide both new and current password.
138138
*/
139139
void changePassword(@NonNull String userId, @NonNull PasswordChange passwordChange, @Nullable ResponseCallback<CreatubblesResponse<User>> callback);
140+
141+
/**
142+
* Method used to obtain current user's 'My Connections' filtered by {@code query} param.
143+
*/
144+
void searchConnections(@NonNull String query, @Nullable Integer page, @Nullable UserSortMode sortMode, @Nullable ResponseCallback<CreatubblesResponse<List<User>>> callback);
140145
}

api/src/main/java/com/creatubbles/api/repository/UserRepositoryImpl.java

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -50,57 +50,49 @@ public void getUser(ResponseCallback<CreatubblesResponse<User>> callback) {
5050

5151
@Override
5252
public void getCreators(@Nullable Integer page, UserSortMode sortMode, ResponseCallback<CreatubblesResponse<List<User>>> callback) {
53-
String sort = sortMode != null ? sortMode.getParam() : null;
54-
Call<JSONAPIDocument<List<User>>> call = userService.getCreators(CURRENT_USER, page, sort);
53+
Call<JSONAPIDocument<List<User>>> call = userService.getCreators(CURRENT_USER, null, page, getSortParam(sortMode));
5554
call.enqueue(new JsonApiResponseMapper<>(objectMapper, callback));
5655
}
5756

5857
@Override
5958
public void getManagers(@Nullable Integer page, UserSortMode sortMode, ResponseCallback<CreatubblesResponse<List<User>>> callback) {
60-
String sort = sortMode != null ? sortMode.getParam() : null;
61-
Call<JSONAPIDocument<List<User>>> call = userService.getManagers(CURRENT_USER, page, sort);
59+
Call<JSONAPIDocument<List<User>>> call = userService.getManagers(CURRENT_USER, null, page, getSortParam(sortMode));
6260
call.enqueue(new JsonApiResponseMapper<>(objectMapper, callback));
6361
}
6462

6563
@Override
6664
public void getConnections(@Nullable Integer page, UserSortMode sortMode, ResponseCallback<CreatubblesResponse<List<User>>> callback) {
67-
String sort = sortMode != null ? sortMode.getParam() : null;
68-
Call<JSONAPIDocument<List<User>>> call = userService.getConnections(CURRENT_USER, page, sort);
65+
Call<JSONAPIDocument<List<User>>> call = userService.getConnections(CURRENT_USER, null, page, getSortParam(sortMode));
6966
call.enqueue(new JsonApiResponseMapper<>(objectMapper, callback));
7067
}
7168

7269
@Override
7370
public void getFollowedUsers(@Nullable Integer page, UserSortMode sortMode, ResponseCallback<CreatubblesResponse<List<User>>> callback) {
74-
String sort = sortMode != null ? sortMode.getParam() : null;
75-
Call<JSONAPIDocument<List<User>>> call = userService.getFollowedUsers(CURRENT_USER, page, sort);
71+
Call<JSONAPIDocument<List<User>>> call = userService.getFollowedUsers(CURRENT_USER, null, page, getSortParam(sortMode));
7672
call.enqueue(new JsonApiResponseMapper<>(objectMapper, callback));
7773
}
7874

7975
@Override
8076
public void getCreators(@NonNull String userId, @Nullable Integer page, UserSortMode sortMode, ResponseCallback<CreatubblesResponse<List<User>>> callback) {
81-
String sort = sortMode != null ? sortMode.getParam() : null;
82-
Call<JSONAPIDocument<List<User>>> call = userService.getCreators(userId, page, sort);
77+
Call<JSONAPIDocument<List<User>>> call = userService.getCreators(userId, null, page, getSortParam(sortMode));
8378
call.enqueue(new JsonApiResponseMapper<>(objectMapper, callback));
8479
}
8580

8681
@Override
8782
public void getManagers(@NonNull String userId, @Nullable Integer page, UserSortMode sortMode, ResponseCallback<CreatubblesResponse<List<User>>> callback) {
88-
String sort = sortMode != null ? sortMode.getParam() : null;
89-
Call<JSONAPIDocument<List<User>>> call = userService.getManagers(userId, page, sort);
83+
Call<JSONAPIDocument<List<User>>> call = userService.getManagers(userId, null, page, getSortParam(sortMode));
9084
call.enqueue(new JsonApiResponseMapper<>(objectMapper, callback));
9185
}
9286

9387
@Override
9488
public void getFollowedUsers(@NonNull String userId, @Nullable Integer page, UserSortMode sortMode, ResponseCallback<CreatubblesResponse<List<User>>> callback) {
95-
String sort = sortMode != null ? sortMode.getParam() : null;
96-
Call<JSONAPIDocument<List<User>>> call = userService.getFollowedUsers(userId, page, sort);
89+
Call<JSONAPIDocument<List<User>>> call = userService.getFollowedUsers(userId, null, page, getSortParam(sortMode));
9790
call.enqueue(new JsonApiResponseMapper<>(objectMapper, callback));
9891
}
9992

10093
@Override
10194
public void getConnections(@NonNull String userId, @Nullable Integer page, UserSortMode sortMode, ResponseCallback<CreatubblesResponse<List<User>>> callback) {
102-
String sort = sortMode != null ? sortMode.getParam() : null;
103-
Call<JSONAPIDocument<List<User>>> call = userService.getConnections(userId, page, sort);
95+
Call<JSONAPIDocument<List<User>>> call = userService.getConnections(userId, null, page, getSortParam(sortMode));
10496
call.enqueue(new JsonApiResponseMapper<>(objectMapper, callback));
10597
}
10698

@@ -159,4 +151,14 @@ public void changePassword(@NonNull String userId, @NonNull PasswordChange passw
159151
call.enqueue(new JsonApiResponseMapper<>(objectMapper, callback));
160152
}
161153

154+
@Override
155+
public void searchConnections(@NonNull String query, @Nullable Integer page, @Nullable UserSortMode sortMode, @Nullable ResponseCallback<CreatubblesResponse<List<User>>> callback) {
156+
Call<JSONAPIDocument<List<User>>> call = userService.getConnections(CURRENT_USER, query, page, getSortParam(sortMode));
157+
call.enqueue(new JsonApiResponseMapper<>(objectMapper, callback));
158+
}
159+
160+
private String getSortParam(UserSortMode sortMode) {
161+
return sortMode != null ? sortMode.getParam() : null;
162+
}
163+
162164
}

api/src/main/java/com/creatubbles/api/service/GalleryService.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,13 @@ public interface GalleryService {
2626
String PARAM_PAGE = "page";
2727
String PARAM_SORT = "sort";
2828
String PARAM_FILTER = "filter";
29+
String PARAM_QUERY = "query";
2930

3031
@GET(EndPoints.GALLERIES)
31-
Call<JSONAPIDocument<List<Gallery>>> getPublic(@Query(PARAM_PAGE) Integer page,
32+
Call<JSONAPIDocument<List<Gallery>>> getPublic(@Query(PARAM_QUERY) String query,
33+
@Query(PARAM_PAGE) Integer page,
3234
@Query(PARAM_SORT) String sort);
3335

34-
3536
@GET(EndPoints.USERS + PATH_ID_GALLERIES)
3637
Call<JSONAPIDocument<List<Gallery>>> getByUser(@Path(PARAM_ID) String userId,
3738
@Query(PARAM_PAGE) Integer page,

api/src/main/java/com/creatubbles/api/service/UserService.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,22 +32,24 @@ public interface UserService {
3232

3333
String PARAM_ID = "id";
3434
String PARAM_PAGE = "page";
35+
String PARAM_QUERY = "query";
36+
String PARAM_SORT = "sort";
3537
String PATH_ID = "{" + PARAM_ID + "}";
3638

3739
@GET(EndPoints.USERS + "/" + PATH_ID)
3840
Call<JSONAPIDocument<User>> getUserById(@Path(PARAM_ID) String id);
3941

4042
@GET(EndPoints.USERS + "/" + PATH_ID + "/creators")
41-
Call<JSONAPIDocument<List<User>>> getCreators(@Path(PARAM_ID) String id, @Query(PARAM_PAGE) Integer page, @Query("sort") String sort);
43+
Call<JSONAPIDocument<List<User>>> getCreators(@Path(PARAM_ID) String id, @Query(PARAM_QUERY) String query, @Query(PARAM_PAGE) Integer page, @Query(PARAM_SORT) String sort);
4244

4345
@GET(EndPoints.USERS + "/" + PATH_ID + "/managers")
44-
Call<JSONAPIDocument<List<User>>> getManagers(@Path(PARAM_ID) String id, @Query(PARAM_PAGE) Integer page, @Query("sort") String sort);
46+
Call<JSONAPIDocument<List<User>>> getManagers(@Path(PARAM_ID) String id, @Query(PARAM_QUERY) String query, @Query(PARAM_PAGE) Integer page, @Query(PARAM_SORT) String sort);
4547

4648
@GET(EndPoints.USERS + "/" + PATH_ID + "/connected_users")
47-
Call<JSONAPIDocument<List<User>>> getConnections(@Path(PARAM_ID) String id, @Query(PARAM_PAGE) Integer page, @Query("sort") String sort);
49+
Call<JSONAPIDocument<List<User>>> getConnections(@Path(PARAM_ID) String id, @Query(PARAM_QUERY) String query, @Query(PARAM_PAGE) Integer page, @Query(PARAM_SORT) String sort);
4850

4951
@GET(EndPoints.USERS + "/" + PATH_ID + "/followed_users")
50-
Call<JSONAPIDocument<List<User>>> getFollowedUsers(@Path(PARAM_ID) String id, @Query(PARAM_PAGE) Integer page, @Query("sort") String sort);
52+
Call<JSONAPIDocument<List<User>>> getFollowedUsers(@Path(PARAM_ID) String id, @Query(PARAM_QUERY) String query, @Query(PARAM_PAGE) Integer page, @Query(PARAM_SORT) String sort);
5153

5254
@POST(EndPoints.CREATORS)
5355
Call<JSONAPIDocument<User>> createUser(@Body NewUser newUser);

0 commit comments

Comments
 (0)