Java Code Examples for com.google.android.gms.ads.NativeExpressAdView

The following are top voted examples for showing how to use com.google.android.gms.ads.NativeExpressAdView. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: justintrain-client-android   File: Ads.java   View source code 6 votes vote down vote up
public static void initializeAds(Context context, View bannerPlaceholder, NativeExpressAdView adView, AnalyticsHelper analyticsHelper, String screenName) {
    initializeAds(context, adView);

    adView.setAdListener(new AdListener() {
        @Override
        public void onAdLoaded() {
            apply(bannerPlaceholder, GONE);
            apply(adView, VISIBLE);
        }

        @Override
        public void onAdFailedToLoad(int i) {
            analyticsHelper.logScreenEvent(screenName, AD_FAILED_TO_LOAD);
        }

        @Override
        public void onAdClicked() {
            analyticsHelper.logScreenEvent(screenName, AD_CLICKED);
        }
    });
}
 
Example 2
Project: item-reaper   File: ItemDetailsFragment.java   View source code 6 votes vote down vote up
private void setUpAndLoadNativeExpressAds() {
    mCoordinatorLayout.post(new Runnable() {
        @Override
        public void run() {
            mNativeExpressAdView = new NativeExpressAdView(getContext());
            float scale = getActivity().getResources().getDisplayMetrics().density;
            int adWidth = mCoordinatorLayout.getWidth();
            AdSize adSize = new AdSize((int) (adWidth / scale), NATIVE_EXPRESS_AD_HEIGHT);
            mNativeExpressAdView.setAdSize(adSize);
            mNativeExpressAdView.setAdUnitId(getString(R.string.test_ad_unit_id));
            mAdViewContainer.addView(mNativeExpressAdView);

            // Load the first Native Express ad in the items list.
            AdRequest request = new AdRequest.Builder()
                    .addTestDevice("872EB083722CD10CAB1DB046CEE82A2D")
                    .build();
            mNativeExpressAdView.loadAd(request);
        }
    });
}
 
Example 3
Project: FwdPortForwardingApp   File: RuleListAdapter.java   View source code 6 votes vote down vote up
public AdViewHolder(View v ) {
    super(v);

    AdRequest request = new AdRequest.Builder()
            .addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
            .build();
    NativeExpressAdView adView = new NativeExpressAdView(v.getContext());
    adView.setAdSize(new AdSize(AdSize.FULL_WIDTH, 80));

    // Load ad type based on theme - dark or light
    if (PreferenceManager.getDefaultSharedPreferences(v.getContext())
            .getBoolean(PREF_DARK_THEME, false)) {
        adView.setAdUnitId(DARK_AD_ID);
    } else {
        adView.setAdUnitId(LIGHT_AD_ID);
    }
    ((LinearLayout) v).addView(adView, 1);
    adView.loadAd(request);
}
 
Example 4
Project: pubnative-android-sdk   File: AdMobNativeExpressAdapter.java   View source code 6 votes vote down vote up
@Override
protected void request(Context context, Map<String, String> networkData) {
    if (context == null || networkData == null) {
        invokeLoadFail(PNException.ADAPTER_ILLEGAL_ARGUMENTS);
    } else {
        String unitId = networkData.get(AdMob.KEY_UNIT_ID);

        if (TextUtils.isEmpty(unitId)) {
            invokeLoadFail(PNException.ADAPTER_MISSING_DATA);
        } else {

            mIsImpressionConfirmed = false;
            mIsReady = false;
            mAdView = null;
            mNativeAd = new NativeExpressAdView(mContext);
            mNativeAd.setAdSize(new AdSize(WIDTH,HEIGHT));
            mNativeAd.setAdUnitId(unitId);
            mNativeAd.setAdListener(mAdListener);
            mNativeAd.loadAd(AdMob.getAdRequest(context));
        }
    }
}
 
Example 5
Project: pubnative-android-sdk   File: AdMobNativeExpressAdapter.java   View source code 6 votes vote down vote up
@Override
protected void request(Context context, Map<String, String> networkData) {
    if (context == null || networkData == null) {
        invokeLoadFail(PNException.ADAPTER_ILLEGAL_ARGUMENTS);
    } else {
        String unitId = networkData.get(AdMob.KEY_UNIT_ID);
        if (TextUtils.isEmpty(unitId)) {
            invokeLoadFail(PNException.ADAPTER_MISSING_DATA);
        } else {

            mIsReady = false;
            mAdView = null;
            mIsImpressionConfirmed = false;
            mNativeAd = new NativeExpressAdView(mContext);
            mNativeAd.setAdSize(AdSize.MEDIUM_RECTANGLE);
            mNativeAd.setAdUnitId(unitId);
            mNativeAd.setAdListener(mAdListener);
            mNativeAd.loadAd(AdMob.getAdRequest(context));
        }
    }
}
 
