--- android/MarketStats/src/dk/thoerup/marketstats/AppsCallback.java 2010/07/05 06:17:05 949 +++ android/MarketStats/src/dk/thoerup/marketstats/AppsCallback.java 2010/07/05 08:18:02 950 @@ -1,5 +1,6 @@ package dk.thoerup.marketstats; +import java.text.NumberFormat; import java.util.Formatter; import com.gc.android.market.api.MarketSession.Callback; @@ -8,48 +9,37 @@ import com.gc.android.market.api.model.Market.ResponseContext; public class AppsCallback implements Callback{ - private StringBuilder sb; - private String appId = null; - - public void setStringBuffer(StringBuilder s) { - sb = s; - } + private AppBean result = null; - public String getAppId() { - return appId; + public AppBean getResult() { + return result; } - - - @Override - public void onResult(ResponseContext context, AppsResponse response) { - //System.out.println("Response : " + response); - //sb.append("Response: " + response + "\n"); - - if (response.getAppCount() == 1 ) { - - App app = response.getApp(0); - appId = app.getId(); - Formatter form = new Formatter(sb); + @Override + public void onResult(ResponseContext cntxt, AppsResponse apps) { + if (apps.getAppCount() == 1) { + NumberFormat form = NumberFormat.getNumberInstance(); + form.setMinimumFractionDigits(4); + form.setMaximumFractionDigits(4); - sb.append( "

" + app.getTitle() + "

"); - sb.append("Ver: " + app.getVersion() + " (" + app.getVersionCode() + ")\n" ); - sb.append("Ratingcount: " + app.getRatingsCount() + "\n"); - - sb.append("Rating: " ); + App app = apps.getApp(0); + + + result = new AppBean(); + result.id = app.getId(); + result.title = app.getTitle(); + result.version = app.getVersion(); + result.versionCode = app.getVersionCode(); + result.downloadsCount = app.getExtendedInfo().getDownloadsCount(); + result.downloadsCountText = app.getExtendedInfo().getDownloadsCountText(); + + result.ratingsCount = app.getRatingsCount(); 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"); - } else { - sb.append("

Application not found

"); + result.rating = form.format(rating); } - } } +