From 7ebfcbb06050d0fac0b96491756d6d17170de4bb Mon Sep 17 00:00:00 2001 From: Matias Waisgold Date: Thu, 27 Aug 2015 17:30:22 +0200 Subject: [PATCH] Send through bidders configuration so that it's available everywhere and reenables notifications --- .../com/bidtorrent/bidding/AuctionResult.java | 40 ++++++------- .../com/bidtorrent/bidding/Auctioneer.java | 50 +++++++---------- .../bidtorrent/bidding/ConstantBidder.java | 8 ++- .../com/bidtorrent/bidding/HttpBidder.java | 56 ++++++++----------- .../java/com/bidtorrent/bidding/IBidder.java | 3 +- .../com/bidtorrent/bidding/Notificator.java | 11 ---- .../bidding/messages/BidResponse.java | 12 ++++ .../messages/ContextualizedBidResponse.java | 29 ++++++++++ .../configuration/BidderConfiguration.java | 5 +- .../BidderConfigurationFilters.java | 3 +- biddingservice/biddingservice.iml | 2 +- biddingservice/build.gradle | 4 +- .../biddingservice/BiddingIntentService.java | 6 +- .../actions/NotificationsAction.java | 10 ++-- .../biddingservice/debug/ListViewAdapter.java | 11 ++-- .../functions/TriggerBidFunction.java | 6 +- .../receivers/CreativeDisplayReceiver.java | 10 +--- 17 files changed, 129 insertions(+), 137 deletions(-) create mode 100755 bidding/src/main/java/com/bidtorrent/bidding/messages/ContextualizedBidResponse.java mode change 100644 => 100755 bidding/src/main/java/com/bidtorrent/bidding/messages/configuration/BidderConfiguration.java mode change 100644 => 100755 bidding/src/main/java/com/bidtorrent/bidding/messages/configuration/BidderConfigurationFilters.java diff --git a/bidding/src/main/java/com/bidtorrent/bidding/AuctionResult.java b/bidding/src/main/java/com/bidtorrent/bidding/AuctionResult.java index f6590eb..03a9fa1 100755 --- a/bidding/src/main/java/com/bidtorrent/bidding/AuctionResult.java +++ b/bidding/src/main/java/com/bidtorrent/bidding/AuctionResult.java @@ -1,48 +1,40 @@ package com.bidtorrent.bidding; -import com.bidtorrent.bidding.messages.BidResponse; +import com.bidtorrent.bidding.messages.ContextualizedBidResponse; import java.io.Serializable; import java.util.Collection; public class AuctionResult implements Serializable { - private IBidder winningBidder; - private final BidResponse winningBid; - private final float winningPrice; - private long runnerUp; - private Collection responses; + private final ContextualizedBidResponse winningBid; + private final ContextualizedBidResponse runnerUp; + private Collection responses; + private float winningPrice; public AuctionResult( - BidResponse winningBid, - float winningPrice, - IBidder winningBidder, - Collection responses, - long runnerUp) - { + ContextualizedBidResponse winningBid, + Collection responses, + ContextualizedBidResponse runnerUp, + float winningPrice){ this.winningBid = winningBid; - this.winningPrice = winningPrice; - this.winningBidder = winningBidder; this.responses = responses; this.runnerUp = runnerUp; + this.winningPrice = winningPrice; } - public BidResponse getWinningBid() { - return winningBid; + public AuctionResult() { + this(null,null,null, 0f); } - public float getWinningPrice() { - return winningPrice; + public ContextualizedBidResponse getWinningBid() { + return winningBid; } - public Collection getResponses() { + public Collection getResponses() { return responses; } - public IBidder getWinningBidder() { - return winningBidder; - } - - public long getRunnerUp() { + public ContextualizedBidResponse getRunnerUp() { return runnerUp; } } diff --git a/bidding/src/main/java/com/bidtorrent/bidding/Auctioneer.java b/bidding/src/main/java/com/bidtorrent/bidding/Auctioneer.java index 125546f..1447b9e 100755 --- a/bidding/src/main/java/com/bidtorrent/bidding/Auctioneer.java +++ b/bidding/src/main/java/com/bidtorrent/bidding/Auctioneer.java @@ -1,6 +1,6 @@ package com.bidtorrent.bidding; -import com.bidtorrent.bidding.messages.BidResponse; +import com.bidtorrent.bidding.messages.ContextualizedBidResponse; import com.google.common.base.Function; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; @@ -35,18 +35,18 @@ public Future runAuction(final Auction auction) { resultFuture = this.executor.submit(new Callable() { @Override public AuctionResult call() throws ExecutionException, InterruptedException { - Collection> responseFutures; - ListenableFuture> responses; + Collection> responseFutures; + ListenableFuture> responses; responseFutures = pushResponseFutures(auction.getOpportunity(), auction.getBidders()); responses = getBidResponses(responseFutures); - return Futures.lazyTransform(responses, new Function, AuctionResult>() { + return Futures.lazyTransform(responses, new Function, AuctionResult>() { @Nullable @Override - public AuctionResult apply(List input) { + public AuctionResult apply(List input) { input.removeAll(Collections.singleton(null)); - return buildAuctionResult(input, auction.getFloor(), auction.getBidders()); + return buildAuctionResult(input, auction.getFloor()); } }).get(); } @@ -55,36 +55,35 @@ public AuctionResult apply(List input) { return resultFuture; } - private static AuctionResult buildAuctionResult(Collection responses, float floor, Collection bidders) { + private static AuctionResult buildAuctionResult(Collection responses, float floor) { float secondPrice; - long runnerUp = 0l; - BidResponse winningBid; - SortedSet sortedResponses; - Iterator iterator; + ContextualizedBidResponse runnerUp = null; + ContextualizedBidResponse winningBid; + SortedSet sortedResponses; + Iterator iterator; sortedResponses = new TreeSet<>(responses); iterator = sortedResponses.iterator(); if (!iterator.hasNext()) - return new AuctionResult(null, 0, null, responses, 0); + return new AuctionResult(); winningBid = iterator.next(); if (iterator.hasNext()){ - BidResponse second = iterator.next(); - secondPrice = second.getPrice(); - runnerUp = second.getBidderId(); - } - else + ContextualizedBidResponse second = iterator.next(); + runnerUp = second; + secondPrice = runnerUp.getBidResponse().getPrice(); + } else secondPrice = floor; - return new AuctionResult(winningBid, secondPrice, getBidderById(winningBid.getBidderId(), bidders), sortedResponses, runnerUp); + return new AuctionResult(winningBid, sortedResponses, runnerUp, secondPrice); } - private static Collection> pushResponseFutures( + private static Collection> pushResponseFutures( final BidOpportunity opportunity, final List bidders) { - Collection> responseFutures; + Collection> responseFutures; responseFutures = new ArrayList<>(bidders.size()); for (final IBidder bidder: bidders) { @@ -100,17 +99,8 @@ public void processError(Exception e) { return responseFutures; } - private static ListenableFuture> getBidResponses(Collection> responseFutures) + private static ListenableFuture> getBidResponses(Collection> responseFutures) { return Futures.successfulAsList(responseFutures); } - - private static IBidder getBidderById(long bidderId, Collection bidders) { - for (IBidder bidder : bidders) { - if (bidder.getId() == bidderId) - return bidder; - } - - return null; - } } diff --git a/bidding/src/main/java/com/bidtorrent/bidding/ConstantBidder.java b/bidding/src/main/java/com/bidtorrent/bidding/ConstantBidder.java index 83433aa..a242d69 100755 --- a/bidding/src/main/java/com/bidtorrent/bidding/ConstantBidder.java +++ b/bidding/src/main/java/com/bidtorrent/bidding/ConstantBidder.java @@ -1,6 +1,8 @@ package com.bidtorrent.bidding; import com.bidtorrent.bidding.messages.BidResponse; +import com.bidtorrent.bidding.messages.ContextualizedBidResponse; +import com.bidtorrent.bidding.messages.configuration.BidderConfiguration; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.MoreExecutors; @@ -17,8 +19,10 @@ public ConstantBidder(long id, BidResponse response) { } @Override - public ListenableFuture bid(BidOpportunity opportunity, IErrorCallback errorCallback) { - return Futures.immediateFuture(response); + public ListenableFuture bid(BidOpportunity opportunity, IErrorCallback errorCallback) { + BidderConfiguration bidderConfiguration = new BidderConfiguration(); + bidderConfiguration.id = id; + return Futures.immediateFuture(new ContextualizedBidResponse(response, bidderConfiguration)); } @Override diff --git a/bidding/src/main/java/com/bidtorrent/bidding/HttpBidder.java b/bidding/src/main/java/com/bidtorrent/bidding/HttpBidder.java index 2d8a291..a1cc6b5 100755 --- a/bidding/src/main/java/com/bidtorrent/bidding/HttpBidder.java +++ b/bidding/src/main/java/com/bidtorrent/bidding/HttpBidder.java @@ -4,51 +4,31 @@ import com.bidtorrent.bidding.messages.Banner; import com.bidtorrent.bidding.messages.BidRequest; import com.bidtorrent.bidding.messages.BidResponse; +import com.bidtorrent.bidding.messages.ContextualizedBidResponse; import com.bidtorrent.bidding.messages.Device; import com.bidtorrent.bidding.messages.Ext; import com.bidtorrent.bidding.messages.Geo; import com.bidtorrent.bidding.messages.Imp; import com.bidtorrent.bidding.messages.Publisher; import com.bidtorrent.bidding.messages.User; -import com.google.common.io.ByteStreams; +import com.bidtorrent.bidding.messages.configuration.BidderConfiguration; +import com.google.common.base.Function; +import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import org.apache.http.client.methods.HttpPost; -import org.apache.http.conn.ClientConnectionManager; -import org.apache.http.conn.scheme.PlainSocketFactory; -import org.apache.http.conn.scheme.Scheme; -import org.apache.http.conn.scheme.SchemeRegistry; -import org.apache.http.entity.StringEntity; -import org.apache.http.impl.client.BasicCookieStore; -import org.apache.http.impl.client.DefaultHttpClient; -import org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager; -import org.apache.http.impl.cookie.BasicClientCookie; -import org.apache.http.params.BasicHttpParams; -import org.apache.http.params.HttpConnectionParams; -import org.apache.http.params.HttpParams; - -import java.io.IOException; -import java.io.UnsupportedEncodingException; import java.net.InetAddress; import java.net.NetworkInterface; -import java.net.URI; import java.util.Arrays; import java.util.Enumeration; -import java.util.concurrent.Callable; + +import javax.annotation.Nullable; public class HttpBidder implements IBidder{ - private long id; - private final String name; - private final String bidUrl; + private final BidderConfiguration bidderConfiguration; private final PooledHttpClient pooledHttpClient; - public HttpBidder(long id, String name, String bidUrl, IResponseConverter responseConverter, int timeout, PooledHttpClient pooledHttpClient) - { - this.id = id; - this.name = name; - this.bidUrl = bidUrl; + public HttpBidder(BidderConfiguration bidderConfiguration, PooledHttpClient pooledHttpClient) { + this.bidderConfiguration = bidderConfiguration; this.pooledHttpClient = pooledHttpClient; } @@ -70,7 +50,6 @@ public static String getLocalIpAddress() return null; } - private static BidRequest createBidRequest(BidOpportunity bidOpportunity){ return new BidRequest( new User("MyID", "MyID"), @@ -90,15 +69,24 @@ private static BidRequest createBidRequest(BidOpportunity bidOpportunity){ } @Override - public ListenableFuture bid(final BidOpportunity opportunity, IErrorCallback errorCallback) { - return pooledHttpClient.jsonPost(bidUrl, createBidRequest(opportunity), BidResponse.class); + public ListenableFuture bid(final BidOpportunity opportunity, IErrorCallback errorCallback) { + return Futures.transform(pooledHttpClient.jsonPost(this.bidderConfiguration.bid_ep, createBidRequest(opportunity), BidResponse.class), + new Function() { + @Nullable + @Override + public ContextualizedBidResponse apply(BidResponse input) { + if (input == null) return null; + + return new ContextualizedBidResponse(input, bidderConfiguration); + } + }); } public String getName() { - return name; + return this.bidderConfiguration.name; } public long getId() { - return id; + return this.bidderConfiguration.id; } } diff --git a/bidding/src/main/java/com/bidtorrent/bidding/IBidder.java b/bidding/src/main/java/com/bidtorrent/bidding/IBidder.java index fb26f45..2baa188 100755 --- a/bidding/src/main/java/com/bidtorrent/bidding/IBidder.java +++ b/bidding/src/main/java/com/bidtorrent/bidding/IBidder.java @@ -1,13 +1,14 @@ package com.bidtorrent.bidding; import com.bidtorrent.bidding.messages.BidResponse; +import com.bidtorrent.bidding.messages.ContextualizedBidResponse; import com.google.common.util.concurrent.ListenableFuture; import java.io.Serializable; import java.util.concurrent.Callable; public interface IBidder extends Serializable{ - ListenableFuture bid(BidOpportunity opportunity, IErrorCallback errorCallback); + ListenableFuture bid(BidOpportunity opportunity, IErrorCallback errorCallback); long getId(); } diff --git a/bidding/src/main/java/com/bidtorrent/bidding/Notificator.java b/bidding/src/main/java/com/bidtorrent/bidding/Notificator.java index 608f46d..dfb15fd 100755 --- a/bidding/src/main/java/com/bidtorrent/bidding/Notificator.java +++ b/bidding/src/main/java/com/bidtorrent/bidding/Notificator.java @@ -1,16 +1,5 @@ package com.bidtorrent.bidding; -import org.apache.http.client.methods.HttpGet; -import org.apache.http.conn.ClientConnectionManager; -import org.apache.http.conn.scheme.PlainSocketFactory; -import org.apache.http.conn.scheme.Scheme; -import org.apache.http.conn.scheme.SchemeRegistry; -import org.apache.http.impl.client.DefaultHttpClient; -import org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager; -import org.apache.http.params.BasicHttpParams; -import org.apache.http.params.HttpConnectionParams; -import org.apache.http.params.HttpParams; - import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; diff --git a/bidding/src/main/java/com/bidtorrent/bidding/messages/BidResponse.java b/bidding/src/main/java/com/bidtorrent/bidding/messages/BidResponse.java index f82f3d3..659ef4b 100755 --- a/bidding/src/main/java/com/bidtorrent/bidding/messages/BidResponse.java +++ b/bidding/src/main/java/com/bidtorrent/bidding/messages/BidResponse.java @@ -1,5 +1,7 @@ package com.bidtorrent.bidding.messages; +import com.bidtorrent.bidding.messages.configuration.BidderConfiguration; + import java.io.Serializable; import java.util.ArrayList; @@ -10,6 +12,8 @@ public class BidResponse implements Comparable, Serializable { public String cur; public ArrayList seatbid; + private BidderConfiguration bidderConfiguration; + public BidResponse(long bidderId, float bidPrice, int bidId, String domain, String creative, String notificationUrl) { this.bidderId = bidderId; Bid bid = new Bid("" + bidId, "", bidPrice, "", notificationUrl, domain, creative); @@ -35,6 +39,14 @@ public void setBidderId(long bidderId) this.bidderId = bidderId; } + public void setBidderConfiguration(BidderConfiguration bidderConfiguration) { + this.bidderConfiguration = bidderConfiguration; + } + + public BidderConfiguration getBidderConfiguration() { + return bidderConfiguration; + } + @Override public int compareTo(Object o) { BidResponse s = (BidResponse) o; diff --git a/bidding/src/main/java/com/bidtorrent/bidding/messages/ContextualizedBidResponse.java b/bidding/src/main/java/com/bidtorrent/bidding/messages/ContextualizedBidResponse.java new file mode 100755 index 0000000..c8150aa --- /dev/null +++ b/bidding/src/main/java/com/bidtorrent/bidding/messages/ContextualizedBidResponse.java @@ -0,0 +1,29 @@ +package com.bidtorrent.bidding.messages; + +import com.bidtorrent.bidding.messages.configuration.BidderConfiguration; + +import java.io.Serializable; + +public class ContextualizedBidResponse implements Comparable, Serializable{ + + private BidResponse bidResponse; + private BidderConfiguration bidderConfiguration; + + public ContextualizedBidResponse(BidResponse bidResponse, BidderConfiguration bidderConfiguration) { + this.bidResponse = bidResponse; + this.bidderConfiguration = bidderConfiguration; + } + + public BidderConfiguration getBidderConfiguration() { + return bidderConfiguration; + } + + public BidResponse getBidResponse() { + return bidResponse; + } + + @Override + public int compareTo(Object o) { + return this.bidResponse.compareTo(((ContextualizedBidResponse)o).bidResponse); + } +} diff --git a/bidding/src/main/java/com/bidtorrent/bidding/messages/configuration/BidderConfiguration.java b/bidding/src/main/java/com/bidtorrent/bidding/messages/configuration/BidderConfiguration.java old mode 100644 new mode 100755 index de1d14b..79834cc --- a/bidding/src/main/java/com/bidtorrent/bidding/messages/configuration/BidderConfiguration.java +++ b/bidding/src/main/java/com/bidtorrent/bidding/messages/configuration/BidderConfiguration.java @@ -1,9 +1,8 @@ package com.bidtorrent.bidding.messages.configuration; -import java.util.Random; -import java.util.concurrent.ThreadLocalRandom; +import java.io.Serializable; -public class BidderConfiguration { +public class BidderConfiguration implements Serializable { public Long id; public String bid_ep; public String name; diff --git a/bidding/src/main/java/com/bidtorrent/bidding/messages/configuration/BidderConfigurationFilters.java b/bidding/src/main/java/com/bidtorrent/bidding/messages/configuration/BidderConfigurationFilters.java old mode 100644 new mode 100755 index 49212d5..a077af5 --- a/bidding/src/main/java/com/bidtorrent/bidding/messages/configuration/BidderConfigurationFilters.java +++ b/bidding/src/main/java/com/bidtorrent/bidding/messages/configuration/BidderConfigurationFilters.java @@ -1,12 +1,13 @@ package com.bidtorrent.bidding.messages.configuration; +import java.io.Serializable; import java.util.Collection; import java.util.Collections; /** * Created by x.noelle on 30/06/2015. */ -public class BidderConfigurationFilters { +public class BidderConfigurationFilters implements Serializable{ public Float sampling; public Collection pub_ctry; public Boolean pub_ctry_wl; diff --git a/biddingservice/biddingservice.iml b/biddingservice/biddingservice.iml index 4422b79..ff8fe39 100755 --- a/biddingservice/biddingservice.iml +++ b/biddingservice/biddingservice.iml @@ -98,7 +98,7 @@ - + \ No newline at end of file diff --git a/biddingservice/build.gradle b/biddingservice/build.gradle index 48e41c6..184a59e 100755 --- a/biddingservice/build.gradle +++ b/biddingservice/build.gradle @@ -31,8 +31,8 @@ group = "io.bidtorrent" // Maven Group ID dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) compile 'com.android.support:appcompat-v7:22.0.0' - //compile project(':bidding') - compile 'io.bidtorrent:bidding:0.2' + compile project(':bidding') + //compile 'io.bidtorrent:bidding:0.2' } install { diff --git a/biddingservice/src/main/java/com/bidtorrent/biddingservice/BiddingIntentService.java b/biddingservice/src/main/java/com/bidtorrent/biddingservice/BiddingIntentService.java index 1713aba..b4d0267 100755 --- a/biddingservice/src/main/java/com/bidtorrent/biddingservice/BiddingIntentService.java +++ b/biddingservice/src/main/java/com/bidtorrent/biddingservice/BiddingIntentService.java @@ -219,10 +219,8 @@ private static PublisherConfiguration mergeConfigurations(PublisherConfiguration if (finalConfiguration.imp.isEmpty()){ finalConfiguration.imp.addAll(basePublisherConfiguration.imp); } else { - if (finalConfiguration.imp.get(0).banner.btype == null) + if (basePublisherConfiguration.imp.get(0).banner.btype != null) finalConfiguration.imp.get(0).banner.btype = basePublisherConfiguration.imp.get(0).banner.btype; - else - finalConfiguration.imp.get(0).banner.btype.addAll(basePublisherConfiguration.imp.get(0).banner.btype); if (basePublisherConfiguration.imp.get(0).banner.h != -1) finalConfiguration.imp.get(0).banner.h = basePublisherConfiguration.imp.get(0).banner.h; if (basePublisherConfiguration.imp.get(0).banner.w != -1) finalConfiguration.imp.get(0).banner.w = basePublisherConfiguration.imp.get(0).banner.w; if (basePublisherConfiguration.imp.get(0).instl != -1) finalConfiguration.imp.get(0).instl = basePublisherConfiguration.imp.get(0).instl; @@ -302,7 +300,7 @@ private void sendItToPrefetch(AuctionResult auctionResult, BidOpportunity bidOpp { Intent responseAvailableIntent = new Intent(Constants.BID_AVAILABLE_INTENT); - responseAvailableIntent.putExtra(Constants.CREATIVE_CODE_ARG, auctionResult.getWinningBid().seatbid.get(0).bid.get(0).creative); + responseAvailableIntent.putExtra(Constants.CREATIVE_CODE_ARG, auctionResult.getWinningBid().getBidResponse().seatbid.get(0).bid.get(0).creative); responseAvailableIntent.putExtra(Constants.BID_OPPORTUNITY_ARG, gson.toJson(bidOpportunity)); responseAvailableIntent.putExtra(Constants.AUCTION_ID_ARG, auctionId); diff --git a/biddingservice/src/main/java/com/bidtorrent/biddingservice/actions/NotificationsAction.java b/biddingservice/src/main/java/com/bidtorrent/biddingservice/actions/NotificationsAction.java index 320fb58..ebd5028 100755 --- a/biddingservice/src/main/java/com/bidtorrent/biddingservice/actions/NotificationsAction.java +++ b/biddingservice/src/main/java/com/bidtorrent/biddingservice/actions/NotificationsAction.java @@ -5,7 +5,7 @@ import com.bidtorrent.bidding.AuctionResult; import com.bidtorrent.bidding.BidOpportunity; import com.bidtorrent.bidding.Notificator; -import com.bidtorrent.bidding.messages.BidResponse; +import com.bidtorrent.bidding.messages.ContextualizedBidResponse; import com.bidtorrent.bidding.messages.configuration.PublisherConfiguration; import com.bidtorrent.biddingservice.Constants; @@ -24,7 +24,7 @@ public void handleIntent(Intent intent) { AuctionResult result = (AuctionResult) intent.getSerializableExtra(Constants.AUCTION_RESULT_ARG); BidOpportunity opp = ActionHelper.getBidOpportunity(intent); - String notificationUrl = result.getWinningBid().buildNotificationUrl(result.getWinningBid().id, "", result.getRunnerUp()); + String notificationUrl = result.getWinningBid().getBidResponse().buildNotificationUrl(result.getWinningBid().getBidResponse().id, "", result.getRunnerUp().getBidderConfiguration().id); this.notificator.notify(notificationUrl); try { @@ -40,10 +40,10 @@ private String getLoggingUrl(AuctionResult result, BidOpportunity opp) { String a = ""; builder.append("log.bidtorrent.io/imp?"); - for (BidResponse response : result.getResponses()){ - a = response.id + "-" + response.seatbid.get(0).bid.get(0).impid; + for (ContextualizedBidResponse response : result.getResponses()){ + a = response.getBidResponse().id + "-" + response.getBidResponse().seatbid.get(0).bid.get(0).impid; //FIXME: We need to send the entire bidder - builder.append(String.format("d[%s]=%.2f-%s&", response.id, response.getPrice(), response.getBidderId())); + builder.append(String.format("d[%s]=%.2f-%s&", response.getBidResponse().id, response.getBidResponse().getPrice(), response.getBidderConfiguration().key)); } builder.append(String.format("f=%.2f&", publisherConfiguration.imp.get(0).bidfloor)); diff --git a/biddingservice/src/main/java/com/bidtorrent/biddingservice/debug/ListViewAdapter.java b/biddingservice/src/main/java/com/bidtorrent/biddingservice/debug/ListViewAdapter.java index 55a38bc..dcf8751 100755 --- a/biddingservice/src/main/java/com/bidtorrent/biddingservice/debug/ListViewAdapter.java +++ b/biddingservice/src/main/java/com/bidtorrent/biddingservice/debug/ListViewAdapter.java @@ -11,23 +11,24 @@ import android.widget.TextView; import com.bidtorrent.bidding.messages.BidResponse; +import com.bidtorrent.bidding.messages.ContextualizedBidResponse; import com.bidtorrent.biddingservice.R; import java.text.NumberFormat; import java.util.List; import java.util.Locale; -public class ListViewAdapter extends ArrayAdapter { +public class ListViewAdapter extends ArrayAdapter { private final int resource; // Declare Variables Context context; LayoutInflater inflater; - List bidresponseslist; + List bidresponseslist; private SparseBooleanArray mSelectedItemsIds; public ListViewAdapter(Context context, int resourceId, - List bidresponseslist) { + List bidresponseslist) { super(context, resourceId, bidresponseslist); mSelectedItemsIds = new SparseBooleanArray(); this.context = context; @@ -56,11 +57,11 @@ public View getView(int position, View view, ViewGroup parent) { } // Capture position and set to the TextViews - long bidderId = bidresponseslist.get(position).bidderId; + long bidderId = bidresponseslist.get(position).getBidderConfiguration().id; holder.bidderuri.setText("BidderId: " + bidderId); if (bidresponseslist.get(position) != null) - holder.price.setText(NumberFormat.getCurrencyInstance(new Locale("en", "US")).format(bidresponseslist.get(position).getPrice())); + holder.price.setText(NumberFormat.getCurrencyInstance(new Locale("en", "US")).format(bidresponseslist.get(position).getBidResponse().getPrice())); else holder.price.setText("TIMEOUT"); diff --git a/biddingservice/src/main/java/com/bidtorrent/biddingservice/functions/TriggerBidFunction.java b/biddingservice/src/main/java/com/bidtorrent/biddingservice/functions/TriggerBidFunction.java index 89e5134..47825fe 100755 --- a/biddingservice/src/main/java/com/bidtorrent/biddingservice/functions/TriggerBidFunction.java +++ b/biddingservice/src/main/java/com/bidtorrent/biddingservice/functions/TriggerBidFunction.java @@ -55,11 +55,7 @@ public ListenableFuture apply(final BidOpportunity bidOpportunity for (BidderConfiguration config : selector.getAvailableBidders()) { bidders.add(new HttpBidder( - 1, - "Kitten", - config.bid_ep, - new JsonResponseConverter(), - publisherConfiguration.tmax, + config, pooledHttpClient)); } diff --git a/biddingservice/src/main/java/com/bidtorrent/biddingservice/receivers/CreativeDisplayReceiver.java b/biddingservice/src/main/java/com/bidtorrent/biddingservice/receivers/CreativeDisplayReceiver.java index eb5fd6c..82991bb 100755 --- a/biddingservice/src/main/java/com/bidtorrent/biddingservice/receivers/CreativeDisplayReceiver.java +++ b/biddingservice/src/main/java/com/bidtorrent/biddingservice/receivers/CreativeDisplayReceiver.java @@ -3,28 +3,20 @@ import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; -import android.database.DataSetObserver; import android.view.View; import android.view.ViewGroup; -import android.webkit.JavascriptInterface; import android.webkit.WebView; import android.webkit.WebViewClient; -import android.widget.ArrayAdapter; -import android.widget.ListAdapter; import android.widget.ListView; import android.widget.Toast; import com.bidtorrent.bidding.AuctionResult; -import com.bidtorrent.bidding.Notificator; -import com.bidtorrent.bidding.messages.BidResponse; import com.bidtorrent.biddingservice.BiddingIntentService; import com.bidtorrent.biddingservice.Constants; import com.bidtorrent.biddingservice.R; import com.bidtorrent.biddingservice.debug.ListViewAdapter; -import java.io.Serializable; import java.util.ArrayList; -import java.util.Objects; public class CreativeDisplayReceiver extends BroadcastReceiver { private final int requesterId; @@ -80,7 +72,7 @@ private void showDebugInfo(Context context, AuctionResult result) { if (this.debugView == null) return; ListView listView = new ListView(context); - listView.setAdapter(new ListViewAdapter(context, R.layout.debug, new ArrayList(result.getResponses()))); + listView.setAdapter(new ListViewAdapter(context, R.layout.debug, new ArrayList<>(result.getResponses()))); debugView.addView(listView); }