Example 6
Project: MoonlightNote   File: SlashFragment.java   View source code 6 votes vote down vote up
@Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        View view = inflater.inflate(R.layout.fragment_slash, container, false);
        // initialize Admob
        MobileAds.initialize(mActivity, APP_ID);
        NativeExpressAdView adView = view.findViewById(R.id.adView);
        AdRequest request = new AdRequest.Builder()
//                .addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
//                .addTestDevice("0ACA1878D607E6C4360F91E0A0379C2F")
//                .addTestDevice("4DA2263EDB49C1F2C00F9D130B823096")
                .build();
        adView.loadAd(request);
        if (!adView.isLoading()) {
            adView.setVisibility(View.GONE);
        }
        return view;
    }
 
Example 7
Project: admobadapter   File: AdmobFetcherExpress.java   View source code 6 votes vote down vote up
/**
 * Fetches a new native ad.
 */
protected synchronized void fetchAd(final NativeExpressAdView adView) {
    if(mFetchFailCount > MAX_FETCH_ATTEMPT)
        return;

    Context context = mContext.get();

    if (context != null) {
        Log.i(TAG, "Fetching Ad now");
        new Handler(context.getMainLooper()).post(new Runnable() {
            @Override
            public void run() {
                adView.loadAd(getAdRequest()); //Fetching the ads item
            }
        });
    } else {
        mFetchFailCount++;
        Log.i(TAG, "Context is null, not fetching Ad");
    }
}
 
Example 8
Project: admobadapter   File: AdmobFetcherExpress.java   View source code 6 votes vote down vote up
/**
 * Subscribing to the native ads events
 * @param adView
 */
protected synchronized void setupAd(final NativeExpressAdView adView) {
    if(mFetchFailCount > MAX_FETCH_ATTEMPT)
        return;

    if(!mPrefetchedAds.contains(adView))
        mPrefetchedAds.add(adView);
    adView.setAdListener(new AdListener() {
        @Override
        public void onAdFailedToLoad(int errorCode) {
            super.onAdFailedToLoad(errorCode);
            // Handle the failure by logging, altering the UI, etc.
            onFailedToLoad(adView, errorCode);
        }
        @Override
        public void onAdLoaded() {
            super.onAdLoaded();
            onFetched(adView);
        }
    });
}
 
Example 9
Project: admobadapter   File: AdmobExpressAdapterWrapper.java   View source code 6 votes vote down vote up
/**
 * Creates N instances {@link NativeExpressAdView} from the next N taken instances {@link ExpressAdPreset}
 * Will start async prefetch of ad blocks to use its further
 * @return last created NativeExpressAdView
 */
private NativeExpressAdView prefetchAds(int cntToPrefetch){
    NativeExpressAdView last = null;
    for (int i = 0; i < cntToPrefetch; i++){
        final NativeExpressAdView item = AdViewHelper.getExpressAdView(mContext, adFetcher.takeNextAdPreset());
        adFetcher.setupAd(item);
        //50 ms throttling to prevent a high-load of server
        new Handler(mContext.getMainLooper()).postDelayed(new Runnable() {
            @Override
            public void run() {
                adFetcher.fetchAd(item);
            }
        }, 50 * i);
        last = item;
    }
    return last;
}
 
Example 10
Project: admobadapter   File: AdmobExpressRecyclerAdapterWrapper.java   View source code 6 votes vote down vote up
/**
 * Creates N instances {@link NativeExpressAdView} from the next N taken instances {@link ExpressAdPreset}
 * Will start async prefetch of ad blocks to use its further
 * @return last created NativeExpressAdView
 */
private NativeExpressAdView prefetchAds(int cntToPrefetch){
    NativeExpressAdView last = null;
    for (int i = 0; i < cntToPrefetch; i++) {
        final NativeExpressAdView item = AdViewHelper.getExpressAdView(mContext, adFetcher.takeNextAdPreset());
        adFetcher.setupAd(item);
        //50 ms throttling to prevent a high-load of server
        new Handler(mContext.getMainLooper()).postDelayed(new Runnable() {
            @Override
            public void run() {
                adFetcher.fetchAd(item);
            }
        }, 50 * i);
        last = item;
    }
    return last;
}
 
