/[projects]/android/MarketStats/src/dk/thoerup/marketstats/AppsCallback.java
ViewVC logotype

Diff of /android/MarketStats/src/dk/thoerup/marketstats/AppsCallback.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 665 by torben, Fri Apr 23 15:26:21 2010 UTC revision 1015 by torben, Thu Aug 12 09:52:03 2010 UTC
# Line 1  Line 1 
1  package dk.thoerup.marketstats;  package dk.thoerup.marketstats;
2    
3  import java.util.Formatter;  import java.text.NumberFormat;
4    import java.util.ArrayList;
5    import java.util.List;
6    
7  import com.gc.android.market.api.MarketSession.Callback;  import com.gc.android.market.api.MarketSession.Callback;
8  import com.gc.android.market.api.model.Market.App;  import com.gc.android.market.api.model.Market.App;
# Line 8  import com.gc.android.market.api.model.M Line 10  import com.gc.android.market.api.model.M
10  import com.gc.android.market.api.model.Market.ResponseContext;  import com.gc.android.market.api.model.Market.ResponseContext;
11    
12  public class AppsCallback implements Callback<AppsResponse>{  public class AppsCallback implements Callback<AppsResponse>{
13          private StringBuilder sb;          private List<AppBean> result = new ArrayList<AppBean>();
14            
15          public void setStringBuffer(StringBuilder s) {          public List<AppBean> getResult() {
16                  sb = s;                  return result;
17          }          }
18            
   
19          @Override          @Override
20          public void onResult(ResponseContext context, AppsResponse response) {          public void onResult(ResponseContext cntxt, AppsResponse apps) {
21                  //System.out.println("Response : " + response);                  
22                  //sb.append("Response: " + response + "\n");                  NumberFormat form = NumberFormat.getNumberInstance();
23                    form.setMinimumFractionDigits(4);
24                  Formatter form = new Formatter(sb);                  form.setMaximumFractionDigits(4);
25                  App app = response.getApp(0);                          
26                  sb.append( "<h2>" + app.getTitle() + "</h2>");                  
27                  sb.append("Ver: " + app.getVersion() + " (" + app.getVersionCode() + ")\n"  );                  for (App app : apps.getAppList()) {    
28                  sb.append("Ratingcount: " + app.getRatingsCount() + "\n");                                                  
29                            
30                  sb.append("Rating: "  );                          AppBean appBean= new AppBean();
31                  double rating = Double.parseDouble( app.getRating() );                          appBean.packageName = app.getPackageName();
32                  form.format("%.4f", rating);                          appBean.creator = app.getCreator();
33                  sb.append("\n");                          
34                            appBean.id = app.getId();
35                  sb.append("Downloads: " + app.getExtendedInfo().getDownloadsCountText() + " (" + app.getExtendedInfo().getDownloadsCount() + ")\n" );                          appBean.title = app.getTitle();
36                            appBean.version = app.getVersion();
37                  sb.append("\n");                          appBean.versionCode = app.getVersionCode();
38                            
39                            appBean.downloadsCount = app.getExtendedInfo().getDownloadsCount();
40                            appBean.downloadsCountText = app.getExtendedInfo().getDownloadsCountText();
41                            appBean.website = (app.getExtendedInfo().hasContactWebsite() ) ? app.getExtendedInfo().getContactWebsite() : "";
42                            appBean.description = app.getExtendedInfo().getDescription();
43                            
44                            appBean.ratingsCount = app.getRatingsCount();
45                            double rating = Double.parseDouble( app.getRating() );
46                            appBean.rating = form.format(rating);
47                            
48                            result.add(appBean);
49                    }
50          }          }
51    
52    
53  }  }
54    

Legend:
Removed from v.665  
changed lines
  Added in v.1015

  ViewVC Help
Powered by ViewVC 1.1.20