Android Open Source - philippine-income-tax-android Income Adapter






From Project

Back to project page philippine-income-tax-android.

License

The source code is released under:

GNU General Public License

If you think the Android project philippine-income-tax-android 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 com.chrisbjr.android.philippineincometax.adapters;
/*  w  w w  . j  a  v  a2s  .co  m*/
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;

import com.chrisbjr.android.philippineincometax.R;
import com.chrisbjr.android.philippineincometax.objects.NonTaxableIncome;
import com.chrisbjr.android.philippineincometax.objects.TaxableIncome;

import java.text.DecimalFormat;

public class IncomeAdapter {

  private TaxableIncome mTaxableIncome = null;
  private NonTaxableIncome mNonTaxableIncome = null;

  public IncomeAdapter(TaxableIncome ti) {
    mTaxableIncome = ti;
  }

  public IncomeAdapter(NonTaxableIncome ti) {
    mNonTaxableIncome = ti;
  }

  public View getView(Context ctx) {
    View view = LayoutInflater.from(ctx).inflate(R.layout.layout_income,
        null, false);

    TextView incomeNameTextView = (TextView) view
        .findViewById(R.id.incomeNameTextView);
    TextView incomeAmountTextView = (TextView) view
        .findViewById(R.id.incomeAmountTextView);
    TextView incomeLabelTextView = (TextView) view
        .findViewById(R.id.incomeLabelTextView);

    if (mTaxableIncome != null) {
      incomeNameTextView.setText(mTaxableIncome.getName());
      incomeAmountTextView.setText("P"
          + customFormat("###,###,###,###.##",
              mTaxableIncome.getAmount()));
      incomeLabelTextView.setText("Taxable Income");
    }

    if (mNonTaxableIncome != null) {
      incomeNameTextView.setText(mNonTaxableIncome.getName());
      incomeAmountTextView.setText("P"
          + customFormat("###,###,###,###.##",
              mNonTaxableIncome.getAmount()));
      incomeLabelTextView.setText("Non-Taxable Income");
    }

    return view;
  }

  private String customFormat(String pattern, double value) {
    DecimalFormat myFormatter = new DecimalFormat(pattern);
    return myFormatter.format(value);

  }

}




Java Source Code List

com.chrisbjr.android.philippineincometax.MainActivity.java
com.chrisbjr.android.philippineincometax.adapters.IncomeAdapter.java
com.chrisbjr.android.philippineincometax.calculator.CalculatorBrain.java
com.chrisbjr.android.philippineincometax.db.DatabaseConfigUtil.java
com.chrisbjr.android.philippineincometax.db.DatabaseHelper.java
com.chrisbjr.android.philippineincometax.db.DatabaseManager.java
com.chrisbjr.android.philippineincometax.models.IncomeTaxCalculationModel.java
com.chrisbjr.android.philippineincometax.models.NonTaxableIncomeModel.java
com.chrisbjr.android.philippineincometax.models.PagibigModel.java
com.chrisbjr.android.philippineincometax.models.PhilHealthModel.java
com.chrisbjr.android.philippineincometax.models.SssModel.java
com.chrisbjr.android.philippineincometax.models.TaxableIncomeModel.java
com.chrisbjr.android.philippineincometax.models.WithholdingTaxModel.java
com.chrisbjr.android.philippineincometax.objects.IncomeTaxCalculation.java
com.chrisbjr.android.philippineincometax.objects.NonTaxableIncome.java
com.chrisbjr.android.philippineincometax.objects.Pagibig.java
com.chrisbjr.android.philippineincometax.objects.Philhealth.java
com.chrisbjr.android.philippineincometax.objects.Sss.java
com.chrisbjr.android.philippineincometax.objects.TaxableIncome.java
com.chrisbjr.android.philippineincometax.objects.WithholdingTaxType.java
com.chrisbjr.android.philippineincometax.objects.WithholdingTax.java