use of com.polito.mad17.madmax.entities.CropCircleTransformation in project MadMax by deviz92.
the class HashMapGroupsAdapter method getView.
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
final View result;
if (convertView == null) {
result = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_item, parent, false);
} else {
result = convertView;
}
TextView name = (TextView) result.findViewById(R.id.tv_sender);
if (position == (mData.size() - 1)) {
Log.d(TAG, "item.getKey().equals(\"nullGroup\")");
// groupViewHolder.imageView.
name.setText("");
} else {
Map.Entry<String, Group> item = getItem(position);
name.setText(item.getValue().getName());
ImageView img_photo = (ImageView) result.findViewById(R.id.img_photo);
Glide.with(parent.getContext()).load(item.getValue().getImage()).centerCrop().bitmapTransform(new CropCircleTransformation(parent.getContext())).diskCacheStrategy(DiskCacheStrategy.ALL).into(img_photo);
Log.d("Adapter image: ", item.getValue().getImage());
result.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String groupID = getItem(position).getKey();
}
});
}
return result;
}
use of com.polito.mad17.madmax.entities.CropCircleTransformation in project MadMax by deviz92.
the class ExpenseEdit method onCreate.
@Override
@TargetApi(23)
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.edit_expense);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
expenseImageView = (ImageView) this.findViewById(R.id.expense_image);
expenseBillView = (ImageView) this.findViewById(R.id.expense_bill);
expenseDescriptionView = (EditText) this.findViewById(R.id.expense_description);
expenseAmountView = (EditText) this.findViewById(R.id.expense_amount);
expenseCurrencyView = (Spinner) this.findViewById(R.id.expense_currency);
saveButton = (Button) this.findViewById(R.id.btn_save);
// creating spinner for currencies
final ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.currencies, android.R.layout.simple_spinner_item);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
expenseCurrencyView.setAdapter(adapter);
Intent intent = getIntent();
String expenseID = intent.getStringExtra("expenseID");
if (intent.getStringExtra("EXPENSE_TYPE").equals("EXPENSE_EDIT")) {
EXPENSE_TYPE = Event.EventType.EXPENSE_EDIT;
expense_type = "expenses";
} else {
EXPENSE_TYPE = Event.EventType.PENDING_EXPENSE_EDIT;
expense_type = "proposedExpenses";
}
databaseReference.child(expense_type).child(expenseID).addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
expense = new Expense();
expense.setID(dataSnapshot.getKey());
expense.setDescription(dataSnapshot.child("description").getValue(String.class));
expense.setCurrency(dataSnapshot.child("currency").getValue(String.class));
expense.setExpensePhoto(dataSnapshot.child("expensePhoto").getValue(String.class));
expense.setBillPhoto(dataSnapshot.child("billPhoto").getValue(String.class));
final String groupID = dataSnapshot.child("groupID").getValue(String.class);
expenseDescriptionView.setText(expense.getDescription());
if (EXPENSE_TYPE.equals(Event.EventType.PENDING_EXPENSE_EDIT)) {
expense.setAmount(dataSnapshot.child("amount").getValue(Double.class));
expenseAmountView.setText(String.valueOf(expense.getAmount()));
}
// set the defaultCurrency value for the spinner based on the user preferences
int spinnerPosition = adapter.getPosition(expense.getCurrency());
expenseCurrencyView.setSelection(spinnerPosition);
// progressDialog = new ProgressDialog(ProfileEdit.this);
// loading expense photo (if present)
String expenseImage = expense.getExpensePhoto();
if (expenseImage != null && !expenseImage.equals("")) {
// Loading image
Glide.with(getApplicationContext()).load(expenseImage).centerCrop().diskCacheStrategy(DiskCacheStrategy.ALL).into(expenseImageView);
} else {
// Loading image
expenseImageView.setImageResource(R.drawable.add_photo);
/* Glide.with(getApplicationContext()).load(R.drawable.add_photo)
.centerCrop()
//.bitmapTransform(new CropCircleTransformation(this))
.diskCacheStrategy(DiskCacheStrategy.ALL)
.into(expenseImageView);*/
}
expenseImageView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Log.i(TAG, "expense image clicked");
if (MainActivity.shouldAskPermission()) {
String[] perms = { "android.permission.READ_EXTERNAL_STORAGE" };
int permsRequestCode = 200;
requestPermissions(perms, permsRequestCode);
}
// allow to the user the choose image
Intent intent = new Intent();
// Show only images, no videos or anything else
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
// Always show the chooser (if there are multiple options available)
startActivityForResult(Intent.createChooser(intent, "Select picture"), PICK_IMAGE_REQUEST);
// now see onActivityResult
}
});
// loading expense bill (if present)
String expenseBill = expense.getBillPhoto();
if (expenseBill != null && !expenseBill.equals("")) {
// Loading image
Glide.with(getApplicationContext()).load(expenseBill).centerCrop().diskCacheStrategy(DiskCacheStrategy.ALL).into(expenseBillView);
} else {
// Loading image
expenseImageView.setImageResource(R.drawable.add_photo);
/*Glide.with(getApplicationContext()).load(R.drawable.add_photo)
.centerCrop()
//.bitmapTransform(new CropCircleTransformation(this))
.diskCacheStrategy(DiskCacheStrategy.ALL)
.into(expenseBillView);*/
}
expenseBillView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Log.i(TAG, "expense bill clicked");
if (MainActivity.shouldAskPermission()) {
String[] perms = { "android.permission.READ_EXTERNAL_STORAGE" };
int permsRequestCode = 200;
requestPermissions(perms, permsRequestCode);
}
// allow to the user the choose image
Intent intent = new Intent();
// Show only images, no videos or anything else
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
// Always show the chooser (if there are multiple options available)
startActivityForResult(Intent.createChooser(intent, "Select picture"), PICK_BILL_REQUEST);
// now see onActivityResult
}
});
saveButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Log.i(TAG, "save clicked");
if (updateExpense(expense)) {
Toast.makeText(ExpenseEdit.this, getString(R.string.saved), Toast.LENGTH_SHORT).show();
Intent intent;
if (EXPENSE_TYPE.equals(Event.EventType.EXPENSE_EDIT)) {
intent = new Intent(getApplicationContext(), ExpenseDetailActivity.class);
intent.putExtra("groupID", expense.getGroupID());
intent.putExtra("expenseID", expense.getID());
intent.putExtra("userID", MainActivity.getCurrentUser().getID());
} else {
intent = new Intent(getApplicationContext(), MainActivity.class);
intent.putExtra("currentFragment", 2);
}
startActivity(intent);
finish();
}
}
});
}
@Override
public void onCancelled(DatabaseError databaseError) {
Log.w(TAG, databaseError.getMessage());
}
});
}
use of com.polito.mad17.madmax.entities.CropCircleTransformation in project MadMax by deviz92.
the class ExpensesViewAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(final ItemExpensesViewHolder expensesViewHolder, int position) {
if (position == (expenses.size() - 1)) {
Log.d(TAG, "item.getKey().equals(\"nullGroup\")");
expensesViewHolder.imageView.setVisibility(View.INVISIBLE);
expensesViewHolder.nameTextView.setText("");
expensesViewHolder.balanceTextTextView.setText("");
expensesViewHolder.balanceTextView.setText("");
} else {
Expense expense = getItem(position).getValue();
Log.d(TAG, "item ID " + expense.getID() + " image " + expense.getExpensePhoto());
expensesViewHolder.imageView.setVisibility(View.VISIBLE);
if (expense.getExpensePhoto() != null && !expense.getExpensePhoto().equals("noImage")) {
Log.d(TAG, "Image not null");
Glide.with(layoutInflater.getContext()).load(expense.getExpensePhoto()).centerCrop().bitmapTransform(new CropCircleTransformation(layoutInflater.getContext())).diskCacheStrategy(DiskCacheStrategy.ALL).into(expensesViewHolder.imageView);
} else {
Glide.with(layoutInflater.getContext()).load(R.drawable.expense_default).centerCrop().bitmapTransform(new CropCircleTransformation(layoutInflater.getContext())).diskCacheStrategy(DiskCacheStrategy.ALL).into(expensesViewHolder.imageView);
}
expensesViewHolder.nameTextView.setText(expense.getDescription());
SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(context);
String defaultCurrency = sharedPref.getString(SettingsFragment.DEFAULT_CURRENCY, "");
Double expenseBalance = expense.getBalance();
String balance = Math.abs(expenseBalance) + " " + expense.getCurrency();
if (expenseBalance > 0) {
expensesViewHolder.balanceTextTextView.setText(R.string.credit_of);
expensesViewHolder.balanceTextTextView.setTextColor(ContextCompat.getColor(context, R.color.colorPrimaryDark));
expensesViewHolder.balanceTextView.setText(balance);
expensesViewHolder.balanceTextView.setTextColor(ContextCompat.getColor(context, R.color.colorPrimaryDark));
} else {
if (expenseBalance < 0) {
expensesViewHolder.balanceTextTextView.setText(R.string.debt_of);
expensesViewHolder.balanceTextTextView.setTextColor(ContextCompat.getColor(context, R.color.colorAccent));
expensesViewHolder.balanceTextView.setText(balance);
expensesViewHolder.balanceTextView.setTextColor(ContextCompat.getColor(context, R.color.colorAccent));
} else {
expensesViewHolder.balanceTextTextView.setText(R.string.no_debts);
expensesViewHolder.balanceTextTextView.setTextColor(ContextCompat.getColor(context, R.color.colorSecondaryText));
expensesViewHolder.balanceTextView.setText("0 " + defaultCurrency);
}
}
}
}
use of com.polito.mad17.madmax.entities.CropCircleTransformation in project MadMax by deviz92.
the class HashMapFriendsAdapter method getView.
@Override
public View getView(int position, View convertView, ViewGroup parent) {
final View result;
if (convertView == null) {
result = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_item, parent, false);
} else {
result = convertView;
}
Map.Entry<String, User> item = getItem(position);
TextView name = (TextView) result.findViewById(R.id.tv_sender);
TextView balanceText = (TextView) result.findViewById(R.id.tv_balance_text);
balanceText.setVisibility(View.INVISIBLE);
TextView balance = (TextView) result.findViewById(R.id.tv_balance);
balance.setVisibility(View.INVISIBLE);
name.setText(item.getValue().getName() + " " + item.getValue().getSurname());
ImageView photo = (ImageView) result.findViewById(R.id.img_photo);
// Loading profile image
Glide.with(parent.getContext()).load(item.getValue().getProfileImage()).placeholder(R.drawable.user_default).centerCrop().bitmapTransform(new CropCircleTransformation(parent.getContext())).diskCacheStrategy(DiskCacheStrategy.ALL).into(photo);
balance.setVisibility(View.GONE);
return result;
}
use of com.polito.mad17.madmax.entities.CropCircleTransformation in project MadMax by deviz92.
the class BasicActivity method loadNavHeader.
/* load navigation header menu info like profile image, name, email */
protected void loadNavHeader() {
// name and email
txtName.setText(getCurrentUser().getName() + " " + getCurrentUser().getSurname());
Log.d(TAG, "name: " + getCurrentUser().getName() + " - surname: " + getCurrentUser().getSurname());
txtWebsite.setText(getCurrentUser().getEmail());
Log.d(TAG, "email: " + getCurrentUser().getEmail());
// profile image
String profileImage = getCurrentUser().getProfileImage();
if (profileImage != null && !profileImage.equals("")) {
// Loading image
Glide.with(getApplicationContext()).load(profileImage).centerCrop().bitmapTransform(new CropCircleTransformation(this)).diskCacheStrategy(DiskCacheStrategy.ALL).into(imgProfile);
Log.d(TAG, "image url: " + MainActivity.getCurrentUser().getProfileImage());
} else {
// Loading image
Glide.with(this).load(R.drawable.user_default).centerCrop().bitmapTransform(new CropCircleTransformation(this)).diskCacheStrategy(DiskCacheStrategy.ALL).into(imgProfile);
}
}
Aggregations