Android Open Source - BitZero Coin Card






From Project

Back to project page BitZero.

License

The source code is released under:

DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE Version 2, December 2004 Copyright (C) 2004 Sam Hocevar <sam@hocevar.net> Everyone is permitted to copy and distribute v...

If you think the Android project BitZero listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package it.thezero.bitzero.adapters;
/*  ww  w  .  j a v  a2s .  c o  m*/
import it.thezero.bitzero.EditActivity;
import it.thezero.bitzero.MainActivity;
import it.thezero.bitzero.R;
import it.thezero.bitzero.address.Address;
import android.content.Context;
import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.PopupMenu.OnMenuItemClickListener;
import android.widget.TextView;
import android.view.MenuItem;
import android.widget.PopupMenu;
import com.fima.cardsui.objects.Card;

public class CoinCard extends Card {
  private Address addr;
  
  public CoinCard(String v,String n,String a,Integer tx,Integer b){
    super(n);
    addr=new Address(v,n,a,tx,b);
  }

  public CoinCard(Address a){
    super(a.getName());
    addr=a;
  }
  
  @Override
  public View getCardContent(final Context context) {
    View view = LayoutInflater.from(context).inflate(R.layout.card_ex, null);

    if(addr.getValuta()==Address.Val[1][0]) {
      ((ImageView) view.findViewById(R.id.valuta)).setImageDrawable(context.getResources().getDrawable(R.drawable.icon_bitcoin));
    }else if(addr.getValuta()==Address.Val[1][1]) {
      ((ImageView) view.findViewById(R.id.valuta)).setImageDrawable(context.getResources().getDrawable(R.drawable.icon_litecoin));
    }else if(addr.getValuta()==Address.Val[1][2]) {
      ((ImageView) view.findViewById(R.id.valuta)).setImageDrawable(context.getResources().getDrawable(R.drawable.icon_dogecoin));
    }else if(addr.getValuta()==Address.Val[1][3]) {
      ((ImageView) view.findViewById(R.id.valuta)).setImageDrawable(context.getResources().getDrawable(R.drawable.icon_zetacoin));
    }
    
    ((TextView) view.findViewById(R.id.label)).setText(title);
    ((TextView) view.findViewById(R.id.address)).setText("Address: "+addr.getAddress());
    
    if(addr.getBalance()>-1){
      if(addr.getValuta()==Address.Val[1][0]) {
        ((TextView) view.findViewById(R.id.bitcoin)).setText("Balance: "+Address.toBTC(addr.getBalance())+" "+addr.getValuta());
      }else if(addr.getValuta()==Address.Val[1][1]) {
        ((TextView) view.findViewById(R.id.bitcoin)).setText("Balance: "+addr.getBalance()+" "+addr.getValuta());
      }else if(addr.getValuta()==Address.Val[1][2]) {
        ((TextView) view.findViewById(R.id.bitcoin)).setText("Balance: "+addr.getBalance()+" "+addr.getValuta());
      }else if(addr.getValuta()==Address.Val[1][3]) {
        ((TextView) view.findViewById(R.id.bitcoin)).setText("Balance: "+addr.getBalance()+" "+addr.getValuta());
      }
      
      ((TextView) view.findViewById(R.id.tx)).setText("Transaction: "+addr.getTx().toString());
    }else{
      ((TextView) view.findViewById(R.id.bitcoin)).setText("Balance: No internet connection");
      ((TextView) view.findViewById(R.id.tx)).setText("Transaction: No internet connection");
    }
    
    ((ImageButton) view.findViewById(R.id.img3button)).setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                PopupMenu popup = new PopupMenu(context, v);
                popup.getMenuInflater().inflate(R.menu.popup, popup.getMenu());
                popup.setOnMenuItemClickListener(new OnMenuItemClickListener() {
 
                    @Override
                    public boolean onMenuItemClick(MenuItem item) {
                      switch (item.getItemId()) {
                          case R.id.action1:
                            Intent it = new Intent(context,EditActivity.class);
                    it.putExtra("label", addr.getName());
                    it.putExtra("addr", addr.getAddress());
                    context.startActivity(it);
                              break;
                          case R.id.action3:
                            MainActivity.encodeBarcode("TEXT_TYPE", addr.getValuta(true)+":"+addr.getAddress()+"?label="+addr.getName());
                              break;
                          case R.id.action2:
                            MainActivity.addr.remove(addr.getAddress());
                            MainActivity.Refresh();
                              break;
                      }
                        return true;
                    }
                });

                popup.show();
 
            }
        });
    
    return view;
  }
  
}




Java Source Code List

it.thezero.bitzero.EditActivity.java
it.thezero.bitzero.MainActivity.java
it.thezero.bitzero.Utils.java
it.thezero.bitzero.adapters.CoinCard.java
it.thezero.bitzero.address.Address.java