Skip to content

Commit

Permalink
Issue #425 new category list method used
Browse files Browse the repository at this point in the history
  • Loading branch information
yeriomin committed Apr 23, 2018
1 parent 453bc92 commit bd28af9
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 11 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,6 @@ dependencies {
implementation 'commons-net:commons-net:3.5'
implementation 'com.nothome:javaxdelta:2.0.1'
debugImplementation 'com.github.yeriomin:play-store-api:master-SNAPSHOT'
releaseImplementation 'com.github.yeriomin:play-store-api:0.39'
releaseImplementation 'com.github.yeriomin:play-store-api:0.40'
implementation 'eu.chainfire:libsuperuser:1.0.0.201608240809'
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,12 @@

package com.github.yeriomin.yalpstore.task.playstore;

import android.net.Uri;
import android.text.TextUtils;
import android.widget.ArrayAdapter;

import com.github.yeriomin.playstoreapi.BrowseLink;
import com.github.yeriomin.playstoreapi.BrowseResponse;
import com.github.yeriomin.playstoreapi.DocV2;
import com.github.yeriomin.playstoreapi.GooglePlayAPI;
import com.github.yeriomin.playstoreapi.ListResponse;
import com.github.yeriomin.yalpstore.CategoryManager;

import java.io.IOException;
Expand Down Expand Up @@ -61,10 +60,10 @@ protected Void doInBackground(String... arguments) {

@Override
protected Void getResult(GooglePlayAPI api, String... arguments) throws IOException {
Map<String, String> topCategories = buildCategoryMap(api.categories());
Map<String, String> topCategories = buildCategoryMap(api.categoriesList());
manager.save(CategoryManager.TOP, topCategories);
for (String categoryId: topCategories.keySet()) {
manager.save(categoryId, buildCategoryMap(api.categories(categoryId)));
manager.save(categoryId, buildCategoryMap(api.categoriesList(categoryId)));
}
return null;
}
Expand All @@ -77,14 +76,25 @@ protected ArrayAdapter getAdapter(Map<String, String> categories, int itemLayout
);
}

private Map<String, String> buildCategoryMap(BrowseResponse response) {
private Map<String, String> buildCategoryMap(ListResponse response) {
Map<String, String> categories = new HashMap<>();
for (BrowseLink category: response.getCategoryContainer().getCategoryList()) {
String categoryId = Uri.parse(category.getDataUrl()).getQueryParameter("cat");
if (TextUtils.isEmpty(categoryId)) {
for (DocV2 categoryCluster: response.getDoc(0).getChildList()) {
if (!categoryCluster.getBackendDocid().equals("category_list_cluster")) {
continue;
}
categories.put(categoryId, category.getName());
for (DocV2 category: categoryCluster.getChildList()) {
if (!category.hasUnknownCategoryContainer()
|| !category.getUnknownCategoryContainer().hasCategoryIdContainer()
|| !category.getUnknownCategoryContainer().getCategoryIdContainer().hasCategoryId()
) {
continue;
}
String categoryId = category.getUnknownCategoryContainer().getCategoryIdContainer().getCategoryId();
if (TextUtils.isEmpty(categoryId)) {
continue;
}
categories.put(categoryId, category.getTitle());
}
}
return categories;
}
Expand Down

0 comments on commit bd28af9

Please sign in to comment.