Browse Source

Version 1.2.1

master v1.2.1
Apostolos Fanakis 8 years ago
parent
commit
c0d1213bed
  1. 2
      VERSION
  2. 4
      app/build.gradle
  3. 13
      app/src/main/java/gr/thmmy/mthmmy/activities/board/BoardActivity.java
  4. 19
      app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java
  5. 11
      app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicAdapter.java
  6. 2
      app/src/main/res/layout/activity_topic.xml

2
VERSION

@ -1 +1 @@
1.2.0 1.2.1

4
app/build.gradle

@ -9,8 +9,8 @@ android {
applicationId "gr.thmmy.mthmmy" applicationId "gr.thmmy.mthmmy"
minSdkVersion 19 minSdkVersion 19
targetSdkVersion 25 targetSdkVersion 25
versionCode 6 versionCode 7
versionName "1.2.0" versionName "1.2.1"
archivesBaseName = "mTHMMY-v$versionName" archivesBaseName = "mTHMMY-v$versionName"
} }

13
app/src/main/java/gr/thmmy/mthmmy/activities/board/BoardActivity.java

@ -54,6 +54,7 @@ public class BoardActivity extends BaseActivity implements BoardAdapter.OnLoadMo
private String boardUrl; private String boardUrl;
private String boardTitle; private String boardTitle;
private String parsedTitle;
private int numberOfPages = -1; private int numberOfPages = -1;
private int pagesLoaded = 0; private int pagesLoaded = 0;
@ -175,7 +176,7 @@ public class BoardActivity extends BaseActivity implements BoardAdapter.OnLoadMo
* <p>BoardTask's {@link AsyncTask#execute execute} method needs a boards's url as String * <p>BoardTask's {@link AsyncTask#execute execute} method needs a boards's url as String
* parameter!</p> * parameter!</p>
*/ */
public class BoardTask extends AsyncTask<String, Void, Void> { private class BoardTask extends AsyncTask<String, Void, Void> {
@Override @Override
protected void onPreExecute() { protected void onPreExecute() {
if (!isLoadingMore) progressBar.setVisibility(ProgressBar.VISIBLE); if (!isLoadingMore) progressBar.setVisibility(ProgressBar.VISIBLE);
@ -200,7 +201,12 @@ public class BoardActivity extends BaseActivity implements BoardAdapter.OnLoadMo
@Override @Override
protected void onPostExecute(Void voids) { protected void onPostExecute(Void voids) {
if (boardTitle == null || Objects.equals(boardTitle, "")) toolbar.setTitle(boardTitle); if (boardTitle == null || Objects.equals(boardTitle, "")
|| !Objects.equals(boardTitle, parsedTitle)) {
boardTitle = parsedTitle;
toolbar.setTitle(boardTitle);
thisPageBookmark = new Bookmark(boardTitle, ThmmyPage.getBoardId(boardUrl));
}
//Parse was successful //Parse was successful
++pagesLoaded; ++pagesLoaded;
@ -211,8 +217,7 @@ public class BoardActivity extends BaseActivity implements BoardAdapter.OnLoadMo
} }
private void parseBoard(Document boardPage) { private void parseBoard(Document boardPage) {
if (boardTitle == null || Objects.equals(boardTitle, "")) parsedTitle = boardPage.select("div.nav a.nav").last().text();
boardTitle = boardPage.select("div.nav a.nav").last().text();
//Removes loading item //Removes loading item
if (isLoadingMore) { if (isLoadingMore) {

19
app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java

@ -165,7 +165,7 @@ public class TopicActivity extends BaseActivity {
recyclerView.setHasFixedSize(true); recyclerView.setHasFixedSize(true);
LinearLayoutManager layoutManager = new LinearLayoutManager(getApplicationContext()); LinearLayoutManager layoutManager = new LinearLayoutManager(getApplicationContext());
recyclerView.setLayoutManager(layoutManager); recyclerView.setLayoutManager(layoutManager);
topicAdapter = new TopicAdapter(this, postsList, topicTask, topicTitle, loadedPageUrl); topicAdapter = new TopicAdapter(this, postsList, topicTask);
recyclerView.setAdapter(topicAdapter); recyclerView.setAdapter(topicAdapter);
replyFAB = (FloatingActionButton) findViewById(R.id.topic_fab); replyFAB = (FloatingActionButton) findViewById(R.id.topic_fab);
@ -178,10 +178,10 @@ public class TopicActivity extends BaseActivity {
public void onClick(View view) { public void onClick(View view) {
if (sessionManager.isLoggedIn()) { if (sessionManager.isLoggedIn()) {
postsList.add(null); postsList.add(null);
topicAdapter.prepareForReply(new ReplyTask()); topicAdapter.notifyItemInserted(postsList.size());
topicAdapter.prepareForReply(new ReplyTask(), topicTitle, loadedPageUrl);
replyFAB.hide(); replyFAB.hide();
bottomNavBar.setVisibility(View.GONE); bottomNavBar.setVisibility(View.GONE);
topicAdapter.notifyItemInserted(postsList.size());
} }
} }
}); });
@ -536,14 +536,16 @@ public class TopicActivity extends BaseActivity {
switch (parseResult) { switch (parseResult) {
case SUCCESS: case SUCCESS:
if (topicTitle == null || Objects.equals(topicTitle, "")) { if (topicTitle == null || Objects.equals(topicTitle, "")
|| !Objects.equals(topicTitle, parsedTitle)) {
toolbarTitle.setText(parsedTitle);
topicTitle = parsedTitle;
thisPageBookmark = new Bookmark(parsedTitle, ThmmyPage.getTopicId(loadedPageUrl)); thisPageBookmark = new Bookmark(parsedTitle, ThmmyPage.getTopicId(loadedPageUrl));
invalidateOptionsMenu(); invalidateOptionsMenu();
} }
progressBar.setVisibility(ProgressBar.INVISIBLE); progressBar.setVisibility(ProgressBar.INVISIBLE);
topicAdapter.customNotifyDataSetChanged(new TopicTask()); topicAdapter.customNotifyDataSetChanged(new TopicTask());
topicAdapter.setTopicInfo(parsedTitle, loadedPageUrl);
if (replyPageUrl == null) replyFAB.hide(); if (replyPageUrl == null) replyFAB.hide();
if (replyFAB.getVisibility() != View.GONE) replyFAB.setEnabled(true); if (replyFAB.getVisibility() != View.GONE) replyFAB.setEnabled(true);
@ -552,11 +554,6 @@ public class TopicActivity extends BaseActivity {
pageRequestValue = thisPage; pageRequestValue = thisPage;
paginationEnabled(true); paginationEnabled(true);
if (topicTitle != null)
if (parsedTitle != null)
if (topicTitle == null || Objects.equals(topicTitle, ""))
toolbarTitle.setText(parsedTitle);
break; break;
case NETWORK_ERROR: case NETWORK_ERROR:
Toast.makeText(getBaseContext(), "Network Error", Toast.LENGTH_SHORT).show(); Toast.makeText(getBaseContext(), "Network Error", Toast.LENGTH_SHORT).show();
@ -602,7 +599,7 @@ public class TopicActivity extends BaseActivity {
} }
//Finds topic title if missing //Finds topic title if missing
if (topicTitle == null || Objects.equals(topicTitle, "")) { {
parsedTitle = topic.select("td[id=top_subject]").first().text(); parsedTitle = topic.select("td[id=top_subject]").first().text();
if (parsedTitle.contains("Topic:")) { if (parsedTitle.contains("Topic:")) {
parsedTitle = parsedTitle.substring(parsedTitle.indexOf("Topic:") + 7 parsedTitle = parsedTitle.substring(parsedTitle.indexOf("Topic:") + 7

11
app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicAdapter.java

@ -111,8 +111,7 @@ class TopicAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
* @param context the context of the {@link RecyclerView} * @param context the context of the {@link RecyclerView}
* @param postsList List of {@link Post} objects to use * @param postsList List of {@link Post} objects to use
*/ */
TopicAdapter(Context context, List<Post> postsList, TopicActivity.TopicTask topicTask TopicAdapter(Context context, List<Post> postsList, TopicActivity.TopicTask topicTask) {
, String topicTitle, String loadedPageUrl) {
this.context = context; this.context = context;
this.postsList = postsList; this.postsList = postsList;
@ -122,15 +121,10 @@ class TopicAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
viewProperties.add(new boolean[3]); viewProperties.add(new boolean[3]);
} }
this.topicTask = topicTask; this.topicTask = topicTask;
this.topicTitle = topicTitle;
this.loadedPageUrl = loadedPageUrl;
} }
void prepareForReply(TopicActivity.ReplyTask replyTask) { void prepareForReply(TopicActivity.ReplyTask replyTask, String topicTitle, String loadedPageUrl) {
this.replyTask = replyTask; this.replyTask = replyTask;
}
void setTopicInfo(String topicTitle, String loadedPageUrl) {
this.topicTitle = topicTitle; this.topicTitle = topicTitle;
this.loadedPageUrl = loadedPageUrl; this.loadedPageUrl = loadedPageUrl;
} }
@ -482,6 +476,7 @@ class TopicAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
holder.quickReplySubject.getText().clear(); holder.quickReplySubject.getText().clear();
holder.quickReplySubject.setText("Re: " + topicTitle); holder.quickReplySubject.setText("Re: " + topicTitle);
holder.quickReply.getText().clear(); holder.quickReply.getText().clear();
holder.submitButton.setEnabled(true);
} }
}); });
} }

2
app/src/main/res/layout/activity_topic.xml

@ -46,6 +46,8 @@
android:layout_gravity="top|start" android:layout_gravity="top|start"
android:layout_marginTop="64dp" android:layout_marginTop="64dp"
android:background="@color/background" android:background="@color/background"
android:paddingBottom="54dp"
android:clipToPadding="false"
android:scrollbars="none" android:scrollbars="none"
tools:context="gr.thmmy.mthmmy.activities.topic.TopicActivity"> tools:context="gr.thmmy.mthmmy.activities.topic.TopicActivity">
</android.support.v7.widget.RecyclerView> </android.support.v7.widget.RecyclerView>

Loading…
Cancel
Save