fix favories layout & count issue
This commit is contained in:
1 parent
2e34913c7d
commit
5d8fe06d5c
4 files changed
+87
-43
No files matched your search
@@ -718,26 +718,38 @@ public class Settings {
|
||||
/********************
|
||||
****** Favorites
|
||||
********************/
|
||||
public static final String KEY_FAV_CAT_0 = "fav_cat_0";
|
||||
public static final String KEY_FAV_CAT_1 = "fav_cat_1";
|
||||
public static final String KEY_FAV_CAT_2 = "fav_cat_2";
|
||||
public static final String KEY_FAV_CAT_3 = "fav_cat_3";
|
||||
public static final String KEY_FAV_CAT_4 = "fav_cat_4";
|
||||
public static final String KEY_FAV_CAT_5 = "fav_cat_5";
|
||||
public static final String KEY_FAV_CAT_6 = "fav_cat_6";
|
||||
public static final String KEY_FAV_CAT_7 = "fav_cat_7";
|
||||
public static final String KEY_FAV_CAT_8 = "fav_cat_8";
|
||||
public static final String KEY_FAV_CAT_9 = "fav_cat_9";
|
||||
public static final String DEFAULT_FAV_CAT_0 = "Favorites 0";
|
||||
public static final String DEFAULT_FAV_CAT_1 = "Favorites 1";
|
||||
public static final String DEFAULT_FAV_CAT_2 = "Favorites 2";
|
||||
public static final String DEFAULT_FAV_CAT_3 = "Favorites 3";
|
||||
public static final String DEFAULT_FAV_CAT_4 = "Favorites 4";
|
||||
public static final String DEFAULT_FAV_CAT_5 = "Favorites 5";
|
||||
public static final String DEFAULT_FAV_CAT_6 = "Favorites 6";
|
||||
public static final String DEFAULT_FAV_CAT_7 = "Favorites 7";
|
||||
public static final String DEFAULT_FAV_CAT_8 = "Favorites 8";
|
||||
public static final String DEFAULT_FAV_CAT_9 = "Favorites 9";
|
||||
private static final String KEY_FAV_CAT_0 = "fav_cat_0";
|
||||
private static final String KEY_FAV_CAT_1 = "fav_cat_1";
|
||||
private static final String KEY_FAV_CAT_2 = "fav_cat_2";
|
||||
private static final String KEY_FAV_CAT_3 = "fav_cat_3";
|
||||
private static final String KEY_FAV_CAT_4 = "fav_cat_4";
|
||||
private static final String KEY_FAV_CAT_5 = "fav_cat_5";
|
||||
private static final String KEY_FAV_CAT_6 = "fav_cat_6";
|
||||
private static final String KEY_FAV_CAT_7 = "fav_cat_7";
|
||||
private static final String KEY_FAV_CAT_8 = "fav_cat_8";
|
||||
private static final String KEY_FAV_CAT_9 = "fav_cat_9";
|
||||
private static final String DEFAULT_FAV_CAT_0 = "Favorites 0";
|
||||
private static final String DEFAULT_FAV_CAT_1 = "Favorites 1";
|
||||
private static final String DEFAULT_FAV_CAT_2 = "Favorites 2";
|
||||
private static final String DEFAULT_FAV_CAT_3 = "Favorites 3";
|
||||
private static final String DEFAULT_FAV_CAT_4 = "Favorites 4";
|
||||
private static final String DEFAULT_FAV_CAT_5 = "Favorites 5";
|
||||
private static final String DEFAULT_FAV_CAT_6 = "Favorites 6";
|
||||
private static final String DEFAULT_FAV_CAT_7 = "Favorites 7";
|
||||
private static final String DEFAULT_FAV_CAT_8 = "Favorites 8";
|
||||
private static final String DEFAULT_FAV_CAT_9 = "Favorites 9";
|
||||
|
||||
private static final String KEY_FAV_COUNT_0 = "fav_count_0";
|
||||
private static final String KEY_FAV_COUNT_1 = "fav_count_1";
|
||||
private static final String KEY_FAV_COUNT_2 = "fav_count_2";
|
||||
private static final String KEY_FAV_COUNT_3 = "fav_count_3";
|
||||
private static final String KEY_FAV_COUNT_4 = "fav_count_4";
|
||||
private static final String KEY_FAV_COUNT_5 = "fav_count_5";
|
||||
private static final String KEY_FAV_COUNT_6 = "fav_count_6";
|
||||
private static final String KEY_FAV_COUNT_7 = "fav_count_7";
|
||||
private static final String KEY_FAV_COUNT_8 = "fav_count_8";
|
||||
private static final String KEY_FAV_COUNT_9 = "fav_count_9";
|
||||
private static final int DEFAULT_FAV_COUNT = 0;
|
||||
|
||||
public static String[] getFavCat() {
|
||||
String[] favCat = new String[10];
|
||||
@@ -770,6 +782,37 @@ public class Settings {
|
||||
.apply();
|
||||
}
|
||||
|
||||
public static int[] getFavCount() {
|
||||
int[] favCount = new int[10];
|
||||
favCount[0] = sSettingsPre.getInt(KEY_FAV_COUNT_0, DEFAULT_FAV_COUNT);
|
||||
favCount[1] = sSettingsPre.getInt(KEY_FAV_COUNT_1, DEFAULT_FAV_COUNT);
|
||||
favCount[2] = sSettingsPre.getInt(KEY_FAV_COUNT_2, DEFAULT_FAV_COUNT);
|
||||
favCount[3] = sSettingsPre.getInt(KEY_FAV_COUNT_3, DEFAULT_FAV_COUNT);
|
||||
favCount[4] = sSettingsPre.getInt(KEY_FAV_COUNT_4, DEFAULT_FAV_COUNT);
|
||||
favCount[5] = sSettingsPre.getInt(KEY_FAV_COUNT_5, DEFAULT_FAV_COUNT);
|
||||
favCount[6] = sSettingsPre.getInt(KEY_FAV_COUNT_6, DEFAULT_FAV_COUNT);
|
||||
favCount[7] = sSettingsPre.getInt(KEY_FAV_COUNT_7, DEFAULT_FAV_COUNT);
|
||||
favCount[8] = sSettingsPre.getInt(KEY_FAV_COUNT_8, DEFAULT_FAV_COUNT);
|
||||
favCount[9] = sSettingsPre.getInt(KEY_FAV_COUNT_9, DEFAULT_FAV_COUNT);
|
||||
return favCount;
|
||||
}
|
||||
|
||||
public static void putFavCount(int[] count) {
|
||||
Assert.assertEquals(10, count.length);
|
||||
sSettingsPre.edit()
|
||||
.putInt(KEY_FAV_COUNT_0, count[0])
|
||||
.putInt(KEY_FAV_COUNT_1, count[1])
|
||||
.putInt(KEY_FAV_COUNT_2, count[2])
|
||||
.putInt(KEY_FAV_COUNT_3, count[3])
|
||||
.putInt(KEY_FAV_COUNT_4, count[4])
|
||||
.putInt(KEY_FAV_COUNT_5, count[5])
|
||||
.putInt(KEY_FAV_COUNT_6, count[6])
|
||||
.putInt(KEY_FAV_COUNT_7, count[7])
|
||||
.putInt(KEY_FAV_COUNT_8, count[8])
|
||||
.putInt(KEY_FAV_COUNT_9, count[9])
|
||||
.apply();
|
||||
}
|
||||
|
||||
private static final String KEY_RECENT_FAV_CAT = "recent_fav_cat";
|
||||
private static final int DEFAULT_RECENT_FAV_CAT = FavListUrlBuilder.FAV_CAT_ALL;
|
||||
|
||||
|
||||
@@ -179,6 +179,7 @@ public class FavoritesScene extends BaseScene implements
|
||||
Assert.assertNotNull(context);
|
||||
mClient = EhApplication.getEhClient(context);
|
||||
mFavCatArray = Settings.getFavCat();
|
||||
mFavCountArray = Settings.getFavCount();
|
||||
|
||||
if (savedInstanceState == null) {
|
||||
onInit();
|
||||
@@ -234,7 +235,9 @@ public class FavoritesScene extends BaseScene implements
|
||||
@Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
View view = inflater.inflate(R.layout.scene_favorites, container, false);
|
||||
ContentLayout contentLayout = (ContentLayout) view.findViewById(R.id.content_layout);
|
||||
mDrawerLayout = (EhDrawerLayout) ViewUtils.$$(getActivity2(), R.id.draw_view);
|
||||
MainActivity activity = getActivity2();
|
||||
Assert.assertNotNull(activity);
|
||||
mDrawerLayout = (EhDrawerLayout) ViewUtils.$$(activity, R.id.draw_view);
|
||||
mRecyclerView = contentLayout.getRecyclerView();
|
||||
FastScroller fastScroller = contentLayout.getFastScroller();
|
||||
RefreshLayout refreshLayout = contentLayout.getRefreshLayout();
|
||||
@@ -437,7 +440,7 @@ public class FavoritesScene extends BaseScene implements
|
||||
@NonNull
|
||||
@Override
|
||||
public FavDrawerHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
return new FavDrawerHolder(mInflater.inflate(R.layout.item_favorite_list, parent, false));
|
||||
return new FavDrawerHolder(mInflater.inflate(R.layout.item_drawer_favorites, parent, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -465,6 +468,9 @@ public class FavoritesScene extends BaseScene implements
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
if (null == mFavCatArray) {
|
||||
return 2;
|
||||
}
|
||||
return 12;
|
||||
}
|
||||
}
|
||||
@@ -835,12 +841,7 @@ public class FavoritesScene extends BaseScene implements
|
||||
mHelper.isCurrentTask(taskId)) {
|
||||
|
||||
if (mFavCatArray != null) {
|
||||
|
||||
System.arraycopy(result.catArray, 0, mFavCatArray, 0,10);
|
||||
|
||||
if (mDrawerAdapter != null) {
|
||||
mDrawerAdapter.notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
|
||||
mFavCountArray = result.countArray;
|
||||
@@ -854,6 +855,10 @@ public class FavoritesScene extends BaseScene implements
|
||||
updateSearchBar();
|
||||
mHelper.setPages(taskId, result.pages);
|
||||
mHelper.onGetPageData(taskId, result.galleryInfoList);
|
||||
|
||||
if (mDrawerAdapter != null) {
|
||||
mDrawerAdapter.notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1119,7 +1124,7 @@ public class FavoritesScene extends BaseScene implements
|
||||
private final int mTaskId;
|
||||
private final String mKeyword;
|
||||
|
||||
public AddFavoritesListener(Context context, int stageId,
|
||||
private AddFavoritesListener(Context context, int stageId,
|
||||
String sceneTag, int taskId, String keyword) {
|
||||
super(context, stageId, sceneTag);
|
||||
mTaskId = taskId;
|
||||
@@ -1158,7 +1163,7 @@ public class FavoritesScene extends BaseScene implements
|
||||
private final boolean mLocal;
|
||||
private final String mKeyword;
|
||||
|
||||
public GetFavoritesListener(Context context, int stageId,
|
||||
private GetFavoritesListener(Context context, int stageId,
|
||||
String sceneTag, int taskId, boolean local, String keyword) {
|
||||
super(context, stageId, sceneTag);
|
||||
mTaskId = taskId;
|
||||
@@ -1170,6 +1175,7 @@ public class FavoritesScene extends BaseScene implements
|
||||
public void onSuccess(FavoritesParser.Result result) {
|
||||
// Put fav cat
|
||||
Settings.putFavCat(result.catArray);
|
||||
Settings.putFavCount(result.countArray);
|
||||
FavoritesScene scene = getScene();
|
||||
if (scene != null) {
|
||||
if (mLocal) {
|
||||
|
||||
@@ -322,7 +322,7 @@ public final class GalleryCommentsScene extends ToolbarScene
|
||||
rv.setAdapter(new RecyclerView.Adapter<InfoHolder>() {
|
||||
@Override
|
||||
public InfoHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
return new InfoHolder(inflater.inflate(R.layout.item_favorite_list, parent, false));
|
||||
return new InfoHolder(inflater.inflate(R.layout.item_drawer_favorites, parent, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in new issue
Block a user