Skip to content

Commit

Permalink
code clean. example implemented.
Browse files Browse the repository at this point in the history
  • Loading branch information
oleg-vasiliev committed Mar 31, 2017
1 parent 9dcacb3 commit 70e1362
Show file tree
Hide file tree
Showing 71 changed files with 475 additions and 311 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Create a branch for your edits.
Be clear about what problem is occurring and how someone can recreate that problem or why your feature will help. Then be equally as clear about the steps you took to make your changes.
It’s best to test. Run your changes against any existing tests if they exist and create new ones when needed. Whether tests exist or not, make sure your changes don’t break the existing project.
Include screenshots of the before and after if your changes include differences in HTML/CSS. Drag and drop the images into the body of your pull request.
Contribute in the style of the project to the best of your abilities. This may mean using indents, semi colons or comments differently than you would in your own repository, but makes it easier for the maintainer to merge, others to understand and maintain in the future.
Contribute in the style of the project to the best of your abilities. This may mean using indents, semi colons or listItems differently than you would in your own repository, but makes it easier for the maintainer to merge, others to understand and maintain in the future.

#### Open Pull Requests

Expand Down
Original file line number Diff line number Diff line change
@@ -1,33 +1,34 @@
package com.ramotion.expandingcollection.examples.simple;

import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.support.annotation.DrawableRes;

import com.ramotion.expandingcollection.ECCardData;

import java.util.Collection;
import java.util.List;
import java.util.Random;

