Android Open Source - android-wallet Asset Selector Adapter






From Project

Back to project page android-wallet.

License

The source code is released under:

GNU General Public License

If you think the Android project android-wallet 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

/*
 * Copyright (c) 2014 Flavien Charlon//from  ww w  .ja  v  a  2s  .  co m
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package com.coinprism.wallet.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import com.coinprism.model.AssetDefinition;
import com.coinprism.wallet.R;

import java.util.List;

/**
 * Renders the list of available asset for a spinner control.
 */
public class AssetSelectorAdapter extends ArrayAdapter<AssetDefinition>
{
    private final Context context;
    private final List<AssetDefinition> values;

    public AssetSelectorAdapter(Context context, List<AssetDefinition> values)
    {
        super(context, R.layout.asset_selector_item, values);
        this.context = context;
        this.values = values;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent)
    {
        LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        TextView rowView;
        if (convertView == null)
            rowView = (TextView)inflater.inflate(R.layout.asset_selector_item, parent, false);
        else
            rowView = (TextView)convertView;

        AssetDefinition item = values.get(position);

        if (item == null)
            rowView.setText(context.getString(R.string.tab_send_selector_short_bitcoin));
        else if (item.getTicker() != null)
            rowView.setText(item.getTicker());
        else
            rowView.setText(context.getString(R.string.tab_send_selector_short_unknown_asset));

        return rowView;
    }

    @Override
    public View getDropDownView(int position, View convertView, ViewGroup parent)
    {
        LayoutInflater inflater = (LayoutInflater) context
            .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        TextView rowView = (TextView)inflater.inflate(R.layout.asset_selector_item_padding, parent,
            false);

        AssetDefinition item = values.get(position);

        if (item == null)
            rowView.setText(context.getString(R.string.tab_send_selector_long_bitcoin));
        else if (item.getName() != null)
            rowView.setText(item.getName());
        else
            rowView.setText(String.format(context.getString(R.string.tab_send_selector_long_unknown_asset), item.getAssetId().substring(0, 10)));

        return rowView;
    }
}




Java Source Code List

com.coinprism.model.APIClient.java
com.coinprism.model.APIException.java
com.coinprism.model.AddressBalance.java
com.coinprism.model.AssetBalance.java
com.coinprism.model.AssetDefinition.java
com.coinprism.model.BalanceLoader.java
com.coinprism.model.CoinprismWalletApplication.java
com.coinprism.model.DownloadImageTask.java
com.coinprism.model.QRCodeEncoder.java
com.coinprism.model.SingleAssetTransaction.java
com.coinprism.model.TransactionsLoader.java
com.coinprism.model.WalletConfiguration.java
com.coinprism.model.WalletState.java
com.coinprism.utils.Formatting.java
com.coinprism.utils.SecurePreferences.java
com.coinprism.utils.StretchingImageView.java
com.coinprism.wallet.ApplicationTest.java
com.coinprism.wallet.ProgressDialog.java
com.coinprism.wallet.QRCodeDialog.java
com.coinprism.wallet.UserPreferences.java
com.coinprism.wallet.WalletOverview.java
com.coinprism.wallet.adapter.AssetBalanceAdapter.java
com.coinprism.wallet.adapter.AssetSelectorAdapter.java
com.coinprism.wallet.adapter.TabsPagerAdapter.java
com.coinprism.wallet.adapter.TransactionAdapter.java
com.coinprism.wallet.fragment.BalanceTab.java
com.coinprism.wallet.fragment.SendTab.java
com.coinprism.wallet.fragment.TransactionsTab.java