Reformat code
This commit is contained in:
1 parent
8bb5f1e955
commit
9ef4512ef9
11 files changed
+176
-177
No files matched your search
@@ -352,21 +352,7 @@ public final class DiskLruCache implements Closeable {
|
||||
i.remove();
|
||||
}
|
||||
}
|
||||
} private final Callable<Void> cleanupCallable = new Callable<>() {
|
||||
public Void call() throws Exception {
|
||||
synchronized (DiskLruCache.this) {
|
||||
if (journalWriter == null) {
|
||||
return null; // Closed.
|
||||
}
|
||||
trimToSize();
|
||||
if (journalRebuildRequired()) {
|
||||
rebuildJournal();
|
||||
redundantOpCount = 0;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new journal that omits redundant information. This replaces the
|
||||
@@ -406,7 +392,21 @@ public final class DiskLruCache implements Closeable {
|
||||
|
||||
journalWriter = new BufferedWriter(
|
||||
new OutputStreamWriter(new FileOutputStream(journalFile, true), Util.US_ASCII));
|
||||
}
|
||||
} private final Callable<Void> cleanupCallable = new Callable<>() {
|
||||
public Void call() throws Exception {
|
||||
synchronized (DiskLruCache.this) {
|
||||
if (journalWriter == null) {
|
||||
return null; // Closed.
|
||||
}
|
||||
trimToSize();
|
||||
if (journalRebuildRequired()) {
|
||||
rebuildJournal();
|
||||
redundantOpCount = 0;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Return {@code true} if it contains the key
|
||||
|
||||
@@ -22,11 +22,11 @@ import androidx.annotation.Nullable;
|
||||
import com.hippo.ehviewer.EhDB;
|
||||
import com.hippo.ehviewer.client.EhFilter;
|
||||
import com.hippo.ehviewer.client.EhUtils;
|
||||
import com.hippo.ehviewer.client.data.BaseGalleryInfo;
|
||||
import com.hippo.ehviewer.client.data.GalleryComment;
|
||||
import com.hippo.ehviewer.client.data.GalleryCommentList;
|
||||
import com.hippo.ehviewer.client.data.GalleryDetail;
|
||||
import com.hippo.ehviewer.client.data.GalleryInfo;
|
||||
import com.hippo.ehviewer.client.data.BaseGalleryInfo;
|
||||
import com.hippo.ehviewer.client.data.GalleryTagGroup;
|
||||
import com.hippo.ehviewer.client.data.LargePreviewSet;
|
||||
import com.hippo.ehviewer.client.data.NormalPreviewSet;
|
||||
|
||||
@@ -23,8 +23,8 @@ import androidx.annotation.NonNull;
|
||||
|
||||
import com.hippo.ehviewer.EhDB;
|
||||
import com.hippo.ehviewer.client.EhUtils;
|
||||
import com.hippo.ehviewer.client.data.GalleryInfo;
|
||||
import com.hippo.ehviewer.client.data.BaseGalleryInfo;
|
||||
import com.hippo.ehviewer.client.data.GalleryInfo;
|
||||
import com.hippo.ehviewer.client.exception.ParseException;
|
||||
import com.hippo.util.ExceptionUtils;
|
||||
import com.hippo.util.JsoupUtils;
|
||||
|
||||
@@ -3,8 +3,8 @@ package com.hippo.ehviewer.dao
|
||||
import androidx.room.ColumnInfo
|
||||
import androidx.room.Entity
|
||||
import androidx.room.Ignore
|
||||
import com.hippo.ehviewer.client.data.GalleryInfo
|
||||
import com.hippo.ehviewer.client.data.BaseGalleryInfo
|
||||
import com.hippo.ehviewer.client.data.GalleryInfo
|
||||
|
||||
@Entity(tableName = "DOWNLOADS")
|
||||
class DownloadInfo() : BaseGalleryInfo() {
|
||||
|
||||
@@ -2,8 +2,8 @@ package com.hippo.ehviewer.dao
|
||||
|
||||
import androidx.room.ColumnInfo
|
||||
import androidx.room.Entity
|
||||
import com.hippo.ehviewer.client.data.GalleryInfo
|
||||
import com.hippo.ehviewer.client.data.BaseGalleryInfo
|
||||
import com.hippo.ehviewer.client.data.GalleryInfo
|
||||
|
||||
@Entity(tableName = "HISTORY")
|
||||
class HistoryInfo() : BaseGalleryInfo() {
|
||||
|
||||
@@ -2,8 +2,8 @@ package com.hippo.ehviewer.dao
|
||||
|
||||
import androidx.room.ColumnInfo
|
||||
import androidx.room.Entity
|
||||
import com.hippo.ehviewer.client.data.GalleryInfo
|
||||
import com.hippo.ehviewer.client.data.BaseGalleryInfo
|
||||
import com.hippo.ehviewer.client.data.GalleryInfo
|
||||
|
||||
@Entity(tableName = "LOCAL_FAVORITES")
|
||||
class LocalFavoriteInfo() : BaseGalleryInfo() {
|
||||
|
||||
@@ -724,6 +724,18 @@ public class FavoritesScene extends SearchBarScene implements
|
||||
}
|
||||
}
|
||||
|
||||
private static class FavDrawerHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private final TextView key;
|
||||
private final TextView value;
|
||||
|
||||
private FavDrawerHolder(View itemView) {
|
||||
super(itemView);
|
||||
key = (TextView) ViewUtils.$$(itemView, R.id.key);
|
||||
value = (TextView) ViewUtils.$$(itemView, R.id.value);
|
||||
}
|
||||
}
|
||||
|
||||
private class AddFavoritesListener extends EhCallback<FavoritesScene, Void> {
|
||||
|
||||
private final int mTaskId;
|
||||
@@ -801,18 +813,6 @@ public class FavoritesScene extends SearchBarScene implements
|
||||
}
|
||||
}
|
||||
|
||||
private static class FavDrawerHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private final TextView key;
|
||||
private final TextView value;
|
||||
|
||||
private FavDrawerHolder(View itemView) {
|
||||
super(itemView);
|
||||
key = (TextView) ViewUtils.$$(itemView, R.id.key);
|
||||
value = (TextView) ViewUtils.$$(itemView, R.id.value);
|
||||
}
|
||||
}
|
||||
|
||||
private class FavDrawerAdapter extends RecyclerView.Adapter<FavDrawerHolder> {
|
||||
|
||||
private final LayoutInflater mInflater;
|
||||
|
||||
@@ -733,6 +733,36 @@ public final class GalleryCommentsScene extends BaseToolbarScene
|
||||
}
|
||||
}
|
||||
|
||||
private static class InfoHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private final TextView key;
|
||||
private final TextView value;
|
||||
|
||||
public InfoHolder(View itemView) {
|
||||
super(itemView);
|
||||
key = (TextView) ViewUtils.$$(itemView, R.id.key);
|
||||
value = (TextView) ViewUtils.$$(itemView, R.id.value);
|
||||
}
|
||||
}
|
||||
|
||||
private abstract static class CommentHolder extends RecyclerView.ViewHolder {
|
||||
public CommentHolder(LayoutInflater inflater, int resId, ViewGroup parent) {
|
||||
super(inflater.inflate(resId, parent, false));
|
||||
}
|
||||
}
|
||||
|
||||
private static class MoreCommentHolder extends CommentHolder {
|
||||
public MoreCommentHolder(LayoutInflater inflater, ViewGroup parent) {
|
||||
super(inflater, R.layout.item_gallery_comment_more, parent);
|
||||
}
|
||||
}
|
||||
|
||||
private static class ProgressCommentHolder extends CommentHolder {
|
||||
public ProgressCommentHolder(LayoutInflater inflater, ViewGroup parent) {
|
||||
super(inflater, R.layout.item_gallery_comment_progress, parent);
|
||||
}
|
||||
}
|
||||
|
||||
private class RefreshCommentListener extends EhCallback<GalleryCommentsScene, GalleryDetail> {
|
||||
|
||||
public RefreshCommentListener(Context context) {
|
||||
@@ -810,36 +840,6 @@ public final class GalleryCommentsScene extends BaseToolbarScene
|
||||
}
|
||||
}
|
||||
|
||||
private static class InfoHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private final TextView key;
|
||||
private final TextView value;
|
||||
|
||||
public InfoHolder(View itemView) {
|
||||
super(itemView);
|
||||
key = (TextView) ViewUtils.$$(itemView, R.id.key);
|
||||
value = (TextView) ViewUtils.$$(itemView, R.id.value);
|
||||
}
|
||||
}
|
||||
|
||||
private abstract static class CommentHolder extends RecyclerView.ViewHolder {
|
||||
public CommentHolder(LayoutInflater inflater, int resId, ViewGroup parent) {
|
||||
super(inflater.inflate(resId, parent, false));
|
||||
}
|
||||
}
|
||||
|
||||
private static class MoreCommentHolder extends CommentHolder {
|
||||
public MoreCommentHolder(LayoutInflater inflater, ViewGroup parent) {
|
||||
super(inflater, R.layout.item_gallery_comment_more, parent);
|
||||
}
|
||||
}
|
||||
|
||||
private static class ProgressCommentHolder extends CommentHolder {
|
||||
public ProgressCommentHolder(LayoutInflater inflater, ViewGroup parent) {
|
||||
super(inflater, R.layout.item_gallery_comment_progress, parent);
|
||||
}
|
||||
}
|
||||
|
||||
private class ActualCommentHolder extends CommentHolder {
|
||||
|
||||
private final TextView user;
|
||||
|
||||
@@ -21,7 +21,6 @@ import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.app.Dialog;
|
||||
import android.app.DownloadManager;
|
||||
import android.app.assist.AssistContent;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
@@ -76,7 +75,6 @@ import com.hippo.ehviewer.client.EhTagDatabase;
|
||||
import com.hippo.ehviewer.client.EhUrl;
|
||||
import com.hippo.ehviewer.client.EhUtils;
|
||||
import com.hippo.ehviewer.client.data.GalleryComment;
|
||||
import com.hippo.ehviewer.client.data.GalleryCommentList;
|
||||
import com.hippo.ehviewer.client.data.GalleryDetail;
|
||||
import com.hippo.ehviewer.client.data.GalleryInfo;
|
||||
import com.hippo.ehviewer.client.data.GalleryTagGroup;
|
||||
@@ -622,7 +620,7 @@ public class GalleryDetailScene extends CollapsingToolbarScene implements View.O
|
||||
}
|
||||
|
||||
EhApplication.getDownloadManager().addDownloadInfoListener(this);
|
||||
((MainActivity)requireActivity()).setMShareUrl(getGalleryDetailUrl());
|
||||
((MainActivity) requireActivity()).setMShareUrl(getGalleryDetailUrl());
|
||||
|
||||
return view;
|
||||
}
|
||||
@@ -634,7 +632,7 @@ public class GalleryDetailScene extends CollapsingToolbarScene implements View.O
|
||||
Context context = getContext();
|
||||
AssertUtils.assertNotNull(context);
|
||||
EhApplication.getDownloadManager().removeDownloadInfoListener(this);
|
||||
((MainActivity)requireActivity()).setMShareUrl(null);
|
||||
((MainActivity) requireActivity()).setMShareUrl(null);
|
||||
|
||||
mTip = null;
|
||||
mViewTransition = null;
|
||||
@@ -1517,40 +1515,6 @@ public class GalleryDetailScene extends CollapsingToolbarScene implements View.O
|
||||
private @interface State {
|
||||
}
|
||||
|
||||
private class GetGalleryDetailListener extends EhCallback<GalleryDetailScene, GalleryDetail> {
|
||||
|
||||
public GetGalleryDetailListener(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(GalleryDetail result) {
|
||||
getApplication().removeGlobalStuff(this);
|
||||
|
||||
// Put gallery detail to cache
|
||||
EhApplication.getGalleryDetailCache().put(result.getGid(), result);
|
||||
|
||||
// Add history
|
||||
EhDB.putHistoryInfo(result);
|
||||
|
||||
// Notify success
|
||||
GalleryDetailScene scene = GalleryDetailScene.this;
|
||||
scene.onGetGalleryDetailSuccess(result);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Exception e) {
|
||||
getApplication().removeGlobalStuff(this);
|
||||
GalleryDetailScene scene = GalleryDetailScene.this;
|
||||
scene.onGetGalleryDetailFailure(e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCancel() {
|
||||
getApplication().removeGlobalStuff(this);
|
||||
}
|
||||
}
|
||||
|
||||
private static class VoteTagListener extends EhCallback<GalleryDetailScene, VoteTagParser.Result> {
|
||||
|
||||
public VoteTagListener(Context context) {
|
||||
@@ -1576,69 +1540,6 @@ public class GalleryDetailScene extends CollapsingToolbarScene implements View.O
|
||||
}
|
||||
}
|
||||
|
||||
private class RateGalleryListener extends EhCallback<GalleryDetailScene, RateGalleryParser.Result> {
|
||||
|
||||
private final long mGid;
|
||||
|
||||
public RateGalleryListener(Context context, int stageId, String sceneTag, long gid) {
|
||||
super(context);
|
||||
mGid = gid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(RateGalleryParser.Result result) {
|
||||
showTip(R.string.rate_successfully, LENGTH_SHORT);
|
||||
|
||||
GalleryDetailScene scene = GalleryDetailScene.this;
|
||||
scene.onRateGallerySuccess(result);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Exception e) {
|
||||
e.printStackTrace();
|
||||
showTip(R.string.rate_failed, LENGTH_LONG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCancel() {
|
||||
}
|
||||
}
|
||||
|
||||
private class ModifyFavoritesListener extends EhCallback<GalleryDetailScene, Void> {
|
||||
|
||||
private final boolean mAddOrRemove;
|
||||
|
||||
/**
|
||||
* @param addOrRemove false for add, true for remove
|
||||
*/
|
||||
public ModifyFavoritesListener(Context context, boolean addOrRemove) {
|
||||
super(context);
|
||||
mAddOrRemove = addOrRemove;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(Void result) {
|
||||
showTip(mAddOrRemove ? R.string.remove_from_favorite_success :
|
||||
R.string.add_to_favorite_success, LENGTH_SHORT);
|
||||
GalleryDetailScene scene = GalleryDetailScene.this;
|
||||
scene.onModifyFavoritesSuccess(mAddOrRemove);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Exception e) {
|
||||
showTip(mAddOrRemove ? R.string.remove_from_favorite_failure :
|
||||
R.string.add_to_favorite_failure, LENGTH_LONG);
|
||||
GalleryDetailScene scene = GalleryDetailScene.this;
|
||||
scene.onModifyFavoritesFailure();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCancel() {
|
||||
GalleryDetailScene scene = GalleryDetailScene.this;
|
||||
scene.onModifyFavoritesCancel();
|
||||
}
|
||||
}
|
||||
|
||||
private static class DownloadArchiveListener extends EhCallback<GalleryDetailScene, String> {
|
||||
|
||||
private final GalleryInfo mGalleryInfo;
|
||||
@@ -1718,6 +1619,103 @@ public class GalleryDetailScene extends CollapsingToolbarScene implements View.O
|
||||
}
|
||||
}
|
||||
|
||||
private class GetGalleryDetailListener extends EhCallback<GalleryDetailScene, GalleryDetail> {
|
||||
|
||||
public GetGalleryDetailListener(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(GalleryDetail result) {
|
||||
getApplication().removeGlobalStuff(this);
|
||||
|
||||
// Put gallery detail to cache
|
||||
EhApplication.getGalleryDetailCache().put(result.getGid(), result);
|
||||
|
||||
// Add history
|
||||
EhDB.putHistoryInfo(result);
|
||||
|
||||
// Notify success
|
||||
GalleryDetailScene scene = GalleryDetailScene.this;
|
||||
scene.onGetGalleryDetailSuccess(result);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Exception e) {
|
||||
getApplication().removeGlobalStuff(this);
|
||||
GalleryDetailScene scene = GalleryDetailScene.this;
|
||||
scene.onGetGalleryDetailFailure(e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCancel() {
|
||||
getApplication().removeGlobalStuff(this);
|
||||
}
|
||||
}
|
||||
|
||||
private class RateGalleryListener extends EhCallback<GalleryDetailScene, RateGalleryParser.Result> {
|
||||
|
||||
private final long mGid;
|
||||
|
||||
public RateGalleryListener(Context context, int stageId, String sceneTag, long gid) {
|
||||
super(context);
|
||||
mGid = gid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(RateGalleryParser.Result result) {
|
||||
showTip(R.string.rate_successfully, LENGTH_SHORT);
|
||||
|
||||
GalleryDetailScene scene = GalleryDetailScene.this;
|
||||
scene.onRateGallerySuccess(result);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Exception e) {
|
||||
e.printStackTrace();
|
||||
showTip(R.string.rate_failed, LENGTH_LONG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCancel() {
|
||||
}
|
||||
}
|
||||
|
||||
private class ModifyFavoritesListener extends EhCallback<GalleryDetailScene, Void> {
|
||||
|
||||
private final boolean mAddOrRemove;
|
||||
|
||||
/**
|
||||
* @param addOrRemove false for add, true for remove
|
||||
*/
|
||||
public ModifyFavoritesListener(Context context, boolean addOrRemove) {
|
||||
super(context);
|
||||
mAddOrRemove = addOrRemove;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(Void result) {
|
||||
showTip(mAddOrRemove ? R.string.remove_from_favorite_success :
|
||||
R.string.add_to_favorite_success, LENGTH_SHORT);
|
||||
GalleryDetailScene scene = GalleryDetailScene.this;
|
||||
scene.onModifyFavoritesSuccess(mAddOrRemove);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Exception e) {
|
||||
showTip(mAddOrRemove ? R.string.remove_from_favorite_failure :
|
||||
R.string.add_to_favorite_failure, LENGTH_LONG);
|
||||
GalleryDetailScene scene = GalleryDetailScene.this;
|
||||
scene.onModifyFavoritesFailure();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCancel() {
|
||||
GalleryDetailScene scene = GalleryDetailScene.this;
|
||||
scene.onModifyFavoritesCancel();
|
||||
}
|
||||
}
|
||||
|
||||
private class ArchiveListDialogHelper implements AdapterView.OnItemClickListener,
|
||||
DialogInterface.OnDismissListener, EhClient.Callback<ArchiveParser.Result> {
|
||||
|
||||
|
||||
@@ -1241,6 +1241,7 @@ class GalleryListScene : SearchBarScene(), OnDragHandlerListener, SearchLayout.H
|
||||
setState(STATE_SEARCH)
|
||||
}
|
||||
}
|
||||
|
||||
abstract fun getDestination(): Int
|
||||
|
||||
abstract fun getArgs(): Bundle
|
||||
|
||||
@@ -250,6 +250,19 @@ public class GalleryPreviewsScene extends BaseToolbarScene {
|
||||
}
|
||||
}
|
||||
|
||||
private static class GalleryPreviewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
public LoadImageView image;
|
||||
public TextView text;
|
||||
|
||||
public GalleryPreviewHolder(View itemView) {
|
||||
super(itemView);
|
||||
|
||||
image = itemView.findViewById(R.id.image);
|
||||
text = itemView.findViewById(R.id.text);
|
||||
}
|
||||
}
|
||||
|
||||
private class GetPreviewSetListener extends EhCallback<GalleryPreviewsScene, Pair<PreviewSet, Integer>> {
|
||||
|
||||
private final int mTaskId;
|
||||
@@ -277,19 +290,6 @@ public class GalleryPreviewsScene extends BaseToolbarScene {
|
||||
}
|
||||
}
|
||||
|
||||
private static class GalleryPreviewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
public LoadImageView image;
|
||||
public TextView text;
|
||||
|
||||
public GalleryPreviewHolder(View itemView) {
|
||||
super(itemView);
|
||||
|
||||
image = itemView.findViewById(R.id.image);
|
||||
text = itemView.findViewById(R.id.text);
|
||||
}
|
||||
}
|
||||
|
||||
private class GalleryPreviewAdapter extends RecyclerView.Adapter<GalleryPreviewHolder> {
|
||||
|
||||
private final LayoutInflater mInflater;
|
||||
|
||||
Reference in new issue
Block a user