Example 11
Project: admobadapter   File: AdmobExpressRecyclerAdapterWrapper.java   View source code 6 votes vote down vote up
@Override
public void onBindViewHolder(RecyclerView.ViewHolder viewHolder, int position) {
    if (viewHolder == null)
        return;
    if(viewHolder.getItemViewType() == getViewTypeAdExpress()) {
        NativeHolder nativeExpressHolder = (NativeHolder) viewHolder;
        ViewGroup wrapper = nativeExpressHolder.getAdViewWrapper();
        int adPos = AdapterCalculator.getAdIndex(position);
        NativeExpressAdView adView = adFetcher.getAdForIndex(adPos);
        if (adView == null)
            adView = prefetchAds(1);
        AdViewWrappingStrategy.recycleAdViewWrapper(wrapper, adView);
        //make sure the AdView for this position doesn't already have a parent of a different recycled NativeExpressHolder.
        if (adView.getParent() != null)
            ((ViewGroup) adView.getParent()).removeView(adView);
        AdViewWrappingStrategy.addAdViewToWrapper(wrapper, adView);

    } else {
        int origPos = AdapterCalculator.getOriginalContentPosition(position,
                adFetcher.getFetchingAdsCount(), mAdapter.getItemCount());
        mAdapter.onBindViewHolder(viewHolder, origPos);
    }
}
 
Example 12
Project: admobadapter   File: AdmobExpressRecyclerAdapterWrapper.java   View source code 6 votes vote down vote up
@Override
public void onAdFailed(int adIdx, int errorCode, Object adPayload) {
    NativeExpressAdView adView = (NativeExpressAdView)adPayload;
    if (adView != null) {
        ViewParent parent = adView.getParent();
        if(parent == null || parent instanceof RecyclerView)
            adView.setVisibility(View.GONE);
        else {
            while (parent.getParent() != null && !(parent.getParent() instanceof RecyclerView))
                parent = parent.getParent();
            ((View) parent).setVisibility(View.GONE);
        }
    }
    int pos = getAdapterCalculator().translateAdToWrapperPosition(Math.max(adIdx,0));
    notifyItemRangeChanged(pos, pos+15);
}
 
Example 13
Project: justintrain-client-android   File: Ads.java   View source code 5 votes vote down vote up
public static void initializeAds(Context context, NativeExpressAdView adView) {
    MobileAds.initialize(context, "ca-app-pub-8963908741443055~4285788324");
    AdRequest adRequest = new AdRequest.Builder()
            .addTestDevice(AdRequest.DEVICE_ID_EMULATOR)        // All emulators
            .addTestDevice("EF67DDDDDDD0896B1B02876D927AC309")  // An example device ID
            .build();
    Log.d("initializeAds: ", adView.getAdUnitId());
    adView.loadAd(adRequest);
}
 
Example 14
Project: ascii_generate   File: MainActivity.java   View source code 5 votes vote down vote up
private void loadAdView() {
    if (BuildConfig.IS_PREMIUM_USER || hasPremiumApp()) {
        findViewById(R.id.card_ad_view).setVisibility(View.GONE);
        findViewById(R.id.btn_remove_ads).setVisibility(View.GONE);
        return;
    }
    mAdView = (NativeExpressAdView) findViewById(R.id.native_ad_view);
    if (mAdView != null) {
        mAdView.loadAd(new AdRequest.Builder().build());
    }
}
 
Example 15
Project: ascii_generate   File: AdBannerActivity.java   View source code 5 votes vote down vote up
protected void loadNativeAd() {
    try {
        mNativeExpressAdView = (NativeExpressAdView) findViewById(R.id.native_ad_view);
        if (mNativeExpressAdView != null) {
            if (BuildConfig.IS_PREMIUM_USER) {
                mNativeExpressAdView.setVisibility(View.GONE);
            } else {
                mNativeExpressAdView.loadAd(new AdRequest.Builder().build());
            }
        }
    } catch (Exception e) {

    }
}
 
Example 16
Project: B4A_FirebaseAdMob   File: AdViewWrapper.java   View source code 5 votes vote down vote up
/**
 * Initializes the ad view.
 *EventName - Sets the subs that will handle the events.
 *AdUnitId - Ad unit ID of a native ad.
 *Width - Requested ad width.
 *Height - Requested ad height.
 */
public void Initialize(final BA ba, String EventName, String AdUnitId, float Width, float Height) {
	NativeExpressAdView ad = new NativeExpressAdView(ba.activity);
	ad.setAdSize(new AdSize((int)Math.round(Width / Common.Density), (int)Math.round(Height / Common.Density)));
	ad.setAdUnitId(AdUnitId);
	setObject(ad);
	super.Initialize(ba, EventName);
	final String eventName = EventName.toLowerCase(BA.cul);
	getObject().setAdListener(new AdListener() {

		@Override
		public void onAdFailedToLoad(int e){
			ba.raiseEvent(getObject(), eventName + "_failedtoreceivead", String.valueOf(e));
		}
		@Override
		public void onAdLoaded() {
			ba.raiseEvent(getObject(), eventName + "_receivead");
		}
		@Override
		public void onAdClosed() {
			ba.raiseEventFromDifferentThread(getObject(), null, 0, eventName + "_adscreendismissed", false, null);
		}
		@Override
		public void onAdLeftApplication() {
			//
		}
		@Override
		public void onAdOpened() {
			ba.raiseEventFromDifferentThread(getObject(), null, 0, eventName + "_presentscreen", false, null);

		}
	});
}
 
