Search in sources :

Example 1 with BadgeView

use of com.readystatesoftware.viewbadger.BadgeView in project HumaneApp by Ganesh1010.

the class ItemDetailsAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(final MyViewHolder holder, final int listPosition) {
    holder.setIsRecyclable(false);
    for (int i = 0; i < itemslist.size(); i++) {
        NeedItemDetails needItemDetails = (NeedItemDetails) itemslist.get(i);
        needItemId = needItemDetails.getItem_type_id();
        needQuantity = needItemDetails.getQuantity();
        Log.d("needItemId", needItemId + "");
        needQuantities[i] = needQuantity;
        //subItemId = needItemDetails.getSub_item_type_id();
        for (int j = 0; j < mainItemDetailsList.size(); j++) {
            MainItemDetails mainItemDetails = mainItemDetailsList.get(j);
            if (needItemId == mainItemDetails.getMainItemCode()) {
                String mainItemName = mainItemDetails.getMainItemName();
                needName[i] = mainItemName;
            }
        }
    // holder.imageView.setImageResource(dataSet.get(listPosition).getImage());
    }
    holder.imageView.setImageResource(getimages(listPosition));
    holder.title.setText(needName[listPosition]);
    holder.requested.setText(needQuantities[listPosition] + "");
    holder.increment.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            boolean isExists = false;
            for (int i = 0; i < donatedItemDetails.size(); i++) {
                item = donatedItemDetails.get(i);
                if (item.getNeeditem() == need.getItems().get(listPosition).getNeed_item_id()) {
                    item.setQuantity(item.getQuantity() + 1);
                    donatedItemDetails.set(i, item);
                    isExists = true;
                    break;
                // CommonUI.displayCheckoutUI(activity.findViewById(R.id.activity_donor_org_details),item.getQuantity(),activity);
                }
            }
            if (!isExists) {
                item = new DonatedItemDetails();
                item.setNeeditem(need.getItems().get(listPosition).getNeed_item_id());
                item.setQuantity(1);
                donatedItemDetails.add(item);
            }
            holder.value.setText((item.getQuantity() + ""));
            CommonUI.displayCheckoutUI(activity.findViewById(R.id.activity_donor_org_details), ++count, activity);
            View target = activity.findViewById(R.id.cart);
            BadgeView badge = new BadgeView(context, target);
            badge.setText((count) + "");
            badge.show();
        }
    });
    holder.decrement.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            boolean isExists = false;
            for (int i = 0; i < donatedItemDetails.size(); i++) {
                item = donatedItemDetails.get(i);
                if (item.getNeeditem() == need.getItems().get(listPosition).getNeed_item_id()) {
                    item.setQuantity(item.getQuantity() - 1);
                    donatedItemDetails.set(i, item);
                    isExists = true;
                    break;
                }
            }
            if (!isExists) {
                item = new DonatedItemDetails();
                item.setNeeditem(need.getItems().get(listPosition).getNeed_item_id());
                item.setQuantity(1);
                donatedItemDetails.add(item);
            }
            holder.value.setText((item.getQuantity() + ""));
            CommonUI.displayCheckoutUI(activity.findViewById(R.id.activity_donor_org_details), --count, activity);
            View target = activity.findViewById(R.id.cart);
            BadgeView badge = new BadgeView(context, target);
            Log.d("view", count + "");
            badge.setText(count + "");
            badge.show();
        }
    });
//Log.d("value", dataSet.get(listPosition).getRequested() + "");
}
Also used : BadgeView(com.readystatesoftware.viewbadger.BadgeView) ImageView(android.widget.ImageView) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) BadgeView(com.readystatesoftware.viewbadger.BadgeView) View(android.view.View)

Example 2 with BadgeView

use of com.readystatesoftware.viewbadger.BadgeView in project android-viewbadger by jgilfelt.

