Search in sources :

Example 1 with AccountFG

use of com.gapcoder.weico.Index.FG.AccountFG in project weibo by dingdangmao123.

the class index method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_index);
    ButterKnife.bind(this);
    ActivityList.add(this);
    tab.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() {

        @Override
        public boolean onNavigationItemSelected(@NonNull MenuItem item) {
            if (item.getItemId() == R.id.weico)
                bar.hide(false);
            FragmentTransaction tran = fm.beginTransaction();
            hideFragments(tran);
            int id = item.getItemId();
            if (!flag.contains(id)) {
                tran.add(R.id.container, map.get(id));
                flag.add(id);
            }
            tran.show(map.get(id));
            tran.commit();
            return true;
        }
    });
    bar = new QBadgeView(this);
    bar.bindTarget(tab).setBadgeGravity(Gravity.CENTER | Gravity.START);
    bar.setGravityOffset(40, 0, true);
    FragmentTransaction tran = fm.beginTransaction();
    hideFragments(tran);
    Fragment fg = new WeicoFG();
    map.put(R.id.weico, fg);
    map.put(R.id.title, new TitleFG());
    map.put(R.id.account, new AccountFG());
    tran.add(R.id.container, fg);
    flag.add(R.id.weico);
    tran.commit();
    receiver = new MessageReceiver();
    filter = new IntentFilter();
    filter.addAction("com.gapcoder.weico.MESSAGE");
    registerReceiver(receiver, filter);
    Intent service = new Intent(this, MessageService.class);
    startService(service);
}
Also used : IntentFilter(android.content.IntentFilter) WeicoFG(com.gapcoder.weico.Index.FG.WeicoFG) AccountFG(com.gapcoder.weico.Index.FG.AccountFG) MenuItem(android.view.MenuItem) QBadgeView(q.rorbin.badgeview.QBadgeView) Intent(android.content.Intent) Fragment(android.support.v4.app.Fragment) FragmentTransaction(android.support.v4.app.FragmentTransaction) TitleFG(com.gapcoder.weico.Index.FG.TitleFG) BottomNavigationView(android.support.design.widget.BottomNavigationView)

Aggregations

Intent (android.content.Intent)1 IntentFilter (android.content.IntentFilter)1 BottomNavigationView (android.support.design.widget.BottomNavigationView)1 Fragment (android.support.v4.app.Fragment)1 FragmentTransaction (android.support.v4.app.FragmentTransaction)1 MenuItem (android.view.MenuItem)1 AccountFG (com.gapcoder.weico.Index.FG.AccountFG)1 TitleFG (com.gapcoder.weico.Index.FG.TitleFG)1 WeicoFG (com.gapcoder.weico.Index.FG.WeicoFG)1 QBadgeView (q.rorbin.badgeview.QBadgeView)1