use of com.hippo.ehviewer.client.data.ListUrlBuilder in project EhViewer by seven332.
the class EhUrlOpener method parseUrl.
@Nullable
public static Announcer parseUrl(String url) {
if (TextUtils.isEmpty(url)) {
return null;
}
ListUrlBuilder listUrlBuilder = GalleryListUrlParser.parse(url);
if (listUrlBuilder != null) {
Bundle args = new Bundle();
args.putString(GalleryListScene.KEY_ACTION, GalleryListScene.ACTION_LIST_URL_BUILDER);
args.putParcelable(GalleryListScene.KEY_LIST_URL_BUILDER, listUrlBuilder);
return new Announcer(GalleryListScene.class).setArgs(args);
}
GalleryDetailUrlParser.Result result1 = GalleryDetailUrlParser.parse(url);
if (result1 != null) {
Bundle args = new Bundle();
args.putString(GalleryDetailScene.KEY_ACTION, GalleryDetailScene.ACTION_GID_TOKEN);
args.putLong(GalleryDetailScene.KEY_GID, result1.gid);
args.putString(GalleryDetailScene.KEY_TOKEN, result1.token);
return new Announcer(GalleryDetailScene.class).setArgs(args);
}
GalleryPageUrlParser.Result result2 = GalleryPageUrlParser.parse(url);
if (result2 != null) {
Bundle args = new Bundle();
args.putString(ProgressScene.KEY_ACTION, ProgressScene.ACTION_GALLERY_TOKEN);
args.putLong(ProgressScene.KEY_GID, result2.gid);
args.putString(ProgressScene.KEY_PTOKEN, result2.pToken);
args.putInt(ProgressScene.KEY_PAGE, result2.page);
return new Announcer(ProgressScene.class).setArgs(args);
}
Log.i(TAG, "Can't parse url: " + url);
return null;
}
use of com.hippo.ehviewer.client.data.ListUrlBuilder in project EhViewer by seven332.
the class GalleryListUrlParser method parseTag.
// TODO get page
private static ListUrlBuilder parseTag(String path) {
String tag;
int prefixLength = PATH_TAG.length();
int index = path.indexOf('/', prefixLength);
if (index < 0) {
tag = path.substring(prefixLength);
} else {
tag = path.substring(prefixLength, index);
}
try {
tag = URLDecoder.decode(tag, "utf-8");
} catch (UnsupportedEncodingException e) {
return null;
}
if (TextUtils.isEmpty(tag)) {
return null;
}
ListUrlBuilder builder = new ListUrlBuilder();
builder.setMode(ListUrlBuilder.MODE_TAG);
builder.setKeyword(tag);
return builder;
}
use of com.hippo.ehviewer.client.data.ListUrlBuilder in project EhViewer by seven332.
the class MainActivity method handleIntent.
private boolean handleIntent(Intent intent) {
if (intent == null) {
return false;
}
String action = intent.getAction();
if (Intent.ACTION_VIEW.equals(action)) {
Announcer announcer = EhUrlOpener.parseUrl(intent.getData().toString());
if (announcer != null) {
startScene(processAnnouncer(announcer));
return true;
}
} else if (Intent.ACTION_SEND.equals(action)) {
String type = intent.getType();
if ("text/plain".equals(type)) {
ListUrlBuilder builder = new ListUrlBuilder();
builder.setKeyword(intent.getStringExtra(Intent.EXTRA_TEXT));
startScene(processAnnouncer(GalleryListScene.getStartAnnouncer(builder)));
return true;
} else if (type.startsWith("image/")) {
Uri uri = intent.getParcelableExtra(Intent.EXTRA_STREAM);
if (null != uri) {
UniFile file = UniFile.fromUri(this, uri);
File temp = saveImageToTempFile(file);
if (null != temp) {
ListUrlBuilder builder = new ListUrlBuilder();
builder.setMode(ListUrlBuilder.MODE_IMAGE_SEARCH);
builder.setImagePath(temp.getPath());
builder.setUseSimilarityScan(true);
builder.setShowExpunged(true);
startScene(processAnnouncer(GalleryListScene.getStartAnnouncer(builder)));
return true;
}
}
}
}
return false;
}
use of com.hippo.ehviewer.client.data.ListUrlBuilder in project EhViewer by seven332.
the class GalleryDetailScene method showSimilarGalleryList.
private void showSimilarGalleryList() {
GalleryDetail gd = mGalleryDetail;
if (null == gd) {
return;
}
String keyword = EhUtils.extractTitle(gd.title);
if (null != keyword) {
ListUrlBuilder lub = new ListUrlBuilder();
lub.setMode(ListUrlBuilder.MODE_NORMAL);
lub.setKeyword(keyword);
GalleryListScene.startScene(this, lub);
return;
}
String artist = getArtist(gd.tags);
if (null != artist) {
ListUrlBuilder lub = new ListUrlBuilder();
lub.setMode(ListUrlBuilder.MODE_TAG);
lub.setKeyword("artist:" + artist);
GalleryListScene.startScene(this, lub);
return;
}
if (null != gd.uploader) {
ListUrlBuilder lub = new ListUrlBuilder();
lub.setMode(ListUrlBuilder.MODE_UPLOADER);
lub.setKeyword(gd.uploader);
GalleryListScene.startScene(this, lub);
}
}
use of com.hippo.ehviewer.client.data.ListUrlBuilder in project EhViewer by seven332.
the class GalleryListUrlParser method parseUploader.
// TODO get page
private static ListUrlBuilder parseUploader(String path) {
String uploader;
int prefixLength = PATH_UPLOADER.length();
int index = path.indexOf('/', prefixLength);
if (index < 0) {
uploader = path.substring(prefixLength);
} else {
uploader = path.substring(prefixLength, index);
}
try {
uploader = URLDecoder.decode(uploader, "utf-8");
} catch (UnsupportedEncodingException e) {
return null;
}
if (TextUtils.isEmpty(uploader)) {
return null;
}
ListUrlBuilder builder = new ListUrlBuilder();
builder.setMode(ListUrlBuilder.MODE_UPLOADER);
builder.setKeyword(uploader);
return builder;
}
Aggregations