Skip to content
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

@tayrinn, Kim #16

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ android {
dependencies {
compile libraries.dagger
apt libraries.daggerCompiler
compile 'com.jakewharton.rxbinding:rxbinding-design:0.4.0'

compile libraries.supportAnnotations
compile libraries.supportAppCompat
Expand All @@ -105,6 +106,16 @@ dependencies {
compile libraries.lynx
compile libraries.processPhoenix

compile libraries.rxjava
compile libraries.rxandroid
compile libraries.jacksonConverter
compile libraries.jacksonDatabind
compile libraries.jacksonAnnotations
compile libraries.retrofit
compile libraries.retrofitAdapter
compile libraries.retrofitAdapter
compile libraries.universalImageLoader

testCompile libraries.junit
testCompile libraries.robolectric
testCompile libraries.assertJ
Expand Down
10 changes: 10 additions & 0 deletions app/src/main/java/ru/yandex/yamblz/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
import android.content.Context;
import android.support.annotation.NonNull;

import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.ImageLoaderConfiguration;

import ru.yandex.yamblz.developer_settings.DevMetricsProxy;
import ru.yandex.yamblz.developer_settings.DeveloperSettingsModel;
import ru.yandex.yamblz.handler.CriticalSectionsManager;
Expand Down Expand Up @@ -36,6 +39,13 @@ public void onCreate() {

CollageLoaderManager.init(null); // add implementation
CriticalSectionsManager.init(null); // add implementation
ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(this)
.diskCacheSize( 20 * 1024 * 1024 ) // 20Mb
.memoryCacheSize( 2 * 1024 * 1024 ) // 2Mb
.threadPoolSize( 5 )
.diskCacheFileCount( 100 )
.build();
ImageLoader.getInstance().init( config );
}

@NonNull
Expand Down
192 changes: 192 additions & 0 deletions app/src/main/java/ru/yandex/yamblz/data/Artist.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,192 @@
package ru.yandex.yamblz.data;

/**
* Created by Volha on 01.08.2016.
*/

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;

import java.util.ArrayList;
import java.util.List;


@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonPropertyOrder( {
"id",
"name",
"genres",
"tracks",
"albums",
"link",
"description",
"cover"
})
public class Artist {

@JsonProperty("id")
private Integer id;
@JsonProperty("name")
private String name;
@JsonProperty("genres")
private List<String> genres = new ArrayList<>();
@JsonProperty("tracks")
private Integer tracks;
@JsonProperty("albums")
private Integer albums;
@JsonProperty("link")
private String link;
@JsonProperty("description")
private String description;
@JsonProperty("cover")
private Cover cover;

/**
* @return The id
*/
@JsonProperty("id")
public Integer getId() {
return id;
}

/**
* @param id The id
*/
@JsonProperty("id")
public void setId(Integer id) {
this.id = id;
}

/**
* @return The name
*/
@JsonProperty("name")
public String getName() {
return name;
}

/**
* @param name The name
*/
@JsonProperty("name")
public void setName(String name) {
this.name = name;
}

/**
* @return The genres
*/
@JsonProperty("genres")
public List<String> getGenres() {
return genres;
}

/**
* @param genres The genres
*/
@JsonProperty("genres")
public void setGenres(List<String> genres) {
this.genres = genres;
}

/*
generate a semicolon separated string
* */
@JsonIgnore
public String getGenresString() {
StringBuilder sb = new StringBuilder();
if (genres.size() == 0)
return "";
sb.append(genres.get(0));
for (int i = 1; i < genres.size(); ++i) {
sb.append(", ");
sb.append(genres.get(i));
}
return sb.toString();
}

/**
* @return The tracks
*/
@JsonProperty("tracks")
public Integer getTracks() {
return tracks;
}

/**
* @param tracks The tracks
*/
@JsonProperty("tracks")
public void setTracks(Integer tracks) {
this.tracks = tracks;
}

/**
* @return The albums
*/
@JsonProperty("albums")
public Integer getAlbums() {
return albums;
}

/**
* @param albums The albums
*/
@JsonProperty("albums")
public void setAlbums(Integer albums) {
this.albums = albums;
}

/**
* @return The link
*/
@JsonProperty("link")
public String getLink() {
return link;
}

/**
* @param link The link
*/
@JsonProperty("link")
public void setLink(String link) {
this.link = link;
}

/**
* @return The description
*/
@JsonProperty("description")
public String getDescription() {
return description;
}

/**
* @param description The description
*/
@JsonProperty("description")
public void setDescription(String description) {
this.description = description;
}

/**
* @return The cover
*/
@JsonProperty("cover")
public Cover getCover() {
return cover;
}

/**
* @param cover The cover
*/
@JsonProperty("cover")
public void setCover(Cover cover) {
this.cover = cover;
}
}

57 changes: 57 additions & 0 deletions app/src/main/java/ru/yandex/yamblz/data/Cover.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package ru.yandex.yamblz.data;

/**
* Created by Volha on 01.08.2016.
*/

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;

@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonPropertyOrder( {
"small",
"big"
})
@JsonIgnoreProperties(ignoreUnknown = true)
public class Cover {

@JsonProperty("small")
private String small;
@JsonProperty("big")
private String big;

/**
* @return The small
*/
@JsonProperty("small")
public String getSmall() {
return small;
}

/**
* @param small The small
*/
@JsonProperty("small")
public void setSmall( String small ) {
this.small = small;
}

/**
* @return The big
*/
@JsonProperty("big")
public String getBig() {
return big;
}

/**
* @param big The big
*/
@JsonProperty("big")
public void setBig( String big ) {
this.big = big;
}
}

57 changes: 57 additions & 0 deletions app/src/main/java/ru/yandex/yamblz/retrofit/ApiServices.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package ru.yandex.yamblz.retrofit;

import java.util.List;

import ru.yandex.yamblz.data.Artist;
import java.util.List;

import retrofit.JacksonConverterFactory;
import retrofit.Retrofit;
import retrofit.RxJavaCallAdapterFactory;
import retrofit.http.GET;
import rx.Observable;
import rx.plugins.RxJavaErrorHandler;
import rx.plugins.RxJavaPlugins;
/**
* Created by Volha on 01.08.2016.
*/

public class ApiServices {

public final static String API_URL = "http://download.cdn.yandex.net/";

private final ApiWebService webService;

static {
RxJavaPlugins.getInstance().registerErrorHandler(new RxJavaErrorHandler() {
@Override
public void handleError(Throwable e) {
e.printStackTrace();
}
});
}

public ApiServices() {

Retrofit retrofit = new Retrofit.Builder()
.baseUrl( API_URL )
.addConverterFactory( JacksonConverterFactory.create() )
.addCallAdapterFactory( RxJavaCallAdapterFactory.create() )
.build();

webService = retrofit.create( ApiWebService.class );
}

public interface ApiWebService {

@GET("mobilization-2016/artists.json")
Observable<List<Artist>> getArtists();
}

public rx.Observable<List<Artist>> getArtists() {

return webService.getArtists();
}


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package ru.yandex.yamblz.ui.adapters;

import android.graphics.Rect;
import android.support.v7.widget.RecyclerView;
import android.view.View;

/**
* Created by Volha on 04.08.2016.
*/
public class FrameItemDecoration extends RecyclerView.ItemDecoration {

private final int offset = 15;


@Override
public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
outRect.left = offset;
outRect.right = offset;
outRect.bottom = offset;
outRect.top = offset;
}

}
Loading