Code Monkey home page Code Monkey logo

advertscreen's Introduction

@TOC

项目内容详情

  • convenientbanner 屏幕广告浏览展示
  • libaums USB操作框架
  • Typeface 设置显示字体
  • 监听应用启动和展示界面

convenientbanner 屏幕广告浏览展示

导入项目引用

    // 广告浏览展示
    compile project(':convenientbanner')

广告显示

 convenientBanner = findViewById(R.id.convenientBanner) as ConvenientBanner<Any>

            convenientBanner!!.setPages(
                    object : CBViewHolderCreator<Holder<String>> {

                        override fun createHolder(itemView: View): MyLocalImageHolderView {
                            var myLihv = MyLocalImageHolderView(this@ActivityAdvert, itemView)
                            return myLihv
                        }

                        override fun getLayoutId(): Int {
                            return R.layout.item_localimage
                        }
                    }, imgFiles as List<Any>?)
                    //设置两个点图片作为翻页指示器,不设置则没有指示器,可以根据自己需求自行配合自己的指示器,不需要圆点指示器可用不设
                    .setPageIndicator(intArrayOf(R.drawable.ic_page_indicator, R.drawable.ic_page_indicator_focused))
                    .setOnItemClickListener { position -> Toast.makeText(this@ActivityAdvert, "点击了第" + position + "个", Toast.LENGTH_SHORT).show() }
                    //设置指示器的方向
                    .setPageIndicatorAlign(ConvenientBanner.PageIndicatorAlign.ALIGN_PARENT_RIGHT)
                    //设置指示器是否可见
                    .setPointViewVisible(false)//
                    // 设置能否循环滚动
                    .setCanLoop(true)
                    //监听翻页事件
                    .setOnPageChangeListener(onPageChange)
            convenientBanner!!.startTurning(10000)


//开始自动翻页
            convenientBanner!!.startTurning(5000)
//停止翻页
            convenientBanner!!.stopTurning()

显示本地图片的holder类

import android.content.Context;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.view.View;
import android.widget.ImageView;

import com.bigkoo.convenientbanner.holder.Holder;
import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;

import ad.vipcare.com.advertscreen.R;
import ad.vipcare.com.bean.AdvertInfoBean;


/**
 * 本地图片Holder例子
 */
public class MyLocalImageHolderView extends Holder<AdvertInfoBean> {

    private static final String TAG = "MyLocalImageHolderView";

    private ImageView imageView;
    private Context mContext ;
    private ImageView ivPlay ;

    public MyLocalImageHolderView(Context con , View itemView) {
        super(itemView);
        this.mContext = con ;
    }

    @Override
    protected void initView(View itemView) {
        imageView = (ImageView) itemView.findViewById(R.id.ivPost);
        ivPlay = (ImageView) itemView.findViewById(R.id.ivPlay);
    }

    @Override
    public void updateUI(AdvertInfoBean data) {
        if (data.getFileName().contains(".mp4")){
         // 播放视频
            ivPlay.setVisibility(View.VISIBLE);
        } else {
            ivPlay.setVisibility(View.GONE);
        }
        //加载图片
        Glide.with(mContext).load(data.getFile())
//                .placeholder(R.drawable.ic_launcher) //设置资源加载过程中的占位符
                .apply(requestOptions)
                .into(imageView);

    }

    RequestOptions requestOptions = new RequestOptions()
            .placeholder(new ColorDrawable(Color.WHITE))
            .error(new ColorDrawable(Color.WHITE))
            .fallback(new ColorDrawable(Color.WHITE));


}

libaums USB操作框架

导入usb使用框架

    // usb 操作框架
    compile 'com.github.mjdev:libaums:0.5.5'

Typeface 设置显示字体

将TTF字体格式文件保存到(app/src/main/assets/fonts)目录中

// 设置文本的显示样式
Typeface typeface = 
		Typeface.createFromAsset(mContext.getAssets(), "fonts/PortStat.ttf");
mTvName.setTypeface(typeface);

监听应用启动和展示界面

advertscreen's People

Stargazers

amelons 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.