Example 17
Project: pubnative-android-sdk   File: AdMobNativeExpressAdapter.java   View source code 5 votes vote down vote up
@Override
protected void request(Context context, Map<String, String> networkData) {
    if (context == null || networkData == null) {
        invokeLoadFail(PNException.ADAPTER_ILLEGAL_ARGUMENTS);
    } else {
        String unitId = networkData.get(AdMob.KEY_UNIT_ID);
        if (TextUtils.isEmpty(unitId)) {
            invokeLoadFail(PNException.ADAPTER_MISSING_DATA);
        } else {
            mIsImpressionConfirmed = false;
            mAdView = null;
            mNativeAd = new NativeExpressAdView(mContext);

            DisplayMetrics displayMetrics = new DisplayMetrics();

            if(context instanceof Activity) {
                ((Activity) context).getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
                int heightDP = PNDeviceUtils.convertPxToDp(displayMetrics.heightPixels, context);
                heightDP = Math.min(Math.max(heightDP, MIN_HEIGHT), MAX_HEIGHT);
                int widthDP = PNDeviceUtils.convertPxToDp(displayMetrics.widthPixels, context);
                widthDP = Math.min(Math.max(widthDP, MIN_WIDTH), MAX_WIDTH);
                mNativeAd.setAdSize(new AdSize(widthDP, heightDP));
                mNativeAd.setAdUnitId(unitId);
                mNativeAd.setAdListener(mAdListener);
                mNativeAd.loadAd(AdMob.getAdRequest(context));
            } else {
                invokeLoadFail(PNException.ADAPTER_ILLEGAL_ARGUMENTS);
            }
        }
    }
}
 
Example 18
Project: android-protwall   File: ActivityFirst.java   View source code 5 votes vote down vote up
private void initBannerAds() {
    // Look up the AdView as a resource and load a request.
    NativeExpressAdView adView = (NativeExpressAdView)this.findViewById(R.id.main_adView);
    AdRequest adRequest = new AdRequest.Builder()
            .addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
            .addTestDevice("BABB35E2F44BD42D7B74D736D34239F2")
            .build();
    adView.loadAd(adRequest);

    //Mechanism to prevent interstitial displaying when banner is active
    adView.setAdListener(new AdListener() {
        @Override
        public void onAdLoaded() {
            // Code to be executed when an ad finishes loading.
            isAdActive = false;
        }
        @Override
        public void onAdOpened() {
            // Code to be executed when an ad opens an overlay that
            // covers the screen.
            isAdActive = true;
        }

        @Override
        public void onAdLeftApplication() {
            // Code to be executed when the user has left the app.
            isAdActive = true;
        }

    });
}
 
Example 19
Project: admobadapter   File: AdViewHelper.java   View source code 5 votes vote down vote up
public static NativeExpressAdView getExpressAdView(Context context, ExpressAdPreset expressAdPreset) {
    NativeExpressAdView adView = new NativeExpressAdView(context);
    AdSize adSize = expressAdPreset.getAdSize();
    adView.setAdSize(adSize);
    adView.setAdUnitId(expressAdPreset.getAdUnitId());
    adView.setLayoutParams(new AbsListView.LayoutParams(AbsListView.LayoutParams.MATCH_PARENT,
            adSize.getHeightInPixels(context)));

    //set video options
    if(expressAdPreset.getVideoOptions() != null)
    adView.setVideoOptions(expressAdPreset.getVideoOptions());

    return adView;
}
 
Example 20
Project: admobadapter   File: AdmobFetcherExpress.java   View source code 5 votes vote down vote up
/**
 * A handler for received native ads
 * @param adView
 */
private synchronized void onFetched(NativeExpressAdView adView) {
    Log.i(TAG, "onAdFetched");
    mFetchFailCount = 0;
    mNoOfFetchedAds++;
    onAdLoaded(mNoOfFetchedAds - 1);
}
 
Example 21
Project: admobadapter   File: AdmobFetcherExpress.java   View source code 5 votes vote down vote up
/**
 * A handler for failed native ads
 * @param adView
 */
private synchronized void onFailedToLoad(NativeExpressAdView adView, int errorCode) {
    Log.i(TAG, "onAdFailedToLoad " + errorCode);
    mFetchFailCount++;
    mNoOfFetchedAds = Math.max(mNoOfFetchedAds - 1, 0);
    //Since Fetch Ad is only called once without retries
    //hide ad row / rollback its count if still not added to list
    mPrefetchedAds.remove(adView);
    onAdFailed(mNoOfFetchedAds - 1, errorCode, adView);
}
 
