Search in sources :

Example 1 with HomeToWebViewInfo

use of com.seven.seven.home.model.HomeToWebViewInfo in project seven_develop by seven123456.

the class HomeFragment method initRecyclerView.

/*
    * 初始化recycler并且初始化headview添加到recycler里面
    * */
private void initRecyclerView() {
    recyclerView.setLayoutManager(linearLayoutManager);
    homeCommonAdapter = new HomeCommonAdapter(R.layout.recycler_item_home_news, newsInfosList, getContext());
    initHeadView();
    homeCommonAdapter.setOnLoadMoreListener(this, recyclerView);
    homeCommonAdapter.disableLoadMoreIfNotFullPage();
    homeCommonAdapter.addHeaderView(headView);
    recyclerView.setAdapter(homeCommonAdapter);
    recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {

        // Drawable drawable = getContext().getResources().getDrawable(R.drawable.home_toolbar_bg);
        @Override
        public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
            // if (isFirst) {
            // int toolbarHeight = appBarLayout.getMeasuredHeight();
            int toolbarHeight = getResources().getDimensionPixelSize(R.dimen.main_title_bar_height);
            int scollyHeight = recyclerView.computeVerticalScrollOffset();
            if (scollyHeight >= (toolbarHeight * 2)) {
                /*此时toolbar和状态栏完全显示红色*/
                // appBarLayout.setVisibility(View.VISIBLE);
                // drawable.setAlpha(255);
                // appBarLayout.setBackground(drawable);
                homeTitleBar.setBgAlpha(1);
            } else if (scollyHeight >= toolbarHeight) {
                /*
                        * 渐变过程
                        * */
                // appBarLayout.setVisibility(View.VISIBLE);
                // drawable.setAlpha((int) (255 * ((scollyHeight - toolbarHeight) / (toolbarHeight * 1.5F))));
                // appBarLayout.setBackground(drawable);
                homeTitleBar.setBgAlpha((scollyHeight - toolbarHeight) / (toolbarHeight * 2F));
            } else {
                /*
                        * 状态栏透明
                        * */
                // appBarLayout.setVisibility(View.GONE);
                homeTitleBar.setBgAlpha(0);
            }
            // } else {
            // isFirst = true;
            // }
            super.onScrolled(recyclerView, dx, dy);
        }
    });
    homeCommonAdapter.setOnItemChildClickListener(new BaseQuickAdapter.OnItemChildClickListener() {

        @Override
        public void onItemChildClick(BaseQuickAdapter adapter, View view, int position) {
            HomeNewsInfos.NewsInfos newsInfos = (HomeNewsInfos.NewsInfos) adapter.getItem(position);
            HomeToWebViewInfo homeToWebViewInfo = new HomeToWebViewInfo();
            homeToWebViewInfo.h5Url = newsInfos.getLink();
            homeToWebViewInfo.imgUrl = newsInfos.getEnvelopePic();
            homeToWebViewInfo.title = newsInfos.getTitle();
            homeToWebViewInfo.id = newsInfos.getId();
            homeToWebViewInfo.collect = newsInfos.isCollect();
            Intent intent = new Intent(getContext(), HomeNewsDetailActivity.class);
            intent.putExtra("newsInfo", homeToWebViewInfo);
            /*
                * item 里面的img设置一个属性,相对应页面的img里面也必须设置
                * getResources().getString(R.string.transition_news_img)
                * */
            ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation((Activity) getContext(), view.findViewById(R.id.iv_right), getResources().getString(R.string.transition_news_img));
            ActivityCompat.startActivity(getContext(), intent, options.toBundle());
        }
    });
}
Also used : MainActivity(com.seven.seven.ui.MainActivity) Activity(android.app.Activity) Intent(android.content.Intent) ErrorLayoutView(com.seven.seven.common.view.ErrorLayoutView) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) ActivityOptionsCompat(android.support.v4.app.ActivityOptionsCompat) HomeToWebViewInfo(com.seven.seven.home.model.HomeToWebViewInfo) BaseQuickAdapter(com.chad.library.adapter.base.BaseQuickAdapter) HomeNewsInfos(com.seven.seven.home.model.HomeNewsInfos) HomeNewsInfos(com.seven.seven.home.model.HomeNewsInfos) RecyclerView(android.support.v7.widget.RecyclerView) HomeCommonAdapter(com.seven.seven.home.adapter.HomeCommonAdapter)

