this commit fixes #109 and fixes #104

This commit is contained in:
Kosh 2017-03-10 00:00:22 +08:00
parent f630029c58
commit cf2880b4b7
13 changed files with 31 additions and 41 deletions

View File

@ -90,7 +90,7 @@ dependencies {
lombokVersion = '1.12.6'
supportVerion = "25.2.0"
firebase = "10.2.0"
thirtyinchVersion = '0.8.0-rc2'
thirtyinchVersion = '0.8.0-rc3'
retrofit = '2.1.0'
}
compile fileTree(include: ['*.jar'], dir: 'libs')

View File

@ -5,6 +5,7 @@ import android.os.Parcelable;
import com.siimkinks.sqlitemagic.annotation.Column;
import com.siimkinks.sqlitemagic.annotation.Id;
import com.siimkinks.sqlitemagic.annotation.IgnoreColumn;
import com.siimkinks.sqlitemagic.annotation.Table;
import lombok.Getter;
@ -24,6 +25,7 @@ public class PayloadModel implements Parcelable {
@Column String action;
@Column(onDeleteCascade = true, handleRecursively = false) RepoModel forkee;
@Column(onDeleteCascade = true, handleRecursively = false) IssueModel issue;
@IgnoreColumn private PullRequestModel pullRequest;
@Override public int describeContents() { return 0; }

View File

@ -45,6 +45,8 @@ public class IssueDetailsViewHolder extends BaseViewHolder<IssueEventAdapterMode
if (!InputHelper.isEmpty(issueModel.getBodyHtml())) {
description.setNestedScrollingEnabled(false);
description.setGithubContent(issueModel.getBodyHtml(), issueModel.getHtmlUrl(), true);
} else {
description.setGithubContent(itemView.getResources().getString(R.string.no_description_provided), null, true);
}
}
}

View File

@ -45,6 +45,8 @@ public class PullRequestDetailsViewHolder extends BaseViewHolder<PullRequestAdap
if (!InputHelper.isEmpty(issueModel.getBodyHtml())) {
description.setNestedScrollingEnabled(false);
description.setGithubContent(issueModel.getBodyHtml(), issueModel.getHtmlUrl(), true);
} else {
description.setGithubContent(itemView.getResources().getString(R.string.no_description_provided), null, true);
}
}
}

View File

