Browse Source

Bug fixes

pull/24/head
Apostolos Fanakis 8 years ago
parent
commit
d84575b3aa
  1. 5
      app/build.gradle
  2. 2
      app/src/main/java/gr/thmmy/mthmmy/activities/main/recent/RecentFragment.java
  3. 21
      app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java
  4. 7
      app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicAdapter.java
  5. 13
      app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicParser.java
  6. 6
      app/src/main/java/gr/thmmy/mthmmy/model/ThmmyPage.java

5
app/build.gradle

@ -20,9 +20,10 @@ android {
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
def date = new Date().format('ddMMyy_HHmm');
def date = new Date().format('ddMMyy_HH');
//def date = 1;
archivesBaseName = archivesBaseName + "-$date"
//archivesBaseName = archivesBaseName + "-$date"
archivesBaseName = archivesBaseName
}
}
}

2
app/src/main/java/gr/thmmy/mthmmy/activities/main/recent/RecentFragment.java

@ -179,7 +179,7 @@ public class RecentFragment extends BaseFragment {
if (result == 0)
recentAdapter.notifyDataSetChanged();
else if (result == 2)
Toast.makeText(getActivity(), "Network error", Toast.LENGTH_SHORT).show();
Toast.makeText(getActivity(), "Network error", Toast.LENGTH_SHORT).show(); //Fixme, sometimes activity isn't ready
progressBar.setVisibility(ProgressBar.INVISIBLE);
swipeRefreshLayout.setRefreshing(false);

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

@ -407,7 +407,8 @@ public class TopicActivity extends BaseActivity {
paginationEnabled(true);
changePage(pageRequestValue - 1);
} else if (event.getAction() == MotionEvent.ACTION_MOVE) {
if (!rect.contains(v.getLeft() + (int) event.getX(), v.getTop() + (int) event.getY())) { //TODO fix bug
if (rect != null &&
!rect.contains(v.getLeft() + (int) event.getX(), v.getTop() + (int) event.getY())) {
autoIncrement = false;
incrementPageRequestValue(thisPage - pageRequestValue);
paginationEnabled(true);
@ -469,7 +470,6 @@ public class TopicActivity extends BaseActivity {
protected Integer doInBackground(String... strings) {
Document document;
base_url = strings[0].substring(0, strings[0].lastIndexOf(".")); //New topic's base url
String newPageUrl = strings[0];
//Finds the index of message focus if present
@ -484,26 +484,33 @@ public class TopicActivity extends BaseActivity {
}
}
//Checks if the page to be loaded is the one already shown
if (!reloadingPage && !Objects.equals(loadedPageUrl, "") && loadedPageUrl.contains(base_url)) {
if (!reloadingPage && !Objects.equals(loadedPageUrl, "") && newPageUrl.contains(base_url)) {
if (newPageUrl.contains("topicseen#new") || newPageUrl.contains("#new"))
if (thisPage == numberOfPages)
return SAME_PAGE;
if (newPageUrl.contains("msg")) {
String tmpUrlSbstr = newPageUrl.substring(newPageUrl.indexOf("msg") + 3);
Log.d("TAG", tmpUrlSbstr);
if (tmpUrlSbstr.contains("msg"))
tmpUrlSbstr = tmpUrlSbstr.substring(0, tmpUrlSbstr.indexOf("msg") - 1);
Log.d("TAG", tmpUrlSbstr);
int testAgainst = Integer.parseInt(tmpUrlSbstr);
Log.d("TAG", "testAgainst = " + testAgainst);
for (Post post : postsList) {
Log.d("TAG", "post index = " + post.getPostIndex());
if (post.getPostIndex() == testAgainst) {
return SAME_PAGE;
}
}
} else if (Integer.parseInt(newPageUrl.substring(base_url.length() + 1)) / 15 + 1 == thisPage) //TODO fix bug
} else if ((Objects.equals(newPageUrl, base_url) && thisPage == 1) ||
Integer.parseInt(newPageUrl.substring(base_url.length() + 1)) / 15 + 1 == thisPage)
return SAME_PAGE;
} else if (!Objects.equals(loadedPageUrl, "")) topicTitle = null;
if (reloadingPage) reloadingPage = !reloadingPage;
loadedPageUrl = newPageUrl;
if (strings[0].substring(0, strings[0].lastIndexOf(".")).contains("topic="))
base_url = strings[0].substring(0, strings[0].lastIndexOf(".")); //New topic's base url
replyPageUrl = null;
Request request = new Request.Builder()
.url(newPageUrl)
@ -693,7 +700,7 @@ public class TopicActivity extends BaseActivity {
numReplies = replyPageUrl.substring(replyPageUrl.indexOf("num_replies=") + 12);
seqnum = document.select("input[name=seqnum]").first().attr("value");
sc = document.select("input[name=sc]").first().attr("value");
subject = document.select("input[name=subject]").first().attr("value");
//subject = document.select("input[name=subject]").first().attr("value");
topic = document.select("input[name=topic]").first().attr("value");
} catch (IOException e) {
Timber.e("Post failed.", e);
@ -705,11 +712,11 @@ public class TopicActivity extends BaseActivity {
RequestBody postBody = new MultipartBody.Builder()
.setType(MultipartBody.FORM)
.addFormDataPart("message", message[0])
.addFormDataPart("message", message[1])
.addFormDataPart("num_replies", numReplies)
.addFormDataPart("seqnum", seqnum)
.addFormDataPart("sc", sc)
.addFormDataPart("subject", subject)
.addFormDataPart("subject", message[0])
.addFormDataPart("topic", topic)
.build();

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

@ -471,9 +471,10 @@ class TopicAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
holder.submitButton.setEnabled(false);
replyTask.execute(holder.quickReplySubject.getText().toString(),
holder.quickReply.getText().toString());
replyDataHolder[replySubject] = "Re: " + topicTitle;
replyDataHolder[replyText] = "";
holder.quickReply.setText("");
holder.quickReplySubject.getText().clear();
holder.quickReplySubject.setText("Re: " + topicTitle);
holder.quickReply.getText().clear();
}
});
}

13
app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicParser.java

@ -1,6 +1,7 @@
package gr.thmmy.mthmmy.activities.topic;
import android.graphics.Color;
import android.util.Log;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
@ -194,11 +195,19 @@ class TopicParser {
//This is an int assigned by the forum used for post focusing and quotes, it is not
//the same as reply index.
Element postIndex = thisRow.select("a[name^=msg]").first();
if (postIndex != null) {
String tmp = postIndex.attr("name");
p_postIndex = Integer.parseInt(tmp.substring(tmp.indexOf("msg") + 3));
} else{
postIndex = thisRow.select("div[id^=subject]").first();
Log.d("TAG", "got");
Log.d("TAG", postIndex.toString());
if (postIndex == null)
p_postIndex = NO_INDEX;
else{
String tmp = postIndex.attr("name");
p_postIndex = Integer.parseInt(tmp.substring(tmp.indexOf("msg") + 3));
String tmp = postIndex.attr("id");
p_postIndex = Integer.parseInt(tmp.substring(tmp.indexOf("subject") + 8));
}
}
Element postLastEditDate = thisRow.select("td.smalltext[id^=modified_]").first();

6
app/src/main/java/gr/thmmy/mthmmy/model/ThmmyPage.java

@ -1,6 +1,7 @@
package gr.thmmy.mthmmy.model;
import android.net.Uri;
import android.util.Log;
import java.util.Objects;
@ -170,7 +171,10 @@ public class ThmmyPage {
public static String getBoardId(String boardUrl) {
if (resolvePageCategory(Uri.parse(boardUrl)) == PageCategory.BOARD) {
return boardUrl.substring(boardUrl.indexOf("board=") + 6, boardUrl.lastIndexOf("."));
String returnString = boardUrl.substring(boardUrl.indexOf("board=") + 6);
if (returnString.contains("."))
returnString = boardUrl.substring(boardUrl.indexOf("board=") + 6, boardUrl.lastIndexOf("."));
return returnString;
}
return null;
}

Loading…
Cancel
Save