parent
dd207daf39
commit
1eebc6509e
@ -0,0 +1,123 @@
|
|||||||
|
package com.example.PersonalCenter;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
import androidx.appcompat.app.ActionBar;
|
||||||
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
import androidx.appcompat.widget.Toolbar;
|
||||||
|
import androidx.fragment.app.Fragment;
|
||||||
|
import androidx.fragment.app.FragmentStatePagerAdapter;
|
||||||
|
import androidx.viewpager.widget.ViewPager;
|
||||||
|
|
||||||
|
import com.example.cmknowledgegraph.MainActivity;
|
||||||
|
import com.example.cmknowledgegraph.R;
|
||||||
|
import com.github.florent37.materialviewpager.MaterialViewPager;
|
||||||
|
import com.github.florent37.materialviewpager.header.HeaderDesign;
|
||||||
|
|
||||||
|
public class MyPersonCenter extends Fragment {
|
||||||
|
MainActivity mainActivity;
|
||||||
|
@Override
|
||||||
|
public void onAttach(Context context) {
|
||||||
|
super.onAttach(context);
|
||||||
|
this.mainActivity = (MainActivity) context;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||||
|
return inflater.inflate(R.layout.chat_content, container, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
|
||||||
|
super.onActivityCreated(savedInstanceState);
|
||||||
|
//包装处理逻辑
|
||||||
|
//得到MaterViewPager实例
|
||||||
|
MaterialViewPager materialViewPager = (MaterialViewPager) getActivity().findViewById(R.id.materialViewPager);
|
||||||
|
//为MaterialViewPager添加监听
|
||||||
|
materialViewPager.setMaterialViewPagerListener(new MaterialViewPager.Listener() {
|
||||||
|
@Override
|
||||||
|
//设置转换动画和图片,颜色
|
||||||
|
public HeaderDesign getHeaderDesign(int page) {
|
||||||
|
switch (page){
|
||||||
|
case 0:
|
||||||
|
return HeaderDesign.fromColorResAndDrawable(
|
||||||
|
R.color.blue,
|
||||||
|
getResources().getDrawable(R.drawable.home_back)
|
||||||
|
);
|
||||||
|
case 1:
|
||||||
|
return HeaderDesign.fromColorResAndDrawable(
|
||||||
|
R.color.green,
|
||||||
|
getResources().getDrawable(R.drawable.home_back)
|
||||||
|
);
|
||||||
|
case 2:
|
||||||
|
return HeaderDesign.fromColorResAndDrawable(
|
||||||
|
R.color.cyan,
|
||||||
|
getResources().getDrawable(R.drawable.home_back)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
//设置Toolbar
|
||||||
|
Toolbar toolbar = materialViewPager.getToolbar();
|
||||||
|
if(toolbar!=null){
|
||||||
|
mainActivity.setSupportActionBar(toolbar);
|
||||||
|
ActionBar actionBar = mainActivity.getSupportActionBar();
|
||||||
|
actionBar.setDisplayHomeAsUpEnabled(true);
|
||||||
|
actionBar.setDisplayShowHomeEnabled(true);
|
||||||
|
actionBar.setDisplayShowTitleEnabled(true);
|
||||||
|
actionBar.setDisplayUseLogoEnabled(false);
|
||||||
|
actionBar.setHomeButtonEnabled(true);
|
||||||
|
}
|
||||||
|
//为Viewpager设置适配器
|
||||||
|
ViewPager viewPager = materialViewPager.getViewPager();
|
||||||
|
viewPager.setAdapter(new FragmentStatePagerAdapter(getChildFragmentManager()) {
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
public Fragment getItem(int position) {
|
||||||
|
switch (position % 3){
|
||||||
|
case 0:
|
||||||
|
return RecyclerViewFragment.newInstance(0,mainActivity);
|
||||||
|
case 1:
|
||||||
|
return RecyclerViewFragment.newInstance(1,mainActivity);
|
||||||
|
case 2:
|
||||||
|
return RecyclerViewFragment.newInstance(1,mainActivity);
|
||||||
|
default:
|
||||||
|
return RecyclerViewFragment.newInstance(1,mainActivity);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getCount() {
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public CharSequence getPageTitle(int position) {
|
||||||
|
switch (position % 3){
|
||||||
|
case 0:
|
||||||
|
return "jil";
|
||||||
|
case 1:
|
||||||
|
return "drug";
|
||||||
|
case 2:
|
||||||
|
return "药友";
|
||||||
|
default:
|
||||||
|
return "TAPN";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
materialViewPager.getViewPager().setOffscreenPageLimit(materialViewPager
|
||||||
|
.getViewPager().getAdapter().getCount());
|
||||||
|
materialViewPager.getPagerTitleStrip().setViewPager(materialViewPager.getViewPager());
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,132 @@
|
|||||||
|
package com.example.PersonalCenter;
|
||||||
|
|
||||||
|
import android.os.Handler;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
|
import com.example.cmknowledgegraph.R;
|
||||||
|
import com.loopeer.cardstack.CardStackView;
|
||||||
|
import com.ramotion.foldingcell.FoldingCell;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class RecyclerViewPagerAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
||||||
|
List<Object> contents;
|
||||||
|
int flag;
|
||||||
|
AppCompatActivity appCompatActivity;
|
||||||
|
|
||||||
|
public void setAppCompatActivity(AppCompatActivity appCompatActivity) {
|
||||||
|
this.appCompatActivity = appCompatActivity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public RecyclerViewPagerAdapter(List<Object> contents, int flag)
|
||||||
|
{
|
||||||
|
this.flag = flag;
|
||||||
|
this.contents = contents;
|
||||||
|
}
|
||||||
|
public int getItemCount() {
|
||||||
|
return contents.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||||
|
|
||||||
|
View view = null;
|
||||||
|
switch (flag){
|
||||||
|
case 0://论坛
|
||||||
|
view = LayoutInflater.from(parent.getContext())
|
||||||
|
.inflate(R.layout.internetforumfragment, parent, false);
|
||||||
|
//
|
||||||
|
// view = LayoutInflater.from(parent.getContext()).inflate(R.layout.drug_friends,parent,false);
|
||||||
|
FoldingCell foldingCell = view.findViewById(R.id.folding_cell);
|
||||||
|
foldingCell.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
foldingCell.toggle(false);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return new RecyclerView.ViewHolder(view) {
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
case 1://动态
|
||||||
|
view = LayoutInflater.from(parent.getContext())
|
||||||
|
.inflate(R.layout.content_cardview, parent, false);
|
||||||
|
|
||||||
|
return new RecyclerView.ViewHolder(view) {
|
||||||
|
};
|
||||||
|
|
||||||
|
case 2://好友列表
|
||||||
|
view = LayoutInflater.from(parent.getContext())
|
||||||
|
.inflate(R.layout.content_cardview, parent, false);
|
||||||
|
|
||||||
|
return new RecyclerView.ViewHolder(view) {
|
||||||
|
};
|
||||||
|
// view = LayoutInflater.from(parent.getContext())
|
||||||
|
// .inflate(R.layout.drug_friends,parent,false);
|
||||||
|
// CardStackView cardStackView = view.findViewById(R.id.stackview);
|
||||||
|
// Integer[] item = new Integer[]{R.color.color_1,
|
||||||
|
// R.color.color_2,
|
||||||
|
// R.color.color_3,
|
||||||
|
// R.color.color_4,
|
||||||
|
// R.color.color_5,
|
||||||
|
// R.color.color_6,
|
||||||
|
// R.color.color_7,
|
||||||
|
// R.color.color_8,
|
||||||
|
// R.color.color_9,
|
||||||
|
// R.color.color_10,
|
||||||
|
// R.color.color_11,
|
||||||
|
// R.color.color_12,
|
||||||
|
// R.color.color_13,
|
||||||
|
// R.color.color_14,
|
||||||
|
// R.color.color_15,
|
||||||
|
// R.color.color_16,
|
||||||
|
// R.color.color_17,
|
||||||
|
// R.color.color_18,
|
||||||
|
// R.color.color_19,
|
||||||
|
// R.color.color_20,
|
||||||
|
// R.color.color_21,
|
||||||
|
// R.color.color_22,
|
||||||
|
// R.color.color_23,
|
||||||
|
// R.color.color_24,
|
||||||
|
// R.color.color_25,
|
||||||
|
// R.color.color_26};
|
||||||
|
// DrugFriendsCardAdapter drugFriendsCardAdapter = new DrugFriendsCardAdapter(parent.getContext());
|
||||||
|
// drugFriendsCardAdapter.setAppCompatActivity(appCompatActivity);
|
||||||
|
//
|
||||||
|
// cardStackView.setAdapter(drugFriendsCardAdapter);
|
||||||
|
// cardStackView.setItemExpendListener(new CardStackView.ItemExpendListener() {
|
||||||
|
// @Override
|
||||||
|
// public void onItemExpend(boolean expend) {
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
// cardStackView.setAnimatorAdapter(new AllMoveDownAnimatorAdapter(cardStackView));
|
||||||
|
// new Handler().postDelayed(new Runnable() {
|
||||||
|
// @Override
|
||||||
|
// public void run() {
|
||||||
|
// drugFriendsCardAdapter.updateData(Arrays.asList(item));
|
||||||
|
// }
|
||||||
|
// },200);
|
||||||
|
// return new RecyclerView.ViewHolder(view) {
|
||||||
|
// @Override
|
||||||
|
// public String toString() {
|
||||||
|
// return super.toString();
|
||||||
|
// }
|
||||||
|
// };
|
||||||
|
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
|
||||||
|
//在这里设置某一个条目的监听
|
||||||
|
}
|
||||||
|
}
|
After Width: | Height: | Size: 1.8 KiB |
@ -0,0 +1,45 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
这个xml文件是chat区的总体页面
|
||||||
|
-->
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
app:layout_behavior="@string/appbar_scrolling_view_behavior"
|
||||||
|
tools:context=".MainActivity"
|
||||||
|
tools:showIn="@layout/activity_main">
|
||||||
|
<com.github.florent37.materialviewpager.MaterialViewPager
|
||||||
|
android:id="@+id/materialViewPager"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
app:viewpager_logo="@layout/header_logo"
|
||||||
|
app:viewpager_logoMarginTop="100dp"
|
||||||
|
app:viewpager_color="@color/colorPrimary"
|
||||||
|
app:viewpager_headerHeight="200dp"
|
||||||
|
app:viewpager_headerAlpha="1.0"
|
||||||
|
app:viewpager_hideLogoWithFade="false"
|
||||||
|
app:viewpager_hideToolbarAndTitle="true"
|
||||||
|
app:viewpager_enableToolbarElevation="true"
|
||||||
|
app:viewpager_parallaxHeaderFactor="1.5"
|
||||||
|
app:viewpager_headerAdditionalHeight="20dp"
|
||||||
|
app:viewpager_displayToolbarWhenSwipe="true"
|
||||||
|
app:viewpager_transparentToolbar="true"
|
||||||
|
app:viewpager_animatedHeaderImage="true"
|
||||||
|
app:viewpager_disableToolbar="false">
|
||||||
|
<RelativeLayout
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginBottom="40dp"
|
||||||
|
>
|
||||||
|
<de.hdodenhof.circleimageview.CircleImageView
|
||||||
|
android:layout_width="40dp"
|
||||||
|
android:layout_height="30dp"
|
||||||
|
android:src="@drawable/home_back_1"
|
||||||
|
/>
|
||||||
|
</RelativeLayout>
|
||||||
|
</com.github.florent37.materialviewpager.MaterialViewPager>
|
||||||
|
|
||||||
|
</LinearLayout>
|
@ -0,0 +1,27 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
|
<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:id="@+id/card_view"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="200dp"
|
||||||
|
android:layout_marginBottom="@dimen/cardMarginVertical"
|
||||||
|
android:layout_marginLeft="@dimen/cardMarginHorizontal"
|
||||||
|
android:layout_marginRight="@dimen/cardMarginHorizontal"
|
||||||
|
android:layout_marginTop="@dimen/cardMarginVertical"
|
||||||
|
app:cardCornerRadius="2dp"
|
||||||
|
app:cardElevation="2dp"
|
||||||
|
app:cardPreventCornerOverlap="false"
|
||||||
|
android:clickable="true"
|
||||||
|
app:contentPadding="0dp">
|
||||||
|
android:foreground="?android:attr/selectableItemBackgroundBorderless"
|
||||||
|
</androidx.cardview.widget.CardView>
|
||||||
|
|
||||||
|
|
||||||
|
</FrameLayout>
|
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<androidx.recyclerview.widget.RecyclerView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:id="@+id/recyclerView"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
/>
|
@ -0,0 +1,81 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:folding-cell="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
<com.ramotion.foldingcell.FoldingCell
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:id="@+id/folding_cell"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginBottom="@dimen/cardMarginVertical"
|
||||||
|
android:layout_marginLeft="@dimen/cardMarginHorizontal"
|
||||||
|
android:layout_marginRight="@dimen/cardMarginHorizontal"
|
||||||
|
android:layout_marginTop="@dimen/cardMarginVertical"
|
||||||
|
android:clipChildren="false"
|
||||||
|
android:clipToPadding="false"
|
||||||
|
android:elevation="0dp"
|
||||||
|
folding-cell:animationDuration="1000"
|
||||||
|
folding-cell:backSideColor="@color/blue"
|
||||||
|
folding-cell:additionalFlipsCount="15">
|
||||||
|
|
||||||
|
<!-- 展开后-->
|
||||||
|
<FrameLayout
|
||||||
|
android:id="@+id/cell_content_view"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="@android:color/holo_green_dark"
|
||||||
|
android:visibility="gone">
|
||||||
|
<!-- 头像-->
|
||||||
|
<de.hdodenhof.circleimageview.CircleImageView
|
||||||
|
android:layout_width="45dp"
|
||||||
|
android:layout_height="45dp"
|
||||||
|
android:layout_marginTop="5dp"
|
||||||
|
android:layout_marginLeft="5dp"
|
||||||
|
android:background="@drawable/van"/>
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="80dp"
|
||||||
|
android:text="这是展开后"/>
|
||||||
|
<ImageView
|
||||||
|
android:layout_width="100dp"
|
||||||
|
android:layout_height="80dp"
|
||||||
|
android:layout_marginTop="180dp"
|
||||||
|
android:src="@drawable/home_back_1"/>
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="1300dp"
|
||||||
|
android:text="这是展开后"/>
|
||||||
|
|
||||||
|
<!-- <TextView-->
|
||||||
|
<!-- android:layout_width="match_parent"-->
|
||||||
|
<!-- android:layout_height="250dp"-->
|
||||||
|
<!-- android:text="jkadiekeieii"-->
|
||||||
|
<!-- android:textColor="@color/white"/>-->
|
||||||
|
</FrameLayout>
|
||||||
|
|
||||||
|
<!-- 展开前-->
|
||||||
|
<FrameLayout
|
||||||
|
android:id="@+id/cell_title_view"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="@color/white">
|
||||||
|
<de.hdodenhof.circleimageview.CircleImageView
|
||||||
|
android:layout_width="45dp"
|
||||||
|
android:layout_height="45dp"
|
||||||
|
android:layout_marginTop="5dp"
|
||||||
|
android:layout_marginLeft="5dp"
|
||||||
|
android:background="@drawable/van"/>
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="90dp"
|
||||||
|
|
||||||
|
android:text="这是未展开前"></TextView>
|
||||||
|
</FrameLayout>
|
||||||
|
|
||||||
|
</com.ramotion.foldingcell.FoldingCell>
|
||||||
|
</LinearLayout>
|
Loading…
Reference in new issue