parent
f3d857fb68
commit
88ee3689db
@ -0,0 +1,269 @@
|
||||
package com.example.PersonalCenter;
|
||||
|
||||
import android.app.Person;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import androidx.viewpager.widget.PagerAdapter;
|
||||
import androidx.viewpager.widget.ViewPager;
|
||||
|
||||
import com.example.PersonalCenter.FeedAdapter;
|
||||
import com.example.PersonalCenter.MenuListFragment;
|
||||
import com.example.cmknowledgegraph.MainActivity;
|
||||
import com.example.cmknowledgegraph.R;
|
||||
import com.mxn.soul.flowingdrawer_core.ElasticDrawer;
|
||||
import com.mxn.soul.flowingdrawer_core.FlowingDrawer;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import devlight.io.library.ntb.NavigationTabBar;
|
||||
import yalantis.com.sidemenu.interfaces.Resourceble;
|
||||
import yalantis.com.sidemenu.interfaces.ScreenShotable;
|
||||
import yalantis.com.sidemenu.util.ViewAnimator;
|
||||
|
||||
public class PersonContent extends Fragment {
|
||||
|
||||
|
||||
protected int res;
|
||||
private ViewPager viewPager;
|
||||
private RecyclerView rvFeed;
|
||||
private FlowingDrawer mDrawer;
|
||||
@Override
|
||||
public void onAttach(@NonNull Context context) {
|
||||
super.onAttach(context);
|
||||
MainActivity mainActivity = (MainActivity) context;
|
||||
}
|
||||
|
||||
AppCompatActivity appCompatActivity;
|
||||
|
||||
public AppCompatActivity getAppCompatActivity() {
|
||||
return appCompatActivity;
|
||||
}
|
||||
|
||||
public void setAppCompatActivity(AppCompatActivity appCompatActivity) {
|
||||
this.appCompatActivity = appCompatActivity;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
// Inflate the layout for this fragment
|
||||
return inflater.inflate( R.layout.activity_personality_center, container, false ); //要加载的layout文件
|
||||
}
|
||||
|
||||
@Override
|
||||
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);
|
||||
mDrawer = (FlowingDrawer) appCompatActivity.findViewById(R.id.drawerlayout);
|
||||
mDrawer.setTouchMode(ElasticDrawer.TOUCH_MODE_BEZEL);
|
||||
//设置工具栏
|
||||
setupToolbar();
|
||||
//设置直接页面
|
||||
// setupFeed();
|
||||
setupViewpager();
|
||||
//设置侧滑菜单
|
||||
setupMenu();
|
||||
}
|
||||
protected void setupToolbar() {
|
||||
Toolbar toolbar = (Toolbar) appCompatActivity.findViewById(R.id.toolbar);
|
||||
appCompatActivity.setSupportActionBar(toolbar);
|
||||
//这里是图片,可以将其动态加载用户图片,如果没有登录就改成别的。
|
||||
toolbar.setNavigationIcon(R.drawable.ic_menu_white);
|
||||
//点击了就开始侧滑
|
||||
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
mDrawer.toggleMenu();
|
||||
}
|
||||
});
|
||||
}
|
||||
//设置没有侧滑之前的状态页面
|
||||
//在这里将东西其改成几个按钮
|
||||
private void setupViewpager(){
|
||||
viewPager.setAdapter(new PagerAdapter() {
|
||||
@Override
|
||||
public int getCount() {
|
||||
return 8;
|
||||
}
|
||||
|
||||
@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) {
|
||||
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;
|
||||
}
|
||||
});
|
||||
|
||||
final String[] colors = getResources().getStringArray(R.array.vertical_ntb);
|
||||
|
||||
final NavigationTabBar navigationTabBar = (NavigationTabBar) appCompatActivity.findViewById(R.id.ntb_vertical);
|
||||
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()
|
||||
);
|
||||
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);
|
||||
navigationTabBar.setViewPager(viewPager, 4);
|
||||
}
|
||||
// private void setupFeed() {
|
||||
// LinearLayoutManager linearLayoutManager = new LinearLayoutManager(appCompatActivity) {
|
||||
// @Override
|
||||
// protected int getExtraLayoutSpace(RecyclerView.State state) {
|
||||
// return 300;
|
||||
// }
|
||||
// };
|
||||
// rvFeed.setLayoutManager(linearLayoutManager);
|
||||
// FeedAdapter feedAdapter = new FeedAdapter(appCompatActivity);
|
||||
// rvFeed.setAdapter(feedAdapter);
|
||||
// feedAdapter.updateItems();
|
||||
// }
|
||||
|
||||
//设置菜单
|
||||
private void setupMenu() {
|
||||
FragmentManager fm = appCompatActivity.getSupportFragmentManager();//获取Fragment管理器
|
||||
MenuListFragment mMenuFragment = (MenuListFragment) fm.findFragmentById(R.id.id_container_menu);
|
||||
if (mMenuFragment == null) {
|
||||
mMenuFragment = new MenuListFragment();
|
||||
fm.beginTransaction().add(R.id.id_container_menu, mMenuFragment).commit();
|
||||
//向activity添加一个布局
|
||||
}
|
||||
|
||||
// mDrawer.setOnDrawerStateChangeListener(new ElasticDrawer.OnDrawerStateChangeListener() {
|
||||
// @Override
|
||||
// public void onDrawerStateChange(int oldState, int newState) {
|
||||
// if (newState == ElasticDrawer.STATE_CLOSED) {
|
||||
// Log.i("MainActivity", "Drawer STATE_CLOSED");
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onDrawerSlide(float openRatio, int offsetPixels) {
|
||||
// Log.i("MainActivity", "openRatio=" + openRatio + " ,offsetPixels=" + offsetPixels);
|
||||
// }
|
||||
// });
|
||||
}
|
||||
//
|
||||
// public void onActivityCreated(Bundle savedInstanceState) {
|
||||
// // TODO Auto-generated method stub
|
||||
// super.onActivityCreated(savedInstanceState);
|
||||
//
|
||||
// Button login_pc_btn = (Button) getActivity().findViewById(R.id.login_pc_button);
|
||||
// login_pc_btn.setOnClickListener(new View.OnClickListener() {
|
||||
// public void onClick(View v) {
|
||||
//
|
||||
// Intent intent=new Intent();
|
||||
// intent.setClass(getActivity(),LoginActivity.class);
|
||||
// startActivity(intent);
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
|
||||
// @Override
|
||||
// public void onResume() {
|
||||
// super.onResume();
|
||||
// if(LoginActivity.isLogin){
|
||||
// Button longin_pc_btn=(Button) getActivity().findViewById(R.id.login_pc_button);
|
||||
// longin_pc_btn.setText("Hello"+LoginActivity.username);
|
||||
// }
|
||||
//
|
||||
////高血压
|
||||
// }
|
||||
}
|
@ -1,156 +0,0 @@
|
||||
package com.example.cmknowledgegraph;
|
||||
|
||||
import android.app.Person;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Canvas;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.example.PersonalCenter.FeedAdapter;
|
||||
import com.example.PersonalCenter.MenuListFragment;
|
||||
import com.mxn.soul.flowingdrawer_core.ElasticDrawer;
|
||||
import com.mxn.soul.flowingdrawer_core.FlowingDrawer;
|
||||
|
||||
import yalantis.com.sidemenu.interfaces.Resourceble;
|
||||
import yalantis.com.sidemenu.interfaces.ScreenShotable;
|
||||
import yalantis.com.sidemenu.util.ViewAnimator;
|
||||
|
||||
public class PersonContent extends Fragment {
|
||||
|
||||
|
||||
protected int res;
|
||||
|
||||
private RecyclerView rvFeed;
|
||||
private FlowingDrawer mDrawer;
|
||||
@Override
|
||||
public void onAttach(@NonNull Context context) {
|
||||
super.onAttach(context);
|
||||
MainActivity mainActivity = (MainActivity) context;
|
||||
}
|
||||
|
||||
AppCompatActivity appCompatActivity;
|
||||
|
||||
public AppCompatActivity getAppCompatActivity() {
|
||||
return appCompatActivity;
|
||||
}
|
||||
|
||||
public void setAppCompatActivity(AppCompatActivity appCompatActivity) {
|
||||
this.appCompatActivity = appCompatActivity;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
// Inflate the layout for this fragment
|
||||
return inflater.inflate( R.layout.activity_personality_center, container, false ); //要加载的layout文件
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
|
||||
super.onActivityCreated(savedInstanceState);
|
||||
rvFeed = (RecyclerView) appCompatActivity.findViewById(R.id.rvFeed);
|
||||
mDrawer = (FlowingDrawer) appCompatActivity.findViewById(R.id.drawerlayout);
|
||||
mDrawer.setTouchMode(ElasticDrawer.TOUCH_MODE_BEZEL);
|
||||
//设置工具栏
|
||||
setupToolbar();
|
||||
//设置直接页面
|
||||
setupFeed();
|
||||
//设置侧滑菜单
|
||||
setupMenu();
|
||||
}
|
||||
protected void setupToolbar() {
|
||||
Toolbar toolbar = (Toolbar) appCompatActivity.findViewById(R.id.toolbar);
|
||||
appCompatActivity.setSupportActionBar(toolbar);
|
||||
//这里是图片,可以将其动态加载用户图片,如果没有登录就改成别的。
|
||||
toolbar.setNavigationIcon(R.drawable.ic_menu_white);
|
||||
//点击了就开始侧滑
|
||||
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
mDrawer.toggleMenu();
|
||||
}
|
||||
});
|
||||
}
|
||||
//设置没有侧滑之前的状态页面
|
||||
//在这里将东西其改成几个按钮
|
||||
private void setupFeed() {
|
||||
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(appCompatActivity) {
|
||||
@Override
|
||||
protected int getExtraLayoutSpace(RecyclerView.State state) {
|
||||
return 300;
|
||||
}
|
||||
};
|
||||
rvFeed.setLayoutManager(linearLayoutManager);
|
||||
FeedAdapter feedAdapter = new FeedAdapter(appCompatActivity);
|
||||
rvFeed.setAdapter(feedAdapter);
|
||||
feedAdapter.updateItems();
|
||||
}
|
||||
|
||||
//设置菜单
|
||||
private void setupMenu() {
|
||||
FragmentManager fm = appCompatActivity.getSupportFragmentManager();//获取Fragment管理器
|
||||
MenuListFragment mMenuFragment = (MenuListFragment) fm.findFragmentById(R.id.id_container_menu);
|
||||
if (mMenuFragment == null) {
|
||||
mMenuFragment = new MenuListFragment();
|
||||
fm.beginTransaction().add(R.id.id_container_menu, mMenuFragment).commit();
|
||||
//向activity添加一个布局
|
||||
}
|
||||
|
||||
// mDrawer.setOnDrawerStateChangeListener(new ElasticDrawer.OnDrawerStateChangeListener() {
|
||||
// @Override
|
||||
// public void onDrawerStateChange(int oldState, int newState) {
|
||||
// if (newState == ElasticDrawer.STATE_CLOSED) {
|
||||
// Log.i("MainActivity", "Drawer STATE_CLOSED");
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onDrawerSlide(float openRatio, int offsetPixels) {
|
||||
// Log.i("MainActivity", "openRatio=" + openRatio + " ,offsetPixels=" + offsetPixels);
|
||||
// }
|
||||
// });
|
||||
}
|
||||
//
|
||||
// public void onActivityCreated(Bundle savedInstanceState) {
|
||||
// // TODO Auto-generated method stub
|
||||
// super.onActivityCreated(savedInstanceState);
|
||||
//
|
||||
// Button login_pc_btn = (Button) getActivity().findViewById(R.id.login_pc_button);
|
||||
// login_pc_btn.setOnClickListener(new View.OnClickListener() {
|
||||
// public void onClick(View v) {
|
||||
//
|
||||
// Intent intent=new Intent();
|
||||
// intent.setClass(getActivity(),LoginActivity.class);
|
||||
// startActivity(intent);
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
|
||||
// @Override
|
||||
// public void onResume() {
|
||||
// super.onResume();
|
||||
// if(LoginActivity.isLogin){
|
||||
// Button longin_pc_btn=(Button) getActivity().findViewById(R.id.login_pc_button);
|
||||
// longin_pc_btn.setText("Hello"+LoginActivity.username);
|
||||
// }
|
||||
//
|
||||
////高血压
|
||||
// }
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package com.example.cmknowledgegraph;
|
||||
package com.example.tools;
|
||||
|
||||
import com.hankcs.hanlp.HanLP;
|
||||
|
Loading…
Reference in new issue