Search in sources :

Example 1 with DecimalDigitsInputFilter

use of com.polito.mad17.madmax.activities.DecimalDigitsInputFilter in project MadMax by deviz92.

the class PayExpenseActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_pay_expense);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    Intent intent = getIntent();
    groupID = intent.getStringExtra("groupID");
    userID = intent.getStringExtra("userID");
    expenseID = intent.getStringExtra("expenseID");
    expenseName = intent.getStringExtra("expenseName");
    debt = intent.getDoubleExtra("debt", 0);
    debt = abs(Math.floor(debt * 100) / 100);
    currency = intent.getStringExtra("expenseCurrency");
    amountEditText = (EditText) findViewById(R.id.amount);
    amountEditText.setFilters(new InputFilter[] { new DecimalDigitsInputFilter(7, 2) });
    expenseNameTextView = (TextView) findViewById(R.id.tv_receiver);
    expenseNameTextView.setText(expenseName);
    amountEditText.setText(debt.toString());
    currencyTextView = (TextView) findViewById(R.id.currency);
    currencyTextView.setText(currency);
}
Also used : Intent(android.content.Intent) DecimalDigitsInputFilter(com.polito.mad17.madmax.activities.DecimalDigitsInputFilter)

Example 2 with DecimalDigitsInputFilter

use of com.polito.mad17.madmax.activities.DecimalDigitsInputFilter in project MadMax by deviz92.

the class PayGroupActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_pay_group);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
    String defaultCurrency = sharedPref.getString(SettingsFragment.DEFAULT_CURRENCY, "");
    Intent intent = getIntent();
    groupID = intent.getStringExtra("groupID");
    userID = intent.getStringExtra("userID");
    groupName = intent.getStringExtra("groupName");
    totBalances = (HashMap<String, Double>) intent.getSerializableExtra("totBalances");
    shownCurrency = intent.getStringExtra("shownCurrency");
    debt = totBalances.get(shownCurrency);
    debt = abs(Math.floor(debt * 100) / 100);
    currency = (Spinner) findViewById(R.id.currency);
    amountEditText = (EditText) findViewById(R.id.amount);
    amountEditText.setFilters(new InputFilter[] { new DecimalDigitsInputFilter(7, 2) });
    groupNameTextView = (TextView) findViewById(R.id.tv_receiver);
    groupNameTextView.setText(groupName);
    amountEditText.setText(debt.toString());
    // creating spinner for currencies
    ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.currencies, android.R.layout.simple_spinner_item);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    currency.setAdapter(adapter);
    // set the defaultCurrency value for the spinner based on the user preferences
    int spinnerPosition = adapter.getPosition(shownCurrency);
    currency.setSelection(spinnerPosition);
}
Also used : SharedPreferences(android.content.SharedPreferences) Intent(android.content.Intent) DecimalDigitsInputFilter(com.polito.mad17.madmax.activities.DecimalDigitsInputFilter)

Aggregations

Intent (android.content.Intent)2 DecimalDigitsInputFilter (com.polito.mad17.madmax.activities.DecimalDigitsInputFilter)2 SharedPreferences (android.content.SharedPreferences)1