@ -108,6 +108,8 @@ class FeedsPresenter extends BasePresenter<FeedsMvp.View> implements FeedsMvp.Pr
} else {
if (item.getPayload() != null && item.getPayload().getIssue() != null) {
SchemeParser.launchUri(v.getContext(), Uri.parse(item.getPayload().getIssue().getHtmlUrl()));
} else if (item.getPayload() != null && item.getPayload().getPullRequest() != null) {
SchemeParser.launchUri(v.getContext(), Uri.parse(item.getPayload().getPullRequest().getHtmlUrl()));
} else {
RepoModel repoModel = item.getRepo();
String name = InputHelper.isEmpty(repoModel.getName()) ? repoModel.getFullName() : repoModel.getName();

View File

@ -63,7 +63,6 @@ public interface RepoPagerMvp {
}
interface Presenter extends BaseMvp.FAPresenter, BottomNavigation.OnMenuItemSelectionListener {
void onActivityCreated(@Nullable Intent intent);
@NonNull String repoId();

View File

@ -1,7 +1,5 @@
package com.fastaccess.ui.modules.repos;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.IdRes;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
@ -12,7 +10,6 @@ import com.fastaccess.R;
import com.fastaccess.data.dao.LoginModel;
import com.fastaccess.data.dao.RepoModel;
import com.fastaccess.helper.AppHelper;
import com.fastaccess.helper.BundleConstant;
import com.fastaccess.helper.InputHelper;
import com.fastaccess.helper.RxHelper;
import com.fastaccess.provider.rest.RestProvider;
@ -38,18 +35,12 @@ class RepoPagerPresenter extends BasePresenter<RepoPagerMvp.View> implements Rep
private final String repoId;
private RepoModel repo;
@Override public void onError(@NonNull Throwable throwable) {
onWorkOffline();
super.onError(throwable);
}
public RepoPagerPresenter(final String repoId, final String login) {
RepoPagerPresenter(final String repoId, final String login) {
if (!InputHelper.isEmpty(login) && !InputHelper.isEmpty(repoId())) {
throw new IllegalArgumentException("aruments cannot be empty");
throw new IllegalArgumentException("arguments cannot be empty");
}
this.repoId = repoId;
this.login = login;
makeRestCall(RestProvider.getRepoService().getRepo(login(), repoId()),
repoModel -> {
this.repo = repoModel;
@ -63,20 +54,18 @@ class RepoPagerPresenter extends BasePresenter<RepoPagerMvp.View> implements Rep
});
}
@Override
protected void onAttachView(@NonNull final RepoPagerMvp.View view) {
super.onAttachView(view);
@Override public void onError(@NonNull Throwable throwable) {
onWorkOffline();
super.onError(throwable);
}
@Override protected void onAttachView(@NonNull final RepoPagerMvp.View view) {
super.onAttachView(view);
if (getRepo() != null) {
view.onInitRepo();
}
}
@Override
public void onActivityCreated(@Nullable final Intent intent) {
// nothing to do
}
@NonNull @Override public String repoId() {
return repoId;
}

View File

@ -137,17 +137,13 @@ public class RepoPagerView extends BaseActivity<RepoPagerMvp.View, RepoPagerPres
return false;
}
@NonNull
@Override
public RepoPagerPresenter providePresenter() {
@NonNull @Override public RepoPagerPresenter providePresenter() {
if (getIntent() == null) {
throw new IllegalArgumentException("intent is null, WTF");
}
if (getIntent().getExtras() == null) {
throw new IllegalArgumentException("no intent extras provided");
}
final Bundle extras = getIntent().getExtras();
final String repoId = extras.getString(BundleConstant.ID);
final String login = extras.getString(BundleConstant.EXTRA_TWO);
@ -159,8 +155,6 @@ public class RepoPagerView extends BaseActivity<RepoPagerMvp.View, RepoPagerPres
setTitle("");
Typeface myTypeface = TypeFaceHelper.getTypeface();
bottomNavigation.setDefaultTypeface(myTypeface);
bottomNavigation.setDefaultSelectedIndex(0);
fab.setImageResource(R.drawable.ic_add);
fab.setImageTintList(ColorStateList.valueOf(Color.WHITE));
showHideFab();
@ -180,7 +174,6 @@ public class RepoPagerView extends BaseActivity<RepoPagerMvp.View, RepoPagerPres
@Override public void onInitRepo() {
if (getPresenter().getRepo() == null) {
finish();
return;
}
bottomNavigation.setOnMenuItemClickListener(getPresenter());

View File

@ -163,16 +163,16 @@ public class CreateIssueView extends BaseActivity<CreateIssueMvp.View, CreateIss
if (!InputHelper.isEmpty(issue.getTitle())) {
if (title.getEditText() != null) title.getEditText().setText(issue.getTitle());
}
if (!InputHelper.isEmpty(issue.getBody())) {
onSetCode(issue.getBody());
if (!InputHelper.isEmpty(issue.getHtmlUrl())) {
onSetCode(issue.getHtmlUrl());
}
}
if (pullRequest != null) {
if (!InputHelper.isEmpty(pullRequest.getTitle())) {
if (title.getEditText() != null) title.getEditText().setText(pullRequest.getTitle());
}
if (!InputHelper.isEmpty(pullRequest.getBody())) {
onSetCode(pullRequest.getBody());
if (!InputHelper.isEmpty(pullRequest.getHtmlUrl())) {
onSetCode(pullRequest.getHtmlUrl());
}
}
}

View File

@ -64,7 +64,7 @@
android:orientation="vertical"
android:paddingBottom="@dimen/spacing_xs_large">
<include layout="@layout/enable_ads_swift"/>
<include layout="@layout/enable_ads_switch"/>
<com.fastaccess.ui.widgets.FontTextView
style="@style/TextAppearance.AppCompat.Title"

View File

@ -12,7 +12,8 @@
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:fillViewport="true">
android:fillViewport="true"
android:clipToPadding="false">
<com.fastaccess.ui.widgets.FontEditText
android:id="@+id/editText"

View File

@ -33,23 +33,23 @@
<com.fastaccess.ui.widgets.ForegroundImageView
android:id="@+id/startGist"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center|end"
android:contentDescription="@string/star"
android:background="?selectableItemBackgroundBorderless"
android:contentDescription="@string/star"
android:padding="@dimen/spacing_normal"
android:scaleType="centerCrop"
android:src="@drawable/ic_star"/>
<com.fastaccess.ui.widgets.ForegroundImageView
android:id="@+id/forkGist"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center|end"
android:contentDescription="@string/fork"
android:background="?selectableItemBackgroundBorderless"
android:contentDescription="@string/fork"
android:padding="@dimen/spacing_normal"
android:scaleType="centerCrop"
android:src="@drawable/ic_fork"/>
</android.support.v7.widget.Toolbar>