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. 15
      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"
minSdkVersion 19
targetSdkVersion 25
versionCode 6
versionName "1.2.0"
versionCode 7
versionName "1.2.1"
archivesBaseName = "mTHMMY-v$versionName"
}

15
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 boardTitle;
private String parsedTitle;
private int numberOfPages = -1;
private int pagesLoaded = 0;
@ -71,7 +72,7 @@ public class BoardActivity extends BaseActivity implements BoardAdapter.OnLoadMo
boardUrl = extras.getString(BUNDLE_BOARD_URL);
ThmmyPage.PageCategory target = ThmmyPage.resolvePageCategory(Uri.parse(boardUrl));
if (!target.is(ThmmyPage.PageCategory.BOARD)) {
Timber.e("Bundle came with a non board url!\nUrl:\n%s" , boardUrl);
Timber.e("Bundle came with a non board url!\nUrl:\n%s", boardUrl);
Toast.makeText(this, "An error has occurred\nAborting.", Toast.LENGTH_SHORT).show();
finish();
}
@ -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
* parameter!</p>
*/
public class BoardTask extends AsyncTask<String, Void, Void> {
private class BoardTask extends AsyncTask<String, Void, Void> {
@Override
protected void onPreExecute() {
if (!isLoadingMore) progressBar.setVisibility(ProgressBar.VISIBLE);
@ -200,7 +201,12 @@ public class BoardActivity extends BaseActivity implements BoardAdapter.OnLoadMo
@Override
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
++pagesLoaded;
@ -211,8 +217,7 @@ public class BoardActivity extends BaseActivity implements BoardAdapter.OnLoadMo
}
private void parseBoard(Document boardPage) {
if (boardTitle == null || Objects.equals(boardTitle, ""))
boardTitle = boardPage.select("div.nav a.nav").last().text();
parsedTitle = boardPage.select("div.nav a.nav").last().text();
//Removes loading item
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);
LinearLayoutManager layoutManager = new LinearLayoutManager(getApplicationContext());
recyclerView.setLayoutManager(layoutManager);
topicAdapter = new TopicAdapter(this, postsList, topicTask, topicTitle, loadedPageUrl);
topicAdapter = new TopicAdapter(this, postsList, topicTask);
recyclerView.setAdapter(topicAdapter);
replyFAB = (FloatingActionButton) findViewById(R.id.topic_fab);
@ -178,10 +178,10 @@ public class TopicActivity extends BaseActivity {
public void onClick(View view) {
if (sessionManager.isLoggedIn()) {
postsList.add(null);
topicAdapter.prepareForReply(new ReplyTask());
topicAdapter.notifyItemInserted(postsList.size());
topicAdapter.prepareForReply(new ReplyTask(), topicTitle, loadedPageUrl);
replyFAB.hide();
bottomNavBar.setVisibility(View.GONE);
topicAdapter.notifyItemInserted(postsList.size());
}
}
});
@ -536,14 +536,16 @@ public class TopicActivity extends BaseActivity {
switch (parseResult) {
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));
invalidateOptionsMenu();
}
progressBar.setVisibility(ProgressBar.INVISIBLE);
topicAdapter.customNotifyDataSetChanged(new TopicTask());
topicAdapter.setTopicInfo(parsedTitle, loadedPageUrl);
if (replyPageUrl == null) replyFAB.hide();
if (replyFAB.getVisibility() != View.GONE) replyFAB.setEnabled(true);
@ -552,11 +554,6 @@ public class TopicActivity extends BaseActivity {
pageRequestValue = thisPage;
paginationEnabled(true);
if (topicTitle != null)
if (parsedTitle != null)
if (topicTitle == null || Objects.equals(topicTitle, ""))
toolbarTitle.setText(parsedTitle);
break;
case NETWORK_ERROR:
Toast.makeText(getBaseContext(), "Network Error", Toast.LENGTH_SHORT).show();
@ -602,7 +599,7 @@ public class TopicActivity extends BaseActivity {
}
//Finds topic title if missing
if (topicTitle == null || Objects.equals(topicTitle, "")) {
{
parsedTitle = topic.select("td[id=top_subject]").first().text();
if (parsedTitle.contains("Topic:")) {
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 postsList List of {@link Post} objects to use
*/
TopicAdapter(Context context, List<Post> postsList, TopicActivity.TopicTask topicTask
, String topicTitle, String loadedPageUrl) {
TopicAdapter(Context context, List<Post> postsList, TopicActivity.TopicTask topicTask) {
this.context = context;
this.postsList = postsList;
@ -122,15 +121,10 @@ class TopicAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
viewProperties.add(new boolean[3]);
}
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;
}
void setTopicInfo(String topicTitle, String loadedPageUrl) {
this.topicTitle = topicTitle;
this.loadedPageUrl = loadedPageUrl;
}
@ -482,6 +476,7 @@ class TopicAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
holder.quickReplySubject.getText().clear();
holder.quickReplySubject.setText("Re: " + topicTitle);
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_marginTop="64dp"
android:background="@color/background"
android:paddingBottom="54dp"
android:clipToPadding="false"
android:scrollbars="none"
tools:context="gr.thmmy.mthmmy.activities.topic.TopicActivity">
</android.support.v7.widget.RecyclerView>

Loading…
Cancel
Save