diff --git a/app/src/main/assets/style.css b/app/src/main/assets/style.css index 7cbafd46..bb3051a1 100644 --- a/app/src/main/assets/style.css +++ b/app/src/main/assets/style.css @@ -100,7 +100,7 @@ body /* By default (td, body..) use verdana in black. */ body, td, th , tr { - color: #000000; + color: #FFFFFF; font-size: small; font-family: Trebuchet, sans-serif; } @@ -110,7 +110,7 @@ body, td, th , tr /* Input boxes - just a bit smaller than normal so they align well. */ input, textarea, button { - color: #000000; + color: #FFFFFF; font-family: Trebuchet, sans-serif; border: 1px solid #aaa; } @@ -122,7 +122,7 @@ input, button textarea { font-size: 100%; - color: #000000; + color: #FFFFFF; font-family: Trebuchet, sans-serif; } @@ -136,7 +136,7 @@ select { font-size: 90%; font-weight: normal; - color: #000000; + color: #FFFFFF; font-family: Trebuchet, sans-serif; } @@ -170,7 +170,7 @@ a img /* A code block - maybe even PHP ;). */ .code { - color: #000000; + color: #26A69A; background-color: #dddddd; font-family: "Comic Sans MS", "times new roman", monospace; font-size: x-small; @@ -228,17 +228,17 @@ a img /* Alternating backgrounds for posts, and several other sections of the forum. */ .windowbg { - color: #000000; + color: #FFFFFF; background-color: #E3E6E1; } .windowbg2 { - color: #000000; + color: #FFFFFF; background-color: #F2F5F0; } .windowbg3 { - color: #000000; + color: #FFFFFF; background-color: #E1E8E0; } /* the today container in calendar */ @@ -267,7 +267,7 @@ a img { font-weight: bold; background-color: #e4e2e0; - color: #000000; + color: #FFFFFF; } /* This is used for tables that have a grid/border background color (such as the topic listing.) */ .bordercolor @@ -506,14 +506,18 @@ img } .yt { - position: relative; + position: relative; } .embedded-video-play { - position: absolute; - top: 22%; - left: 10%; - width: 20%; - opacity: 0.7; - z-index: 2; + position: absolute; + top: 22%; + left: 10%; + width: 20%; + opacity: 0.7; + z-index: 2; } + +.customSignature{ + background: #323232; +} \ No newline at end of file diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/main/MainActivity.java b/app/src/main/java/gr/thmmy/mthmmy/activities/main/MainActivity.java index 8fb76090..0bb5df1d 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/main/MainActivity.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/main/MainActivity.java @@ -20,8 +20,8 @@ import gr.thmmy.mthmmy.activities.topic.TopicActivity; import gr.thmmy.mthmmy.data.Board; import gr.thmmy.mthmmy.data.TopicSummary; -import static gr.thmmy.mthmmy.activities.board.BoardActivity.EXTRAS_BOARD_TITLE; -import static gr.thmmy.mthmmy.activities.board.BoardActivity.EXTRAS_BOARD_URL; +import static gr.thmmy.mthmmy.activities.board.BoardActivity.BUNDLE_BOARD_TITLE; +import static gr.thmmy.mthmmy.activities.board.BoardActivity.BUNDLE_BOARD_URL; import static gr.thmmy.mthmmy.activities.topic.TopicActivity.BUNDLE_TOPIC_TITLE; import static gr.thmmy.mthmmy.activities.topic.TopicActivity.BUNDLE_TOPIC_URL; @@ -96,8 +96,8 @@ public class MainActivity extends BaseActivity implements RecentFragment.RecentF @Override public void onForumFragmentInteraction(Board board) { Intent i = new Intent(MainActivity.this, BoardActivity.class); - i.putExtra(EXTRAS_BOARD_URL, board.getBoardURL()); - i.putExtra(EXTRAS_BOARD_TITLE, board.getTitle()); + i.putExtra(BUNDLE_BOARD_URL, board.getBoardURL()); + i.putExtra(BUNDLE_BOARD_TITLE, board.getTitle()); startActivity(i); } diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/profile/ProfileActivity.java b/app/src/main/java/gr/thmmy/mthmmy/activities/profile/ProfileActivity.java index 900fbb32..a740af10 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/profile/ProfileActivity.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/profile/ProfileActivity.java @@ -51,15 +51,10 @@ import static gr.thmmy.mthmmy.activities.topic.TopicActivity.BUNDLE_TOPIC_URL; /** * Activity for user profile. When creating an Intent of this activity you need to bundle a String * containing this user's profile url using the key {@link #BUNDLE_PROFILE_URL}, a String containing - * this user's avatar url and a String containing the username. + * this user's avatar url using the key {@link #BUNDLE_THUMBNAIL_URL} and a String containing + * the username using the key {@link #BUNDLE_USERNAME}. */ -public class ProfileActivity extends BaseActivity implements LatestPostsFragment.LatestPostsFragmentInteractionListener{ - //Graphics - private TextView personalTextView; - private MaterialProgressBar progressBar; - private FloatingActionButton replyFAB; - private ViewPager viewPager; - //Other variables and constants +public class ProfileActivity extends BaseActivity implements LatestPostsFragment.LatestPostsFragmentInteractionListener { /** * Debug Tag for logging debug output to LogCat */ @@ -79,6 +74,12 @@ public class ProfileActivity extends BaseActivity implements LatestPostsFragment */ public static final String BUNDLE_USERNAME = "USERNAME"; private static final int THUMBNAIL_SIZE = 200; + + private TextView personalTextView; + private MaterialProgressBar progressBar; + private FloatingActionButton replyFAB; + private ViewPager viewPager; + private ProfileTask profileTask; private String personalText; private String profileUrl; @@ -90,6 +91,7 @@ public class ProfileActivity extends BaseActivity implements LatestPostsFragment Bundle extras = getIntent().getExtras(); String thumbnailUrl = extras.getString(BUNDLE_THUMBNAIL_URL); + if (thumbnailUrl == null) thumbnailUrl = ""; String username = extras.getString(BUNDLE_USERNAME); profileUrl = extras.getString(BUNDLE_PROFILE_URL); @@ -107,7 +109,7 @@ public class ProfileActivity extends BaseActivity implements LatestPostsFragment progressBar = (MaterialProgressBar) findViewById(R.id.progressBar); ImageView thumbnailView = (ImageView) findViewById(R.id.user_thumbnail); - if (thumbnailUrl != null && !Objects.equals(thumbnailUrl, "")) + if (!Objects.equals(thumbnailUrl, "")) //noinspection ConstantConditions Picasso.with(this) .load(thumbnailUrl) @@ -156,7 +158,7 @@ public class ProfileActivity extends BaseActivity implements LatestPostsFragment }); profileTask = new ProfileTask(); - profileTask.execute(profileUrl); //Attempt data parsing + profileTask.execute(profileUrl); //Attempts data parsing } @Override @@ -170,15 +172,19 @@ public class ProfileActivity extends BaseActivity implements LatestPostsFragment public void onLatestPostsFragmentInteraction(TopicSummary topicSummary) { Intent i = new Intent(ProfileActivity.this, TopicActivity.class); i.putExtra(BUNDLE_TOPIC_URL, topicSummary.getTopicUrl()); - i.putExtra(BUNDLE_TOPIC_TITLE, topicSummary.getTitle()); + i.putExtra(BUNDLE_TOPIC_TITLE, topicSummary.getTitle().substring(topicSummary.getTitle(). + lastIndexOf("/ ") + 2)); startActivity(i); } /** * An {@link AsyncTask} that handles asynchronous fetching of a profile page and parsing this - * user's personal text. + * user's personal text. The {@link Document} resulting from the parse is stored for use in + * the {@link SummaryFragment}. *

ProfileTask's {@link AsyncTask#execute execute} method needs a profile's url as String * parameter!

+ * + * @see Jsoup */ public class ProfileTask extends AsyncTask { //Class variables @@ -225,6 +231,7 @@ public class ProfileActivity extends BaseActivity implements LatestPostsFragment protected void onPostExecute(Boolean result) { if (!result) { //Parse failed! + Report.d(TAG, "Parse failed!"); Toast.makeText(getBaseContext() , "Fatal error!\n Aborting...", Toast.LENGTH_LONG).show(); finish(); @@ -247,7 +254,8 @@ public class ProfileActivity extends BaseActivity implements LatestPostsFragment /** * Simple method that sets up the {@link ViewPager} of a {@link ProfileActivity} - * @param viewPager the ViewPager to be setup + * + * @param viewPager the ViewPager to be setup * @param profilePage this profile's parsed page */ private void setupViewPager(ViewPager viewPager, Document profilePage) { @@ -265,18 +273,22 @@ public class ProfileActivity extends BaseActivity implements LatestPostsFragment ViewPagerAdapter(FragmentManager manager) { super(manager); } + @Override public Fragment getItem(int position) { return mFragmentList.get(position); } + @Override public int getCount() { return mFragmentList.size(); } + void addFrag(Fragment fragment, String title) { mFragmentList.add(fragment); mFragmentTitleList.add(title); } + @Override public CharSequence getPageTitle(int position) { return mFragmentTitleList.get(position); diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/profile/latestPosts/LatestPostsAdapter.java b/app/src/main/java/gr/thmmy/mthmmy/activities/profile/latestPosts/LatestPostsAdapter.java index 737e4024..0f0f05c5 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/profile/latestPosts/LatestPostsAdapter.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/profile/latestPosts/LatestPostsAdapter.java @@ -1,6 +1,5 @@ package gr.thmmy.mthmmy.activities.profile.latestPosts; -import android.annotation.SuppressLint; import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; @@ -16,12 +15,15 @@ import me.zhanghai.android.materialprogressbar.MaterialProgressBar; import static gr.thmmy.mthmmy.activities.profile.latestPosts.LatestPostsFragment.parsedTopicSummaries; +/** + * {@link RecyclerView.Adapter} that can display a {@link TopicSummary} and makes a call to the + * specified {@link LatestPostsFragment.LatestPostsFragmentInteractionListener}. + */ class LatestPostsAdapter extends RecyclerView.Adapter { private static final String TAG = "LatestPostsAdapter"; private final int VIEW_TYPE_ITEM = 0; private final int VIEW_TYPE_LOADING = 1; - //private OnLoadMoreListener mOnLoadMoreListener; - private LatestPostsFragment.LatestPostsFragmentInteractionListener interactionListener; + final private LatestPostsFragment.LatestPostsFragmentInteractionListener interactionListener; LatestPostsAdapter(BaseFragment.FragmentInteractionListener interactionListener){ this.interactionListener = (LatestPostsFragment.LatestPostsFragmentInteractionListener) interactionListener; @@ -31,10 +33,6 @@ class LatestPostsAdapter extends RecyclerView.Adapter { void onLoadMore(); } - void setOnLoadMoreListener(OnLoadMoreListener mOnLoadMoreListener) { - //this.mOnLoadMoreListener = mOnLoadMoreListener; - } - @Override public int getItemViewType(int position) { return parsedTopicSummaries.get(position) == null ? VIEW_TYPE_LOADING : VIEW_TYPE_ITEM; @@ -54,7 +52,6 @@ class LatestPostsAdapter extends RecyclerView.Adapter { return null; } - @SuppressLint("SetJavaScriptEnabled") @Override public void onBindViewHolder(final RecyclerView.ViewHolder holder, int position) { if (holder instanceof LatestPostViewHolder) { @@ -90,10 +87,10 @@ class LatestPostsAdapter extends RecyclerView.Adapter { } private static class LatestPostViewHolder extends RecyclerView.ViewHolder { - RelativeLayout latestPostsRow; - TextView postTitle; - TextView postDate; - WebView post; + final RelativeLayout latestPostsRow; + final TextView postTitle; + final TextView postDate; + final WebView post; LatestPostViewHolder(View itemView) { super(itemView); @@ -105,7 +102,7 @@ class LatestPostsAdapter extends RecyclerView.Adapter { } private static class LoadingViewHolder extends RecyclerView.ViewHolder { - MaterialProgressBar progressBar; + final MaterialProgressBar progressBar; LoadingViewHolder(View itemView) { super(itemView); diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/profile/latestPosts/LatestPostsFragment.java b/app/src/main/java/gr/thmmy/mthmmy/activities/profile/latestPosts/LatestPostsFragment.java index b0417809..5b811550 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/profile/latestPosts/LatestPostsFragment.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/profile/latestPosts/LatestPostsFragment.java @@ -41,20 +41,20 @@ public class LatestPostsFragment extends BaseFragment { /** * The key to use when putting profile's url String to {@link LatestPostsFragment}'s Bundle. */ - static final String PROFILE_URL = "PROFILE_DOCUMENT"; + private static final String PROFILE_URL = "PROFILE_URL"; /** * {@link ArrayList} of {@link TopicSummary} objects used to hold profile's latest posts. Data - * are added in {@link LatestPostsFragment.ProfileLatestPostsTask}. + * are added in {@link LatestPostsTask}. */ static ArrayList parsedTopicSummaries; private LatestPostsAdapter latestPostsAdapter; private int numberOfPages = -1; private int pagesLoaded = 0; private String profileUrl; - private ProfileLatestPostsTask profileLatestPostsTask; + private LatestPostsTask profileLatestPostsTask; private MaterialProgressBar progressBar; private boolean isLoadingMore; - static int visibleThreshold = 5; + private static final int visibleThreshold = 5; private int lastVisibleItem, totalItemCount; public LatestPostsFragment() { @@ -87,7 +87,6 @@ public class LatestPostsFragment extends BaseFragment { public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final View rootView = inflater.inflate(R.layout.profile_fragment_latest_posts, container, false); - latestPostsAdapter = new LatestPostsAdapter(fragmentInteractionListener); RecyclerView mainContent = (RecyclerView) rootView.findViewById(R.id.profile_latest_posts_recycler); mainContent.setAdapter(latestPostsAdapter); @@ -105,19 +104,18 @@ public class LatestPostsFragment extends BaseFragment { latestPostsAdapter.notifyItemInserted(parsedTopicSummaries.size() - 1); //Load data - profileLatestPostsTask = new ProfileLatestPostsTask(); + profileLatestPostsTask = new LatestPostsTask(); profileLatestPostsTask.execute(profileUrl + ";sa=showPosts;start=" + pagesLoaded * 15); ++pagesLoaded; } } }; - latestPostsAdapter.setOnLoadMoreListener(onLoadMoreListener); + //latestPostsAdapter.setOnLoadMoreListener(); mainContent.addOnScrollListener(new RecyclerView.OnScrollListener() { @Override public void onScrolled(RecyclerView recyclerView, int dx, int dy) { super.onScrolled(recyclerView, dx, dy); - totalItemCount = layoutManager.getItemCount(); lastVisibleItem = layoutManager.findLastVisibleItemPosition(); @@ -135,7 +133,7 @@ public class LatestPostsFragment extends BaseFragment { public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); if (parsedTopicSummaries.isEmpty()) { - profileLatestPostsTask = new ProfileLatestPostsTask(); + profileLatestPostsTask = new LatestPostsTask(); profileLatestPostsTask.execute(profileUrl + ";sa=showPosts"); pagesLoaded = 1; } @@ -155,22 +153,20 @@ public class LatestPostsFragment extends BaseFragment { /** * An {@link AsyncTask} that handles asynchronous fetching of a profile page and parsing this - * user's personal text. - *

ProfileTask's {@link AsyncTask#execute execute} method needs a profile's url as String + * user's latest posts. + *

LatestPostsTask's {@link AsyncTask#execute execute} method needs a profile's url as String * parameter!

*/ - public class ProfileLatestPostsTask extends AsyncTask { + public class LatestPostsTask extends AsyncTask { //Class variables /** * Debug Tag for logging debug output to LogCat */ @SuppressWarnings("unused") - private static final String TAG = "ProfileLatestPostsTask"; //Separate tag for AsyncTask + private static final String TAG = "LatestPostsTask"; //Separate tag for AsyncTask protected void onPreExecute() { - if (!isLoadingMore) { - progressBar.setVisibility(ProgressBar.VISIBLE); - } + if (!isLoadingMore) progressBar.setVisibility(ProgressBar.VISIBLE); } protected Boolean doInBackground(String... profileUrl) { @@ -190,6 +186,7 @@ public class LatestPostsFragment extends BaseFragment { protected void onPostExecute(Boolean result) { if (!result) { //Parse failed! + Report.d(TAG, "Parse failed!"); Toast.makeText(getContext() , "Fatal error!\n Aborting...", Toast.LENGTH_LONG).show(); getActivity().finish(); @@ -203,14 +200,13 @@ public class LatestPostsFragment extends BaseFragment { private boolean parseLatestPosts(Document latestPostsPage) { Elements latestPostsRows = latestPostsPage. select("td:has(table:Contains(Show Posts)):not([style]) > table"); - if (latestPostsRows == null) + if (latestPostsRows.isEmpty()) { latestPostsRows = latestPostsPage. - select("td:has(table:Contains(Show Posts)):not([style]) > table"); - + select("td:has(table:Contains(Εμφάνιση μηνυμάτων)):not([style]) > table"); + } //Removes loading item if (isLoadingMore) { parsedTopicSummaries.remove(parsedTopicSummaries.size() - 1); - } for (Element row : latestPostsRows) { @@ -219,7 +215,7 @@ public class LatestPostsFragment extends BaseFragment { if (numberOfPages == -1) { Elements pages = row.select("tr.catbg3 a"); for (Element page : pages) { - if (Integer.parseInt(page.text()) >= numberOfPages) + if (Integer.parseInt(page.text()) > numberOfPages) numberOfPages = Integer.parseInt(page.text()); } } @@ -228,7 +224,7 @@ public class LatestPostsFragment extends BaseFragment { if (rowHeader.size() != 2) { return false; } else { - pTopicTitle = rowHeader.text(); + pTopicTitle = rowHeader.first().text().trim(); pTopicUrl = rowHeader.first().select("a").last().attr("href"); pDateTime = rowHeader.last().text(); } @@ -256,7 +252,6 @@ public class LatestPostsFragment extends BaseFragment { + "\"\"" + "" - //+ "" + ""); } } diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/profile/stats/StatsFragment.java b/app/src/main/java/gr/thmmy/mthmmy/activities/profile/stats/StatsFragment.java index 33dc692d..e1ba8400 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/profile/stats/StatsFragment.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/profile/stats/StatsFragment.java @@ -54,7 +54,7 @@ public class StatsFragment extends Fragment { /** * The key to use when putting profile's url String to {@link StatsFragment}'s Bundle. */ - static final String PROFILE_URL = "PROFILE_DOCUMENT"; + private static final String PROFILE_URL = "PROFILE_DOCUMENT"; private String profileUrl; private ProfileStatsTask profileStatsTask; private LinearLayout mainContent; @@ -62,9 +62,9 @@ public class StatsFragment extends Fragment { private boolean haveParsed = false; private String generalStatisticsTitle = "", generalStatistics = "", postingActivityByTimeTitle = "", mostPopularBoardsByPostsTitle = "", mostPopularBoardsByActivityTitle = ""; - private List postingActivityByTime = new ArrayList<>(); - private List mostPopularBoardsByPosts = new ArrayList<>(), mostPopularBoardsByActivity = new ArrayList<>(); - private ArrayList mostPopularBoardsByPostsLabels = new ArrayList<>(), mostPopularBoardsByActivityLabels = new ArrayList<>(); + final private List postingActivityByTime = new ArrayList<>(); + final private List mostPopularBoardsByPosts = new ArrayList<>(), mostPopularBoardsByActivity = new ArrayList<>(); + final private ArrayList mostPopularBoardsByPostsLabels = new ArrayList<>(), mostPopularBoardsByActivityLabels = new ArrayList<>(); public StatsFragment() { // Required empty public constructor @@ -124,7 +124,7 @@ public class StatsFragment extends Fragment { * {@link AsyncTask#onPostExecute(Object) OnPostExecute} method calls {@link #()} * to build graphics. *

- *

Calling ProfileSummaryTask's {@link AsyncTask#execute execute} method needs to have profile's url + *

Calling SummaryTask's {@link AsyncTask#execute execute} method needs to have profile's url * as String parameter!

*/ public class ProfileStatsTask extends AsyncTask { @@ -160,6 +160,7 @@ public class StatsFragment extends Fragment { @Override protected void onPostExecute(Boolean result) { if (!result) { //Parse failed! + Report.d(TAG, "Parse failed!"); Toast.makeText(getContext() , "Fatal error!\n Aborting...", Toast.LENGTH_LONG).show(); getActivity().finish(); @@ -170,17 +171,17 @@ public class StatsFragment extends Fragment { } private boolean parseStats(Document statsPage) { - if (statsPage.select("table.bordercolor>tbody>tr").size() != 6) - return false; //It's my profile + if (statsPage.select("table.bordercolor[align]>tbody>tr").size() != 6) + return false; { - Elements titleRows = statsPage.select("table.bordercolor>tbody>tr.titlebg"); + Elements titleRows = statsPage.select("table.bordercolor[align]>tbody>tr.titlebg"); generalStatisticsTitle = titleRows.first().text(); postingActivityByTimeTitle = titleRows.get(1).text(); mostPopularBoardsByPostsTitle = titleRows.last().select("td").first().text(); mostPopularBoardsByActivityTitle = titleRows.last().select("td").last().text(); } { - Elements statsRows = statsPage.select("table.bordercolor>tbody>tr:not(.titlebg)"); + Elements statsRows = statsPage.select("table.bordercolor[align]>tbody>tr:not(.titlebg)"); { Elements generalStatisticsRows = statsRows.first().select("tbody>tr"); for (Element generalStatisticsRow : generalStatisticsRows) @@ -341,7 +342,7 @@ public class StatsFragment extends Fragment { } class MyXAxisValueFormatter implements IAxisValueFormatter { - private ArrayList mValues; + private final ArrayList mValues; MyXAxisValueFormatter(ArrayList values) { this.mValues = values; diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/profile/summary/SummaryFragment.java b/app/src/main/java/gr/thmmy/mthmmy/activities/profile/summary/SummaryFragment.java index 9951d457..5e89ca5c 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/profile/summary/SummaryFragment.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/profile/summary/SummaryFragment.java @@ -5,7 +5,6 @@ import android.os.Build; import android.os.Bundle; import android.support.v4.app.Fragment; import android.text.Html; -import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -37,17 +36,17 @@ public class SummaryFragment extends Fragment { /** * The key to use when putting profile's source code String to {@link SummaryFragment}'s Bundle. */ - static final String PROFILE_DOCUMENT = "PROFILE_DOCUMENT"; + private static final String PROFILE_DOCUMENT = "PROFILE_DOCUMENT"; /** * {@link ArrayList} of Strings used to hold profile's information. Data are added in - * {@link SummaryFragment.ProfileSummaryTask}. + * {@link SummaryTask}. */ private ArrayList parsedProfileSummaryData; /** * A {@link Document} holding this profile's source code. */ private Document profileSummaryDocument; - private ProfileSummaryTask profileSummaryTask; + private SummaryTask summaryTask; private LinearLayout mainContent; public SummaryFragment() { @@ -90,8 +89,8 @@ public class SummaryFragment extends Fragment { public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); if (parsedProfileSummaryData.isEmpty()) { - profileSummaryTask = new ProfileSummaryTask(); - profileSummaryTask.execute(profileSummaryDocument); + summaryTask = new SummaryTask(); + summaryTask.execute(profileSummaryDocument); } Report.d(TAG, "onActivityCreated"); } @@ -99,8 +98,8 @@ public class SummaryFragment extends Fragment { @Override public void onDestroy() { super.onDestroy(); - if (profileSummaryTask != null && profileSummaryTask.getStatus() != AsyncTask.Status.RUNNING) - profileSummaryTask.cancel(true); + if (summaryTask != null && summaryTask.getStatus() != AsyncTask.Status.RUNNING) + summaryTask.cancel(true); } /** @@ -108,16 +107,16 @@ public class SummaryFragment extends Fragment { * {@link AsyncTask#onPostExecute(Object) OnPostExecute} method calls {@link #populateLayout()} * to build graphics. *

- *

Calling ProfileSummaryTask's {@link AsyncTask#execute execute} method needs to have profile's url + *

Calling SummaryTask's {@link AsyncTask#execute execute} method needs to have profile's url * as String parameter!

*/ - public class ProfileSummaryTask extends AsyncTask { + public class SummaryTask extends AsyncTask { //Class variables /** * Debug Tag for logging debug output to LogCat */ @SuppressWarnings("unused") - private static final String TAG = "TopicTask"; //Separate tag for AsyncTask + private static final String TAG = "SummaryTask"; //Separate tag for AsyncTask protected Void doInBackground(Document... profileSummaryPage) { parsedProfileSummaryData = parseProfileSummary(profileSummaryPage[0]); @@ -142,16 +141,15 @@ public class SummaryFragment extends Fragment { //Contains all summary's rows Elements summaryRows = profile.select(".bordercolor > tbody:nth-child(1) > tr:nth-child(2) tr"); - for (Element row : summaryRows) { - String rowText = row.text(), pHtml = ""; + for (Element summaryRow : summaryRows) { + String rowText = summaryRow.text(), pHtml = ""; - //Horizontal rule rows - if (row.select("td").size() == 1) + if (summaryRow.select("td").size() == 1) //Horizontal rule rows pHtml = ""; else if (rowText.contains("Signature") || rowText.contains("Υπογραφή")) { //This needs special handling since it may have css { //Fix embedded videos - Elements noembedTag = row.select("noembed"); + Elements noembedTag = summaryRow.select("noembed"); ArrayList embededVideosUrls = new ArrayList<>(); for (Element _noembed : noembedTag) { @@ -160,7 +158,7 @@ public class SummaryFragment extends Fragment { , _noembed.text().indexOf("target") - 2)); } - pHtml = row.html(); + pHtml = summaryRow.html(); int tmp_counter = 0; while (pHtml.contains("" + pHtml); - } else if (!rowText.contains("Name") && !rowText.contains("Όνομα")) { //Don't add username twice - if (Objects.equals(row.select("td").get(1).text(), "")) + pHtml = ("\n" + + "
\n" + pHtml + "\n
"); + } else if (!rowText.contains("Name") && !rowText.contains("Όνομα")) { //Doesn't add username twice + if (Objects.equals(summaryRow.select("td").get(1).text(), "")) continue; //Style parsed information with html - pHtml = "" + row.select("td").first().text() + " " - + row.select("td").get(1).text(); + pHtml = "" + summaryRow.select("td").first().text() + " " + + summaryRow.select("td").get(1).text(); } parsedInformation.add(pHtml); } @@ -204,10 +203,12 @@ public class SummaryFragment extends Fragment { private void populateLayout() { for (String profileSummaryRow : parsedProfileSummaryData) { if (profileSummaryRow.contains("Signature") - || profileSummaryRow.contains("Υπογραφή")) { + || profileSummaryRow.contains("Υπογραφή")) { //This may contain css WebView signatureEntry = new WebView(this.getContext()); signatureEntry.loadDataWithBaseURL("file:///android_asset/", profileSummaryRow, "text/html", "UTF-8", null); + mainContent.addView(signatureEntry); + continue; } TextView entry = new TextView(this.getContext()); @@ -216,7 +217,6 @@ public class SummaryFragment extends Fragment { } else { //noinspection deprecation entry.setTextColor(getResources().getColor(R.color.primary_text)); - } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { entry.setText(Html.fromHtml(profileSummaryRow, Html.FROM_HTML_MODE_LEGACY)); @@ -226,7 +226,6 @@ public class SummaryFragment extends Fragment { } mainContent.addView(entry); - Log.d(TAG, "new: " + profileSummaryRow); } } } diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java index 9db884f3..d9cd670c 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java @@ -322,6 +322,7 @@ public class TopicActivity extends BaseActivity { protected void onPreExecute() { progressBar.setVisibility(ProgressBar.VISIBLE); + paginationEnable(false); replyFAB.setEnabled(false); } @@ -392,10 +393,7 @@ public class TopicActivity extends BaseActivity { pageIndicator.setText(String.valueOf(thisPage) + "/" + String.valueOf(numberOfPages)); pageRequestValue = thisPage; - firstPage.setEnabled(true); - previousPage.setEnabled(true); - nextPage.setEnabled(true); - lastPage.setEnabled(true); + paginationEnable(true); if (topicTitle == null || Objects.equals(topicTitle, "")) toolbar.setTitle(parsedTitle); @@ -408,6 +406,7 @@ public class TopicActivity extends BaseActivity { break; default: //Parse failed - should never happen + Report.d(TAG, "Parse failed!"); Toast.makeText(getBaseContext(), "Fatal Error", Toast.LENGTH_SHORT).show(); finish(); break; @@ -477,4 +476,11 @@ public class TopicActivity extends BaseActivity { } } } + + private void paginationEnable(boolean enabled) { + firstPage.setEnabled(enabled); + previousPage.setEnabled(enabled); + nextPage.setEnabled(enabled); + lastPage.setEnabled(enabled); + } } \ No newline at end of file diff --git a/app/src/main/res/layout/activity_board.xml b/app/src/main/res/layout/activity_board.xml index 6685f2e3..cfc80bdd 100644 --- a/app/src/main/res/layout/activity_board.xml +++ b/app/src/main/res/layout/activity_board.xml @@ -7,7 +7,7 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:fitsSystemWindows="true" - tools:context=".activities.board.BoardActivity"> + tools:context=".activities.topic.TopicActivity"> + + + + + + + + + + + + + + + + + app:mpb_progressStyle="horizontal"/> + + + + - \ No newline at end of file