--- android/MarketStats/src/dk/thoerup/marketstats/AppsCallback.java 2010/08/10 07:01:40 1013 +++ android/MarketStats/src/dk/thoerup/marketstats/AppsCallback.java 2010/08/12 09:25:52 1014 @@ -1,7 +1,8 @@ package dk.thoerup.marketstats; import java.text.NumberFormat; -import java.util.Formatter; +import java.util.ArrayList; +import java.util.List; import com.gc.android.market.api.MarketSession.Callback; import com.gc.android.market.api.model.Market.App; @@ -9,34 +10,37 @@ import com.gc.android.market.api.model.Market.ResponseContext; public class AppsCallback implements Callback{ - private AppBean result = null; + private List result = new ArrayList(); - public AppBean getResult() { + public List getResult() { return result; } @Override public void onResult(ResponseContext cntxt, AppsResponse apps) { - if (apps.getAppCount() == 1) { - NumberFormat form = NumberFormat.getNumberInstance(); - form.setMinimumFractionDigits(4); - form.setMaximumFractionDigits(4); + + NumberFormat form = NumberFormat.getNumberInstance(); + form.setMinimumFractionDigits(4); + form.setMaximumFractionDigits(4); + + for (App app : apps.getAppList()) { + - App app = apps.getApp(0); + AppBean appBean= new AppBean(); + appBean.packageName = app.getPackageName(); + appBean.id = app.getId(); + appBean.title = app.getTitle(); + appBean.version = app.getVersion(); + appBean.versionCode = app.getVersionCode(); + appBean.downloadsCount = app.getExtendedInfo().getDownloadsCount(); + appBean.downloadsCountText = app.getExtendedInfo().getDownloadsCountText(); - - 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(); + appBean.ratingsCount = app.getRatingsCount(); double rating = Double.parseDouble( app.getRating() ); - result.rating = form.format(rating); + appBean.rating = form.format(rating); + + result.add(appBean); } }