Reformat Code

This commit is contained in:
tarsin committed 2022-12-11 12:26:22 +08:00
1 parent 8d1fc85638
commit a859941845
22 files changed
+85 -85

No files matched your search

@@ -250,21 +250,7 @@ public final class DiskLruCache implements Closeable {
private static String inputStreamToString(InputStream in) throws IOException {
return Util.readFully(new InputStreamReader(in, Util.UTF_8));
} 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;
}
};
}
private void readJournal() throws IOException {
StrictLineReader reader = new StrictLineReader(new FileInputStream(journalFile), Util.US_ASCII);
@@ -304,7 +290,21 @@ public final class DiskLruCache implements Closeable {
} finally {
Util.closeQuietly(reader);
}
}
} 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;
}
};
private void readJournalLine(String line) throws IOException {
int firstSpace = line.indexOf(' ');
@@ -27,7 +27,6 @@ import androidx.annotation.Nullable;
import androidx.preference.PreferenceManager;
import com.hippo.ehviewer.client.EhConfig;
import com.hippo.ehviewer.client.EhUtils;
import com.hippo.ehviewer.client.data.FavListUrlBuilder;
import com.hippo.ehviewer.ui.CommonOperations;
import com.hippo.ehviewer.ui.scene.GalleryListScene;
@@ -67,8 +66,6 @@ public class Settings {
public static final int DEFAULT_DEFAULT_CATEGORIES = EhConfig.ALL_CATEGORY;
public static final String KEY_EXCLUDED_TAG_NAMESPACES = "excluded_tag_namespaces";
public static final String KEY_EXCLUDED_LANGUAGES = "excluded_languages";
private static final String KEY_HIDE_HV_EVENTS = "hide_hv_events";
private static final boolean DEFAULT_HIDE_HV_EVENTS = true;
/********************
****** Privacy and Security
********************/
@@ -102,6 +99,8 @@ public class Settings {
public static final String KEY_DOMAIN_FRONTING = "domain_fronting";
public static final String KEY_APP_LANGUAGE = "app_language";
public static final String KEY_LIST_THUMB_SIZE = "list_tile_size";
private static final String KEY_HIDE_HV_EVENTS = "hide_hv_events";
private static final boolean DEFAULT_HIDE_HV_EVENTS = true;
private static final String KEY_SHOW_COMMENTS = "show_gallery_comments";
private static final boolean DEFAULT_SHOW_COMMENTS = true;
private static final String KEY_PREVIEW_NUM = "preview_num";
@@ -55,9 +55,8 @@ public class EhClient {
public static final int METHOD_DOWNLOAD_ARCHIVE = 18;
public static final int METHOD_VOTE_TAG = 19;
public static final int METHOD_GET_UCONFIG = 20;
private final ThreadPoolExecutor mRequestThreadPool;
private static final OkHttpClient mOkHttpClient = EhApplication.getOkHttpClient();
private final ThreadPoolExecutor mRequestThreadPool;
public EhClient() {
mRequestThreadPool = IoThreadPoolExecutor.getInstance();
@@ -814,7 +814,7 @@ public class EhEngine {
}
public static Void getUConfig(@Nullable EhClient.Task task,
OkHttpClient okHttpClient) throws Throwable {
OkHttpClient okHttpClient) throws Throwable {
String url = EhUrl.getUConfigUrl();
Log.d(TAG, url);
Request request = new EhRequestBuilder(url, null).build();
@@ -520,6 +520,15 @@ public class GalleryActivity extends EhActivity implements SeekBar.OnSeekBarChan
if (mGLRootView != null) {
mGLRootView.onPause();
}
}
@Override
protected void onResume() {
super.onResume();
if (mGLRootView != null) {
mGLRootView.onResume();
}
} ActivityResultLauncher<String> requestStoragePermissionLauncher = registerForActivityResult(
new ActivityResultContracts.RequestPermission(),
result -> {
@@ -531,15 +540,6 @@ public class GalleryActivity extends EhActivity implements SeekBar.OnSeekBarChan
mSavingPage = -1;
});
@Override
protected void onResume() {
super.onResume();
if (mGLRootView != null) {
mGLRootView.onResume();
}
}
@Override
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
@@ -232,7 +232,7 @@ public class FavoritesScene extends SearchBarScene implements
@NonNull
@Override
public View onCreateViewWithToolbar(@NonNull LayoutInflater inflater,
@Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
@Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.scene_favorites, container, false);
ContentLayout mContentLayout = view.findViewById(R.id.content_layout);
MainActivity activity = getMainActivity();
@@ -245,7 +245,7 @@ public class FavoritesScene extends SearchBarScene implements
mRecyclerView = mContentLayout.getRecyclerView();
FastScroller fastScroller = mContentLayout.getFastScroller();
mFabLayout = (FabLayout) ViewUtils.$$(view, R.id.fab_layout);
((ViewGroup)mFabLayout.getParent()).removeView(mFabLayout);
((ViewGroup) mFabLayout.getParent()).removeView(mFabLayout);
AssertUtils.assertNotNull(container);
container.addView(mFabLayout);
ViewCompat.setWindowInsetsAnimationCallback(view, new WindowInsetsAnimationHelper(
@@ -365,7 +365,7 @@ public class FavoritesScene extends SearchBarScene implements
mRecyclerView = null;
}
if (null != mFabLayout) {
((ViewGroup)mFabLayout.getParent()).removeView(mFabLayout);
((ViewGroup) mFabLayout.getParent()).removeView(mFabLayout);
removeAboveSnackView(mFabLayout);
mFabLayout = null;
}
@@ -65,7 +65,6 @@ import com.google.android.material.snackbar.Snackbar;
import com.hippo.app.BaseDialogBuilder;
import com.hippo.app.CheckBoxDialogBuilder;
import com.hippo.app.EditTextDialogBuilder;
import com.hippo.ehviewer.AppConfig;
import com.hippo.ehviewer.EhApplication;
import com.hippo.ehviewer.EhDB;
import com.hippo.ehviewer.R;
@@ -119,7 +118,6 @@ import com.hippo.yorozuya.IntIdGenerator;
import com.hippo.yorozuya.ViewUtils;
import com.hippo.yorozuya.collect.IntList;
import java.io.File;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.ArrayList;
@@ -267,11 +267,6 @@ public final class GalleryListScene extends SearchBarScene
}
}
@Override
public int getMenuResId() {
return R.menu.scene_gallery_list_searchbar_menu;
}
public static void startScene(SceneFragment scene, ListUrlBuilder lub) {
scene.startScene(getStartAnnouncer(lub));
}
@@ -283,6 +278,11 @@ public final class GalleryListScene extends SearchBarScene
return new Announcer(GalleryListScene.class).setArgs(args);
}
@Override
public int getMenuResId() {
return R.menu.scene_gallery_list_searchbar_menu;
}
@Override
public int getNavCheckedItem() {
return mNavCheckedId;
@@ -558,7 +558,7 @@ public final class GalleryListScene extends SearchBarScene
mFabLayout,
(View) mSearchFab.getParent()
));
((ViewGroup)mFabLayout.getParent()).removeView(mFabLayout);
((ViewGroup) mFabLayout.getParent()).removeView(mFabLayout);
container.addView(mFabLayout);
int paddingTopSB = resources.getDimensionPixelOffset(R.dimen.gallery_padding_top_search_bar);
@@ -601,7 +601,7 @@ public final class GalleryListScene extends SearchBarScene
int colorID = ResourcesKt.resolveColor(getTheme(), com.google.android.material.R.attr.colorOnSurface);
mActionFabDrawable = new AddDeleteDrawable(context, colorID);
mFabLayout.getPrimaryFab().setImageDrawable(mActionFabDrawable);
mSearchFab.setOnClickListener( (v) -> {
mSearchFab.setOnClickListener((v) -> {
if (STATE_NORMAL != mState) {
onApplySearch();
hideSoftInput();
@@ -640,7 +640,7 @@ public final class GalleryListScene extends SearchBarScene
mRecyclerView = null;
}
if (null != mFabLayout) {
((ViewGroup)mFabLayout.getParent()).removeView(mFabLayout);
((ViewGroup) mFabLayout.getParent()).removeView(mFabLayout);
removeAboveSnackView(mFabLayout);
mFabLayout = null;
}
@@ -41,7 +41,8 @@ abstract class SearchBarScene : ToolbarScene() {
inflater.inflate(R.layout.scene_searchbar, container, false) as ViewGroup
mToolbar = view.findViewById(R.id.toolbar)
mAppBarLayout = view.findViewById(R.id.appbar)
mAppBarLayout?.statusBarForeground = MaterialShapeDrawable.createWithElevationOverlay(context)
mAppBarLayout?.statusBarForeground =
MaterialShapeDrawable.createWithElevationOverlay(context)
mSearchView = view.findViewById(R.id.searchview)
mRecyclerView = view.findViewById(R.id.search_bar_list)
@@ -26,7 +26,6 @@ import com.hippo.glview.image.ImageWrapper;
import com.hippo.glview.view.GLRoot;
import com.hippo.image.Image;
import com.hippo.yorozuya.ConcurrentPool;
import com.hippo.yorozuya.MathUtils;
import com.hippo.yorozuya.OSUtils;
import java.lang.annotation.Retention;
@@ -16,7 +16,6 @@
package com.hippo.glview.image;
import android.graphics.Bitmap;
import android.graphics.Rect;
import android.util.Log;
@@ -118,6 +118,12 @@ public class BatteryView extends AppCompatTextView {
stopCharger();
mAttached = false;
}
}
private void registerReceiver() {
final IntentFilter filter = new IntentFilter();
filter.addAction(Intent.ACTION_BATTERY_CHANGED);
getContext().registerReceiver(mIntentReceiver, filter, null, getHandler());
} private final Runnable mCharger = new Runnable() {
private int level = 0;
@@ -133,12 +139,6 @@ public class BatteryView extends AppCompatTextView {
}
};
private void registerReceiver() {
final IntentFilter filter = new IntentFilter();
filter.addAction(Intent.ACTION_BATTERY_CHANGED);
getContext().registerReceiver(mIntentReceiver, filter, null, getHandler());
}
private void unregisterReceiver() {
getContext().unregisterReceiver(mIntentReceiver);
}
@@ -119,6 +119,10 @@ public class TextClock extends AppCompatTextView {
chooseFormat();
onTimeChanged();
}
public boolean is24HourModeEnabled() {
return DateFormat.is24HourFormat(getContext());
} private final Runnable mTicker = new Runnable() {
@Override
public void run() {
@@ -131,10 +135,6 @@ public class TextClock extends AppCompatTextView {
}
};
public boolean is24HourModeEnabled() {
return DateFormat.is24HourFormat(getContext());
}
public String getTimeZone() {
return mTimeZone;
}
@@ -236,6 +236,16 @@ public class TextClock extends AppCompatTextView {
private void unregisterReceiver() {
getContext().unregisterReceiver(mIntentReceiver);
}
private void unregisterObserver() {
final ContentResolver resolver = getContext().getContentResolver();
resolver.unregisterContentObserver(mFormatChangeObserver);
}
private void onTimeChanged() {
mTime.setTimeInMillis(System.currentTimeMillis());
setText(DateFormat.format(mFormat, mTime));
} private final ContentObserver mFormatChangeObserver = new ContentObserver(new Handler()) {
@Override
public void onChange(boolean selfChange) {
@@ -250,16 +260,6 @@ public class TextClock extends AppCompatTextView {
}
};
private void unregisterObserver() {
final ContentResolver resolver = getContext().getContentResolver();
resolver.unregisterContentObserver(mFormatChangeObserver);
}
private void onTimeChanged() {
mTime.setTimeInMillis(System.currentTimeMillis());
setText(DateFormat.format(mFormat, mTime));
}