package com.hjx.personalcenter.activity; import android.content.Context; import android.content.Intent; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.TextView; import com.hjx.personalcenter.R; import com.hjx.personalcenter.customdialog.HeadDialog; import com.hjx.personalcenter.interfaces.DialogCallBack; import com.hjx.personalcenter.util.AlertUtils; import com.mylhyl.circledialog.CircleDialog; import com.mylhyl.circledialog.callback.ConfigInput; import com.mylhyl.circledialog.params.InputParams; import com.mylhyl.circledialog.view.listener.OnInputClickListener; import com.zaaach.toprightmenu.MenuItem; import com.zaaach.toprightmenu.TopRightMenu; import java.util.ArrayList; import java.util.List; public class MainActivity extends AppCompatActivity implements View.OnClickListener, DialogCallBack.CallBackView { private ImageView iv_imformatioan, iv_look_card, iv_setting, iv_sign, iv_head, iv_sex; private TextView tv_edit_presoninfo, tv_sign, oktakephone, cancetakephone, tv_username, tv_username1, tv_mygad, tv_sex, tv_useinfo_adress, tv_useinfo_birthday, tv_useinfo_qq, tv_useinfo_school, tv_useinfo_gender; private LinearLayout linel_mycuoti, linel_mynote, linel_mycollege, linel_myclass; private TopRightMenu mTopRightMenu; private boolean showIcon = true; private boolean dimBg = true; private boolean needAnim = true; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); initView(); initData(); initLister(); } private void initView() { iv_imformatioan = (ImageView) findViewById(R.id.iv_imformatioan); iv_look_card = (ImageView) findViewById(R.id.iv_look_card); tv_edit_presoninfo = (TextView) findViewById(R.id.tv_edit_presoninfo); iv_setting = (ImageView) findViewById(R.id.iv_setting); iv_sign = (ImageView) findViewById(R.id.iv_sign); tv_sign = (TextView) findViewById(R.id.tv_sign); //头像 iv_head = (ImageView) findViewById(R.id.iv_head); //初始化个人信息 iv_sex = (ImageView) findViewById(R.id.iv_sex); tv_username = (TextView) findViewById(R.id.tv_username); tv_username1 = (TextView) findViewById(R.id.tv_username1); tv_mygad = (TextView) findViewById(R.id.tv_mygad); tv_sex = (TextView) findViewById(R.id.tv_sex); tv_useinfo_adress = (TextView) findViewById(R.id.tv_useinfo_adress); tv_useinfo_birthday = (TextView) findViewById(R.id.tv_useinfo_birthday); tv_useinfo_qq = (TextView) findViewById(R.id.tv_useinfo_qq); tv_useinfo_school = (TextView) findViewById(R.id.tv_useinfo_school); tv_useinfo_gender = (TextView) findViewById(R.id.tv_useinfo_gender); //跳转其他应用 linel_mycuoti = (LinearLayout) findViewById(R.id.linel_mycuoti); linel_mynote = (LinearLayout) findViewById(R.id.linel_mynote); linel_mycollege = (LinearLayout) findViewById(R.id.linel_mycollege); linel_myclass = (LinearLayout) findViewById(R.id.linel_myclass); } private void initData() { //加载个人信息 } private void initLister() { iv_imformatioan.setOnClickListener(this); iv_look_card.setOnClickListener(this); tv_edit_presoninfo.setOnClickListener(this); iv_setting.setOnClickListener(this); iv_sign.setOnClickListener(this); iv_head.setOnClickListener(this); linel_mycuoti.setOnClickListener(this); linel_mynote.setOnClickListener(this); linel_mycollege.setOnClickListener(this); linel_myclass.setOnClickListener(this); } @Override public void onClick(View v) { switch (v.getId()) { case R.id.iv_imformatioan: Intent intent = new Intent(); intent.setClass(MainActivity.this, FeedBackActivity.class); startActivity(intent); overridePendingTransition(R.anim.rightin, R.anim.rightout); break; case R.id.iv_look_card: Intent lookintent = new Intent(); lookintent.setClass(MainActivity.this, ElectronicCardLookInfoActivity.class); startActivity(lookintent); overridePendingTransition(R.anim.rightin, R.anim.rightout); break; case R.id.tv_edit_presoninfo: Intent editintent = new Intent(); editintent.setClass(MainActivity.this, ChangePresonalInfoActivity.class); startActivity(editintent); overridePendingTransition(R.anim.rightin, R.anim.rightout); break; case R.id.iv_head: HeadDialog.getInstance(this).show(getSupportFragmentManager(), "HeadDialog"); break; case R.id.iv_setting: mTopRightMenu = new TopRightMenu(MainActivity.this); List menuItems = new ArrayList<>(); menuItems.add(new MenuItem(R.mipmap.blank, "切换账户")); menuItems.add(new MenuItem(R.mipmap.blank, "账户管理")); mTopRightMenu .setHeight(150) //默认高度480 .setWidth(320) //默认宽度wrap_content .showIcon(showIcon) //显示菜单图标,默认为true .dimBackground(dimBg) //背景变暗,默认为true .needAnimationStyle(needAnim) //显示动画,默认为true .setAnimationStyle(R.style.TRM_ANIM_STYLE) //默认为R.style.TRM_ANIM_STYLE .setOnMenuItemClickListener(new TopRightMenu.OnMenuItemClickListener() { @Override public void onMenuItemClick(int position) { switch (position) { case 0: //清除数据 Intent settingintent = new Intent(); settingintent.setClass(MainActivity.this, LoginAndRegisterActivity.class); startActivity(settingintent); overridePendingTransition(R.anim.rightin, R.anim.rightout); break; case 1: Intent accontMintent = new Intent(); accontMintent.setClass(MainActivity.this, AccountManagementActivity.class); startActivity(accontMintent); overridePendingTransition(R.anim.rightin, R.anim.rightout); break; } } }) .addMenuList(menuItems) .showAsDropDown(iv_setting, -250, 0); break; case R.id.iv_sign: new CircleDialog.Builder(this) .setCanceledOnTouchOutside(false) .setCancelable(true) .setTitle("个性签名") .setInputHint("请输入个性签名") .setWidth(0.5f) .configInput(new ConfigInput() { @Override public void onConfig(InputParams params) { // params.inputBackgroundResourceId = R.drawable.bg_input; } }) .setNegative("取消", null) .setPositiveInput("确定", new OnInputClickListener() { @Override public void onClick(String text, View v) { if (text.equals("")) { AlertUtils.showToast(MainActivity.this, "请输入个性签名"); } else { tv_sign.setText(text); } } }) .show(); break; case R.id.linel_mycuoti: AlertUtils.showToast(this, "hhahahah "); break; case R.id.linel_mynote: AlertUtils.showToast(this, "hhahahah "); break; case R.id.linel_mycollege: AlertUtils.showToast(this, "hhahahah "); break; case R.id.linel_myclass: AlertUtils.showToast(this, "hhahahah "); break; case R.id.oktakephone: AlertUtils.showToast(this, "hhahahah "); break; case R.id.canceltakephone: AlertUtils.showToast(this, "hhahahah "); break; } } @Override public void provinceOnItemClick(Context context, LayoutInflater inflater, ViewGroup container) { View mView = inflater.inflate(R.layout.custom_adilog_lhead, container, false); oktakephone = (TextView) mView.findViewById(R.id.oktakephone); cancetakephone = (TextView) mView.findViewById(R.id.canceltakephone); oktakephone.setOnClickListener(this); cancetakephone.setOnClickListener(this); } }