sdf
This commit is contained in:
380
app/src/main/java/com/sl/house_property/Main4Fragment.java
Normal file
380
app/src/main/java/com/sl/house_property/Main4Fragment.java
Normal file
@@ -0,0 +1,380 @@
|
||||
package com.sl.house_property;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.RelativeLayout;
|
||||
|
||||
import com.cutil.SizeUtils;
|
||||
import com.cutil.StringUtils;
|
||||
import com.cutil.Utils;
|
||||
import com.sl.house_property.f1.UserdlistActivity;
|
||||
import com.sl.house_property.user.MyAuthorizedFamilyHistory;
|
||||
import com.sl.house_property.user.MyBillHistory;
|
||||
import com.sl.house_property.user.MyGuaranteeHistory;
|
||||
import com.sl.house_property.user.MyKeyManagement;
|
||||
import com.sl.house_property.user.MyMarketShopActivity;
|
||||
import com.sl.house_property.user.MyPropertyActivity;
|
||||
import com.sl.house_property.user.MyServiceHistory;
|
||||
import com.sl.house_property.user.MyUserMessage;
|
||||
import com.sl.house_property.user.MyWalletActivity;
|
||||
import com.sl.house_property.databinding.FragmentMain4Binding;
|
||||
import com.sl.house_property.databinding.UserFragmentItemBinding;
|
||||
import com.squareup.picasso.Picasso;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import adapter.BaseRecycleViewAdapter;
|
||||
import entity.MyUserFEntity;
|
||||
import entity.RegisterUser;
|
||||
import my_view.tao_bao_refresh.FullyGridLayoutManager;
|
||||
import tools.Config;
|
||||
import utils.BitmapTools;
|
||||
|
||||
|
||||
/**
|
||||
* A simple {@link Fragment} subclass.
|
||||
* Activities that contain this fragment must implement the
|
||||
* {@link Main1Fragment.OnFragmentInteractionListener} interface
|
||||
* to handle interaction events.
|
||||
* Use the {@link Main1Fragment#newInstance} factory method to
|
||||
* create an instance of this fragment.
|
||||
*/
|
||||
public class Main4Fragment extends BaseFragment<FragmentMain4Binding> {
|
||||
// TODO: Rename parameter arguments, choose names that match
|
||||
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
|
||||
private static final String ARG_PARAM1 = "param1";
|
||||
private static final String ARG_PARAM2 = "param2";
|
||||
private String otherphoto = "otherphoto.jpg";
|
||||
private ArrayList<String> deletePath = new ArrayList<String>();
|
||||
// TODO: Rename and change types of parameters
|
||||
private String mParam1;
|
||||
private String mParam2;
|
||||
private int userImgeREQUST=10000;
|
||||
private OnFragmentInteractionListener mListener;
|
||||
private boolean istakepic;
|
||||
private ArrayList<MyUserFEntity> myUserFEntities;
|
||||
private BaseRecycleViewAdapter baseRecycleViewAdapter;
|
||||
private ImageView userImageView;
|
||||
|
||||
public Main4Fragment() {
|
||||
// Required empty public constructor
|
||||
}
|
||||
@Override
|
||||
protected void onCreateVew(LayoutInflater inflater, Bundle savedInstanceState) {
|
||||
super.onCreateVew(inflater, savedInstanceState);
|
||||
mDataBinding.setting.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
Intent intent=new Intent(getActivity(),SettingActivity.class);
|
||||
startActivity(intent);
|
||||
}
|
||||
});
|
||||
//mDataBinding.myRecyView;
|
||||
mDataBinding.userImage.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
|
||||
}
|
||||
});
|
||||
initTopView();
|
||||
initMyReycyView();
|
||||
initData();
|
||||
// mDataBinding.usermale;
|
||||
|
||||
|
||||
/* toolbar.set*/
|
||||
/*baseActivity.setAbr(getString(R.string.news4), new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
|
||||
}
|
||||
}, R.mipmap.shezhi, new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
|
||||
}
|
||||
}, 0, null, R.mipmap.head);
|
||||
*/
|
||||
// int height= MyPhoneValue.getStatusBarHeight(getActivity());
|
||||
|
||||
|
||||
/* mDataBinding.myhistory.setOnClickListener(this);
|
||||
mDataBinding.mynew.setOnClickListener(this);
|
||||
mDataBinding.myqrrel.setOnClickListener(this);*/
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
* 初始化顶部view
|
||||
* */
|
||||
private void initTopView(){
|
||||
DisplayMetrics dm = getResources().getDisplayMetrics();
|
||||
View topView = mDataBinding.topView;
|
||||
LinearLayout.LayoutParams topViewLp = (LinearLayout.LayoutParams) topView.getLayoutParams();
|
||||
topViewLp.width = dm.widthPixels;
|
||||
topViewLp.height = topViewLp.width*152/375;
|
||||
topView.setLayoutParams(topViewLp);
|
||||
|
||||
View userView = mDataBinding.userLayout;
|
||||
RelativeLayout.LayoutParams userViewLp = (RelativeLayout.LayoutParams) userView.getLayoutParams();
|
||||
userViewLp.width = dm.widthPixels;
|
||||
userViewLp.height = topViewLp.height - SizeUtils.dp2px(28);
|
||||
|
||||
userView.setLayoutParams(userViewLp);
|
||||
|
||||
userImageView = mDataBinding.userImage;
|
||||
RelativeLayout.LayoutParams userImageLP = (RelativeLayout.LayoutParams) userImageView.getLayoutParams();
|
||||
int userImageHeight = (int) ( userViewLp.height*0.7);
|
||||
userImageLP.height = userImageHeight;
|
||||
userImageLP.width = userImageHeight;
|
||||
userImageView.setLayoutParams(userImageLP);
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void initMyReycyView() {
|
||||
myUserFEntities=getMyActivityList();
|
||||
|
||||
FullyGridLayoutManager mgr = new FullyGridLayoutManager(getActivity(),1);
|
||||
mgr.setOrientation(FullyGridLayoutManager.VERTICAL);
|
||||
mgr.setSmoothScrollbarEnabled(true);
|
||||
mDataBinding.myRecyView.setLayoutManager(mgr);
|
||||
|
||||
baseRecycleViewAdapter=new BaseRecycleViewAdapter(getActivity(),R.layout.user_fragment_item);
|
||||
|
||||
baseRecycleViewAdapter.setOnBindViewHolder(new BaseRecycleViewAdapter.BindView() {
|
||||
@Override
|
||||
public void onBindViewHolder(Object b, final int position) {
|
||||
if(!(position>=myUserFEntities.size())) {
|
||||
UserFragmentItemBinding homeGridAdapterItemBinding = (UserFragmentItemBinding) b;
|
||||
homeGridAdapterItemBinding.setMyentity(myUserFEntities.get(position));
|
||||
homeGridAdapterItemBinding.imageViewlogo.setImageResource(myUserFEntities.get(position).getImagetResource());homeGridAdapterItemBinding.userFragmentItem.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
Intent intent = new Intent(getActivity(), myUserFEntities.get(position).getMyclazz());
|
||||
intent.putExtra("usertitile", myUserFEntities.get(position).getTitile());
|
||||
startActivityForResult(intent,0);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
mDataBinding.myRecyView.setAdapter(baseRecycleViewAdapter);
|
||||
baseRecycleViewAdapter.setData(myUserFEntities);
|
||||
|
||||
}
|
||||
|
||||
public void refreshData(){
|
||||
initTopView();
|
||||
initMyReycyView();
|
||||
initData();
|
||||
}
|
||||
/*
|
||||
* 初始化数据
|
||||
* */
|
||||
private void initData(){
|
||||
RegisterUser user = Config.getInstance(getActivity()).getUser();
|
||||
mDataBinding.username.setText(user.getNickname());
|
||||
if(StringUtils.isEmpty(user.getAvatar())){
|
||||
Picasso.with(getActivity()).load(R.mipmap.head).error(R.mipmap.head).placeholder(R.mipmap.head).into(mDataBinding.userImage);
|
||||
}else {
|
||||
Picasso.with(getActivity()).load(user.getAvatar()).error(R.mipmap.head).placeholder(R.mipmap.head).into(mDataBinding.userImage);
|
||||
|
||||
}
|
||||
String gender = user.getGender();
|
||||
if(gender.equals("0")){
|
||||
Picasso.with(getActivity()).load(R.mipmap.icon_secret).into(mDataBinding.usermale);
|
||||
}else if(gender.equals("1")){
|
||||
Picasso.with(getActivity()).load(R.mipmap.boy).into(mDataBinding.usermale);
|
||||
}else if(gender.equals("2")){
|
||||
Picasso.with(getActivity()).load(R.mipmap.lady).into(mDataBinding.usermale);
|
||||
}else {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Use this factory method to create a new instance of
|
||||
* this fragment using the provided parameters.
|
||||
*
|
||||
* @param param1 Parameter 1.
|
||||
* @param param2 Parameter 2.
|
||||
* @return A new instance of fragment Main1Fragment.
|
||||
*/
|
||||
// TODO: Rename and change types and number of parameters
|
||||
public static Main4Fragment newInstance(String param1, String param2) {
|
||||
Main4Fragment fragment = new Main4Fragment();
|
||||
Bundle args = new Bundle();
|
||||
args.putString(ARG_PARAM1, param1);
|
||||
args.putString(ARG_PARAM2, param2);
|
||||
fragment.setArguments(args);
|
||||
return fragment;
|
||||
}
|
||||
|
||||
private boolean onclik=false;
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
onclik=false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
if (getArguments() != null) {
|
||||
mParam1 = getArguments().getString(ARG_PARAM1);
|
||||
mParam2 = getArguments().getString(ARG_PARAM2);
|
||||
}
|
||||
/* Toolbar toolbar = (Toolbar)getActivity(). findViewById(R.id.toolbar);
|
||||
BaseActivity baseActivity= (BaseActivity) getActivity();
|
||||
baseActivity.setSupportActionBar(toolbar);*/
|
||||
|
||||
/* toolbar.set*/
|
||||
/* baseActivity.setAbr(getString(R.string.news4), new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
|
||||
}
|
||||
}, R.mipmap.shezhi, new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
|
||||
}
|
||||
}, 0, null, R.mipmap.head);
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
/* @Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
// Inflate the layout for this fragment
|
||||
return inflater.inflate(R.layout.fragment_main1, container, false);
|
||||
}*/
|
||||
|
||||
// TODO: Rename method, update argument and hook method into UI event
|
||||
public void onButtonPressed(Uri uri) {
|
||||
if (mListener != null) {
|
||||
mListener.onFragmentInteraction(uri);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttach(Context context) {
|
||||
super.onAttach(context);
|
||||
if (context instanceof OnFragmentInteractionListener) {
|
||||
mListener = (OnFragmentInteractionListener) context;
|
||||
} else {
|
||||
throw new RuntimeException(context.toString()
|
||||
+ " must implement OnFragmentInteractionListener");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDetach() {
|
||||
super.onDetach();
|
||||
mListener = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.fragment_main4;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadData() {
|
||||
initData();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
|
||||
super.onResume();
|
||||
onclik=true;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public ArrayList<MyUserFEntity> getMyActivityList() {
|
||||
ArrayList<MyUserFEntity> myUserFEntities=new ArrayList<>();
|
||||
String myActivityListString[]=getActivity().getResources().getStringArray(R.array.useraction);
|
||||
int imageres[]={R.mipmap.genren,
|
||||
R.mipmap.qianbao,
|
||||
R.mipmap.shangcheng,
|
||||
R.mipmap.zhangdan,
|
||||
R.mipmap.fuwu,
|
||||
R.mipmap.fuwu,
|
||||
R.mipmap.baoxiu,
|
||||
R.mipmap.shouquan,
|
||||
R.mipmap.fangchan,
|
||||
R.mipmap.yaoshi};
|
||||
Class tClass[]={MyUserMessage.class,
|
||||
MyWalletActivity.class,
|
||||
MyMarketShopActivity.class,
|
||||
MyBillHistory.class,
|
||||
MyServiceHistory.class,
|
||||
UserdlistActivity.class,
|
||||
MyGuaranteeHistory.class,
|
||||
MyAuthorizedFamilyHistory.class,
|
||||
MyPropertyActivity.class,
|
||||
MyKeyManagement.class};
|
||||
for (int i = 0; i <9 ; i++) {
|
||||
MyUserFEntity myUserFEntity=new MyUserFEntity();
|
||||
myUserFEntity.setImagetResource(imageres[i]);
|
||||
myUserFEntity.setMyclazz(tClass[i]);
|
||||
myUserFEntity.setTitile(myActivityListString[i]);
|
||||
myUserFEntities.add(myUserFEntity);
|
||||
|
||||
}
|
||||
|
||||
return myUserFEntities;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This interface must be implemented by activities that contain this
|
||||
* fragment to allow an interaction in this fragment to be communicated
|
||||
* to the activity and potentially other fragments contained in that
|
||||
* activity.
|
||||
* <p>
|
||||
* See the Android Training lesson <a href=
|
||||
* "http://developer.android.com/training/basics/fragments/communicating.html"
|
||||
* >Communicating with Other Fragments</a> for more information.
|
||||
*/
|
||||
public interface OnFragmentInteractionListener {
|
||||
// TODO: Update argument type and name
|
||||
void onFragmentInteraction(Uri uri);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
if(deletePath.size()>0){
|
||||
for (int i = 0; i <deletePath.size(); i++) {
|
||||
BitmapTools.deleteFile(new File(deletePath.get(i)));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user