jeudi 20 avril 2017

Class 'Anonymous class derived from AdListener' must either be declared abstract or implement abstract method 'onLoggingImpressionMethod(Ad)'

Error: Class 'Anonymous class derived from AdListener' must either be declared abstract or implement abstract method 'onLoggingImpressionMethod(Ad)' in 'AdListener'

Here is my code:

public class AdvancedAnswerListAdapter extends RecyclerView.Adapter implements Constants {

private List<Answer> items = new ArrayList<>();

private Context context;

ImageLoader imageLoader = App.getInstance().getImageLoader();

private OnItemMenuButtonClickListener onItemMenuButtonClickListener;

public interface OnItemMenuButtonClickListener {

    void onItemClick(View view, Answer obj, int actionId, int position);
}

public void setOnMoreButtonClickListener(final OnItemMenuButtonClickListener onItemMenuButtonClickListener) {

    this.onItemMenuButtonClickListener = onItemMenuButtonClickListener;
}

// FB Native AD
private NativeAd mFBNativeAd;

public class ViewHolder extends RecyclerView.ViewHolder {

    public CircularImageView mItemAuthorPhoto, mItemAuthorIcon;
    public TextView mItemAuthor, mItemAuthorUsername;
    public ImageView mItemAuthorOnlineIcon, mItemPlayVideo;
    public ImageView mItemMenuButton;
    public ResizableImageView mItemImg;
    public ImageView mItemLikeImg, mItemAnswerImg, mItemShareImg;
    public TextView mItemLikesCount, mItemAnswersCount;
    public EmojiconTextView mItemDescription;
    public TextView mItemTimeAgo;
    public ProgressBar mProgressBar;
    public MaterialRippleLayout mItemLikeButton, mItemAnswerButton, mItemShareButton;

    public LinearLayout mLinkContainer;
    public ImageView mLinkImage;
    public TextView mLinkTitle;
    public TextView mLinkDescription;

    // FB Native Ad Views
    ImageView nativeAdIcon ;
    TextView nativeAdTitle;
    MediaView nativeAdMedia ;
    TextView nativeAdSocialContext ;
    TextView nativeAdBody ;
    Button nativeAdCallToAction ;
    LinearLayout adContainer,adChoicesContainer ;



    public ViewHolder(View v, int itemType) {

        super(v);

        if (itemType == 0) {

            mItemAuthorPhoto = (CircularImageView) v.findViewById(R.id.itemAuthorPhoto);
            mItemAuthorIcon = (CircularImageView) v.findViewById(R.id.itemAuthorIcon);

            mItemAuthor = (TextView) v.findViewById(R.id.itemAuthor);
            mItemAuthorOnlineIcon = (ImageView) v.findViewById(R.id.itemAuthorOnlineIcon);
            mItemAuthorUsername = (TextView) v.findViewById(R.id.itemAuthorUsername);

            mItemImg = (ResizableImageView) v.findViewById(R.id.itemImg);
            mItemDescription = (EmojiconTextView) v.findViewById(R.id.itemDescription);

            mItemPlayVideo = (ImageView) v.findViewById(R.id.itemPlayVideo);

            mItemMenuButton = (ImageView) v.findViewById(R.id.itemMenuButton);
            mItemLikeImg = (ImageView) v.findViewById(R.id.itemLikeImg);
            mItemAnswerImg = (ImageView) v.findViewById(R.id.itemAnswerImg);
            mItemShareImg = (ImageView) v.findViewById(R.id.itemShareImg);
            mItemTimeAgo = (TextView) v.findViewById(R.id.itemTimeAgo);

            mItemLikesCount = (TextView) v.findViewById(R.id.itemLikesCount);
            mItemAnswersCount = (TextView) v.findViewById(R.id.itemAnswersCount);

            mProgressBar = (ProgressBar) v.findViewById(R.id.progressBar);

            mItemLikeButton = (MaterialRippleLayout) v.findViewById(R.id.itemLikeButton);
            mItemAnswerButton = (MaterialRippleLayout) v.findViewById(R.id.itemAnswerButton);
            mItemShareButton = (MaterialRippleLayout) v.findViewById(R.id.itemShareButton);

            mLinkContainer = (LinearLayout) v.findViewById(R.id.linkContainer);
            mLinkTitle = (TextView) v.findViewById(R.id.linkTitle);
            mLinkDescription = (TextView) v.findViewById(R.id.linkDescription);
            mLinkImage = (ImageView) v.findViewById(R.id.linkImage);

        } else if (itemType == 1) {

            nativeAdIcon = (ImageView) v.findViewById(R.id.native_ad_icon);
            nativeAdTitle = (TextView) v.findViewById(R.id.native_ad_title);
            nativeAdMedia = (MediaView) v.findViewById(R.id.native_ad_media);
            nativeAdSocialContext = (TextView) v.findViewById(R.id.native_ad_social_context);
            nativeAdBody = (TextView) v.findViewById(R.id.native_ad_body);
            nativeAdCallToAction = (Button) v.findViewById(R.id.native_ad_call_to_action);
            adContainer = (LinearLayout) v.findViewById(R.id.native_ad_unit);
            adChoicesContainer = (LinearLayout) v.findViewById(R.id.ad_choices_container);
        }
    }

}

public AdvancedAnswerListAdapter(Context ctx, List<Answer> items) {

    this.context = ctx;
    this.items = items;

    if (imageLoader == null) {

        imageLoader = App.getInstance().getImageLoader();
    }
    setUpFacebookAD();
}

private void setUpFacebookAD() {
    //AdSettings.addTestDevice("ae869b4a0e40ebbea07dafaabd9690aa");
    mFBNativeAd = new NativeAd(context, "xxxxxxxxxxxxxxx_xxxxxxxxxxxxxxx");
    mFBNativeAd.setAdListener(new com.facebook.ads.AdListener() {

        @Override
        public void onError(Ad ad, AdError error) {
            // Ad error callback
            Log.i("fb native ad","on Error" + " "+ error.getErrorMessage());
        }

        @Override
        public void onAdLoaded(Ad ad) {
            // Ad loaded callback
            Log.i("FB native ad ", "On Ad loaded");
            notifyDataSetChanged();

        }

        @Override
        public void onAdClicked(Ad ad) {
            // Ad clicked callback
            Log.i("FB natvie Ad" , "onAd clicked");
        }
    });
    mFBNativeAd.loadAd(NativeAd.MediaCacheFlag.ALL);
}

The com.facebook.ads.AdListener is red color underlined. I tried reduced it to AdListener only but still getting error. It only happened after i upgraded the jdk version and the location of jdk. Before the upgrade the code is working. How can I get it to work?






Comments
0 Comments

0 commentaires:

Enregistrer un commentaire