Sfoglia il codice sorgente

1.修改Android Apex Mobile删除工具类。

Pen Li 7 anni fa
parent
commit
886b757564

+ 0 - 133
ApexDrivers/apexmobile/src/main/java/com/usai/apex/actionSheet/ActionSheet.java

@@ -1,133 +0,0 @@
-package com.usai.apex.actionSheet;
-
-import android.app.Dialog;
-import android.content.Context;
-import android.graphics.Color;
-import android.support.annotation.NonNull;
-import android.support.annotation.Nullable;
-import android.text.TextPaint;
-import android.util.TypedValue;
-import android.view.Gravity;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.view.Window;
-import android.view.WindowManager;
-import android.widget.Button;
-import android.widget.LinearLayout;
-
-
-import com.usai.apex.R;
-import com.usai.apex.button.RAButton;
-
-import java.util.HashMap;
-
-public class ActionSheet extends Dialog implements View.OnClickListener {
-
-    private Context mCtx;
-    private LinearLayout mRootView;
-    private HashMap<Button,View.OnClickListener> buttonListenerMap = new HashMap<>();
-
-    public ActionSheet(@NonNull Context context) {
-        this(context,R.style.actionSheet);
-
-    }
-
-    public ActionSheet(@NonNull Context context, int themeResId) {
-        super(context, themeResId);
-
-        mCtx = context;
-        init();
-    }
-
-    protected ActionSheet(@NonNull Context context, boolean cancelable, @Nullable OnCancelListener cancelListener) {
-        super(context, cancelable, cancelListener);
-
-        mCtx = context;
-        init();
-    }
-
-    private void init() {
-        mRootView = (LinearLayout) LayoutInflater.from(mCtx).inflate(R.layout.action_sheet, null);
-        setContentView(mRootView);
-    }
-
-    public void addAction(String title, ActionType actionType, View.OnClickListener clickListener) {
-
-        RAButton button = new RAButton(mCtx);
-        button.setText(title);
-        button.setTextColor(Color.parseColor("#2577ff"));
-        button.setTextSize(TypedValue.COMPLEX_UNIT_SP,20);
-        button.setAllCaps(false);
-        button.setBackgroundResource(R.drawable.actionsheet_round_corner_normal_bg);
-        button.setOnClickListener(this);
-        if (clickListener != null) {
-            buttonListenerMap.put(button,clickListener);
-        }
-
-        button.setTitleColorForState(RAButton.RAButtonState.RAButtonStateHighlight,Color.GRAY);
-        button.setBackgroundDrawableForState(RAButton.RAButtonState.RAButtonStateNormal,mCtx.getResources().getDrawable(R.drawable.actionsheet_round_corner_normal_bg));
-
-        LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,dp2px(mCtx,50));
-
-        int marginH = dp2px(mCtx,10);
-        int marginV = dp2px(mCtx,5);
-        switch (actionType) {
-            case ACtionTypeCancel: {
-                layoutParams.setMargins(marginH,marginV,marginH,marginV);
-
-                TextPaint tp = button.getPaint();
-                tp.setFakeBoldText(true);
-            }
-            break;
-            case ActionTypeDefault: {
-                layoutParams.setMargins(marginH,0,marginH,marginV);
-            }
-            break;
-        }
-
-        mRootView.addView(button,layoutParams);
-    }
-
-    private static int dp2px(Context context, float dpValue) {
-        float scale = context.getResources().getDisplayMetrics().density;
-        return (int) (dpValue * scale + 0.5f);
-    }
-
-    @Override
-    public void show() {
-
-        Window dialogWindow = getWindow();
-        if (dialogWindow != null) {
-
-            dialogWindow.setGravity(Gravity.BOTTOM);
-            WindowManager.LayoutParams layoutParams = dialogWindow.getAttributes(); // 获取对话框当前的参数值
-            layoutParams.x = 0; // 新位置X坐标
-            layoutParams.y = 0; // 新位置Y坐标
-            layoutParams.width = (int) mCtx.getResources().getDisplayMetrics().widthPixels; // 宽度
-            mRootView.measure(0, 0);
-            layoutParams.height = mRootView.getMeasuredHeight();
-
-            layoutParams.alpha = 9f; // 透明度
-            dialogWindow.setAttributes(layoutParams);
-        }
-
-        super.show();
-    }
-
-    @Override
-    public void onClick(View v) {
-
-        dismiss();
-
-        View.OnClickListener listener = buttonListenerMap.get(v);
-        if (listener != null) {
-            listener.onClick(v);
-        }
-    }
-
-    public enum ActionType {
-        ActionTypeDefault,
-        ACtionTypeCancel
-    }
-}

