Skip to content

Commit

Permalink
Merge pull request #58 from clockbyte/experimental
Browse files Browse the repository at this point in the history
a merge with Experimental
  • Loading branch information
Philipp Mikheyev authored Jan 21, 2017
2 parents 223aafc + 8028340 commit d36d1d6
Show file tree
Hide file tree
Showing 14 changed files with 158 additions and 111 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
93 changes: 45 additions & 48 deletions admobadapter/admobadapter.iml
Original file line number Diff line number Diff line change
Expand Up @@ -88,28 +88,28 @@
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/bundles" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dependency-cache" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/animated-vector-drawable/25.0.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/appcompat-v7/25.0.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/recyclerview-v7/25.0.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-compat/25.0.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-core-ui/25.0.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-core-utils/25.0.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-fragment/25.0.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-media-compat/25.0.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-v4/25.0.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-vector-drawable/25.0.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.android.gms/play-services-ads-lite/9.6.1/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.android.gms/play-services-ads/9.6.1/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.android.gms/play-services-base/9.6.1/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.android.gms/play-services-basement/9.6.1/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.android.gms/play-services-clearcut/9.6.1/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.android.gms/play-services-gass/9.6.1/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.android.gms/play-services-tasks/9.6.1/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.firebase/firebase-ads/9.6.1/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.firebase/firebase-analytics-impl/9.6.1/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.firebase/firebase-analytics/9.6.1/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.firebase/firebase-common/9.6.1/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.firebase/firebase-iid/9.6.1/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/animated-vector-drawable/25.1.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/appcompat-v7/25.1.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/recyclerview-v7/25.1.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-compat/25.1.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-core-ui/25.1.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-core-utils/25.1.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-fragment/25.1.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-media-compat/25.1.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-v4/25.1.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-vector-drawable/25.1.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.android.gms/play-services-ads-lite/10.0.1/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.android.gms/play-services-ads/10.0.1/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.android.gms/play-services-base/10.0.1/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.android.gms/play-services-basement/10.0.1/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.android.gms/play-services-clearcut/10.0.1/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.android.gms/play-services-gass/10.0.1/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.android.gms/play-services-tasks/10.0.1/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.firebase/firebase-ads/10.0.1/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.firebase/firebase-analytics-impl/10.0.1/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.firebase/firebase-analytics/10.0.1/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.firebase/firebase-common/10.0.1/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.firebase/firebase-iid/10.0.1/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental-safeguard" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/jniLibs" />
Expand All @@ -121,54 +121,51 @@
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/transforms" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/typedefs.txt" />
<excludeFolder url="file://$MODULE_DIR$/build/ivy.xml" />
<excludeFolder url="file://$MODULE_DIR$/build/libs" />
<excludeFolder url="file://$MODULE_DIR$/build/outputs" />
<excludeFolder url="file://$MODULE_DIR$/build/poms" />
<excludeFolder url="file://$MODULE_DIR$/build/tmp" />
</content>
<orderEntry type="jdk" jdkName="Android API 25 Platform" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" exported="" name="play-services-base-9.6.1" level="project" />
<orderEntry type="library" exported="" name="firebase-analytics-10.0.1" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="powermock-api-mockito-common-1.6.5" level="project" />
<orderEntry type="library" exported="" name="firebase-ads-9.6.1" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="javassist-3.20.0-GA" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="powermock-module-junit4-common-1.6.5" level="project" />
<orderEntry type="library" exported="" name="firebase-analytics-impl-9.6.1" level="project" />
<orderEntry type="library" exported="" name="play-services-tasks-10.0.1" level="project" />
<orderEntry type="library" exported="" name="play-services-gass-10.0.1" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="xpp3_min-1.1.4c" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="powermock-classloading-base-1.6.5" level="project" />
<orderEntry type="library" exported="" name="support-fragment-25.0.0" level="project" />
<orderEntry type="library" exported="" name="play-services-base-10.0.1" level="project" />
<orderEntry type="library" exported="" name="support-fragment-25.1.0" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="powermock-classloading-xstream-1.6.5" level="project" />
<orderEntry type="library" exported="" name="support-core-ui-25.0.0" level="project" />
<orderEntry type="library" exported="" name="play-services-clearcut-10.0.1" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="xstream-1.4.9" level="project" />
<orderEntry type="library" exported="" name="firebase-common-9.6.1" level="project" />
<orderEntry type="library" exported="" name="support-core-ui-25.1.0" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="powermock-reflect-1.6.5" level="project" />
<orderEntry type="library" exported="" name="support-core-utils-25.0.0" level="project" />
<orderEntry type="library" exported="" name="play-services-ads-lite-10.0.1" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="powermock-module-junit4-rule-1.6.5" level="project" />
<orderEntry type="library" exported="" name="firebase-iid-9.6.1" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="mockito-core-1.10.19" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="powermock-api-support-1.6.5" level="project" />
<orderEntry type="library" exported="" name="firebase-iid-10.0.1" level="project" />
<orderEntry type="library" exported="" name="support-core-utils-25.1.0" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="xmlpull-1.1.3.1" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="objenesis-2.2" level="project" />
<orderEntry type="library" exported="" name="support-annotations-25.0.0" level="project" />
<orderEntry type="library" exported="" name="play-services-gass-9.6.1" level="project" />
<orderEntry type="library" exported="" name="play-services-ads-9.6.1" level="project" />
<orderEntry type="library" exported="" name="play-services-tasks-9.6.1" level="project" />
<orderEntry type="library" exported="" name="play-services-basement-9.6.1" level="project" />
<orderEntry type="library" exported="" name="support-v4-25.0.0" level="project" />
<orderEntry type="library" exported="" name="support-media-compat-25.0.0" level="project" />
<orderEntry type="library" exported="" name="support-compat-25.0.0" level="project" />
<orderEntry type="library" exported="" name="animated-vector-drawable-25.0.0" level="project" />
<orderEntry type="library" exported="" name="play-services-ads-lite-9.6.1" level="project" />
<orderEntry type="library" exported="" name="play-services-clearcut-9.6.1" level="project" />
<orderEntry type="library" exported="" name="support-annotations-25.1.0" level="project" />
<orderEntry type="library" exported="" name="firebase-analytics-impl-10.0.1" level="project" />
<orderEntry type="library" exported="" name="play-services-ads-10.0.1" level="project" />
<orderEntry type="library" exported="" name="firebase-common-10.0.1" level="project" />
<orderEntry type="library" exported="" name="support-compat-25.1.0" level="project" />
<orderEntry type="library" exported="" name="animated-vector-drawable-25.1.0" level="project" />
<orderEntry type="library" exported="" name="play-services-basement-10.0.1" level="project" />
<orderEntry type="library" exported="" name="support-v4-25.1.0" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="hamcrest-core-1.3" level="project" />
<orderEntry type="library" exported="" name="support-media-compat-25.1.0" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="powermock-api-mockito-1.6.5" level="project" />
<orderEntry type="library" exported="" name="appcompat-v7-25.0.0" level="project" />
<orderEntry type="library" exported="" name="support-vector-drawable-25.0.0" level="project" />
<orderEntry type="library" exported="" name="support-vector-drawable-25.1.0" level="project" />
<orderEntry type="library" exported="" name="firebase-ads-10.0.1" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="junit-4.12" level="project" />
<orderEntry type="library" exported="" name="firebase-analytics-9.6.1" level="project" />
<orderEntry type="library" exported="" name="appcompat-v7-25.1.0" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="powermock-module-junit4-1.6.5" level="project" />
<orderEntry type="library" exported="" name="recyclerview-v7-25.0.0" level="project" />
<orderEntry type="library" exported="" name="recyclerview-v7-25.1.0" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="powermock-core-1.6.5" level="project" />
</component>
</module>
12 changes: 6 additions & 6 deletions admobadapter/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -15,7 +15,7 @@ repositories {

android {
compileSdkVersion 25
buildToolsVersion "24.0.3"
buildToolsVersion "25.0.2"

defaultConfig {
minSdkVersion 9
Expand All @@ -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'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down
Loading

0 comments on commit d36d1d6

Please sign in to comment.