Example 22
Project: admobadapter   File: AdmobFetcherExpress.java   View source code 5 votes vote down vote up
@Override
public synchronized void destroyAllAds() {
    super.destroyAllAds();
    for(NativeExpressAdView ad:mPrefetchedAds){
        ad.destroy();
    }
    mPrefetchedAds.clear();
}
 
Example 23
Project: admobadapter   File: AdViewWrappingStrategy.java   View source code 5 votes vote down vote up
/**
 * This method can be overriden to recycle (remove) {@param ad} from {@param wrapper} view before adding to wrap.
 * By default it will look for {@param ad} in the direct children of {@param wrapper} and remove the first occurence.
 * See the super's implementation for instance.
 * The NativeExpressHolder recycled by the RecyclerView may be a different
 * instance than the one used previously for this position. Clear the
 * wrapper of any subviews in case it has a different
 * AdView associated with it
 */
@Override
protected void recycleAdViewWrapper(@NonNull ViewGroup wrapper, @NonNull NativeExpressAdView ad) {
    for (int i = 0; i < wrapper.getChildCount(); i++) {
        View v = wrapper.getChildAt(i);
        if (v instanceof NativeExpressAdView) {
            wrapper.removeViewAt(i);
            break;
        }
    }
}
 
Example 24
Project: admobadapter   File: AdmobExpressAdapterWrapper.java   View source code 5 votes vote down vote up
@Override
public void onAdFailed(int adIdx, int errorCode, Object adPayload) {
    NativeExpressAdView adView = (NativeExpressAdView)adPayload;
    if (adView != null) {
        ViewParent parent = adView.getParent();
        if(parent == null || parent instanceof ListView)
            adView.setVisibility(View.GONE);
        else {
            while (parent.getParent() != null && !(parent.getParent() instanceof ListView))
                parent = parent.getParent();
            ((View) parent).setVisibility(View.GONE);
        }
    }
    notifyDataSetChanged();
}
 
Example 25
Project: Calendouer   File: CelebrityActivity.java   View source code 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_celebrity);

    type = getIntent().getStringExtra("type");

    todayMovie = new Gson().fromJson(
            sharedPref.getString("movie_json", ""),
            MovieBean.class
    );
    if (todayMovie == null) {
        finish();
    }

    subjectPB = (ProgressBar) findViewById(R.id.subject_loading);

    celebrityImageIV = (ImageView) findViewById(R.id.celebrity_image);
    celebrityNameTV = (TextView) findViewById(R.id.celebrity_name);
    genderTV = (TextView) findViewById(R.id.gender);
    bornPlaceTV = (TextView) findViewById(R.id.born_place);
    akaEnTV = (TextView) findViewById(R.id.aka_en);
    akaTV = (TextView) findViewById(R.id.aka);
    subjectTitleTV = (TextView) findViewById(R.id.subject_title);
    gotoDouban = (Button) findViewById(R.id.goto_douban);
    toolbar = (Toolbar) findViewById(R.id.toolbar);
    recyclerView = (RecyclerView) findViewById(R.id.subject_recycler_view);
    subjectMoreBtn = (Button) findViewById(R.id.subject_more);
    celebrityInfo = (LinearLayout) findViewById(R.id.celebrity_info);
    ratingUs = (LinearLayout) findViewById(R.id.rating_us_card);
    adView = (NativeExpressAdView) findViewById(R.id.adView);

    findViewById(R.id.after_ad_closed_rate).setOnClickListener(this);
    findViewById(R.id.after_ad_closed_restore).setOnClickListener(this);

    initView();

    setSupportActionBar(toolbar);
    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        // Show the Up button in the action bar.
        actionBar.setHomeAsUpIndicator(R.drawable.ic_arrow_back_24dp);
        actionBar.setDisplayHomeAsUpEnabled(true);
    }

    // ad
    if (settingPref.getBoolean("ad_show", true)) {
        adView.setVisibility(View.VISIBLE);
        ratingUs.setVisibility(View.GONE);
        initAd();
    } else {
        adView.setVisibility(View.GONE);
        ratingUs.setVisibility(View.VISIBLE);
    }
}
 
