package com.wasu.cs.widget;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;
import cn.com.wasu.main.R;
/**
 * 资产页用户登录说明文字(分三种情况)
 * 1.没登录显示"VIP免费看"
 * 2.登录了没有订包显示 用户名字+"您好！"
 * 3.登录了并订包了显示 用户名字+"您好！"  和  所订包的到期时间
 * created by danxingxi on 2016/3/8
 *
 */
public class ChannelUserCenterTextView extends LinearLayout{
	
	private Context context;
	private TextView tvName ,tvTime ,tvDefaultOrName;
	
	public ChannelUserCenterTextView(Context context, AttributeSet attrs, int defStyle) {
		super(context, attrs, defStyle);
		init(context);
	}

	public ChannelUserCenterTextView(Context context, AttributeSet attrs) {
		super(context, attrs);
		init(context);
	}

	public ChannelUserCenterTextView(Context context) {
		super(context);
		init(context);
	}

	private void init(Context mContext){
		this.context = mContext;
		LayoutInflater.from(context).inflate(R.layout.channel_user_center_textview, this);
		tvDefaultOrName = (TextView) findViewById(R.id.tvDefaultOrName);
		tvName = (TextView) findViewById(R.id.tvName);
		tvTime = (TextView) findViewById(R.id.tvTime);
	}
	/**
	 * 显示"VIP免费看"
	 */
	public void showDefault(){
		hideNameAndTime();
		tvDefaultOrName.setText(getResources().getString(R.string.VIP_see_free));
		tvDefaultOrName.setVisibility(View.VISIBLE);
	}
	/**
	 * 用户登录没订包
	 * 显示 name 您好！
	 * @param name
	 */
	public void showName(String name){
		hideNameAndTime();
		tvDefaultOrName.setText(name+",您好！");
		tvDefaultOrName.setVisibility(View.VISIBLE);
	}
	/**
	 * 用户登录并订过包
	 * 显示
	 * @param name
	 * @param time
	 */
	public void showNameAndTime(String name ,String time){
		tvDefaultOrName.setVisibility(View.GONE);
		tvName.setText(name+",您好！");
		tvTime.setText("VIP到期时间:"+time);
		tvName.setVisibility(View.VISIBLE);
		tvTime.setVisibility(View.VISIBLE);
	}
	
	private void hideNameAndTime(){
		tvName.setVisibility(View.GONE);
		tvTime.setVisibility(View.GONE);
	}
}
