Commit acb4e937 authored by fallenstardust's avatar fallenstardust

gradle 7.5

code arranged
parent 1f66dc4e
...@@ -10,7 +10,7 @@ buildscript { ...@@ -10,7 +10,7 @@ buildscript {
mavenCentral() mavenCentral()
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:7.3.1' classpath 'com.android.tools.build:gradle:7.4.2'
classpath 'com.android.tools.build:gradle-experimental:0.11.1' classpath 'com.android.tools.build:gradle-experimental:0.11.1'
//classpath 'me.tatarka:gradle-retrolambda:3.2.5' //classpath 'me.tatarka:gradle-retrolambda:3.2.5'
} }
......
...@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME ...@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-all.zip
...@@ -116,9 +116,9 @@ public class YGOGameOptions implements Parcelable { ...@@ -116,9 +116,9 @@ public class YGOGameOptions implements Parcelable {
StringBuilder builder = new StringBuilder("YGOGameOptions: "); StringBuilder builder = new StringBuilder("YGOGameOptions: ");
builder.append("serverAddr: ").append(mServerAddr == null ? "(unspecified)" : mServerAddr). builder.append("serverAddr: ").append(mServerAddr == null ? "(unspecified)" : mServerAddr).
append(", port: ").append(mPort). append(", port: ").append(mPort).
append(", roomName: ").append(mRoomName == null ? "(unspecified)" : mRoomName.toString()). append(", roomName: ").append(mRoomName == null ? "(unspecified)" : mRoomName).
append(", roomPassword: ").append(mRoomPasswd == null ? "(unspecified)" : mRoomPasswd.toString()). append(", roomPassword: ").append(mRoomPasswd == null ? "(unspecified)" : mRoomPasswd).
append(", userName: ").append(mUserName == null ? "(unspecified)" : mUserName.toString()). append(", userName: ").append(mUserName == null ? "(unspecified)" : mUserName).
append(", mode: ").append(mMode). append(", mode: ").append(mMode).
append(", isCompleteRequest").append(isCompleteOptions). append(", isCompleteRequest").append(isCompleteOptions).
append(", rule: ").append(mRule). append(", rule: ").append(mRule).
......
...@@ -173,7 +173,7 @@ public class YGOMobileActivity extends GameActivity implements ...@@ -173,7 +173,7 @@ public class YGOMobileActivity extends GameActivity implements
} }
if (options != null) { if (options != null) {
if (DEBUG) if (DEBUG)
Log.i(TAG, "receive:" + time + ":" + options.toString()); Log.i(TAG, "receive:" + time + ":" + options);
ByteBuffer buffer = options.toByteBuffer(); ByteBuffer buffer = options.toByteBuffer();
IrrlichtBridge.joinGame(buffer, buffer.position()); IrrlichtBridge.joinGame(buffer, buffer.position());
} else { } else {
......
...@@ -11,7 +11,7 @@ import android.net.wifi.WifiManager; ...@@ -11,7 +11,7 @@ import android.net.wifi.WifiManager;
*/ */
public final class NetworkController { public final class NetworkController {
private Context mContext; private final Context mContext;
private WifiManager mWM; private WifiManager mWM;
private ConnectivityManager mCM; private ConnectivityManager mCM;
...@@ -40,11 +40,8 @@ public final class NetworkController { ...@@ -40,11 +40,8 @@ public final class NetworkController {
// TODO Auto-generated method stub // TODO Auto-generated method stub
boolean isWifiEnabled = mWM.isWifiEnabled(); boolean isWifiEnabled = mWM.isWifiEnabled();
NetworkInfo ni = mCM.getActiveNetworkInfo(); NetworkInfo ni = mCM.getActiveNetworkInfo();
if (isWifiEnabled && null != ni && ni.isConnected() return isWifiEnabled && null != ni && ni.isConnected()
&& ni.getType() == ConnectivityManager.TYPE_WIFI) { && ni.getType() == ConnectivityManager.TYPE_WIFI;
return true;
}
return false;
} }
public int getIPAddress() { public int getIPAddress() {
......
...@@ -6,7 +6,7 @@ import android.view.View; ...@@ -6,7 +6,7 @@ import android.view.View;
public class FullScreenUtils { public class FullScreenUtils {
private boolean isFullscreen; private boolean isFullscreen;
private Activity activity; private final Activity activity;
private static final int windowsFlags = private static final int windowsFlags =
Build.VERSION.SDK_INT >=Build.VERSION_CODES.KITKAT ? ( Build.VERSION.SDK_INT >=Build.VERSION_CODES.KITKAT ? (
View.SYSTEM_UI_FLAG_LAYOUT_STABLE View.SYSTEM_UI_FLAG_LAYOUT_STABLE
......
...@@ -26,11 +26,11 @@ public class ComboBoxCompat extends PopupWindow { ...@@ -26,11 +26,11 @@ public class ComboBoxCompat extends PopupWindow {
/*change this will affect C++ code, be careful!*/ /*change this will affect C++ code, be careful!*/
public static final int COMPAT_GUI_MODE_CHECKBOXES_PANEL = 1; public static final int COMPAT_GUI_MODE_CHECKBOXES_PANEL = 1;
private Context mContext; private final Context mContext;
private WheelView mComboBoxContent; private final WheelView mComboBoxContent;
private Button mSubmitButton; private final Button mSubmitButton;
private Button mCancelButton; private final Button mCancelButton;
private ViewFlipper mFlipper; private final ViewFlipper mFlipper;
private ArrayWheelAdapter<String> mAdapter; private ArrayWheelAdapter<String> mAdapter;
public ComboBoxCompat(Context context) { public ComboBoxCompat(Context context) {
...@@ -38,9 +38,9 @@ public class ComboBoxCompat extends PopupWindow { ...@@ -38,9 +38,9 @@ public class ComboBoxCompat extends PopupWindow {
super(context); super(context);
mContext = context; mContext = context;
View menuView = LayoutInflater.from(mContext).inflate(R.layout.combobox_compat_layout, null); View menuView = LayoutInflater.from(mContext).inflate(R.layout.combobox_compat_layout, null);
mComboBoxContent = (WheelView) menuView.findViewById(R.id.combobox_content); mComboBoxContent = menuView.findViewById(R.id.combobox_content);
mSubmitButton = (Button) menuView.findViewById(R.id.submit); mSubmitButton = menuView.findViewById(R.id.submit);
mCancelButton = (Button) menuView.findViewById(R.id.cancel); mCancelButton = menuView.findViewById(R.id.cancel);
mFlipper = new ViewFlipper(context); mFlipper = new ViewFlipper(context);
mFlipper.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, mFlipper.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,
......
...@@ -24,17 +24,17 @@ import cn.garymb.ygomobile.lib.R; ...@@ -24,17 +24,17 @@ import cn.garymb.ygomobile.lib.R;
*/ */
public class EditWindowCompat extends PopupWindow { public class EditWindowCompat extends PopupWindow {
private Context mContext; private final Context mContext;
private ViewGroup mContentView; private final ViewGroup mContentView;
private EditText mEditText; private final EditText mEditText;
private InputMethodManager mIM; private final InputMethodManager mIM;
public EditWindowCompat(Context context) { public EditWindowCompat(Context context) {
super(context); super(context);
mContext = context; mContext = context;
mContentView = (ViewGroup) LayoutInflater.from(mContext).inflate( mContentView = (ViewGroup) LayoutInflater.from(mContext).inflate(
R.layout.text_input_compat_layout, null); R.layout.text_input_compat_layout, null);
mEditText = (EditText) mContentView.findViewById(R.id.global_input); mEditText = mContentView.findViewById(R.id.global_input);
mIM = (InputMethodManager) mContext.getSystemService(Context.INPUT_METHOD_SERVICE); mIM = (InputMethodManager) mContext.getSystemService(Context.INPUT_METHOD_SERVICE);
setContentView(mContentView); setContentView(mContentView);
} }
......
...@@ -41,7 +41,7 @@ public class OverlayOvalView extends OverlayView implements View.OnClickListener ...@@ -41,7 +41,7 @@ public class OverlayOvalView extends OverlayView implements View.OnClickListener
@Override @Override
protected void onInflateView() { protected void onInflateView() {
mInfo = (TextView) this.findViewById(R.id.textview_info); mInfo = this.findViewById(R.id.textview_info);
mInfo.setOnClickListener(this); mInfo.setOnClickListener(this);
} }
......
...@@ -22,9 +22,9 @@ public class OverlayRectView extends OverlayView implements OnCheckedChangeListe ...@@ -22,9 +22,9 @@ public class OverlayRectView extends OverlayView implements OnCheckedChangeListe
@Override @Override
protected void onInflateView() { protected void onInflateView() {
super.onInflateView(); super.onInflateView();
mIgnoreButton= (ToggleButton) findViewById(R.id.overlay_ignore); mIgnoreButton= findViewById(R.id.overlay_ignore);
mIgnoreButton.setOnCheckedChangeListener(this); mIgnoreButton.setOnCheckedChangeListener(this);
mReactButton = (ToggleButton) findViewById(R.id.overlay_react); mReactButton = findViewById(R.id.overlay_react);
mReactButton.setOnCheckedChangeListener(this); mReactButton.setOnCheckedChangeListener(this);
} }
......
...@@ -32,7 +32,7 @@ public abstract class OverlayView extends RelativeLayout { ...@@ -32,7 +32,7 @@ public abstract class OverlayView extends RelativeLayout {
public static final int MODE_REACT_CHAIN_OPTION = 3; public static final int MODE_REACT_CHAIN_OPTION = 3;
protected WindowManager.LayoutParams layoutParams; protected WindowManager.LayoutParams layoutParams;
private int layoutResId; private final int layoutResId;
private boolean mIsAdded = false; private boolean mIsAdded = false;
public OverlayView(Context context, int layoutResId) { public OverlayView(Context context, int layoutResId) {
...@@ -232,9 +232,7 @@ public abstract class OverlayView extends RelativeLayout { ...@@ -232,9 +232,7 @@ public abstract class OverlayView extends RelativeLayout {
if (x >= location[0]) { if (x >= location[0]) {
if (x <= location[0] + view.getWidth()) { if (x <= location[0] + view.getWidth()) {
if (y >= location[1]) { if (y >= location[1]) {
if (y <= location[1] + view.getHeight()) { return y <= location[1] + view.getHeight();
return true;
}
} }
} }
} }
......
...@@ -290,7 +290,7 @@ public abstract class AbstractWheelTextAdapter extends AbstractWheelAdapter { ...@@ -290,7 +290,7 @@ public abstract class AbstractWheelTextAdapter extends AbstractWheelAdapter {
if (textResource == NO_RESOURCE && view instanceof TextView) { if (textResource == NO_RESOURCE && view instanceof TextView) {
text = (TextView) view; text = (TextView) view;
} else if (textResource != NO_RESOURCE) { } else if (textResource != NO_RESOURCE) {
text = (TextView) view.findViewById(textResource); text = view.findViewById(textResource);
} }
} catch (ClassCastException e) { } catch (ClassCastException e) {
Log.e("AbstractWheelAdapter", Log.e("AbstractWheelAdapter",
......
...@@ -10,7 +10,7 @@ import android.content.Context; ...@@ -10,7 +10,7 @@ import android.content.Context;
public class AdapterWheel extends AbstractWheelTextAdapter { public class AdapterWheel extends AbstractWheelTextAdapter {
// Source adapter // Source adapter
private WheelAdapter adapter; private final WheelAdapter adapter;
/** /**
* Constructor * Constructor
......
...@@ -11,7 +11,7 @@ import android.content.Context; ...@@ -11,7 +11,7 @@ import android.content.Context;
public class ArrayWheelAdapter<T> extends AbstractWheelTextAdapter { public class ArrayWheelAdapter<T> extends AbstractWheelTextAdapter {
// items // items
private T items[]; private final T[] items;
/** /**
* Constructor * Constructor
...@@ -21,7 +21,7 @@ public class ArrayWheelAdapter<T> extends AbstractWheelTextAdapter { ...@@ -21,7 +21,7 @@ public class ArrayWheelAdapter<T> extends AbstractWheelTextAdapter {
* @param items * @param items
* the items * the items
*/ */
public ArrayWheelAdapter(Context context, T items[]) { public ArrayWheelAdapter(Context context, T[] items) {
super(context); super(context);
// setEmptyItemResource(TEXT_VIEW_ITEM_RESOURCE); // setEmptyItemResource(TEXT_VIEW_ITEM_RESOURCE);
......
...@@ -2,10 +2,10 @@ package cn.garymb.ygomobile.widget.wheelview; ...@@ -2,10 +2,10 @@ package cn.garymb.ygomobile.widget.wheelview;
public class ItemsRange { public class ItemsRange {
// First item number // First item number
private int first; private final int first;
// Items count // Items count
private int count; private final int count;
/** /**
* Default constructor. Creates an empty range * Default constructor. Creates an empty range
......
...@@ -6,7 +6,7 @@ public interface WheelAdapter { ...@@ -6,7 +6,7 @@ public interface WheelAdapter {
* *
* @return the count of wheel items * @return the count of wheel items
*/ */
public int getItemsCount(); int getItemsCount();
/** /**
* Gets a wheel item by index. * Gets a wheel item by index.
...@@ -15,7 +15,7 @@ public interface WheelAdapter { ...@@ -15,7 +15,7 @@ public interface WheelAdapter {
* the item index * the item index
* @return the wheel item text or null * @return the wheel item text or null
*/ */
public String getItem(int index); String getItem(int index);
/** /**
* Gets maximum item length. It is used to determine the wheel width. If -1 * Gets maximum item length. It is used to determine the wheel width. If -1
...@@ -23,5 +23,5 @@ public interface WheelAdapter { ...@@ -23,5 +23,5 @@ public interface WheelAdapter {
* *
* @return the maximum item length or -1 * @return the maximum item length or -1
*/ */
public int getMaximumLength(); int getMaximumLength();
} }
\ No newline at end of file
...@@ -17,7 +17,7 @@ public class WheelRecycle { ...@@ -17,7 +17,7 @@ public class WheelRecycle {
private List<View> emptyItems; private List<View> emptyItems;
// Wheel view // Wheel view
private WheelView wheel; private final WheelView wheel;
/** /**
* Constructor * Constructor
......
...@@ -48,13 +48,13 @@ public class WheelScroller { ...@@ -48,13 +48,13 @@ public class WheelScroller {
public static final int MIN_DELTA_FOR_SCROLLING = 1; public static final int MIN_DELTA_FOR_SCROLLING = 1;
// Listener // Listener
private ScrollingListener listener; private final ScrollingListener listener;
// Context // Context
private Context context; private final Context context;
// Scrolling // Scrolling
private GestureDetector gestureDetector; private final GestureDetector gestureDetector;
private Scroller scroller; private Scroller scroller;
private int lastScrollY; private int lastScrollY;
private float lastTouchedY; private float lastTouchedY;
...@@ -151,7 +151,7 @@ public class WheelScroller { ...@@ -151,7 +151,7 @@ public class WheelScroller {
} }
// gesture listener // gesture listener
private SimpleOnGestureListener gestureListener = new SimpleOnGestureListener() { private final SimpleOnGestureListener gestureListener = new SimpleOnGestureListener() {
public boolean onScroll(MotionEvent e1, MotionEvent e2, public boolean onScroll(MotionEvent e1, MotionEvent e2,
float distanceX, float distanceY) { float distanceX, float distanceY) {
// Do scrolling in onTouchEvent() since onScroll() are not call // Do scrolling in onTouchEvent() since onScroll() are not call
...@@ -196,7 +196,7 @@ public class WheelScroller { ...@@ -196,7 +196,7 @@ public class WheelScroller {
} }
// animation handler // animation handler
private Handler animationHandler = new Handler() { private final Handler animationHandler = new Handler() {
public void handleMessage(Message msg) { public void handleMessage(Message msg) {
scroller.computeScrollOffset(); scroller.computeScrollOffset();
int currY = scroller.getCurrY(); int currY = scroller.getCurrY();
......
...@@ -72,12 +72,12 @@ public class WheelView extends View { ...@@ -72,12 +72,12 @@ public class WheelView extends View {
private WheelViewAdapter viewAdapter; private WheelViewAdapter viewAdapter;
// Recycle // Recycle
private WheelRecycle recycle = new WheelRecycle(this); private final WheelRecycle recycle = new WheelRecycle(this);
// Listeners // Listeners
private List<OnWheelChangedListener> changingListeners = new LinkedList<OnWheelChangedListener>(); private final List<OnWheelChangedListener> changingListeners = new LinkedList<OnWheelChangedListener>();
private List<OnWheelScrollListener> scrollingListeners = new LinkedList<OnWheelScrollListener>(); private final List<OnWheelScrollListener> scrollingListeners = new LinkedList<OnWheelScrollListener>();
private List<OnWheelClickedListener> clickingListeners = new LinkedList<OnWheelClickedListener>(); private final List<OnWheelClickedListener> clickingListeners = new LinkedList<OnWheelClickedListener>();
/** /**
* Constructor * Constructor
...@@ -191,7 +191,7 @@ public class WheelView extends View { ...@@ -191,7 +191,7 @@ public class WheelView extends View {
} }
// Adapter listener // Adapter listener
private DataSetObserver dataObserver = new DataSetObserver() { private final DataSetObserver dataObserver = new DataSetObserver() {
@Override @Override
public void onChanged() { public void onChanged() {
invalidateWheel(false); invalidateWheel(false);
......
...@@ -13,7 +13,7 @@ public interface WheelViewAdapter { ...@@ -13,7 +13,7 @@ public interface WheelViewAdapter {
* *
* @return the count of wheel items * @return the count of wheel items
*/ */
public int getItemsCount(); int getItemsCount();
/** /**
* Get a View that displays the data at the specified position in the data * Get a View that displays the data at the specified position in the data
...@@ -27,7 +27,7 @@ public interface WheelViewAdapter { ...@@ -27,7 +27,7 @@ public interface WheelViewAdapter {
* the parent that this view will eventually be attached to * the parent that this view will eventually be attached to
* @return the wheel item View * @return the wheel item View
*/ */
public View getItem(int index, View convertView, ViewGroup parent); View getItem(int index, View convertView, ViewGroup parent);
/** /**
* Get a View that displays an empty wheel item placed before the first or * Get a View that displays an empty wheel item placed before the first or
...@@ -39,7 +39,7 @@ public interface WheelViewAdapter { ...@@ -39,7 +39,7 @@ public interface WheelViewAdapter {
* the parent that this view will eventually be attached to * the parent that this view will eventually be attached to
* @return the empty item View * @return the empty item View
*/ */
public View getEmptyItem(View convertView, ViewGroup parent); View getEmptyItem(View convertView, ViewGroup parent);
/** /**
* Register an observer that is called when changes happen to the data used * Register an observer that is called when changes happen to the data used
...@@ -48,7 +48,7 @@ public interface WheelViewAdapter { ...@@ -48,7 +48,7 @@ public interface WheelViewAdapter {
* @param observer * @param observer
* the observer to be registered * the observer to be registered
*/ */
public void registerDataSetObserver(DataSetObserver observer); void registerDataSetObserver(DataSetObserver observer);
/** /**
* Unregister an observer that has previously been registered * Unregister an observer that has previously been registered
......
...@@ -59,6 +59,8 @@ android { ...@@ -59,6 +59,8 @@ android {
packagingOptions { packagingOptions {
exclude 'META-INF/DEPENDENCIES' exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/LICENSE' exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.md'
exclude 'META-INF/LICENSE-notice.md'
exclude 'META-INF/rxjava.properties' exclude 'META-INF/rxjava.properties'
} }
androidResources { androidResources {
......
...@@ -2606,7 +2606,7 @@ public class ItemTouchHelperPlus extends RecyclerView.ItemDecoration ...@@ -2606,7 +2606,7 @@ public class ItemTouchHelperPlus extends RecyclerView.ItemDecoration
} }
} }
private Runnable enterLongPress = new Runnable() { private final Runnable enterLongPress = new Runnable() {
@Override @Override
public void run() { public void run() {
if (System.currentTimeMillis() - longPressTime >= mLongTime) { if (System.currentTimeMillis() - longPressTime >= mLongTime) {
......
...@@ -9,7 +9,7 @@ import androidx.core.view.GestureDetectorCompat; ...@@ -9,7 +9,7 @@ import androidx.core.view.GestureDetectorCompat;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
public class RecyclerViewItemListener extends RecyclerView.SimpleOnItemTouchListener { public class RecyclerViewItemListener extends RecyclerView.SimpleOnItemTouchListener {
private GestureDetectorCompat gestureDetector; private final GestureDetectorCompat gestureDetector;
public interface OnItemListener { public interface OnItemListener {
......
...@@ -36,7 +36,7 @@ import ocgcore.DataManager; ...@@ -36,7 +36,7 @@ import ocgcore.DataManager;
public class GameUriManager { public class GameUriManager {
private Activity activity; private final Activity activity;
private HomeFragment homeFragment; private HomeFragment homeFragment;
private String fname; private String fname;
......
...@@ -33,7 +33,7 @@ import cn.garymb.ygomobile.utils.glide.GlideCompat; ...@@ -33,7 +33,7 @@ import cn.garymb.ygomobile.utils.glide.GlideCompat;
public class YGOStarter { public class YGOStarter {
private static String TAG = "YGOStarter"; private static final String TAG = "YGOStarter";
private static Bitmap mLogo; private static Bitmap mLogo;
private static void setFullScreen(Activity activity, ActivityShowInfo activityShowInfo) { private static void setFullScreen(Activity activity, ActivityShowInfo activityShowInfo) {
...@@ -184,7 +184,7 @@ public class YGOStarter { ...@@ -184,7 +184,7 @@ public class YGOStarter {
Log.e(TAG, "跳转后" + System.currentTimeMillis()); Log.e(TAG, "跳转后" + System.currentTimeMillis());
} }
private static HashMap<Activity, ActivityShowInfo> Infos = new HashMap<>(); private static final HashMap<Activity, ActivityShowInfo> Infos = new HashMap<>();
private static class ActivityShowInfo { private static class ActivityShowInfo {
//根布局 //根布局
......
...@@ -18,12 +18,12 @@ import cn.garymb.ygomobile.lite.R; ...@@ -18,12 +18,12 @@ import cn.garymb.ygomobile.lite.R;
public class TextBaseAdapter extends BaseAdapter { public class TextBaseAdapter extends BaseAdapter {
private Context context; private final Context context;
private String[] data; private final String[] data;
private int leftPadding; private final int leftPadding;
private int rightPadding; private final int rightPadding;
private int topPadding; private final int topPadding;
private int bottomPadding; private final int bottomPadding;
private int textColor = 0; private int textColor = 0;
public TextBaseAdapter(Context context, String[] data, int textColor, int leftPadding, int topPadding, int rightPadding, int bottomPadding) { public TextBaseAdapter(Context context, String[] data, int textColor, int leftPadding, int topPadding, int rightPadding, int bottomPadding) {
......
...@@ -64,13 +64,9 @@ public abstract class BaseFragemnt extends Fragment { ...@@ -64,13 +64,9 @@ public abstract class BaseFragemnt extends Fragment {
isHorizontal = true; isHorizontal = true;
} }
} else { } else {
if (ScaleUtils.isScreenOriatationPortrait()) { // setContentView(R.layout.ending_activity);
// setContentView(R.layout.ending_activity); // setContentView(R.layout.ending_horizontal_activity);
isHorizontal = false; isHorizontal = !ScaleUtils.isScreenOriatationPortrait();
} else {
// setContentView(R.layout.ending_horizontal_activity);
isHorizontal = true;
}
} }
return super.onCreateView(inflater, container, savedInstanceState); return super.onCreateView(inflater, container, savedInstanceState);
} }
...@@ -92,13 +88,9 @@ public abstract class BaseFragemnt extends Fragment { ...@@ -92,13 +88,9 @@ public abstract class BaseFragemnt extends Fragment {
isHorizontal = true; isHorizontal = true;
} }
} else { } else {
if (ScaleUtils.isScreenOriatationPortrait()) { // setContentView(R.layout.ending_activity);
// setContentView(R.layout.ending_activity); // setContentView(R.layout.ending_horizontal_activity);
isHorizontal = false; isHorizontal = !ScaleUtils.isScreenOriatationPortrait();
} else {
// setContentView(R.layout.ending_horizontal_activity);
isHorizontal = true;
}
} }
} }
......
...@@ -2,7 +2,7 @@ package cn.garymb.ygomobile.bean.events; ...@@ -2,7 +2,7 @@ package cn.garymb.ygomobile.bean.events;
public class ExCardEvent { public class ExCardEvent {
public enum EventType { public enum EventType {
exCardPackageChange,exCardPrefChange; exCardPackageChange,exCardPrefChange
} }
private EventType eventType; private EventType eventType;
......
...@@ -24,9 +24,9 @@ public class ExCardActivity extends BaseActivity { ...@@ -24,9 +24,9 @@ public class ExCardActivity extends BaseActivity {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.activity_ex_card); setContentView(R.layout.activity_ex_card);
viewPager = (ViewPager) findViewById(R.id.viewPager); viewPager = findViewById(R.id.viewPager);
viewPager.setOffscreenPageLimit(2); viewPager.setOffscreenPageLimit(2);
tabLayout = (TabLayout) findViewById(R.id.packagetablayout); tabLayout = findViewById(R.id.packagetablayout);
createTabFragment(); createTabFragment();
} }
......
...@@ -76,7 +76,7 @@ public class ExCardListFragment extends Fragment { ...@@ -76,7 +76,7 @@ public class ExCardListFragment extends Fragment {
*/ */
enum DownloadState { enum DownloadState {
DOWNLOAD_ING, DOWNLOAD_ING,
NO_DOWNLOAD; NO_DOWNLOAD
} }
private DownloadState downloadState; private DownloadState downloadState;
......
...@@ -18,7 +18,7 @@ public class ExCardLogAdapter extends BaseExpandableListAdapter { ...@@ -18,7 +18,7 @@ public class ExCardLogAdapter extends BaseExpandableListAdapter {
this.context = context; this.context = context;
} }
private Context context; private final Context context;
private List<ExCardLogItem> expandalbeList = new ArrayList<>(); private List<ExCardLogItem> expandalbeList = new ArrayList<>();
...@@ -50,7 +50,7 @@ public class ExCardLogAdapter extends BaseExpandableListAdapter { ...@@ -50,7 +50,7 @@ public class ExCardLogAdapter extends BaseExpandableListAdapter {
convertView = layoutInflater.inflate(R.layout.item_log, null); convertView = layoutInflater.inflate(R.layout.item_log, null);
} }
TextView expandedListTextView = (TextView) convertView TextView expandedListTextView = convertView
.findViewById(R.id.expandedListItem); .findViewById(R.id.expandedListItem);
expandedListTextView.setText(expandalbeList.get(groupPosition).getLogs().get(childPosition)); expandedListTextView.setText(expandalbeList.get(groupPosition).getLogs().get(childPosition));
return convertView; return convertView;
...@@ -79,7 +79,7 @@ public class ExCardLogAdapter extends BaseExpandableListAdapter { ...@@ -79,7 +79,7 @@ public class ExCardLogAdapter extends BaseExpandableListAdapter {
getSystemService(Context.LAYOUT_INFLATER_SERVICE); getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = layoutInflater.inflate(R.layout.item_log_group, null); convertView = layoutInflater.inflate(R.layout.item_log_group, null);
} }
TextView listTitleTextView = (TextView) convertView TextView listTitleTextView = convertView
.findViewById(R.id.listTitle); .findViewById(R.id.listTitle);
listTitleTextView.setText(expandalbeList.get(groupPosition).getDateTime()); listTitleTextView.setText(expandalbeList.get(groupPosition).getDateTime());
......
...@@ -168,7 +168,7 @@ public class CardLoader implements ICardSearcher { ...@@ -168,7 +168,7 @@ public class CardLoader implements ICardSearcher {
private static final Comparator<Card> ASC = (o1, o2) -> { private static final Comparator<Card> ASC = (o1, o2) -> {
if (o1.getStar() == o2.getStar()) { if (o1.getStar() == o2.getStar()) {
if (o1.Attack == o2.Attack) { if (o1.Attack == o2.Attack) {
return (int) (o2.Code - o1.Code); return o2.Code - o1.Code;
} else { } else {
return o2.Attack - o1.Attack; return o2.Attack - o1.Attack;
} }
......
...@@ -326,9 +326,7 @@ public class CardSearchInfo implements ICardFilter{ ...@@ -326,9 +326,7 @@ public class CardSearchInfo implements ICardFilter{
} }
//TODO setcode //TODO setcode
if (setcode > 0) { if (setcode > 0) {
if (!card.isSetCode(setcode)) { return card.isSetCode(setcode);
return false;
}
} }
return true; return true;
} }
......
...@@ -13,6 +13,7 @@ import java.io.FileInputStream; ...@@ -13,6 +13,7 @@ import java.io.FileInputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import cn.garymb.ygomobile.Constants; import cn.garymb.ygomobile.Constants;
import cn.garymb.ygomobile.bean.Deck; import cn.garymb.ygomobile.bean.Deck;
...@@ -54,7 +55,7 @@ public class DeckLoader { ...@@ -54,7 +55,7 @@ public class DeckLoader {
InputStreamReader in = null; InputStreamReader in = null;
DeckItemType type = DeckItemType.Space; DeckItemType type = DeckItemType.Space;
try { try {
in = new InputStreamReader(inputStream, "utf-8"); in = new InputStreamReader(inputStream, StandardCharsets.UTF_8);
BufferedReader reader = new BufferedReader(in); BufferedReader reader = new BufferedReader(in);
String line = null; String line = null;
while ((line = reader.readLine()) != null) { while ((line = reader.readLine()) != null) {
...@@ -136,11 +137,7 @@ public class DeckLoader { ...@@ -136,11 +137,7 @@ public class DeckLoader {
tmp.put(id, cardLoader.readAllCardCodes().get(code)); tmp.put(id, cardLoader.readAllCardCodes().get(code));
isChanged = true; isChanged = true;
} }
if (type == DeckItemType.Pack) { deckInfo.addMainCards(id, tmp.get(id), type == DeckItemType.Pack);
deckInfo.addMainCards(id, tmp.get(id), true);
} else {
deckInfo.addMainCards(id, tmp.get(id), false);
}
} }
tmp = cardLoader.readCards(deck.getExtraList(), true); tmp = cardLoader.readCards(deck.getExtraList(), true);
for (Integer id : deck.getExtraList()) { for (Integer id : deck.getExtraList()) {
......
...@@ -97,7 +97,7 @@ public class BaseActivity extends AppCompatActivity { ...@@ -97,7 +97,7 @@ public class BaseActivity extends AppCompatActivity {
} }
protected void setupActionBar() { protected void setupActionBar() {
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); Toolbar toolbar = findViewById(R.id.toolbar);
if (toolbar != null) { if (toolbar != null) {
setSupportActionBar(toolbar); setSupportActionBar(toolbar);
} }
...@@ -125,7 +125,7 @@ public class BaseActivity extends AppCompatActivity { ...@@ -125,7 +125,7 @@ public class BaseActivity extends AppCompatActivity {
} }
protected <T extends View> T $(int id) { protected <T extends View> T $(int id) {
return (T) findViewById(id); return findViewById(id);
} }
public void setEnterAnimEnable(boolean disableEnterAnim) { public void setEnterAnimEnable(boolean disableEnterAnim) {
......
...@@ -13,7 +13,7 @@ import java.util.List; ...@@ -13,7 +13,7 @@ import java.util.List;
public abstract class BaseAdapterPlus<T> extends BaseAdapter implements SpinnerAdapter { public abstract class BaseAdapterPlus<T> extends BaseAdapter implements SpinnerAdapter {
protected Context context; protected Context context;
private LayoutInflater mLayoutInflater; private final LayoutInflater mLayoutInflater;
protected final List<T> mItems = new ArrayList<T>(); protected final List<T> mItems = new ArrayList<T>();
public BaseAdapterPlus(Context context) { public BaseAdapterPlus(Context context) {
...@@ -158,7 +158,7 @@ public abstract class BaseAdapterPlus<T> extends BaseAdapter implements SpinnerA ...@@ -158,7 +158,7 @@ public abstract class BaseAdapterPlus<T> extends BaseAdapter implements SpinnerA
} }
protected <T extends View> T findViewById(int id) { protected <T extends View> T findViewById(int id) {
return (T) view.findViewById(id); return view.findViewById(id);
} }
} }
} }
...@@ -16,7 +16,7 @@ import java.util.List; ...@@ -16,7 +16,7 @@ import java.util.List;
public abstract class BaseRecyclerAdapterPlus<T, V extends BaseViewHolder> extends BaseQuickAdapter<T,V> { public abstract class BaseRecyclerAdapterPlus<T, V extends BaseViewHolder> extends BaseQuickAdapter<T,V> {
protected Context context; protected Context context;
private LayoutInflater mLayoutInflater; private final LayoutInflater mLayoutInflater;
// protected final List<T> mItems = new ArrayList<T>(); // protected final List<T> mItems = new ArrayList<T>();
public BaseRecyclerAdapterPlus(Context context,int layout) { public BaseRecyclerAdapterPlus(Context context,int layout) {
...@@ -125,7 +125,7 @@ public abstract class BaseRecyclerAdapterPlus<T, V extends BaseViewHolder> exten ...@@ -125,7 +125,7 @@ public abstract class BaseRecyclerAdapterPlus<T, V extends BaseViewHolder> exten
} }
protected <T extends View> T $(int id) { protected <T extends View> T $(int id) {
return (T) itemView.findViewById(id); return itemView.findViewById(id);
} }
} }
} }
...@@ -25,11 +25,11 @@ import ocgcore.enums.CardType; ...@@ -25,11 +25,11 @@ import ocgcore.enums.CardType;
import ocgcore.enums.LimitType; import ocgcore.enums.LimitType;
public class CardListAdapter extends BaseRecyclerAdapterPlus<Card, BaseViewHolder> implements CardListProvider { public class CardListAdapter extends BaseRecyclerAdapterPlus<Card, BaseViewHolder> implements CardListProvider {
private StringManager mStringManager; private final StringManager mStringManager;
private ImageTop mImageTop; private ImageTop mImageTop;
private LimitList mLimitList; private LimitList mLimitList;
private boolean mItemBg; private boolean mItemBg;
private ImageLoader imageLoader; private final ImageLoader imageLoader;
private boolean mEnableSwipe = false; private boolean mEnableSwipe = false;
public CardListAdapter(Context context, ImageLoader imageLoader) { public CardListAdapter(Context context, ImageLoader imageLoader) {
......
...@@ -28,26 +28,23 @@ import ocgcore.DataManager; ...@@ -28,26 +28,23 @@ import ocgcore.DataManager;
import ocgcore.data.LimitList; import ocgcore.data.LimitList;
public class DeckListAdapter<T extends TextSelect> extends BaseQuickAdapter<T, DeckViewHolder> { public class DeckListAdapter<T extends TextSelect> extends BaseQuickAdapter<T, DeckViewHolder> {
private ImageLoader imageLoader; private final ImageLoader imageLoader;
private Context mContext; private final Context mContext;
private LimitList mLimitList; private LimitList mLimitList;
private CardLoader mCardLoader; private final CardLoader mCardLoader;
private DeckLoader mDeckLoader; private final DeckLoader mDeckLoader;
private DeckInfo deckInfo; private DeckInfo deckInfo;
private DeckFile deckFile; private DeckFile deckFile;
private OnItemSelectListener onItemSelectListener; private OnItemSelectListener onItemSelectListener;
private int selectPosition; private int selectPosition;
private boolean isSelect; private final boolean isSelect;
private boolean isManySelect; private boolean isManySelect;
private List<T> selectList; private final List<T> selectList;
public DeckListAdapter(Context context, List<T> data, int select) { public DeckListAdapter(Context context, List<T> data, int select) {
super(R.layout.item_deck_list_swipe, data); super(R.layout.item_deck_list_swipe, data);
this.selectPosition = select; this.selectPosition = select;
if (select >= 0) isSelect = select >= 0;
isSelect = true;
else
isSelect = false;
isManySelect = false; isManySelect = false;
selectList = new ArrayList<>(); selectList = new ArrayList<>();
setOnItemClickListener(new OnItemClickListener() { setOnItemClickListener(new OnItemClickListener() {
...@@ -79,7 +76,7 @@ public class DeckListAdapter<T extends TextSelect> extends BaseQuickAdapter<T, D ...@@ -79,7 +76,7 @@ public class DeckListAdapter<T extends TextSelect> extends BaseQuickAdapter<T, D
this.deckFile = (DeckFile) item; this.deckFile = (DeckFile) item;
holder.deckName.setText(item.getName()); holder.deckName.setText(item.getName());
//预读卡组信息 //预读卡组信息
this.deckInfo = mDeckLoader.readDeck(mCardLoader, deckFile.getPathFile(), mLimitList); this.deckInfo = DeckLoader.readDeck(mCardLoader, deckFile.getPathFile(), mLimitList);
//加载卡组第一张卡的图 //加载卡组第一张卡的图
holder.cardImage.setVisibility(View.VISIBLE); holder.cardImage.setVisibility(View.VISIBLE);
imageLoader.bindImage(holder.cardImage, deckFile.getFirstCode(), ImageLoader.Type.middle); imageLoader.bindImage(holder.cardImage, deckFile.getFirstCode(), ImageLoader.Type.middle);
......
...@@ -15,7 +15,7 @@ public class SimpleListAdapter extends BaseAdapterPlus<String> { ...@@ -15,7 +15,7 @@ public class SimpleListAdapter extends BaseAdapterPlus<String> {
@Override @Override
protected View createView(int position, ViewGroup parent) { protected View createView(int position, ViewGroup parent) {
View view = inflate(android.R.layout.simple_list_item_1, null); View view = inflate(android.R.layout.simple_list_item_1, null);
TextView textView = (TextView) view.findViewById(android.R.id.text1); TextView textView = view.findViewById(android.R.id.text1);
textView.setTextColor(context.getResources().getColor(R.color.item_title)); textView.setTextColor(context.getResources().getColor(R.color.item_title));
view.setTag(textView); view.setTag(textView);
return view; return view;
......
...@@ -34,7 +34,7 @@ public class SimpleSpinnerAdapter extends BaseAdapterPlus<SimpleSpinnerItem> { ...@@ -34,7 +34,7 @@ public class SimpleSpinnerAdapter extends BaseAdapterPlus<SimpleSpinnerItem> {
@Override @Override
protected View createView(int position, ViewGroup parent) { protected View createView(int position, ViewGroup parent) {
View view = inflate(android.R.layout.simple_list_item_1, null); View view = inflate(android.R.layout.simple_list_item_1, null);
TextView textView = (TextView) view.findViewById(android.R.id.text1); TextView textView = view.findViewById(android.R.id.text1);
view.setTag(textView); view.setTag(textView);
textView.setMaxLines(maxLines); textView.setMaxLines(maxLines);
if (singleLine) { if (singleLine) {
......
...@@ -19,17 +19,14 @@ public class TextSelectAdapter<T extends TextSelect> extends BaseQuickAdapter<T, ...@@ -19,17 +19,14 @@ public class TextSelectAdapter<T extends TextSelect> extends BaseQuickAdapter<T,
private OnItemSelectListener onItemSelectListener; private OnItemSelectListener onItemSelectListener;
private int selectPosition; private int selectPosition;
private boolean isSelect; private final boolean isSelect;
private boolean isManySelect; private boolean isManySelect;
private List<T> selectList; private final List<T> selectList;
public TextSelectAdapter(List<T> data, int select) { public TextSelectAdapter(List<T> data, int select) {
super(R.layout.text_select_item, data); super(R.layout.text_select_item, data);
this.selectPosition = select; this.selectPosition = select;
if (select >= 0) isSelect = select >= 0;
isSelect = true;
else
isSelect = false;
isManySelect = false; isManySelect = false;
selectList = new ArrayList<>(); selectList = new ArrayList<>();
setOnItemClickListener(new OnItemClickListener() { setOnItemClickListener(new OnItemClickListener() {
......
...@@ -340,7 +340,7 @@ public class CardDetail extends BaseAdapterPlus.BaseViewHolder { ...@@ -340,7 +340,7 @@ public class CardDetail extends BaseAdapterPlus.BaseViewHolder {
if (cardInfo.isType(CardType.Link)) { if (cardInfo.isType(CardType.Link)) {
level.setVisibility(View.GONE); level.setVisibility(View.GONE);
linkArrow.setVisibility(View.VISIBLE); linkArrow.setVisibility(View.VISIBLE);
cardDef.setText((cardInfo.getStar() < 0 ? "?" : "LINK-" + String.valueOf(cardInfo.getStar()))); cardDef.setText((cardInfo.getStar() < 0 ? "?" : "LINK-" + cardInfo.getStar()));
BaseActivity.showLinkArrows(cardInfo, view); BaseActivity.showLinkArrows(cardInfo, view);
} else { } else {
level.setVisibility(View.VISIBLE); level.setVisibility(View.VISIBLE);
...@@ -382,9 +382,9 @@ public class CardDetail extends BaseAdapterPlus.BaseViewHolder { ...@@ -382,9 +382,9 @@ public class CardDetail extends BaseAdapterPlus.BaseViewHolder {
photoView.enable(); photoView.enable();
photoView.setOnClickListener(View -> { photoView.setOnClickListener(View -> {
if (ll_btn.getVisibility() == View.VISIBLE) { if (ll_btn.getVisibility() == android.view.View.VISIBLE) {
ll_btn.startAnimation(AnimationUtils.loadAnimation(context, R.anim.push_out)); ll_btn.startAnimation(AnimationUtils.loadAnimation(context, R.anim.push_out));
ll_btn.setVisibility(View.GONE); ll_btn.setVisibility(android.view.View.GONE);
} else { } else {
dialog.dis(); dialog.dis();
} }
......
...@@ -18,20 +18,21 @@ import ocgcore.data.Card; ...@@ -18,20 +18,21 @@ import ocgcore.data.Card;
import ocgcore.enums.CardType; import ocgcore.enums.CardType;
public class CardDetailRandom { public class CardDetailRandom {
private View viewCardDetail; private final View viewCardDetail;
private ImageView cardImage; private final ImageView cardImage;
private TextView name; private final TextView name;
private TextView desc; private final TextView desc;
private TextView level; private final TextView level;
private TextView type; private final TextView type;
private TextView race; private final TextView race;
private TextView cardAtk; private final TextView cardAtk;
private TextView cardDef; private final TextView cardDef;
private TextView attrView; private final TextView attrView;
private View monsterlayout; private final View monsterlayout;
private View atkdefView, textdefView; private final View atkdefView;
private StringManager mStringManager; private final View textdefView;
private Context mContext; private final StringManager mStringManager;
private final Context mContext;
private static CardDetailRandom sCardDetailRandom = null; private static CardDetailRandom sCardDetailRandom = null;
...@@ -74,7 +75,7 @@ public class CardDetailRandom { ...@@ -74,7 +75,7 @@ public class CardDetailRandom {
if (cardInfo.isType(CardType.Link)) { if (cardInfo.isType(CardType.Link)) {
level.setVisibility(View.GONE); level.setVisibility(View.GONE);
textdefView.setVisibility(View.INVISIBLE); textdefView.setVisibility(View.INVISIBLE);
cardDef.setText((cardInfo.getStar() < 0 ? "?" : "LINK-" + String.valueOf(cardInfo.getStar()))); cardDef.setText((cardInfo.getStar() < 0 ? "?" : "LINK-" + cardInfo.getStar()));
} else { } else {
level.setVisibility(View.VISIBLE); level.setVisibility(View.VISIBLE);
textdefView.setVisibility(View.VISIBLE); textdefView.setVisibility(View.VISIBLE);
......
...@@ -73,7 +73,7 @@ public class CardSearcher implements View.OnClickListener { ...@@ -73,7 +73,7 @@ public class CardSearcher implements View.OnClickListener {
private final Button myFavButton; private final Button myFavButton;
private CallBack mCallBack; private CallBack mCallBack;
private boolean mShowFavorite; private boolean mShowFavorite;
private ICardSearcher mCardLoader; private final ICardSearcher mCardLoader;
public interface CallBack { public interface CallBack {
void onSearchStart(); void onSearchStart();
......
...@@ -110,7 +110,7 @@ import ocgcore.data.LimitList; ...@@ -110,7 +110,7 @@ import ocgcore.data.LimitList;
import ocgcore.enums.LimitType; import ocgcore.enums.LimitType;
public class DeckManagerFragment extends BaseFragemnt implements RecyclerViewItemListener.OnItemListener, OnItemDragListener, YGODialogUtil.OnDeckMenuListener, CardLoader.CallBack, CardSearcher.CallBack { public class DeckManagerFragment extends BaseFragemnt implements RecyclerViewItemListener.OnItemListener, OnItemDragListener, YGODialogUtil.OnDeckMenuListener, CardLoader.CallBack, CardSearcher.CallBack {
private static String TAG = "DeckManagerFragment"; private static final String TAG = "DeckManagerFragment";
protected DrawerLayout mDrawerLayout; protected DrawerLayout mDrawerLayout;
protected RecyclerView mListView; protected RecyclerView mListView;
protected CardSearcher mCardSelector; protected CardSearcher mCardSelector;
...@@ -382,7 +382,7 @@ public class DeckManagerFragment extends BaseFragemnt implements RecyclerViewIte ...@@ -382,7 +382,7 @@ public class DeckManagerFragment extends BaseFragemnt implements RecyclerViewIte
} }
}).done((rs) -> { }).done((rs) -> {
dlg.dismiss(); dlg.dismiss();
setCurDeck(rs, file.getParent().equals(mSettings.getPackDeckDir()) ? true : false); setCurDeck(rs, file.getParent().equals(mSettings.getPackDeckDir()));
}); });
} }
...@@ -420,7 +420,7 @@ public class DeckManagerFragment extends BaseFragemnt implements RecyclerViewIte ...@@ -420,7 +420,7 @@ public class DeckManagerFragment extends BaseFragemnt implements RecyclerViewIte
initLimitListSpinners(mLimitSpinner, mCardLoader.getLimitList()); initLimitListSpinners(mLimitSpinner, mCardLoader.getLimitList());
//设置当前卡组 //设置当前卡组
if (rs.source != null) { if (rs.source != null) {
setCurDeck(rs, rs.source.getParent().equals(mSettings.getPackDeckDir()) ? true : false); setCurDeck(rs, rs.source.getParent().equals(mSettings.getPackDeckDir()));
} else { } else {
setCurDeck(rs, false); setCurDeck(rs, false);
} }
......
...@@ -34,9 +34,9 @@ import ocgcore.enums.LimitType; ...@@ -34,9 +34,9 @@ import ocgcore.enums.LimitType;
public class DeckAdapater extends RecyclerView.Adapter<DeckViewHolder> implements CardListProvider { public class DeckAdapater extends RecyclerView.Adapter<DeckViewHolder> implements CardListProvider {
private final List<DeckItem> mItems = new ArrayList<>(); private final List<DeckItem> mItems = new ArrayList<>();
private SparseArray<Integer> mCount = new SparseArray<>(); private final SparseArray<Integer> mCount = new SparseArray<>();
private Context context; private final Context context;
private LayoutInflater mLayoutInflater; private final LayoutInflater mLayoutInflater;
private ImageTop mImageTop; private ImageTop mImageTop;
private int mMainCount; private int mMainCount;
...@@ -57,14 +57,14 @@ public class DeckAdapater extends RecyclerView.Adapter<DeckViewHolder> implement ...@@ -57,14 +57,14 @@ public class DeckAdapater extends RecyclerView.Adapter<DeckViewHolder> implement
private int mFullWidth; private int mFullWidth;
private int mWidth; private int mWidth;
private int mHeight; private int mHeight;
private int Padding = 1; private final int Padding = 1;
private RecyclerView recyclerView; private final RecyclerView recyclerView;
private Random mRandom; private final Random mRandom;
private DeckViewHolder mHeadHolder; private DeckViewHolder mHeadHolder;
private DeckItem mRemoveItem; private DeckItem mRemoveItem;
private int mRemoveIndex; private int mRemoveIndex;
private LimitList mLimitList; private LimitList mLimitList;
private ImageLoader imageLoader; private final ImageLoader imageLoader;
private boolean showHead = false; private boolean showHead = false;
private String mDeckMd5; private String mDeckMd5;
private DeckInfo mDeckInfo; private DeckInfo mDeckInfo;
......
...@@ -6,7 +6,7 @@ import cn.garymb.ygomobile.Constants; ...@@ -6,7 +6,7 @@ import cn.garymb.ygomobile.Constants;
import ocgcore.data.Card; import ocgcore.data.Card;
class DeckDrager { class DeckDrager {
private DeckAdapater deckAdapater; private final DeckAdapater deckAdapater;
public DeckDrager(DeckAdapater deckAdapater) { public DeckDrager(DeckAdapater deckAdapater) {
this.deckAdapater = deckAdapater; this.deckAdapater = deckAdapater;
......
...@@ -16,10 +16,10 @@ import cn.garymb.ygomobile.Constants; ...@@ -16,10 +16,10 @@ import cn.garymb.ygomobile.Constants;
import cn.garymb.ygomobile.lite.R; import cn.garymb.ygomobile.lite.R;
public class DeckItemTouchHelper extends ItemTouchHelperPlus.Callback2 { public class DeckItemTouchHelper extends ItemTouchHelperPlus.Callback2 {
private DeckDrager mDeckDrager; private final DeckDrager mDeckDrager;
private static final String TAG = "drag"; private static final String TAG = "drag";
private static final boolean DEBUG = false; private static final boolean DEBUG = false;
private DeckAdapater deckAdapater; private final DeckAdapater deckAdapater;
public DeckItemTouchHelper(DeckAdapater deckAdapater) { public DeckItemTouchHelper(DeckAdapater deckAdapater) {
this.mDeckDrager = new DeckDrager(deckAdapater); this.mDeckDrager = new DeckDrager(deckAdapater);
...@@ -32,7 +32,7 @@ public class DeckItemTouchHelper extends ItemTouchHelperPlus.Callback2 { ...@@ -32,7 +32,7 @@ public class DeckItemTouchHelper extends ItemTouchHelperPlus.Callback2 {
// setDragSize(); // setDragSize();
} }
private int Min_Pos = -10; private final int Min_Pos = -10;
@Override @Override
public boolean canDropOver(RecyclerView recyclerView, RecyclerView.ViewHolder current, public boolean canDropOver(RecyclerView recyclerView, RecyclerView.ViewHolder current,
......
...@@ -4,6 +4,7 @@ import java.io.File; ...@@ -4,6 +4,7 @@ import java.io.File;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStreamWriter; import java.io.OutputStreamWriter;
import java.nio.charset.StandardCharsets;
import java.util.List; import java.util.List;
import cn.garymb.ygomobile.Constants; import cn.garymb.ygomobile.Constants;
...@@ -120,7 +121,7 @@ class DeckItemUtils { ...@@ -120,7 +121,7 @@ class DeckItemUtils {
} }
file.createNewFile(); file.createNewFile();
outputStream = new FileOutputStream(file); outputStream = new FileOutputStream(file);
writer = new OutputStreamWriter(outputStream, "utf-8"); writer = new OutputStreamWriter(outputStream, StandardCharsets.UTF_8);
writer.write("#created by ygomobile".toCharArray()); writer.write("#created by ygomobile".toCharArray());
writer.write("\n#main".toCharArray()); writer.write("\n#main".toCharArray());
for (int i = DeckItem.MainStart; i < DeckItem.MainStart + Constants.DECK_MAIN_MAX; i++) { for (int i = DeckItem.MainStart; i < DeckItem.MainStart + Constants.DECK_MAIN_MAX; i++) {
...@@ -242,9 +243,6 @@ class DeckItemUtils { ...@@ -242,9 +243,6 @@ class DeckItemUtils {
} }
public static boolean isLabel(int position) { public static boolean isLabel(int position) {
if (position == DeckItem.MainLabel || position == DeckItem.ExtraLabel || position == DeckItem.SideLabel) { return position == DeckItem.MainLabel || position == DeckItem.ExtraLabel || position == DeckItem.SideLabel;
return true;
}
return false;
} }
} }
...@@ -7,7 +7,7 @@ import androidx.recyclerview.widget.GridLayoutManager; ...@@ -7,7 +7,7 @@ import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
public class DeckLayoutManager extends GridLayoutManager { public class DeckLayoutManager extends GridLayoutManager {
private Context context; private final Context context;
public DeckLayoutManager(Context context, final int span) { public DeckLayoutManager(Context context, final int span) {
super(context, span); super(context, span);
......
...@@ -10,6 +10,7 @@ import java.io.IOException; ...@@ -10,6 +10,7 @@ import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;
import java.io.OutputStreamWriter; import java.io.OutputStreamWriter;
import java.io.PrintWriter; import java.io.PrintWriter;
import java.nio.charset.StandardCharsets;
import cn.garymb.ygomobile.AppsSettings; import cn.garymb.ygomobile.AppsSettings;
import cn.garymb.ygomobile.bean.Deck; import cn.garymb.ygomobile.bean.Deck;
...@@ -37,7 +38,7 @@ public class DeckUtils { ...@@ -37,7 +38,7 @@ public class DeckUtils {
private static boolean save(DeckInfo deck, OutputStream outputStream) { private static boolean save(DeckInfo deck, OutputStream outputStream) {
OutputStreamWriter writer = null; OutputStreamWriter writer = null;
try { try {
writer = new OutputStreamWriter(outputStream, "utf-8"); writer = new OutputStreamWriter(outputStream, StandardCharsets.UTF_8);
writer.write("#created by ygomobile".toCharArray()); writer.write("#created by ygomobile".toCharArray());
writer.write("\n#main".toCharArray()); writer.write("\n#main".toCharArray());
for (Card card : deck.getMainCards()) { for (Card card : deck.getMainCards()) {
...@@ -65,7 +66,7 @@ public class DeckUtils { ...@@ -65,7 +66,7 @@ public class DeckUtils {
private static boolean save(Deck deck, OutputStream outputStream) { private static boolean save(Deck deck, OutputStream outputStream) {
OutputStreamWriter writer = null; OutputStreamWriter writer = null;
try { try {
writer = new OutputStreamWriter(outputStream, "utf-8"); writer = new OutputStreamWriter(outputStream, StandardCharsets.UTF_8);
writer.write("#created by ygomobile".toCharArray()); writer.write("#created by ygomobile".toCharArray());
writer.write("\n#main".toCharArray()); writer.write("\n#main".toCharArray());
for (long id : deck.getMainlist()) { for (long id : deck.getMainlist()) {
......
...@@ -112,7 +112,7 @@ class DeckViewHolder extends RecyclerView.ViewHolder { ...@@ -112,7 +112,7 @@ class DeckViewHolder extends RecyclerView.ViewHolder {
} }
protected <T extends View> T $(int id) { protected <T extends View> T $(int id) {
return (T) view.findViewById(id); return view.findViewById(id);
} }
public void setHeadVisibility(int visibility) { public void setHeadVisibility(int visibility) {
......
...@@ -21,7 +21,7 @@ public class LabelInfo { ...@@ -21,7 +21,7 @@ public class LabelInfo {
private int mSideMonsterCount = 0; private int mSideMonsterCount = 0;
private int mSideSpellCount = 0; private int mSideSpellCount = 0;
private int mSideTrapCount = 0; private int mSideTrapCount = 0;
private Context mContext; private final Context mContext;
public LabelInfo(Context context) { public LabelInfo(Context context) {
mContext = context; mContext = context;
......
...@@ -147,9 +147,7 @@ class FileAdapter extends BaseAdapterPlus<File> { ...@@ -147,9 +147,7 @@ class FileAdapter extends BaseAdapterPlus<File> {
} }
} }
if (!mShowHide) { if (!mShowHide) {
if (pathname.getName().startsWith(".")) { return !pathname.getName().startsWith(".");
return false;
}
} }
return true; return true;
}); });
......
...@@ -145,9 +145,9 @@ public abstract class HomeActivity extends BaseActivity implements BottomNavigat ...@@ -145,9 +145,9 @@ public abstract class HomeActivity extends BaseActivity implements BottomNavigat
} }
private void initBottomNavigationBar() { private void initBottomNavigationBar() {
frameLayout = (FrameLayout) findViewById(R.id.fragment_content); frameLayout = findViewById(R.id.fragment_content);
// 获取页面上的底部导航栏控件 // 获取页面上的底部导航栏控件
bottomNavigationBar = (BottomNavigationBar) findViewById(R.id.bottom_navigation_bar); bottomNavigationBar = findViewById(R.id.bottom_navigation_bar);
bottomNavigationBar bottomNavigationBar
.addItem(new BottomNavigationItem(R.drawable.home, R.string.mc_home)) .addItem(new BottomNavigationItem(R.drawable.home, R.string.mc_home))
.addItem(new BottomNavigationItem(R.drawable.searcher, R.string.search)) .addItem(new BottomNavigationItem(R.drawable.searcher, R.string.search))
......
...@@ -194,8 +194,8 @@ public class HomeFragment extends BaseFragemnt implements OnDuelAssistantListene ...@@ -194,8 +194,8 @@ public class HomeFragment extends BaseFragemnt implements OnDuelAssistantListene
ll_back = view.findViewById(R.id.return_to_duel); ll_back = view.findViewById(R.id.return_to_duel);
ll_back.setOnClickListener(this); ll_back.setOnClickListener(this);
tv = (ShimmerTextView) view.findViewById(R.id.shimmer_tv); tv = view.findViewById(R.id.shimmer_tv);
tv2 = (ShimmerTextView) view.findViewById(R.id.shimmer_tv2); tv2 = view.findViewById(R.id.shimmer_tv2);
toggleAnimation(tv); toggleAnimation(tv);
toggleAnimation(tv2); toggleAnimation(tv2);
......
...@@ -34,11 +34,11 @@ import ocgcore.enums.CardType; ...@@ -34,11 +34,11 @@ import ocgcore.enums.CardType;
*/ */
public class ImageUpdater implements DialogInterface.OnCancelListener { public class ImageUpdater implements DialogInterface.OnCancelListener {
private BaseActivity mContext; private final BaseActivity mContext;
private final static int SubThreads = 4; private final static int SubThreads = 4;
private int mDownloading = 0; private int mDownloading = 0;
private final List<Item> mCardStatus = new ArrayList<>(); private final List<Item> mCardStatus = new ArrayList<>();
private ExecutorService mExecutorService = Executors.newFixedThreadPool(SubThreads); private final ExecutorService mExecutorService = Executors.newFixedThreadPool(SubThreads);
private DialogPlus mDialog; private DialogPlus mDialog;
private int mIndex; private int mIndex;
private int mCount; private int mCount;
......
...@@ -73,11 +73,7 @@ public class MainActivity extends HomeActivity implements BottomNavigationBar.On ...@@ -73,11 +73,7 @@ public class MainActivity extends HomeActivity implements BottomNavigationBar.On
checkResourceDownload((error, isNew) -> { checkResourceDownload((error, isNew) -> {
//加载收藏夹 //加载收藏夹
CardFavorites.get().load(); CardFavorites.get().load();
if (error < 0) { enableStart = error >= 0;
enableStart = false;
} else {
enableStart = true;
}
if (isNew) { if (isNew) {
if (!getGameUriManager().doIntent(getIntent())) { if (!getGameUriManager().doIntent(getIntent())) {
final DialogPlus dialog = new DialogPlus(this); final DialogPlus dialog = new DialogPlus(this);
...@@ -179,11 +175,7 @@ public class MainActivity extends HomeActivity implements BottomNavigationBar.On ...@@ -179,11 +175,7 @@ public class MainActivity extends HomeActivity implements BottomNavigationBar.On
super.onNewIntent(intent); super.onNewIntent(intent);
if (ACTION_RELOAD.equals(intent.getAction())) { if (ACTION_RELOAD.equals(intent.getAction())) {
checkResourceDownload((error, isNew) -> { checkResourceDownload((error, isNew) -> {
if (error < 0) { enableStart = error >= 0;
enableStart = false;
} else {
enableStart = true;
}
getGameUriManager().doIntent(getIntent()); getGameUriManager().doIntent(getIntent());
}); });
} else { } else {
......
...@@ -48,8 +48,8 @@ public class ResCheckTask extends AsyncTask<Void, Integer, Integer> { ...@@ -48,8 +48,8 @@ public class ResCheckTask extends AsyncTask<Void, Integer, Integer> {
private static final String TAG = "ResCheckTask"; private static final String TAG = "ResCheckTask";
protected int mError = ERROR_NONE; protected int mError = ERROR_NONE;
MessageReceiver mReceiver = new MessageReceiver(); MessageReceiver mReceiver = new MessageReceiver();
private AppsSettings mSettings; private final AppsSettings mSettings;
private Context mContext; private final Context mContext;
Handler han = new Handler() { Handler han = new Handler() {
@Override @Override
...@@ -62,9 +62,9 @@ public class ResCheckTask extends AsyncTask<Void, Integer, Integer> { ...@@ -62,9 +62,9 @@ public class ResCheckTask extends AsyncTask<Void, Integer, Integer> {
} }
} }
}; };
private ResCheckListener mListener; private final ResCheckListener mListener;
private DialogPlus dialog = null; private DialogPlus dialog = null;
private Handler handler; private final Handler handler;
private boolean isNewVersion; private boolean isNewVersion;
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
...@@ -228,13 +228,13 @@ public class ResCheckTask extends AsyncTask<Void, Integer, Integer> { ...@@ -228,13 +228,13 @@ public class ResCheckTask extends AsyncTask<Void, Integer, Integer> {
mSettings.getDeckDir(), needsUpdate); mSettings.getDeckDir(), needsUpdate);
} }
//复制卡包 //复制卡包
File pack = new File(mSettings.get().getPackDeckDir()); File pack = new File(AppsSettings.get().getPackDeckDir());
File[] subYdks = pack.listFiles(); File[] subYdks = pack.listFiles();
for (File packs : subYdks) { for (File packs : subYdks) {
packs.delete(); packs.delete();
} }
IOUtils.copyFilesFromAssets(mContext, getDatapath(Constants.CORE_PACK_PATH), IOUtils.copyFilesFromAssets(mContext, getDatapath(Constants.CORE_PACK_PATH),
mSettings.get().getPackDeckDir(), needsUpdate); AppsSettings.get().getPackDeckDir(), needsUpdate);
} }
String[] sound1 = mContext.getAssets().list(getDatapath(Constants.CORE_SOUND_PATH)); String[] sound1 = mContext.getAssets().list(getDatapath(Constants.CORE_SOUND_PATH));
String[] sound2 = new File(mSettings.getSoundPath()).list(); String[] sound2 = new File(mSettings.getSoundPath()).list();
......
...@@ -28,8 +28,8 @@ import cn.garymb.ygomobile.utils.SystemUtils; ...@@ -28,8 +28,8 @@ import cn.garymb.ygomobile.utils.SystemUtils;
import cn.garymb.ygomobile.utils.XmlUtils; import cn.garymb.ygomobile.utils.XmlUtils;
public class ServerListManager { public class ServerListManager {
private ServerListAdapter mAdapter; private final ServerListAdapter mAdapter;
private Context mContext; private final Context mContext;
private final File xmlFile; private final File xmlFile;
public ServerListManager(Context context, ServerListAdapter adapter) { public ServerListManager(Context context, ServerListAdapter adapter) {
......
...@@ -25,6 +25,7 @@ import java.io.FileInputStream; ...@@ -25,6 +25,7 @@ import java.io.FileInputStream;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.nio.charset.Charset; import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
...@@ -96,7 +97,7 @@ public class MyCard { ...@@ -96,7 +97,7 @@ public class MyCard {
public static final String ARG_ADDRESS = "address"; public static final String ARG_ADDRESS = "address";
public static final String ARG_PORT = "port"; public static final String ARG_PORT = "port";
public static final String PACKAGE_NAME_EZ = "com.ourygo.ez"; public static final String PACKAGE_NAME_EZ = "com.ourygo.ez";
private static final Charset UTF_8 = Charset.forName("UTF-8"); private static final Charset UTF_8 = StandardCharsets.UTF_8;
private final DefWebViewClient mDefWebViewClient = new DefWebViewClient() { private final DefWebViewClient mDefWebViewClient = new DefWebViewClient() {
@Override @Override
public boolean shouldOverrideUrlLoading(WebView view, String url) { public boolean shouldOverrideUrlLoading(WebView view, String url) {
...@@ -128,7 +129,7 @@ public class MyCard { ...@@ -128,7 +129,7 @@ public class MyCard {
}; };
private final SharedPreferences lastModified; private final SharedPreferences lastModified;
private MyCardListener mMyCardListener; private MyCardListener mMyCardListener;
private Activity mContext; private final Activity mContext;
public MyCard(Activity context) { public MyCard(Activity context) {
mContext = context; mContext = context;
...@@ -237,7 +238,7 @@ public class MyCard { ...@@ -237,7 +238,7 @@ public class MyCard {
Activity activity; Activity activity;
MyCardListener mListener; MyCardListener mListener;
private AppsSettings settings = AppsSettings.get(); private final AppsSettings settings = AppsSettings.get();
private Ygopro(Activity activity, MyCardListener listener) { private Ygopro(Activity activity, MyCardListener listener) {
this.activity = activity; this.activity = activity;
......
...@@ -17,7 +17,7 @@ import java.text.MessageFormat; ...@@ -17,7 +17,7 @@ import java.text.MessageFormat;
import cn.garymb.ygomobile.lite.BuildConfig; import cn.garymb.ygomobile.lite.BuildConfig;
public class X5WebView extends WebView { public class X5WebView extends WebView {
private WebViewClient client = new WebViewClient() { private final WebViewClient client = new WebViewClient() {
/** /**
* 防止加载网页时调起系统浏览器 * 防止加载网页时调起系统浏览器
*/ */
......
...@@ -25,8 +25,8 @@ import cn.garymb.ygomobile.utils.YGOUtil; ...@@ -25,8 +25,8 @@ import cn.garymb.ygomobile.utils.YGOUtil;
public class ChatAdapter extends RecyclerView.Adapter<ChatAdapter.ViewHolder> { public class ChatAdapter extends RecyclerView.Adapter<ChatAdapter.ViewHolder> {
private static final int CHAT = 0; private static final int CHAT = 0;
private static final int CHAT_ME = 1; private static final int CHAT_ME = 1;
private List<ChatMessage> data; private final List<ChatMessage> data;
private Context context; private final Context context;
public ChatAdapter(Context context, List<ChatMessage> data) { public ChatAdapter(Context context, List<ChatMessage> data) {
......
...@@ -44,16 +44,16 @@ public class ServiceManagement { ...@@ -44,16 +44,16 @@ public class ServiceManagement {
public static final int CHAT_JOIN_ROOM_LOADING = 7; public static final int CHAT_JOIN_ROOM_LOADING = 7;
public static final int CHAT_USER_NULL = 8; public static final int CHAT_USER_NULL = 8;
private static ServiceManagement su = new ServiceManagement(); private static final ServiceManagement su = new ServiceManagement();
private XMPPTCPConnection con; private XMPPTCPConnection con;
private MultiUserChat muc; private MultiUserChat muc;
private boolean isConnected = false; private boolean isConnected = false;
private boolean isListener = false; private boolean isListener = false;
private boolean isStartLoading=false; private boolean isStartLoading=false;
private List<ChatMessage> chatMessageList; private final List<ChatMessage> chatMessageList;
private List<ChatListener> chatListenerList; private final List<ChatListener> chatListenerList;
private List<OnJoinChatListener> joinChatListenerList; private final List<OnJoinChatListener> joinChatListenerList;
@SuppressLint("HandlerLeak") @SuppressLint("HandlerLeak")
......
...@@ -3,7 +3,7 @@ package cn.garymb.ygomobile.ui.mycard.mcchat.management; ...@@ -3,7 +3,7 @@ package cn.garymb.ygomobile.ui.mycard.mcchat.management;
import cn.garymb.ygomobile.ui.mycard.bean.McUser; import cn.garymb.ygomobile.ui.mycard.bean.McUser;
public class UserManagement { public class UserManagement {
private static UserManagement userManagement = new UserManagement(); private static final UserManagement userManagement = new UserManagement();
private McUser mcUser; private McUser mcUser;
private UserManagement() { private UserManagement() {
} }
......
...@@ -22,8 +22,8 @@ public class TaxiConnectionListener implements ConnectionListener { ...@@ -22,8 +22,8 @@ public class TaxiConnectionListener implements ConnectionListener {
private Timer tExit; private Timer tExit;
private String username; private String username;
private String password; private String password;
private int logintime = 2000; private final int logintime = 2000;
private ServiceManagement sm = ServiceManagement.getDx(); private final ServiceManagement sm = ServiceManagement.getDx();
@Override @Override
public void connected(XMPPConnection p1) { public void connected(XMPPConnection p1) {
......
...@@ -21,7 +21,7 @@ import androidx.appcompat.widget.AppCompatImageView; ...@@ -21,7 +21,7 @@ import androidx.appcompat.widget.AppCompatImageView;
*/ */
public class YuanImage extends AppCompatImageView { public class YuanImage extends AppCompatImageView {
private Context mContext; private final Context mContext;
// 控件默认长、宽 // 控件默认长、宽
private int defaultWidth = 0; private int defaultWidth = 0;
private int defaultHeight = 0; private int defaultHeight = 0;
......
...@@ -38,19 +38,13 @@ public class AOnGestureListener implements GestureDetector.OnGestureListener { ...@@ -38,19 +38,13 @@ public class AOnGestureListener implements GestureDetector.OnGestureListener {
} }
protected boolean isRightFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { protected boolean isRightFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
if (e2.getX() - e1.getX() > FLING_MIN_DISTANCE return e2.getX() - e1.getX() > FLING_MIN_DISTANCE
&& Math.abs(velocityX) > FLING_MIN_VELOCITY) { && Math.abs(velocityX) > FLING_MIN_VELOCITY;
return true;
}
return false;
} }
protected boolean isLeftFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { protected boolean isLeftFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
if (e1.getX() - e2.getX() > FLING_MIN_DISTANCE // Fling left
&& Math.abs(velocityX) > FLING_MIN_VELOCITY) { return e1.getX() - e2.getX() > FLING_MIN_DISTANCE
// Fling left && Math.abs(velocityX) > FLING_MIN_VELOCITY;
return true;
}
return false;
} }
} }
...@@ -25,8 +25,8 @@ import cn.garymb.ygomobile.ui.widget.WebViewPlus; ...@@ -25,8 +25,8 @@ import cn.garymb.ygomobile.ui.widget.WebViewPlus;
public class DialogPlus extends Dialog { public class DialogPlus extends Dialog {
public static final int TYPE_KEYGUARD = FIRST_SYSTEM_WINDOW + 4; public static final int TYPE_KEYGUARD = FIRST_SYSTEM_WINDOW + 4;
private Context context; private final Context context;
private LayoutInflater mLayoutInflater; private final LayoutInflater mLayoutInflater;
private View mView; private View mView;
// //
private TextView mTitleView; private TextView mTitleView;
...@@ -35,10 +35,11 @@ public class DialogPlus extends Dialog { ...@@ -35,10 +35,11 @@ public class DialogPlus extends Dialog {
private Button mLeft; private Button mLeft;
private Button mRight; private Button mRight;
private View mContentView; private View mContentView;
private int mMaxHeight, mMaxWidth; private final int mMaxHeight;
private final int mMaxWidth;
private String mUrl, mHtml; private String mUrl, mHtml;
private View mCancelLayout, mButtonLayout, mTitleLayout; private View mCancelLayout, mButtonLayout, mTitleLayout;
private View mProgressBar; private final View mProgressBar;
private WebViewPlus mWebView; private WebViewPlus mWebView;
private final GestureDetector mGestureDetector; private final GestureDetector mGestureDetector;
private GestureDetector.OnGestureListener mOnGestureListener; private GestureDetector.OnGestureListener mOnGestureListener;
...@@ -303,11 +304,11 @@ public class DialogPlus extends Dialog { ...@@ -303,11 +304,11 @@ public class DialogPlus extends Dialog {
} }
private <T extends View> T $(int id) { private <T extends View> T $(int id) {
return (T) mView.findViewById(id); return mView.findViewById(id);
} }
public <T extends View> T bind(int id) { public <T extends View> T bind(int id) {
return (T) mContentView.findViewById(id); return mContentView.findViewById(id);
} }
public View getContentView() { public View getContentView() {
......
...@@ -100,7 +100,7 @@ abstract class BasePreferenceFragment extends PreferenceFragment implements Pref ...@@ -100,7 +100,7 @@ abstract class BasePreferenceFragment extends PreferenceFragment implements Pref
Object value = null; Object value = null;
try { try {
if (isbool) { if (isbool) {
boolean def = defValue == null ? false : (Boolean) defValue; boolean def = defValue != null && (Boolean) defValue;
value = mSharedPreferences.getBoolean(key, def); value = mSharedPreferences.getBoolean(key, def);
} else { } else {
value = mSharedPreferences.getString(key, "" + defValue); value = mSharedPreferences.getString(key, "" + defValue);
......
...@@ -216,11 +216,11 @@ public abstract class PreferenceFragmentPlus extends BasePreferenceFragment { ...@@ -216,11 +216,11 @@ public abstract class PreferenceFragmentPlus extends BasePreferenceFragment {
public static class SharedPreferencesPlus implements SharedPreferences { public static class SharedPreferencesPlus implements SharedPreferences {
private SharedPreferences mSharedPreferences; private final SharedPreferences mSharedPreferences;
private boolean autoSave = false; private boolean autoSave = false;
private boolean isMultiProess = false; private boolean isMultiProess = false;
private String spName; private final String spName;
private Context context; private final Context context;
private SharedPreferencesPlus(Context context, String name, int mode) { private SharedPreferencesPlus(Context context, String name, int mode) {
spName = name; spName = name;
......
...@@ -32,13 +32,15 @@ public class DeckGroupView extends FrameLayout implements View.OnClickListener { ...@@ -32,13 +32,15 @@ public class DeckGroupView extends FrameLayout implements View.OnClickListener {
private final DeckInfo mDeckInfo; private final DeckInfo mDeckInfo;
private final ImageTop mImageTop; private final ImageTop mImageTop;
private LimitList mLimitList; private LimitList mLimitList;
private int mainTop, extraTop, sideTop; private final int mainTop;
private final int extraTop;
private final int sideTop;
int mCardWidth = 0; int mCardWidth = 0;
int mCardHeight = 0; int mCardHeight = 0;
private final SparseArray<CardView> mMainViews = new SparseArray<>(); private final SparseArray<CardView> mMainViews = new SparseArray<>();
private final SparseArray<CardView> mExtraViews = new SparseArray<>(); private final SparseArray<CardView> mExtraViews = new SparseArray<>();
private final SparseArray<CardView> mSideViews = new SparseArray<>(); private final SparseArray<CardView> mSideViews = new SparseArray<>();
private int mOrgLimit = 10; private final int mOrgLimit = 10;
private int mMainLimit = 15, mExtraLimit = 15, mSideLimit = 15; private int mMainLimit = 15, mExtraLimit = 15, mSideLimit = 15;
private OnCardClickListener mOnCardClickListener; private OnCardClickListener mOnCardClickListener;
private CardView mLastView; private CardView mLastView;
......
...@@ -34,7 +34,7 @@ public class SearchableListDialog extends DialogPlus implements ...@@ -34,7 +34,7 @@ public class SearchableListDialog extends DialogPlus implements
LayoutInflater inflater = LayoutInflater.from(context); LayoutInflater inflater = LayoutInflater.from(context);
View rootView = inflater.inflate(R.layout.searchable_list_dialog, null); View rootView = inflater.inflate(R.layout.searchable_list_dialog, null);
SearchManager searchManager = (SearchManager)context.getSystemService(Context.SEARCH_SERVICE); SearchManager searchManager = (SearchManager)context.getSystemService(Context.SEARCH_SERVICE);
_searchView = (SearchView) rootView.findViewById(R.id.search); _searchView = rootView.findViewById(R.id.search);
if(context instanceof Activity) { if(context instanceof Activity) {
_searchView.setSearchableInfo(searchManager _searchView.setSearchableInfo(searchManager
.getSearchableInfo(((Activity)context).getComponentName())); .getSearchableInfo(((Activity)context).getComponentName()));
...@@ -44,11 +44,11 @@ public class SearchableListDialog extends DialogPlus implements ...@@ -44,11 +44,11 @@ public class SearchableListDialog extends DialogPlus implements
_searchView.setOnCloseListener(this); _searchView.setOnCloseListener(this);
_searchView.clearFocus(); _searchView.clearFocus();
int id = _searchView.getContext().getResources().getIdentifier("android:id/search_src_text", null, null); int id = _searchView.getContext().getResources().getIdentifier("android:id/search_src_text", null, null);
TextView textView1 = (TextView) _searchView.findViewById(id); TextView textView1 = _searchView.findViewById(id);
if(textView1 != null) { if(textView1 != null) {
textView1.setTextColor(getContext().getResources().getColor(R.color.search_text_color)); textView1.setTextColor(getContext().getResources().getColor(R.color.search_text_color));
} }
ListView _listViewItems = (ListView) rootView.findViewById(R.id.listItems); ListView _listViewItems = rootView.findViewById(R.id.listItems);
listAdapter = new ArrayAdapter<Object>(context, android.R.layout.simple_list_item_1, items) { listAdapter = new ArrayAdapter<Object>(context, android.R.layout.simple_list_item_1, items) {
@Override @Override
......
...@@ -10,7 +10,7 @@ import androidx.appcompat.widget.AppCompatTextView; ...@@ -10,7 +10,7 @@ import androidx.appcompat.widget.AppCompatTextView;
public class ShimmerTextView extends AppCompatTextView implements ShimmerViewBase { public class ShimmerTextView extends AppCompatTextView implements ShimmerViewBase {
private ShimmerViewHelper shimmerViewHelper; private final ShimmerViewHelper shimmerViewHelper;
public ShimmerTextView(Context context) { public ShimmerTextView(Context context) {
super(context); super(context);
......
...@@ -2,14 +2,14 @@ package cn.garymb.ygomobile.ui.widget; ...@@ -2,14 +2,14 @@ package cn.garymb.ygomobile.ui.widget;
public interface ShimmerViewBase { public interface ShimmerViewBase {
public float getGradientX(); float getGradientX();
public void setGradientX(float gradientX); void setGradientX(float gradientX);
public boolean isShimmering(); boolean isShimmering();
public void setShimmering(boolean isShimmering); void setShimmering(boolean isShimmering);
public boolean isSetUp(); boolean isSetUp();
public void setAnimationSetupCallback(ShimmerViewHelper.AnimationSetupCallback callback); void setAnimationSetupCallback(ShimmerViewHelper.AnimationSetupCallback callback);
public int getPrimaryColor(); int getPrimaryColor();
public void setPrimaryColor(int primaryColor); void setPrimaryColor(int primaryColor);
public int getReflectionColor(); int getReflectionColor();
public void setReflectionColor(int reflectionColor); void setReflectionColor(int reflectionColor);
} }
...@@ -18,8 +18,8 @@ public class ShimmerViewHelper { ...@@ -18,8 +18,8 @@ public class ShimmerViewHelper {
private static final int DEFAULT_REFLECTION_COLOR = 0xFFFFFFFF; private static final int DEFAULT_REFLECTION_COLOR = 0xFFFFFFFF;
private View view; private final View view;
private Paint paint; private final Paint paint;
// center position of the gradient // center position of the gradient
private float gradientX; private float gradientX;
......
...@@ -16,9 +16,7 @@ public class ActivityUtils { ...@@ -16,9 +16,7 @@ public class ActivityUtils {
} }
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
if (activity.isDestroyed()) { return !activity.isDestroyed();
return false;
}
} }
return true; return true;
......
...@@ -26,8 +26,8 @@ public class CrashHandler implements Thread.UncaughtExceptionHandler { ...@@ -26,8 +26,8 @@ public class CrashHandler implements Thread.UncaughtExceptionHandler {
public static final String TAG = "YGOMobile-Exception"; public static final String TAG = "YGOMobile-Exception";
public static final CrashHandler INSTANCE = new CrashHandler(); public static final CrashHandler INSTANCE = new CrashHandler();
private Map<String, String> infos = new HashMap<String, String>(); private final Map<String, String> infos = new HashMap<String, String>();
private DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH.mm.ss"); private final DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH.mm.ss");
private Context context; private Context context;
private Thread.UncaughtExceptionHandler defaultHandler; private Thread.UncaughtExceptionHandler defaultHandler;
......
...@@ -13,6 +13,7 @@ import java.io.FileInputStream; ...@@ -13,6 +13,7 @@ import java.io.FileInputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.Comparator; import java.util.Comparator;
...@@ -199,7 +200,7 @@ public class DeckUtil { ...@@ -199,7 +200,7 @@ public class DeckUtil {
public static int getFirstCardCode(String deckPath) { public static int getFirstCardCode(String deckPath) {
InputStreamReader in = null; InputStreamReader in = null;
try { try {
in = new InputStreamReader(new FileInputStream(new File(deckPath)), "utf-8"); in = new InputStreamReader(new FileInputStream(new File(deckPath)), StandardCharsets.UTF_8);
BufferedReader reader = new BufferedReader(in); BufferedReader reader = new BufferedReader(in);
String line = null; String line = null;
DeckItemType type = DeckItemType.Space; DeckItemType type = DeckItemType.Space;
......
...@@ -142,7 +142,7 @@ public class DownloadUtil { ...@@ -142,7 +142,7 @@ public class DownloadUtil {
} }
public static interface OnDownloadListener { public interface OnDownloadListener {
/** /**
* 下载成功之后的文件 * 下载成功之后的文件
......
...@@ -70,10 +70,7 @@ public class IOUtils { ...@@ -70,10 +70,7 @@ public class IOUtils {
} catch (IOException e) { } catch (IOException e) {
} }
if (files != null && files.length > 0) { return files != null && files.length > 0;
return true;
}
return false;
} }
public static String tirmName(String name, String ex) { public static String tirmName(String name, String ex) {
......
...@@ -7,7 +7,7 @@ import java.io.InputStream; ...@@ -7,7 +7,7 @@ import java.io.InputStream;
import java.security.MessageDigest; import java.security.MessageDigest;
public class MD5Util { public class MD5Util {
private static char[] hexChar = "0123456789abcdef".toCharArray(); private static final char[] hexChar = "0123456789abcdef".toCharArray();
public static String toHexString(byte[] b) { public static String toHexString(byte[] b) {
StringBuilder sb = new StringBuilder(b.length * 2); StringBuilder sb = new StringBuilder(b.length * 2);
......
...@@ -190,7 +190,7 @@ public class OkhttpUtil { ...@@ -190,7 +190,7 @@ public class OkhttpUtil {
Request.Builder request = new Request.Builder() Request.Builder request = new Request.Builder()
.url(httpBuilder.build()); .url(httpBuilder.build());
Log.e("OkhttpUtil", "为" + httpBuilder.build().toString()); Log.e("OkhttpUtil", "为" + httpBuilder.build());
if (!TextUtils.isEmpty(cookie)) { if (!TextUtils.isEmpty(cookie)) {
request.addHeader("cookie", cookie); request.addHeader("cookie", cookie);
} }
...@@ -210,7 +210,7 @@ public class OkhttpUtil { ...@@ -210,7 +210,7 @@ public class OkhttpUtil {
Request.Builder request = new Request.Builder() Request.Builder request = new Request.Builder()
.delete() .delete()
.url(httpBuilder.build()); .url(httpBuilder.build());
Log.e("OkhttpUtil", "删除为" + httpBuilder.build().toString()); Log.e("OkhttpUtil", "删除为" + httpBuilder.build());
if (!TextUtils.isEmpty(cookie)) { if (!TextUtils.isEmpty(cookie)) {
request.addHeader("cookie", cookie); request.addHeader("cookie", cookie);
} }
...@@ -292,7 +292,7 @@ public class OkhttpUtil { ...@@ -292,7 +292,7 @@ public class OkhttpUtil {
if (!TextUtils.isEmpty(cookie)) { if (!TextUtils.isEmpty(cookie)) {
request.addHeader("cookie", cookie); request.addHeader("cookie", cookie);
} }
Log.e("OkhttpUtil",json+" 状态 "+request.build().toString()); Log.e("OkhttpUtil",json+" 状态 "+ request.build());
okHttpClient.newCall(request.build()).enqueue(callback); okHttpClient.newCall(request.build()).enqueue(callback);
} }
......
...@@ -30,7 +30,7 @@ public class ScreenUtil { ...@@ -30,7 +30,7 @@ public class ScreenUtil {
public static final int NOTCH_TYPE_PHONE_ANDROID_P = 4; public static final int NOTCH_TYPE_PHONE_ANDROID_P = 4;
public static final int NOTCH_TYPE_PHONE_OTHER = 5; public static final int NOTCH_TYPE_PHONE_OTHER = 5;
public static interface FindNotchInformation { public interface FindNotchInformation {
void onNotchInformation(boolean isNotch, int notchHeight, int phoneType); void onNotchInformation(boolean isNotch, int notchHeight, int phoneType);
} }
...@@ -198,7 +198,7 @@ public class ScreenUtil { ...@@ -198,7 +198,7 @@ public class ScreenUtil {
Method getInt = SystemProperties.getMethod("getInt", paramTypes); Method getInt = SystemProperties.getMethod("getInt", paramTypes);
//参数 //参数
Object[] params = new Object[2]; Object[] params = new Object[2];
params[0] = new String(key); params[0] = key;
params[1] = new Integer(0); params[1] = new Integer(0);
result = (Integer) getInt.invoke(SystemProperties, params); result = (Integer) getInt.invoke(SystemProperties, params);
......
...@@ -19,7 +19,7 @@ import okhttp3.Response; ...@@ -19,7 +19,7 @@ import okhttp3.Response;
public class ServerUtil { public class ServerUtil {
public enum ExCardState { public enum ExCardState {
/* 已安装最新版扩展卡,扩展卡不是最新版本,无法查询到服务器版本 */ /* 已安装最新版扩展卡,扩展卡不是最新版本,无法查询到服务器版本 */
UPDATED, NEED_UPDATE, ERROR; UPDATED, NEED_UPDATE, ERROR
} }
/* 存储了当前先行卡是否需要更新的状态,UI逻辑直接读取该变量就能获知是否已安装先行卡 */ /* 存储了当前先行卡是否需要更新的状态,UI逻辑直接读取该变量就能获知是否已安装先行卡 */
...@@ -86,11 +86,7 @@ public class ServerUtil { ...@@ -86,11 +86,7 @@ public class ServerUtil {
} }
public static boolean isPreServer(int port, String addr) { public static boolean isPreServer(int port, String addr) {
if ((port == Constants.PORT_YGO233 && addr.equals(Constants.URL_YGO233_1)) || return (port == Constants.PORT_YGO233 && addr.equals(Constants.URL_YGO233_1)) ||
(port == Constants.PORT_YGO233 && addr.equals(Constants.URL_YGO233_2))) { (port == Constants.PORT_YGO233 && addr.equals(Constants.URL_YGO233_2));
return true;
} else {
return false;
}
} }
} }
...@@ -7,6 +7,7 @@ import static cn.garymb.ygomobile.Constants.PREF_OPENGL_VERSION; ...@@ -7,6 +7,7 @@ import static cn.garymb.ygomobile.Constants.PREF_OPENGL_VERSION;
import static cn.garymb.ygomobile.Constants.PREF_READ_EX; import static cn.garymb.ygomobile.Constants.PREF_READ_EX;
import static cn.garymb.ygomobile.Constants.PREF_WINDOW_TOP_BOTTOM; import static cn.garymb.ygomobile.Constants.PREF_WINDOW_TOP_BOTTOM;
import android.content.Context;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import cn.garymb.ygomobile.App; import cn.garymb.ygomobile.App;
...@@ -23,22 +24,22 @@ public class SharedPreferenceUtil { ...@@ -23,22 +24,22 @@ public class SharedPreferenceUtil {
//获取存放路径的share //获取存放路径的share
public static SharedPreferences getSharePath() { public static SharedPreferences getSharePath() {
return App.get().getSharedPreferences("path", App.get().MODE_PRIVATE); return App.get().getSharedPreferences("path", Context.MODE_PRIVATE);
} }
//获取存放类型的share //获取存放类型的share
public static SharedPreferences getShareType() { public static SharedPreferences getShareType() {
return App.get().getSharedPreferences("type", App.get().MODE_PRIVATE); return App.get().getSharedPreferences("type", Context.MODE_PRIVATE);
} }
//获取存放开关状态的share //获取存放开关状态的share
public static SharedPreferences getShareKaiguan() { public static SharedPreferences getShareKaiguan() {
return App.get().getSharedPreferences("kaiguan", App.get().MODE_PRIVATE); return App.get().getSharedPreferences("kaiguan", Context.MODE_PRIVATE);
} }
//获取各种记录的share //获取各种记录的share
public static SharedPreferences getShareRecord() { public static SharedPreferences getShareRecord() {
return App.get().getSharedPreferences("record", App.get().MODE_PRIVATE); return App.get().getSharedPreferences("record", Context.MODE_PRIVATE);
} }
public static boolean addAppStartTimes() { public static boolean addAppStartTimes() {
...@@ -54,8 +55,6 @@ public class SharedPreferenceUtil { ...@@ -54,8 +55,6 @@ public class SharedPreferenceUtil {
getShareRecord().edit().putString("ExpansionsDataVer", json).commit(); getShareRecord().edit().putString("ExpansionsDataVer", json).commit();
} }
;
public static String getExpansionDataVer() { public static String getExpansionDataVer() {
return getShareRecord().getString("ExpansionsDataVer", null); return getShareRecord().getString("ExpansionsDataVer", null);
} }
......
...@@ -9,7 +9,7 @@ public class StringUtils { ...@@ -9,7 +9,7 @@ public class StringUtils {
* @return 全角字符串. * @return 全角字符串.
*/ */
public static String toSBC(String input) { public static String toSBC(String input) {
char c[] = input.toCharArray(); char[] c = input.toCharArray();
for (int i = 0; i < c.length; i++) { for (int i = 0; i < c.length; i++) {
if (c[i] == ' ') { if (c[i] == ' ') {
c[i] = '\u3000'; c[i] = '\u3000';
...@@ -30,7 +30,7 @@ public class StringUtils { ...@@ -30,7 +30,7 @@ public class StringUtils {
public static String toDBC(String input) { public static String toDBC(String input) {
char c[] = input.toCharArray(); char[] c = input.toCharArray();
for (int i = 0; i < c.length; i++) { for (int i = 0; i < c.length; i++) {
if (c[i] == '\u3000') { if (c[i] == '\u3000') {
c[i] = ' '; c[i] = ' ';
......
...@@ -5,6 +5,7 @@ import java.io.FileOutputStream; ...@@ -5,6 +5,7 @@ import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Enumeration; import java.util.Enumeration;
import java.util.zip.ZipEntry; import java.util.zip.ZipEntry;
...@@ -37,7 +38,7 @@ public class UnzipUtils { ...@@ -37,7 +38,7 @@ public class UnzipUtils {
} }
InputStream is = zf.getInputStream(entry); InputStream is = zf.getInputStream(entry);
String str = folderPath + File.separator + entry.getName(); String str = folderPath + File.separator + entry.getName();
str = new String(str.getBytes("8859_1"), "UTF-8"); str = new String(str.getBytes("8859_1"), StandardCharsets.UTF_8);
File desFile = new File(str); File desFile = new File(str);
if (!desFile.exists()) { if (!desFile.exists()) {
File fileParentDir = desFile.getParentFile(); File fileParentDir = desFile.getParentFile();
...@@ -47,7 +48,7 @@ public class UnzipUtils { ...@@ -47,7 +48,7 @@ public class UnzipUtils {
desFile.createNewFile(); desFile.createNewFile();
} }
OutputStream os = new FileOutputStream(desFile); OutputStream os = new FileOutputStream(desFile);
byte buffer[] = new byte[BUFFER_SIZE]; byte[] buffer = new byte[BUFFER_SIZE];
int length; int length;
while ((length = is.read(buffer)) > 0) { while ((length = is.read(buffer)) > 0) {
os.write(buffer, 0, length); os.write(buffer, 0, length);
...@@ -84,7 +85,7 @@ public class UnzipUtils { ...@@ -84,7 +85,7 @@ public class UnzipUtils {
if (entry.getName().contains(nameContains)) { if (entry.getName().contains(nameContains)) {
InputStream is = zf.getInputStream(entry); InputStream is = zf.getInputStream(entry);
String str = folderPath + File.separator + entry.getName(); String str = folderPath + File.separator + entry.getName();
str = new String(str.getBytes("8859_1"), "UTF-8"); str = new String(str.getBytes("8859_1"), StandardCharsets.UTF_8);
File desFile = new File(str); File desFile = new File(str);
if (!desFile.exists()) { if (!desFile.exists()) {
File fileParentDir = desFile.getParentFile(); File fileParentDir = desFile.getParentFile();
...@@ -94,7 +95,7 @@ public class UnzipUtils { ...@@ -94,7 +95,7 @@ public class UnzipUtils {
desFile.createNewFile(); desFile.createNewFile();
} }
OutputStream os = new FileOutputStream(desFile); OutputStream os = new FileOutputStream(desFile);
byte buffer[] = new byte[BUFFER_SIZE]; byte[] buffer = new byte[BUFFER_SIZE];
int length; int length;
while ((length = is.read(buffer)) > 0) { while ((length = is.read(buffer)) > 0) {
os.write(buffer, 0, length); os.write(buffer, 0, length);
......
...@@ -39,7 +39,7 @@ public class XmlUtils { ...@@ -39,7 +39,7 @@ public class XmlUtils {
public String toXml(Object object) throws Exception { public String toXml(Object object) throws Exception {
ByteArrayOutputStream arrayOutputStream = new ByteArrayOutputStream(); ByteArrayOutputStream arrayOutputStream = new ByteArrayOutputStream();
saveXml(object, arrayOutputStream); saveXml(object, arrayOutputStream);
return new String(arrayOutputStream.toByteArray()); return arrayOutputStream.toString();
} }
public <T> T getObject(Class<T> tClass, InputStream inputStream) throws Exception { public <T> T getObject(Class<T> tClass, InputStream inputStream) throws Exception {
......
...@@ -47,7 +47,7 @@ import cn.garymb.ygomobile.ui.plus.DialogPlus; ...@@ -47,7 +47,7 @@ import cn.garymb.ygomobile.ui.plus.DialogPlus;
import cn.garymb.ygomobile.utils.recyclerview.DeckTypeTouchHelperCallback; import cn.garymb.ygomobile.utils.recyclerview.DeckTypeTouchHelperCallback;
public class YGODialogUtil { public class YGODialogUtil {
private static String TAG = "YGODialogUtil"; private static final String TAG = "YGODialogUtil";
public static void dialogDeckSelect(Context context, String selectDeckPath, OnDeckMenuListener onDeckMenuListener) { public static void dialogDeckSelect(Context context, String selectDeckPath, OnDeckMenuListener onDeckMenuListener) {
ViewHolder viewHolder = new ViewHolder(context, selectDeckPath, onDeckMenuListener); ViewHolder viewHolder = new ViewHolder(context, selectDeckPath, onDeckMenuListener);
......
...@@ -81,11 +81,7 @@ public class YGOUtil { ...@@ -81,11 +81,7 @@ public class YGOUtil {
final int offset = recyclerView.computeVerticalScrollOffset(); final int offset = recyclerView.computeVerticalScrollOffset();
final int range = recyclerView.computeVerticalScrollRange() - recyclerView.computeVerticalScrollExtent(); final int range = recyclerView.computeVerticalScrollRange() - recyclerView.computeVerticalScrollExtent();
if(visibleItemCount > 0 && lastVisibleItemPosition >= totalItemCount - 3 && state == recyclerView.SCROLL_STATE_IDLE){ return visibleItemCount > 0 && lastVisibleItemPosition >= totalItemCount - 3 && state == RecyclerView.SCROLL_STATE_IDLE;
return true;
} else {
return false;
}
} }
public static void startDuelService(Context context) { public static void startDuelService(Context context) {
......
...@@ -16,7 +16,7 @@ public class DeckTypeTouchHelperCallback extends ItemTouchHelper.Callback { ...@@ -16,7 +16,7 @@ public class DeckTypeTouchHelperCallback extends ItemTouchHelper.Callback {
private int dragFlags; private int dragFlags;
private int swipeFlags; private int swipeFlags;
private RecyclerView recyclerView; private RecyclerView recyclerView;
private YGODialogUtil.OnDeckTypeListener onDeckTypeListener; private final YGODialogUtil.OnDeckTypeListener onDeckTypeListener;
public DeckTypeTouchHelperCallback(YGODialogUtil.OnDeckTypeListener onDeckTypeListener) { public DeckTypeTouchHelperCallback(YGODialogUtil.OnDeckTypeListener onDeckTypeListener) {
this.onDeckTypeListener = onDeckTypeListener; this.onDeckTypeListener = onDeckTypeListener;
......
...@@ -17,7 +17,7 @@ import java.util.List; ...@@ -17,7 +17,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
class Reflect { class Reflect {
private Class<?> mClass; private final Class<?> mClass;
private XmlOptions options; private XmlOptions options;
private static final HashMap<String, Reflect> sReflectUtils = new HashMap<>(); private static final HashMap<String, Reflect> sReflectUtils = new HashMap<>();
...@@ -157,9 +157,7 @@ class Reflect { ...@@ -157,9 +157,7 @@ class Reflect {
} }
if (options != null) { if (options != null) {
//是否忽略没有标记的元素? //是否忽略没有标记的元素?
if (options.isUseNoAnnotation()) { return options.isUseNoAnnotation();
return true;
}
} }
return false; return false;
} }
......
...@@ -27,7 +27,7 @@ class ReflectUtils { ...@@ -27,7 +27,7 @@ class ReflectUtils {
if (type == null || type.isEnum()) { if (type == null || type.isEnum()) {
return true; return true;
} }
if (boolean.class == type || Boolean.class == type return boolean.class == type || Boolean.class == type
|| int.class == type || Integer.class == type || int.class == type || Integer.class == type
|| long.class == type || Long.class == type || long.class == type || Long.class == type
|| short.class == type || Short.class == type || short.class == type || Short.class == type
...@@ -35,10 +35,7 @@ class ReflectUtils { ...@@ -35,10 +35,7 @@ class ReflectUtils {
|| double.class == type || Double.class == type || double.class == type || Double.class == type
|| float.class == type || Float.class == type || float.class == type || Float.class == type
|| char.class == type || Character.class == type || char.class == type || Character.class == type
|| String.class == type) { || String.class == type;
return true;
}
return false;
} }
...@@ -220,7 +217,7 @@ class ReflectUtils { ...@@ -220,7 +217,7 @@ class ReflectUtils {
if (elementType instanceof Class) { if (elementType instanceof Class) {
return (Collection<T>) EnumSet.noneOf((Class) elementType); return (Collection<T>) EnumSet.noneOf((Class) elementType);
} else { } else {
throw new RuntimeException("Invalid EnumSet type: " + type.toString()); throw new RuntimeException("Invalid EnumSet type: " + type);
} }
} else { } else {
throw new RuntimeException("Invalid EnumSet type: " + type.toString()); throw new RuntimeException("Invalid EnumSet type: " + type.toString());
...@@ -300,7 +297,7 @@ class ReflectUtils { ...@@ -300,7 +297,7 @@ class ReflectUtils {
return Boolean.parseBoolean(value); return Boolean.parseBoolean(value);
} else if (int.class == type || Integer.class == type) { } else if (int.class == type || Integer.class == type) {
if (value.trim().length() == 0) { if (value.trim().length() == 0) {
return (int) 0; return 0;
} }
return (value.startsWith("0x")) ? return (value.startsWith("0x")) ?
Integer.parseInt(value.substring(2), 16) : Integer.parseInt(value); Integer.parseInt(value.substring(2), 16) : Integer.parseInt(value);
...@@ -337,7 +334,7 @@ class ReflectUtils { ...@@ -337,7 +334,7 @@ class ReflectUtils {
} }
return value.toCharArray()[0]; return value.toCharArray()[0];
} else if (String.class == type) { } else if (String.class == type) {
return object == null ? "" : String.valueOf(object); return object == null ? "" : object;
} else if (type.isEnum()) { } else if (type.isEnum()) {
if (value.trim().length() == 0) { if (value.trim().length() == 0) {
return null; return null;
......
...@@ -28,7 +28,7 @@ class XmlCore { ...@@ -28,7 +28,7 @@ class XmlCore {
} }
protected TagObject make(Object obj) throws Exception { protected TagObject make(Object obj) throws Exception {
if (IXmlElement.class.isInstance(obj)) { if (obj instanceof IXmlElement) {
int pos = on(obj).get(obj, "pos"); int pos = on(obj).get(obj, "pos");
return make(obj.getClass(), pos); return make(obj.getClass(), pos);
} }
...@@ -87,16 +87,11 @@ class XmlCore { ...@@ -87,16 +87,11 @@ class XmlCore {
} }
String alias = xmlElement.alias(); String alias = xmlElement.alias();
if (mOptions.isIgnoreTagCase()) { if (mOptions.isIgnoreTagCase()) {
if (name.equalsIgnoreCase(alias)) { return name.equalsIgnoreCase(alias);
return true;
}
} else { } else {
if (name.equals(alias)) { return name.equals(alias);
return true;
}
} }
} }
return false;
} }
protected boolean matchAttribute(Field field, String name, String namespace) { protected boolean matchAttribute(Field field, String name, String namespace) {
...@@ -133,15 +128,10 @@ class XmlCore { ...@@ -133,15 +128,10 @@ class XmlCore {
} }
String alia = attribute.alias(); String alia = attribute.alias();
if (mOptions.isIgnoreTagCase()) { if (mOptions.isIgnoreTagCase()) {
if (name.equalsIgnoreCase(alia)) { return name.equalsIgnoreCase(alia);
return true;
}
} else { } else {
if (name.equals(alia)) { return name.equals(alia);
return true;
}
} }
return false;
} }
} }
......
...@@ -105,7 +105,7 @@ public class XmlOptions { ...@@ -105,7 +105,7 @@ public class XmlOptions {
} }
public static class Builder { public static class Builder {
private XmlOptions mOptions; private final XmlOptions mOptions;
public Builder() { public Builder() {
mOptions = new XmlOptions(); mOptions = new XmlOptions();
......
...@@ -14,6 +14,7 @@ import java.io.IOException; ...@@ -14,6 +14,7 @@ import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.lang.reflect.Array; import java.lang.reflect.Array;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.HashMap; import java.util.HashMap;
...@@ -34,7 +35,7 @@ public class XmlReader extends XmlCore { ...@@ -34,7 +35,7 @@ public class XmlReader extends XmlCore {
//region api //region api
public <T> T fromXml(Class<T> pClass, String xml) throws Exception { public <T> T fromXml(Class<T> pClass, String xml) throws Exception {
T t = null; T t = null;
ByteArrayInputStream inputStream = new ByteArrayInputStream(xml.getBytes("utf-8")); ByteArrayInputStream inputStream = new ByteArrayInputStream(xml.getBytes(StandardCharsets.UTF_8));
try { try {
t = fromInputStream(pClass, inputStream, "utf-8"); t = fromInputStream(pClass, inputStream, "utf-8");
} finally { } finally {
......
...@@ -22,7 +22,7 @@ import java.util.Set; ...@@ -22,7 +22,7 @@ import java.util.Set;
public class XmlWriter extends XmlCore { public class XmlWriter extends XmlCore {
private static final String NEW_LINE = System.getProperty("line.separator", "\n"); private static final String NEW_LINE = System.getProperty("line.separator", "\n");
private XmlSerializer serializer; private final XmlSerializer serializer;
/*** /***
* @see org.xmlpull.v1.XmlPullParserFactory newInstance().newSerializer() * @see org.xmlpull.v1.XmlPullParserFactory newInstance().newSerializer()
......
...@@ -14,8 +14,8 @@ public class AttributeObject { ...@@ -14,8 +14,8 @@ public class AttributeObject {
this.value = value; this.value = value;
} }
private String name; private final String name;
private String namespace; private final String namespace;
private String value; private String value;
public void setValue(String value) { public void setValue(String value) {
...@@ -45,10 +45,7 @@ public class AttributeObject { ...@@ -45,10 +45,7 @@ public class AttributeObject {
} }
if (other.getNamespace() != null && !other.getNamespace().equals(name)) { if (other.getNamespace() != null && !other.getNamespace().equals(name)) {
return false; return false;
} else if (namespace != null) { } else return namespace == null;
return false;
}
return true;
} }
return super.equals(o); return super.equals(o);
} }
......
...@@ -34,7 +34,8 @@ import ocgcore.data.Card; ...@@ -34,7 +34,8 @@ import ocgcore.data.Card;
public class CardManager { public class CardManager {
private static int cdbNum = 0; private static int cdbNum = 0;
private final SparseArray<Card> cardDataHashMap = new SparseArray<>(); private final SparseArray<Card> cardDataHashMap = new SparseArray<>();
private String dbDir, exDbPath; private final String dbDir;
private final String exDbPath;
private static final String TAG = IrrlichtBridge.TAG; private static final String TAG = IrrlichtBridge.TAG;
/** /**
......
...@@ -10,6 +10,7 @@ import java.io.Closeable; ...@@ -10,6 +10,7 @@ import java.io.Closeable;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
...@@ -81,7 +82,7 @@ public class LimitManager implements Closeable { ...@@ -81,7 +82,7 @@ public class LimitManager implements Closeable {
FileInputStream inputStream = null; FileInputStream inputStream = null;
try { try {
inputStream = new FileInputStream(file); inputStream = new FileInputStream(file);
in = new InputStreamReader(inputStream, "utf-8"); in = new InputStreamReader(inputStream, StandardCharsets.UTF_8);
BufferedReader reader = new BufferedReader(in); BufferedReader reader = new BufferedReader(in);
String line = null; String line = null;
String name = null; String name = null;
...@@ -99,7 +100,7 @@ public class LimitManager implements Closeable { ...@@ -99,7 +100,7 @@ public class LimitManager implements Closeable {
String[] words = line.trim().split("[\t| ]+"); String[] words = line.trim().split("[\t| ]+");
if (words.length >= 2) { if (words.length >= 2) {
int id = toNumber(words[0]); int id = toNumber(words[0]);
int count = (int) toNumber(words[1]); int count = toNumber(words[1]);
switch (count) { switch (count) {
case 0: case 0:
tmp.addForbidden(id); tmp.addForbidden(id);
......
...@@ -12,7 +12,7 @@ public enum CardLocation { ...@@ -12,7 +12,7 @@ public enum CardLocation {
Onfield(0x0C); Onfield(0x0C);
private int value = 0; private int value = 0;
private CardLocation(int value) { CardLocation(int value) {
this.value = value; this.value = value;
} }
public static CardLocation valueOf(int value) { public static CardLocation valueOf(int value) {
......
...@@ -12,7 +12,7 @@ public enum CardPosition { ...@@ -12,7 +12,7 @@ public enum CardPosition {
private int value = 0; private int value = 0;
private CardPosition(int value) { CardPosition(int value) {
this.value = value; this.value = value;
} }
......
...@@ -13,7 +13,7 @@ public enum DuelPhase { ...@@ -13,7 +13,7 @@ public enum DuelPhase {
End(0x200); End(0x200);
private int value = 0; private int value = 0;
private DuelPhase(int value) { DuelPhase(int value) {
this.value = value; this.value = value;
} }
......
...@@ -93,7 +93,7 @@ public enum GameMessage { ...@@ -93,7 +93,7 @@ public enum GameMessage {
private int value = 0; private int value = 0;
private GameMessage(int value) { GameMessage(int value) {
this.value = value; this.value = value;
} }
......
...@@ -26,7 +26,7 @@ public enum Query { ...@@ -26,7 +26,7 @@ public enum Query {
RScale(0x400000); RScale(0x400000);
private int value = 0; private int value = 0;
private Query(int value) { Query(int value) {
this.value = value; this.value = value;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment