package com.lianxin.pubqq.chat;

import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.util.DisplayMetrics;

import com.lianxin.pubqq.R;

/*有两个聊天窗口，功能完全一样，都正常，都在调用（更新时注意同步）
 * EMChatFragment(EMChatActivity)
 * IMChatActivity
 */
//聊天页面1
public class EMChatActivity extends FragmentActivity {
	
	public static final int RESULT_CODE_COPY = 1;
	public static final int RESULT_CODE_DELETE = 2;
	public static final int RESULT_CODE_CANCEL = 8;	
	public static final int RESULT_CODE_FORWARD = 3;
	public static final int RESULT_CODE_OPEN = 4;
	public static final int RESULT_CODE_DWONLOAD = 5;
	public static final int RESULT_CODE_TO_CLOUD = 6;
	public static final int RESULT_CODE_EXIT_GROUP = 7;
	public static final int RESULT_CODE_MARK = 9;
	
	public static int screenWidth = 480;
	public static int screenHeight = 640;	
	public static int resendPos;
	//public int playMsgId;
	
    public static EMChatActivity activityInstance;
    private EMChatFragment chatFragment;
    public   String toChatUsername;

    @Override
    protected void onCreate(Bundle arg0) {
        super.onCreate(arg0);
        setContentView(R.layout.em_activity_chat);
        activityInstance = this;
 
        chatFragment = new EMChatFragment();
        chatFragment.setArguments(getIntent().getExtras());
        getSupportFragmentManager().beginTransaction().add(R.id.container, chatFragment).commit();
		//获取屏幕分辨率		
		DisplayMetrics dm = getResources().getDisplayMetrics();
		screenWidth = dm.widthPixels;
		screenHeight = dm.heightPixels;   
    }
    
    @Override
    protected void onDestroy() {
        super.onDestroy();
        activityInstance = null;
    }
    
    @Override
    protected void onNewIntent(Intent intent) {

        String username = intent.getStringExtra("userId");
        if (toChatUsername.equals(username))
            super.onNewIntent(intent);
        else {
            finish();
            startActivity(intent);
        }

    }
    
    @Override
    public void onBackPressed() {
        chatFragment.onBackPressed();
 
    }
    
    public String getToChatUsername(){
        return toChatUsername;
    }

}