Example 2 with HomeToWebViewInfo

use of com.seven.seven.home.model.HomeToWebViewInfo in project seven_develop by seven123456.

the class CollectListActivity method initRecycler.

private void initRecycler() {
    collectAdapter = new CollectAdapter(R.layout.recycler_item_collect, collectInfoList);
    recyclerView.setAdapter(collectAdapter);
    collectAdapter.setOnLoadMoreListener(this, recyclerView);
    collectAdapter.disableLoadMoreIfNotFullPage();
    ItemDragAndSwipeCallback itemDragAndSwipeCallback = new ItemDragAndSwipeCallback(collectAdapter);
    ItemTouchHelper itemTouchHelper = new ItemTouchHelper(itemDragAndSwipeCallback);
    itemTouchHelper.attachToRecyclerView(recyclerView);
    itemDragAndSwipeCallback.setSwipeMoveFlags(ItemTouchHelper.START | ItemTouchHelper.END);
    collectAdapter.enableSwipeItem();
    collectAdapter.setOnItemSwipeListener(new OnItemSwipeListener() {

        @Override
        public void onItemSwipeStart(RecyclerView.ViewHolder viewHolder, int pos) {
            Log.d("onItemSwipeStart", "执行了");
        }

        @Override
        public void clearView(RecyclerView.ViewHolder viewHolder, int pos) {
            Log.d("clearView", "执行了");
        }

        @Override
        public void onItemSwiped(RecyclerView.ViewHolder viewHolder, int pos) {
            Log.d("onItemSwiped", "执行了");
            collectInfo = collectAdapter.getItem(pos);
            position = pos;
            if (collectInfo != null) {
                collectPresenter.deleteCollect(collectInfo.getId());
            }
        }

        @Override
        public void onItemSwipeMoving(Canvas canvas, RecyclerView.ViewHolder viewHolder, float dX, float dY, boolean isCurrentlyActive) {
            canvas.drawColor(ContextCompat.getColor(CollectListActivity.this, R.color.red));
            Log.d("onItemSwipeMoving", "执行了");
        }
    });
    collectAdapter.setOnItemChildClickListener(new BaseQuickAdapter.OnItemChildClickListener() {

        @Override
        public void onItemChildClick(BaseQuickAdapter adapter, View view, int position) {
            CollectInfo collectInfo = (CollectInfo) adapter.getItem(position);
            HomeToWebViewInfo homeToWebViewInfo = new HomeToWebViewInfo();
            homeToWebViewInfo.collect = collectInfo.isCollect();
            homeToWebViewInfo.h5Url = collectInfo.getLink();
            homeToWebViewInfo.id = collectInfo.getId();
            homeToWebViewInfo.imgUrl = collectInfo.getEnvelopePic();
            homeToWebViewInfo.title = collectInfo.getTitle();
            Intent intent = new Intent(mActivity, HomeNewsDetailActivity.class);
            intent.putExtra("newsInfo", homeToWebViewInfo);
            startActivity(intent);
        }
    });
}
Also used : CollectAdapter(com.seven.seven.user.adapter.CollectAdapter) CollectInfo(com.seven.seven.user.model.CollectInfo) Canvas(android.graphics.Canvas) Intent(android.content.Intent) ImageView(android.widget.ImageView) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) ItemTouchHelper(android.support.v7.widget.helper.ItemTouchHelper) HomeToWebViewInfo(com.seven.seven.home.model.HomeToWebViewInfo) BaseQuickAdapter(com.chad.library.adapter.base.BaseQuickAdapter) RecyclerView(android.support.v7.widget.RecyclerView) OnItemSwipeListener(com.chad.library.adapter.base.listener.OnItemSwipeListener) ItemDragAndSwipeCallback(com.chad.library.adapter.base.callback.ItemDragAndSwipeCallback) HomeNewsDetailActivity(com.seven.seven.home.HomeNewsDetailActivity)

