Search in sources :

Example 1 with Currency

use of run.wallet.common.Currency in project run-wallet-android by runplay.

the class ChooseSeedAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(final ViewHolder holder, int position) {
    int adapterPosition = holder.getAdapterPosition();
    Seeds.Seed address = getItem(adapterPosition - 1);
    holder.isDefault = address.isdefault;
    holder.setIsRecyclable(false);
    holder.seed = address;
    holder.addressLabel.setText(address.getShortValue());
    holder.seedName.setText(address.name);
    Wallet wallet = Store.getWallet(address);
    if (wallet != null) {
        holder.extraValue.setVisibility(View.VISIBLE);
        String balanceText = IotaToText.convertRawIotaAmountToDisplayText(wallet.getBalanceDisplay(), true);
        holder.seedValue.setText(balanceText);
        Currency defcur = Store.getDefaultCurrency(context);
        Ticker ticker = Store.getTicker("IOTA:" + defcur);
        if (ticker != null) {
            holder.extraValue.setText(ticker.getIotaValString(wallet.getBalanceDisplay()) + " " + defcur);
        } else {
            holder.extraValue.setVisibility(View.GONE);
        }
    } else {
        holder.extraValue.setVisibility(View.GONE);
    }
    if (address.id.equals(Store.getCurrentSeed().id)) {
        holder.addressImage.setImageDrawable(UiManager.getDrawable(context, R.drawable.check_green));
    // holder.addressLabel.setPaintFlags(holder.addressLabel.getPaintFlags() | Paint.);
    } else if (!address.isdefault) {
        holder.addressImage.setImageDrawable(UiManager.getDrawable(context, R.drawable.ic_address));
        holder.addressImage.setColorFilter(ContextCompat.getColor(context, R.color.flatGreen));
    }
}
Also used : Seeds(run.wallet.iota.model.Seeds) Wallet(run.wallet.iota.model.Wallet) Currency(run.wallet.common.Currency) Ticker(run.wallet.iota.model.Ticker)

Example 2 with Currency

use of run.wallet.common.Currency in project run-wallet-android by runplay.

the class WalletTabFragment method updateAlternateBalance.

private void updateAlternateBalance() {
    Currency alternateCurrency = Utils.getConfiguredAlternateCurrency(getActivity());
    Ticker useticker = Store.getTicker("IOTA:" + alternateCurrency);
    if (useticker != null && Store.getCurrentWallet() != null) {
        alternateBalanceTextView.setText(useticker.getIotaValString(Store.getCurrentWallet().getBalanceDisplay()));
        altCurrency.setText(alternateCurrency.getSymbol());
    } else {
        alternateBalanceTextView.setText("");
        altCurrency.setText("");
    }
}
Also used : Currency(run.wallet.common.Currency) Ticker(run.wallet.iota.model.Ticker)

Example 3 with Currency

use of run.wallet.common.Currency in project run-wallet-android by runplay.

the class ChooseSeedFragment method drawChart.

