forked from Mishiranu/Dashchan-Extensions
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
131 additions
and
1 deletion.
There are no files selected for viewing
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
src/com/mishiranu/dashchan/chan/synch/SynchPostsParser.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package com.mishiranu.dashchan.chan.synch; | ||
|
||
import java.text.DateFormatSymbols; | ||
import java.text.SimpleDateFormat; | ||
import java.util.ArrayList; | ||
import java.util.Locale; | ||
import java.util.TimeZone; | ||
import java.util.regex.Matcher; | ||
import java.util.regex.Pattern; | ||
|
||
import android.annotation.SuppressLint; | ||
import android.text.Html; | ||
import android.util.Log; | ||
import android.util.Pair; | ||
|
||
import chan.content.ChanConfiguration; | ||
import chan.content.ChanLocator; | ||
import chan.content.model.FileAttachment; | ||
import chan.content.model.Post; | ||
import chan.content.model.Posts; | ||
import chan.text.ParseException; | ||
import chan.text.TemplateParser; | ||
import chan.util.StringUtils; | ||
|
||
@SuppressLint("SimpleDateFormat") | ||
public class SynchPostsParser | ||
{ | ||
private String mSource; | ||
|
||
private String mPostNumber; | ||
|
||
// private static final Pattern FLAG = Pattern.compile("<span class=\"flag flag-(.*?)\""); | ||
|
||
|
||
|
||
public SynchPostsParser(String source, String postNumber) | ||
{ | ||
mSource = source; | ||
mPostNumber = postNumber; | ||
} | ||
|
||
public Pair<String, String> convertSinglePost() { | ||
Pattern FLAG = Pattern.compile("<label for=\"delete_" + mPostNumber + "\">(.*?)<span class=\"flag flag-(.*?)\"(.*?)title=\"(.*?)\" ></span>(.*?)</label>"); | ||
Pattern NOT_NEEDED = Pattern.compile("<label for=\"delete_(.*?)\""); | ||
Matcher matcher = FLAG.matcher(mSource); | ||
if(matcher.find()){ | ||
Matcher matcher1 = NOT_NEEDED.matcher(matcher.group(1)); | ||
if(!matcher1.find()){ | ||
Log.d("benis", "found" + matcher.group(2)); | ||
Log.d("benis", matcher.group(4)); | ||
Pair<String, String> toIcon = new Pair<String, String>(matcher.group(2), StringUtils.unescapeHtml(matcher.group(4))); | ||
return toIcon; | ||
} else { | ||
return null; | ||
} | ||
} else{ | ||
return null; | ||
} | ||
} | ||
} |