Example 3 with HomeToWebViewInfo

use of com.seven.seven.home.model.HomeToWebViewInfo in project seven_develop by seven123456.

the class SearchFragment method initURLFlowlayout.

private void initURLFlowlayout(final List<UsingURLinfos> usingURLinfos) {
    // 循环添加TextView到容器
    for (int i = 0; i < usingURLinfos.size(); i++) {
        final TextView view = new TextView(getContext());
        view.setText(usingURLinfos.get(i).getName());
        view.setTextColor(getResources().getColor(R.color.search_text));
        view.setPadding(5, 5, 5, 5);
        view.setGravity(Gravity.CENTER);
        view.setTextSize(14);
        // 设置点击事件
        final int index = i;
        view.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                long currTime = System.currentTimeMillis();
                if (currTime - lastTime > 1000) {
                    Log.d("onClick", "点击了");
                    // showSuccessToast(usingURLinfos.get(index).getName());
                    Intent intent = new Intent(getContext(), HomeNewsDetailActivity.class);
                    HomeToWebViewInfo homeToWebViewInfo = new HomeToWebViewInfo();
                    homeToWebViewInfo.h5Url = usingURLinfos.get(index).getLink();
                    homeToWebViewInfo.id = usingURLinfos.get(index).getId();
                    homeToWebViewInfo.imgUrl = usingURLinfos.get(index).getIcon();
                    homeToWebViewInfo.collect = true;
                    intent.putExtra("newsInfo", homeToWebViewInfo);
                    startActivity(intent);
                }
                lastTime = currTime;
            }
        });
        // 设置彩色背景
        GradientDrawable normalDrawable = new GradientDrawable();
        normalDrawable.setColor(getResources().getColor(R.color.seven));
        /* // 设置按下的灰色背景
            GradientDrawable pressedDrawable = new GradientDrawable();
            pressedDrawable.setShape(GradientDrawable.RECTANGLE);
            pressedDrawable.setColor(Color.GRAY);*/
        // 背景选择器
        StateListDrawable stateDrawable = new StateListDrawable();
        // stateDrawable.addState(new int[]{android.R.attr.state_pressed}, pressedDrawable);
        stateDrawable.addState(new int[] {}, normalDrawable);
        // 设置背景选择器到TextView上
        view.setBackground(stateDrawable);
        urlFlowLayout.addView(view);
    }
}
Also used : HomeToWebViewInfo(com.seven.seven.home.model.HomeToWebViewInfo) TextView(android.widget.TextView) Intent(android.content.Intent) StateListDrawable(android.graphics.drawable.StateListDrawable) View(android.view.View) TextView(android.widget.TextView) HomeNewsDetailActivity(com.seven.seven.home.HomeNewsDetailActivity) GradientDrawable(android.graphics.drawable.GradientDrawable)

Example 4 with HomeToWebViewInfo

use of com.seven.seven.home.model.HomeToWebViewInfo in project seven_develop by seven123456.

the class HomeFragment method initRecyclerHeadView.

private void initRecyclerHeadView(List<HomeBannerInfos> homeBannerInfos) {
    bannerViewAdapter = new BannerViewAdapter(R.layout.recycler_item_banner, homeBannerInfos, getContext());
    bannerLayout.setAdapter(bannerViewAdapter);
    bannerViewAdapter.setOnItemChildClickListener(new BaseQuickAdapter.OnItemChildClickListener() {

        @Override
        public void onItemChildClick(BaseQuickAdapter adapter, View view, int position) {
            HomeBannerInfos homeBannerInfos = (HomeBannerInfos) adapter.getItem(position);
            HomeToWebViewInfo homeToWebViewInfo = new HomeToWebViewInfo();
            Intent intent = new Intent(getContext(), HomeNewsDetailActivity.class);
            homeToWebViewInfo.title = homeBannerInfos.getTitle();
            homeToWebViewInfo.imgUrl = homeBannerInfos.getImagePath();
            homeToWebViewInfo.h5Url = homeBannerInfos.getUrl();
            intent.putExtra("newsInfo", homeToWebViewInfo);
            ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation((Activity) getContext(), view.findViewById(R.id.iv_banner_image), getResources().getString(R.string.transition_news_img));
            ActivityCompat.startActivity(getContext(), intent, options.toBundle());
        }
    });
}
Also used : HomeBannerInfos(com.seven.seven.home.model.HomeBannerInfos) HomeToWebViewInfo(com.seven.seven.home.model.HomeToWebViewInfo) BaseQuickAdapter(com.chad.library.adapter.base.BaseQuickAdapter) BannerViewAdapter(com.seven.seven.home.adapter.BannerViewAdapter) MainActivity(com.seven.seven.ui.MainActivity) Activity(android.app.Activity) Intent(android.content.Intent) ErrorLayoutView(com.seven.seven.common.view.ErrorLayoutView) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) ActivityOptionsCompat(android.support.v4.app.ActivityOptionsCompat)

