use of com.polito.mad17.madmax.entities.CropCircleTransformation in project MadMax by deviz92.
the class ParticipantsViewAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(final ParticipantsViewAdapter.ItemParticipantsViewHolder holder, int position) {
Map.Entry<String, User> item = getItem(position);
String photo = item.getValue().getProfileImage();
if (photo == null || photo.equals("")) {
Glide.with(layoutInflater.getContext()).load(R.drawable.user_default).centerCrop().bitmapTransform(new CropCircleTransformation(layoutInflater.getContext())).diskCacheStrategy(DiskCacheStrategy.ALL).into(holder.imageView);
} else {
Glide.with(layoutInflater.getContext()).load(photo).centerCrop().bitmapTransform(new CropCircleTransformation(layoutInflater.getContext())).diskCacheStrategy(DiskCacheStrategy.ALL).into(holder.imageView);
}
holder.nameTextView.setText(item.getValue().getName() + " " + item.getValue().getSurname());
DecimalFormat df = new DecimalFormat("#.##");
Double dueImport = item.getValue().getDueImport();
if (dueImport > 0) {
holder.balanceTextTextView.setText(R.string.credit_of);
holder.balanceTextTextView.setTextColor(ContextCompat.getColor(context, R.color.colorPrimaryDark));
String balance = df.format(Math.abs(dueImport)) + " " + item.getValue().getExpenseCurrency();
Log.d(TAG, "balance " + balance);
holder.toPayTextView.setText(balance);
holder.toPayTextView.setTextColor(ContextCompat.getColor(context, R.color.colorPrimaryDark));
} else {
if (dueImport < 0) {
holder.balanceTextTextView.setText(R.string.debt_of);
holder.balanceTextTextView.setTextColor(ContextCompat.getColor(context, R.color.colorAccent));
String balance = df.format(Math.abs(dueImport)) + " " + item.getValue().getExpenseCurrency();
Log.d(TAG, "balance " + balance + " " + R.color.colorAccent);
holder.toPayTextView.setText(balance);
holder.toPayTextView.setTextColor(ContextCompat.getColor(context, R.color.colorAccent));
} else {
holder.balanceTextTextView.setText(R.string.no_debts);
holder.toPayTextView.setText("0 " + item.getValue().getExpenseCurrency());
holder.balanceTextTextView.setTextColor(ContextCompat.getColor(context, R.color.colorSecondaryText));
}
}
String alreadyPaid = df.format(Math.abs(item.getValue().getAlreadyPaid()));
holder.alreadyPaidTextView.setText(alreadyPaid + " " + item.getValue().getExpenseCurrency());
}
use of com.polito.mad17.madmax.entities.CropCircleTransformation 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();
userID = intent.getStringExtra("userID");
userImageURL = intent.getStringExtra("userImage");
groupID = intent.getStringExtra("groupID");
expenseID = intent.getStringExtra("expenseID");
expenseName = intent.getStringExtra("expenseName");
expenseImageURL = intent.getStringExtra("expenseImage");
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);
userImage = (ImageView) findViewById(R.id.sender_photo);
if (userImageURL != null) {
Glide.with(getLayoutInflater().getContext()).load(userImageURL).centerCrop().bitmapTransform(new CropCircleTransformation(getLayoutInflater().getContext())).diskCacheStrategy(DiskCacheStrategy.ALL).into(userImage);
} else {
Glide.with(getLayoutInflater().getContext()).load(R.drawable.user_default).centerCrop().bitmapTransform(new CropCircleTransformation(getLayoutInflater().getContext())).diskCacheStrategy(DiskCacheStrategy.ALL).into(userImage);
}
expenseImage = (ImageView) findViewById(R.id.receiver_photo);
if (expenseImageURL != null) {
Glide.with(getLayoutInflater().getContext()).load(expenseImageURL).centerCrop().bitmapTransform(new CropCircleTransformation(getLayoutInflater().getContext())).diskCacheStrategy(DiskCacheStrategy.ALL).into(expenseImage);
} else {
Glide.with(getLayoutInflater().getContext()).load(R.drawable.expense_default).centerCrop().bitmapTransform(new CropCircleTransformation(getLayoutInflater().getContext())).diskCacheStrategy(DiskCacheStrategy.ALL).into(expenseImage);
}
}
use of com.polito.mad17.madmax.entities.CropCircleTransformation in project MadMax by deviz92.
the class PendingExpenseViewAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(final PendingExpenseViewAdapter.ItemExpensesViewHolder holder, int position) {
if (position == (pendingExpenses.size() - 1)) {
Log.d(TAG, "item.getKey().equals(\"nullGroup\")");
holder.imageView.setVisibility(View.GONE);
holder.nameTextView.setText("");
holder.groupTextView.setText("");
holder.yesTextView.setText("");
holder.noTextView.setText("");
holder.participantsCountTextView.setText("");
holder.amountTextView.setText("");
holder.partecipantsImageView.setVisibility(View.GONE);
holder.thumbUpButton.setVisibility(View.GONE);
holder.thumbDownButton.setVisibility(View.GONE);
} else {
Expense expense = getItem(position).getValue();
Log.d(TAG, "item ID " + expense.getID() + " item name " + expense.getDescription());
String p = expense.getGroupImage();
Log.d(TAG, "groupImage " + p);
if (p != null && !p.equals("noImage")) {
Log.d(TAG, "Image not null " + p);
Glide.with(layoutInflater.getContext()).load(p).centerCrop().bitmapTransform(new CropCircleTransformation(layoutInflater.getContext())).diskCacheStrategy(DiskCacheStrategy.ALL).into(holder.imageView);
} else {
Glide.with(layoutInflater.getContext()).load(R.drawable.group_default).centerCrop().bitmapTransform(new CropCircleTransformation(layoutInflater.getContext())).diskCacheStrategy(DiskCacheStrategy.ALL).into(holder.imageView);
}
holder.nameTextView.setText(expense.getDescription());
holder.groupTextView.setText(expense.getGroupName());
holder.yesTextView.setText(expense.getYes().toString());
holder.noTextView.setText(expense.getNo().toString());
holder.participantsCountTextView.setText(expense.getParticipantsCount().toString());
holder.imageView.setVisibility(View.VISIBLE);
holder.partecipantsImageView.setVisibility(View.VISIBLE);
holder.thumbUpButton.setVisibility(View.VISIBLE);
holder.thumbDownButton.setVisibility(View.VISIBLE);
DecimalFormat df = new DecimalFormat("#.##");
Double amount = expense.getAmount();
holder.amountTextView.setText(df.format(amount) + " " + expense.getCurrency());
if (expense.getMyVote().equals("yes")) {
holder.thumbUpButton.setBackgroundResource(R.drawable.thumb_up_teal);
holder.thumbDownButton.setBackgroundResource(R.drawable.thumb_down_black);
} else if (expense.getMyVote().equals("no")) {
holder.thumbUpButton.setBackgroundResource(R.drawable.thumb_up_black);
holder.thumbDownButton.setBackgroundResource(R.drawable.thumb_down_amber);
} else if (expense.getMyVote().equals("null")) {
holder.thumbUpButton.setBackgroundResource(R.drawable.thumb_up_black);
holder.thumbDownButton.setBackgroundResource(R.drawable.thumb_down_black);
}
}
}
use of com.polito.mad17.madmax.entities.CropCircleTransformation in project MadMax by deviz92.
the class VotersViewAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(final VotersViewAdapter.ItemVotersViewHolder holder, int position) {
if (position == (mData.size() - 1)) {
Log.d(TAG, "item.getKey().equals(\"nullGroup\")");
holder.nameTextView.setText("");
holder.voteTextView.setVisibility(View.GONE);
} else {
Map.Entry<String, User> item = getItem(position);
String photo = item.getValue().getProfileImage();
if (photo != null && !photo.equals("")) {
Glide.with(layoutInflater.getContext()).load(photo).centerCrop().bitmapTransform(new CropCircleTransformation(layoutInflater.getContext())).diskCacheStrategy(DiskCacheStrategy.ALL).into(holder.imageView);
} else {
Glide.with(layoutInflater.getContext()).load(R.drawable.user_default).centerCrop().bitmapTransform(new CropCircleTransformation(layoutInflater.getContext())).diskCacheStrategy(DiskCacheStrategy.ALL).into(holder.imageView);
}
holder.nameTextView.setText(item.getValue().getName() + " " + item.getValue().getSurname());
Log.d(TAG, "vote " + item.getValue().getVote());
if (item.getValue().getVote().equals("yes")) {
holder.voteTextView.setVisibility(View.VISIBLE);
holder.voteTextView.setBackgroundResource(R.drawable.thumb_up_teal);
} else if (item.getValue().getVote().equals("no")) {
holder.voteTextView.setVisibility(View.VISIBLE);
holder.voteTextView.setBackgroundResource(R.drawable.thumb_down_amber);
} else if (item.getValue().getVote().equals("null")) {
holder.voteTextView.setVisibility(View.GONE);
}
}
}
use of com.polito.mad17.madmax.entities.CropCircleTransformation in project MadMax by deviz92.
the class GroupsViewAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(final RecyclerView.ViewHolder holder, int position) {
final ItemGroupViewHolder groupViewHolder = (ItemGroupViewHolder) holder;
Map.Entry<String, Group> item = getItem(position);
if (position == (mData.size() - 1)) {
Log.d(TAG, "item.getKey().equals(\"nullGroup\")");
groupViewHolder.imageView.setVisibility(View.GONE);
groupViewHolder.nameTextView.setText("");
groupViewHolder.balanceTextTextView.setText("");
groupViewHolder.balanceTextView.setText("");
} else {
Log.d(TAG, "item ID " + item.getKey() + " item name " + item.getValue().getName());
// String p = groups.get(String.valueOf(position)).getImage();
groupViewHolder.imageView.setVisibility(View.VISIBLE);
String p = item.getValue().getImage();
if (p != null && !p.equals("noImage")) {
Log.d(TAG, "Image not null " + p);
Glide.with(layoutInflater.getContext()).load(p).centerCrop().bitmapTransform(new CropCircleTransformation(layoutInflater.getContext())).diskCacheStrategy(DiskCacheStrategy.ALL).into(groupViewHolder.imageView);
} else {
Glide.with(layoutInflater.getContext()).load(R.drawable.group_default).centerCrop().bitmapTransform(new CropCircleTransformation(layoutInflater.getContext())).diskCacheStrategy(DiskCacheStrategy.ALL).into(groupViewHolder.imageView);
}
groupViewHolder.nameTextView.setText(item.getValue().getName());
// mydebt = mio debito con il gruppo
String groupname = item.getValue().getName();
totBalances = item.getValue().getCurrencyBalances();
SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(context);
String defaultCurrency = sharedPref.getString(SettingsFragment.DEFAULT_CURRENCY, "");
Boolean multipleCurrencies = false;
Double shownBal;
String shownCurr;
if (groupname.equals("fff") || groupname.equals("Regalo")) {
Log.d(TAG, "sii");
}
Log.d(TAG, "callingActivity " + callingActivity);
if (!callingActivity.equals("FriendDetailActivity") && !callingActivity.equals("ChooseGroupActivity")) {
if (totBalances != null) {
groupViewHolder.balanceTextTextView.setVisibility(View.VISIBLE);
groupViewHolder.balanceTextView.setVisibility(View.VISIBLE);
for (Map.Entry<String, Double> entry : totBalances.entrySet()) {
Log.d(TAG, "Bilancio in " + groupname + " : " + entry.getValue() + " " + entry.getKey());
}
if (!totBalances.isEmpty()) {
// If there is more than one currency
if (totBalances.size() > 1) {
multipleCurrencies = true;
} else // If there is just one currency
{
multipleCurrencies = false;
}
if (totBalances.containsKey(defaultCurrency)) {
shownBal = totBalances.get(defaultCurrency);
shownCurr = defaultCurrency;
} else {
shownCurr = (String) totBalances.keySet().toArray()[0];
shownBal = totBalances.get(shownCurr);
}
// Print balance
if (shownBal > 0) {
groupViewHolder.balanceTextTextView.setText(R.string.you_should_receive);
groupViewHolder.balanceTextTextView.setTextColor(ContextCompat.getColor(context, R.color.colorAccent));
if (multipleCurrencies)
groupViewHolder.balanceTextView.setText(df.format(shownBal) + " " + shownCurr + "*");
else
groupViewHolder.balanceTextView.setText(df.format(shownBal) + " " + shownCurr);
groupViewHolder.balanceTextView.setTextColor(ContextCompat.getColor(context, R.color.colorAccent));
} else if (shownBal < 0) {
groupViewHolder.balanceTextTextView.setText(R.string.you_owe);
groupViewHolder.balanceTextTextView.setTextColor(ContextCompat.getColor(context, R.color.colorPrimaryDark));
if (multipleCurrencies)
groupViewHolder.balanceTextView.setText(df.format(Math.abs(shownBal)) + " " + shownCurr + "*");
else
groupViewHolder.balanceTextView.setText(df.format(Math.abs(shownBal)) + " " + shownCurr);
groupViewHolder.balanceTextView.setTextColor(ContextCompat.getColor(context, R.color.colorPrimaryDark));
} else if (shownBal == 0) {
groupViewHolder.balanceTextTextView.setText(R.string.no_debts);
groupViewHolder.balanceTextTextView.setTextColor(ContextCompat.getColor(context, R.color.colorSecondaryText));
groupViewHolder.balanceTextView.setText("0 " + defaultCurrency);
groupViewHolder.balanceTextView.setTextColor(ContextCompat.getColor(context, R.color.colorSecondaryText));
}
}
groupViewHolder.balanceTextTextView.setVisibility(View.VISIBLE);
groupViewHolder.balanceTextView.setVisibility(View.VISIBLE);
} else // If there are no balances in the map
{
groupViewHolder.balanceTextTextView.setText(R.string.no_debts);
groupViewHolder.balanceTextTextView.setTextColor(ContextCompat.getColor(context, R.color.colorSecondaryText));
groupViewHolder.balanceTextView.setText("0 " + defaultCurrency);
groupViewHolder.balanceTextView.setTextColor(ContextCompat.getColor(context, R.color.colorSecondaryText));
groupViewHolder.balanceTextTextView.setVisibility(View.VISIBLE);
groupViewHolder.balanceTextView.setVisibility(View.VISIBLE);
}
}
if (callingActivity.equals(DetailFragment.class.getSimpleName())) {
groupViewHolder.balanceTextTextView.setVisibility(View.GONE);
groupViewHolder.balanceTextView.setVisibility(View.GONE);
}
/*
else
{
groupViewHolder.balanceTextTextView.setVisibility(View.GONE);
groupViewHolder.balanceTextView.setVisibility(View.GONE);
}
*/
// check if there are expenses with other currencies than the default
/*Boolean defaultCurrencyExpense = false;
Boolean otherCurrenciesPresent = false;
Double groupBalanceDefaultCurrency = 0.0d;
HashMap<String, Double> otherCurrenciesBalance = new HashMap<>();
HashMap<String, Expense> groupExpenses = item.getValue().getExpenses();
if(groupExpenses != null) {
for (Map.Entry<String, Expense> expenseEntry : groupExpenses.entrySet()) {
String currentCurrency = expenseEntry.getValue().getCurrency();
if (currentCurrency.equals(defaultCurrency)) {
groupBalanceDefaultCurrency += expenseEntry.getValue().getAmount();
defaultCurrencyExpense = true;
} else {
otherCurrenciesPresent = true;
if (otherCurrenciesBalance.containsKey(currentCurrency)) {
Double currentBalance = otherCurrenciesBalance.get(currentCurrency);
currentBalance += otherCurrenciesBalance.get(currentCurrency);
otherCurrenciesBalance.put(currentCurrency, currentBalance);
} else {
otherCurrenciesBalance.put(currentCurrency, expenseEntry.getValue().getAmount());
}
}
}
if (defaultCurrencyExpense) {
if (groupBalanceDefaultCurrency == null) {
groupViewHolder.balanceTextTextView.setText("");
groupViewHolder.balanceTextView.setText("");
return;
}
if (groupBalanceDefaultCurrency > 0) {
groupViewHolder.balanceTextTextView.setText(R.string.credit_of);
groupViewHolder.balanceTextTextView.setTextColor(ContextCompat.getColor(context, R.color.colorPrimaryDark));
String balance = df.format(Math.abs(groupBalanceDefaultCurrency)) + " " + defaultCurrency;
if (otherCurrenciesPresent) {
balance += " *";
}
groupViewHolder.balanceTextView.setText(balance);
groupViewHolder.balanceTextView.setTextColor(ContextCompat.getColor(context, R.color.colorPrimaryDark));
} else {
if (groupBalanceDefaultCurrency < 0) {
groupViewHolder.balanceTextTextView.setText(R.string.debt_of);
groupViewHolder.balanceTextTextView.setTextColor(ContextCompat.getColor(context, R.color.colorAccent));
String balance = df.format(Math.abs(groupBalanceDefaultCurrency)) + " " + defaultCurrency;
if (otherCurrenciesPresent) {
balance += " *";
}
groupViewHolder.balanceTextView.setText(balance);
groupViewHolder.balanceTextView.setTextColor(ContextCompat.getColor(context, R.color.colorAccent));
} else if (!otherCurrenciesPresent) {
groupViewHolder.balanceTextTextView.setText(R.string.no_debts);
groupViewHolder.balanceTextTextView.setTextColor(ContextCompat.getColor(context, R.color.colorSecondaryText));
groupViewHolder.balanceTextView.setText("0.0 " + defaultCurrency);
groupViewHolder.balanceTextView.setTextColor(ContextCompat.getColor(context, R.color.colorAccent));
} else {
Map.Entry<String, Double> entry = otherCurrenciesBalance.entrySet().iterator().next();
if (entry.getValue() > 0) {
groupViewHolder.balanceTextTextView.setText(R.string.credit_of);
groupViewHolder.balanceTextTextView.setTextColor(ContextCompat.getColor(context, R.color.colorPrimaryDark));
String balance = df.format(Math.abs(entry.getValue())) + " " + entry.getKey();
groupViewHolder.balanceTextView.setText(balance);
groupViewHolder.balanceTextView.setTextColor(ContextCompat.getColor(context, R.color.colorPrimaryDark));
} else {
groupViewHolder.balanceTextTextView.setText(R.string.debt_of);
groupViewHolder.balanceTextTextView.setTextColor(ContextCompat.getColor(context, R.color.colorAccent));
String balance = df.format(Math.abs(entry.getValue())) + " " + entry.getKey();
groupViewHolder.balanceTextView.setText(balance);
groupViewHolder.balanceTextView.setTextColor(ContextCompat.getColor(context, R.color.colorAccent));
}
}
}
}
}
else
{
groupViewHolder.balanceTextTextView.setText(R.string.no_debts);
groupViewHolder.balanceTextTextView.setTextColor(ContextCompat.getColor(context, R.color.colorSecondaryText));
groupViewHolder.balanceTextView.setText("0.0 " + defaultCurrency);
groupViewHolder.balanceTextView.setTextColor(ContextCompat.getColor(context, R.color.colorAccent));
}*/
}
}
Aggregations