Skip to content
This repository has been archived by the owner on Sep 30, 2021. It is now read-only.

Commit

Permalink
this commit fixes #598
Browse files Browse the repository at this point in the history
  • Loading branch information
Kosh committed Jun 4, 2017
1 parent 6e520e5 commit b27e6ab
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 73 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
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;
Expand Down Expand Up @@ -82,8 +81,7 @@ public static FeedsFragment newInstance() {
}

@Override public void showProgress(@StringRes int resId) {

refresh.setRefreshing(true);
refresh.setRefreshing(true);
stateLayout.showProgress();
}

Expand Down Expand Up @@ -133,45 +131,7 @@ public static FeedsFragment newInstance() {
}

@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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
package com.fastaccess.ui.modules.trending

import android.support.design.widget.NavigationView
import com.fastaccess.ui.base.mvp.BaseMvp

/**
* Created by Kosh on 30 May 2017, 10:51 PM
*/

interface TrendingMvp {
interface View : BaseMvp.FAView, NavigationView.OnNavigationItemSelectedListener {
interface View : BaseMvp.FAView{
fun onAppend(title: String)
}

Expand Down
53 changes: 29 additions & 24 deletions app/src/main/java/com/prettifier/pretty/helper/PrettifyHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,30 @@

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 " +
Expand All @@ -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) {
Expand All @@ -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.
}

}

0 comments on commit b27e6ab

Please sign in to comment.