/[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 949 by torben, Tue May 4 03:48:37 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;
         private String appId = null;  
   
         public void setStringBuffer(StringBuilder s) {  
                 sb = s;  
         }  
13                    
14          public String getAppId() {          public AppBean getResult() {
15                  return appId;                  return result;
16          }          }
   
   
         @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();  
17                    
18                          Formatter form = new Formatter(sb);          @Override
19            public void onResult(ResponseContext cntxt, AppsResponse apps) {
20                    if (apps.getAppCount() == 1) {
21                            NumberFormat form = NumberFormat.getNumberInstance();
22                            form.setMinimumFractionDigits(4);
23                            form.setMaximumFractionDigits(4);
24                                                    
25                                                    
26                          sb.append( "<h2>" + app.getTitle() + "</h2>");                          App app = apps.getApp(0);
27                          sb.append("Ver: " + app.getVersion() + " (" + app.getVersionCode() + ")\n"  );                          
28                          sb.append("Ratingcount: " + app.getRatingsCount() + "\n");                          
29                                    result = new AppBean();
30                          sb.append("Rating: "  );                          result.id = app.getId();
31                            result.title = app.getTitle();
32                            result.version = app.getVersion();
33                            result.versionCode = app.getVersionCode();
34                            result.downloadsCount = app.getExtendedInfo().getDownloadsCount();
35                            result.downloadsCountText = app.getExtendedInfo().getDownloadsCountText();
36                            
37                            result.ratingsCount = app.getRatingsCount();
38                          double rating = Double.parseDouble( app.getRating() );                          double rating = Double.parseDouble( app.getRating() );
39                          form.format("%.4f", rating);                          result.rating = form.format(rating);
                         sb.append("\n");  
           
                         sb.append("Downloads: " + app.getExtendedInfo().getDownloadsCountText() + " (" + app.getExtendedInfo().getDownloadsCount() + ")\n" );  
           
                         sb.append("\n");  
                 } else {  
                         sb.append("<h2>Application not found</h2>");  
40                  }                  }
   
41          }          }
42    
43    
44  }  }
45    

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

  ViewVC Help
Powered by ViewVC 1.1.20