Created
June 7, 2019 08:16
-
-
Save maichanchinh/20718a7dc03a442a281365c95eb263dc to your computer and use it in GitHub Desktop.
Custom Interstitial of startapp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?xml version="1.0" encoding="utf-8"?> | |
| <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
| xmlns:app="http://schemas.android.com/apk/res-auto" | |
| xmlns:tools="http://schemas.android.com/tools" | |
| android:layout_width="match_parent" | |
| android:layout_height="match_parent" | |
| android:background="@color/gray" | |
| tools:context="com.vintro.rainbow.features.ads.AdsActivity"> | |
| <RelativeLayout | |
| android:layout_marginBottom="@dimen/_16sdp" | |
| android:layout_centerInParent="true" | |
| android:id="@+id/rl_main" | |
| android:layout_width="wrap_content" | |
| android:layout_height="wrap_content"> | |
| </RelativeLayout> | |
| <RelativeLayout | |
| android:layout_width="42dp" | |
| android:layout_height="42dp" | |
| android:layout_marginEnd="25dp" | |
| android:layout_marginTop="25dp" | |
| android:layout_alignParentEnd="true"> | |
| <ImageView | |
| android:id="@+id/btnClose" | |
| android:layout_width="42dp" | |
| android:layout_height="42dp" | |
| android:src="@drawable/icon_close_splash" /> | |
| <TextView | |
| android:id="@+id/tv_count_timer" | |
| android:layout_width="wrap_content" | |
| android:layout_height="wrap_content" | |
| android:layout_centerInParent="true" | |
| android:textColor="#fff" | |
| android:visibility="gone" | |
| android:textSize="20sp" | |
| android:gravity="center" | |
| android:background="@drawable/bg_tv_count_timer"/> | |
| </RelativeLayout> | |
| </RelativeLayout> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class AdsActivity extends AppCompatActivity { | |
| @BindView(R.id.rl_main) | |
| RelativeLayout rlMain; | |
| @BindView(R.id.btnClose) | |
| ImageView btnClose; | |
| @BindView(R.id.tv_count_timer) | |
| TextView tvCountTimer; | |
| private String path; | |
| @Override | |
| protected void onCreate(Bundle savedInstanceState) { | |
| super.onCreate(savedInstanceState); | |
| setContentView(R.layout.activity_ads); | |
| ButterKnife.bind(this); | |
| showAds(); | |
| } | |
| private void showAds() { | |
| RelativeLayout mainLayout = findViewById(R.id.rl_main); | |
| Mrec startAppMrec = new Mrec(this); | |
| StartAppAd.disableSplash(); | |
| RelativeLayout.LayoutParams mrecParameters = | |
| new RelativeLayout.LayoutParams( | |
| RelativeLayout.LayoutParams.WRAP_CONTENT, | |
| RelativeLayout.LayoutParams.WRAP_CONTENT); | |
| mrecParameters.addRule(RelativeLayout.CENTER_IN_PARENT); | |
| startAppMrec.setBannerListener(new BannerListener() { | |
| @Override | |
| public void onReceiveAd(View view) { | |
| } | |
| @Override | |
| public void onFailedToReceiveAd(View view) { | |
| Intent i = new Intent(AdsActivity.this, CongratulationActivity.class); | |
| path = getIntent().getStringExtra(Const.IMAGE_PATH); | |
| i.putExtra(Const.IMAGE_PATH, path); | |
| startActivity(i); | |
| finish(); | |
| } | |
| @Override | |
| public void onClick(View view) { | |
| } | |
| }); | |
| mainLayout.addView(startAppMrec, mrecParameters); | |
| } | |
| @OnClick(R.id.btnClose) | |
| public void onViewClicked() { | |
| Intent i = new Intent(this, CongratulationActivity.class); | |
| path = getIntent().getStringExtra(Const.IMAGE_PATH); | |
| i.putExtra(Const.IMAGE_PATH, path); | |
| startActivity(i); | |
| finish(); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment