Add thumb size option
This commit is contained in:
1 parent
474eea094d
commit
4d9452c791
10 files changed
+66
-3
No files matched your search
@@ -253,6 +253,13 @@ public class Settings {
|
||||
return getIntFromStr(KEY_LIST_MODE, DEFAULT_LIST_MODE);
|
||||
}
|
||||
|
||||
public static final String KEY_THUMB_SIZE = "thumb_size";
|
||||
private static final int DEFAULT_THUMB_SIZE = 1;
|
||||
|
||||
public static int getThumbSize() {
|
||||
return getIntFromStr(KEY_THUMB_SIZE, DEFAULT_THUMB_SIZE);
|
||||
}
|
||||
|
||||
private static final String KEY_SHOW_JPN_TITLE = "show_jpn_title";
|
||||
private static final boolean DEFAULT_SHOW_JPN_TITLE = false;
|
||||
|
||||
|
||||
@@ -34,9 +34,11 @@ public class EhFragment extends PreferenceFragment
|
||||
|
||||
Preference gallerySite = findPreference(Settings.KEY_GALLERY_SITE);
|
||||
Preference listMode = findPreference(Settings.KEY_LIST_MODE);
|
||||
Preference thumbSize = findPreference(Settings.KEY_THUMB_SIZE);
|
||||
|
||||
gallerySite.setOnPreferenceChangeListener(this);
|
||||
listMode.setOnPreferenceChangeListener(this);
|
||||
thumbSize.setOnPreferenceChangeListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -48,6 +50,8 @@ public class EhFragment extends PreferenceFragment
|
||||
} else if (Settings.KEY_LIST_MODE.equals(key)) {
|
||||
getActivity().setResult(Activity.RESULT_OK);
|
||||
return true;
|
||||
} else if (Settings.KEY_THUMB_SIZE.equals(key)) {
|
||||
getActivity().setResult(Activity.RESULT_OK);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@ import android.widget.TextView;
|
||||
import com.hippo.drawable.TriangleDrawable;
|
||||
import com.hippo.easyrecyclerview.MarginItemDecoration;
|
||||
import com.hippo.ehviewer.R;
|
||||
import com.hippo.ehviewer.Settings;
|
||||
import com.hippo.ehviewer.client.EhCacheKeyFactory;
|
||||
import com.hippo.ehviewer.client.EhUtils;
|
||||
import com.hippo.ehviewer.client.data.GalleryInfo;
|
||||
@@ -100,7 +101,20 @@ abstract class GalleryAdapter extends RecyclerView.Adapter<GalleryHolder> {
|
||||
break;
|
||||
}
|
||||
case GalleryAdapter.TYPE_GRID: {
|
||||
int columnWidth = mResources.getDimensionPixelOffset(R.dimen.gallery_grid_column_width);
|
||||
int columnWidthId;
|
||||
switch (Settings.getThumbSize()) {
|
||||
case 0:
|
||||
columnWidthId = R.dimen.gallery_grid_column_width_large;
|
||||
break;
|
||||
default:
|
||||
case 1:
|
||||
columnWidthId = R.dimen.gallery_grid_column_width_middle;
|
||||
break;
|
||||
case 2:
|
||||
columnWidthId = R.dimen.gallery_grid_column_width_small;
|
||||
break;
|
||||
}
|
||||
int columnWidth = mResources.getDimensionPixelOffset(columnWidthId);
|
||||
mLayoutManager.setColumnSize(columnWidth);
|
||||
mLayoutManager.setStrategy(AutoGridLayoutManager.STRATEGY_SUITABLE_SIZE);
|
||||
if (null == mGirdDecoration) {
|
||||
|
||||
Reference in new issue
Block a user