remove splash banner ad
This commit is contained in:
@@ -1,8 +1,10 @@
|
|||||||
package org.autojs.autojs.ui.splash;
|
package org.autojs.autojs.ui.splash;
|
||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.os.Handler;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
|
import android.text.Html;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.FrameLayout;
|
import android.widget.FrameLayout;
|
||||||
@@ -14,6 +16,7 @@ import com.google.android.gms.ads.AdRequest;
|
|||||||
import com.google.android.gms.ads.AdSize;
|
import com.google.android.gms.ads.AdSize;
|
||||||
import com.google.android.gms.ads.AdView;
|
import com.google.android.gms.ads.AdView;
|
||||||
import com.google.android.gms.ads.InterstitialAd;
|
import com.google.android.gms.ads.InterstitialAd;
|
||||||
|
|
||||||
import org.autojs.autojs.BuildConfig;
|
import org.autojs.autojs.BuildConfig;
|
||||||
import org.autojs.autojs.Constants;
|
import org.autojs.autojs.Constants;
|
||||||
import org.autojs.autojs.Pref;
|
import org.autojs.autojs.Pref;
|
||||||
@@ -40,51 +43,37 @@ public class SplashActivity extends BaseActivity {
|
|||||||
@ViewById(R.id.logo)
|
@ViewById(R.id.logo)
|
||||||
ImageView mLogo;
|
ImageView mLogo;
|
||||||
|
|
||||||
@ViewById(R.id.skip_view)
|
|
||||||
TextView mSkipView;
|
|
||||||
|
|
||||||
@ViewById(R.id.ad_container)
|
|
||||||
View mAdContainer;
|
|
||||||
|
|
||||||
@ViewById(R.id.ad)
|
|
||||||
AdView mAd;
|
|
||||||
|
|
||||||
private boolean mCanEnterNextActivity = false;
|
private boolean mCanEnterNextActivity = false;
|
||||||
private boolean mNotStartMainActivity;
|
private boolean mNotStartMainActivity;
|
||||||
|
private boolean mAlreadyEnterNextActivity = false;
|
||||||
|
private boolean mAdLoading = false;
|
||||||
|
|
||||||
|
private Handler mHandler;
|
||||||
|
|
||||||
private InterstitialAd mInterstitialAd;
|
private InterstitialAd mInterstitialAd;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
mHandler = new Handler();
|
||||||
mNotStartMainActivity = getIntent().getBooleanExtra(NOT_START_MAIN_ACTIVITY, false);
|
mNotStartMainActivity = getIntent().getBooleanExtra(NOT_START_MAIN_ACTIVITY, false);
|
||||||
boolean forceShowAd = getIntent().getBooleanExtra(FORCE_SHOW_AD, false);
|
boolean forceShowAd = getIntent().getBooleanExtra(FORCE_SHOW_AD, false);
|
||||||
if (!forceShowAd && !Pref.shouldShowAd()) {
|
if (!forceShowAd && !Pref.shouldShowAd()) {
|
||||||
enterNextActivity();
|
enterNextActivity();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@AfterViews
|
|
||||||
void setUpViews() {
|
|
||||||
fetchSplashAD();
|
fetchSplashAD();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Click(R.id.skip_view)
|
|
||||||
void skip() {
|
|
||||||
enterNextActivity();
|
|
||||||
}
|
|
||||||
|
|
||||||
void enterNextActivity() {
|
void enterNextActivity() {
|
||||||
|
if (mAlreadyEnterNextActivity)
|
||||||
|
return;
|
||||||
|
mAlreadyEnterNextActivity = true;
|
||||||
if (!mNotStartMainActivity)
|
if (!mNotStartMainActivity)
|
||||||
MainActivity_.intent(this).start();
|
MainActivity_.intent(this).start();
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
|
|
||||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onResume() {
|
protected void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
@@ -106,48 +95,46 @@ public class SplashActivity extends BaseActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void fetchSplashAD() {
|
private void fetchSplashAD() {
|
||||||
|
mAdLoading = true;
|
||||||
|
mHandler.postDelayed(() -> {
|
||||||
|
if (mAdLoading)
|
||||||
|
enterNextActivity();
|
||||||
|
}, 4000);
|
||||||
mInterstitialAd = new InterstitialAd(this);
|
mInterstitialAd = new InterstitialAd(this);
|
||||||
mInterstitialAd.setAdUnitId(BuildConfig.DEBUG ? Constants.ADMOB_INTERSTITIAL_TEST_ID : Constants.ADMOB_INTERSTITIAL_ID);
|
mInterstitialAd.setAdUnitId(BuildConfig.DEBUG ? Constants.ADMOB_INTERSTITIAL_TEST_ID : Constants.ADMOB_INTERSTITIAL_ID);
|
||||||
mInterstitialAd.setAdListener(new AdListener() {
|
mInterstitialAd.setAdListener(new AdListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onAdLoaded() {
|
public void onAdLoaded() {
|
||||||
|
mAdLoading = false;
|
||||||
mInterstitialAd.show();
|
mInterstitialAd.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onAdFailedToLoad(int i) {
|
|
||||||
Log.d(Constants.LOG_TAG_ADMOB, "Fail to load interstitial ad: " + i);
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
mInterstitialAd.loadAd(new AdRequest.Builder()
|
|
||||||
.build());
|
|
||||||
mAd.setAdListener(new AdListener() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onAdClicked() {
|
|
||||||
enterNextActivity();
|
|
||||||
Log.d(Constants.LOG_TAG_ADMOB, "Ad clicked");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onAdFailedToLoad(int i) {
|
|
||||||
Log.d(Constants.LOG_TAG_ADMOB, "Fail to load banner ad: " + i);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAdClosed() {
|
public void onAdClosed() {
|
||||||
enterNextActivity();
|
enterNextActivity();
|
||||||
}
|
}
|
||||||
});
|
|
||||||
if (BuildConfig.DEBUG) {
|
|
||||||
mAd.loadAd(new AdRequest.Builder()
|
|
||||||
.addTestDevice("774E105820188FA387B617ECD279B167")
|
|
||||||
.build());
|
|
||||||
} else {
|
|
||||||
mAd.loadAd(new AdRequest.Builder()
|
|
||||||
.build());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAdClicked() {
|
||||||
|
enterNextActivity();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAdFailedToLoad(int i) {
|
||||||
|
mAdLoading = false;
|
||||||
|
enterNextActivity();
|
||||||
|
Log.d(Constants.LOG_TAG_ADMOB, "Fail to load interstitial ad: " + i);
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
mInterstitialAd.loadAd(buildAdRequest());
|
||||||
|
}
|
||||||
|
|
||||||
|
private AdRequest buildAdRequest() {
|
||||||
|
AdRequest.Builder builder = new AdRequest.Builder();
|
||||||
|
if (BuildConfig.DEBUG) {
|
||||||
|
builder.addTestDevice("774E105820188FA387B617ECD279B167");
|
||||||
|
}
|
||||||
|
return builder.build();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,33 +14,6 @@
|
|||||||
android:layout_weight="1">
|
android:layout_weight="1">
|
||||||
|
|
||||||
|
|
||||||
<com.google.android.gms.ads.AdView
|
|
||||||
xmlns:ads="http://schemas.android.com/apk/res-auto"
|
|
||||||
android:id="@+id/ad"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:layout_alignParentBottom="true"
|
|
||||||
android:layout_centerHorizontal="true"
|
|
||||||
ads:adSize="FLUID"
|
|
||||||
ads:adUnitId="ca-app-pub-5495978608535144/3281269730">
|
|
||||||
</com.google.android.gms.ads.AdView>
|
|
||||||
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/skip_view"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_alignParentRight="true"
|
|
||||||
android:layout_alignParentTop="true"
|
|
||||||
android:layout_marginRight="16dp"
|
|
||||||
android:layout_marginTop="20dp"
|
|
||||||
android:background="@drawable/skip_circle_bg"
|
|
||||||
android:gravity="center"
|
|
||||||
android:padding="8dp"
|
|
||||||
android:text="@string/text_skip"
|
|
||||||
android:textColor="#ddffffff"
|
|
||||||
android:textSize="14sp"/>
|
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
@@ -69,4 +42,4 @@
|
|||||||
</ImageView>
|
</ImageView>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|||||||
Reference in New Issue
Block a user