|
|
@@ -1,25 +1,20 @@
|
|
|
package com.sk.weichat.ui.cardcast;
|
|
|
|
|
|
-import android.annotation.SuppressLint;
|
|
|
import android.app.Activity;
|
|
|
-import android.content.BroadcastReceiver;
|
|
|
import android.content.ComponentName;
|
|
|
-import android.content.Context;
|
|
|
-import android.content.Intent;
|
|
|
import android.content.ServiceConnection;
|
|
|
import android.os.Bundle;
|
|
|
import android.os.IBinder;
|
|
|
import android.support.v4.app.Fragment;
|
|
|
-import android.support.v4.app.FragmentManager;
|
|
|
import android.support.v4.app.FragmentTransaction;
|
|
|
import android.support.v7.app.ActionBar;
|
|
|
import android.support.v7.app.ActionBar.Tab;
|
|
|
+import android.util.Log;
|
|
|
import android.view.View;
|
|
|
import android.widget.RadioButton;
|
|
|
|
|
|
import com.sk.weichat.R;
|
|
|
import com.sk.weichat.bean.message.NewFriendMessage;
|
|
|
-import com.sk.weichat.broadcast.CardcastUiUpdateUtil;
|
|
|
import com.sk.weichat.ui.base.BaseActivity;
|
|
|
import com.sk.weichat.xmpp.CoreService;
|
|
|
import com.sk.weichat.xmpp.CoreService.CoreServiceBinder;
|
|
|
@@ -28,7 +23,7 @@ import com.sk.weichat.xmpp.CoreService.CoreServiceBinder;
|
|
|
* 我的名片盒
|
|
|
*/
|
|
|
@SuppressWarnings("deprecation")
|
|
|
-public class CardcastActivity extends BaseActivity {
|
|
|
+public class CardcastActivity extends BaseActivity implements View.OnClickListener {
|
|
|
|
|
|
private TabListener<FriendFragment> mFriend;
|
|
|
private TabListener<AttentionFragment> mAttention;
|
|
|
@@ -41,7 +36,6 @@ public class CardcastActivity extends BaseActivity {
|
|
|
private FriendFragment friendFragment;
|
|
|
private AttentionFragment attentionFragment;
|
|
|
private RoomFragment roomFragment;
|
|
|
- private FragmentTransaction bt;
|
|
|
|
|
|
@Override
|
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
|
@@ -66,49 +60,53 @@ public class CardcastActivity extends BaseActivity {
|
|
|
roomFragment = new RoomFragment();
|
|
|
friendFragment = new FriendFragment();
|
|
|
attentionFragment = new AttentionFragment();
|
|
|
- btnG = (RadioButton) findViewById(R.id.btn_guanzu);
|
|
|
- btnAG = (RadioButton) findViewById(R.id.btn_aguanzu);
|
|
|
- FragmentManager fm = getSupportFragmentManager();
|
|
|
- bt = fm.beginTransaction();
|
|
|
+ findViewById(R.id.btn_mutual).setOnClickListener(this);
|
|
|
+ findViewById(R.id.tv_back).setOnClickListener(this);
|
|
|
+ findViewById(R.id.btn_Unilateral).setOnClickListener(this);
|
|
|
+
|
|
|
+ FragmentTransaction bt = getSupportFragmentManager().beginTransaction();
|
|
|
bt.add(R.id.fl, friendFragment);
|
|
|
bt.add(R.id.fl, attentionFragment);
|
|
|
- bt.hide(roomFragment);
|
|
|
+ bt.hide(friendFragment);
|
|
|
bt.commit();
|
|
|
- findViewById(R.id.tv_back).setOnClickListener(new View.OnClickListener() {
|
|
|
- @Override
|
|
|
- public void onClick(View view) {
|
|
|
- CardcastActivity.this.finish();
|
|
|
- }
|
|
|
- });
|
|
|
- btnG.setOnClickListener(new View.OnClickListener() {
|
|
|
- @SuppressLint("NewApi")
|
|
|
- @Override
|
|
|
- public void onClick(View view) {
|
|
|
- btnG.setClickable(false);
|
|
|
- btnG.setBackground(getResources().getDrawable(R.drawable.aguanzu_pass));
|
|
|
- btnAG.setBackground(getResources().getDrawable(R.drawable.guanzu));
|
|
|
- btnAG.setClickable(true);
|
|
|
- bt = getSupportFragmentManager().beginTransaction();
|
|
|
- bt.hide(friendFragment);
|
|
|
- bt.show(attentionFragment);
|
|
|
- bt.commit();
|
|
|
|
|
|
- }
|
|
|
- });
|
|
|
- btnAG.setOnClickListener(new View.OnClickListener() {
|
|
|
- @SuppressLint("NewApi")
|
|
|
- @Override
|
|
|
- public void onClick(View view) {
|
|
|
- btnAG.setClickable(false);
|
|
|
- btnG.setClickable(true);
|
|
|
- btnG.setBackground(getResources().getDrawable(R.drawable.aguanzu));
|
|
|
- btnAG.setBackground(getResources().getDrawable(R.drawable.guanzu_pass));
|
|
|
- bt = getSupportFragmentManager().beginTransaction();
|
|
|
- bt.hide(attentionFragment);
|
|
|
- bt.show(friendFragment);
|
|
|
- bt.commit();
|
|
|
- }
|
|
|
- });
|
|
|
+
|
|
|
+// new View.OnClickListener() {
|
|
|
+// @Override
|
|
|
+// public void onClick(View view) {
|
|
|
+// CardcastActivity.this.finish();
|
|
|
+// }
|
|
|
+// });
|
|
|
+
|
|
|
+// new View.OnClickListener() {
|
|
|
+// @SuppressLint("NewApi")
|
|
|
+// @Override
|
|
|
+// public void onClick(View view) {
|
|
|
+// btnG.setClickable(false);
|
|
|
+// btnAG.setClickable(true);
|
|
|
+// Log.i("gongpengming", "btn_aguanzu and show the pager attentionFragment");
|
|
|
+// bt = getSupportFragmentManager().beginTransaction();
|
|
|
+//
|
|
|
+// bt.hide(friendFragment);
|
|
|
+// bt.show(attentionFragment);
|
|
|
+// bt.commit();
|
|
|
+//
|
|
|
+// }
|
|
|
+// });
|
|
|
+
|
|
|
+// new View.OnClickListener() {
|
|
|
+// @SuppressLint("NewApi")
|
|
|
+// @Override
|
|
|
+// public void onClick(View view) {
|
|
|
+// btnAG.setClickable(false);
|
|
|
+// btnG.setClickable(true);
|
|
|
+// Log.i("gongpengming", "btn_guanzu and show the pager friendFragment");
|
|
|
+// bt = getSupportFragmentManager().beginTransaction();
|
|
|
+// bt.hide(attentionFragment);
|
|
|
+// bt.show(friendFragment);
|
|
|
+// bt.commit();
|
|
|
+// }
|
|
|
+// });
|
|
|
|
|
|
// Tab tab = actionBar.newTab().setText(R.string.focus_on_each_other).setTabListener(mFriend);
|
|
|
// actionBar.addTab(tab);
|
|
|
@@ -147,15 +145,15 @@ public class CardcastActivity extends BaseActivity {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
- protected void onDestroy() {
|
|
|
- super.onDestroy();
|
|
|
-
|
|
|
- if (mBind) {
|
|
|
- unregisterReceiver(mUpdateReceiver);
|
|
|
- unbindService(mServiceConnection);
|
|
|
- }
|
|
|
- }
|
|
|
+// @Override
|
|
|
+// protected void onDestroy() {
|
|
|
+// super.onDestroy();
|
|
|
+//
|
|
|
+// if (mBind) {
|
|
|
+// unregisterReceiver(mUpdateReceiver);
|
|
|
+// unbindService(mServiceConnection);
|
|
|
+// }
|
|
|
+// }
|
|
|
|
|
|
void sendNewFriendMessage(String toUserId, NewFriendMessage message) {
|
|
|
if (mBind && mXmppService != null) {
|
|
|
@@ -163,22 +161,52 @@ public class CardcastActivity extends BaseActivity {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private BroadcastReceiver mUpdateReceiver = new BroadcastReceiver() {
|
|
|
- @Override
|
|
|
- public void onReceive(Context context, Intent intent) {
|
|
|
- if (intent.getAction().equals(CardcastUiUpdateUtil.ACTION_UPDATE_UI)) {
|
|
|
- if (mAttention.getFragment() != null) {
|
|
|
- mAttention.getFragment().update();
|
|
|
- }
|
|
|
- if (mFriend.getFragment() != null) {
|
|
|
- mFriend.getFragment().update();
|
|
|
- }
|
|
|
- if (mRoom.getFragment() != null) {
|
|
|
- mRoom.getFragment().update();
|
|
|
- }
|
|
|
- }
|
|
|
+// private BroadcastReceiver mUpdateReceiver = new BroadcastReceiver() {
|
|
|
+// @Override
|
|
|
+// public void onReceive(Context context, Intent intent) {
|
|
|
+// if (intent.getAction().equals(CardcastUiUpdateUtil.ACTION_UPDATE_UI)) {
|
|
|
+// if (mAttention.getFragment() != null) {
|
|
|
+// mAttention.getFragment().update();
|
|
|
+// }
|
|
|
+// if (mFriend.getFragment() != null) {
|
|
|
+// mFriend.getFragment().update();
|
|
|
+// }
|
|
|
+// if (mRoom.getFragment() != null) {
|
|
|
+// mRoom.getFragment().update();
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+// };
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onClick(View view) {
|
|
|
+ FragmentTransaction bt = getSupportFragmentManager().beginTransaction();
|
|
|
+ switch (view.getId()) {
|
|
|
+ case R.id.tv_back:
|
|
|
+ finish();
|
|
|
+ break;
|
|
|
+ case R.id.btn_mutual://相互
|
|
|
+ Log.i("gongpengming", "btn_mutual and show the pager attentionFragment");
|
|
|
+// btnG.setClickable(false);
|
|
|
+// btnAG.setClickable(true);
|
|
|
+
|
|
|
+ bt.hide(friendFragment);
|
|
|
+ bt.show(attentionFragment);
|
|
|
+ break;
|
|
|
+ case R.id.btn_Unilateral://单方
|
|
|
+ Log.i("gongpengming", "btn_guanzu and show the pager friendFragment");
|
|
|
+
|
|
|
+// btnAG.setClickable(false);
|
|
|
+// btnG.setClickable(true);
|
|
|
+
|
|
|
+ bt.hide(attentionFragment);
|
|
|
+ bt.show(friendFragment);
|
|
|
+
|
|
|
+ break;
|
|
|
}
|
|
|
- };
|
|
|
+ bt.commit();
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
public static class TabListener<T extends Fragment> implements ActionBar.TabListener {
|
|
|
private Fragment mFragment;
|