Fix fab hide scroll issue and clean up (#381)

Merge branch 'fix-fab-scroll-issue' of gitea.com:gitnex/GitNex into fix-fab-scroll-issue

Merge branch 'master' into fix-fab-scroll-issue

Merge branch 'master' into fix-fab-scroll-issue

Fix fab hide scroll issue and clean up

Co-authored-by: 6543 <6543@noreply.gitea.io>
Reviewed-on: https://gitea.com/gitnex/GitNex/pulls/381
Reviewed-by: 6543 <6543@noreply.gitea.io>
This commit is contained in:
M M Arif 2020-04-11 20:17:24 +00:00
parent 398cceed2f
commit adb8a8bf04
1 changed files with 49 additions and 73 deletions

View File

@ -17,7 +17,6 @@ import io.noties.markwon.ext.strikethrough.StrikethroughPlugin;
import io.noties.markwon.ext.tables.TablePlugin; import io.noties.markwon.ext.tables.TablePlugin;
import io.noties.markwon.ext.tasklist.TaskListPlugin; import io.noties.markwon.ext.tasklist.TaskListPlugin;
import io.noties.markwon.html.HtmlPlugin; import io.noties.markwon.html.HtmlPlugin;
import io.noties.markwon.image.AsyncDrawable;
import io.noties.markwon.image.DefaultMediaDecoder; import io.noties.markwon.image.DefaultMediaDecoder;
import io.noties.markwon.image.ImageItem; import io.noties.markwon.image.ImageItem;
import io.noties.markwon.image.ImagesPlugin; import io.noties.markwon.image.ImagesPlugin;
@ -34,6 +33,7 @@ import android.graphics.Color;
import android.graphics.Typeface; import android.graphics.Typeface;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.net.Uri; import android.net.Uri;
import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import android.text.Html; import android.text.Html;
@ -152,47 +152,37 @@ public class IssueDetailActivity extends BaseActivity {
DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(mRecyclerView.getContext(), DividerItemDecoration.VERTICAL); DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(mRecyclerView.getContext(), DividerItemDecoration.VERTICAL);
mRecyclerView.addItemDecoration(dividerItemDecoration); mRecyclerView.addItemDecoration(dividerItemDecoration);
createNewComment = findViewById(R.id.addNewComment); createNewComment.setOnClickListener(v -> startActivity(new Intent(ctx, ReplyToIssueActivity.class)));
createNewComment.setOnClickListener(new View.OnClickListener() {
@Override if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
public void onClick(View v) {
startActivity(new Intent(ctx, ReplyToIssueActivity.class)); scrollViewComments.setOnScrollChangeListener((v, scrollX, scrollY, oldScrollX, oldScrollY) -> {
} if ((scrollY - oldScrollY) > 0 && createNewComment.isShown()) {
});
mRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
if (dy > 0 && createNewComment.isShown()) {
createNewComment.setVisibility(View.GONE); createNewComment.setVisibility(View.GONE);
} else if (dy < 0) { }
else if ((scrollY - oldScrollY) < 0) {
createNewComment.setVisibility(View.VISIBLE); createNewComment.setVisibility(View.VISIBLE);
} }
} if (!scrollViewComments.canScrollVertically(1)) { // bottom
createNewComment.setVisibility(View.GONE);
}
@Override if (!scrollViewComments.canScrollVertically(-1)) { // top
public void onScrollStateChanged(@NonNull RecyclerView recyclerView, int newState) { createNewComment.setVisibility(View.VISIBLE);
super.onScrollStateChanged(recyclerView, newState); }
}
});
swipeRefresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { });
@Override
public void onRefresh() { }
new Handler().postDelayed(new Runnable() {
@Override swipeRefresh.setOnRefreshListener(() -> new Handler().postDelayed(() -> {
public void run() {
swipeRefresh.setRefreshing(false); swipeRefresh.setRefreshing(false);
IssueCommentsViewModel.loadIssueComments(instanceUrl, Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName, issueIndex, getApplicationContext()); IssueCommentsViewModel.loadIssueComments(instanceUrl, Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName, issueIndex, getApplicationContext());
}
}, 500); }, 500));
}
});
Typeface myTypeface; Typeface myTypeface;
@ -352,44 +342,35 @@ public class IssueDetailActivity extends BaseActivity {
final Markwon markwon = Markwon.builder(Objects.requireNonNull(getApplicationContext())) final Markwon markwon = Markwon.builder(Objects.requireNonNull(getApplicationContext()))
.usePlugin(CorePlugin.create()) .usePlugin(CorePlugin.create())
.usePlugin(ImagesPlugin.create(new ImagesPlugin.ImagesConfigure() { .usePlugin(ImagesPlugin.create(plugin -> {
@Override plugin.addSchemeHandler(new SchemeHandler() {
public void configureImages(@NonNull ImagesPlugin plugin) { @NonNull
plugin.addSchemeHandler(new SchemeHandler() { @Override
@NonNull public ImageItem handle(@NonNull String raw, @NonNull Uri uri) {
@Override
public ImageItem handle(@NonNull String raw, @NonNull Uri uri) {
final int resourceId = getApplicationContext().getResources().getIdentifier( final int resourceId = getApplicationContext().getResources().getIdentifier(
raw.substring("drawable://".length()), raw.substring("drawable://".length()),
"drawable", "drawable",
getApplicationContext().getPackageName()); getApplicationContext().getPackageName());
final Drawable drawable = getApplicationContext().getDrawable(resourceId); final Drawable drawable = getApplicationContext().getDrawable(resourceId);
assert drawable != null; assert drawable != null;
return ImageItem.withResult(drawable); return ImageItem.withResult(drawable);
} }
@NonNull @NonNull
@Override @Override
public Collection<String> supportedSchemes() { public Collection<String> supportedSchemes() {
return Collections.singleton("drawable"); return Collections.singleton("drawable");
} }
}); });
plugin.placeholderProvider(new ImagesPlugin.PlaceholderProvider() { plugin.placeholderProvider(drawable -> null);
@Nullable plugin.addMediaDecoder(GifMediaDecoder.create(false));
@Override plugin.addMediaDecoder(SvgMediaDecoder.create(getApplicationContext().getResources()));
public Drawable providePlaceholder(@NonNull AsyncDrawable drawable) { plugin.addMediaDecoder(SvgMediaDecoder.create());
return null; plugin.defaultMediaDecoder(DefaultMediaDecoder.create(getApplicationContext().getResources()));
} plugin.defaultMediaDecoder(DefaultMediaDecoder.create());
});
plugin.addMediaDecoder(GifMediaDecoder.create(false));
plugin.addMediaDecoder(SvgMediaDecoder.create(getApplicationContext().getResources()));
plugin.addMediaDecoder(SvgMediaDecoder.create());
plugin.defaultMediaDecoder(DefaultMediaDecoder.create(getApplicationContext().getResources()));
plugin.defaultMediaDecoder(DefaultMediaDecoder.create());
}
})) }))
.usePlugin(new AbstractMarkwonPlugin() { .usePlugin(new AbstractMarkwonPlugin() {
@ -575,12 +556,7 @@ public class IssueDetailActivity extends BaseActivity {
} }
private void initCloseListener() { private void initCloseListener() {
View.OnClickListener onClickListener = new View.OnClickListener() { View.OnClickListener onClickListener = view -> finish();
@Override
public void onClick(View view) {
finish();
}
};
} }
} }