+ 0 - 176
ApexDrivers/apexmobile/src/main/java/com/usai/apex/button/RAButton.java

@@ -1,176 +0,0 @@
-package com.usai.apex.button;
-
-import android.content.Context;
-import android.graphics.drawable.Drawable;
-import android.util.AttributeSet;
-
-import java.util.HashMap;
-
-public class RAButton extends android.support.v7.widget.AppCompatButton {
-
-    private HashMap<RAButtonState,Drawable> stateDrawableHashMap = new HashMap<>();
-    private HashMap<RAButtonState,String> stateTitleHashMap = new HashMap<>();
-    private HashMap<RAButtonState,Integer> stateTitleColorHashMap = new HashMap<>();
-
-    private RAButtonState state = RAButtonState.RAButtonStateNormal;
-    private boolean mSelected = false;
-
-    public RAButton(Context context) {
-        super(context);
-
-        init();
-    }
-
-    public RAButton(Context context, AttributeSet attrs) {
-        super(context, attrs);
-
-        init();
-    }
-
-    public RAButton(Context context, AttributeSet attrs, int defStyleAttr) {
-        super(context, attrs, defStyleAttr);
-
-        init();
-    }
-
-    private void init() {
-
-        setAllCaps(false);
-
-        String normalTitle = getText().toString();
-        Drawable normalDrawable = getBackground();
-        Integer normalTitleColor = getTextColors().getDefaultColor();
-
-        String title = stateTitleHashMap.get(RAButtonState.RAButtonStateNormal);
-        if (title == null && normalTitle != null) {
-            stateTitleHashMap.put(RAButtonState.RAButtonStateNormal,normalTitle);
-        }
-
-        Drawable background = stateDrawableHashMap.get(RAButtonState.RAButtonStateNormal);
-        if (background == null && normalDrawable != null) {
-            stateDrawableHashMap.put(RAButtonState.RAButtonStateNormal,normalDrawable);
-        }
-
-        stateTitleColorHashMap.put(RAButtonState.RAButtonStateNormal,normalTitleColor);
-
-    }
-
-    public void setBackgroundDrawableForState(RAButtonState state, Drawable drawable) {
-
-        if (state == null) {
-            return;
-        }
-
-        if (drawable != null) {
-            stateDrawableHashMap.put(state,drawable);
-        } else {
-            stateDrawableHashMap.remove(state);
-        }
-    }
-
-    public void setTitleForState(RAButtonState state, String title) {
-
-        if (state == null) {
-            return;
-        }
-        if (title == null) {
-            stateTitleHashMap.remove(state);
-        } else {
-            stateTitleHashMap.put(state,title);
-        }
-    }
-
-    public void setTitleColorForState(RAButtonState state, int color) {
-
-        if (state == null) {
-            return;
-        }
-
-        stateTitleColorHashMap.put(state,Integer.valueOf(color));
-    }
-
-    public void setText(String text) {
-        super.setText(text);
-
-        setTitleForState(state,text);
-    }
-
-    public void setTextColor(int color) {
-        super.setTextColor(color);
-
-        setTitleColorForState(state,color);
-    }
-
-    public void setBackgroundDrawable(Drawable drawable) {
-        super.setBackgroundDrawable(drawable);
-
-        setBackgroundDrawableForState(state,drawable);
-    }
-
-    private void refreshUI() {
-
-        Drawable drawable = stateDrawableHashMap.get(state);
-        if (drawable == null) {
-            drawable = stateDrawableHashMap.get(RAButtonState.RAButtonStateNormal);
-        }
-        super.setBackgroundDrawable(drawable);
-
-        String title = stateTitleHashMap.get(state);
-        if (title == null) {
-            title = stateTitleHashMap.get(RAButtonState.RAButtonStateNormal);
-        }
-        super.setText(title);
-
-        Integer colorInteger = stateTitleColorHashMap.get(state);
-        if (colorInteger != null) {
-            super.setTextColor(colorInteger.intValue());
-        }
-    }
-
-    public void setSelection(boolean selection) {
-        mSelected = selection;
-
-        if (selection) {
-            state = RAButtonState.RAButtonStateSelected;
-        } else {
-            state = RAButtonState.RAButtonStateNormal;
-        }
-
-        refreshUI();
-    }
-
-    public boolean getSelection() {
-        return mSelected;
-    }
-
-    /**
-     * 按钮触摸状态改变回调
-     * */
-    @Override
-    protected void drawableStateChanged() {
-        super.drawableStateChanged();
-
-        boolean pressed = isPressed();
-
-        if (pressed) {
-            state = RAButtonState.RAButtonStateHighlight;
-        } else {
-
-            if (mSelected) {
-                state = RAButtonState.RAButtonStateSelected;
-            } else {
-                state = RAButtonState.RAButtonStateNormal;
-            }
-
-        }
-
-        refreshUI();
-
-    }
-
-    public enum RAButtonState {
-        RAButtonStateNormal,
-        RAButtonStateHighlight,
-        RAButtonStateSelected
-    }
-}

