Search in sources :

Example 1 with QBadgeView

use of q.rorbin.badgeview.QBadgeView in project weibo by dingdangmao123.

the class WeicoFG method CreateView.

@Override
public void CreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState, View v) {
    target.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            msg.hide(false);
            Intent i = new Intent(getActivity(), Message.class);
            startActivity(i);
        }
    });
    title.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            final EasyPopup mCirclePop;
            mCirclePop = new EasyPopup(getActivity()).setContentView(R.layout.popmenu).setFocusAndOutsideEnable(true).createPopup();
            TextView t1 = mCirclePop.getView(R.id.t1);
            TextView t2 = mCirclePop.getView(R.id.t2);
            TextView t3 = mCirclePop.getView(R.id.t3);
            t1.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    mCirclePop.dismiss();
                    type = "new";
                    if (current != 1) {
                        reset = true;
                        current = 1;
                    } else {
                        reset = false;
                    }
                    title.setText("最新微博");
                    Refresh(1);
                }
            });
            t2.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    mCirclePop.dismiss();
                    type = "hot";
                    if (current != 2) {
                        reset = true;
                        current = 2;
                    } else {
                        reset = false;
                    }
                    title.setText("热门微博");
                    Refresh(1);
                }
            });
            t3.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    mCirclePop.dismiss();
                    type = "care";
                    if (current != 3) {
                        reset = true;
                        current = 3;
                    } else {
                        reset = false;
                    }
                    title.setText("我关注的");
                    Refresh(1);
                }
            });
            mCirclePop.showAtAnchorView(v, VerticalGravity.BELOW, HorizontalGravity.ALIGN_LEFT, 0, 0);
        }
    });
    adapter = new WeicoAdapter(data, getActivity());
    tl.setLayoutManager(new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, false));
    tl.setAdapter(adapter);
    rf.setOnRefreshListener(new OnRefreshListener() {

        @Override
        public void onRefresh(RefreshLayout refreshlayout) {
            Refresh(1);
        }
    });
    rf.setOnLoadmoreListener(new OnLoadmoreListener() {

        @Override
        public void onLoadmore(RefreshLayout refreshlayout) {
            Refresh(0);
        }
    });
    msg = new QBadgeView(getActivity());
    msg.bindTarget(target).setBadgeGravity(Gravity.END | Gravity.TOP);
    getMessage();
    rf.autoRefresh();
}
Also used : Message(com.gapcoder.weico.Message.Message) Intent(android.content.Intent) QBadgeView(q.rorbin.badgeview.QBadgeView) EasyPopup(com.zyyoona7.lib.EasyPopup) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) BindView(butterknife.BindView) View(android.view.View) QBadgeView(q.rorbin.badgeview.QBadgeView) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) OnLoadmoreListener(com.scwang.smartrefresh.layout.listener.OnLoadmoreListener) SmartRefreshLayout(com.scwang.smartrefresh.layout.SmartRefreshLayout) RefreshLayout(com.scwang.smartrefresh.layout.api.RefreshLayout) TextView(android.widget.TextView) OnRefreshListener(com.scwang.smartrefresh.layout.listener.OnRefreshListener) WeicoAdapter(com.gapcoder.weico.Index.Adapter.WeicoAdapter)

Example 2 with QBadgeView

use of q.rorbin.badgeview.QBadgeView 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)

Example 3 with QBadgeView

use of q.rorbin.badgeview.QBadgeView in project weibo by dingdangmao123.

the class Message method badge.

void badge(int i, int n) {
    if (msg[i] == null) {
        msg[i] = new QBadgeView(this);
        msg[i].bindTarget(tv[i]).setBadgeGravity(Gravity.CENTER | Gravity.END);
    }
    if (n <= 0) {
        msg[i].hide(false);
    } else {
        msg[i].setBadgeNumber(n);
    }
}
Also used : QBadgeView(q.rorbin.badgeview.QBadgeView)

Aggregations

QBadgeView (q.rorbin.badgeview.QBadgeView)3 Intent (android.content.Intent)2 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 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)1 RecyclerView (android.support.v7.widget.RecyclerView)1 MenuItem (android.view.MenuItem)1 View (android.view.View)1 TextView (android.widget.TextView)1 BindView (butterknife.BindView)1 WeicoAdapter (com.gapcoder.weico.Index.Adapter.WeicoAdapter)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 Message (com.gapcoder.weico.Message.Message)1 SmartRefreshLayout (com.scwang.smartrefresh.layout.SmartRefreshLayout)1 RefreshLayout (com.scwang.smartrefresh.layout.api.RefreshLayout)1 OnLoadmoreListener (com.scwang.smartrefresh.layout.listener.OnLoadmoreListener)1