gpt4 book ai didi

android - 如果按钮点击 4 次,我可以显示插页式广告吗?

转载 作者:行者123 更新时间:2023-11-29 14:46:36 26 4
gpt4 key购买 nike

我在Detailactivity中安装了Interstitial ad,但是如果按钮点击4次我必须显示Interstitial ad?这可能吗?我的意思是看看这个;

DetailActivity

private View.OnClickListener onFabButtonListener = new View.OnClickListener() {
@Override
public void onClick(View v) {
if (future == null) {
//prepare the call
future = Ion.with(DetailActivity.this)
.load(mSelectedImage.getHighResImage(mWallpaperWidth, mWallpaperHeight))
.progressHandler(progressCallback)
.asInputStream();
if (mInterstitialAd != null && mInterstitialAd.isLoaded())
mInterstitialAd.show();

animateStart();

mFabButton.animate().rotation(360).setDuration(ANIMATION_DURATION_LONG).setListener(new CustomAnimatorListener() {
@Override
public void onAnimationEnd(Animator animation) {
streamAndSetImage();
super.onAnimationEnd(animation);
}

@Override
public void onAnimationCancel(Animator animation) {
streamAndSetImage();
super.onAnimationCancel(animation);
}
}).start();
} else {
animateReset(false);
}
}
};

请看这个新的DetailActivity

Edited DetailActivity

 int counter = 0;
private View.OnClickListener onFabButtonListener = new View.OnClickListener() {
@Override
public void onClick(View v) {

if (counter == 4) {
/** SHOW AD **/
if (mInterstitialAd != null && mInterstitialAd.isLoaded())
mInterstitialAd.show();
/** RESET THE COUNTER **/
counter = 0;
} else {
/** INCREMENT THE COUNTER **/
counter++;

/** DO SOMETHING ELSE **/

}
if (future == null) {
//prepare the call
future = Ion.with(DetailActivity.this)
.load(mSelectedImage.getHighResImage(mWallpaperWidth, mWallpaperHeight))
.progressHandler(progressCallback)
.asInputStream();


animateStart();

mFabButton.animate().rotation(360).setDuration(ANIMATION_DURATION_LONG).setListener(new CustomAnimatorListener() {
@Override
public void onAnimationEnd(Animator animation) {
streamAndSetImage();
super.onAnimationEnd(animation);
}

@Override
public void onAnimationCancel(Animator animation) {
streamAndSetImage();
super.onAnimationCancel(animation);
}
}).start();
} else {
animateReset(false);
}
}
};

最佳答案

是这样的。它当然未经测试,但逻辑应该是有用的:

int counter = 0;

private View.OnClickListener onFabButtonListener = new View.OnClickListener() {
@Override
public void onClick(View v) {
if (counter == 4) {
/** SHOW AD **/

/** RESET THE COUNTER **/
counter = 0;
} else {
/** INCREMENT THE COUNTER **/
counter++;

/** DO SOMETHING ELSE **/
// MOVE THIS BLOCK INSIDE THE ELSE BLOCK AS ILLUSTRATED
if (future == null) {
//prepare the call
future = Ion.with(DetailActivity.this)
.load(mSelectedImage.getHighResImage(mWallpaperWidth, mWallpaperHeight))
.progressHandler(progressCallback)
.asInputStream();


animateStart();

mFabButton.animate().rotation(360).setDuration(ANIMATION_DURATION_LONG).setListener(new CustomAnimatorListener() {
@Override
public void onAnimationEnd(Animator animation) {
streamAndSetImage();
super.onAnimationEnd(animation);
}

@Override
public void onAnimationCancel(Animator animation) {
streamAndSetImage();
super.onAnimationCancel(animation);
}
}).start();
} else {
animateReset(false);
}
}
}
};

此外,您可以使用 SharedPreferences 存储 counter 值因此,点击次数可以存储在应用程序使用 session 之间。

关于android - 如果按钮点击 4 次,我可以显示插页式广告吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34809985/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com