mirror of
https://github.com/k0shk0sh/FastHub.git
synced 2025-12-08 19:05:54 +00:00
this commit fixed #129 and reading for 1.1.0
This commit is contained in:
parent
0e750a835d
commit
0f1751ebff
@ -122,7 +122,6 @@ dependencies {
|
||||
compile 'com.github.k0shk0sh:RetainedDateTimePickers:1.0.2'
|
||||
compile 'com.zzhoujay.markdown:markdown:1.0.4'
|
||||
compile 'com.github.daniel-stoneuk:material-about-library:1.8.1'
|
||||
compile 'com.mikepenz:community-material-typeface:1.7.22.1@aar'
|
||||
annotationProcessor "org.projectlombok:lombok:${lombokVersion}"
|
||||
annotationProcessor "frankiesardo:icepick-processor:${icepickVersion}"
|
||||
annotationProcessor "com.jakewharton:butterknife-compiler:${butterKnifeVersion}"
|
||||
|
||||
@ -23,7 +23,8 @@ import com.fastaccess.ui.modules.repos.code.contributors.RepoContributorsView;
|
||||
import com.fastaccess.ui.modules.repos.code.files.paths.RepoFilePathView;
|
||||
import com.fastaccess.ui.modules.repos.code.prettifier.ViewerView;
|
||||
import com.fastaccess.ui.modules.repos.code.releases.RepoReleasesView;
|
||||
import com.fastaccess.ui.modules.repos.issues.issue.RepoIssuesView;
|
||||
import com.fastaccess.ui.modules.repos.issues.issue.RepoClosedIssuesView;
|
||||
import com.fastaccess.ui.modules.repos.issues.issue.RepoOpenedIssuesView;
|
||||
import com.fastaccess.ui.modules.repos.issues.issue.details.comments.IssueCommentsView;
|
||||
import com.fastaccess.ui.modules.repos.issues.issue.details.events.IssueDetailsView;
|
||||
import com.fastaccess.ui.modules.repos.pull_requests.pull_request.RepoPullRequestView;
|
||||
@ -107,9 +108,9 @@ public class FragmentPagerAdapterModel {
|
||||
@NonNull public static List<FragmentPagerAdapterModel> buildForRepoIssue(@NonNull Context context, @NonNull String login,
|
||||
@NonNull String repoId) {
|
||||
return Stream.of(new FragmentPagerAdapterModel(context.getString(R.string.opened),
|
||||
RepoIssuesView.newInstance(repoId, login, IssueState.open)),
|
||||
RepoOpenedIssuesView.newInstance(repoId, login, IssueState.open)),
|
||||
new FragmentPagerAdapterModel(context.getString(R.string.closed),
|
||||
RepoIssuesView.newInstance(repoId, login, IssueState.closed)))
|
||||
RepoClosedIssuesView.newInstance(repoId, login, IssueState.closed)))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
|
||||
@ -6,10 +6,12 @@ import com.fastaccess.ui.base.mvp.BaseMvp;
|
||||
* Created by Kosh on 31 Dec 2016, 1:35 AM
|
||||
*/
|
||||
|
||||
interface RepoIssuesPagerMvp {
|
||||
public interface RepoIssuesPagerMvp {
|
||||
|
||||
interface View extends BaseMvp.FAView {
|
||||
void onAddIssue();
|
||||
|
||||
void setCurrentItem(int index);
|
||||
}
|
||||
|
||||
interface Presenter extends BaseMvp.FAPresenter {}
|
||||
|
||||
@ -12,7 +12,7 @@ import com.fastaccess.helper.BundleConstant;
|
||||
import com.fastaccess.helper.Bundler;
|
||||
import com.fastaccess.ui.adapter.FragmentsPagerAdapter;
|
||||
import com.fastaccess.ui.base.BaseFragment;
|
||||
import com.fastaccess.ui.modules.repos.issues.issue.RepoIssuesView;
|
||||
import com.fastaccess.ui.modules.repos.issues.issue.RepoOpenedIssuesView;
|
||||
import com.fastaccess.ui.widgets.ViewPagerView;
|
||||
|
||||
import butterknife.BindView;
|
||||
@ -56,7 +56,11 @@ public class RepoIssuesPagerView extends BaseFragment<RepoIssuesPagerMvp.View, R
|
||||
|
||||
@Override public void onAddIssue() {
|
||||
if (pager.getCurrentItem() != 0) pager.setCurrentItem(0);
|
||||
RepoIssuesView repoIssuesView = (RepoIssuesView) pager.getAdapter().instantiateItem(pager, 0);
|
||||
repoIssuesView.onAddIssue();
|
||||
RepoOpenedIssuesView repoOpenedIssuesView = (RepoOpenedIssuesView) pager.getAdapter().instantiateItem(pager, 0);
|
||||
repoOpenedIssuesView.onAddIssue();
|
||||
}
|
||||
|
||||
@Override public void setCurrentItem(int index) {
|
||||
pager.setCurrentItem(index, true);
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,111 @@
|
||||
package com.fastaccess.ui.modules.repos.issues.issue;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.annotation.StringRes;
|
||||
import android.support.v4.widget.SwipeRefreshLayout;
|
||||
import android.view.View;
|
||||
|
||||
import com.fastaccess.R;
|
||||
import com.fastaccess.data.dao.types.IssueState;
|
||||
import com.fastaccess.helper.BundleConstant;
|
||||
import com.fastaccess.helper.Bundler;
|
||||
import com.fastaccess.helper.Logger;
|
||||
import com.fastaccess.provider.rest.loadmore.OnLoadMore;
|
||||
import com.fastaccess.ui.adapter.IssuesAdapter;
|
||||
import com.fastaccess.ui.base.BaseFragment;
|
||||
import com.fastaccess.ui.widgets.StateLayout;
|
||||
import com.fastaccess.ui.widgets.recyclerview.DynamicRecyclerView;
|
||||
|
||||
import butterknife.BindView;
|
||||
|
||||
/**
|
||||
* Created by Kosh on 03 Dec 2016, 3:56 PM
|
||||
*/
|
||||
|
||||
public class RepoClosedIssuesView extends BaseFragment<RepoIssuesMvp.View, RepoIssuesPresenter> implements RepoIssuesMvp.View {
|
||||
@BindView(R.id.recycler) DynamicRecyclerView recycler;
|
||||
@BindView(R.id.refresh) SwipeRefreshLayout refresh;
|
||||
@BindView(R.id.stateLayout) StateLayout stateLayout;
|
||||
private OnLoadMore<IssueState> onLoadMore;
|
||||
private IssuesAdapter adapter;
|
||||
|
||||
public static RepoClosedIssuesView newInstance(@NonNull String repoId, @NonNull String login, @NonNull IssueState issueState) {
|
||||
RepoClosedIssuesView view = new RepoClosedIssuesView();
|
||||
view.setArguments(Bundler.start()
|
||||
.put(BundleConstant.ID, repoId)
|
||||
.put(BundleConstant.EXTRA, login)
|
||||
.put(BundleConstant.EXTRA_TWO, issueState)
|
||||
.end());
|
||||
return view;
|
||||
}
|
||||
|
||||
@Override public void onNotifyAdapter() {
|
||||
Logger.e();
|
||||
hideProgress();
|
||||
adapter.notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@Override protected int fragmentLayout() {
|
||||
return R.layout.small_grid_refresh_list;
|
||||
}
|
||||
|
||||
@Override protected void onFragmentCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
if (getArguments() == null) {
|
||||
throw new NullPointerException("Bundle is null, therefore, issues can't be proceeded.");
|
||||
}
|
||||
stateLayout.setOnReloadListener(this);
|
||||
refresh.setOnRefreshListener(this);
|
||||
recycler.setEmptyView(stateLayout, refresh);
|
||||
adapter = new IssuesAdapter(getPresenter().getIssues(), true);
|
||||
adapter.setListener(getPresenter());
|
||||
getLoadMore().setCurrent_page(getPresenter().getCurrentPage(), getPresenter().getPreviousTotal());
|
||||
recycler.setAdapter(adapter);
|
||||
recycler.addOnScrollListener(getLoadMore());
|
||||
if (savedInstanceState == null) {
|
||||
getPresenter().onFragmentCreated(getArguments());
|
||||
} else if (getPresenter().getIssues().isEmpty() && !getPresenter().isApiCalled()) {
|
||||
onRefresh();
|
||||
}
|
||||
}
|
||||
|
||||
@NonNull @Override public RepoIssuesPresenter providePresenter() {
|
||||
return new RepoIssuesPresenter();
|
||||
}
|
||||
|
||||
@Override public void hideProgress() {
|
||||
refresh.setRefreshing(false);
|
||||
stateLayout.hideProgress();
|
||||
}
|
||||
|
||||
@Override public void showProgress(@StringRes int resId) {
|
||||
stateLayout.showProgress();
|
||||
}
|
||||
|
||||
@Override public void showErrorMessage(@NonNull String message) {
|
||||
hideProgress();
|
||||
stateLayout.showReload(adapter.getItemCount());
|
||||
super.showErrorMessage(message);
|
||||
}
|
||||
|
||||
@NonNull @Override public OnLoadMore<IssueState> getLoadMore() {
|
||||
if (onLoadMore == null) {
|
||||
onLoadMore = new OnLoadMore<>(getPresenter());
|
||||
}
|
||||
onLoadMore.setParameter(((IssueState) getArguments().getSerializable(BundleConstant.EXTRA_TWO)));
|
||||
return onLoadMore;
|
||||
}
|
||||
|
||||
@Override public void onAddIssue() {
|
||||
//DO NOTHING
|
||||
}
|
||||
|
||||
@Override public void onRefresh() {
|
||||
getPresenter().onCallApi(1, null);
|
||||
}
|
||||
|
||||
@Override public void onClick(View view) {
|
||||
onRefresh();
|
||||
}
|
||||
}
|
||||
@ -58,6 +58,7 @@ class RepoIssuesPresenter extends BasePresenter<RepoIssuesMvp.View> implements R
|
||||
}
|
||||
|
||||
@Override public void onCallApi(int page, @Nullable IssueState parameter) {
|
||||
Logger.e(page, page, login, repoId);
|
||||
if (page == 1) {
|
||||
lastPage = Integer.MAX_VALUE;
|
||||
sendToView(view -> view.getLoadMore().reset());
|
||||
@ -66,10 +67,10 @@ class RepoIssuesPresenter extends BasePresenter<RepoIssuesMvp.View> implements R
|
||||
sendToView(RepoIssuesMvp.View::hideProgress);
|
||||
return;
|
||||
}
|
||||
if (repoId == null || login == null) return;
|
||||
setCurrentPage(page);
|
||||
makeRestCall(RestProvider.getIssueService().getRepositoryIssues(login, repoId, issueState.name(), page),
|
||||
issues -> {
|
||||
lastPage = issues.getLast();
|
||||
if (getCurrentPage() == 1) {
|
||||
getIssues().clear();
|
||||
manageSubscription(IssueModel.save(issues.getItems(), repoId, login).subscribe());
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package com.fastaccess.ui.modules.repos.issues.issue;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
@ -10,7 +11,6 @@ import android.support.v4.widget.SwipeRefreshLayout;
|
||||
import android.view.View;
|
||||
|
||||
import com.fastaccess.R;
|
||||
import com.fastaccess.data.dao.IssueModel;
|
||||
import com.fastaccess.data.dao.types.IssueState;
|
||||
import com.fastaccess.helper.BundleConstant;
|
||||
import com.fastaccess.helper.Bundler;
|
||||
@ -18,6 +18,7 @@ import com.fastaccess.helper.Logger;
|
||||
import com.fastaccess.provider.rest.loadmore.OnLoadMore;
|
||||
import com.fastaccess.ui.adapter.IssuesAdapter;
|
||||
import com.fastaccess.ui.base.BaseFragment;
|
||||
import com.fastaccess.ui.modules.repos.issues.RepoIssuesPagerMvp;
|
||||
import com.fastaccess.ui.modules.repos.issues.create.CreateIssueView;
|
||||
import com.fastaccess.ui.widgets.StateLayout;
|
||||
import com.fastaccess.ui.widgets.recyclerview.DynamicRecyclerView;
|
||||
@ -28,15 +29,17 @@ import butterknife.BindView;
|
||||
* Created by Kosh on 03 Dec 2016, 3:56 PM
|
||||
*/
|
||||
|
||||
public class RepoIssuesView extends BaseFragment<RepoIssuesMvp.View, RepoIssuesPresenter> implements RepoIssuesMvp.View {
|
||||
public class RepoOpenedIssuesView extends BaseFragment<RepoIssuesMvp.View, RepoIssuesPresenter> implements RepoIssuesMvp.View {
|
||||
@BindView(R.id.recycler) DynamicRecyclerView recycler;
|
||||
@BindView(R.id.refresh) SwipeRefreshLayout refresh;
|
||||
@BindView(R.id.stateLayout) StateLayout stateLayout;
|
||||
private OnLoadMore<IssueState> onLoadMore;
|
||||
private IssuesAdapter adapter;
|
||||
|
||||
public static RepoIssuesView newInstance(@NonNull String repoId, @NonNull String login, @NonNull IssueState issueState) {
|
||||
RepoIssuesView view = new RepoIssuesView();
|
||||
private RepoIssuesPagerMvp.View pagerCallback;
|
||||
|
||||
public static RepoOpenedIssuesView newInstance(@NonNull String repoId, @NonNull String login, @NonNull IssueState issueState) {
|
||||
RepoOpenedIssuesView view = new RepoOpenedIssuesView();
|
||||
view.setArguments(Bundler.start()
|
||||
.put(BundleConstant.ID, repoId)
|
||||
.put(BundleConstant.EXTRA, login)
|
||||
@ -45,6 +48,20 @@ public class RepoIssuesView extends BaseFragment<RepoIssuesMvp.View, RepoIssuesP
|
||||
return view;
|
||||
}
|
||||
|
||||
@Override public void onAttach(Context context) {
|
||||
super.onAttach(context);
|
||||
if (getParentFragment() instanceof RepoIssuesPagerMvp.View) {
|
||||
pagerCallback = (RepoIssuesPagerMvp.View) getParentFragment();
|
||||
} else if (context instanceof RepoIssuesPagerMvp.View) {
|
||||
pagerCallback = (RepoIssuesPagerMvp.View) context;
|
||||
}
|
||||
}
|
||||
|
||||
@Override public void onDetach() {
|
||||
pagerCallback = null;
|
||||
super.onDetach();
|
||||
}
|
||||
|
||||
@Override public void onNotifyAdapter() {
|
||||
Logger.e();
|
||||
hideProgress();
|
||||
@ -59,9 +76,9 @@ public class RepoIssuesView extends BaseFragment<RepoIssuesMvp.View, RepoIssuesP
|
||||
if (getArguments() == null) {
|
||||
throw new NullPointerException("Bundle is null, therefore, issues can't be proceeded.");
|
||||
}
|
||||
recycler.setEmptyView(stateLayout, refresh);
|
||||
stateLayout.setOnReloadListener(this);
|
||||
refresh.setOnRefreshListener(this);
|
||||
recycler.setEmptyView(stateLayout, refresh);
|
||||
adapter = new IssuesAdapter(getPresenter().getIssues(), true);
|
||||
adapter.setListener(getPresenter());
|
||||
getLoadMore().setCurrent_page(getPresenter().getCurrentPage(), getPresenter().getPreviousTotal());
|
||||
@ -76,14 +93,9 @@ public class RepoIssuesView extends BaseFragment<RepoIssuesMvp.View, RepoIssuesP
|
||||
|
||||
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
if (resultCode == Activity.RESULT_OK && requestCode == BundleConstant.REQUEST_CODE && data != null) {
|
||||
Bundle bundle = data.getExtras();
|
||||
if (bundle != null) {
|
||||
IssueModel issueModel = bundle.getParcelable(BundleConstant.ITEM);
|
||||
if (issueModel != null) {
|
||||
adapter.addItem(issueModel, 0);
|
||||
}
|
||||
}
|
||||
if (resultCode == Activity.RESULT_OK && requestCode == BundleConstant.REQUEST_CODE) {
|
||||
onRefresh();
|
||||
if (pagerCallback != null) pagerCallback.setCurrentItem(0);
|
||||
}
|
||||
}
|
||||
|
||||
@ -110,8 +122,8 @@ public class RepoIssuesView extends BaseFragment<RepoIssuesMvp.View, RepoIssuesP
|
||||
@NonNull @Override public OnLoadMore<IssueState> getLoadMore() {
|
||||
if (onLoadMore == null) {
|
||||
onLoadMore = new OnLoadMore<>(getPresenter());
|
||||
onLoadMore.setParameter(((IssueState) getArguments().getSerializable(BundleConstant.EXTRA_TWO)));
|
||||
}
|
||||
onLoadMore.setParameter(((IssueState) getArguments().getSerializable(BundleConstant.EXTRA_TWO)));
|
||||
return onLoadMore;
|
||||
}
|
||||
|
||||
@ -82,16 +82,15 @@ public class AvatarLayout extends FrameLayout implements ImageLoadingListener {
|
||||
}
|
||||
|
||||
@Override public void onLoadingStarted(String imageUri, View view) {
|
||||
setBackgroundResource(R.drawable.circle_shape);
|
||||
setBackground(false);
|
||||
}
|
||||
|
||||
@Override public void onLoadingFailed(String imageUri, View view, FailReason failReason) {
|
||||
avatar.setImageResource(R.drawable.ic_github_black);
|
||||
setBackgroundColor(Color.TRANSPARENT);
|
||||
setBackground(true);
|
||||
}
|
||||
|
||||
@Override public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
|
||||
setBackgroundColor(Color.TRANSPARENT);
|
||||
setBackground(true);
|
||||
}
|
||||
|
||||
@Override public void onLoadingCancelled(String imageUri, View view) {}
|
||||
@ -105,4 +104,16 @@ public class AvatarLayout extends FrameLayout implements ImageLoadingListener {
|
||||
ImageLoader.getInstance().displayImage(null, avatar);
|
||||
}
|
||||
}
|
||||
|
||||
private void setBackground(boolean clear) {
|
||||
if (clear) {
|
||||
setBackgroundColor(Color.TRANSPARENT);
|
||||
} else {
|
||||
if (PrefGetter.isRectdAvatar()) {
|
||||
setBackgroundResource(R.drawable.rect_shape);
|
||||
} else {
|
||||
setBackgroundResource(R.drawable.circle_shape);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -5,7 +5,7 @@ import android.support.v7.widget.RecyclerView;
|
||||
/**
|
||||
* Created by Kosh on 8/2/2015. copyrights are reserved @Innov8tif
|
||||
*/
|
||||
public abstract class InfiniteScroll extends RecyclerView.OnScrollListener {
|
||||
@SuppressWarnings("FieldCanBeLocal") public abstract class InfiniteScroll extends RecyclerView.OnScrollListener {
|
||||
private int previousTotal = 0;
|
||||
private boolean loading = true;
|
||||
private int visibleThreshold = 2;
|
||||
@ -17,7 +17,6 @@ public abstract class InfiniteScroll extends RecyclerView.OnScrollListener {
|
||||
private static final int HIDE_THRESHOLD = 20;
|
||||
private int scrolledDistance = 0;
|
||||
private boolean controlsVisible = true;
|
||||
private final int PAGING_SIZE = 30;
|
||||
|
||||
public InfiniteScroll() {}
|
||||
|
||||
@ -27,7 +26,6 @@ public abstract class InfiniteScroll extends RecyclerView.OnScrollListener {
|
||||
visibleItemCount = recyclerView.getChildCount();
|
||||
totalItemCount = mRecyclerViewHelper.getItemCount();
|
||||
firstVisibleItem = mRecyclerViewHelper.findFirstVisibleItemPosition();
|
||||
if (PAGING_SIZE > totalItemCount) return;
|
||||
if (loading) {
|
||||
if (totalItemCount > previousTotal) {
|
||||
loading = false;
|
||||
@ -60,9 +58,7 @@ public abstract class InfiniteScroll extends RecyclerView.OnScrollListener {
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("WeakerAccess") protected void onScrollToLast(RecyclerView recyclerView) {
|
||||
|
||||
}
|
||||
@SuppressWarnings("WeakerAccess") protected void onScrollToLast(RecyclerView recyclerView) {}
|
||||
|
||||
@SuppressWarnings("WeakerAccess") protected void onShow(RecyclerView recyclerView) {}
|
||||
|
||||
|
||||
@ -100,10 +100,12 @@ public class PrettifyWebView extends NestedWebView {
|
||||
setGithubContent(source, baseUrl, false);
|
||||
}
|
||||
|
||||
public void setGithubContent(@NonNull String source, @Nullable String baseUrl, boolean wrap) {
|
||||
@SuppressLint("SetJavaScriptEnabled") public void setGithubContent(@NonNull String source, @Nullable String baseUrl, boolean wrap) {
|
||||
if (wrap) {
|
||||
setScrollbarFadingEnabled(false);
|
||||
setVerticalScrollBarEnabled(false);
|
||||
} else {
|
||||
getSettings().setJavaScriptEnabled(true);
|
||||
}
|
||||
if (!InputHelper.isEmpty(source)) {
|
||||
if (!wrap) addJavascriptInterface(new MarkDownInterceptorInterface(this), "Android");
|
||||
|
||||
8
app/src/main/res/drawable/rect_shape.xml
Normal file
8
app/src/main/res/drawable/rect_shape.xml
Normal file
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
|
||||
<corners android:radius="15dp"/>
|
||||
<solid android:color="@color/universal_primary_dark_color"/>
|
||||
|
||||
</shape>
|
||||
@ -247,7 +247,7 @@
|
||||
<string name="author">Author</string>
|
||||
<string name="fork_github">Fork on GitHub</string>
|
||||
<string name="send_email">Send an email</string>
|
||||
<string name="email_address">kosh20111@gmail.com</string>
|
||||
<string name="email_address">fastaccess.app@gmail.com</string>
|
||||
<string name="question_concerning_fasthub">Question concerning FastHub</string>
|
||||
<string name="feedback">Feedback</string>
|
||||
<string name="report_issue">Report an issue</string>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user