the class DemoActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    final TabHost tabHost = getTabHost();
    tabHost.addTab(tabHost.newTabSpec("demos").setIndicator("Badge Demos").setContent(R.id.tab1));
    tabHost.addTab(tabHost.newTabSpec("adapter").setIndicator("List Adapter").setContent(R.id.tab2));
    tabHost.addTab(tabHost.newTabSpec("tests").setIndicator("Layout Tests").setContent(R.id.tab3));
    // *** default badge ***
    View target = findViewById(R.id.default_target);
    BadgeView badge = new BadgeView(this, target);
    badge.setText("1");
    badge.show();
    // *** set position ***
    btnPosition = (Button) findViewById(R.id.position_target);
    badge1 = new BadgeView(this, btnPosition);
    badge1.setText("12");
    badge1.setBadgePosition(BadgeView.POSITION_CENTER);
    btnPosition.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            badge1.toggle();
        }
    });
    // *** badge/text size & colour ***
    btnColour = (Button) findViewById(R.id.colour_target);
    badge2 = new BadgeView(this, btnColour);
    badge2.setText("New!");
    badge2.setTextColor(Color.BLUE);
    badge2.setBadgeBackgroundColor(Color.YELLOW);
    badge2.setTextSize(12);
    btnColour.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            badge2.toggle();
        }
    });
    // *** default animation ***
    btnAnim1 = (Button) findViewById(R.id.anim1_target);
    badge3 = new BadgeView(this, btnAnim1);
    badge3.setText("84");
    btnAnim1.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            badge3.toggle(true);
        }
    });
    // *** custom animation ***
    btnAnim2 = (Button) findViewById(R.id.anim2_target);
    badge4 = new BadgeView(this, btnAnim2);
    badge4.setText("123");
    badge4.setBadgePosition(BadgeView.POSITION_TOP_LEFT);
    badge4.setBadgeMargin(15, 10);
    badge4.setBadgeBackgroundColor(Color.parseColor("#A4C639"));
    btnAnim2.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            TranslateAnimation anim = new TranslateAnimation(-100, 0, 0, 0);
            anim.setInterpolator(new BounceInterpolator());
            anim.setDuration(1000);
            badge4.toggle(anim, null);
        }
    });
    // *** custom background ***
    btnCustom = (Button) findViewById(R.id.custom_target);
    badge5 = new BadgeView(this, btnCustom);
    badge5.setText("37");
    badge5.setBackgroundResource(R.drawable.badge_ifaux);
    badge5.setTextSize(16);
    btnCustom.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            badge5.toggle(true);
        }
    });
    // *** clickable badge ***
    btnClick = (Button) findViewById(R.id.click_target);
    badge6 = new BadgeView(this, btnClick);
    badge6.setText("click me");
    badge6.setBadgeBackgroundColor(Color.BLUE);
    badge6.setTextSize(16);
    badge6.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            Toast.makeText(DemoActivity.this, "clicked badge", Toast.LENGTH_SHORT).show();
        }
    });
    btnClick.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            badge6.toggle();
        }
    });
    // *** tab ***
    TabWidget tabs = (TabWidget) findViewById(android.R.id.tabs);
    btnTab = (Button) findViewById(R.id.tab_btn);
    badge7 = new BadgeView(this, tabs, 0);
    badge7.setText("5");
    btnTab.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            badge7.toggle();
        }
    });
    // *** increment ***
    btnIncrement = (Button) findViewById(R.id.increment_target);
    badge8 = new BadgeView(this, btnIncrement);
    badge8.setText("0");
    btnIncrement.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            if (badge8.isShown()) {
                badge8.increment(1);
            } else {
                badge8.show();
            }
        }
    });
    // *** list adapter ****
    listDemo = (ListView) findViewById(R.id.tab2);
    listDemo.setAdapter(new BadgeAdapter(this));
}
Also used : TabHost(android.widget.TabHost) BounceInterpolator(android.view.animation.BounceInterpolator) BadgeView(com.readystatesoftware.viewbadger.BadgeView) OnClickListener(android.view.View.OnClickListener) TranslateAnimation(android.view.animation.TranslateAnimation) TabWidget(android.widget.TabWidget) TextView(android.widget.TextView) BadgeView(com.readystatesoftware.viewbadger.BadgeView) View(android.view.View) ListView(android.widget.ListView)

Example 3 with BadgeView

use of com.readystatesoftware.viewbadger.BadgeView in project android-viewbadger by jgilfelt.

the class DemoActivity method onResume.

@Override
protected void onResume() {
    super.onResume();
    BadgeView badge;
    View target;
    // *** test linear layout container ***
    target = findViewById(R.id.linear_target);
    badge = new BadgeView(this, target);
    badge.setText("OK");
    badge.show();
    // *** test relative layout container ***
    target = findViewById(R.id.relative_target);
    badge = new BadgeView(this, target);
    badge.setText("OK");
    badge.show();
    // *** test frame layout container ***
    target = findViewById(R.id.frame_target);
    badge = new BadgeView(this, target);
    badge.setText("OK");
    badge.show();
    // *** test table layout container ***
    target = findViewById(R.id.table_target);
    badge = new BadgeView(this, target);
    badge.setText("OK");
    badge.show();
    // *** test linear layout ***
    target = findViewById(R.id.linear_group_target);
    badge = new BadgeView(this, target);
    badge.setText("OK");
    badge.show();
    // *** test relative layout ***
    target = findViewById(R.id.relative_group_target);
    badge = new BadgeView(this, target);
    badge.setText("OK");
    badge.show();
    // *** test frame layout ***
    target = findViewById(R.id.frame_group_target);
    badge = new BadgeView(this, target);
    badge.setText("OK");
    badge.show();
    // *** test table layout ***
    target = findViewById(R.id.tablerow_group_target);
    badge = new BadgeView(this, target);
    badge.setText("OK");
    badge.show();
}
Also used : BadgeView(com.readystatesoftware.viewbadger.BadgeView) TextView(android.widget.TextView) BadgeView(com.readystatesoftware.viewbadger.BadgeView) View(android.view.View) ListView(android.widget.ListView)

Aggregations

View (android.view.View)3 TextView (android.widget.TextView)3 BadgeView (com.readystatesoftware.viewbadger.BadgeView)3 ListView (android.widget.ListView)2 RecyclerView (android.support.v7.widget.RecyclerView)1 OnClickListener (android.view.View.OnClickListener)1 BounceInterpolator (android.view.animation.BounceInterpolator)1 TranslateAnimation (android.view.animation.TranslateAnimation)1 ImageView (android.widget.ImageView)1 TabHost (android.widget.TabHost)1 TabWidget (android.widget.TabWidget)1