forked from artem-zinnatullin/qualitymatters
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ff42c0e
commit 4ddebca
Showing
29 changed files
with
315 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
...rationTests/java/com/artemzin/qualitymatters/integration_tests/api/entities/ItemTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package com.artemzin.qualitymatters.integration_tests.api.entities; | ||
|
||
import com.artemzin.qualitymatters.QualityMattersRobolectricTestRunner; | ||
import com.artemzin.qualitymatters.api.entities.Item; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
|
||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
import java.io.IOException; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
@RunWith(QualityMattersRobolectricTestRunner.class) | ||
public class ItemTest { | ||
|
||
// Why test JSON serialization/deserialization? | ||
// 1. Update JSON libraries without worrying about breaking changes. | ||
// 2. Be sure that @JsonIgnore and similar annotations do not affect expected behavior (cc @karlicos). | ||
@Test | ||
public void fromJson() throws IOException { | ||
ObjectMapper objectMapper = QualityMattersRobolectricTestRunner.qualityMattersApp().applicationComponent().objectMapper(); | ||
|
||
Item item = objectMapper.readValue("{ " + | ||
"\"id\": \"test_id\", " + | ||
"\"image_preview_url\": \"some_url\"," + | ||
"\"title\": \"Test title\", " + | ||
"\"short_description\": \"Test short description\"" + | ||
"}", | ||
Item.class); | ||
|
||
assertThat(item.id()).isEqualTo("test_id"); | ||
assertThat(item.imagePreviewUrl()).isEqualTo("some_url"); | ||
assertThat(item.title()).isEqualTo("Test title"); | ||
assertThat(item.shortDescription()).isEqualTo("Test short description"); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
app/src/main/java/com/artemzin/qualitymatters/ui/adapters/ItemViewHolder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package com.artemzin.qualitymatters.ui.adapters; | ||
|
||
import android.support.annotation.NonNull; | ||
import android.support.v7.widget.RecyclerView; | ||
import android.view.View; | ||
import android.widget.ImageView; | ||
import android.widget.TextView; | ||
|
||
import com.artemzin.qualitymatters.R; | ||
import com.artemzin.qualitymatters.api.entities.Item; | ||
import com.squareup.picasso.Picasso; | ||
|
||
import butterknife.Bind; | ||
import butterknife.ButterKnife; | ||
|
||
class ItemViewHolder extends RecyclerView.ViewHolder { | ||
|
||
@NonNull | ||
private final Picasso picasso; | ||
|
||
@Bind(R.id.list_item_image_view) | ||
ImageView imageView; | ||
|
||
@Bind(R.id.list_item_title_text_view) | ||
TextView titleTextView; | ||
|
||
@Bind(R.id.list_item_short_description_text_view) | ||
TextView shortDescriptionTextView; | ||
|
||
public ItemViewHolder(@NonNull View itemView, @NonNull Picasso picasso) { | ||
super(itemView); | ||
this.picasso = picasso; | ||
ButterKnife.bind(this, itemView); | ||
} | ||
|
||
public void bind(@NonNull Item item) { | ||
picasso.load(item.imagePreviewUrl()).fit().centerCrop().into(imageView); | ||
titleTextView.setText(item.title()); | ||
shortDescriptionTextView.setText(item.shortDescription()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
app/src/main/java/com/artemzin/qualitymatters/ui/others/VerticalSpaceItemDecoration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.artemzin.qualitymatters.ui.others; | ||
|
||
import android.graphics.Rect; | ||
import android.support.annotation.NonNull; | ||
import android.support.v7.widget.RecyclerView; | ||
import android.view.View; | ||
|
||
public class VerticalSpaceItemDecoration extends RecyclerView.ItemDecoration { | ||
|
||
private final int verticalSpacePx; | ||
|
||
public VerticalSpaceItemDecoration(int verticalSpacePx) { | ||
this.verticalSpacePx = verticalSpacePx; | ||
} | ||
|
||
@Override | ||
public void getItemOffsets(@NonNull Rect outRect, @NonNull View view, @NonNull RecyclerView parent, @NonNull RecyclerView.State state) { | ||
outRect.bottom = verticalSpacePx; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 2 additions & 30 deletions
32
app/src/unitTests/java/com/artemzin/qualitymatters/api/entities/ItemTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.