public class PagerCardDataPOJO implements ECCardData<CommentPOJO> {
public class CardData implements ECCardData<Comment> {

private String headTitle;

private BitmapDrawable headBgImageDrawable;
private BitmapDrawable mainBgImageDrawable;
private BitmapDrawable headBackgroundDrawable;
private BitmapDrawable mainBackgroundDrawable;

private Integer headBgImageDrawableResource;
private Integer mainBgImageDrawableResource;
private Integer headBackgroundResource;
private Integer mainBackgroundResource;

@DrawableRes
private Integer personPicture;

private Drawable personPicture;
private String personName;
private String personMessage;
private int personViewsCount;
private int personCommentsCount;
private int personLikesCount;
private List<CommentPOJO> comments;
private List<Comment> listItems;

public PagerCardDataPOJO() {
public CardData() {
Random rnd = new Random();
this.personViewsCount = 50 + rnd.nextInt(950);
this.personCommentsCount = 35 + rnd.nextInt(170);
Expand All @@ -42,47 +43,43 @@ public void setHeadTitle(String headTitle) {
this.headTitle = headTitle;
}

@Override
public BitmapDrawable getHeadBgImageDrawable() {
return headBgImageDrawable;
public BitmapDrawable getHeadBackgroundDrawable() {
return headBackgroundDrawable;
}

public void setHeadBgImageDrawable(BitmapDrawable headBgImageDrawable) {
this.headBgImageDrawable = headBgImageDrawable;
public void setHeadBackgroundDrawable(BitmapDrawable headBackgroundDrawable) {
this.headBackgroundDrawable = headBackgroundDrawable;
}

@Override
public BitmapDrawable getMainBgImageDrawable() {
return mainBgImageDrawable;
public BitmapDrawable getMainBackgroundDrawable() {
return mainBackgroundDrawable;
}

public void setMainBgImageDrawable(BitmapDrawable mainBgImageDrawable) {
this.mainBgImageDrawable = mainBgImageDrawable;
public void setMainBackgroundDrawable(BitmapDrawable mainBackgroundDrawable) {
this.mainBackgroundDrawable = mainBackgroundDrawable;
}

@Override
public Integer getHeadBgImageDrawableResource() {
return headBgImageDrawableResource;
public Integer getHeadBackgroundResource() {
return headBackgroundResource;
}

public void setHeadBgImageDrawableResource(Integer headBgImageDrawableResource) {
this.headBgImageDrawableResource = headBgImageDrawableResource;
public void setHeadBackgroundResource(Integer headBackgroundResource) {
this.headBackgroundResource = headBackgroundResource;
}

@Override
public Integer getMainBgImageDrawableResource() {
return mainBgImageDrawableResource;
public Integer getMainBackgroundResource() {
return mainBackgroundResource;
}

public void setMainBgImageDrawableResource(Integer mainBgImageDrawableResource) {
this.mainBgImageDrawableResource = mainBgImageDrawableResource;
public void setMainBackgroundResource(Integer mainBackgroundResource) {
this.mainBackgroundResource = mainBackgroundResource;
}

public Drawable getPersonPicture() {
public Integer getPersonPicture() {
return personPicture;
}

public void setPersonPicture(Drawable personPicture) {
public void setPersonPicture(Integer personPicture) {
this.personPicture = personPicture;
}

Expand Down Expand Up @@ -127,11 +124,11 @@ public void setPersonLikesCount(int personLikesCount) {
}

@Override
public List<CommentPOJO> getComments() {
return comments;
public List<Comment> getListItems() {
return listItems;
}

public void setComments(List<CommentPOJO> comments) {
this.comments = comments;
public void setListItems(List<Comment> listItems) {
this.listItems = listItems;
}
}
Original file line number Diff line number Diff line change
@@ -1,26 +1,24 @@
package com.ramotion.expandingcollection.examples.simple;

import android.graphics.drawable.Drawable;

public class CommentPOJO {
private Drawable commentPersonPicture;
public class Comment {
private Integer commentPersonPictureRes;
private String commentPersonName;
private String commentText;
private String commentDate;

public CommentPOJO(Drawable commentPersonPicture, String commentPersonName, String commentText, String commentDate) {
this.commentPersonPicture = commentPersonPicture;
public Comment(Integer commentPersonPictureRes, String commentPersonName, String commentText, String commentDate) {
this.commentPersonPictureRes = commentPersonPictureRes;
this.commentPersonName = commentPersonName;
this.commentText = commentText;
this.commentDate = commentDate;
}

public Drawable getCommentPersonPicture() {
return commentPersonPicture;
public Integer getCommentPersonPictureRes() {
return commentPersonPictureRes;
}

public void setCommentPersonPicture(Drawable commentPersonPicture) {
this.commentPersonPicture = commentPersonPicture;
public void setCommentPersonPictureRes(Integer commentPersonPictureRes) {
this.commentPersonPictureRes = commentPersonPictureRes;
}

public String getCommentPersonName() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@
import android.widget.ImageView;
import android.widget.TextView;

import com.ramotion.expandingcollection.ECCardContentListAdapter;
import com.ramotion.expandingcollection.ECCardContentListItemAdapter;

import java.util.List;

import ramotion.com.expandingcollection.examples.simple.R;

public class CommentsArrayAdapter extends ECCardContentListAdapter<CommentPOJO> {
public class CommentArrayAdapter extends ECCardContentListItemAdapter<Comment> {

public CommentsArrayAdapter(@NonNull Context context, @LayoutRes int resource, @NonNull List<CommentPOJO> objects) {
public CommentArrayAdapter(@NonNull Context context, @LayoutRes int resource, @NonNull List<Comment> objects) {
super(context, resource, objects);
}

Expand All @@ -39,6 +39,7 @@ public View getView(int position, @Nullable View convertView, @NonNull ViewGroup
rowView = inflater.inflate(R.layout.list_element, null);
// configure view holder
viewHolder = new ViewHolder();
viewHolder.date = (TextView) rowView.findViewById(R.id.firstLineDate);
viewHolder.line1 = (TextView) rowView.findViewById(R.id.firstLine);
viewHolder.line2 = (TextView) rowView.findViewById(R.id.secondLine);
viewHolder.icon = (ImageView) rowView.findViewById(R.id.icon);
Expand All @@ -47,18 +48,18 @@ public View getView(int position, @Nullable View convertView, @NonNull ViewGroup
viewHolder = (ViewHolder) rowView.getTag();
}

CommentPOJO objectItem = getItem(position);

Comment objectItem = getItem(position);
if (objectItem != null) {
viewHolder.line1.setText(objectItem.getCommentPersonName() + ":");
viewHolder.line2.setText(objectItem.getCommentText());
viewHolder.icon.setImageDrawable(objectItem.getCommentPersonPicture());
viewHolder.date.setText(objectItem.getCommentDate());
viewHolder.icon.setImageResource(objectItem.getCommentPersonPictureRes());
}

return rowView;
}

static class ViewHolder {
TextView date;
TextView line1;
TextView line2;
ImageView icon;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
package com.ramotion.expandingcollection.examples.simple;

import com.ramotion.expandingcollection.ECCardData;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Random;

import ramotion.com.expandingcollection.examples.simple.R;

public class ExampleDataset {

private List<ECCardData> dataset;
private List<Comment> comments;

public ExampleDataset() {
dataset = new ArrayList<>(5);
comments = Arrays.asList(
new Comment(R.drawable.aaron_bradley, "Aaron Bradley", "When the sensor experiments for deep space, all mermaids accelerate mysterious, vital moons.", "jan 12, 2014"),
new Comment(R.drawable.barry_allen, "Barry Allen", "It is a cold powerdrain, sir.", "jun 1, 2015"),
new Comment(R.drawable.bella_holmes, "Bella Holmes", "Particle of a calm shield, control the alignment!", "sep 21, 1937"),
new Comment(R.drawable.caroline_shaw, "Caroline Shaw", "The human kahless quickly promises the phenomenan.", "may 23, 1967"),
new Comment(R.drawable.connor_graham, "Connor Graham", "Ionic cannon at the infinity room was the sensor of voyage, imitated to a dead pathway.", "sep 1, 1972"),
new Comment(R.drawable.deann_hunt, "Deann Hunt", "Vital particles, to the port.", "aug 13, 1995"),
new Comment(R.drawable.ella_cole, "Ella Cole", "Stars fly with hypnosis at the boldly infinity room!", "nov 18, 1952"),
new Comment(R.drawable.jayden_shaw, "Jayden Shaw", "Hypnosis, definition, and powerdrain.", "apr 1, 2013"),
new Comment(R.drawable.jerry_carrol, "Jerry Carrol", "When the queen experiments for nowhere, all particles control reliable, cold captains.", "nov 14, 1964"),
new Comment(R.drawable.lena_lucas, "Lena Lukas", "When the c-beam experiments for astral city, all cosmonauts acquire remarkable, virtual lieutenant commanders.", "may 4, 1965"),
new Comment(R.drawable.leonrd_kim, "Leonard Kim", "Starships walk with love at the cold parallel universe!", "jul 3, 1974"),
new Comment(R.drawable.marc_baker, "Mark Baker", "Friendship at the bridge that is when quirky green people yell.", "dec 24, 1989"));


CardData item5 = new CardData();
item5.setMainBackgroundResource(R.drawable.attractions);
item5.setHeadBackgroundResource(R.drawable.attractions_head);
item5.setHeadTitle("Attractions");
item5.setPersonMessage("Usus de bassus buxum, desiderium index!");
item5.setPersonName("Marjorie Ellis");
item5.setPersonPicture(R.drawable.marjorie_ellis);
item5.setListItems(prepareCommentsArray());
dataset.add(item5);

CardData item4 = new CardData();
item4.setMainBackgroundResource(R.drawable.city_scape);
item4.setHeadBackgroundResource(R.drawable.city_scape_head);
item4.setHeadTitle("City Scape");
item4.setPersonMessage("Solems manducare, tanquam neuter verpa.");
item4.setPersonName("Mattew Jordan");
item4.setPersonPicture(R.drawable.mattew_jordan);
item4.setListItems(prepareCommentsArray());
dataset.add(item4);

CardData item3 = new CardData();
item3.setMainBackgroundResource(R.drawable.cuisine);
item3.setHeadBackgroundResource(R.drawable.cuisine_head);
item3.setHeadTitle("Cuisine");
item3.setPersonMessage("Magnum lacteas ducunt ad orexis.");
item3.setPersonName("Ross Rodriguez");
item3.setPersonPicture(R.drawable.ross_rodriguez);
item3.setListItems(prepareCommentsArray());
dataset.add(item3);

CardData item2 = new CardData();
item2.setMainBackgroundResource(R.drawable.nature);
item2.setHeadBackgroundResource(R.drawable.nature_head);
item2.setHeadTitle("Nature");
item2.setPersonName("Tina Caldwell");
item2.setPersonMessage("Nunquam perdere clabulare.");
item2.setListItems(prepareCommentsArray());
item2.setPersonPicture(R.drawable.tina_caldwell);
dataset.add(item2);

CardData item1 = new CardData();
item1.setMainBackgroundResource(R.drawable.night_life);
item1.setHeadBackgroundResource(R.drawable.night_life_head);
item1.setHeadTitle("Night Life");
item1.setPersonMessage("Cur adelphis studere?");
item1.setPersonName("Wallace Sutton");
item1.setPersonPicture(R.drawable.wallace_sutton);
item1.setListItems(prepareCommentsArray());
dataset.add(item1);

}

public List<ECCardData> getDataset() {
Collections.shuffle(dataset);
return dataset;
}

private List<Comment> prepareCommentsArray() {
Random random = new Random();
Collections.shuffle(comments);
return comments.subList(0, 6 + random.nextInt(5));
}
}
Loading

0 comments on commit 70e1362

Please sign in to comment.