package com.partynetwork.dataprovider.util; import com.partynetwork.dataprovider.DataProvider.IJsonResultListener; import com.partynetwork.dataprovider.json.struct.Login_loginRequest; import com.partynetwork.iparty.R; import com.partynetwork.iparty.app.AppContext; import android.app.Activity; import android.content.Context; import android.graphics.drawable.Drawable; import android.widget.TextView; public class IPartyUtil { private static IPartyUtil iPartyUtil = new IPartyUtil(); public static IPartyUtil getInstance() { if (iPartyUtil == null) { iPartyUtil = new IPartyUtil(); return iPartyUtil; } return iPartyUtil; } /** * 给TextView的右边添加性别图标 */ public void addSexImg(Context context, TextView textView, int sex) { Drawable right = null; String sexStr; int src = R.drawable.sex_boy_middle_pressed; if (sex == ActionUtil.user.MALE) { sexStr = "男"; src = R.drawable.sex_boy_middle_pressed; } else if (sex == ActionUtil.user.FEMALE) { sexStr = "女"; src = R.drawable.sex_girl_middle_pressed; } else { sexStr = "其他"; src = R.drawable.sex_neutral_middle_pressed; } right = context.getResources().getDrawable(src); right.setBounds(0, 0, right.getMinimumWidth(), right.getMinimumHeight()); textView.setCompoundDrawables(null, null, right, null); textView.setText(sexStr); } public void login(int type, String name, String password, IJsonResultListener listener) { // 开始登陆 SharePreferenceUtil util = new SharePreferenceUtil( AppContext.getInstance(), AppConst.PREFERENCES_NAME); Login_loginRequest loginRequest = new Login_loginRequest(); loginRequest.setLoginType(type); loginRequest.setPassword(password); loginRequest.setLoginContent(name); loginRequest.setBaiduUserId(util.getPushUserId()); loginRequest.setBaiduChannel(util.getChannelId()); loginRequest.setOsType(3); AppContext.getInstance().getmDataProvider() .getJsonFromNetwork(loginRequest, listener); } }