Example 26
Project: Calendouer   File: MainActivity.java   View source code 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    pinIV = (ImageView) findViewById(R.id.today_pin);
    pinIV.setOnClickListener(this);

    weatherCard = (LinearLayout) findViewById(R.id.weather_card);
    movieCard = (LinearLayout) findViewById(R.id.movie_card);
    todayMovieCard = (LinearLayout) findViewById(R.id.today_movie_card);
    inTheatersCard = (LinearLayout) findViewById(R.id.in_theaters_card);
    comingSoonCard = (LinearLayout) findViewById(R.id.coming_soon_card);
    youMayLikeCard = (LinearLayout) findViewById(R.id.you_may_like_card);
    ratingUs = (LinearLayout) findViewById(R.id.rating_us_card);
    adView = (NativeExpressAdView) findViewById(R.id.adView);

    inTheatersRecyclerHolder = (RecyclerView) findViewById(R.id.in_theaters_recycler_holder);
    comingSoonRecyclerHolder = (RecyclerView) findViewById(R.id.coming_soon_recycler_holder);
    inTheatersRecyclerHolder.setNestedScrollingEnabled(false);
    comingSoonRecyclerHolder.setNestedScrollingEnabled(false);

    directorTV = (TextView) findViewById(R.id.director);
    castsTV1 = (TextView) findViewById(R.id.casts_1);
    castsTV2 = (TextView) findViewById(R.id.casts_2);
    genresTV = (TextView) findViewById(R.id.genres);
    sameNameTV = (TextView) findViewById(R.id.same_name);

    progressOfDay = findViewById(R.id.progress_day);
    collapsingToolbarLayout = (CollapsingToolbarLayout) findViewById(R.id.collapsing_toolbar);
    nestedScrollView = (NestedScrollView) findViewById(R.id.nest_scroll_view);

    monthDayTV = (TextView) findViewById(R.id.month_day);
    weekTV = (TextView) findViewById(R.id.week_day);
    lunarTV = (TextView) findViewById(R.id.lunar_date);
    dateTV = (TextView) findViewById(R.id.date);
    solarTermTV = (TextView) findViewById(R.id.solar_term);
    festivalTV = (TextView) findViewById(R.id.festival);
    weatherHolder = (RelativeLayout) findViewById(R.id.weatherHolder);
    getWeatherBtn = (AppCompatButton) findViewById(R.id.getWeatherInfo);
    cityNameTV = (TextView) findViewById(R.id.city_name);
    weatherTV = (TextView) findViewById(R.id.weather);
    weatherIconIV = (ImageView) findViewById(R.id.weather_icon);
    weatherIconIV.setOnClickListener(this);

    movieCardCover = (ImageView) findViewById(R.id.movie_card_cover);
    movieImageIV = (ImageView) findViewById(R.id.movie_image);
    movieAverageTV = (TextView) findViewById(R.id.rating__average);
    movieTitleTV = (TextView) findViewById(R.id.movie_title);
    movieSummaryTV = (TextView) findViewById(R.id.movie_summary);
    starsHolderLL = (LinearLayout) findViewById(R.id.rating__stars_holder);

    getTop250Btn = (AppCompatButton) findViewById(R.id.getTop250_btn);
    dbHelper = new DBHelper(this);
    icons = new WeatherIcon();
    sharedPref.registerOnSharedPreferenceChangeListener(this);
    settingPref.registerOnSharedPreferenceChangeListener(this);
    locationMgr = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE);

    color = ContextCompat.getColor(this, R.color.colorPrimary);
    colorDark = ContextCompat.getColor(this, R.color.colorPrimaryDark);

    findViewById(R.id.after_ad_closed_rate).setOnClickListener(this);
    findViewById(R.id.after_ad_closed_restore).setOnClickListener(this);
}
 
Example 27
Project: MTweaks-KernelAdiutorMOD   File: AdNativeExpress.java   View source code 4 votes vote down vote up
public AdNativeExpress(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);

    LayoutInflater.from(context).inflate(R.layout.ad_native_express_view, this);
    mNativeAdLayout = (FrameLayout) findViewById(R.id.ad_layout);
    mProgress = findViewById(R.id.progress);
    mAdText = findViewById(R.id.ad_text);
    mGHImage = (AppCompatImageView) findViewById(R.id.gh_image);

    findViewById(R.id.remove_ad).setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            ViewUtils.dialogDonate(v.getContext()).show();
        }
    });

    mNativeExpressAdView = new NativeExpressAdView(context);
    mNativeExpressAdView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));
    mNativeExpressAdView.setAdUnitId(getContext().getString(Utils.DARK_THEME ?
            R.string.native_express_id_dark : R.string.native_express_id_light));
    mNativeExpressAdView.setAdListener(new AdListener() {
        @Override
        public void onAdFailedToLoad(int i) {
            super.onAdFailedToLoad(i);
            mNativeLoading = false;
            mNativeLoaded = false;
            mNativeFailedLoading = true;
            loadGHAd();
        }

        @Override
        public void onAdLoaded() {
            super.onAdLoaded();
            mNativeLoaded = true;
            mNativeLoading = false;
            mNativeFailedLoading = false;
            mProgress.setVisibility(GONE);
            mNativeAdLayout.addView(mNativeExpressAdView);
        }
    });
}
 
