home update frame

ongbodev
ongbo 6 years ago
parent 48545bca10
commit fbd9a5f41c

@ -75,18 +75,23 @@ public class SlideFragment extends Fragment {
mItemTouchHelperCallback = new ItemTouchHelperCallback(mRecyclerView.getAdapter(), mList);
mItemTouchHelper = new ItemTouchHelper(mItemTouchHelperCallback);
mSlideLayoutManager = new SlideLayoutManager(mRecyclerView, mItemTouchHelper);
mItemTouchHelper.attachToRecyclerView(mRecyclerView);
mRecyclerView.setLayoutManager(mSlideLayoutManager);
}
private void initListener() {
//往左滑就是不喜欢,往右滑就是喜欢
mItemTouchHelperCallback.setOnSlideListener(new OnSlideListener() {
@Override
public void onSliding(RecyclerView.ViewHolder viewHolder, float ratio, int direction) {
if (direction == ItemConfig.SLIDING_LEFT) {
} else if (direction == ItemConfig.SLIDING_RIGHT) {
}
}
@ -107,6 +112,8 @@ public class SlideFragment extends Fragment {
@Override
public void onClear() {
// 一旦几个页面的数据加载完了,就在这里重新加载数据
addData();
}
});
@ -114,6 +121,7 @@ public class SlideFragment extends Fragment {
/**
*
*
*/
private void addData(){
int[] icons = {R.mipmap.header_icon_1, R.mipmap.header_icon_2, R.mipmap.header_icon_3,
@ -151,6 +159,14 @@ public class SlideFragment extends Fragment {
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = LayoutInflater.from(appCompatActivity).inflate(R.layout.item_slide, parent, false);
view.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Log.i("你呗","你点接了");
//这里可以设置点开文章好查看
// 可以新开一个Activity来查看文章
}
});
return new ViewHolder(view);
}
@ -168,10 +184,10 @@ public class SlideFragment extends Fragment {
}
public class ViewHolder extends RecyclerView.ViewHolder {
ImageView imgBg;
ImageView userIcon;
TextView tvTitle;
TextView userSay;
ImageView imgBg;//背景图片
ImageView userIcon;//读者头像
TextView tvTitle;//推文标题
TextView userSay;//用户名或者到时候改成一段摘要也可以
public ViewHolder(View itemView) {
super(itemView);

@ -83,7 +83,8 @@ public class PersonContent extends Fragment {
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
// rvFeed = (RecyclerView) appCompatActivity.findViewById(R.id.rvFeed);
viewPager = (ViewPager) appCompatActivity.findViewById(R.id.vp_vertical_ntb);
// 原来的viewpager
// viewPager = (ViewPager) appCompatActivity.findViewById(R.id.vp_vertical_ntb);
mDrawer = (FlowingDrawer) appCompatActivity.findViewById(R.id.drawerlayout);
mDrawer.setTouchMode(ElasticDrawer.TOUCH_MODE_BEZEL);
//设置工具栏
@ -91,17 +92,22 @@ public class PersonContent extends Fragment {
setuptoolbar();
//设置直接页面
// setupFeed();
setupViewpager();
// setupViewpager();
//设置侧滑菜单
setupMenu();
}
protected void setuptoolbar(){
//分别设置背景和头像
//背景
ImageView blurimageView = (ImageView) appCompatActivity.findViewById(R.id.iv_blur);
//头像
ImageView avatarImageView = (ImageView) appCompatActivity.findViewById(R.id.iv_avatar);
Glide.with(appCompatActivity).load(R.drawable.draw7)
.apply(RequestOptions.bitmapTransform(new BlurTransformation(25,3))).into(blurimageView);
int width = blurimageView.getWidth();
Glide.with(appCompatActivity).load(R.drawable.draw7)
.apply(RequestOptions.bitmapTransform(new BlurTransformation(18,3))).into(blurimageView);
// Glide.with(appCompatActivity).load(R.drawable.draw7).override(width,450)
// .into(blurimageView);
Glide.with(appCompatActivity).load(R.drawable.draw6).into(avatarImageView);
//用户名
final TextView rainbowTextView = (TextView) appCompatActivity.findViewById(R.id.user_name_person);
@ -112,156 +118,157 @@ public class PersonContent extends Fragment {
}
});
avatarOnclickListener avatarOnclickListener = new avatarOnclickListener(getAppCompatActivity(),this);
avatarOnclickListener.setFlowingDrawerl(mDrawer);
avatarImageView.setOnClickListener(avatarOnclickListener);
}
//
//设置没有侧滑之前的状态页面
//在这里将东西其改成几个按钮
private void setupViewpager(){
/*
*
* */
viewPager.setAdapter(new PagerAdapter() {
//设置菜单栏个数
@Override
public int getCount() {
return 5;
}
@Override
public boolean isViewFromObject(final View view, final Object object) {
return view.equals(object);
}
//移除某一个
@Override
public void destroyItem(final View container, final int position, final Object object) {
((ViewPager) container).removeView((View) object);
}
/*
*
*
* */
@Override
public Object instantiateItem(final ViewGroup container, final int position) {
//每个position代表一个菜单根据position来设置不同视图
// private void setupViewpager(){
// /*
// * 先设置适配器
// * */
// viewPager.setAdapter(new PagerAdapter() {
// //设置菜单栏个数
// @Override
// public int getCount() {
// return 5;
// }
//
switch (position){
case 0:
//饮食爱好
case 1:
//日历
View view = setCanlendar();
container.addView(view);
return view;
case 2:
//消息通知
case 3:
//我的文章
case 4:
//养生推荐
}
//这是默认的,不要管,因为上面必须有个返回值
final View view = LayoutInflater.from(
appCompatActivity.getBaseContext()).inflate(R.layout.item_vp, null, false);
final TextView txtPage = (TextView) view.findViewById(R.id.txt_vp_item_page);
txtPage.setText(String.format("Page #%d", position));
container.addView(view);
return view;
}
//设置日历
public View setCanlendar(){
final View view = LayoutInflater.from(
appCompatActivity.getBaseContext()
).inflate(R.layout.canlendar_layout, null, false);
return view;
}
//设置饮食爱好
public View setfoodhobby(){
return null;
}
});
/*
*
* */
//每个菜单选取了不同的颜色
final String[] colors = getResources().getStringArray(R.array.vertical_ntb);
//这里菜单栏选取的是NavigationTabBar
final NavigationTabBar navigationTabBar = (NavigationTabBar) appCompatActivity.findViewById(R.id.ntb_vertical);
//这里用来加载每个model可以设置几个菜单
final ArrayList<NavigationTabBar.Model> models = new ArrayList<>();
models.add(
new NavigationTabBar.Model.Builder(
getResources().getDrawable(R.drawable.ic_first),
Color.parseColor(colors[0]))
.title("ic_first")
.selectedIcon(getResources().getDrawable(R.drawable.ic_eighth))
.build()
);
models.add(
new NavigationTabBar.Model.Builder(
getResources().getDrawable(R.drawable.ic_second),
Color.parseColor(colors[1]))
.selectedIcon(getResources().getDrawable(R.drawable.ic_eighth))
.title("ic_second")
.build()
);
models.add(
new NavigationTabBar.Model.Builder(
getResources().getDrawable(R.drawable.ic_third),
Color.parseColor(colors[2]))
.selectedIcon(getResources().getDrawable(R.drawable.ic_eighth))
.title("ic_third")
.build()
);
models.add(
new NavigationTabBar.Model.Builder(
getResources().getDrawable(R.drawable.ic_fourth),
Color.parseColor(colors[3]))
.selectedIcon(getResources().getDrawable(R.drawable.ic_eighth))
.title("ic_fourth")
.build()
);
models.add(
new NavigationTabBar.Model.Builder(
getResources().getDrawable(R.drawable.ic_fifth),
Color.parseColor(colors[4]))
.selectedIcon(getResources().getDrawable(R.drawable.ic_eighth))
.title("ic_fifth")
.build()
);
// @Override
// public boolean isViewFromObject(final View view, final Object object) {
// return view.equals(object);
// }
// //移除某一个
// @Override
// public void destroyItem(final View container, final int position, final Object object) {
// ((ViewPager) container).removeView((View) object);
// }
// /*
// *这里用来加载视图区,也就是每个菜单的对应的内容
// *但是这里应该针对不同的菜单填选对应不同的内容
// * */
// @Override
// public Object instantiateItem(final ViewGroup container, final int position) {
// //每个position代表一个菜单根据position来设置不同视图
////
// switch (position){
// case 0:
// //饮食爱好
// case 1:
// //日历
// View view = setCanlendar();
// container.addView(view);
// return view;
// case 2:
// //消息通知
// case 3:
// //我的文章
// case 4:
// //养生推荐
//
//
// }
// //这是默认的,不要管,因为上面必须有个返回值
// final View view = LayoutInflater.from(
// appCompatActivity.getBaseContext()).inflate(R.layout.item_vp, null, false);
// final TextView txtPage = (TextView) view.findViewById(R.id.txt_vp_item_page);
// txtPage.setText(String.format("Page #%d", position));
// container.addView(view);
//
// return view;
//
// }
// //设置日历
// public View setCanlendar(){
// final View view = LayoutInflater.from(
// appCompatActivity.getBaseContext()
// ).inflate(R.layout.canlendar_layout, null, false);
// return view;
// }
// //设置饮食爱好
// public View setfoodhobby(){
// return null;
// }
// });
// /*
// * 这里开始设置菜单栏
// * */
// //每个菜单选取了不同的颜色
// final String[] colors = getResources().getStringArray(R.array.vertical_ntb);
// //这里菜单栏选取的是NavigationTabBar
// final NavigationTabBar navigationTabBar = (NavigationTabBar) appCompatActivity.findViewById(R.id.ntb_vertical);
// //这里用来加载每个model可以设置几个菜单
// final ArrayList<NavigationTabBar.Model> models = new ArrayList<>();
// models.add(
// new NavigationTabBar.Model.Builder(
// getResources().getDrawable(R.drawable.ic_sixth),
// Color.parseColor(colors[5]))
// getResources().getDrawable(R.drawable.ic_first),
// Color.parseColor(colors[0]))
// .title("ic_first")
// .selectedIcon(getResources().getDrawable(R.drawable.ic_eighth))
// .title("ic_sixth")
// .build()
// );
// models.add(
// new NavigationTabBar.Model.Builder(
// getResources().getDrawable(R.drawable.ic_seventh),
// Color.parseColor(colors[6]))
// getResources().getDrawable(R.drawable.ic_second),
// Color.parseColor(colors[1]))
// .selectedIcon(getResources().getDrawable(R.drawable.ic_eighth))
// .title("ic_seventh")
// .title("ic_second")
// .build()
// );
// models.add(
// new NavigationTabBar.Model.Builder(
// getResources().getDrawable(R.drawable.ic_eighth),
// Color.parseColor(colors[7]))
// getResources().getDrawable(R.drawable.ic_third),
// Color.parseColor(colors[2]))
// .selectedIcon(getResources().getDrawable(R.drawable.ic_eighth))
// .title("ic_eighth")
// .title("ic_third")
// .build()
// );
//设置菜单
navigationTabBar.setModels(models);
//设置每个子菜单对一个的viewpager
navigationTabBar.setViewPager(viewPager, 0);
}
// models.add(
// new NavigationTabBar.Model.Builder(
// getResources().getDrawable(R.drawable.ic_fourth),
// Color.parseColor(colors[3]))
// .selectedIcon(getResources().getDrawable(R.drawable.ic_eighth))
// .title("ic_fourth")
// .build()
// );
// models.add(
// new NavigationTabBar.Model.Builder(
// getResources().getDrawable(R.drawable.ic_fifth),
// Color.parseColor(colors[4]))
// .selectedIcon(getResources().getDrawable(R.drawable.ic_eighth))
// .title("ic_fifth")
// .build()
// );
//// models.add(
//// new NavigationTabBar.Model.Builder(
//// getResources().getDrawable(R.drawable.ic_sixth),
//// Color.parseColor(colors[5]))
//// .selectedIcon(getResources().getDrawable(R.drawable.ic_eighth))
//// .title("ic_sixth")
//// .build()
//// );
//// models.add(
//// new NavigationTabBar.Model.Builder(
//// getResources().getDrawable(R.drawable.ic_seventh),
//// Color.parseColor(colors[6]))
//// .selectedIcon(getResources().getDrawable(R.drawable.ic_eighth))
//// .title("ic_seventh")
//// .build()
//// );
//// models.add(
//// new NavigationTabBar.Model.Builder(
//// getResources().getDrawable(R.drawable.ic_eighth),
//// Color.parseColor(colors[7]))
//// .selectedIcon(getResources().getDrawable(R.drawable.ic_eighth))
//// .title("ic_eighth")
//// .build()
//// );
// //设置菜单
// navigationTabBar.setModels(models);
// //设置每个子菜单对一个的viewpager
// navigationTabBar.setViewPager(viewPager, 0);
// }
//设置菜单

@ -7,11 +7,27 @@ import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.Fragment;
import com.example.cmknowledgegraph.LoginActivity;
import com.mxn.soul.flowingdrawer_core.FlowingDrawer;
/*
*
*
*
*
* */
public class avatarOnclickListener implements View.OnClickListener {
AppCompatActivity appCompatActivity;
Fragment personFragment;
public avatarOnclickListener(AppCompatActivity appCompatActivity,Fragment fragment){
private FlowingDrawer flowingDrawerl;
public FlowingDrawer getFlowingDrawerl() {
return flowingDrawerl;
}
public void setFlowingDrawerl(FlowingDrawer flowingDrawerl){
this.flowingDrawerl = flowingDrawerl;
}
public avatarOnclickListener(AppCompatActivity appCompatActivity, Fragment fragment){
this.personFragment = fragment;
this.appCompatActivity = appCompatActivity;
}
@ -19,7 +35,9 @@ public class avatarOnclickListener implements View.OnClickListener {
public void onClick(View v) {
//这里监听就是如果未登录就跳到登录界面
if(User.isLogin()){
//登陆了
//登陆了,登录了点击主界面头像就可以打开左边菜单栏
flowingDrawerl.toggleMenu();
}else{
//没有登录
//跳转到登录界面

@ -18,82 +18,85 @@
android:layout_height="match_parent"
android:orientation="vertical">
>
<!-- 主要页面的内容也就是在person直接能看到的-->
<!-- 在这里添加自定义主页面 可支持自定义背景图还有头像然后几个cardview-->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ImageView
android:layout_width="match_parent"
android:layout_height="300dp"
android:background="@drawable/draw1"/>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="440dp"
android:orientation="horizontal"
android:background="#423752">
<devlight.io.library.ntb.NavigationTabBar
app:ntb_title_mode="all"
app:ntb_titled="true"
app:ntb_title_size="14sp"
android:id="@+id/ntb_vertical"
android:layout_width="50dp"
android:layout_height="match_parent"
app:ntb_preview_colors="@array/vertical_ntb"/>
<androidx.viewpager.widget.ViewPager
android:id="@+id/vp_vertical_ntb"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"/>
</LinearLayout>
</LinearLayout>
//最上面的菜单栏
//上面的背景
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView android:id="@+id/iv_blur"
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="300dp" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_centerInParent="true">
<de.hdodenhof.circleimageview.CircleImageView
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/iv_avatar"
android:layout_width="80dp"
android:layout_height="80dp"
android:src="@drawable/draw1"
app:civ_border_width="2dp"
app:civ_border_color="#FF000000"
/>
<TextView
android:id="@+id/user_name_person"
android:background="#423752">
//背景
<ImageView android:id="@+id/iv_blur"
android:layout_width="match_parent"
android:layout_height="410dp"
android:scaleType="fitXY"
android:paddingTop="0dp"/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="未登录"
android:textSize="20sp"
android:layout_marginTop="30dp"
/>
android:orientation="horizontal"
android:layout_centerInParent="true">
//头像
<de.hdodenhof.circleimageview.CircleImageView
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/iv_avatar"
android:layout_width="80dp"
android:layout_height="80dp"
android:src="@drawable/draw7"
app:civ_border_width="2dp"
app:civ_border_color="#FF000000"
/>
//用户名
<TextView
android:id="@+id/user_name_person"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="未登录"
android:textSize="20sp"
android:layout_marginTop="30dp"
/>
</LinearLayout>
</RelativeLayout>
<!--原来的竖向菜单-->
<!-- <LinearLayout-->
<!-- xmlns:android="http://schemas.android.com/apk/res/android"-->
<!-- xmlns:app="http://schemas.android.com/apk/res-auto"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="match_parent"-->
<!-- android:layout_marginBottom="50dp"-->
<!-- android:orientation="horizontal"-->
<!-- android:background="#423752">-->
<!-- <devlight.io.library.ntb.NavigationTabBar-->
<!-- app:ntb_title_mode="all"-->
<!-- app:ntb_titled="true"-->
<!-- app:ntb_title_size="14sp"-->
<!-- android:id="@+id/ntb_vertical"-->
<!-- android:layout_width="50dp"-->
<!-- android:layout_height="match_parent"-->
<!-- app:ntb_preview_colors="@array/vertical_ntb"/>-->
<!-- <androidx.viewpager.widget.ViewPager-->
<!-- android:id="@+id/vp_vertical_ntb"-->
<!-- android:layout_width="0dp"-->
<!-- android:layout_height="match_parent"-->
<!-- android:layout_weight="1"/>-->
<!-- </LinearLayout>-->
</LinearLayout>
</LinearLayout>
</RelativeLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>

@ -10,8 +10,11 @@
android:id="@+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/draw7"
/>
<!-- 喜欢或者不喜欢-->
<com.example.HomeContent.SmileView
android:id="@+id/smile_view"
android:layout_width="match_parent"

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="321dp"
android:layout_height="456dp"
android:layout_width="match_parent"
android:layout_height="620dp"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_gravity="center_horizontal"
app:cardCornerRadius="5dp"

Loading…
Cancel
Save