Example 5 with HomeToWebViewInfo

use of com.seven.seven.home.model.HomeToWebViewInfo in project seven_develop by seven123456.

the class SearchDetailActivity method initRecyclerData.

private void initRecyclerData(List<SearchListInfos.DatasBean> listInfosList) {
    searchAdapter = new SearchAdapter(R.layout.recycler_item_search, listInfosList);
    // searchAdapter.setOnLoadMoreListener(this, recyclerView);
    recyclerView.setAdapter(searchAdapter);
    searchAdapter.setOnItemChildClickListener(new BaseQuickAdapter.OnItemChildClickListener() {

        @Override
        public void onItemChildClick(BaseQuickAdapter adapter, View view, int position) {
            SearchListInfos.DatasBean newsInfos = (SearchListInfos.DatasBean) adapter.getItem(position);
            HomeToWebViewInfo homeToWebViewInfo = new HomeToWebViewInfo();
            homeToWebViewInfo.h5Url = newsInfos.getLink();
            homeToWebViewInfo.imgUrl = newsInfos.getEnvelopePic();
            homeToWebViewInfo.title = newsInfos.getTitle();
            homeToWebViewInfo.id = newsInfos.getId();
            homeToWebViewInfo.collect = newsInfos.isCollect();
            Intent intent = new Intent(mActivity, HomeNewsDetailActivity.class);
            intent.putExtra("newsInfo", homeToWebViewInfo);
            startActivity(intent);
        }
    });
}
Also used : SearchListInfos(com.seven.seven.search.model.SearchListInfos) HomeToWebViewInfo(com.seven.seven.home.model.HomeToWebViewInfo) BaseQuickAdapter(com.chad.library.adapter.base.BaseQuickAdapter) Intent(android.content.Intent) ImageView(android.widget.ImageView) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) HomeNewsDetailActivity(com.seven.seven.home.HomeNewsDetailActivity)

Aggregations

Intent (android.content.Intent)5 View (android.view.View)5 HomeToWebViewInfo (com.seven.seven.home.model.HomeToWebViewInfo)5 RecyclerView (android.support.v7.widget.RecyclerView)4 BaseQuickAdapter (com.chad.library.adapter.base.BaseQuickAdapter)4 HomeNewsDetailActivity (com.seven.seven.home.HomeNewsDetailActivity)3 Activity (android.app.Activity)2 ActivityOptionsCompat (android.support.v4.app.ActivityOptionsCompat)2 ImageView (android.widget.ImageView)2 ErrorLayoutView (com.seven.seven.common.view.ErrorLayoutView)2 MainActivity (com.seven.seven.ui.MainActivity)2 Canvas (android.graphics.Canvas)1 GradientDrawable (android.graphics.drawable.GradientDrawable)1 StateListDrawable (android.graphics.drawable.StateListDrawable)1 ItemTouchHelper (android.support.v7.widget.helper.ItemTouchHelper)1 TextView (android.widget.TextView)1 ItemDragAndSwipeCallback (com.chad.library.adapter.base.callback.ItemDragAndSwipeCallback)1 OnItemSwipeListener (com.chad.library.adapter.base.listener.OnItemSwipeListener)1 BannerViewAdapter (com.seven.seven.home.adapter.BannerViewAdapter)1 HomeCommonAdapter (com.seven.seven.home.adapter.HomeCommonAdapter)1