mirror of
https://github.com/k0shk0sh/FastHub.git
synced 2025-12-08 19:05:54 +00:00
this commit fixes #267
This commit is contained in:
parent
02ad84ab30
commit
8570d65080
@ -1,44 +1,51 @@
|
||||
package com.fastaccess.data.dao.types;
|
||||
|
||||
|
||||
import android.support.annotation.DrawableRes;
|
||||
import android.support.annotation.StringRes;
|
||||
|
||||
import com.fastaccess.R;
|
||||
|
||||
public enum EventsType {
|
||||
WatchEvent(R.string.starred),
|
||||
CreateEvent(R.string.created_repo),
|
||||
CommitCommentEvent(R.string.commented_on_commit),
|
||||
DownloadEvent(R.string.downloaded),
|
||||
FollowEvent(R.string.followed),
|
||||
ForkEvent(R.string.forked),
|
||||
GistEvent(R.string.created_gist),
|
||||
GollumEvent(R.string.gollum),
|
||||
IssueCommentEvent(R.string.commented_on_issue),
|
||||
IssuesEvent(R.string.created_issue),
|
||||
MemberEvent(R.string.member),
|
||||
PublicEvent(R.string.public_event),
|
||||
PullRequestEvent(R.string.pull_request),
|
||||
PullRequestReviewCommentEvent(R.string.pr_comment_review),
|
||||
PullRequestReviewEvent(R.string.pr_review_event),
|
||||
RepositoryEvent(R.string.repo_event),
|
||||
PushEvent(R.string.pushed),
|
||||
StatusEvent(R.string.status),
|
||||
TeamAddEvent(R.string.team_event),
|
||||
DeleteEvent(R.string.deleted),
|
||||
ReleaseEvent(R.string.released),
|
||||
Unhandled(R.string.unknown),
|
||||
ForkApplyEvent(R.string.forked),
|
||||
OrgBlockEvent(R.string.organization_event),
|
||||
ProjectCardEvent(R.string.card_event),
|
||||
ProjectColumnEvent(R.string.project_event),
|
||||
OrganizationEvent(R.string.organization_event),
|
||||
ProjectEvent(R.string.project_event);
|
||||
WatchEvent(R.string.starred, R.drawable.ic_star_filled),
|
||||
CreateEvent(R.string.created_repo, R.drawable.ic_add),
|
||||
CommitCommentEvent(R.string.commented_on_commit, R.drawable.ic_comment),
|
||||
DownloadEvent(R.string.downloaded, R.drawable.ic_download),
|
||||
FollowEvent(R.string.followed, R.drawable.ic_add),
|
||||
ForkEvent(R.string.forked, R.drawable.ic_fork),
|
||||
GistEvent(R.string.created_gist, R.drawable.ic_gists),
|
||||
GollumEvent(R.string.gollum, R.drawable.ic_info_outline),
|
||||
IssueCommentEvent(R.string.commented_on_issue, R.drawable.ic_comment),
|
||||
IssuesEvent(R.string.created_issue, R.drawable.ic_issues),
|
||||
MemberEvent(R.string.member, R.drawable.ic_add),
|
||||
PublicEvent(R.string.public_event, R.drawable.ic_repo),
|
||||
PullRequestEvent(R.string.pull_request, R.drawable.ic_pull_requests),
|
||||
PullRequestReviewCommentEvent(R.string.pr_comment_review, R.drawable.ic_comment),
|
||||
PullRequestReviewEvent(R.string.pr_review_event, R.drawable.ic_eye),
|
||||
RepositoryEvent(R.string.repo_event, R.drawable.ic_repo),
|
||||
PushEvent(R.string.pushed, R.drawable.ic_arrow_right),
|
||||
StatusEvent(R.string.status, R.drawable.ic_info_outline),
|
||||
TeamAddEvent(R.string.team_event, R.drawable.ic_profile),
|
||||
DeleteEvent(R.string.deleted, R.drawable.ic_trash),
|
||||
ReleaseEvent(R.string.released, R.drawable.ic_download),
|
||||
Unhandled(R.string.unknown, R.drawable.ic_info_outline),
|
||||
ForkApplyEvent(R.string.forked, R.drawable.ic_fork),
|
||||
OrgBlockEvent(R.string.organization_event, R.drawable.ic_profile),
|
||||
ProjectCardEvent(R.string.card_event, R.drawable.ic_info_outline),
|
||||
ProjectColumnEvent(R.string.project_event, R.drawable.ic_info_outline),
|
||||
OrganizationEvent(R.string.organization_event, R.drawable.ic_profile),
|
||||
ProjectEvent(R.string.project_event, R.drawable.ic_info_outline);
|
||||
|
||||
@StringRes int type;
|
||||
@DrawableRes int drawableRes;
|
||||
|
||||
EventsType(@StringRes int type) {
|
||||
EventsType(@StringRes int type, @DrawableRes int drawableRes) {
|
||||
this.type = type;
|
||||
this.drawableRes = drawableRes;
|
||||
}
|
||||
|
||||
@DrawableRes public int getDrawableRes() {
|
||||
return drawableRes;
|
||||
}
|
||||
|
||||
@StringRes public int getType() {
|
||||
|
||||
@ -2,6 +2,7 @@ package com.fastaccess.ui.adapter.viewholder;
|
||||
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
@ -47,6 +48,8 @@ public class FeedsViewHolder extends BaseViewHolder<Event> {
|
||||
SpannableBuilder spannableBuilder = SpannableBuilder.builder();
|
||||
spannableBuilder.append(eventsModel.getActor() != null ? eventsModel.getActor().getLogin() : "N/A").append(" ");
|
||||
if (eventsModel.getType() != null) {
|
||||
date.setGravity(Gravity.CENTER);
|
||||
date.setSmallLeftDrawable(eventsModel.getType().getDrawableRes());
|
||||
String action;
|
||||
if (eventsModel.getType() == EventsType.WatchEvent) {
|
||||
action = itemView.getResources().getString(eventsModel.getType().getType()).toLowerCase();
|
||||
@ -56,7 +59,8 @@ public class FeedsViewHolder extends BaseViewHolder<Event> {
|
||||
spannableBuilder.bold(action != null ? action.toLowerCase() : "")
|
||||
.append(eventsModel.getPayload() != null && eventsModel.getPayload().getAction() != null ? " " : "");
|
||||
if (eventsModel.getType() != EventsType.WatchEvent) {
|
||||
if (eventsModel.getType() == EventsType.CreateEvent && eventsModel.getPayload().getRefType().equalsIgnoreCase("branch")) {
|
||||
if (eventsModel.getType() == EventsType.CreateEvent && eventsModel.getPayload()
|
||||
.getRefType().equalsIgnoreCase("branch")) {
|
||||
spannableBuilder
|
||||
.bold(itemView.getResources().getString(eventsModel.getType().getType()).toLowerCase())
|
||||
.append(" ")
|
||||
@ -64,8 +68,8 @@ public class FeedsViewHolder extends BaseViewHolder<Event> {
|
||||
.append(" ")
|
||||
.append(to).append(" ");
|
||||
} else {
|
||||
spannableBuilder.bold(itemView.getResources().getString(eventsModel.getType().getType()).toLowerCase())
|
||||
.append(" ");
|
||||
spannableBuilder.bold(itemView.getResources().getString(eventsModel.getType()
|
||||
.getType()).toLowerCase()).append(" ");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -3,12 +3,16 @@ package com.fastaccess.ui.widgets;
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.graphics.drawable.ScaleDrawable;
|
||||
import android.os.Parcelable;
|
||||
import android.support.annotation.ColorInt;
|
||||
import android.support.annotation.DrawableRes;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v7.widget.AppCompatTextView;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.Gravity;
|
||||
|
||||
import com.fastaccess.R;
|
||||
import com.fastaccess.helper.TypeFaceHelper;
|
||||
@ -72,4 +76,14 @@ public class FontTextView extends AppCompatTextView {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setSmallLeftDrawable(@DrawableRes int drawableRes) {
|
||||
Drawable drawable = ContextCompat.getDrawable(getContext(), drawableRes);
|
||||
int width = drawable.getIntrinsicWidth();
|
||||
int height = drawable.getIntrinsicHeight();
|
||||
drawable.setBounds(0, 0, width / 2, height / 2);
|
||||
ScaleDrawable sd = new ScaleDrawable(drawable, Gravity.CENTER, 0.8f, 0.8f);
|
||||
sd.setLevel(8000);
|
||||
setCompoundDrawablesWithIntrinsicBounds(sd, null, null, null);
|
||||
}
|
||||
}
|
||||
|
||||
11
app/src/main/res/drawable/ic_repo.xml
Normal file
11
app/src/main/res/drawable/ic_repo.xml
Normal file
@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportHeight="12"
|
||||
android:viewportWidth="12">
|
||||
|
||||
<path
|
||||
android:fillColor="?icon_color"
|
||||
android:pathData="M4 9H3V8h1v1zm0-3H3v1h1V6zm0-2H3v1h1V4zm0-2H3v1h1V2zm8-1v12c0 .55-.45 1-1 1H6v2l-1.5-1.5L3 16v-2H1c-.55 0-1-.45-1-1V1c0-.55.45-1 1-1h10c.55 0 1 .45 1 1zm-1 10H1v2h2v-1h3v1h5v-2zm0-10H2v9h9V1z"/>
|
||||
</vector>
|
||||
@ -12,4 +12,4 @@
|
||||
app:headerLayout="@layout/drawer_header"
|
||||
app:itemIconTint="?colorAccent"
|
||||
app:itemTextColor="?colorAccent"
|
||||
app:menu="@menu/deeper_drawer_menu"/>
|
||||
app:menu="@menu/extras_drawer_menu"/>
|
||||
@ -15,6 +15,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
|
||||
<com.fastaccess.ui.widgets.AvatarLayout
|
||||
android:id="@+id/avatarLayout"
|
||||
android:layout_width="@dimen/large_icon_zie"
|
||||
@ -44,10 +45,10 @@
|
||||
android:id="@+id/description"
|
||||
style="@style/TextAppearance.AppCompat.Small"
|
||||
android:layout_width="match_parent"
|
||||
android:visibility="gone"
|
||||
android:layout_height="wrap_content"
|
||||
android:maxLines="2"
|
||||
android:textColor="?android:attr/textColorSecondary"
|
||||
android:visibility="gone"
|
||||
tools:text="50 minutes ago"/>
|
||||
|
||||
<com.fastaccess.ui.widgets.FontTextView
|
||||
@ -55,7 +56,9 @@
|
||||
style="@style/TextAppearance.AppCompat.Small"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:drawablePadding="@dimen/spacing_normal"
|
||||
android:textColor="?android:attr/textColorSecondary"
|
||||
tools:drawableStart="@drawable/ic_notification"
|
||||
tools:text="50 minutes ago"/>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
<group android:id="@+id/home_group">
|
||||
<item
|
||||
android:id="@+id/navToRepo"
|
||||
android:icon="@drawable/ic_home"
|
||||
android:icon="@drawable/ic_repo"
|
||||
android:title="@string/repo"
|
||||
android:visible="false"/>
|
||||
<item
|
||||
Loading…
x
Reference in New Issue
Block a user