|
|
@@ -1,5 +1,6 @@
|
|
|
package com.sk.weichat.ui.cardcast;
|
|
|
|
|
|
+import android.annotation.SuppressLint;
|
|
|
import android.app.Activity;
|
|
|
import android.content.BroadcastReceiver;
|
|
|
import android.content.ComponentName;
|
|
|
@@ -9,9 +10,12 @@ 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.view.View;
|
|
|
+import android.widget.RadioButton;
|
|
|
|
|
|
import com.sk.weichat.R;
|
|
|
import com.sk.weichat.bean.message.NewFriendMessage;
|
|
|
@@ -22,8 +26,6 @@ import com.sk.weichat.xmpp.CoreService.CoreServiceBinder;
|
|
|
|
|
|
/**
|
|
|
* 我的名片盒
|
|
|
- *
|
|
|
- *
|
|
|
*/
|
|
|
@SuppressWarnings("deprecation")
|
|
|
public class CardcastActivity extends BaseActivity {
|
|
|
@@ -34,38 +36,91 @@ public class CardcastActivity extends BaseActivity {
|
|
|
|
|
|
private boolean mBind;
|
|
|
private CoreService mXmppService;
|
|
|
+ private RadioButton btnG;
|
|
|
+ private RadioButton btnAG;
|
|
|
+ private FriendFragment friendFragment;
|
|
|
+ private AttentionFragment attentionFragment;
|
|
|
+ private RoomFragment roomFragment;
|
|
|
+ private FragmentTransaction bt;
|
|
|
|
|
|
@Override
|
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
|
super.onCreate(savedInstanceState);
|
|
|
// setup action bar for tabs
|
|
|
- ActionBar actionBar = getSupportActionBar();
|
|
|
-
|
|
|
- actionBar.setTitle(R.string.my_friend);
|
|
|
-
|
|
|
- actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
|
|
|
-
|
|
|
- mFriend = new TabListener<FriendFragment>(this, "friend", FriendFragment.class);
|
|
|
- mAttention = new TabListener<AttentionFragment>(this, "attention", AttentionFragment.class);
|
|
|
- mRoom = new TabListener<RoomFragment>(this, "room", RoomFragment.class);
|
|
|
- int index = 0;
|
|
|
- if (savedInstanceState != null) {
|
|
|
- mFriend.setFragment(getSupportFragmentManager().findFragmentByTag("friend"));
|
|
|
- mAttention.setFragment(getSupportFragmentManager().findFragmentByTag("attention"));
|
|
|
- mRoom.setFragment(getSupportFragmentManager().findFragmentByTag("room"));
|
|
|
- index = savedInstanceState.getInt("index", 0);
|
|
|
- }
|
|
|
- Tab tab = actionBar.newTab().setText(R.string.focus_on_each_other).setTabListener(mFriend);
|
|
|
- actionBar.addTab(tab);
|
|
|
-
|
|
|
- tab = actionBar.newTab().setText(R.string.unilateral_attention).setTabListener(mAttention);
|
|
|
- actionBar.addTab(tab);
|
|
|
- tab = actionBar.newTab().setText(R.string.focus_room).setTabListener(mRoom);
|
|
|
- actionBar.addTab(tab);
|
|
|
- actionBar.setSelectedNavigationItem(index);
|
|
|
+ setContentView(R.layout.activity_cardast);
|
|
|
+// ActionBar actionBar = getSupportActionBar();
|
|
|
+
|
|
|
+// actionBar.setTitle(R.string.my_friend);
|
|
|
+// actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
|
|
|
+
|
|
|
+// mFriend = new TabListener<FriendFragment>(this, "friend", FriendFragment.class);
|
|
|
+// mAttention = new TabListener<AttentionFragment>(this, "attention", AttentionFragment.class);
|
|
|
+// mRoom = new TabListener<RoomFragment>(this, "room", RoomFragment.class);
|
|
|
+// int index = 0;
|
|
|
+// if (savedInstanceState != null) {
|
|
|
+// mFriend.setFragment(getSupportFragmentManager().findFragmentByTag("friend"));
|
|
|
+// mAttention.setFragment(getSupportFragmentManager().findFragmentByTag("attention"));
|
|
|
+// mRoom.setFragment(getSupportFragmentManager().findFragmentByTag("room"));
|
|
|
+// index = savedInstanceState.getInt("index", 0);
|
|
|
+// }
|
|
|
+ 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();
|
|
|
+ bt.add(R.id.fl, friendFragment);
|
|
|
+ bt.add(R.id.fl, attentionFragment);
|
|
|
+ bt.hide(roomFragment);
|
|
|
+ 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.show(friendFragment);
|
|
|
+ bt.hide(attentionFragment);
|
|
|
+ bt.commit();
|
|
|
|
|
|
- registerReceiver(mUpdateReceiver, CardcastUiUpdateUtil.getUpdateActionFilter());
|
|
|
- mBind = bindService(CoreService.getIntent(), mServiceConnection, BIND_AUTO_CREATE);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ 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.show(attentionFragment);
|
|
|
+ bt.hide(friendFragment);
|
|
|
+ bt.commit();
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+// Tab tab = actionBar.newTab().setText(R.string.focus_on_each_other).setTabListener(mFriend);
|
|
|
+// actionBar.addTab(tab);
|
|
|
+//
|
|
|
+// tab = actionBar.newTab().setText(R.string.unilateral_attention).setTabListener(mAttention);
|
|
|
+// actionBar.addTab(tab);
|
|
|
+// tab = actionBar.newTab().setText(R.string.focus_room).setTabListener(mRoom);
|
|
|
+// actionBar.addTab(tab);
|
|
|
+// actionBar.setSelectedNavigationItem(index);
|
|
|
+
|
|
|
+// registerReceiver(mUpdateReceiver, CardcastUiUpdateUtil.getUpdateActionFilter());
|
|
|
+// mBind = bindService(CoreService.getIntent(), mServiceConnection, BIND_AUTO_CREATE);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -95,8 +150,9 @@ public class CardcastActivity extends BaseActivity {
|
|
|
@Override
|
|
|
protected void onDestroy() {
|
|
|
super.onDestroy();
|
|
|
- unregisterReceiver(mUpdateReceiver);
|
|
|
+
|
|
|
if (mBind) {
|
|
|
+ unregisterReceiver(mUpdateReceiver);
|
|
|
unbindService(mServiceConnection);
|
|
|
}
|
|
|
}
|