private void drawChart() {
    long displayBalance = 0L;
    if (Store.getCurrentWallet() != null) {
        seedName.setText(Store.getCurrentSeed().name);
        displayBalance = Store.getCurrentWallet().getBalanceDisplay();
    }
    Currency cur = Store.getDefaultCurrency(getActivity());
    seedValue.setText(IotaToText.convertRawIotaAmountToDisplayText(displayBalance, true));
    Ticker ticker = Store.getTicker("IOTA:" + cur.getCurrencyCode());
    if (ticker != null) {
        seedCurrency.setText(ticker.getIotaValString(displayBalance) + "\n" + cur.getSymbol());
        DecimalFormat udf = df;
        if (ticker.getLast() < 0.01)
            udf = dfs;
        xchangeLast.setText(udf.format(ticker.getLast()));
        xchangeHigh.setText(udf.format(ticker.getHigh()));
        xchangeLow.setText(udf.format(ticker.getLow()));
    }
    // Log.e("THIST","go 3");
    chart.setNoDataText(getString(R.string.messages_no_chart_data));
    chart.setNoDataTextColor(ContextCompat.getColor(getActivity(), R.color.white));
    chart.setGridBackgroundColor(ContextCompat.getColor(getActivity(), R.color.colorLight));
    Paint p = chart.getPaint(Chart.PAINT_INFO);
    p.setColor(ContextCompat.getColor(getActivity(), AppTheme.getPrimaryDark()));
    chart.getDescription().setEnabled(false);
    chart.setDragDecelerationFrictionCoef(0.95f);
    // chart.setExtraOffsets(15.f, 15.f, 15.f, 15.f);
    chart.setHighlightPerTapEnabled(false);
    chart.setEnabled(false);
    chart.setTouchEnabled(false);
    chart.animateX(1000);
    chart.setPadding(0, 0, 0, 0);
    chart.getAxisLeft().setEnabled(false);
    chart.getAxisRight().setEnabled(false);
    chart.getXAxis().setEnabled(false);
    // chart.setZ(0.5f);
    chart.zoomOut();
    chart.setPinchZoom(false);
    chart.setPinchZoom(false);
    chart.setFocusable(false);
    Legend leg = chart.getLegend();
    leg.setVerticalAlignment(Legend.LegendVerticalAlignment.BOTTOM);
    leg.setHorizontalAlignment(Legend.LegendHorizontalAlignment.LEFT);
    leg.setOrientation(Legend.LegendOrientation.HORIZONTAL);
    leg.setDrawInside(false);
    leg.setEnabled(false);
    List<Entry> entries = new ArrayList<Entry>();
    List<Entry> entriesvol = new ArrayList<Entry>();
    // Log
    history = Store.getTickerHist(getActivity(), Store.getDefaultCurrency(getActivity()).getCurrencyCode(), currentStep);
    double avg = 0D;
    if (history != null) {
        // Log.e("THIST","go 4");
        List<Tick> tickers = history.getTicks();
        Collections.reverse(tickers);
        // double min=tickers.get(0).getLast();
        double max = tickers.get(0).getLast();
        double lastvol = 0;
        double maxvol = 0;
        double minvol = 0D;
        for (int i = 0; i < tickers.size(); i++) {
            double last = tickers.get(i).getLast();
            double tmpvol = tickers.get(i).getVol();
            if (avg == 0D) {
                avg = last;
            } else {
                avg = (avg + last) / 2;
            }
            if (last > max)
                max = last;
            if (tmpvol > maxvol)
                maxvol = tmpvol;
            if (minvol == 0)
                minvol = tmpvol;
            else if (tmpvol < minvol)
                minvol = tmpvol;
            Entry e = new Entry(i * 10, Double.valueOf(last).floatValue());
            entries.add(e);
        }
        max = Math.abs(max);
        double voldivide = (100 / maxvol) / 70;
        for (int i = tickers.size() - 1; i >= 0; i--) {
            double tmpvol = tickers.get(i).getVol() * voldivide;
            // Log.e("YUP", "vol: "+tickers.get(i).getVol()+" = " + tmpvol);
            Entry ev = new Entry(i * 10, Double.valueOf(tmpvol + (0.015 * history.getStep())).floatValue());
            entriesvol.add(ev);
        }
        Collections.reverse(entriesvol);
        // add entries to dataset
        LineDataSet dataSet = new LineDataSet(entries, "IOTA:" + Store.getDefaultCurrency(getActivity()).getCurrencyCode());
        dataSet.setDrawCircleHole(false);
        dataSet.setDrawCircles(false);
        dataSet.setDrawFilled(true);
        dataSet.setFillColor(getResources().getColor(AppTheme.getPrimaryDark()));
        dataSet.setFillAlpha(100);
        dataSet.setColor(B.getColor(getActivity(), AppTheme.getPrimary()));
        // add entries to dataset
        LineDataSet idataSet = new LineDataSet(entriesvol, "Vol");
        idataSet.setDrawCircleHole(false);
        idataSet.setDrawCircles(false);
        idataSet.setDrawFilled(true);
        idataSet.setFillColor(getResources().getColor(R.color.colorMiddle));
        idataSet.setColor(B.getColor(getActivity(), AppTheme.getPrimaryDark()));
        idataSet.setFillAlpha(100);
        ArrayList<ILineDataSet> dataSets = new ArrayList<ILineDataSet>();
        dataSets.add(dataSet);
        dataSets.add(idataSet);
        LineData lineData = new LineData(dataSets);
        chart.setData(lineData);
        float gomin = Double.valueOf(0).floatValue();
        float gomax = +Double.valueOf(max * 1.4).floatValue();
        chart.getAxisLeft().setAxisMinimum(gomin);
        chart.getAxisLeft().setAxisMaximum(gomax);
        chart.getAxisRight().setAxisMinimum(gomin);
        chart.getAxisRight().setAxisMaximum(gomax);
    }
    // refresh
    chart.invalidate();
}
Also used : Legend(com.github.mikephil.charting.components.Legend) LineDataSet(com.github.mikephil.charting.data.LineDataSet) ILineDataSet(com.github.mikephil.charting.interfaces.datasets.ILineDataSet) Ticker(run.wallet.iota.model.Ticker) DecimalFormat(java.text.DecimalFormat) ArrayList(java.util.ArrayList) Paint(android.graphics.Paint) Paint(android.graphics.Paint) Entry(com.github.mikephil.charting.data.Entry) LineData(com.github.mikephil.charting.data.LineData) ILineDataSet(com.github.mikephil.charting.interfaces.datasets.ILineDataSet) Currency(run.wallet.common.Currency) Tick(run.wallet.iota.model.Tick)

Aggregations

Currency (run.wallet.common.Currency)3 Ticker (run.wallet.iota.model.Ticker)3 Paint (android.graphics.Paint)1 Legend (com.github.mikephil.charting.components.Legend)1 Entry (com.github.mikephil.charting.data.Entry)1 LineData (com.github.mikephil.charting.data.LineData)1 LineDataSet (com.github.mikephil.charting.data.LineDataSet)1 ILineDataSet (com.github.mikephil.charting.interfaces.datasets.ILineDataSet)1 DecimalFormat (java.text.DecimalFormat)1 ArrayList (java.util.ArrayList)1 Seeds (run.wallet.iota.model.Seeds)1 Tick (run.wallet.iota.model.Tick)1 Wallet (run.wallet.iota.model.Wallet)1