+ 0 - 92
ApexDrivers/apexmobile/src/main/java/com/usai/apex/operationQueue/OperationQueue.java

@@ -1,92 +0,0 @@
-package com.usai.apex.operationQueue;
-
-import android.os.AsyncTask;
-
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-
-public class OperationQueue {
-
-    /**
-     * 根据CPU核心数控制线程数
-     * */
-    private static final int count = Runtime.getRuntime().availableProcessors() * 3;
-
-    private static ExecutorService limitedTaskExecutor = null;
-
-    private static volatile OperationQueue instance;
-
-    public static OperationQueue sharedQueue() {
-        if (instance == null) {
-            synchronized (OperationQueue.class) {
-                if (instance == null) {
-                    instance = new OperationQueue();
-                }
-            }
-        }
-        return instance;
-    }
-
-    private OperationQueue() {
-        limitedTaskExecutor = Executors.newFixedThreadPool(count);
-    }
-
-    public void addOperationTask(OperationBackgroundCallBack backgroundCallBack, OperationCompletionCallBack completion, OperationCancelCallBack cancelCallBack) {
-
-        OperationTask task = new OperationTask(backgroundCallBack,completion,cancelCallBack);
-        task.executeOnExecutor(limitedTaskExecutor);
-    }
-
-    private class OperationTask extends AsyncTask<Void, Void, Object> {
-
-        private OperationBackgroundCallBack mBackgroundCallBack;
-        private OperationCompletionCallBack mCompletion;
-        private OperationCancelCallBack mCancelCallBack;
-
-        OperationTask(OperationBackgroundCallBack backgroundCallBack, OperationCompletionCallBack completion, OperationCancelCallBack cancelCallBack) {
-            mBackgroundCallBack = backgroundCallBack;
-            mCompletion = completion;
-            mCancelCallBack = cancelCallBack;
-        }
-
-        @Override
-        protected Object doInBackground(Void... voids) {
-
-            if (mBackgroundCallBack != null) {
-                return mBackgroundCallBack.operationDoInBackground();
-            }
-
-            return null;
-        }
-
-        @Override
-        protected void onPostExecute(Object object) {
-
-            if (mCompletion != null) {
-                mCompletion.operationCompletion(object);
-            }
-        }
-
-        @Override
-        protected void onCancelled() {
-            super.onCancelled();
-
-            if (mCancelCallBack != null) {
-                mCancelCallBack.operationCancelled();
-            }
-        }
-    }
-
-    public interface OperationBackgroundCallBack {
-        Object operationDoInBackground();
-    }
-
-    public interface OperationCompletionCallBack {
-        void operationCompletion(Object object);
-    }
-
-    public interface OperationCancelCallBack {
-        void operationCancelled();
-    }
-
-}