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());
}
});
}
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);
}
});
}
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);
}
}
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());
}
});
}
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);
}
});
}
Aggregations