Giter Site home page Giter Site logo

dora-ironsource-support's Introduction

dora-ironsource-support Release

Gradle依赖配置

添加以下代码到项目根目录下的settings.gradle.kts

dependencyResolutionManagement {
    repositories {
        maven { setUrl("https://jitpack.io") }
        // IronSource
        maven { setUrl("https://android-sdk.is.com/") }
    }
}

添加以下代码到app模块的build.gradle.kts

dependencies {
    // 扩展包必须在有主框架dora的情况下使用
    implementation("com.github.dora4:dora:1.2.25")
    implementation("com.github.dora4:dora-ironsource-support:1.0")
}

使用方式

Application中加入代码。

override fun attachBaseContext(base: Context?) {
    super.attachBaseContext(base)
    DoraIronSource.setAppKey("填入你的Iron Source App Key")
}

在AndroidManifest中加入配置。

<application>
        <!-- Dora生命周期注入的配置 -->
        <meta-data
            android:name="dora.lifecycle.config.IronSourceGlobalConfig"
            android:value="GlobalConfig"/>
</application>

要显示banner广告的Activity加入代码。

override fun onResume() {
    super.onResume()
    IronSource.onResume(this)
}

override fun onPause() {
    super.onPause()
    IronSource.onPause(this)
}

可设置回调接口。

IronSource.addImpressionDataListener {
}

xml布局。

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">
    
    <!-- 此处省略原先的业务代码若干行...
        容器的宽高修改为
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1" -->
    
    <!-- 要加入的部分开始 -->
    <LinearLayout
        android:id="@+id/banner_view_layout"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:gravity="bottom"
        android:orientation="vertical">

        <FrameLayout
            android:id="@+id/banner_footer"
            android:layout_width="match_parent"
            android:layout_height="50dp"
            android:layout_gravity="center"
            android:visibility="gone"/>
    </LinearLayout>
    <!-- 要加入的部分结束 -->
</LinearLayout>

展示和销毁广告。

// 伪代码,实际请设置为成员属性
val listener = DoraBannerViewListener(binding.bannerFooter)
// 展示横幅广告
listener.loadBanner()
// 销毁横幅广告
listener.destroyBanner()

dora-ironsource-support's People

Contributors

dora4 avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.