Example 28
Project: KernelAdiutor-Mod   File: AdNativeExpress.java   View source code 4 votes vote down vote up
public AdNativeExpress(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);

    LayoutInflater.from(context).inflate(R.layout.ad_native_express_view, this);
    mNativeAdLayout = (FrameLayout) findViewById(R.id.ad_layout);
    mProgress = findViewById(R.id.progress);
    mAdText = findViewById(R.id.ad_text);
    mGHImage = (AppCompatImageView) findViewById(R.id.gh_image);

    findViewById(R.id.remove_ad).setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            ViewUtils.dialogDonate(v.getContext()).show();
        }
    });

    mNativeExpressAdView = new NativeExpressAdView(context);
    mNativeExpressAdView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));
    mNativeExpressAdView.setAdUnitId(getContext().getString(Utils.DARK_THEME ?
            R.string.native_express_id_dark : R.string.native_express_id_light));
    mNativeExpressAdView.setAdListener(new AdListener() {
        @Override
        public void onAdFailedToLoad(int i) {
            super.onAdFailedToLoad(i);
            mNativeLoading = false;
            mNativeLoaded = false;
            mNativeFailedLoading = true;
            loadGHAd();
        }

        @Override
        public void onAdLoaded() {
            super.onAdLoaded();
            mNativeLoaded = true;
            mNativeLoading = false;
            mNativeFailedLoading = false;
            mProgress.setVisibility(GONE);
            mNativeAdLayout.addView(mNativeExpressAdView);
        }
    });
}
 
Example 29
Project: SaveIg   File: MainActivity.java   View source code 4 votes vote down vote up
private void initializeAd() {
    NativeExpressAdView avNativeAd = (NativeExpressAdView) findViewById(R.id.av_nativeAd);
    avNativeAd.loadAd(new AdRequest.Builder().build());
}
 
Example 30
Project: Firebase   File: MainActivity.java   View source code 4 votes vote down vote up
private void initView() {
    adv_banner = (AdView) findViewById(R.id.main_adv_banner);
    bt_insert_page = (Button) findViewById(R.id.main_bt_insert_page);
    neadv_native = (NativeExpressAdView) findViewById(R.id.main_neadv_native);
}
 
Example 31
Project: admobadapter   File: AdViewWrappingStrategy.java   View source code 4 votes vote down vote up
/**
 * Add the Native Express {@param ad} to {@param wrapper}.
 * See the super's implementation for instance.
 */
@Override
protected void addAdViewToWrapper(@NonNull ViewGroup wrapper, @NonNull NativeExpressAdView ad) {
    wrapper.addView(ad);
}
 
Example 32
Project: KernelAdiutor   File: AdNativeExpress.java   View source code 4 votes vote down vote up
public AdNativeExpress(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);

    LayoutInflater.from(context).inflate(R.layout.ad_native_express_view, this);
    mNativeAdLayout = (FrameLayout) findViewById(R.id.ad_layout);
    mProgress = findViewById(R.id.progress);
    mAdText = findViewById(R.id.ad_text);
    mGHImage = (AppCompatImageView) findViewById(R.id.gh_image);

    findViewById(R.id.remove_ad).setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            ViewUtils.dialogDonate(v.getContext()).show();
        }
    });

    mNativeExpressAdView = new NativeExpressAdView(context);
    mNativeExpressAdView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));
    mNativeExpressAdView.setAdUnitId(getContext().getString(Utils.DARK_THEME ?
            R.string.native_express_id_dark : R.string.native_express_id_light));
    mNativeExpressAdView.setAdListener(new AdListener() {
        @Override
        public void onAdFailedToLoad(int i) {
            super.onAdFailedToLoad(i);
            mNativeLoading = false;
            mNativeLoaded = false;
            mNativeFailedLoading = true;
            loadGHAd();
        }

        @Override
        public void onAdLoaded() {
            super.onAdLoaded();
            mNativeLoaded = true;
            mNativeLoading = false;
            mNativeFailedLoading = false;
            mProgress.setVisibility(GONE);
            mNativeAdLayout.addView(mNativeExpressAdView);
        }
    });
}
 
