From 9d70f8b93a4844e6eb85f35284fa8172c13ea9fc Mon Sep 17 00:00:00 2001 From: Philipp Mikheyev Date: Sat, 21 Jan 2017 15:55:08 +0300 Subject: [PATCH 1/7] bump gradle version --- admobadapter/admobadapter.iml | 13 +++++-------- admobadapter/build.gradle | 2 +- build.gradle | 2 +- sampleapp/build.gradle | 2 +- sampleapp/sampleapp.iml | 23 +++++++++++------------ 5 files changed, 19 insertions(+), 23 deletions(-) diff --git a/admobadapter/admobadapter.iml b/admobadapter/admobadapter.iml index 7ef6f44..be6aad2 100644 --- a/admobadapter/admobadapter.iml +++ b/admobadapter/admobadapter.iml @@ -121,10 +121,7 @@ - - - @@ -139,15 +136,15 @@ - + - - + + @@ -160,15 +157,15 @@ - + - + \ No newline at end of file diff --git a/admobadapter/build.gradle b/admobadapter/build.gradle index 7459a80..6eceeab 100644 --- a/admobadapter/build.gradle +++ b/admobadapter/build.gradle @@ -3,7 +3,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:2.2.2' + classpath 'com.android.tools.build:gradle:2.2.3' } } apply plugin: 'com.android.library' diff --git a/build.gradle b/build.gradle index 2a61024..d06d2c2 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:2.2.2' + classpath 'com.android.tools.build:gradle:2.2.3' classpath 'com.google.gms:google-services:3.0.0' // NOTE: Do not place your application dependencies here; they belong diff --git a/sampleapp/build.gradle b/sampleapp/build.gradle index 0990bcd..b06f428 100644 --- a/sampleapp/build.gradle +++ b/sampleapp/build.gradle @@ -3,7 +3,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:2.2.2' + classpath 'com.android.tools.build:gradle:2.2.3' } } apply plugin: 'com.android.application' diff --git a/sampleapp/sampleapp.iml b/sampleapp/sampleapp.iml index 3d574a6..cae9c06 100644 --- a/sampleapp/sampleapp.iml +++ b/sampleapp/sampleapp.iml @@ -66,14 +66,6 @@ - - - - - - - - @@ -82,6 +74,14 @@ + + + + + + + + @@ -109,7 +109,6 @@ - @@ -142,9 +141,9 @@ - + @@ -152,13 +151,13 @@ - + - + \ No newline at end of file From 278b91d01f355a4472a010f3b498d708a40634a0 Mon Sep 17 00:00:00 2001 From: Philipp Mikheyev Date: Sat, 21 Jan 2017 20:28:28 +0300 Subject: [PATCH 2/7] bump dependencies and build tools version --- admobadapter/admobadapter.iml | 90 +++++++++++++++++------------------ admobadapter/build.gradle | 10 ++-- sampleapp/build.gradle | 6 +-- sampleapp/sampleapp.iml | 77 ++++++++++++++++-------------- 4 files changed, 95 insertions(+), 88 deletions(-) diff --git a/admobadapter/admobadapter.iml b/admobadapter/admobadapter.iml index be6aad2..c2bf10d 100644 --- a/admobadapter/admobadapter.iml +++ b/admobadapter/admobadapter.iml @@ -88,28 +88,28 @@ - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + @@ -126,46 +126,46 @@ - + - - + + - + + + - - + + - - + + - - - - - - - - - - + + + + + + + + - + - - + + - + + - \ No newline at end of file diff --git a/admobadapter/build.gradle b/admobadapter/build.gradle index 6eceeab..0313356 100644 --- a/admobadapter/build.gradle +++ b/admobadapter/build.gradle @@ -15,7 +15,7 @@ repositories { android { compileSdkVersion 25 - buildToolsVersion "24.0.3" + buildToolsVersion "25.0.2" defaultConfig { minSdkVersion 9 @@ -38,10 +38,10 @@ android { dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) - compile 'com.android.support:appcompat-v7:25.0.0' - compile 'com.google.android.gms:play-services-ads:9.6.1' - compile 'com.android.support:recyclerview-v7:25.0.0' - compile 'com.google.firebase:firebase-ads:9.6.1' + compile 'com.android.support:appcompat-v7:25.1.0' + compile 'com.google.android.gms:play-services-ads:10.0.1' + compile 'com.android.support:recyclerview-v7:25.1.0' + compile 'com.google.firebase:firebase-ads:10.0.1' testCompile 'junit:junit:4.12' testCompile 'org.mockito:mockito-core:1.10.19' diff --git a/sampleapp/build.gradle b/sampleapp/build.gradle index b06f428..143fec3 100644 --- a/sampleapp/build.gradle +++ b/sampleapp/build.gradle @@ -14,7 +14,7 @@ repositories { android { compileSdkVersion 25 - buildToolsVersion "24.0.3" + buildToolsVersion "25.0.2" defaultConfig { applicationId "com.clockbyte.admobadapter.sampleapp" @@ -39,7 +39,7 @@ android { dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) - compile 'com.android.support:appcompat-v7:25.0.0' - compile 'com.android.support:cardview-v7:25.0.0' + compile 'com.android.support:appcompat-v7:25.1.0' + compile 'com.android.support:cardview-v7:25.1.0' compile project(':admobadapter') } diff --git a/sampleapp/sampleapp.iml b/sampleapp/sampleapp.iml index cae9c06..75c195c 100644 --- a/sampleapp/sampleapp.iml +++ b/sampleapp/sampleapp.iml @@ -84,27 +84,34 @@ + - - - + + + - - - - - - - + + + + + + + + + + + + - + + @@ -115,49 +122,49 @@ - - - - - - + + + + + + - - - - - + + + + + - + - - + + + + - + - + - - - - - + + + + - + - + - \ No newline at end of file From e9dbe366671622a5b1b8d047bf28b460c05f87c4 Mon Sep 17 00:00:00 2001 From: Philipp Mikheyev Date: Sat, 21 Jan 2017 21:50:44 +0300 Subject: [PATCH 3/7] fix https://github.com/clockbyte/admobadapter/issues/53 hiding the adview ot it's wrapper view if was failed to load (no internet etc). --- .../admobadapter/expressads/AdmobFetcherExpress.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/admobadapter/src/main/java/com/clockbyte/admobadapter/expressads/AdmobFetcherExpress.java b/admobadapter/src/main/java/com/clockbyte/admobadapter/expressads/AdmobFetcherExpress.java index 13e71d3..5a34bc0 100644 --- a/admobadapter/src/main/java/com/clockbyte/admobadapter/expressads/AdmobFetcherExpress.java +++ b/admobadapter/src/main/java/com/clockbyte/admobadapter/expressads/AdmobFetcherExpress.java @@ -19,8 +19,11 @@ import android.content.Context; import android.os.Handler; +import android.support.v7.widget.RecyclerView; import android.util.Log; import android.view.View; +import android.view.ViewParent; +import android.widget.ListView; import com.clockbyte.admobadapter.AdPresetCyclingList; import com.clockbyte.admobadapter.AdmobFetcherBase; @@ -166,14 +169,19 @@ private synchronized void onFetched(NativeExpressAdViewHolder adViewEx) { private synchronized void onFailedToLoad(NativeExpressAdViewHolder adViewEx, int errorCode) { Log.i(TAG, "onAdFailedToLoad " + errorCode); mFetchFailCount++; + mNoOfFetchedAds = Math.max(mNoOfFetchedAds - 1, -1); //Since Fetch Ad is only called once without retries //hide ad row / rollback its count if still not added to list adViewEx.setFailedToLoad(true); mPrefetchedAds.remove(adViewEx); - mNoOfFetchedAds = Math.max(mNoOfFetchedAds - 1, -1); notifyObserversOfAdSizeChange(mNoOfFetchedAds - 1); - if(adViewEx.getAdView().getParent()!=null) + ViewParent parent = adViewEx.getAdView().getParent(); + //parent is not empty and not an instance of ListView/RecyclerView + if(parent!=null + && !(parent instanceof RecyclerView + || parent instanceof ListView)) ((View) adViewEx.getAdView().getParent()).setVisibility(View.GONE); + else adViewEx.getAdView().setVisibility(View.GONE); } @Override From 3b74bb6501683fd577c7fcf3cfaebc814b7bc365 Mon Sep 17 00:00:00 2001 From: kot331107 Date: Sat, 21 Jan 2017 21:51:01 +0300 Subject: [PATCH 4/7] improve some comments --- .../admobadapter/expressads/NativeExpressAdViewHolder.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/admobadapter/src/main/java/com/clockbyte/admobadapter/expressads/NativeExpressAdViewHolder.java b/admobadapter/src/main/java/com/clockbyte/admobadapter/expressads/NativeExpressAdViewHolder.java index 85ce827..c59d5cf 100644 --- a/admobadapter/src/main/java/com/clockbyte/admobadapter/expressads/NativeExpressAdViewHolder.java +++ b/admobadapter/src/main/java/com/clockbyte/admobadapter/expressads/NativeExpressAdViewHolder.java @@ -34,7 +34,7 @@ void setFailedToLoad(boolean failedToLoad) { } /** - * This field is for internal use + * This field is for internal use, could be null, especially for RecyclerView * @return some {@link ViewGroup} which wraps current ad view * @see NativeExpressAdViewHolder#getAdView() */ From 88b1058c7057b85ea8295ee9bcaf6f0a88e0c595 Mon Sep 17 00:00:00 2001 From: kot331107 Date: Sat, 21 Jan 2017 21:57:18 +0300 Subject: [PATCH 5/7] add the method getFetchingAdsCount() to all adapterwrappers due to the https://github.com/clockbyte/admobadapter/issues/49 --- .../clockbyte/admobadapter/AdmobAdapterWrapper.java | 9 +++++++++ .../admobadapter/AdmobRecyclerAdapterWrapper.java | 9 +++++++++ .../expressads/AdmobExpressAdapterWrapper.java | 10 ++++++++++ .../expressads/AdmobExpressRecyclerAdapterWrapper.java | 9 +++++++++ 4 files changed, 37 insertions(+) diff --git a/admobadapter/src/main/java/com/clockbyte/admobadapter/AdmobAdapterWrapper.java b/admobadapter/src/main/java/com/clockbyte/admobadapter/AdmobAdapterWrapper.java index 33a8c73..888b2b5 100644 --- a/admobadapter/src/main/java/com/clockbyte/admobadapter/AdmobAdapterWrapper.java +++ b/admobadapter/src/main/java/com/clockbyte/admobadapter/AdmobAdapterWrapper.java @@ -90,6 +90,15 @@ public int getFetchedAdsCount() { return adFetcher.getFetchedAdsCount(); } + /** + * Gets the number of ads have been fetched so far + currently fetching ads + * + * @return the number of already fetched ads + currently fetching ads + */ + public int getFetchingAdsCount(){ + return adFetcher.getFetchingAdsCount(); + } + private int getViewTypeAdContent(){ return mAdapter.getViewTypeCount() + VIEW_TYPE_AD_CONTENT; } diff --git a/admobadapter/src/main/java/com/clockbyte/admobadapter/AdmobRecyclerAdapterWrapper.java b/admobadapter/src/main/java/com/clockbyte/admobadapter/AdmobRecyclerAdapterWrapper.java index ea37bf2..3410ae7 100644 --- a/admobadapter/src/main/java/com/clockbyte/admobadapter/AdmobRecyclerAdapterWrapper.java +++ b/admobadapter/src/main/java/com/clockbyte/admobadapter/AdmobRecyclerAdapterWrapper.java @@ -111,6 +111,15 @@ public int getFetchedAdsCount() { return adFetcher.getFetchedAdsCount(); } + /** + * Gets the number of ads have been fetched so far + currently fetching ads + * + * @return the number of already fetched ads + currently fetching ads + */ + public int getFetchingAdsCount(){ + return adFetcher.getFetchingAdsCount(); + } + private int getViewTypeAdContent(){ return getViewTypeBiggestSource() + VIEW_TYPE_AD_CONTENT + 1; } diff --git a/admobadapter/src/main/java/com/clockbyte/admobadapter/expressads/AdmobExpressAdapterWrapper.java b/admobadapter/src/main/java/com/clockbyte/admobadapter/expressads/AdmobExpressAdapterWrapper.java index 9978246..9305670 100644 --- a/admobadapter/src/main/java/com/clockbyte/admobadapter/expressads/AdmobExpressAdapterWrapper.java +++ b/admobadapter/src/main/java/com/clockbyte/admobadapter/expressads/AdmobExpressAdapterWrapper.java @@ -99,6 +99,16 @@ public int getFetchedAdsCount() { return adFetcher.getFetchedAdsCount(); } + + /** + * Gets the number of ads have been fetched so far + currently fetching ads + * + * @return the number of already fetched ads + currently fetching ads + */ + public int getFetchingAdsCount(){ + return adFetcher.getFetchingAdsCount(); + } + private int getViewTypeAdExpress(){ return mAdapter.getViewTypeCount() + VIEW_TYPE_AD_EXPRESS; } diff --git a/admobadapter/src/main/java/com/clockbyte/admobadapter/expressads/AdmobExpressRecyclerAdapterWrapper.java b/admobadapter/src/main/java/com/clockbyte/admobadapter/expressads/AdmobExpressRecyclerAdapterWrapper.java index fc98e18..74045a2 100644 --- a/admobadapter/src/main/java/com/clockbyte/admobadapter/expressads/AdmobExpressRecyclerAdapterWrapper.java +++ b/admobadapter/src/main/java/com/clockbyte/admobadapter/expressads/AdmobExpressRecyclerAdapterWrapper.java @@ -121,6 +121,15 @@ public int getFetchedAdsCount() { return adFetcher.getFetchedAdsCount(); } + /** + * Gets the number of ads have been fetched so far + currently fetching ads + * + * @return the number of already fetched ads + currently fetching ads + */ + public int getFetchingAdsCount(){ + return adFetcher.getFetchingAdsCount(); + } + private int getViewTypeAdExpress(){ return getViewTypeBiggestSource() + VIEW_TYPE_AD_EXPRESS + 1; } From b396b963313b4fe0cbfbf45f52505b6391d6d204 Mon Sep 17 00:00:00 2001 From: kot331107 Date: Sat, 21 Jan 2017 22:56:55 +0300 Subject: [PATCH 6/7] minor refactor --- .../com/clockbyte/admobadapter/AdmobAdapterCalculator.java | 5 ++--- .../clockbyte/admobadapter/AdmobAdapterCalculatorTest.java | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/admobadapter/src/main/java/com/clockbyte/admobadapter/AdmobAdapterCalculator.java b/admobadapter/src/main/java/com/clockbyte/admobadapter/AdmobAdapterCalculator.java index fedd3c8..6e6813c 100644 --- a/admobadapter/src/main/java/com/clockbyte/admobadapter/AdmobAdapterCalculator.java +++ b/admobadapter/src/main/java/com/clockbyte/admobadapter/AdmobAdapterCalculator.java @@ -102,12 +102,11 @@ public int getOriginalContentPosition(int position, int fetchedAdsCount, int sou int adSpacesCount = (getAdIndex(position) + 1); int originalPosition = position - Math.min(adSpacesCount, noOfAds); //Log.d("POSITION", position + " is originally " + originalPosition); - return originalPosition; } /** - * Translates an ad position to an actual position withing the adapter wrapper. + * Translates an ad position to an actual position within the adapter wrapper. * * @param adPos the ad's position in the fetched list * @return the position of the adapter wrapper item @@ -118,7 +117,7 @@ public int translateAdToWrapperPosition(int adPos) { } /** - * Translates the source position to an actual position withing the adapter wrapper. + * Translates the source position to an actual position within the adapter wrapper. * @param fetchedAdsCount the count of completely fetched ads that are ready to be published * @param sourcePos the source index * diff --git a/admobadapter/src/test/java/com/clockbyte/admobadapter/AdmobAdapterCalculatorTest.java b/admobadapter/src/test/java/com/clockbyte/admobadapter/AdmobAdapterCalculatorTest.java index 8028373..655bdad 100644 --- a/admobadapter/src/test/java/com/clockbyte/admobadapter/AdmobAdapterCalculatorTest.java +++ b/admobadapter/src/test/java/com/clockbyte/admobadapter/AdmobAdapterCalculatorTest.java @@ -277,7 +277,7 @@ public void testCanShowAdAtPosition33_fetchedCntIs3_Fail() throws Exception { } @Test - public void testCanShowAdAtPosition_fetchedCntIs0_Fail() throws Exception { + public void testCanShowAdAtPosition0_fetchedCntIs0_Fail() throws Exception { setupAdmobAdapterCalculatorHelper(10, 0, 10); assertThat(admobAdapterCalculator.canShowAdAtPosition(0, 0), is(false)); } From 8028340397f86e97757eea7c4fb643334f590178 Mon Sep 17 00:00:00 2001 From: Philipp Mikheyev Date: Sat, 21 Jan 2017 23:01:32 +0300 Subject: [PATCH 7/7] Update .travis.yml --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 14a4242..5a9e40f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -23,7 +23,7 @@ android: components: - tools # to get the new `repository-11.xml` - tools # to install Android SDK tools 25.1.x (x = 6 right now) - - build-tools-24.0.3 + - build-tools-25.0.2 - android-24 - android-25 - platform-tools