Reformat Code
This commit is contained in:
1 parent
5513d47b6d
commit
e0f7dab34f
30 files changed
+129
-178
No files matched your search
@@ -21,10 +21,6 @@ package com.hippo;
|
||||
import android.content.Context;
|
||||
import android.net.Uri;
|
||||
import android.os.ParcelFileDescriptor;
|
||||
import android.system.Os;
|
||||
import android.system.OsConstants;
|
||||
|
||||
import java.io.FileDescriptor;
|
||||
|
||||
public class UriArchiveAccessor {
|
||||
ParcelFileDescriptor pfd;
|
||||
|
||||
@@ -231,6 +231,12 @@ public final class DiskLruCache implements Closeable {
|
||||
cache = new DiskLruCache(directory, appVersion, valueCount, maxSize);
|
||||
cache.rebuildJournal();
|
||||
return cache;
|
||||
}
|
||||
|
||||
private static void deleteIfExists(File file) throws IOException {
|
||||
if (file.exists() && !file.delete()) {
|
||||
throw new IOException();
|
||||
}
|
||||
} private final Callable<Void> cleanupCallable = new Callable<>() {
|
||||
public Void call() throws Exception {
|
||||
synchronized (DiskLruCache.this) {
|
||||
@@ -247,12 +253,6 @@ public final class DiskLruCache implements Closeable {
|
||||
}
|
||||
};
|
||||
|
||||
private static void deleteIfExists(File file) throws IOException {
|
||||
if (file.exists() && !file.delete()) {
|
||||
throw new IOException();
|
||||
}
|
||||
}
|
||||
|
||||
private static void renameTo(File from, File to, boolean deleteDestination) throws IOException {
|
||||
if (deleteDestination) {
|
||||
deleteIfExists(to);
|
||||
|
||||
@@ -97,16 +97,13 @@ public class Settings {
|
||||
public static final String KEY_BUILT_IN_HOSTS = "built_in_hosts_2";
|
||||
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 TAG = Settings.class.getSimpleName();
|
||||
private static final String KEY_VERSION_CODE = "version_code";
|
||||
private static final int DEFAULT_VERSION_CODE = 0;
|
||||
private static final String KEY_DISPLAY_NAME = "display_name";
|
||||
private static final String DEFAULT_DISPLAY_NAME = null;
|
||||
public static final String KEY_LIST_THUMB_SIZE = "list_tile_size";
|
||||
private static final int DEFAULT_LIST_THUMB_SIZE = 40;
|
||||
private static int LIST_THUMB_SIZE = 40;
|
||||
|
||||
public static boolean LIST_THUMB_SIZE_INITED = false;
|
||||
private static final String KEY_AVATAR = "avatar";
|
||||
private static final String DEFAULT_AVATAR = null;
|
||||
private static final String KEY_SHOW_WARNING = "show_warning";
|
||||
@@ -279,11 +276,9 @@ public class Settings {
|
||||
private static final int DEFAULT_DOWNLOAD_DELAY = 0;
|
||||
private static final String KEY_REQUEST_NEWS = "request_news";
|
||||
private static final boolean DEFAULT_REQUEST_NEWS = true;
|
||||
|
||||
|
||||
private static final String KEY_ARCHIVE_PASSWDS = "archive_passwds";
|
||||
|
||||
|
||||
public static boolean LIST_THUMB_SIZE_INITED = false;
|
||||
private static int LIST_THUMB_SIZE = 40;
|
||||
private static Context sContext;
|
||||
private static SharedPreferences sSettingsPre;
|
||||
private static EhConfig sEhConfig;
|
||||
|
||||
@@ -19,13 +19,12 @@ package com.hippo.ehviewer.client.data;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import com.hippo.ehviewer.client.EhUrl;
|
||||
import com.hippo.network.UrlBuilder;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
public class FavListUrlBuilder implements Parcelable {
|
||||
|
||||
@@ -93,17 +92,13 @@ public class FavListUrlBuilder implements Parcelable {
|
||||
ub.addQuery("favcat", "all");
|
||||
}
|
||||
if (!TextUtils.isEmpty(mKeyword)) {
|
||||
try {
|
||||
ub.addQuery("f_search", URLEncoder.encode(mKeyword, "UTF-8"));
|
||||
// Name
|
||||
ub.addQuery("sn", "on");
|
||||
// Tags
|
||||
ub.addQuery("st", "on");
|
||||
// Note
|
||||
ub.addQuery("sf", "on");
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
Log.e(TAG, "Can't URLEncoder.encode " + mKeyword);
|
||||
}
|
||||
ub.addQuery("f_search", URLEncoder.encode(mKeyword, StandardCharsets.UTF_8));
|
||||
// Name
|
||||
ub.addQuery("sn", "on");
|
||||
// Tags
|
||||
ub.addQuery("st", "on");
|
||||
// Note
|
||||
ub.addQuery("sf", "on");
|
||||
}
|
||||
if (mIndex > 0) {
|
||||
ub.addQuery("page", Integer.toString(mIndex));
|
||||
|
||||
@@ -32,11 +32,11 @@ import com.hippo.network.UrlBuilder;
|
||||
import com.hippo.yorozuya.NumberUtils;
|
||||
import com.hippo.yorozuya.StringUtils;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.net.URLDecoder;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
public class ListUrlBuilder implements Cloneable, Parcelable {
|
||||
|
||||
@@ -383,8 +383,8 @@ public class ListUrlBuilder implements Cloneable, Parcelable {
|
||||
break;
|
||||
case "f_search":
|
||||
try {
|
||||
keyword = URLDecoder.decode(value, "utf-8");
|
||||
} catch (UnsupportedEncodingException | IllegalArgumentException e) {
|
||||
keyword = URLDecoder.decode(value, StandardCharsets.UTF_8);
|
||||
} catch (IllegalArgumentException e) {
|
||||
// Ignore
|
||||
}
|
||||
break;
|
||||
@@ -514,11 +514,7 @@ public class ListUrlBuilder implements Cloneable, Parcelable {
|
||||
if (mKeyword != null) {
|
||||
String keyword = mKeyword.trim();
|
||||
if (!keyword.isEmpty()) {
|
||||
try {
|
||||
ub.addQuery("f_search", URLEncoder.encode(mKeyword, "UTF-8"));
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
// Empty
|
||||
}
|
||||
ub.addQuery("f_search", URLEncoder.encode(mKeyword, StandardCharsets.UTF_8));
|
||||
}
|
||||
}
|
||||
if (mSHash != null) {
|
||||
@@ -565,11 +561,7 @@ public class ListUrlBuilder implements Cloneable, Parcelable {
|
||||
case MODE_UPLOADER: {
|
||||
StringBuilder sb = new StringBuilder(EhUrl.getHost());
|
||||
sb.append("uploader/");
|
||||
try {
|
||||
sb.append(URLEncoder.encode(mKeyword, "UTF-8"));
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
// Empty
|
||||
}
|
||||
sb.append(URLEncoder.encode(mKeyword, StandardCharsets.UTF_8));
|
||||
if (mPageIndex != 0) {
|
||||
sb.append('/').append(mPageIndex);
|
||||
}
|
||||
@@ -578,11 +570,7 @@ public class ListUrlBuilder implements Cloneable, Parcelable {
|
||||
case MODE_TAG: {
|
||||
StringBuilder sb = new StringBuilder(EhUrl.getHost());
|
||||
sb.append("tag/");
|
||||
try {
|
||||
sb.append(URLEncoder.encode(mKeyword, "UTF-8"));
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
// Empty
|
||||
}
|
||||
sb.append(URLEncoder.encode(mKeyword, StandardCharsets.UTF_8));
|
||||
if (mPageIndex != 0) {
|
||||
sb.append('/').append(mPageIndex);
|
||||
}
|
||||
@@ -595,11 +583,7 @@ public class ListUrlBuilder implements Cloneable, Parcelable {
|
||||
case MODE_TOPLIST:
|
||||
StringBuilder sb = new StringBuilder(EhUrl.HOST_E);
|
||||
sb.append("toplist.php?tl=");
|
||||
try {
|
||||
sb.append(URLEncoder.encode(mKeyword, "UTF-8"));
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
// Empty
|
||||
}
|
||||
sb.append(URLEncoder.encode(mKeyword, StandardCharsets.UTF_8));
|
||||
if (mPageIndex != 0) {
|
||||
sb.append("&p=").append(mPageIndex);
|
||||
}
|
||||
|
||||
@@ -23,10 +23,10 @@ import com.hippo.ehviewer.client.EhUrl;
|
||||
import com.hippo.ehviewer.client.data.ListUrlBuilder;
|
||||
import com.hippo.yorozuya.Utilities;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.net.URLDecoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
public final class GalleryListUrlParser {
|
||||
|
||||
@@ -91,11 +91,7 @@ public final class GalleryListUrlParser {
|
||||
uploader = path.substring(prefixLength, index);
|
||||
}
|
||||
|
||||
try {
|
||||
uploader = URLDecoder.decode(uploader, "utf-8");
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
return null;
|
||||
}
|
||||
uploader = URLDecoder.decode(uploader, StandardCharsets.UTF_8);
|
||||
|
||||
if (TextUtils.isEmpty(uploader)) {
|
||||
return null;
|
||||
@@ -120,11 +116,7 @@ public final class GalleryListUrlParser {
|
||||
tag = path.substring(prefixLength, index);
|
||||
}
|
||||
|
||||
try {
|
||||
tag = URLDecoder.decode(tag, "utf-8");
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
return null;
|
||||
}
|
||||
tag = URLDecoder.decode(tag, StandardCharsets.UTF_8);
|
||||
|
||||
if (TextUtils.isEmpty(tag)) {
|
||||
return null;
|
||||
|
||||
@@ -4,5 +4,6 @@ import java.util.List;
|
||||
|
||||
public interface BasicDao<T> {
|
||||
List<T> list();
|
||||
|
||||
long insert(T t);
|
||||
}
|
||||
@@ -48,14 +48,13 @@ public class ArchiveGalleryProvider extends GalleryProvider2 {
|
||||
private final UriArchiveAccessor archiveAccessor;
|
||||
private final Stack<Integer> requests = new Stack<>();
|
||||
private final LinkedHashMap<Integer, Long> streams = new LinkedHashMap<>();
|
||||
private Thread archiveThread;
|
||||
private Thread[] decodeThread = new Thread[] {
|
||||
private final Thread[] decodeThread = new Thread[]{
|
||||
new Thread(new DecodeTask()),
|
||||
new Thread(new DecodeTask()),
|
||||
new Thread(new DecodeTask()),
|
||||
new Thread(new DecodeTask())
|
||||
};
|
||||
|
||||
private Thread archiveThread;
|
||||
private volatile int size = STATE_WAIT;
|
||||
private String error;
|
||||
|
||||
@@ -168,7 +167,7 @@ public class ArchiveGalleryProvider extends GalleryProvider2 {
|
||||
}
|
||||
|
||||
private class ArchiveHostTask implements Runnable {
|
||||
public final Thread[] archiveThreads = new Thread[] {
|
||||
public final Thread[] archiveThreads = new Thread[]{
|
||||
new Thread(new ArchiveTask()),
|
||||
new Thread(new ArchiveTask()),
|
||||
new Thread(new ArchiveTask()),
|
||||
|
||||
@@ -56,7 +56,7 @@ class VersionPreference @JvmOverloads constructor(
|
||||
}
|
||||
|
||||
fun getMessage(): String {
|
||||
return message;
|
||||
return message
|
||||
}
|
||||
|
||||
fun addLib(msg: String): NativeLibInfo {
|
||||
|
||||
@@ -121,7 +121,7 @@ abstract class EhActivity : AppCompatActivity() {
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.TIRAMISU)
|
||||
fun checkAndRequestNotificationPermission(){
|
||||
fun checkAndRequestNotificationPermission() {
|
||||
if (ContextCompat.checkSelfPermission(
|
||||
this,
|
||||
Manifest.permission.POST_NOTIFICATIONS
|
||||
|
||||
@@ -290,16 +290,7 @@ public class GalleryActivity extends EhActivity implements SeekBar.OnSeekBarChan
|
||||
}
|
||||
outState.putInt(KEY_PAGE, mPage);
|
||||
outState.putInt(KEY_CURRENT_INDEX, mCurrentIndex);
|
||||
} ActivityResultLauncher<String> requestStoragePermissionLauncher = registerForActivityResult(
|
||||
new ActivityResultContracts.RequestPermission(),
|
||||
result -> {
|
||||
if (result && mSavingPage != -1) {
|
||||
saveImage(mSavingPage);
|
||||
} else {
|
||||
Toast.makeText(this, R.string.error_cant_save_image, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
mSavingPage = -1;
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void attachBaseContext(@NonNull Context newBase) {
|
||||
@@ -312,7 +303,16 @@ public class GalleryActivity extends EhActivity implements SeekBar.OnSeekBarChan
|
||||
break;
|
||||
}
|
||||
super.attachBaseContext(newBase);
|
||||
}
|
||||
} ActivityResultLauncher<String> requestStoragePermissionLauncher = registerForActivityResult(
|
||||
new ActivityResultContracts.RequestPermission(),
|
||||
result -> {
|
||||
if (result && mSavingPage != -1) {
|
||||
saveImage(mSavingPage);
|
||||
} else {
|
||||
Toast.makeText(this, R.string.error_cant_save_image, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
mSavingPage = -1;
|
||||
});
|
||||
|
||||
@Override
|
||||
@SuppressWarnings({"WrongConstant"})
|
||||
@@ -410,7 +410,7 @@ public class GalleryActivity extends EhActivity implements SeekBar.OnSeekBarChan
|
||||
if (scroll < 0.0f) {
|
||||
if (mLayoutMode == GalleryView.LAYOUT_RIGHT_TO_LEFT) {
|
||||
mGalleryView.pageLeft();
|
||||
} else if (mLayoutMode == GalleryView.LAYOUT_LEFT_TO_RIGHT){
|
||||
} else if (mLayoutMode == GalleryView.LAYOUT_LEFT_TO_RIGHT) {
|
||||
mGalleryView.pageRight();
|
||||
} else if (mLayoutMode == GalleryView.LAYOUT_TOP_TO_BOTTOM) {
|
||||
mGalleryView.onScroll(0, -scroll, 0, -scroll, 0, -scroll);
|
||||
@@ -1375,4 +1375,6 @@ public class GalleryActivity extends EhActivity implements SeekBar.OnSeekBarChan
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -33,7 +33,8 @@ class SettingsActivity : EhActivity() {
|
||||
setSupportActionBar(findViewById(R.id.toolbar))
|
||||
val bar = supportActionBar
|
||||
bar?.setDisplayHomeAsUpEnabled(true)
|
||||
WindowCompat.getInsetsController(window, window.decorView).isAppearanceLightStatusBars = (resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_YES) <= 0
|
||||
WindowCompat.getInsetsController(window, window.decorView).isAppearanceLightStatusBars =
|
||||
(resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_YES) <= 0
|
||||
if (savedInstanceState == null) {
|
||||
supportFragmentManager
|
||||
.beginTransaction()
|
||||
|
||||
@@ -70,7 +70,8 @@ public class BasePreferenceFragment extends PreferenceFragmentCompat
|
||||
.replace(R.id.fragment, classObj)
|
||||
.addToBackStack(null)
|
||||
.commitAllowingStateLoss();
|
||||
} catch (ClassNotFoundException | IllegalAccessException | java.lang.InstantiationException ignored) {
|
||||
} catch (ClassNotFoundException | IllegalAccessException |
|
||||
java.lang.InstantiationException ignored) {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -21,13 +21,10 @@ import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Point;
|
||||
import android.graphics.Rect;
|
||||
import android.os.Bundle;
|
||||
import android.text.InputType;
|
||||
import android.text.TextUtils;
|
||||
import android.util.SparseBooleanArray;
|
||||
import android.view.Display;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
@@ -77,7 +74,6 @@ import com.hippo.widget.ContentLayout;
|
||||
import com.hippo.widget.FabLayout;
|
||||
import com.hippo.widget.SearchBarMover;
|
||||
import com.hippo.yorozuya.AssertUtils;
|
||||
import com.hippo.yorozuya.LayoutUtils;
|
||||
import com.hippo.yorozuya.ObjectUtils;
|
||||
import com.hippo.yorozuya.SimpleHandler;
|
||||
import com.hippo.yorozuya.ViewUtils;
|
||||
|
||||
@@ -133,6 +133,8 @@ public final class GalleryListScene extends BaseScene
|
||||
private final static int STATE_SEARCH = 2;
|
||||
private final static int STATE_SEARCH_SHOW_LIST = 3;
|
||||
private static final long ANIMATE_TIME = 300L;
|
||||
// Double click back exit
|
||||
private final long mPressBackTime = 0;
|
||||
/*---------------
|
||||
Whole life cycle
|
||||
---------------*/
|
||||
@@ -213,8 +215,6 @@ public final class GalleryListScene extends BaseScene
|
||||
}
|
||||
}
|
||||
};
|
||||
// Double click back exit
|
||||
private long mPressBackTime = 0;
|
||||
private boolean mHasFirstRefresh = false;
|
||||
private int mNavCheckedId = 0;
|
||||
private DownloadManager mDownloadManager;
|
||||
|
||||
@@ -20,7 +20,6 @@ import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
|
||||
import com.hippo.ehviewer.Settings;
|
||||
import com.hippo.ehviewer.client.EhUtils;
|
||||
import com.hippo.scene.Announcer;
|
||||
|
||||
/**
|
||||
|
||||
@@ -242,7 +242,7 @@ class SearchLayout @JvmOverloads constructor(
|
||||
override fun onTabReselected(tab: TabLayout.Tab) {}
|
||||
|
||||
@IntDef(SEARCH_MODE_NORMAL, SEARCH_MODE_IMAGE)
|
||||
@kotlin.annotation.Retention(AnnotationRetention.SOURCE)
|
||||
@Retention(AnnotationRetention.SOURCE)
|
||||
private annotation class SearchMode
|
||||
interface Helper {
|
||||
fun onChangeSearchMode()
|
||||
|
||||
@@ -983,15 +983,13 @@ public final class GalleryView extends GLView implements GestureRecognizer.Liste
|
||||
|
||||
private final Context mContext;
|
||||
private final Adapter mAdapter;
|
||||
private final int mEdgeColor = Color.WHITE;
|
||||
private Listener mListener;
|
||||
|
||||
private int mLayoutMode = LAYOUT_LEFT_TO_RIGHT;
|
||||
private int mScaleMode = SCALE_FIT;
|
||||
private int mStartPosition = START_POSITION_TOP_LEFT;
|
||||
private int mStartPage = 0;
|
||||
|
||||
private int mBackgroundColor = Color.BLACK;
|
||||
private int mEdgeColor = Color.WHITE;
|
||||
private int mPagerInterval = 48;
|
||||
private int mScrollInterval = 24;
|
||||
private int mPageMinHeight = 256;
|
||||
|
||||
@@ -62,8 +62,8 @@ public class GLES11Canvas implements GLCanvas {
|
||||
private static final int MSKEW_Y = 1;
|
||||
private static final int MSCALE_X = 0;
|
||||
private static final int MSCALE_Y = 5;
|
||||
private static float[] sCropRect = new float[4];
|
||||
private static GLId mGLId = new GLES11IdImpl();
|
||||
private static final float[] sCropRect = new float[4];
|
||||
private static final GLId mGLId = new GLES11IdImpl();
|
||||
|
||||
static {
|
||||
float[] temp = {
|
||||
@@ -98,12 +98,12 @@ public class GLES11Canvas implements GLCanvas {
|
||||
}
|
||||
}
|
||||
|
||||
private final float mMatrixValues[] = new float[16];
|
||||
private final float mTextureMatrixValues[] = new float[16];
|
||||
private final float[] mMatrixValues = new float[16];
|
||||
private final float[] mTextureMatrixValues = new float[16];
|
||||
// The results of mapPoints are stored in this buffer, and the order is
|
||||
// x1, y1, x2, y2.
|
||||
private final float mMapPointsBuffer[] = new float[4];
|
||||
private final float mTextureColor[] = new float[4];
|
||||
private final float[] mMapPointsBuffer = new float[4];
|
||||
private final float[] mTextureColor = new float[4];
|
||||
private final ArrayList<RawTexture> mTargetStack = new ArrayList<RawTexture>();
|
||||
private final ArrayList<ConfigState> mRestoreStack = new ArrayList<ConfigState>();
|
||||
private final RectF mDrawTextureSourceRect = new RectF();
|
||||
@@ -111,21 +111,21 @@ public class GLES11Canvas implements GLCanvas {
|
||||
private final float[] mTempMatrix = new float[32];
|
||||
private final IntList mUnboundTextures = new IntList();
|
||||
private final IntList mDeleteBuffers = new IntList();
|
||||
private final GL11 mGL;
|
||||
private final int mBoxCoords;
|
||||
private final GLState mGLState;
|
||||
private final boolean mBlendEnabled = true;
|
||||
private final int[] mFrameBuffer = new int[1];
|
||||
// Drawing statistics
|
||||
int mCountDrawLine;
|
||||
int mCountFillRect;
|
||||
int mCountDrawMesh;
|
||||
int mCountTextureRect;
|
||||
int mCountTextureOES;
|
||||
private GL11 mGL;
|
||||
private int mBoxCoords;
|
||||
private GLState mGLState;
|
||||
private float mAlpha;
|
||||
private ConfigState mRecycledRestoreAction;
|
||||
private int mScreenWidth;
|
||||
private int mScreenHeight;
|
||||
private boolean mBlendEnabled = true;
|
||||
private int mFrameBuffer[] = new int[1];
|
||||
private RawTexture mTargetTexture;
|
||||
|
||||
public GLES11Canvas(GL11 gl) {
|
||||
@@ -191,7 +191,7 @@ public class GLES11Canvas implements GLCanvas {
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isMatrixRotatedOrFlipped(float matrix[]) {
|
||||
private static boolean isMatrixRotatedOrFlipped(float[] matrix) {
|
||||
final float eps = 1e-5f;
|
||||
return Math.abs(matrix[MSKEW_X]) > eps
|
||||
|| Math.abs(matrix[MSKEW_Y]) > eps
|
||||
@@ -247,7 +247,7 @@ public class GLES11Canvas implements GLCanvas {
|
||||
gl.glMatrixMode(GL11.GL_MODELVIEW);
|
||||
gl.glLoadIdentity();
|
||||
|
||||
float matrix[] = mMatrixValues;
|
||||
float[] matrix = mMatrixValues;
|
||||
Matrix.setIdentityM(matrix, 0);
|
||||
// to match the graphic coordinate system in android, we flip it vertically.
|
||||
if (mTargetTexture == null) {
|
||||
@@ -408,7 +408,7 @@ public class GLES11Canvas implements GLCanvas {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void multiplyMatrix(float matrix[], int offset) {
|
||||
public void multiplyMatrix(float[] matrix, int offset) {
|
||||
float[] temp = mTempMatrix;
|
||||
Matrix.multiplyMM(temp, 0, mMatrixValues, 0, matrix, offset);
|
||||
System.arraycopy(temp, 0, mMatrixValues, 0, 16);
|
||||
@@ -467,7 +467,7 @@ public class GLES11Canvas implements GLCanvas {
|
||||
|
||||
// Transforms two points by the given matrix m. The result
|
||||
// {x1', y1', x2', y2'} are stored in mMapPointsBuffer and also returned.
|
||||
private float[] mapPoints(float m[], int x1, int y1, int x2, int y2) {
|
||||
private float[] mapPoints(float[] m, int x1, int y1, int x2, int y2) {
|
||||
float[] r = mMapPointsBuffer;
|
||||
|
||||
// Multiply m and (x1 y1 0 1) to produce (x3 y3 z3 w3). z3 is unused.
|
||||
@@ -506,7 +506,7 @@ public class GLES11Canvas implements GLCanvas {
|
||||
textureRect(x, y, width, height);
|
||||
} else {
|
||||
// draw the rect from bottom-left to top-right
|
||||
float points[] = mapPoints(
|
||||
float[] points = mapPoints(
|
||||
mMatrixValues, x, y + height, x + width, y);
|
||||
x = (int) (points[0] + 0.5f);
|
||||
y = (int) (points[1] + 0.5f);
|
||||
@@ -958,13 +958,12 @@ public class GLES11Canvas implements GLCanvas {
|
||||
private static class GLState {
|
||||
|
||||
private final GL11 mGL;
|
||||
|
||||
private final boolean mLineSmooth = false;
|
||||
private int mTexEnvMode = GL11.GL_REPLACE;
|
||||
private float mTextureAlpha = 1.0f;
|
||||
private int mTextureTarget = GL11.GL_TEXTURE_2D;
|
||||
private boolean mBlendEnabled = true;
|
||||
private float mLineWidth = 1.0f;
|
||||
private boolean mLineSmooth = false;
|
||||
|
||||
public GLState(GL11 gl) {
|
||||
mGL = gl;
|
||||
@@ -1059,7 +1058,7 @@ public class GLES11Canvas implements GLCanvas {
|
||||
|
||||
private static class ConfigState {
|
||||
float mAlpha;
|
||||
float mMatrix[] = new float[16];
|
||||
float[] mMatrix = new float[16];
|
||||
ConfigState mNextFree;
|
||||
|
||||
public void restore(GLES11Canvas canvas) {
|
||||
|
||||
@@ -30,9 +30,9 @@ class NinePatchChunk {
|
||||
|
||||
public Rect mPaddings = new Rect();
|
||||
|
||||
public int mDivX[];
|
||||
public int mDivY[];
|
||||
public int mColor[];
|
||||
public int[] mDivX;
|
||||
public int[] mDivY;
|
||||
public int[] mColor;
|
||||
|
||||
private static void readIntArray(int[] data, ByteBuffer buffer) {
|
||||
for (int i = 0, n = data.length; i < n; ++i) {
|
||||
|
||||
@@ -35,9 +35,9 @@ import java.nio.FloatBuffer;
|
||||
public class NinePatchTexture extends ResourceTexture {
|
||||
@SuppressWarnings("unused")
|
||||
private static final String TAG = "NinePatchTexture";
|
||||
private NinePatchChunk mChunk;
|
||||
private SmallCache<NinePatchInstance> mInstanceCache
|
||||
private final SmallCache<NinePatchInstance> mInstanceCache
|
||||
= new SmallCache<NinePatchInstance>();
|
||||
private NinePatchChunk mChunk;
|
||||
|
||||
public NinePatchTexture(Context context, int resId) {
|
||||
super(context, resId);
|
||||
@@ -120,8 +120,8 @@ public class NinePatchTexture extends ResourceTexture {
|
||||
private static class SmallCache<V> {
|
||||
private static final int CACHE_SIZE = 16;
|
||||
private static final int CACHE_SIZE_START_MOVE = CACHE_SIZE / 2;
|
||||
private int[] mKey = new int[CACHE_SIZE];
|
||||
private V[] mValue = (V[]) new Object[CACHE_SIZE];
|
||||
private final int[] mKey = new int[CACHE_SIZE];
|
||||
private final V[] mValue = (V[]) new Object[CACHE_SIZE];
|
||||
private int mCount; // number of items in this cache
|
||||
|
||||
// Puts a value into the cache. If the cache is full, also returns
|
||||
@@ -217,10 +217,10 @@ class NinePatchInstance {
|
||||
throw new RuntimeException("unsupported nine patch");
|
||||
}
|
||||
|
||||
float divX[] = new float[4];
|
||||
float divY[] = new float[4];
|
||||
float divU[] = new float[4];
|
||||
float divV[] = new float[4];
|
||||
float[] divX = new float[4];
|
||||
float[] divY = new float[4];
|
||||
float[] divU = new float[4];
|
||||
float[] divV = new float[4];
|
||||
|
||||
int nx = stretch(divX, divU, chunk.mDivX, tex.getWidth(), width);
|
||||
int ny = stretch(divY, divV, chunk.mDivY, tex.getHeight(), height);
|
||||
@@ -261,7 +261,7 @@ class NinePatchInstance {
|
||||
* @return the number of these dividers.
|
||||
*/
|
||||
private static int stretch(
|
||||
float x[], float u[], int div[], int source, int target) {
|
||||
float[] x, float[] u, int[] div, int source, int target) {
|
||||
int textureSize = MathUtils.nextPowerOf2(source);
|
||||
float textureBound = (float) source / textureSize;
|
||||
|
||||
@@ -313,7 +313,7 @@ class NinePatchInstance {
|
||||
return ByteBuffer.allocateDirect(size).order(ByteOrder.nativeOrder());
|
||||
}
|
||||
|
||||
private void prepareVertexData(float x[], float y[], float u[], float v[],
|
||||
private void prepareVertexData(float[] x, float[] y, float[] u, float[] v,
|
||||
int nx, int ny, int[] color) {
|
||||
/*
|
||||
* Given a 3x3 nine-patch image, the vertex order is defined as the
|
||||
@@ -335,8 +335,8 @@ class NinePatchInstance {
|
||||
* index: 04152637B6A5948C9DAEBF
|
||||
*/
|
||||
int pntCount = 0;
|
||||
float xy[] = new float[VERTEX_BUFFER_SIZE];
|
||||
float uv[] = new float[VERTEX_BUFFER_SIZE];
|
||||
float[] xy = new float[VERTEX_BUFFER_SIZE];
|
||||
float[] uv = new float[VERTEX_BUFFER_SIZE];
|
||||
for (int j = 0; j < ny; ++j) {
|
||||
for (int i = 0; i < nx; ++i) {
|
||||
int xIndex = (pntCount++) << 1;
|
||||
@@ -350,7 +350,7 @@ class NinePatchInstance {
|
||||
|
||||
int idxCount = 1;
|
||||
boolean isForward = false;
|
||||
byte index[] = new byte[INDEX_BUFFER_SIZE];
|
||||
byte[] index = new byte[INDEX_BUFFER_SIZE];
|
||||
for (int row = 0; row < ny - 1; row++) {
|
||||
--idxCount;
|
||||
isForward = !isForward;
|
||||
|
||||
@@ -54,21 +54,17 @@ public class GLProgressView extends GLView {
|
||||
}
|
||||
|
||||
private final GLPaint mGLPaint;
|
||||
|
||||
private final List<Animation> mAnimations;
|
||||
private float mCx;
|
||||
private float mCy;
|
||||
private float mRadiusX;
|
||||
private float mRadiusY;
|
||||
|
||||
private float mTrimStart = 0.0f;
|
||||
private float mTrimEnd = 0.0f;
|
||||
private float mTrimOffset = 0.0f;
|
||||
private float mTrimRotation = 0.0f;
|
||||
|
||||
private boolean mIndeterminate = false;
|
||||
|
||||
private List<Animation> mAnimations;
|
||||
|
||||
public GLProgressView() {
|
||||
mGLPaint = new GLPaint();
|
||||
mGLPaint.setColor(Color.WHITE);
|
||||
|
||||
@@ -104,17 +104,13 @@ final class DocumentsContractApi19 {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Writable normal files considered writable
|
||||
if (DocumentsContract.Document.MIME_TYPE_DIR.equals(type)
|
||||
&& (flags & DocumentsContract.Document.FLAG_DIR_SUPPORTS_CREATE) != 0) {
|
||||
// Directories that allow create considered writable
|
||||
return true;
|
||||
} else if (!TextUtils.isEmpty(type)
|
||||
&& (flags & DocumentsContract.Document.FLAG_SUPPORTS_WRITE) != 0) {
|
||||
// Writable normal files considered writable
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
} else return !TextUtils.isEmpty(type)
|
||||
&& (flags & DocumentsContract.Document.FLAG_SUPPORTS_WRITE) != 0;
|
||||
}
|
||||
|
||||
public static boolean delete(Context context, Uri self) {
|
||||
|
||||
@@ -25,7 +25,7 @@ import java.io.RandomAccessFile;
|
||||
|
||||
class RawRandomAccessFile implements UniRandomAccessFile {
|
||||
|
||||
private RandomAccessFile mFile;
|
||||
private final RandomAccessFile mFile;
|
||||
|
||||
RawRandomAccessFile(RandomAccessFile file) {
|
||||
mFile = file;
|
||||
|
||||
@@ -38,7 +38,7 @@ import java.io.OutputStream;
|
||||
// TODO need more test
|
||||
class UriOutputStream extends FileOutputStream {
|
||||
|
||||
private ParcelFileDescriptor mPfd;
|
||||
private final ParcelFileDescriptor mPfd;
|
||||
|
||||
private UriOutputStream(ParcelFileDescriptor pfd, FileDescriptor fd) {
|
||||
super(fd);
|
||||
|
||||
@@ -89,6 +89,13 @@ public class BatteryView extends AppCompatTextView {
|
||||
getHandler().post(mCharger);
|
||||
mIsChargerWorking = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void stopCharger() {
|
||||
if (mIsChargerWorking) {
|
||||
getHandler().removeCallbacks(mCharger);
|
||||
mIsChargerWorking = false;
|
||||
}
|
||||
} private final Runnable mCharger = new Runnable() {
|
||||
|
||||
private int level = 0;
|
||||
@@ -104,13 +111,6 @@ public class BatteryView extends AppCompatTextView {
|
||||
}
|
||||
};
|
||||
|
||||
private void stopCharger() {
|
||||
if (mIsChargerWorking) {
|
||||
getHandler().removeCallbacks(mCharger);
|
||||
mIsChargerWorking = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onAttachedToWindow() {
|
||||
super.onAttachedToWindow();
|
||||
|
||||
@@ -101,6 +101,13 @@ public class TextClock extends AppCompatTextView {
|
||||
|
||||
public CharSequence getFormat12Hour() {
|
||||
return mFormat12;
|
||||
}
|
||||
|
||||
public void setFormat12Hour(CharSequence format) {
|
||||
mFormat12 = format;
|
||||
|
||||
chooseFormat();
|
||||
onTimeChanged();
|
||||
} private final Runnable mTicker = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@@ -113,13 +120,6 @@ public class TextClock extends AppCompatTextView {
|
||||
}
|
||||
};
|
||||
|
||||
public void setFormat12Hour(CharSequence format) {
|
||||
mFormat12 = format;
|
||||
|
||||
chooseFormat();
|
||||
onTimeChanged();
|
||||
}
|
||||
|
||||
public CharSequence getFormat24Hour() {
|
||||
return mFormat24;
|
||||
}
|
||||
@@ -158,19 +158,7 @@ public class TextClock extends AppCompatTextView {
|
||||
|
||||
public CharSequence getFormat() {
|
||||
return mFormat;
|
||||
} private final ContentObserver mFormatChangeObserver = new ContentObserver(new Handler()) {
|
||||
@Override
|
||||
public void onChange(boolean selfChange) {
|
||||
chooseFormat();
|
||||
onTimeChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChange(boolean selfChange, Uri uri) {
|
||||
chooseFormat();
|
||||
onTimeChanged();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Selects either one of {@link #getFormat12Hour()} or {@link #getFormat24Hour()}
|
||||
@@ -215,7 +203,19 @@ public class TextClock extends AppCompatTextView {
|
||||
onTimeChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
} private final ContentObserver mFormatChangeObserver = new ContentObserver(new Handler()) {
|
||||
@Override
|
||||
public void onChange(boolean selfChange) {
|
||||
chooseFormat();
|
||||
onTimeChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChange(boolean selfChange, Uri uri) {
|
||||
chooseFormat();
|
||||
onTimeChanged();
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
protected void onDetachedFromWindow() {
|
||||
|
||||
@@ -27,6 +27,7 @@ import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Locale;
|
||||
|
||||
public final class FileUtils {
|
||||
@@ -154,7 +155,7 @@ public final class FileUtils {
|
||||
OutputStream os = null;
|
||||
try {
|
||||
os = new FileOutputStream(file);
|
||||
os.write(str.getBytes("utf-8"));
|
||||
os.write(str.getBytes(StandardCharsets.UTF_8));
|
||||
return true;
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
|
||||
@@ -20,7 +20,7 @@ import android.os.Process;
|
||||
|
||||
public class PriorityThread extends Thread {
|
||||
|
||||
private int mPriority;
|
||||
private final int mPriority;
|
||||
|
||||
public PriorityThread(Runnable runnable, int priority) {
|
||||
super(runnable);
|
||||
|
||||
@@ -28,9 +28,9 @@ public class SerialThreadExecutor implements Executor, Runnable {
|
||||
|
||||
private final Lock mThreadLock = new ReentrantLock();
|
||||
private final Object mWaitLock = new Object();
|
||||
private long mKeepAliveMillis;
|
||||
private Queue<Runnable> mWorkQueue;
|
||||
private ThreadFactory mThreadFactory;
|
||||
private final long mKeepAliveMillis;
|
||||
private final Queue<Runnable> mWorkQueue;
|
||||
private final ThreadFactory mThreadFactory;
|
||||
// The worker
|
||||
private Thread mThread;
|
||||
|
||||
|
||||
Reference in new issue
Block a user