Example 33
Project: BookED   File: AllBooksAdapter.java   View source code 3 votes vote down vote up
public MyViewHolder(View view) {
    super(view);
    book_name = (TextView) view.findViewById(R.id.mbl_bookname);

    book_author = (TextView) view.findViewById(R.id.mbl_bookauthor);

    //book_description = (TextView) view.findViewById(R.id.mbl_bookdescription);

    book_image = (ImageView) view.findViewById(R.id.mbl_bookimage);

    book_exchange_donate = (TextView) view.findViewById(R.id.mbl_exchange_donate);

    book_date_posted = (TextView) view.findViewById(R.id.mbl_date_posted);

    NativeExpressAdView mAdView = (NativeExpressAdView)view.findViewById(R.id.adViewNative);
    AdRequest adRequest = new AdRequest.Builder()
            .addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
            .addTestDevice("19958886412D28A5FFC7BA20F66C6FF5")
            .build();

        if (mAdView != null) {

            mAdView.loadAd(adRequest);
        }




}
 
Example 34
Project: SecretBrand   File: ListHolderActivity.java   View source code 2 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    Log.d(TAG, "onCreate() called with: " + "savedInstanceState = [" + this.getDatabasePath("dota2.db") + "]");
    setTheme(R.style.Infodota);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main_fragment_holder);

    TypefaceUtil.overrideFont(getApplicationContext(), "SERIF", "fonts/future.ttf"); // font from assets: "assets/fonts/Roboto-Regular.ttf

    //mActionMenuView.setPresenter(new ActionMenuPresenter(this));

    FacebookSdk.sdkInitialize(getApplicationContext());

    // Initialize the Mobile Ads SDK.§

    MobileAds.initialize(this, getString(R.string.banner_ad_unit_id));


   /* Chartboost.startWithAppId(this, getString(R.string.appIDChartboost), getString(R.string.appSignature));
    Chartboost.onCreate(this);*/

    AppEventsLogger.activateApp(this);

    MenuFragment.updateActivity(this);

    Log.d(TAG, "onCreate() called with: " + "savedInstanceState = [" + savedInstanceState + "]");

    ActionBar bar = getSupportActionBar();
    bar.setDisplayShowTitleEnabled(false);
    bar.setDisplayShowHomeEnabled(false);

    SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
    preferences.edit().remove("mainMenuLastSelected").commit();

    // BinhTran comment 23/03 for calling redundant
    // UpdateUtils.checkNewVersion(this, false);


    navSpinner = (Spinner) mToolbar.findViewById(R.id.nav_spinner);
    ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
            R.layout.spinner_item, getResources().getStringArray(R.array.main_menu));
    adapter.setDropDownViewResource(R.layout.spinner_dropdown_item);
    navSpinner.setAdapter(adapter);
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
    int selected = prefs.getInt("mainMenuLastSelected", 0);

    navSpinner.setOnItemSelectedListener(this);
    navSpinner.setSelection(Math.min(selected, adapter.getCount() - 1));
    // navSpinner.setVisibility(View.GONE);

    initUI();

    initControl();

    UpdateUtils.checkNewVersion(this, false);

    appContext = this;

    AppRater.showRate(appContext);

    adView = (NativeExpressAdView) findViewById(R.id.adView);

    AdRequest request = new AdRequest.Builder()
            .addTestDevice("121EC3F83A2EAFBD46DB00F1773A13A0")
            .build();
    adView.loadAd(request);
    visiableAdview(8);
    //не нужен AppRater.onAppLaunched(this);
}
 
Example 35
Project: admobadapter   File: AdViewWrappingStrategyBase.java   View source code 2 votes vote down vote up
/**
 * Add the Native Express {@param ad} to {@param wrapper}.
 * See the super's implementation for instance.
 */
protected abstract void addAdViewToWrapper(@NonNull ViewGroup wrapper, @NonNull NativeExpressAdView ad);
 
Example 36
Project: admobadapter   File: AdViewWrappingStrategyBase.java   View source code 2 votes vote down vote up
/**
 * This method can be overriden to recycle (remove) {@param ad} from {@param wrapper} view before adding to wrap.
 * By default it will look for {@param ad} in the direct children of {@param wrapper} and remove the first occurence.
 * See the super's implementation for instance.
 * The NativeExpressHolder recycled by the RecyclerView may be a different
 * instance than the one used previously for this position. Clear the
 * wrapper of any subviews in case it has a different
 * AdView associated with it
 */
protected abstract  void recycleAdViewWrapper(@NonNull ViewGroup wrapper, @NonNull NativeExpressAdView ad);
 
Example 37
Project: admobadapter   File: AdmobFetcherExpress.java   View source code 2 votes vote down vote up
/**
 * Gets native ad at a particular index in the fetched ads list.
 *
 * @param adPos the index of ad in the fetched ads list
 * @return the native ad in the list
 * @see #getFetchedAdsCount()
 */
public synchronized NativeExpressAdView getAdForIndex(int adPos) {
    if(adPos >= 0 && mPrefetchedAds.size() > adPos)
        return mPrefetchedAds.get(adPos);
    return null;
}