/[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 950 by torben, Mon Jul 5 08:18:02 2010 UTC
# Line 1  Line 1 
1  package dk.thoerup.marketstats;  package dk.thoerup.marketstats;
2    
3    import java.text.NumberFormat;
4  import java.util.Formatter;  import java.util.Formatter;
5    
6  import com.gc.android.market.api.MarketSession.Callback;  import com.gc.android.market.api.MarketSession.Callback;
# Line 8  import com.gc.android.market.api.model.M Line 9  import com.gc.android.market.api.model.M
9  import com.gc.android.market.api.model.Market.ResponseContext;  import com.gc.android.market.api.model.Market.ResponseContext;
10    
11  public class AppsCallback implements Callback<AppsResponse>{  public class AppsCallback implements Callback<AppsResponse>{
12          private StringBuilder sb;          private AppBean result = null;
13            
14          public void setStringBuffer(StringBuilder s) {          public AppBean getResult() {
15                  sb = s;                  return result;
16          }          }
17            
   
18          @Override          @Override
19          public void onResult(ResponseContext context, AppsResponse response) {          public void onResult(ResponseContext cntxt, AppsResponse apps) {
20                  //System.out.println("Response : " + response);                  if (apps.getAppCount() == 1) {
21                  //sb.append("Response: " + response + "\n");                          NumberFormat form = NumberFormat.getNumberInstance();
22                            form.setMinimumFractionDigits(4);
23                  Formatter form = new Formatter(sb);                          form.setMaximumFractionDigits(4);
24                  App app = response.getApp(0);                          
25                  sb.append( "<h2>" + app.getTitle() + "</h2>");                          
26                  sb.append("Ver: " + app.getVersion() + " (" + app.getVersionCode() + ")\n"  );                          App app = apps.getApp(0);
27                  sb.append("Ratingcount: " + app.getRatingsCount() + "\n");                          
28                            
29                  sb.append("Rating: "  );                          result = new AppBean();
30                  double rating = Double.parseDouble( app.getRating() );                          result.id = app.getId();
31                  form.format("%.4f", rating);                          result.title = app.getTitle();
32                  sb.append("\n");                          result.version = app.getVersion();
33                            result.versionCode = app.getVersionCode();
34                  sb.append("Downloads: " + app.getExtendedInfo().getDownloadsCountText() + " (" + app.getExtendedInfo().getDownloadsCount() + ")\n" );                          result.downloadsCount = app.getExtendedInfo().getDownloadsCount();
35                            result.downloadsCountText = app.getExtendedInfo().getDownloadsCountText();
36                  sb.append("\n");                          
37                            result.ratingsCount = app.getRatingsCount();
38                            double rating = Double.parseDouble( app.getRating() );
39                            result.rating = form.format(rating);
40                    }
41          }          }
42    
43    
44  }  }
45    

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

  ViewVC Help
Powered by ViewVC 1.1.20