Search in sources :

Example 6 with AdRequest

use of com.google.android.gms.ads.AdRequest in project Space-Station-Tracker by Kiarasht.

the class PeopleinSpace method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.people_in_space_layout);
    mRecyclerView = (RecyclerView) findViewById(R.id.recycler);
    mActivity = this;
    SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
    mRequestQueue = Volley.newRequestQueue(this);
    display_people();
    // Show an ad, or hide it if its disabled
    if (!sharedPreferences.getBoolean("advertisement", false)) {
        adView = (AdView) findViewById(R.id.adView);
        AdRequest adRequest = new AdRequest.Builder().addTestDevice(getString(R.string.test_device)).build();
        if (adView != null) {
            adView.loadAd(adRequest);
            adView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {

                @Override
                public void onGlobalLayout() {
                    if (!mPaddingOnce) {
                        mPaddingOnce = true;
                        mRecyclerView.setPadding(mRecyclerView.getPaddingLeft(), mRecyclerView.getPaddingTop(), mRecyclerView.getPaddingRight(), mRecyclerView.getPaddingBottom() + adView.getHeight());
                    }
                }
            });
        }
    } else {
        findViewById(R.id.adView).setVisibility(View.GONE);
    }
}
Also used : AdRequest(com.google.android.gms.ads.AdRequest) SharedPreferences(android.content.SharedPreferences) ViewTreeObserver(android.view.ViewTreeObserver)

Example 7 with AdRequest

use of com.google.android.gms.ads.AdRequest in project Space-Station-Tracker by Kiarasht.

the class MapsActivity method requestNewInterstitial.

/**
     * Request for a new interstitial ad
     */
private void requestNewInterstitial() {
    if (!mSharedPreferences.getBoolean("fullPage", false)) {
        AdRequest adRequest = new AdRequest.Builder().addTestDevice(getString(R.string.test_device)).build();
        mInterstitialAd.loadAd(adRequest);
    }
}
Also used : AdRequest(com.google.android.gms.ads.AdRequest)

Example 8 with AdRequest

use of com.google.android.gms.ads.AdRequest in project Space-Station-Tracker by Kiarasht.

the class MapsActivity method initializeAds.

/**
     * Initialize ads when the activity is started for the first time
     */
private void initializeAds() {
    SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
    mapFragment.getMapAsync(this);
    MobileAds.initialize(mContext, getString(R.string.app_ID_Main));
    // Initiate the interstitial ad and onAdClosed listener
    mInterstitialAd = new InterstitialAd(this);
    mInterstitialAd.setAdUnitId(getString(R.string.interstitial_ad_unit_id));
    mInterstitialAd.setAdListener(new AdListener() {

        @Override
        public void onAdClosed() {
            requestNewInterstitial();
            switch(mInterstitialAdActivity) {
                case 0:
                    startActivity(new Intent(mContext, Locations.class));
                    break;
                case 1:
                    startActivity(new Intent(mContext, PeopleinSpace.class));
                    break;
            }
        }
    });
    if (!mSharedPreferences.getBoolean("advertisement", false)) {
        mAdView = (AdView) findViewById(R.id.adView);
        AdRequest adRequest = new AdRequest.Builder().addTestDevice(getString(R.string.test_device)).build();
        mAdView.loadAd(adRequest);
    } else if (mAdView == null) {
        findViewById(R.id.adView).setVisibility(View.GONE);
    }
}
Also used : SupportMapFragment(com.google.android.gms.maps.SupportMapFragment) AdRequest(com.google.android.gms.ads.AdRequest) InterstitialAd(com.google.android.gms.ads.InterstitialAd) Intent(android.content.Intent) AdListener(com.google.android.gms.ads.AdListener)

Example 9 with AdRequest

use of com.google.android.gms.ads.AdRequest in project YourAppIdea by Michenux.

the class YourAppMainActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    ((YourApplication) getApplication()).inject(this);
    setContentView(R.layout.main);
    // toolbar
    Toolbar toolBar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolBar);
    // For debug
    if (BuildConfig.DEBUG) {
        Log.d(YourApplication.LOG_TAG, "HashKey: " + SecurityUtils.logHashKey(this));
    }
    // app usage
    AppUsageUtils.updateLastUsedTimestamp(this);
    // init fragment
    if (savedInstanceState == null) {
        this.navController.goHomeFragment(this);
        this.navController.showWhatsNew(this);
    }
    // ads
    mAdView = (AdView) findViewById(R.id.adView);
    AdRequest adRequest = new AdRequest.Builder().addTestDevice(AdRequest.DEVICE_ID_EMULATOR).addTestDevice("1174B15820BDCDE357023377AAF1D72D").addTestDevice("FB73634EFAFEF29BE7973A97B5543A4D").addTestDevice(//LG Nexus 5
    "3C4438D5DE2E7086B63C92FC5846F662").build();
    mAdView.loadAd(adRequest);
    // social networks
    mFacebookDelegate = new FacebookDelegate(mUserHelper, this);
    mFacebookDelegate.setUserSessionCallback(this);
    mGoogleAuthDelegate = new GoogleAuthDelegate(this, mUserHelper);
    mGoogleAuthDelegate.setUserSessionCallback(this);
}
Also used : YourApplication(org.michenux.yourappidea.YourApplication) AdRequest(com.google.android.gms.ads.AdRequest) FacebookDelegate(org.michenux.yourappidea.facebook.FacebookDelegate) GoogleAuthDelegate(org.michenux.drodrolib.gms.auth.GoogleAuthDelegate) Toolbar(android.support.v7.widget.Toolbar)

Aggregations

AdRequest (com.google.android.gms.ads.AdRequest)9 AdView (com.google.android.gms.ads.AdView)3 SharedPreferences (android.content.SharedPreferences)2 ViewTreeObserver (android.view.ViewTreeObserver)2 AdListener (com.google.android.gms.ads.AdListener)2 InterstitialAd (com.google.android.gms.ads.InterstitialAd)2 Intent (android.content.Intent)1 Handler (android.os.Handler)1 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)1 Toolbar (android.support.v7.widget.Toolbar)1 View (android.view.View)1 LinearLayout (android.widget.LinearLayout)1 RelativeLayout (android.widget.RelativeLayout)1 SupportMapFragment (com.google.android.gms.maps.SupportMapFragment)1 DecimalFormat (java.text.DecimalFormat)1 Timer (java.util.Timer)1 TimerTask (java.util.TimerTask)1 GoogleAuthDelegate (org.michenux.drodrolib.gms.auth.GoogleAuthDelegate)1 YourApplication (org.michenux.yourappidea.YourApplication)1 FacebookDelegate (org.michenux.yourappidea.facebook.FacebookDelegate)1