Commit acb4e937 authored by fallenstardust's avatar fallenstardust

gradle 7.5

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