60 |
} |
} |
61 |
return response; |
return response; |
62 |
} |
} |
63 |
|
|
64 |
|
private void loadComments(String appId, MarketSession session, String locale, ArrayList<CommentBean> commentBeans) { |
65 |
|
CommentCallback commentsCb = new CommentCallback(); |
66 |
|
commentsCb.setList( commentBeans ); |
67 |
|
|
68 |
|
commentsCb.setLocale( locale ); |
69 |
|
session.setLocale( new Locale(locale) ); |
70 |
|
|
71 |
|
|
72 |
|
int start = 0; |
73 |
|
do { |
74 |
|
int count = 10; |
75 |
|
if (start > 0) |
76 |
|
count = Math.min(10, commentsCb.getEntryCount() ); |
77 |
|
|
78 |
|
log.warning("count=" + count + " start=" + start + " " + locale); |
79 |
|
CommentsRequest commentsRequest = CommentsRequest.newBuilder() |
80 |
|
.setAppId(appId) |
81 |
|
.setStartIndex(start) |
82 |
|
.setEntriesCount(count) |
83 |
|
.build(); |
84 |
|
|
85 |
|
session.append(commentsRequest, commentsCb); |
86 |
|
session.flush(); |
87 |
|
start +=10; |
88 |
|
|
89 |
|
if (start >= 30) |
90 |
|
break; //emergency brake |
91 |
|
|
92 |
|
} while ( start < commentsCb.getEntryCount() ); |
93 |
|
} |
94 |
|
|
95 |
|
|
96 |
protected String doLookupWorker(String appId) { |
protected String doLookupWorker(String appId) { |
107 |
.setWithExtendedInfo(true) |
.setWithExtendedInfo(true) |
108 |
.build(); |
.build(); |
109 |
|
|
|
CommentsRequest commentsRequest = CommentsRequest.newBuilder() |
|
|
.setAppId(appId) |
|
|
.setStartIndex(0) |
|
|
.setEntriesCount(10) |
|
|
.build(); |
|
|
|
|
|
|
|
110 |
|
|
111 |
|
AppsCallback appsCb = new AppsCallback() ; |
112 |
Callback<AppsResponse> appsCb = new Callback<AppsResponse>() { |
appsCb.setStringBuffer(sb); |
|
@Override |
|
|
public void onResult(ResponseContext context, AppsResponse response) { |
|
|
//System.out.println("Response : " + response); |
|
|
//sb.append("Response: " + response + "\n"); |
|
|
|
|
|
Formatter form = new Formatter(sb); |
|
|
App app = response.getApp(0); |
|
|
sb.append( "<h2>" + app.getTitle() + "</h2>"); |
|
|
sb.append("Ver: " + app.getVersion() + " (" + app.getVersionCode() + ")\n" ); |
|
|
sb.append("Ratingcount: " + app.getRatingsCount() + "\n"); |
|
|
|
|
|
sb.append("Rating: " ); |
|
|
double rating = Double.parseDouble( app.getRating() ); |
|
|
form.format("%.4f", rating); |
|
|
sb.append("\n"); |
|
|
|
|
|
sb.append("Downloads: " + app.getExtendedInfo().getDownloadsCountText() + " (" + app.getExtendedInfo().getDownloadsCount() + ")\n" ); |
|
|
|
|
|
sb.append("\n"); |
|
|
|
|
|
} |
|
|
}; |
|
113 |
|
|
114 |
ArrayList<CommentBean> commentBeans = new ArrayList<CommentBean>(); |
ArrayList<CommentBean> commentBeans = new ArrayList<CommentBean>(); |
115 |
|
|
|
CommentCallback commentsCb = new CommentCallback(); |
|
|
commentsCb.setList( commentBeans ); |
|
116 |
|
|
|
commentsCb.setLocale("en"); |
|
|
session.setLocale( Locale.ENGLISH ); |
|
117 |
|
|
118 |
session.append(appsRequest, appsCb); |
session.append(appsRequest, appsCb); |
|
session.append(commentsRequest, commentsCb); |
|
119 |
session.flush(); |
session.flush(); |
120 |
|
|
121 |
commentsCb.setLocale( "da" ); |
loadComments(appId, session, "da", commentBeans); |
122 |
session.setLocale( new Locale("da") ); |
loadComments(appId, session, "en", commentBeans); |
|
session.append(commentsRequest, commentsCb); |
|
|
session.flush(); |
|
123 |
|
|
124 |
Collections.sort(commentBeans); |
Collections.sort(commentBeans); |
125 |
|
|
132 |
sb.append("\n"); |
sb.append("\n"); |
133 |
|
|
134 |
} |
} |
135 |
|
sb.append("Comments: " + commentBeans.size() ); |
136 |
|
|
137 |
|
|
138 |
return sb.toString(); |
return sb.toString(); |