-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Shmakova Anastasia - @shmakova #4
Open
shmakova
wants to merge
10
commits into
yamblz-native:master
Choose a base branch
from
shmakova:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 5 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
eb651e6
get artists from content provider
shmakova dbdb8e4
sliding tab layout
shmakova 46cbb4c
tablet layout
shmakova 17f288d
fixes
shmakova 338a262
fix qualifier
shmakova 9c9c0bd
add storio, remove IterableCursor and DataManager
shmakova c71c4fa
make setters for FragmentArgs package-private
shmakova e60b4e5
fixed ClassCastException message
shmakova e143675
TabLayout instead of SlidingTabLayout
shmakova 31b9628
try to make animation
shmakova File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
76 changes: 76 additions & 0 deletions
76
app/src/androidTest/java/ru/yandex/yamblz/ApplicationTest.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,76 @@ | ||
package ru.yandex.yamblz; | ||
|
||
import android.support.test.espresso.matcher.BoundedMatcher; | ||
|
||
import org.hamcrest.Description; | ||
import org.hamcrest.Matcher; | ||
import org.junit.Rule; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
import android.support.test.rule.ActivityTestRule; | ||
import android.support.test.runner.AndroidJUnit4; | ||
import android.test.suitebuilder.annotation.LargeTest; | ||
import ru.yandex.yamblz.data.models.Artist; | ||
import ru.yandex.yamblz.ui.activities.MainActivity; | ||
|
||
import static android.support.test.espresso.Espresso.onData; | ||
import static android.support.test.espresso.Espresso.onView; | ||
import static android.support.test.espresso.action.ViewActions.click; | ||
import static android.support.test.espresso.assertion.ViewAssertions.matches; | ||
import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed; | ||
import static android.support.test.espresso.matcher.ViewMatchers.withId; | ||
import static android.support.test.espresso.matcher.ViewMatchers.withText; | ||
import static org.hamcrest.CoreMatchers.allOf; | ||
|
||
@RunWith(AndroidJUnit4.class) | ||
@LargeTest | ||
public class ApplicationTest { | ||
private static final String ARTIST_NAME = "Сплин"; | ||
private static final String ARTIST_GENRES = "rusrock"; | ||
|
||
@Rule | ||
public ActivityTestRule<MainActivity> mActivityRule = new ActivityTestRule<>( | ||
MainActivity.class); | ||
|
||
@Test | ||
public void ApplicationTest() { | ||
// find Artist in Artists list with ARTIST_NAME name and ARTIST_GENRES genres and tap on it | ||
onData(allOf(withArtistName(ARTIST_NAME), withGenres(ARTIST_GENRES))).perform(click()); | ||
|
||
// check visibility all items in the opened activity | ||
onView(withId(R.id.biography)).check(matches(isDisplayed())); | ||
onView(withId(R.id.genres)).check(matches(withText(ARTIST_GENRES))); | ||
onView(withId(R.id.info)).check(matches(isDisplayed())); | ||
onView(withId(R.id.description)).check(matches(isDisplayed())); | ||
onView(withId(R.id.cover_big)).check(matches(isDisplayed())); | ||
} | ||
|
||
public static Matcher<Object> withArtistName(final String artistName) { | ||
return new BoundedMatcher<Object, Artist>(Artist.class) { | ||
@Override | ||
protected boolean matchesSafely(Artist artist) { | ||
return artistName.equals(artist.getName()); | ||
} | ||
|
||
@Override | ||
public void describeTo(Description description) { | ||
description.appendText("with id: " + artistName); | ||
} | ||
}; | ||
} | ||
|
||
public static Matcher<Object> withGenres(final String genres) { | ||
return new BoundedMatcher<Object, Artist>(Artist.class) { | ||
@Override | ||
protected boolean matchesSafely(Artist artist) { | ||
return genres.equals(artist.getGenres()); | ||
} | ||
|
||
@Override | ||
public void describeTo(Description description) { | ||
description.appendText("with id: " + genres); | ||
} | ||
}; | ||
} | ||
} |
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 |
---|---|---|
@@ -1,26 +1,26 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="ru.yandex.yamblz"> | ||
package="ru.yandex.yamblz"> | ||
|
||
<uses-permission android:name="android.permission.INTERNET" /> | ||
<uses-permission android:name="android.permission.INTERNET"/> | ||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> | ||
|
||
<application | ||
android:name="ru.yandex.yamblz.App" | ||
android:allowBackup="false" | ||
android:allowBackup="true" | ||
android:fullBackupContent="true" | ||
android:icon="@mipmap/ic_launcher" | ||
android:label="@string/app_name" | ||
android:supportsRtl="true" | ||
android:theme="@style/AppTheme"> | ||
android:theme="@style/AppTheme.NoActionBar"> | ||
<activity | ||
android:name="ru.yandex.yamblz.ui.activities.MainActivity" | ||
android:label="@string/app_name" | ||
android:theme="@style/AppTheme.NoActionBar"> | ||
android:label="@string/main_activity_name"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
|
||
<category android:name="android.intent.category.LAUNCHER" /> | ||
<action android:name="android.intent.action.MAIN"/> | ||
<category android:name="android.intent.category.LAUNCHER"/> | ||
</intent-filter> | ||
</activity> | ||
</application> | ||
|
||
</manifest> | ||
</manifest> |
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
42 changes: 42 additions & 0 deletions
42
app/src/main/java/ru/yandex/yamblz/data/IterableCursor.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,42 @@ | ||
package ru.yandex.yamblz.data; | ||
|
||
/** | ||
* Created by shmakova on 07.08.16. | ||
*/ | ||
|
||
import android.database.Cursor; | ||
|
||
import java.util.Iterator; | ||
|
||
public class IterableCursor implements Iterable<Cursor> { | ||
private Cursor cursor; | ||
|
||
public IterableCursor(Cursor cursor) { | ||
this.cursor = cursor; | ||
if (cursor != null) { | ||
this.cursor.moveToPosition(-1); | ||
} | ||
} | ||
|
||
@Override | ||
public Iterator<Cursor> iterator() { | ||
return new Iterator<Cursor>() { | ||
@Override | ||
public boolean hasNext() { | ||
if (cursor != null && cursor.isClosed() && !cursor.moveToNext()) { | ||
cursor.close(); | ||
} | ||
return cursor != null && !cursor.isClosed() && cursor.moveToNext(); | ||
} | ||
|
||
@Override | ||
public Cursor next() { | ||
return cursor; | ||
} | ||
|
||
@Override | ||
public void remove() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. throw new UnsupportedOperationException(); |
||
} | ||
}; | ||
} | ||
} |
187 changes: 187 additions & 0 deletions
187
app/src/main/java/ru/yandex/yamblz/data/models/Artist.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,187 @@ | ||
package ru.yandex.yamblz.data.models; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Тоже посоветую посмотреть на AutoValue + AutoParcel + Moshi, как будет время. |
||
|
||
import android.database.Cursor; | ||
import android.os.Parcel; | ||
import android.os.Parcelable; | ||
import android.text.TextUtils; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
/** | ||
* Created by shmakova on 12.04.16. | ||
*/ | ||
public class Artist implements Parcelable { | ||
private int id; | ||
private String name; | ||
private List<String> genres; | ||
private Cover cover; | ||
private int tracks; | ||
private int albums; | ||
private String description; | ||
private String link; | ||
|
||
private Artist(int id, String name, List<String> genres, Cover cover, int tracks, int albums, String description, String link) { | ||
this.id = id; | ||
this.name = name; | ||
this.genres = genres; | ||
this.cover = cover; | ||
this.tracks = tracks; | ||
this.albums = albums; | ||
this.description = description; | ||
this.link = link; | ||
} | ||
|
||
public String getDescription() { | ||
return description; | ||
} | ||
|
||
public String getLink() { | ||
return link; | ||
} | ||
|
||
public int getTracks() { | ||
return tracks; | ||
} | ||
|
||
public int getAlbums() { | ||
return albums; | ||
} | ||
|
||
public int getId() { | ||
return id; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public Cover getCover() { | ||
return cover; | ||
} | ||
|
||
public String getGenres() { | ||
return TextUtils.join(", ", genres); | ||
} | ||
|
||
@Override | ||
public int describeContents() { | ||
return 0; | ||
} | ||
|
||
@Override | ||
public void writeToParcel(Parcel dest, int flags) { | ||
dest.writeInt(this.id); | ||
dest.writeString(this.name); | ||
dest.writeStringList(this.genres); | ||
dest.writeParcelable(this.cover, flags); | ||
dest.writeInt(this.tracks); | ||
dest.writeInt(this.albums); | ||
dest.writeString(this.description); | ||
dest.writeString(this.link); | ||
} | ||
|
||
private Artist(Parcel in) { | ||
this.id = in.readInt(); | ||
this.name = in.readString(); | ||
this.genres = in.createStringArrayList(); | ||
this.cover = in.readParcelable(Cover.class.getClassLoader()); | ||
this.tracks = in.readInt(); | ||
this.albums = in.readInt(); | ||
this.description = in.readString(); | ||
this.link = in.readString(); | ||
} | ||
|
||
public static final Parcelable.Creator<Artist> CREATOR = new Parcelable.Creator<Artist>() { | ||
@Override | ||
public Artist createFromParcel(Parcel source) { | ||
return new Artist(source); | ||
} | ||
|
||
@Override | ||
public Artist[] newArray(int size) { | ||
return new Artist[size]; | ||
} | ||
}; | ||
|
||
@Override | ||
public String toString() { | ||
return "Artist: " + name; | ||
} | ||
|
||
public static class Builder { | ||
private int id; | ||
private String name; | ||
private List<String> genres; | ||
private Cover cover; | ||
private int tracks; | ||
private int albums; | ||
private String description; | ||
private String link; | ||
|
||
public Builder setId(int id) { | ||
this.id = id; | ||
return this; | ||
} | ||
|
||
public Builder setName(String name) { | ||
this.name = name; | ||
return this; | ||
} | ||
|
||
public Builder setGenres(List<String> genres) { | ||
this.genres = genres; | ||
return this; | ||
} | ||
|
||
public Builder setCover(Cover cover) { | ||
this.cover = cover; | ||
return this; | ||
} | ||
|
||
public Builder setTracks(int tracks) { | ||
this.tracks = tracks; | ||
return this; | ||
} | ||
|
||
public Builder setAlbums(int albums) { | ||
this.albums = albums; | ||
return this; | ||
} | ||
|
||
public Builder setDescription(String description) { | ||
this.description = description; | ||
return this; | ||
} | ||
|
||
public Builder setLink(String link) { | ||
this.link = link; | ||
return this; | ||
} | ||
|
||
public Artist build() { | ||
return new Artist(id, name, genres, cover, tracks, albums, description, link); | ||
} | ||
} | ||
|
||
public static Artist getArtistFromCursor(Cursor cursor) { | ||
String genresString = cursor.getString(8); | ||
List<String> genres = new ArrayList<>(Collections.singletonList(genresString)); | ||
|
||
Cover cover = new Cover( | ||
cursor.getString(6), | ||
cursor.getString(7) | ||
); | ||
|
||
return new Artist.Builder() | ||
.setName(cursor.getString(1)) | ||
.setTracks(cursor.getInt(2)) | ||
.setAlbums(cursor.getInt(3)) | ||
.setGenres(genres) | ||
.setCover(cover) | ||
.setDescription(cursor.getString(4)) | ||
.setLink(cursor.getString(5)) | ||
.build(); | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Рекомендую посмотреть на StorIO. https://github.com/pushtorefresh/storio
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Впилила StorIO