mirror of
https://github.com/k0shk0sh/FastHub.git
synced 2025-12-08 19:05:54 +00:00
this commit fixes #598
This commit is contained in:
parent
6e520e5f13
commit
b27e6abbd5
@ -11,7 +11,6 @@ import android.view.View;
|
||||
import com.fastaccess.R;
|
||||
import com.fastaccess.data.dao.SimpleUrlsModel;
|
||||
import com.fastaccess.data.dao.model.Event;
|
||||
import com.fastaccess.helper.ActivityHelper;
|
||||
import com.fastaccess.helper.PrefGetter;
|
||||
import com.fastaccess.provider.rest.loadmore.OnLoadMore;
|
||||
import com.fastaccess.provider.scheme.SchemeParser;
|
||||
@ -82,8 +81,7 @@ public class FeedsFragment extends BaseFragment<FeedsMvp.View, FeedsPresenter> i
|
||||
}
|
||||
|
||||
@Override public void showProgress(@StringRes int resId) {
|
||||
|
||||
refresh.setRefreshing(true);
|
||||
refresh.setRefreshing(true);
|
||||
stateLayout.showProgress();
|
||||
}
|
||||
|
||||
@ -133,45 +131,7 @@ refresh.setRefreshing(true);
|
||||
}
|
||||
|
||||
@Override public void onShowGuide(@NonNull View itemView, @NonNull Event model) {
|
||||
if (!PrefGetter.isUserIconGuideShowed()) {
|
||||
final boolean[] dismissed = {false};
|
||||
/*new MaterialTapTargetPrompt.Builder(getActivity())
|
||||
.setTarget(itemView.findViewById(R.id.avatarLayout))
|
||||
.setPrimaryText(R.string.users)
|
||||
.setSecondaryText(R.string.avatar_click_hint)
|
||||
.setBackgroundColourAlpha(244)
|
||||
.setBackgroundColour(ViewHelper.getAccentColor(getContext()))
|
||||
.setOnHidePromptListener(new MaterialTapTargetPrompt.OnHidePromptListener() {
|
||||
@Override public void onHidePrompt(MotionEvent event, boolean tappedTarget) {}
|
||||
|
||||
@Override public void onHidePromptComplete() {
|
||||
if (!dismissed[0])
|
||||
new MaterialTapTargetPrompt.Builder(getActivity())
|
||||
.setTarget(itemView)
|
||||
.setPrimaryText(R.string.fork)
|
||||
.setSecondaryText(R.string.feeds_fork_hint)
|
||||
.setCaptureTouchEventOutsidePrompt(true)
|
||||
.setBackgroundColourAlpha(244)
|
||||
.setBackgroundColour(ViewHelper.getAccentColor(getContext()))
|
||||
.setOnHidePromptListener(new MaterialTapTargetPrompt.OnHidePromptListener() {
|
||||
@Override
|
||||
public void onHidePrompt(MotionEvent motionEvent, boolean b) {
|
||||
ActivityHelper.hideDismissHints(FeedsFragment.this.getContext());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onHidePromptComplete() {
|
||||
|
||||
}
|
||||
})
|
||||
.show();
|
||||
ActivityHelper.bringDismissAllToFront(getContext());
|
||||
}
|
||||
})
|
||||
.setCaptureTouchEventOutsidePrompt(true)
|
||||
.show();*/
|
||||
ActivityHelper.showDismissHints(getContext(), () -> dismissed[0] = true);
|
||||
}
|
||||
if (!PrefGetter.isUserIconGuideShowed()) {}
|
||||
}
|
||||
|
||||
private void showReload() {
|
||||
|
||||
@ -93,7 +93,10 @@ class TrendingActivity : BaseActivity<TrendingMvp.View, TrendingPresenter>(), Tr
|
||||
daily.setOnClickListener { onDailyClicked() }
|
||||
weekly.setOnClickListener { onWeeklyClicked() }
|
||||
monthly.setOnClickListener { onMonthlyClicked() }
|
||||
navMenu.setNavigationItemSelectedListener(this)
|
||||
navMenu.setNavigationItemSelectedListener({ item ->
|
||||
closeDrawerLayout()
|
||||
onItemClicked(item)
|
||||
})
|
||||
setupIntent(savedInstanceState)
|
||||
presenter.onLoadLanguage()
|
||||
onSelectTrending()
|
||||
@ -131,10 +134,6 @@ class TrendingActivity : BaseActivity<TrendingMvp.View, TrendingPresenter>(), Tr
|
||||
return true
|
||||
}
|
||||
|
||||
override fun onNavigationItemSelected(item: MenuItem): Boolean {
|
||||
closeDrawerLayout()
|
||||
return onItemClicked(item)
|
||||
}
|
||||
|
||||
private fun closeDrawerLayout() {
|
||||
drawerLayout.closeDrawer(Gravity.END)
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
package com.fastaccess.ui.modules.trending
|
||||
|
||||
import android.support.design.widget.NavigationView
|
||||
import com.fastaccess.ui.base.mvp.BaseMvp
|
||||
|
||||
/**
|
||||
@ -8,7 +7,7 @@ import com.fastaccess.ui.base.mvp.BaseMvp
|
||||
*/
|
||||
|
||||
interface TrendingMvp {
|
||||
interface View : BaseMvp.FAView, NavigationView.OnNavigationItemSelectedListener {
|
||||
interface View : BaseMvp.FAView{
|
||||
fun onAppend(title: String)
|
||||
}
|
||||
|
||||
|
||||
@ -8,29 +8,30 @@ import android.support.annotation.NonNull;
|
||||
|
||||
public class PrettifyHelper {
|
||||
|
||||
@NonNull private final static String HTML_CONTENT =
|
||||
"<!DOCTYPE html>\n" +
|
||||
"<html>\n" +
|
||||
"<head>\n" +
|
||||
" <meta charset=\"utf-8\">\n" +
|
||||
" <link rel=\"stylesheet\" href=\"./styles/%s\">\n" +
|
||||
" %s\n" +
|
||||
"</head>\n" +
|
||||
"<body onload=\"prettyPrint()\">\n" +
|
||||
"<pre class=\"prettyprint linenums\">%s</pre>\n" +
|
||||
"<script src=\"./js/prettify.js\"></script>\n" +
|
||||
"<script>\n" +
|
||||
"function scrollToLineNumber(lineNo) {\n" +
|
||||
" var normalizedLineNo = (lineNo - 1) %% 10;\n" +
|
||||
" var nthLineNo = Math.floor((lineNo - 1) / 10);\n" +
|
||||
" var elLines = document.querySelectorAll('li.L' + normalizedLineNo);\n" +
|
||||
" if (elLines[nthLineNo]) {\n" +
|
||||
" elLines[nthLineNo].scrollIntoView();\n" +
|
||||
" }\n" +
|
||||
"}" +
|
||||
"</script>" +
|
||||
"</body>\n" +
|
||||
"</html>";
|
||||
@NonNull private static String getHtmlContent(@NonNull String css, @NonNull String text, @NonNull String wrapStyle) {
|
||||
return "<!DOCTYPE html>\n" +
|
||||
"<html>\n" +
|
||||
"<head>\n" +
|
||||
" <meta charset=\"utf-8\">\n" +
|
||||
" <link rel=\"stylesheet\" href=\"./styles/" + css + "\">\n" +
|
||||
" " + wrapStyle + "\n" +
|
||||
"</head>\n" +
|
||||
"<body onload=\"" + (textTooLarge(text) ? "" : "prettyPrint()") + "\">\n" +
|
||||
"<pre class=\"prettyprint linenums\">" + text + "</pre>\n" +
|
||||
"<script src=\"./js/prettify.js\"></script>\n" +
|
||||
"<script>\n" +
|
||||
"function scrollToLineNumber(lineNo) {\n" +
|
||||
" var normalizedLineNo = (lineNo - 1) %% 10;\n" +
|
||||
" var nthLineNo = Math.floor((lineNo - 1) / 10);\n" +
|
||||
" var elLines = document.querySelectorAll('li.L' + normalizedLineNo);\n" +
|
||||
" if (elLines[nthLineNo]) {\n" +
|
||||
" elLines[nthLineNo].scrollIntoView();\n" +
|
||||
" }\n" +
|
||||
"}" +
|
||||
"</script>" +
|
||||
"</body>\n" +
|
||||
"</html>";
|
||||
}
|
||||
|
||||
@NonNull private static final String WRAPPED_STYLE =
|
||||
"<style>\n " +
|
||||
@ -55,7 +56,7 @@ public class PrettifyHelper {
|
||||
|
||||
|
||||
@NonNull public static String generateContent(@NonNull String source, boolean isDark, boolean wrap) {
|
||||
return String.format(HTML_CONTENT, getStyle(isDark), wrap ? WRAPPED_STYLE : "", getFormattedSource(source));
|
||||
return getHtmlContent(getStyle(isDark), getFormattedSource(source), wrap ? WRAPPED_STYLE : "");
|
||||
}
|
||||
|
||||
@NonNull private static String getFormattedSource(@NonNull String source) {
|
||||
@ -67,4 +68,8 @@ public class PrettifyHelper {
|
||||
return !isDark ? "prettify.css" : "prettify_dark.css";
|
||||
}
|
||||
|
||||
private static boolean textTooLarge(@NonNull String text) {
|
||||
return text.length() > 204800;//>200kb ? disable highlighting to avoid crash.
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user