-
Notifications
You must be signed in to change notification settings - Fork 10
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
8e8e036
commit 5d76408
Showing
12 changed files
with
200 additions
and
19 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
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
31 changes: 31 additions & 0 deletions
31
app/src/main/java/com/ryan/corelibs/adapter/GithubAdapter.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,31 @@ | ||
package com.ryan.corelibs.adapter; | ||
|
||
import android.content.Context; | ||
|
||
import com.corelibs.utils.adapter.BaseAdapterHelper; | ||
import com.corelibs.utils.adapter.recycler.RecyclerAdapter; | ||
import com.ryan.corelibs.R; | ||
import com.ryan.corelibs.model.entity.Repository; | ||
|
||
import java.text.SimpleDateFormat; | ||
import java.util.Locale; | ||
|
||
public class GithubAdapter extends RecyclerAdapter<Repository> { | ||
|
||
private SimpleDateFormat format; | ||
|
||
public GithubAdapter(Context context) { | ||
super(context, R.layout.i_github); | ||
format = new SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.CHINA); | ||
} | ||
|
||
@Override | ||
protected void convert(BaseAdapterHelper helper, Repository item, int position) { | ||
helper.setText(R.id.tv_title, item.owner.login + "/" + item.name) | ||
.setText(R.id.tv_desc, item.description) | ||
.setText(R.id.tv_lang, item.language) | ||
.setText(R.id.tv_star, String.valueOf(item.stargazers_count)) | ||
.setText(R.id.tv_update_date, "Updated at " + format.format(item.updated_at)) | ||
.setImageUrl(R.id.iv_avatar, item.owner.avatar_url); | ||
} | ||
} |
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,8 @@ | ||
package com.ryan.corelibs.model.entity; | ||
|
||
import java.io.Serializable; | ||
|
||
public class Owner implements Serializable { | ||
public String login; | ||
public String avatar_url; | ||
} |
8 changes: 8 additions & 0 deletions
8
app/src/main/java/com/ryan/corelibs/model/entity/Repository.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 |
---|---|---|
@@ -1,6 +1,14 @@ | ||
package com.ryan.corelibs.model.entity; | ||
|
||
import java.io.Serializable; | ||
import java.util.Date; | ||
|
||
public class Repository implements Serializable { | ||
public Long id; | ||
public String name; | ||
public String description; | ||
public Owner owner; | ||
public int stargazers_count; | ||
public String language; | ||
public Date updated_at; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<LinearLayout | ||
xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:orientation="horizontal" | ||
android:padding="15dp" | ||
android:background="@color/transparent"> | ||
|
||
<ImageView | ||
android:id="@+id/iv_avatar" | ||
android:layout_width="40dp" | ||
android:layout_height="40dp" | ||
android:contentDescription="@null" | ||
android:scaleType="centerCrop" | ||
android:src="#eee" | ||
android:layout_marginEnd="10dp" | ||
android:layout_marginTop="8dp"/> | ||
|
||
<LinearLayout | ||
android:layout_width="0dp" | ||
android:layout_weight="1" | ||
android:layout_height="wrap_content" | ||
android:orientation="vertical" | ||
android:layout_marginEnd="10dp"> | ||
|
||
<TextView | ||
android:id="@+id/tv_title" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:textSize="16sp" | ||
android:textColor="@color/blue" | ||
android:layout_marginBottom="3dp"/> | ||
|
||
<TextView | ||
android:id="@+id/tv_desc" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:textSize="14sp" | ||
android:textColor="@color/text_hint" | ||
android:layout_marginBottom="10dp" | ||
android:maxLines="2" | ||
android:ellipsize="end"/> | ||
|
||
<TextView | ||
android:id="@+id/tv_update_date" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:textColor="@color/text_hint" | ||
android:textSize="12sp"/> | ||
|
||
</LinearLayout> | ||
|
||
<TextView | ||
android:id="@+id/tv_lang" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:textSize="14sp" | ||
android:textColor="@color/text_main" | ||
android:layout_marginEnd="8dp"/> | ||
|
||
<TextView | ||
android:id="@+id/tv_star" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:textSize="14sp" | ||
android:textColor="@color/text_main" | ||
android:layout_marginEnd="8dp" | ||
android:drawableStart="@mipmap/star" | ||
android:gravity="center_vertical" | ||
android:drawablePadding="2dp"/> | ||
|
||
</LinearLayout> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,6 +1,5 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
<color name="colorPrimary">#3F51B5</color> | ||
<color name="colorPrimaryDark">#303F9F</color> | ||
<color name="colorAccent">#FF4081</color> | ||
<color name="text_main">#666666</color> | ||
<color name="text_hint">#999999</color> | ||
</resources> |