use of com.squareup.picasso.RequestCreator in project MaterialList by dexafree.
the class MainActivity method getRandomCard.
private Card getRandomCard(final int position) {
String title = "Card number " + (position + 1);
String description = "Lorem ipsum dolor sit amet";
switch(position % 7) {
case 0:
{
return new Card.Builder(this).setTag("SMALL_IMAGE_CARD").setDismissible().withProvider(new CardProvider()).setLayout(R.layout.material_small_image_card).setTitle(title).setDescription(description).setDrawable(R.drawable.sample_android).setDrawableConfiguration(new CardProvider.OnImageConfigListener() {
@Override
public void onImageConfigure(@NonNull final RequestCreator requestCreator) {
requestCreator.rotate(position * 90.0f).resize(150, 150).centerCrop();
}
}).endConfig().build();
}
case 1:
{
return new Card.Builder(this).setTag("BIG_IMAGE_CARD").withProvider(new CardProvider()).setLayout(R.layout.material_big_image_card_layout).setTitle(title).setSubtitle(description).setSubtitleGravity(Gravity.END).setDrawable("https://assets-cdn.github.com/images/modules/logos_page/GitHub-Mark.png").setDrawableConfiguration(new CardProvider.OnImageConfigListener() {
@Override
public void onImageConfigure(@NonNull final RequestCreator requestCreator) {
requestCreator.rotate(position * 45.0f).resize(200, 200).centerCrop();
}
}).endConfig().build();
}
case 2:
{
final CardProvider provider = new Card.Builder(this).setTag("BASIC_IMAGE_BUTTON_CARD").setDismissible().withProvider(new CardProvider<>()).setLayout(R.layout.material_basic_image_buttons_card_layout).setTitle(title).setTitleGravity(Gravity.END).setDescription(description).setDescriptionGravity(Gravity.END).setDrawable(R.drawable.dog).setDrawableConfiguration(new CardProvider.OnImageConfigListener() {
@Override
public void onImageConfigure(@NonNull RequestCreator requestCreator) {
requestCreator.fit();
}
}).addAction(R.id.left_text_button, new TextViewAction(this).setText("left").setTextResourceColor(R.color.black_button).setListener(new OnActionClickListener() {
@Override
public void onActionClicked(View view, Card card) {
Toast.makeText(mContext, "You have pressed the left button", Toast.LENGTH_SHORT).show();
card.getProvider().setTitle("CHANGED ON RUNTIME");
}
})).addAction(R.id.right_text_button, new TextViewAction(this).setText("right").setTextResourceColor(R.color.orange_button).setListener(new OnActionClickListener() {
@Override
public void onActionClicked(View view, Card card) {
Toast.makeText(mContext, "You have pressed the right button on card " + card.getProvider().getTitle(), Toast.LENGTH_SHORT).show();
card.dismiss();
}
}));
if (position % 2 == 0) {
provider.setDividerVisible(true);
}
return provider.endConfig().build();
}
case 3:
{
final CardProvider provider = new Card.Builder(this).setTag("BASIC_BUTTONS_CARD").setDismissible().withProvider(new CardProvider()).setLayout(R.layout.material_basic_buttons_card).setTitle(title).setDescription(description).addAction(R.id.left_text_button, new TextViewAction(this).setText("left").setTextResourceColor(R.color.black_button).setListener(new OnActionClickListener() {
@Override
public void onActionClicked(View view, Card card) {
Toast.makeText(mContext, "You have pressed the left button", Toast.LENGTH_SHORT).show();
}
})).addAction(R.id.right_text_button, new TextViewAction(this).setText("right").setTextResourceColor(R.color.accent_material_dark).setListener(new OnActionClickListener() {
@Override
public void onActionClicked(View view, Card card) {
Toast.makeText(mContext, "You have pressed the right button", Toast.LENGTH_SHORT).show();
}
}));
if (position % 2 == 0) {
provider.setDividerVisible(true);
}
return provider.endConfig().build();
}
case 4:
{
final CardProvider provider = new Card.Builder(this).setTag("WELCOME_CARD").setDismissible().withProvider(new CardProvider()).setLayout(R.layout.material_welcome_card_layout).setTitle("Welcome Card").setTitleColor(Color.WHITE).setDescription("I am the description").setDescriptionColor(Color.WHITE).setSubtitle("My subtitle!").setSubtitleColor(Color.WHITE).setBackgroundColor(Color.BLUE).addAction(R.id.ok_button, new WelcomeButtonAction(this).setText("Okay!").setTextColor(Color.WHITE).setListener(new OnActionClickListener() {
@Override
public void onActionClicked(View view, Card card) {
Toast.makeText(mContext, "Welcome!", Toast.LENGTH_SHORT).show();
}
}));
if (position % 2 == 0) {
provider.setBackgroundResourceColor(android.R.color.background_dark);
}
return provider.endConfig().build();
}
case 5:
{
ArrayAdapter<String> adapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1);
adapter.add("Hello");
adapter.add("World");
adapter.add("!");
return new Card.Builder(this).setTag("LIST_CARD").setDismissible().withProvider(new ListCardProvider()).setLayout(R.layout.material_list_card_layout).setTitle("List Card").setDescription("Take a list").setAdapter(adapter).endConfig().build();
}
default:
{
final CardProvider provider = new Card.Builder(this).setTag("BIG_IMAGE_BUTTONS_CARD").setDismissible().withProvider(new CardProvider()).setLayout(R.layout.material_image_with_buttons_card).setTitle(title).setDescription(description).setDrawable(R.drawable.photo).addAction(R.id.left_text_button, new TextViewAction(this).setText("add card").setTextResourceColor(R.color.black_button).setListener(new OnActionClickListener() {
@Override
public void onActionClicked(View view, Card card) {
Log.d("ADDING", "CARD");
mListView.getAdapter().add(generateNewCard());
Toast.makeText(mContext, "Added new card", Toast.LENGTH_SHORT).show();
}
})).addAction(R.id.right_text_button, new TextViewAction(this).setText("right button").setTextResourceColor(R.color.accent_material_dark).setListener(new OnActionClickListener() {
@Override
public void onActionClicked(View view, Card card) {
Toast.makeText(mContext, "You have pressed the right button", Toast.LENGTH_SHORT).show();
}
}));
if (position % 2 == 0) {
provider.setDividerVisible(true);
}
return provider.endConfig().build();
}
}
}
use of com.squareup.picasso.RequestCreator in project scissors by lyft.
the class PicassoBitmapLoader method load.
@Override
public void load(@Nullable Object model, @NonNull ImageView imageView) {
final RequestCreator requestCreator;
if (model instanceof Uri || model == null) {
requestCreator = picasso.load((Uri) model);
} else if (model instanceof String) {
requestCreator = picasso.load((String) model);
} else if (model instanceof File) {
requestCreator = picasso.load((File) model);
} else if (model instanceof Integer) {
requestCreator = picasso.load((Integer) model);
} else {
throw new IllegalArgumentException("Unsupported model " + model);
}
requestCreator.skipMemoryCache().transform(transformation).into(imageView);
}
Aggregations