() {
-
- @Override
- public int compare(GizMessage arg0, GizMessage arg1) {
-
- String updatedAt = DateUtil.utc2Local(arg0.getUpdatedAt());
- String updatedAt2 = DateUtil.utc2Local(arg1.getUpdatedAt());
-
- int diff = (int) DateUtil.getDiff(updatedAt2, updatedAt);
-
- return diff;
- }
-
- });
- }
-
- if (progressDialog.isShowing()) {
- progressDialog.cancel();
- }
- mymessageList = messageList;
- if (mymessageList.size() != 0) {
- tvNoMessage.setVisibility(View.GONE);
- }
- myadapter.notifyDataSetChanged();
- }
-
- });
- }
-}
diff --git a/src/main/java/com/gizwits/opensource/appkit/sharingdevice/gosZxingDeviceSharingActivity.java b/src/main/java/com/gizwits/opensource/appkit/sharingdevice/gosZxingDeviceSharingActivity.java
deleted file mode 100644
index 497019d..0000000
--- a/src/main/java/com/gizwits/opensource/appkit/sharingdevice/gosZxingDeviceSharingActivity.java
+++ /dev/null
@@ -1,235 +0,0 @@
-package com.gizwits.opensource.appkit.sharingdevice;
-
-import android.content.Intent;
-import android.os.Bundle;
-import android.os.Handler;
-import android.view.MenuItem;
-import android.view.View;
-import android.widget.Button;
-import android.widget.TextView;
-import android.widget.Toast;
-
-import com.gizwits.gizwifisdk.api.GizDeviceSharing;
-import com.gizwits.gizwifisdk.enumration.GizWifiErrorCode;
-import com.gizwits.gizwifisdk.listener.GizDeviceSharingListener;
-import com.gizwits.opensource.appkit.CommonModule.GosBaseActivity;
-import com.gizwits.opensource.appkit.R;
-import com.gizwits.opensource.appkit.utils.DateUtil;
-
-public class gosZxingDeviceSharingActivity extends GosBaseActivity {
-
- private String code;
- private int time = 15;
- private String[] split2s;
- private String tip;
- private TextView tiptext;
- private String token;
- private Button yes;
- private Button no;
- private TextView zxingtext;
- private String whoshared;
- private String[] splits;
- private String userName;
- private String productName;
- private String deviceAlias;
- private String expiredAt;
-
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
- setContentView(R.layout.gos_devicesharing_zxing_activity);
- setToolBar(true, R.string.QR_code);
- initData();
- initView();
- }
-
- private void initView() {
-
- zxingtext = (TextView) findViewById(R.id.zxingtext);
-
- yes = (Button) findViewById(R.id.yes);
-
- no = (Button) findViewById(R.id.no);
-
- whoshared = getResources().getString(R.string.whoshared);
-
- splits = whoshared.split("xxx");
- // [, 向你共享, ,你接受并绑定设备吗?]
- whoshared = userName + splits[1] + productName + splits[splits.length - 1];
- zxingtext.setText(whoshared);
-
- String timeByFormat = DateUtil.getCurTimeByFormat("yyyy-MM-dd HH:mm:ss");
- expiredAt = DateUtil.utc2Local(expiredAt);
- long diff = DateUtil.getDiff(expiredAt, timeByFormat);
- if (diff >= 0) {
- double c = diff / 60.0;
- time = (int) Math.ceil(c);
- } else {
- tiptext.setText(getResources().getString(R.string.requestoutoftime));
- yes.setClickable(false);
- yes.setTextColor(getResources().getColor(R.color.gray));
- return;
- }
- tiptext = (TextView) findViewById(R.id.tiptext);
- tip = getResources().getString(R.string.tipthings);
- split2s = tip.split("xx");
-
- tip = split2s[0] + time + split2s[1];
-
- tiptext.setText(tip);
-
- hand.sendEmptyMessageDelayed(1, diff % 60 * 1000);
-
- yes.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- GizDeviceSharing.acceptDeviceSharingByQRCode(spf.getString("Token", ""), code);
- }
- });
-
- no.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- finish();
- }
- });
- }
-
- private void initData() {
-
- Intent intent = getIntent();
- code = intent.getStringExtra("code");
- userName = intent.getStringExtra("userName");
- productName = intent.getStringExtra("productName");
- deviceAlias = intent.getStringExtra("deviceAlias");
- expiredAt = intent.getStringExtra("expiredAt");
-
- token = spf.getString("Token", "");
-
- }
-
- @Override
- protected void onResume() {
- super.onResume();
-
- if (time > 0) {
- tip = split2s[0] + time + split2s[1];
-
- tiptext.setText(tip);
- } else {
- tiptext.setText(getResources().getString(R.string.requestoutoftime));
- yes.setClickable(false);
- yes.setTextColor(getResources().getColor(R.color.gray));
- }
-
- GizDeviceSharing.setListener(new GizDeviceSharingListener() {
-
- @Override
- public void didAcceptDeviceSharing(GizWifiErrorCode result, int sharingID) {
- super.didAcceptDeviceSharing(result, sharingID);
- if (result.ordinal() == 0) {
- finish();
- } else {
- Toast.makeText(gosZxingDeviceSharingActivity.this, toastError(result), 1).show();
- finish();
- }
- }
-
- @Override
- public void didAcceptDeviceSharingByQRCode(GizWifiErrorCode result) {
- super.didAcceptDeviceSharingByQRCode(result);
- if (result.ordinal() == 0) {
- Toast.makeText(gosZxingDeviceSharingActivity.this, "success", 1).show();
-
- finish();
- } else {
- Toast.makeText(gosZxingDeviceSharingActivity.this, toastError(result), 1).show();
-
- finish();
- }
- }
-
- @Override
- public void didCheckDeviceSharingInfoByQRCode(GizWifiErrorCode result, String userName, String productName,
- String deviceAlias, String expiredAt) {
- super.didCheckDeviceSharingInfoByQRCode(result, userName, productName, deviceAlias, expiredAt);
-
- int errorcode = result.ordinal();
-
- if (8041 <= errorcode && errorcode <= 8050 || errorcode == 8308) {
- tiptext.setVisibility(View.GONE);
- yes.setClickable(false);
- no.setClickable(false);
- yes.setTextColor(getResources().getColor(R.color.gray));
- no.setTextColor(getResources().getColor(R.color.gray));
- zxingtext.setText(getResources().getString(R.string.sorry));
- } else if (errorcode != 0) {
- tiptext.setVisibility(View.GONE);
- yes.setClickable(false);
- no.setClickable(false);
- yes.setTextColor(getResources().getColor(R.color.gray));
- no.setTextColor(getResources().getColor(R.color.gray));
- zxingtext.setText(getResources().getString(R.string.verysorry));
- } else {
- tiptext.setVisibility(View.VISIBLE);
- yes.setClickable(true);
- no.setClickable(true);
- yes.setTextColor(getResources().getColor(R.color.text_color));
- no.setTextColor(getResources().getColor(R.color.text_color));
-
- whoshared = userName + splits[1] + productName + splits[splits.length - 1];
- zxingtext.setText(whoshared);
-
- String timeByFormat = DateUtil.getCurTimeByFormat("yyyy-MM-dd HH:mm:ss");
- expiredAt = DateUtil.utc2Local(expiredAt);
- long diff = DateUtil.getDiff(expiredAt, timeByFormat);
-
- if (diff >= 0) {
- time = (int) Math.ceil(diff / 60);
- } else {
-
- }
- Toast.makeText(gosZxingDeviceSharingActivity.this, diff % 60 + "", 1).show();
-
- }
- }
- });
-
- }
-
-
- Handler hand = new Handler() {
- public void handleMessage(android.os.Message msg) {
-
- time = time - 1;
-
- if (time > 0) {
- tip = split2s[0] + time + split2s[1];
-
- tiptext.setText(tip);
- hand.sendEmptyMessageDelayed(1, 60000);
- } else {
- tiptext.setText(getResources().getString(R.string.requestoutoftime));
- yes.setClickable(false);
- yes.setTextColor(getResources().getColor(R.color.gray));
- }
-
- }
-
- ;
- };
-
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- switch (item.getItemId()) {
- case android.R.id.home:
- this.finish();
- break;
- }
- return super.onOptionsItemSelected(item);
- }
-
-}
diff --git a/src/main/java/com/gizwits/opensource/appkit/sharingdevice/twoSharedActivity.java b/src/main/java/com/gizwits/opensource/appkit/sharingdevice/twoSharedActivity.java
deleted file mode 100644
index 8494466..0000000
--- a/src/main/java/com/gizwits/opensource/appkit/sharingdevice/twoSharedActivity.java
+++ /dev/null
@@ -1,175 +0,0 @@
-package com.gizwits.opensource.appkit.sharingdevice;
-
-import android.content.Intent;
-import android.graphics.Bitmap;
-import android.os.Bundle;
-import android.os.Handler;
-import android.view.MenuItem;
-import android.view.View;
-import android.widget.ImageView;
-import android.widget.TextView;
-
-import com.gizwits.gizwifisdk.api.GizDeviceSharing;
-import com.gizwits.gizwifisdk.enumration.GizDeviceSharingWay;
-import com.gizwits.gizwifisdk.enumration.GizWifiErrorCode;
-import com.gizwits.gizwifisdk.listener.GizDeviceSharingListener;
-import com.gizwits.opensource.appkit.CommonModule.GosBaseActivity;
-import com.gizwits.opensource.appkit.R;
-
-import java.util.Timer;
-import java.util.TimerTask;
-
-public class twoSharedActivity extends GosBaseActivity {
-
- private String productname;
- private String did;
- private ImageView myimage;
- private TextView timeout;
- private TextView bottomtext;
- private int time = 15;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
-
- super.onCreate(savedInstanceState);
-
- setContentView(R.layout.activity_gos_two_shared);
-
- setToolBar(true, R.string.scan_code_sharing);
-
- initData();
- initView();
- }
-
- private void initView() {
- TextView usersharedtext = (TextView) findViewById(R.id.usersharedtext);
-
- myimage = (ImageView) findViewById(R.id.myimageview);
-
- timeout = (TextView) findViewById(R.id.timeout);
-
- timeout2 = splits[0] + time + splits[1];
-
- timeout.setText(timeout2);
-
- bottomtext = (TextView) findViewById(R.id.bottomtext);
-
- usersharedtext.setText(getResources().getString(R.string.shared) + " " + productname
- + getResources().getString(R.string.friends));
- }
-
- private void initData() {
-
- Intent tent = getIntent();
- productname = tent.getStringExtra("productname");
- did = tent.getStringExtra("did");
-
- timeout2 = getResources().getString(R.string.zxingtimeout);
- splits = timeout2.split("15");
- GizDeviceSharing.sharingDevice(spf.getString("Token", ""), did, GizDeviceSharingWay.GizDeviceSharingByQRCode,
- null, null);
-
- }
-
- private void startTimer() {
- timer = new Timer();
- timer.schedule(new TimerTask() {
-
- @Override
- public void run() {
-
- time = time - 1;
- hand.sendEmptyMessage(1);
- }
- }, 60000, 60000);
- }
-
- @Override
- protected void onResume() {
- super.onResume();
- if (time > 0) {
- timeout2 = splits[0] + time + splits[1];
-
- timeout.setText(timeout2);
- } else {
- timeout.setText(getResources().getString(R.string.twofailed));
- }
- GizDeviceSharing.setListener(new GizDeviceSharingListener() {
-
- @Override
- public void didSharingDevice(GizWifiErrorCode result, String deviceID, int sharingID,
- Bitmap QRCodeImage) {
- super.didSharingDevice(result, deviceID, sharingID, QRCodeImage);
-
- if (QRCodeImage != null) {
- myimage.setImageBitmap(QRCodeImage);
- bottomtext.setVisibility(View.VISIBLE);
-
- // hand.sendEmptyMessageDelayed(1, 60000);
- startTimer();
- } else {
- int errorcode = result.ordinal();
-
- if (8041 <= errorcode && errorcode <= 8050 || errorcode == 8308) {
-
- timeout.setText(getResources().getString(R.string.twosharedtimeout));
- bottomtext.setVisibility(View.GONE);
-
- } else {
- timeout.setText(getResources().getString(R.string.sharedfailed));
- bottomtext.setVisibility(View.GONE);
- }
- }
-
- }
- });
-
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- switch (item.getItemId()) {
- case android.R.id.home:
-
- finish();
- break;
-
- }
- return super.onOptionsItemSelected(item);
- }
-
- Handler hand = new Handler() {
- public void handleMessage(android.os.Message msg) {
-
- // time = time - 1;
-
- if (time > 0) {
- timeout2 = splits[0] + time + splits[1];
-
- timeout.setText(timeout2);
- // hand.sendEmptyMessageDelayed(1, 60000);
- } else {
- timeout.setText(getResources().getString(R.string.twofailed));
- }
-
- };
- };
-
- @Override
- protected void onDestroy() {
- // TODO Auto-generated method stub
- super.onDestroy();
-
- time = 15;
-
- hand.removeMessages(1);
- if (timer != null) {
- timer.cancel();
- }
-
- }
-
- private String timeout2;
- private String[] splits;
- private Timer timer;
-}
diff --git a/src/main/java/com/gizwits/opensource/appkit/sharingdevice/userSharedActivity.java b/src/main/java/com/gizwits/opensource/appkit/sharingdevice/userSharedActivity.java
deleted file mode 100644
index 0323389..0000000
--- a/src/main/java/com/gizwits/opensource/appkit/sharingdevice/userSharedActivity.java
+++ /dev/null
@@ -1,145 +0,0 @@
-package com.gizwits.opensource.appkit.sharingdevice;
-
-import android.content.Context;
-import android.content.Intent;
-import android.content.SharedPreferences;
-import android.graphics.Bitmap;
-import android.os.Bundle;
-import android.text.TextUtils;
-import android.view.MenuItem;
-import android.view.View;
-import android.widget.Button;
-import android.widget.EditText;
-import android.widget.TextView;
-import android.widget.Toast;
-
-import com.gizwits.gizwifisdk.api.GizDeviceSharing;
-import com.gizwits.gizwifisdk.enumration.GizDeviceSharingWay;
-import com.gizwits.gizwifisdk.enumration.GizUserAccountType;
-import com.gizwits.gizwifisdk.enumration.GizWifiErrorCode;
-import com.gizwits.gizwifisdk.listener.GizDeviceSharingListener;
-import com.gizwits.opensource.appkit.CommonModule.GosBaseActivity;
-import com.gizwits.opensource.appkit.CommonModule.GosDeploy;
-import com.gizwits.opensource.appkit.CommonModule.TipsDialog;
-import com.gizwits.opensource.appkit.R;
-
-public class userSharedActivity extends GosBaseActivity {
-
- private String productname;
- private EditText username;
- private int chooseitem = 0;
- private String did;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- // TODO Auto-generated method stub
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_gos_user_shared);
-
- setToolBar(true, R.string.account_shared);
-
- initData();
- initView();
- }
-
- private void initView() {
- TextView usersharedtext = (TextView) findViewById(R.id.usersharedtext);
- Button button = (Button) findViewById(R.id.button);
- button.setBackgroundDrawable(GosDeploy.appConfig_BackgroundColor());
- button.setTextColor(GosDeploy.appConfig_Contrast());
-
- username = (EditText) findViewById(R.id.username);
- usersharedtext.setText(
- getResources().getString(R.string.shared) + productname + getResources().getString(R.string.friends));
- }
-
- private void initData() {
-
- Intent tent = getIntent();
- productname = tent.getStringExtra("productname");
- did = tent.getStringExtra("did");
- }
-
- public void usershared(View v) {
-
- final String usernametext = username.getText().toString();
- if (TextUtils.isEmpty(usernametext)) {
-
- // Toast.makeText(this,
- // getResources().getString(R.string.toast_name_empet), 0).show();
-
- TipsDialog dia = new TipsDialog(this, getResources().getString(R.string.toast_name_empet));
- dia.show();
- return;
- }
-
- SharedPreferences spf = getSharedPreferences("set", Context.MODE_PRIVATE);
- String token = spf.getString("Token", "");
- if (usernametext.length() < 32) {
- if (usernametext.matches("[0-9]+")) {
- GizDeviceSharing.sharingDevice(token, did, GizDeviceSharingWay.GizDeviceSharingByNormal, usernametext,
- GizUserAccountType.GizUserPhone);
- return;
- }
-
- }
- if (usernametext.contains("@")) {
- GizDeviceSharing.sharingDevice(token, did, GizDeviceSharingWay.GizDeviceSharingByNormal, usernametext,
- GizUserAccountType.GizUserEmail);
- return;
- }
- if (usernametext.length() == 32) {
- if (usernametext.matches("[a-zA-Z0-9]+")) {
- GizDeviceSharing.sharingDevice(token, did, GizDeviceSharingWay.GizDeviceSharingByNormal, usernametext,
- GizUserAccountType.GizUserOther);
- return;
- }
-
- }
- Toast.makeText(this, getString(R.string.account_incorrect), Toast.LENGTH_LONG).show();
-
-
- }
-
- @Override
- protected void onResume() {
- super.onResume();
-
- GizDeviceSharing.setListener(new GizDeviceSharingListener() {
-
- @Override
- public void didSharingDevice(GizWifiErrorCode result, String deviceID, int sharingID,
- Bitmap QRCodeImage) {
- super.didSharingDevice(result, deviceID, sharingID, QRCodeImage);
-
- if (result.ordinal() == 0) {
- Toast.makeText(userSharedActivity.this, getResources().getString(R.string.alawyssend), 1).show();
- finish();
- } else if (result == GizWifiErrorCode.GIZ_OPENAPI_GUEST_ALREADY_BOUND) {
- Toast.makeText(userSharedActivity.this, getResources().getString(R.string.account_shared2), toastTime).show();
- } else if (result == GizWifiErrorCode.GIZ_OPENAPI_NOT_FOUND_GUEST) {
- Toast.makeText(userSharedActivity.this, getResources().getString(R.string.user_not_exist), toastTime).show();
- } else if (result == GizWifiErrorCode.GIZ_OPENAPI_CANNOT_SHARE_TO_SELF) {
- Toast.makeText(userSharedActivity.this, getResources().getString(R.string.not_shared_self), toastTime).show();
- } else {
- Toast.makeText(userSharedActivity.this, getResources().getString(R.string.send_failed1), 2).show();
- }
-
- }
-
- });
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- switch (item.getItemId()) {
- case android.R.id.home:
-
- finish();
- break;
-
- }
- return super.onOptionsItemSelected(item);
- }
-
-}
diff --git a/src/main/java/com/gizwits/opensource/appkit/utils/.DS_Store b/src/main/java/com/gizwits/opensource/appkit/utils/.DS_Store
deleted file mode 100644
index 69a3990..0000000
Binary files a/src/main/java/com/gizwits/opensource/appkit/utils/.DS_Store and /dev/null differ
diff --git a/src/main/java/com/gizwits/opensource/appkit/utils/AssetsUtils.java b/src/main/java/com/gizwits/opensource/appkit/utils/AssetsUtils.java
deleted file mode 100644
index 62bcabe..0000000
--- a/src/main/java/com/gizwits/opensource/appkit/utils/AssetsUtils.java
+++ /dev/null
@@ -1,111 +0,0 @@
-package com.gizwits.opensource.appkit.utils;
-
-import android.content.Context;
-import android.util.DisplayMetrics;
-import android.view.WindowManager;
-
-import com.gizwits.opensource.appkit.CommonModule.GosDeploy;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.Locale;
-
-public class AssetsUtils {
-
- public static void assetsDataToSD(String fileOutPutName,
- String fileInPutName, Context context) throws IOException {
- InputStream myInput;
- File file = new File(fileOutPutName);
- if (!file.exists()) {
- file.createNewFile();
- }else {
- return;
- }
- OutputStream myOutput = new FileOutputStream(fileOutPutName);
- myInput = context.getAssets().open(fileInPutName);
- byte[] buffer = new byte[1024];
- int length = myInput.read(buffer);
- while (length > 0) {
- myOutput.write(buffer, 0, length);
- length = myInput.read(buffer);
- }
-
- myOutput.flush();
- myInput.close();
- myOutput.close();
- }
-
-
-
- public static void saveFile(String str) {
- String filePath = null;
-
-
- filePath = GosDeploy.fileOutName;
- try {
- if(filePath!=null){
- File file = new File(filePath);
- if (!file.exists()) {
- File dir = new File(file.getParent());
- dir.mkdirs();
- file.createNewFile();
- }
- FileOutputStream outStream = new FileOutputStream(file);
- outStream.write(str.getBytes());
- outStream.close();
- }
-
- } catch (Exception e) {
- e.printStackTrace();
- }
-}
- /**
- * 将dip或dp值转换为px值,保证尺寸大小不变
- *
- * @param dipValue
- * @param scale
- * (DisplayMetrics类中属性density)
- * @return
- */
- public static int diptopx(Context context, float dipValue) {
- final float scale = context.getResources().getDisplayMetrics().density;
- return (int) (dipValue * scale + 0.5f);
- }
-
-
- /**
- * 将sp值转换为px值,保证文字大小不变
- *
- * @param spValue
- * @param fontScale
- * (DisplayMetrics类中属性scaledDensity)
- * @return
- */
- public static int sptopx(Context context, float spValue) {
- final float fontScale = context.getResources().getDisplayMetrics().scaledDensity;
- return (int) (spValue * fontScale + 0.5f);
- }
-
- public static boolean isZh(Context context) {
- Locale locale = context.getResources().getConfiguration().locale;
- String language = locale.getLanguage();
- if (language.endsWith("zh"))
- return true;
- else
- return false;
- }
-
- public static int getScreenWidth(Context context)
- {
- WindowManager wm = (WindowManager) context
- .getSystemService(Context.WINDOW_SERVICE );
- DisplayMetrics outMetrics = new DisplayMetrics();
- wm.getDefaultDisplay().getMetrics( outMetrics);
- return outMetrics .widthPixels ;
- }
-
-
-}
diff --git a/src/main/java/com/gizwits/opensource/appkit/utils/DateUtil.java b/src/main/java/com/gizwits/opensource/appkit/utils/DateUtil.java
deleted file mode 100644
index a347d0e..0000000
--- a/src/main/java/com/gizwits/opensource/appkit/utils/DateUtil.java
+++ /dev/null
@@ -1,1331 +0,0 @@
-package com.gizwits.opensource.appkit.utils;
-
-import android.annotation.SuppressLint;
-
-import java.io.Serializable;
-import java.text.DateFormat;
-import java.text.ParseException;
-import java.text.ParsePosition;
-import java.text.SimpleDateFormat;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.GregorianCalendar;
-import java.util.TimeZone;
-
-/**
- * 日期操作工具类,主要实现了日期的常用操作。
- *
- * 在工具类中经常使用到工具类的格式化描述,这个主要是一个日期的操作类,所以日志格式主要使用 SimpleDateFormat的定义格式.
- *
- * 格式的意义如下: 日期和时间模式
- * 日期和时间格式由日期和时间模式字符串指定。在日期和时间模式字符串中,未加引号的字母 'A' 到 'Z' 和 'a' 到 'z'
- * 被解释为模式字母,用来表示日期或时间字符串元素。文本可以使用单引号 (') 引起来,以免进行解释。"''"
- * 表示单引号。所有其他字符均不解释;只是在格式化时将它们简单复制到输出字符串,或者在分析时与输入字符串进行匹配。
- *
- * 定义了以下模式字母(所有其他字符 'A' 到 'Z' 和 'a' 到 'z' 都被保留):
- *
- *
- * 字母 |
- * 日期或时间元素 |
- * 表示 |
- * 示例 |
- *
- * |
- *
- * G |
- * Era |
- * 标志符 |
- * Text |
- * AD |
- *
- * |
- *
- * y |
- * 年 |
- * Year |
- * 1996; |
- * 96 |
- *
- * |
- *
- * M |
- * 年中的月份 |
- * Month |
- * July; |
- * Jul; |
- * 07
- * |
- *
- * w |
- * 年中的周数 |
- * Number |
- * 27 |
- *
- * |
- *
- * W |
- * 月份中的周数 |
- * Number |
- * 2 |
- *
- * |
- *
- * D |
- * 年中的天数 |
- * Number |
- * 189 |
- *
- * |
- *
- * d |
- * 月份中的天数 |
- * Number |
- * 10 |
- *
- * |
- *
- * F |
- * 月份中的星期 |
- * Number |
- * 2 |
- *
- * |
- *
- * E |
- * 星期中的天数 |
- * Text |
- * Tuesday; |
- * Tue
- * |
- *
- * a |
- * Am/pm |
- * 标记 |
- * Text |
- * PM |
- *
- * |
- *
- * H |
- * 一天中的小时数(0-23) |
- * Number |
- * 0
- * |
- *
- * k |
- * 一天中的小时数(1-24) |
- * Number |
- * 24 |
- *
- * |
- *
- * K |
- * am/pm |
- * 中的小时数(0-11) |
- * Number |
- * 0 |
- *
- * |
- *
- * h |
- * am/pm |
- * 中的小时数(1-12) |
- * Number |
- * 12 |
- *
- * |
- *
- * m |
- * 小时中的分钟数 |
- * Number |
- * 30 |
- *
- * |
- *
- * s |
- * 分钟中的秒数 |
- * Number |
- * 55 |
- *
- * |
- *
- * S |
- * 毫秒数 |
- * Number |
- * 978 |
- *
- * |
- *
- * z |
- * 时区 |
- * General |
- * time |
- * zone |
- * Pacific |
- * Standard |
- * Time; |
- * PST; |
- * GMT-08:00
- * |
- *
- * Z |
- * 时区 |
- * RFC |
- * 822 |
- * time |
- * zone |
- * -0800 |
- *
- * |
- *
- *
- * 模式字母通常是重复的,其数量确定其精确表示:
- *
- */
-public final class DateUtil implements Serializable {
- /**
- *
- */
- private static final long serialVersionUID = -3098985139095632110L;
-
- private DateUtil() {
- }
-
- /**
- * 格式化日期显示格式yyyy-MM-dd
- *
- * @param sdate
- * 原始日期格式
- * @return yyyy-MM-dd格式化后的日期显示
- */
- public static String dateFormat(String sdate) {
- return dateFormat(sdate, "yyyy-MM-dd");
- }
-
- /**
- * 格式化日期显示格式
- *
- * @param sdate
- * 原始日期格式
- * @param format
- * 格式化后日期格式
- * @return 格式化后的日期显示
- */
- public static String dateFormat(String sdate, String format) {
- SimpleDateFormat formatter = new SimpleDateFormat(format);
- java.sql.Date date = java.sql.Date.valueOf(sdate);
- String dateString = formatter.format(date);
-
- return dateString;
- }
-
- /**
- * 求两个日期相差天数
- *
- * @param sd
- * 起始日期,格式yyyy-MM-dd
- * @param ed
- * 终止日期,格式yyyy-MM-dd
- * @return 两个日期相差天数
- */
- public static long getIntervalDays(String sd, String ed) {
- return ((java.sql.Date.valueOf(ed)).getTime() - (java.sql.Date.valueOf(sd)).getTime()) / (3600 * 24 * 1000);
- }
-
- /**
- * 起始年月yyyy-MM与终止月yyyy-MM之间跨度的月数
- *
- * @return int
- */
- public static int getInterval(String beginMonth, String endMonth) {
- int intBeginYear = Integer.parseInt(beginMonth.substring(0, 4));
- int intBeginMonth = Integer.parseInt(beginMonth.substring(beginMonth.indexOf("-") + 1));
- int intEndYear = Integer.parseInt(endMonth.substring(0, 4));
- int intEndMonth = Integer.parseInt(endMonth.substring(endMonth.indexOf("-") + 1));
-
- return ((intEndYear - intBeginYear) * 12) + (intEndMonth - intBeginMonth) + 1;
- }
-
- public static Date getDate(String sDate, String dateFormat) {
- SimpleDateFormat fmt = new SimpleDateFormat(dateFormat);
- ParsePosition pos = new ParsePosition(0);
-
- return fmt.parse(sDate, pos);
- }
-
- /**
- * 取得当前日期的年份,以yyyy格式返回.
- *
- * @return 当年 yyyy
- */
- public static String getCurrentYear() {
- return getFormatCurrentTime("yyyy");
- }
-
- /**
- * 自动返回上一年。例如当前年份是2007年,那么就自动返回2006
- *
- * @return 返回结果的格式为 yyyy
- */
- public static String getBeforeYear() {
- String currentYear = getFormatCurrentTime("yyyy");
- int beforeYear = Integer.parseInt(currentYear) - 1;
- return "" + beforeYear;
- }
-
- /**
- * 取得当前日期的月份,以MM格式返回.
- *
- * @return 当前月份 MM
- */
- public static String getCurrentMonth() {
- return getFormatCurrentTime("MM");
- }
-
- /**
- * 取得当前日期的天数,以格式"dd"返回.
- *
- * @return 当前月中的某天dd
- */
- public static String getCurrentDay() {
- return getFormatCurrentTime("dd");
- }
-
- /**
- * 返回当前时间字符串。
- *
- * 格式:yyyy-MM-dd
- *
- * @return String 指定格式的日期字符串.
- */
- public static String getCurrentDate() {
- return getFormatDateTime(new Date(), "yyyy-MM-dd");
- }
-
- /**
- * 返回给定时间字符串。
- *
- * 格式:yyyy-MM-dd
- *
- * @param date
- * 日期
- * @return String 指定格式的日期字符串.
- */
- public static String getFormatDate(Date date) {
- return getFormatDateTime(date, "yyyy-MM-dd");
- }
-
- /**
- * 根据制定的格式,返回日期字符串。例如2007-05-05
- *
- * @param format
- * "yyyy-MM-dd" 或者 "yyyy/MM/dd"
- * @return 指定格式的日期字符串。
- */
- public static String getFormatDate(String format) {
- return getFormatDateTime(new Date(), format);
- }
-
- /**
- * 返回当前时间字符串。
- *
- * 格式:yyyy-MM-dd HH:mm:ss
- *
- * @return String 指定格式的日期字符串.
- */
- public static String getCurrentTime() {
- return getFormatDateTime(new Date(), "yyyy-MM-dd HH:mm:ss");
- }
-
- /**
- * 返回给定时间字符串。
- *
- * 格式:yyyy-MM-dd HH:mm:ss
- *
- * @param date
- * 日期
- * @return String 指定格式的日期字符串.
- */
- public static String getFormatTime(Date date) {
- return getFormatDateTime(date, "yyyy-MM-dd HH:mm:ss");
- }
-
- /**
- * 根据给定的格式,返回时间字符串。
- *
- * 格式参照类描绘中说明.
- *
- * @param format
- * 日期格式字符串
- * @return String 指定格式的日期字符串.
- */
- public static String getFormatCurrentTime(String format) {
- return getFormatDateTime(new Date(), format);
- }
-
- /**
- * 根据给定的格式与时间(Date类型的),返回时间字符串
- *
- * @param date
- * 指定的日期
- * @param format
- * 日期格式字符串
- * @return String 指定格式的日期字符串.
- */
- public static String getFormatDateTime(Date date, String format) {
- SimpleDateFormat sdf = new SimpleDateFormat(format);
- return sdf.format(date);
- }
-
- /**
- * 取得指定年月日的日期对象.
- *
- * @param year
- * 年
- * @param month
- * 月注意是从1到12
- * @param day
- * 日
- * @return 一个java.util.Date()类型的对象
- */
- public static Date getDateObj(int year, int month, int day) {
- Calendar c = new GregorianCalendar();
- c.set(year, month - 1, day);
- return c.getTime();
- }
-
- /**
- * 取得指定分隔符分割的年月日的日期对象.
- *
- * @param args
- * 格式为"yyyy-MM-dd"
- * @param split
- * 时间格式的间隔符,例如“-”,“/”
- * @return 一个java.util.Date()类型的对象
- */
- public static Date getDateObj(String args, String split) {
- String[] temp = args.split(split);
- int year = new Integer(temp[0]).intValue();
- int month = new Integer(temp[1]).intValue();
- int day = new Integer(temp[2]).intValue();
- return getDateObj(year, month, day);
- }
-
- /**
- * 取得给定字符串描述的日期对象,描述模式采用pattern指定的格式.
- *
- * @param dateStr
- * 日期描述
- * @param pattern
- * 日期模式
- * @return 给定字符串描述的日期对象。
- */
- public static Date getDateFromString(String dateStr, String pattern) {
- SimpleDateFormat sdf = new SimpleDateFormat(pattern);
- Date resDate = null;
- try {
- resDate = sdf.parse(dateStr);
- } catch (Exception e) {
- e.printStackTrace();
- }
- return resDate;
- }
-
- /**
- * 取得当前Date对象.
- *
- * @return Date 当前Date对象.
- */
- public static Date getDateObj() {
- Calendar c = new GregorianCalendar();
- return c.getTime();
- }
-
- /**
- *
- * @return 当前月份有多少天;
- */
- public static int getDaysOfCurMonth() {
- int curyear = new Integer(getCurrentYear()).intValue(); // 当前年份
- int curMonth = new Integer(getCurrentMonth()).intValue();// 当前月份
- int mArray[] = new int[] { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
- // 判断闰年的情况 ,2月份有29天;
- if ((curyear % 400 == 0) || ((curyear % 100 != 0) && (curyear % 4 == 0))) {
- mArray[1] = 29;
- }
- return mArray[curMonth - 1];
- // 如果要返回下个月的天数,注意处理月份12的情况,防止数组越界;
- // 如果要返回上个月的天数,注意处理月份1的情况,防止数组越界;
- }
-
- /**
- * 根据指定的年月 返回指定月份(yyyy-MM)有多少天。
- *
- * @param time
- * yyyy-MM
- * @return 天数,指定月份的天数。
- */
- public static int getDaysOfCurMonth(final String time) {
- String[] timeArray = time.split("-");
- int curyear = new Integer(timeArray[0]).intValue(); // 当前年份
- int curMonth = new Integer(timeArray[1]).intValue();// 当前月份
- int mArray[] = new int[] { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
- // 判断闰年的情况 ,2月份有29天;
- if ((curyear % 400 == 0) || ((curyear % 100 != 0) && (curyear % 4 == 0))) {
- mArray[1] = 29;
- }
- if (curMonth == 12) {
- return mArray[0];
- }
- return mArray[curMonth - 1];
- // 如果要返回下个月的天数,注意处理月份12的情况,防止数组越界;
- // 如果要返回上个月的天数,注意处理月份1的情况,防止数组越界;
- }
-
- /**
- * 返回指定为年度为year月度为month的月份内,第weekOfMonth个星期的第dayOfWeek天。
- * 00 00 00 01 02 03 04
- * 05 06 07 08 09 10 11
- * 12 13 14 15 16 17 18
- * 19 20 21 22 23 24 25
- * 26 27 28 29 30 31
- * 2006年的第一个周的1到7天为:05 06 07 01 02 03 04
- * 2006年的第二个周的1到7天为:12 13 14 08 09 10 11
- * 2006年的第三个周的1到7天为:19 20 21 15 16 17 18
- * 2006年的第四个周的1到7天为:26 27 28 22 23 24 25
- * 2006年的第五个周的1到7天为:02 03 04 29 30 31 01 。本月没有就自动转到下个月了。
- *
- * @param year
- * 形式为yyyy
- * @param month
- * 形式为MM,参数值在[1-12]。
- * @param weekOfMonth
- * 在[1-6],因为一个月最多有6个周。
- * @param dayOfWeek
- * 数字在1到7之间,包括1和7。1表示星期天,7表示星期六
- * -6为星期日-1为星期五,0为星期六
- * @return int
- */
- public static int getDayofWeekInMonth(String year, String month, String weekOfMonth, String dayOfWeek) {
- Calendar cal = new GregorianCalendar();
- // 在具有默认语言环境的默认时区内使用当前时间构造一个默认的 GregorianCalendar。
- int y = new Integer(year).intValue();
- int m = new Integer(month).intValue();
- cal.clear();// 不保留以前的设置
- cal.set(y, m - 1, 1);// 将日期设置为本月的第一天。
- cal.set(Calendar.DAY_OF_WEEK_IN_MONTH, new Integer(weekOfMonth).intValue());
- cal.set(Calendar.DAY_OF_WEEK, new Integer(dayOfWeek).intValue());
- // System.out.print(cal.get(Calendar.MONTH)+" ");
- // System.out.print("当"+cal.get(Calendar.WEEK_OF_MONTH)+"\t");
- // WEEK_OF_MONTH表示当天在本月的第几个周。不管1号是星期几,都表示在本月的第一个周
- return cal.get(Calendar.DAY_OF_MONTH);
- }
-
- /**
- * 根据指定的年月日小时分秒,返回一个java.Util.Date对象。
- *
- * @param year
- * 年
- * @param month
- * 月 0-11
- * @param date
- * 日
- * @param hourOfDay
- * 小时 0-23
- * @param minute
- * 分 0-59
- * @param second
- * 秒 0-59
- * @return 一个Date对象。
- */
- public static Date getDate(int year, int month, int date, int hourOfDay, int minute, int second) {
- Calendar cal = new GregorianCalendar();
- cal.set(year, month, date, hourOfDay, minute, second);
- return cal.getTime();
- }
-
- /**
- * 根据指定的年、月、日返回当前是星期几。1表示星期天、2表示星期一、7表示星期六。
- *
- * @param year
- * @param month
- * month是从1开始的12结束
- * @param day
- * @return 返回一个代表当期日期是星期几的数字。1表示星期天、2表示星期一、7表示星期六。
- */
- public static int getDayOfWeek(String year, String month, String day) {
- Calendar cal = new GregorianCalendar(new Integer(year).intValue(), new Integer(month).intValue() - 1,
- new Integer(day).intValue());
- return cal.get(Calendar.DAY_OF_WEEK);
- }
-
- /**
- * 根据指定的年、月、日返回当前是星期几。1表示星期天、2表示星期一、7表示星期六。
- *
- * @param date
- * "yyyy/MM/dd",或者"yyyy-MM-dd"
- * @return 返回一个代表当期日期是星期几的数字。1表示星期天、2表示星期一、7表示星期六。
- */
- public static int getDayOfWeek(String date) {
- String[] temp = null;
- if (date.indexOf("/") > 0) {
- temp = date.split("/");
- }
- if (date.indexOf("-") > 0) {
- temp = date.split("-");
- }
- return getDayOfWeek(temp[0], temp[1], temp[2]);
- }
-
- /**
- * 返回当前日期是星期几。例如:星期日、星期一、星期六等等。
- *
- * @param date
- * 格式为 yyyy/MM/dd 或者 yyyy-MM-dd
- * @return 返回当前日期是星期几
- */
- public static String getChinaDayOfWeek(String date) {
- String[] weeks = new String[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
- int week = getDayOfWeek(date);
- return weeks[week - 1];
- }
-
- /**
- * 根据指定的年、月、日返回当前是星期几。1表示星期天、2表示星期一、7表示星期六。
- *
- * @param date
- *
- * @return 返回一个代表当期日期是星期几的数字。1表示星期天、2表示星期一、7表示星期六。
- */
- public static int getDayOfWeek(Date date) {
- Calendar cal = new GregorianCalendar();
- cal.setTime(date);
- return cal.get(Calendar.DAY_OF_WEEK);
- }
-
- /**
- * 返回制定日期所在的周是一年中的第几个周。
- * created by wangmj at 20060324.
- *
- * @param year
- * @param month
- * 范围1-12
- * @param day
- * @return int
- */
- public static int getWeekOfYear(String year, String month, String day) {
- Calendar cal = new GregorianCalendar();
- cal.clear();
- cal.set(new Integer(year).intValue(), new Integer(month).intValue() - 1, new Integer(day).intValue());
- return cal.get(Calendar.WEEK_OF_YEAR);
- }
-
- /**
- * 取得给定日期加上一定天数后的日期对象.
- *
- * @param date
- * 给定的日期对象
- * @param amount
- * 需要添加的天数,如果是向前的天数,使用负数就可以.
- * @return Date 加上一定天数以后的Date对象.
- */
- public static Date getDateAdd(Date date, int amount) {
- Calendar cal = new GregorianCalendar();
- cal.setTime(date);
- cal.add(GregorianCalendar.DATE, amount);
- return cal.getTime();
- }
-
- /**
- * 取得给定日期加上一定天数后的日期对象.
- *
- * @param date
- * 给定的日期对象
- * @param amount
- * 需要添加的天数,如果是向前的天数,使用负数就可以.
- * @param format
- * 输出格式.
- * @return Date 加上一定天数以后的Date对象.
- */
- public static String getFormatDateAdd(Date date, int amount, String format) {
- Calendar cal = new GregorianCalendar();
- cal.setTime(date);
- cal.add(GregorianCalendar.DATE, amount);
- return getFormatDateTime(cal.getTime(), format);
- }
-
- /**
- * 获得当前日期固定间隔天数的日期,如前60天dateAdd(-60)
- *
- * @param amount
- * 距今天的间隔日期长度,向前为负,向后为正
- * @param format
- * 输出日期的格式.
- * @return java.lang.String 按照格式输出的间隔的日期字符串.
- */
- public static String getFormatCurrentAdd(int amount, String format) {
-
- Date d = getDateAdd(new Date(), amount);
-
- return getFormatDateTime(d, format);
- }
-
- /**
- * 取得给定格式的昨天的日期输出
- *
- * @param format
- * 日期输出的格式
- * @return String 给定格式的日期字符串.
- */
- public static String getFormatYestoday(String format) {
- return getFormatCurrentAdd(-1, format);
- }
-
- /**
- * 返回指定日期的前一天。
- *
- * @param sourceDate
- * @param format
- * yyyy MM dd hh mm ss
- * @return 返回日期字符串,形式和formcat一致。
- */
- public static String getYestoday(String sourceDate, String format) {
- return getFormatDateAdd(getDateFromString(sourceDate, format), -1, format);
- }
-
- /**
- * 返回明天的日期,
- *
- * @param format
- * @return 返回日期字符串,形式和formcat一致。
- */
- public static String getFormatTomorrow(String format) {
- return getFormatCurrentAdd(1, format);
- }
-
- /**
- * 返回指定日期的后一天。
- *
- * @param sourceDate
- * @param format
- * @return 返回日期字符串,形式和formcat一致。
- */
- public static String getFormatDateTommorrow(String sourceDate, String format) {
- return getFormatDateAdd(getDateFromString(sourceDate, format), 1, format);
- }
-
- /**
- * 根据主机的默认 TimeZone,来获得指定形式的时间字符串。
- *
- * @param dateFormat
- * @return 返回日期字符串,形式和formcat一致。
- */
- public static String getCurrentDateString(String dateFormat) {
- Calendar cal = Calendar.getInstance(TimeZone.getDefault());
- SimpleDateFormat sdf = new SimpleDateFormat(dateFormat);
- sdf.setTimeZone(TimeZone.getDefault());
-
- return sdf.format(cal.getTime());
- }
-
- /**
- * @deprecated 不鼓励使用。 返回当前时间串 格式:yyMMddhhmmss,在上传附件时使用
- *
- * @return String
- */
- public static String getCurDate() {
- GregorianCalendar gcDate = new GregorianCalendar();
- int year = gcDate.get(GregorianCalendar.YEAR);
- int month = gcDate.get(GregorianCalendar.MONTH) + 1;
- int day = gcDate.get(GregorianCalendar.DAY_OF_MONTH);
- int hour = gcDate.get(GregorianCalendar.HOUR_OF_DAY);
- int minute = gcDate.get(GregorianCalendar.MINUTE);
- int sen = gcDate.get(GregorianCalendar.SECOND);
- String y;
- String m;
- String d;
- String h;
- String n;
- String s;
- y = new Integer(year).toString();
-
- if (month < 10) {
- m = "0" + new Integer(month).toString();
- } else {
- m = new Integer(month).toString();
- }
-
- if (day < 10) {
- d = "0" + new Integer(day).toString();
- } else {
- d = new Integer(day).toString();
- }
-
- if (hour < 10) {
- h = "0" + new Integer(hour).toString();
- } else {
- h = new Integer(hour).toString();
- }
-
- if (minute < 10) {
- n = "0" + new Integer(minute).toString();
- } else {
- n = new Integer(minute).toString();
- }
-
- if (sen < 10) {
- s = "0" + new Integer(sen).toString();
- } else {
- s = new Integer(sen).toString();
- }
-
- return "" + y + m + d + h + n + s;
- }
-
- /**
- * 根据给定的格式,返回时间字符串。 和getFormatDate(String format)相似。
- *
- * @param format
- * yyyy MM dd hh mm ss
- * @return 返回一个时间字符串
- */
- public static String getCurTimeByFormat(String format) {
- Date newdate = new Date(System.currentTimeMillis());
- SimpleDateFormat sdf = new SimpleDateFormat(format);
- return sdf.format(newdate);
- }
-
- /**
- * 获取两个时间串时间的差值,单位为秒
- *
- * @param startTime
- * 开始时间 yyyy-MM-dd HH:mm:ss
- * @param endTime
- * 结束时间 yyyy-MM-dd HH:mm:ss
- * @return 两个时间的差值(秒)
- */
- public static long getDiff(String startTime, String endTime) {
- long diff = 0;
- SimpleDateFormat ft = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- try {
- Date startDate = ft.parse(startTime);
- Date endDate = ft.parse(endTime);
- diff = startDate.getTime() - endDate.getTime();
- diff = diff / 1000;
- } catch (ParseException e) {
- e.printStackTrace();
- }
- return diff;
- }
-
- /**
- * 获取小时/分钟/秒
- *
- * @param second
- * 秒
- * @return 包含小时、分钟、秒的时间字符串,例如3小时23分钟13秒。
- */
- public static String getHour(long second) {
- long hour = second / 60 / 60;
- long minute = (second - hour * 60 * 60) / 60;
- long sec = (second - hour * 60 * 60) - minute * 60;
-
- return hour + "小时" + minute + "分钟" + sec + "秒";
-
- }
-
- /**
- * 返回指定时间字符串。
- *
- * 格式:yyyy-MM-dd HH:mm:ss
- *
- * @return String 指定格式的日期字符串.
- */
- public static String getDateTime(long microsecond) {
- return getFormatDateTime(new Date(microsecond), "yyyy-MM-dd HH:mm:ss");
- }
-
- /**
- * 返回当前时间加实数小时后的日期时间。
- *
- * 格式:yyyy-MM-dd HH:mm:ss
- *
- * @return Float 加几实数小时.
- */
- public static String getDateByAddFltHour(float flt) {
- int addMinute = (int) (flt * 60);
- Calendar cal = new GregorianCalendar();
- cal.setTime(new Date());
- cal.add(GregorianCalendar.MINUTE, addMinute);
- return getFormatDateTime(cal.getTime(), "yyyy-MM-dd HH:mm:ss");
- }
-
- /**
- * 返回指定时间加指定小时数后的日期时间。
- *
- * 格式:yyyy-MM-dd HH:mm:ss
- *
- * @return 时间.
- */
- public static String getDateByAddHour(String datetime, int minute) {
- String returnTime = null;
- Calendar cal = new GregorianCalendar();
- SimpleDateFormat ft = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- Date date;
- try {
- date = ft.parse(datetime);
- cal.setTime(date);
- cal.add(GregorianCalendar.MINUTE, minute);
- returnTime = getFormatDateTime(cal.getTime(), "yyyy-MM-dd HH:mm:ss");
- } catch (ParseException e) {
- e.printStackTrace();
- }
- return returnTime;
-
- }
-
- /**
- * 获取两个时间串时间的差值,单位为小时
- *
- * @param startTime
- * 开始时间 yyyy-MM-dd HH:mm:ss
- * @param endTime
- * 结束时间 yyyy-MM-dd HH:mm:ss
- * @return 两个时间的差值(秒)
- */
- public static int getDiffHour(String startTime, String endTime) {
- long diff = 0;
- SimpleDateFormat ft = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- try {
- Date startDate = ft.parse(startTime);
- Date endDate = ft.parse(endTime);
- diff = startDate.getTime() - endDate.getTime();
- diff = diff / (1000 * 60 * 60);
- } catch (ParseException e) {
- e.printStackTrace();
- }
- return new Long(diff).intValue();
- }
-
- /**
- * 返回年份的下拉框。
- *
- * @param selectName
- * 下拉框名称
- * @param value
- * 当前下拉框的值
- * @param startYear
- * 开始年份
- * @param endYear
- * 结束年份
- * @return 年份下拉框的html
- */
- public static String getYearSelect(String selectName, String value, int startYear, int endYear) {
- int start = startYear;
- int end = endYear;
- if (startYear > endYear) {
- start = endYear;
- end = startYear;
- }
- StringBuffer sb = new StringBuffer("");
- sb.append("");
- return sb.toString();
- }
-
- /**
- * 返回年份的下拉框。
- *
- * @param selectName
- * 下拉框名称
- * @param value
- * 当前下拉框的值
- * @param startYear
- * 开始年份
- * @param endYear
- * 结束年份
- * 例如开始年份为2001结束年份为2005那么下拉框就有五个值。(2001、2002、2003、2004、2005)。
- * @return 返回年份的下拉框的html。
- */
- public static String getYearSelect(String selectName, String value, int startYear, int endYear, boolean hasBlank) {
- int start = startYear;
- int end = endYear;
- if (startYear > endYear) {
- start = endYear;
- end = startYear;
- }
- StringBuffer sb = new StringBuffer("");
- sb.append("");
- return sb.toString();
- }
-
- /**
- * 返回年份的下拉框。
- *
- * @param selectName
- * 下拉框名称
- * @param value
- * 当前下拉框的值
- * @param startYear
- * 开始年份
- * @param endYear
- * 结束年份
- * @param js
- * 这里的js为js字符串。例如 " onchange=\"changeYear()\" "
- * ,这样任何js的方法就可以在jsp页面中编写,方便引入。
- * @return 返回年份的下拉框。
- */
- public static String getYearSelect(String selectName, String value, int startYear, int endYear, boolean hasBlank,
- String js) {
- int start = startYear;
- int end = endYear;
- if (startYear > endYear) {
- start = endYear;
- end = startYear;
- }
- StringBuffer sb = new StringBuffer("");
-
- sb.append("");
- return sb.toString();
- }
-
- /**
- * 返回年份的下拉框。
- *
- * @param selectName
- * 下拉框名称
- * @param value
- * 当前下拉框的值
- * @param startYear
- * 开始年份
- * @param endYear
- * 结束年份
- * @param js
- * 这里的js为js字符串。例如 " onchange=\"changeYear()\" "
- * ,这样任何js的方法就可以在jsp页面中编写,方便引入。
- * @return 返回年份的下拉框。
- */
- public static String getYearSelect(String selectName, String value, int startYear, int endYear, String js) {
- int start = startYear;
- int end = endYear;
- if (startYear > endYear) {
- start = endYear;
- end = startYear;
- }
- StringBuffer sb = new StringBuffer("");
- sb.append("");
- return sb.toString();
- }
-
- /**
- * 获取月份的下拉框
- *
- * @param selectName
- * @param value
- * @param hasBlank
- * @return 返回月份的下拉框。
- */
- public static String getMonthSelect(String selectName, String value, boolean hasBlank) {
- StringBuffer sb = new StringBuffer("");
- sb.append("");
- return sb.toString();
- }
-
- /**
- * 获取月份的下拉框
- *
- * @param selectName
- * @param value
- * @param hasBlank
- * @param js
- * @return 返回月份的下拉框。
- */
- public static String getMonthSelect(String selectName, String value, boolean hasBlank, String js) {
- StringBuffer sb = new StringBuffer("");
- sb.append("");
- return sb.toString();
- }
-
- /**
- * 获取天的下拉框,默认的为1-31。 注意:此方法不能够和月份下拉框进行联动。
- *
- * @param selectName
- * @param value
- * @param hasBlank
- * @return 获得天的下拉框
- */
- public static String getDaySelect(String selectName, String value, boolean hasBlank) {
- StringBuffer sb = new StringBuffer("");
- sb.append("");
- return sb.toString();
- }
-
- /**
- * 获取天的下拉框,默认的为1-31
- *
- * @param selectName
- * @param value
- * @param hasBlank
- * @param js
- * @return 获取天的下拉框
- */
- public static String getDaySelect(String selectName, String value, boolean hasBlank, String js) {
- StringBuffer sb = new StringBuffer("");
- sb.append("");
- return sb.toString();
- }
-
- /**
- * 计算两天之间有多少个周末(这个周末,指星期六和星期天,一个周末返回结果为2,两个为4,以此类推。) (此方法目前用于统计司机用车记录。)
- *
- * @param startDate
- * 开始日期 ,格式"yyyy/MM/dd"
- * @param endDate
- * 结束日期 ,格式"yyyy/MM/dd"
- * @return int
- */
- public static int countWeekend(String startDate, String endDate) {
- int result = 0;
- Date sdate = null;
- Date edate = null;
- sdate = getDateObj(startDate, "/"); // 开始日期
- edate = getDateObj(endDate, "/");// 结束日期
- // 首先计算出都有那些日期,然后找出星期六星期天的日期
- int sumDays = Math.abs(getDiffDays(startDate, endDate));
- int dayOfWeek = 0;
- for (int i = 0; i <= sumDays; i++) {
- dayOfWeek = getDayOfWeek(getDateAdd(sdate, i)); // 计算每过一天的日期
- if (dayOfWeek == 1 || dayOfWeek == 7) { // 1 星期天 7星期六
- result++;
- }
- }
- return result;
- }
-
- /**
- * 返回两个日期之间相差多少天。
- *
- * @param startDate
- * 格式"yyyy/MM/dd"
- * @param endDate
- * 格式"yyyy/MM/dd"
- * @return 整数。
- */
- public static int getDiffDays(String startDate, String endDate) {
- long diff = 0;
- SimpleDateFormat ft = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
- try {
- Date sDate = ft.parse(startDate + " 00:00:00");
- Date eDate = ft.parse(endDate + " 00:00:00");
- diff = eDate.getTime() - sDate.getTime();
- diff = diff / 86400000;// 1000*60*60*24;
- } catch (ParseException e) {
- e.printStackTrace();
- }
- return (int) diff;
-
- }
-
- /**
- * 返回两个日期之间的详细日期数组(包括开始日期和结束日期)。 例如:2007/07/01 到2007/07/03 ,那么返回数组
- * {"2007/07/01","2007/07/02","2007/07/03"}
- *
- * @param startDate
- * 格式"yyyy/MM/dd"
- * @param endDate
- * 格式"yyyy/MM/dd"
- * @return 返回一个字符串数组对象
- */
- public static String[] getArrayDiffDays(String startDate, String endDate) {
- int LEN = 0; // 用来计算两天之间总共有多少天
- // 如果结束日期和开始日期相同
- if (startDate.equals(endDate)) {
- return new String[] { startDate };
- }
- Date sdate = null;
- sdate = getDateObj(startDate, "/"); // 开始日期
- LEN = getDiffDays(startDate, endDate);
- String[] dateResult = new String[LEN + 1];
- dateResult[0] = startDate;
- for (int i = 1; i < LEN + 1; i++) {
- dateResult[i] = getFormatDateTime(getDateAdd(sdate, i), "yyyy/MM/dd");
- }
-
- return dateResult;
- }
-
- public static int getTimeZone() {
-
- TimeZone tz = TimeZone.getDefault();
- String displayName = tz.getDisplayName();
- int dstSavings = tz.getDSTSavings();
- String id = tz.getID();
- String displayName2 = tz.getDisplayName(false, TimeZone.SHORT);
-
- return 1;
- }
-
- /*
- * 当前时间组转换utc时间
- *
- * @param time 当前时间的字符串
- *
- * @param formart 需要转换的格式
- *
- * @return 转换后的字符串
- */
- public static String getUtc(String time, String formart) {
- // 1、获得当前所在的令时偏移量-(zoneOffset + dstOffset)
- String date = null;
- Calendar cal = Calendar.getInstance();
- int zoneOffset = cal.get(Calendar.ZONE_OFFSET);
- int dstOffset = cal.get(Calendar.DST_OFFSET);
- // 2、生成Calendar,并传入对应的时间
- // 使用GMT时区进行时间计算,防止令时切换导致的微调整
- Calendar cal1 = Calendar.getInstance();
- cal1.setTimeZone(TimeZone.getTimeZone("GMT"));
-
- Date stringToDate = stringToDate(time, formart);
- if (stringToDate != null) {
- cal1.setTime(stringToDate);
- cal1.add(Calendar.MILLISECOND, -(zoneOffset + dstOffset));
- // 3、获取对应的UTC时间
-
- date = dateToString(cal1.getTime(), formart);
- }
-
- return date;
-
- }
-
- @SuppressLint("SimpleDateFormat")
- public static Date stringToDate(String str, String formart) {
- DateFormat format = new SimpleDateFormat(formart);
- Date date = null;
- try {
- // Fri Feb 24 00:00:00 CST 2012
- date = format.parse(str);
- } catch (ParseException e) {
- e.printStackTrace();
- }
- // 2012-02-24
- // date = java.sql.Date.valueOf(str);
-
- return date;
- }
-
- @SuppressLint("SimpleDateFormat")
- public static String dateToString(Date date, String type) {
- String str = null;
- SimpleDateFormat format = new SimpleDateFormat(type);
-
- str = format.format(date);
-
- return str;
- }
-
- // utc时间转换当地时间
- public static String utc2Local(String utcTime) {
-
- utcTime = utcTime.substring(0, utcTime.length()-1);
-
- String[] split = utcTime.split("T");
-
- utcTime = split[0]+" "+split[1];
-
- SimpleDateFormat utcFormater = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- utcFormater.setTimeZone(TimeZone.getTimeZone("UTC"));// 时区定义并进行时间获取
- Date gpsUTCDate = null;
- try {
- gpsUTCDate = utcFormater.parse(utcTime);
- } catch (ParseException e) {
- e.printStackTrace();
- }
- SimpleDateFormat localFormater = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- localFormater.setTimeZone(TimeZone.getDefault());
- String localTime = localFormater.format(gpsUTCDate.getTime());
- return localTime;
- }
-
-}
diff --git a/src/main/java/com/gizwits/opensource/appkit/utils/HexStrUtils.java b/src/main/java/com/gizwits/opensource/appkit/utils/HexStrUtils.java
deleted file mode 100644
index 6b53e54..0000000
--- a/src/main/java/com/gizwits/opensource/appkit/utils/HexStrUtils.java
+++ /dev/null
@@ -1,58 +0,0 @@
-package com.gizwits.opensource.appkit.utils;
-
-import java.util.Locale;
-
-public class HexStrUtils {
-
- public static byte[] hexStringToBytes(String hexString) {
- if (hexString == null || hexString.equals("")) {
- return null;
- }
- hexString = hexString.toUpperCase(Locale.getDefault());
- int length = hexString.length() / 2;
- char[] hexChars = hexString.toCharArray();
- byte[] d = new byte[length];
- for (int i = 0; i < length; i++) {
- int pos = i * 2;
- d[i] = (byte) (charToByte(hexChars[pos]) << 4 | charToByte(hexChars[pos + 1]));
- }
- return d;
- }
-
- private static byte charToByte(char c) {
- return (byte) "0123456789ABCDEF".indexOf(c);
- }
-
- /**
- * 数组转换成十六进制字符串
- *
- * @param byte[]
- * @return HexString
- */
- public static final String bytesToHexString(byte[] bArray) {
- if (bArray == null) {
- return "";
- }
- StringBuffer sb = new StringBuffer(bArray.length);
- String sTemp;
- for (int i = 0; i < bArray.length; i++) {
- sTemp = Integer.toHexString(0xFF & bArray[i]);
- if (sTemp.length() < 2)
- sb.append(0);
- sb.append(sTemp.toUpperCase(Locale.getDefault()));
- }
- return sb.toString();
- }
-
- public static final String splitBytesString(String byteString) {
- StringBuilder sb = new StringBuilder();
- for (int i = 0; i < byteString.length(); i++) {
- sb.append(byteString.charAt(i));
- if (sb.length() % 3 == 0 && sb.charAt(sb.length() - 1) != ' ') {
- sb.insert(sb.length() - 1, ' ');
- }
- }
- return sb.toString();
- }
-
-}
\ No newline at end of file
diff --git a/src/main/java/com/gizwits/opensource/appkit/utils/NetUtils.java b/src/main/java/com/gizwits/opensource/appkit/utils/NetUtils.java
deleted file mode 100644
index e0c6389..0000000
--- a/src/main/java/com/gizwits/opensource/appkit/utils/NetUtils.java
+++ /dev/null
@@ -1,226 +0,0 @@
-/**
- * Project Name:Gokit
- * File Name:NetUtils.java
- * Package Name:com.xpg.gokit.utils
- * Date:2014-11-18 10:06:37
- * Copyright (c) 2014~2015 Xtreme Programming Group, Inc.
- * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-package com.gizwits.opensource.appkit.utils;
-
-import android.app.ActivityManager;
-import android.app.ActivityManager.RunningAppProcessInfo;
-import android.content.Context;
-import android.content.pm.PackageInfo;
-import android.content.pm.PackageManager;
-import android.net.ConnectivityManager;
-import android.net.NetworkInfo;
-import android.net.wifi.ScanResult;
-import android.net.wifi.WifiInfo;
-import android.net.wifi.WifiManager;
-import android.text.TextUtils;
-import android.util.Log;
-
-import java.util.List;
-
-/**
- * 网络工具类.
- *
- * @author Sunny Ding
- *
- * *
- */
-public class NetUtils {
-
- /**
- * 判断当前手机是否连上Wifi.
- *
- * @param context
- * 上下文
- * @return boolean 是否连上网络
- *
- * *
- */
- static public boolean isWifiConnected(Context context) {
- if (context != null) {
- ConnectivityManager mConnectivityManager = (ConnectivityManager) context
- .getSystemService(Context.CONNECTIVITY_SERVICE);
- NetworkInfo mWiFiNetworkInfo = mConnectivityManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
- if (mWiFiNetworkInfo != null) {
- if (mWiFiNetworkInfo.isAvailable()) {
- return mWiFiNetworkInfo.isConnected();
- } else {
- return false;
- }
- }
- }
- return false;
- }
-
- /**
- * 判断当前手机的网络是否可用.
- *
- * @param context
- * 上下文
- * @return boolean 是否连上网络
- *
- * *
- */
- static public boolean isMobileConnected(Context context) {
- if (context != null) {
- ConnectivityManager mConnectivityManager = (ConnectivityManager) context
- .getSystemService(Context.CONNECTIVITY_SERVICE);
- NetworkInfo mMobileNetworkInfo = mConnectivityManager.getNetworkInfo(ConnectivityManager.TYPE_MOBILE);
- if (mMobileNetworkInfo != null) {
- if (mMobileNetworkInfo.isAvailable()) {
- return mMobileNetworkInfo.isConnected();
- } else {
- return false;
- }
- }
- }
- return false;
- }
-
- /**
- * 判断当前网络是手机网络还是WIFI.
- *
- * @param context
- * 上下文
- * @return ConnectedType 数据类型
- *
- * *
- */
- public static int getConnectedType(Context context) {
- if (context != null) {
- ConnectivityManager mConnectivityManager = (ConnectivityManager) context
- .getSystemService(Context.CONNECTIVITY_SERVICE);
- // 获取代表联网状态的NetWorkInfo对象
- NetworkInfo mNetworkInfo = mConnectivityManager.getActiveNetworkInfo();
- // 判断NetWorkInfo对象是否为空;判断当前的网络连接是否可用
- if (mNetworkInfo != null && mNetworkInfo.isAvailable()) {
- return mNetworkInfo.getType();
- }
- }
- return -1;
- }
-
- /**
- * 获取当前WIFI的SSID.
- *
- * @param context
- * 上下文
- * @return ssid
- *
- * *
- */
- public static String getCurentWifiSSID(Context context) {
- String ssid = "";
- if (context != null) {
- WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
- WifiInfo wifiInfo = wifiManager.getConnectionInfo();
-
- if (wifiInfo != null) {
- ssid = wifiInfo.getSSID();
-
- if (!TextUtils.isEmpty(ssid) && ssid.substring(0, 1).equals("\"")
- && ssid.substring(ssid.length() - 1).equals("\"")) {
- ssid = ssid.substring(1, ssid.length() - 1);
- }
- }
-
- }
- return ssid;
- }
-
- /**
- * 用来获得手机扫描到的所有wifi的信息.
- *
- * @param c
- * 上下文
- * @return the current wifi scan result
- */
- public static List getCurrentWifiScanResult(Context c) {
- WifiManager wifiManager = (WifiManager) c.getSystemService(Context.WIFI_SERVICE);
- wifiManager.startScan();
-
- return wifiManager.getScanResults();
-
- }
-
- public interface WifiSsidList {
-
- public void ssidList(List list);
- }
-
- static public String getConnectWifiSsid(Context c) {
- String ssid = "";
- WifiManager wifiManager = (WifiManager) c.getSystemService(Context.WIFI_SERVICE);
- WifiInfo wifiInfo = wifiManager.getConnectionInfo();
- if (wifiInfo != null) {
- ssid = wifiInfo.getSSID();
- }
- return ssid;
- }
-
- // 以下是获得版本信息的工具方法
-
- // 版本名
- public static String getVersionName(Context context) {
- return getPackageInfo(context).versionName;
- }
-
- // 版本号
- public static int getVersionCode(Context context) {
- return getPackageInfo(context).versionCode;
- }
-
- private static PackageInfo getPackageInfo(Context context) {
- PackageInfo pi = null;
-
- try {
- PackageManager pm = context.getPackageManager();
- pi = pm.getPackageInfo(context.getPackageName(), PackageManager.GET_CONFIGURATIONS);
-
- return pi;
- } catch (Exception e) {
- e.printStackTrace();
- }
-
- return pi;
- }
-
- // 检测android 应用在前台还是后台
-
- public static boolean isBackground(Context context) {
- ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
- List appProcesses = activityManager.getRunningAppProcesses();
- for (RunningAppProcessInfo appProcess : appProcesses) {
- if (appProcess.processName.equals(context.getPackageName())) {
- /*
- * BACKGROUND=400 EMPTY=500 FOREGROUND=100 GONE=1000
- * PERCEPTIBLE=130 SERVICE=300 ISIBLE=200
- */
- Log.i(context.getPackageName(), "此appimportace =" + appProcess.importance
- + ",context.getClass().getName()=" + context.getClass().getName());
- if (appProcess.importance != RunningAppProcessInfo.IMPORTANCE_FOREGROUND) {
- Log.i(context.getPackageName(), "处于后台" + appProcess.processName);
- return true;
- } else {
- Log.i(context.getPackageName(), "处于前台" + appProcess.processName);
- return false;
- }
- }
- }
- return false;
- }
-}
diff --git a/src/main/java/com/gizwits/opensource/appkit/utils/ReflectionUtils.java b/src/main/java/com/gizwits/opensource/appkit/utils/ReflectionUtils.java
deleted file mode 100644
index 592b199..0000000
--- a/src/main/java/com/gizwits/opensource/appkit/utils/ReflectionUtils.java
+++ /dev/null
@@ -1,138 +0,0 @@
-package com.gizwits.opensource.appkit.utils;
-
-import android.text.TextUtils;
-
-import java.lang.reflect.Field;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-
-/**
- * Created by zhaopan on 2016/11/7.
- * e-mail: kangqiao610@gmail.com
- */
-public class ReflectionUtils {
-
- /**
- * 循环向上转型, 获取对象的 DeclaredMethod
- *
- * @param object : 子类对象
- * @param methodName : 父类中的方法名
- * @param parameterTypes : 父类中的方法参数类型
- * @return 父类中的方法对象
- */
-
- public static Method getDeclaredMethod(Object object, String methodName, Class>... parameterTypes) {
- Method method = null;
-
- for (Class> clazz = object.getClass(); clazz != Object.class; clazz = clazz.getSuperclass()) {
- try {
- method = clazz.getDeclaredMethod(methodName, parameterTypes);
- return method;
- } catch (Exception e) {
- //这里甚么都不要做!并且这里的异常必须这样写,不能抛出去。
- //如果这里的异常打印或者往外抛,则就不会执行clazz = clazz.getSuperclass(),最后就不会进入到父类中了
-
- }
- }
-
- return null;
- }
-
- /**
- * 直接调用对象方法, 而忽略修饰符(private, protected, default)
- *
- * @param object : 子类对象
- * @param methodName : 父类中的方法名
- * @param parameterTypes : 父类中的方法参数类型
- * @param parameters : 父类中的方法参数
- * @return 父类中方法的执行结果
- */
-
- public static Object invokeMethod(Object object, String methodName, Class>[] parameterTypes,
- Object[] parameters) {
- //根据 对象、方法名和对应的方法参数 通过反射 调用上面的方法获取 Method 对象
- Method method = getDeclaredMethod(object, methodName, parameterTypes);
-
- //抑制Java对方法进行检查,主要是针对私有方法而言
- method.setAccessible(true);
-
- try {
- if (null != method) {
-
- //调用object 的 method 所代表的方法,其方法的参数是 parameters
- return method.invoke(object, parameters);
- }
- } catch (IllegalArgumentException e) {
- e.printStackTrace();
- } catch (IllegalAccessException e) {
- e.printStackTrace();
- } catch (InvocationTargetException e) {
- e.printStackTrace();
- }
-
- return null;
- }
-
- /**
- * 循环向上转型, 获取对象的 DeclaredField
- *
- * @param object : 子类对象
- * @param fieldName : 父类中的属性名
- * @return 父类中的属性对象
- */
-
- public static Field getDeclaredField(Object object, String fieldName) {
- Field field = null;
-
- Class> clazz = object.getClass();
-
- for (; clazz != Object.class; clazz = clazz.getSuperclass()) {
- try {
- field = clazz.getDeclaredField(fieldName);
- return field;
- } catch (Exception e) {
- //这里甚么都不要做!并且这里的异常必须这样写,不能抛出去。
- //如果这里的异常打印或者往外抛,则就不会执行clazz = clazz.getSuperclass(),最后就不会进入到父类中了
-
- }
- }
-
- return null;
- }
-
- public static Object getFieldValue(Object obj, String fieldName) {
- if (obj == null || TextUtils.isEmpty(fieldName)) {
- return null;
- }
-
- Class> clazz = obj.getClass();
- while (clazz != Object.class) {
- try {
- Field field = clazz.getDeclaredField(fieldName);
- field.setAccessible(true);
- return field.get(obj);
- } catch (Exception e) {
- }
- clazz = clazz.getSuperclass();
- }
- return null;
- }
-
- public static void setFieldValue(Object obj, String fieldName, Object value) {
- if (obj == null || TextUtils.isEmpty(fieldName)) {
- return;
- }
- Class> clazz = obj.getClass();
- while (clazz != Object.class) {
- try {
- Field field = clazz.getDeclaredField(fieldName);
- field.setAccessible(true);
- field.set(obj, value);
- return;
- } catch (Exception e) {
- }
- clazz = clazz.getSuperclass();
- }
- }
-}
-
diff --git a/src/main/java/com/gizwits/opensource/appkit/utils/SkxDrawableHelper.java b/src/main/java/com/gizwits/opensource/appkit/utils/SkxDrawableHelper.java
deleted file mode 100644
index 8545e03..0000000
--- a/src/main/java/com/gizwits/opensource/appkit/utils/SkxDrawableHelper.java
+++ /dev/null
@@ -1,66 +0,0 @@
-package com.gizwits.opensource.appkit.utils;
-
-import android.content.res.ColorStateList;
-import android.graphics.drawable.Drawable;
-import android.support.v4.graphics.drawable.DrawableCompat;
-
-public class SkxDrawableHelper {
-
- /**
- * 对目标Drawable 进行着色
- *
- * @param drawable 目标Drawable
- * @param color 着色的颜色值
- * @return 着色处理后的Drawable
- */
- public static Drawable tintDrawable(Drawable drawable, int color) {
- // 获取此drawable的共享状态实例
- Drawable wrappedDrawable = getCanTintDrawable(drawable);
- // 进行着色
- DrawableCompat.setTint(wrappedDrawable, color);
- return wrappedDrawable;
- }
-
- /**
- * 对目标Drawable 进行着色。
- * 通过ColorStateList 指定单一颜色
- *
- * @param drawable 目标Drawable
- * @param color 着色值
- * @return 着色处理后的Drawable
- */
- public static Drawable tintListDrawable(Drawable drawable, int color) {
- return tintListDrawable(drawable, ColorStateList.valueOf(color));
- }
-
- /**
- * 对目标Drawable 进行着色
- *
- * @param drawable 目标Drawable
- * @param colors 着色值
- * @return 着色处理后的Drawable
- */
- public static Drawable tintListDrawable( Drawable drawable, ColorStateList colors) {
- Drawable wrappedDrawable = getCanTintDrawable(drawable);
- // 进行着色
- DrawableCompat.setTintList(wrappedDrawable, colors);
- return wrappedDrawable;
- }
-
- /**
- * 获取可以进行tint 的Drawable
- *
- * 对原drawable进行重新实例化 newDrawable()
- * 包装 warp()
- * 可变操作 mutate()
- *
- * @param drawable 原始drawable
- * @return 可着色的drawable
- */
- private static Drawable getCanTintDrawable(Drawable drawable) {
- // 获取此drawable的共享状态实例
- Drawable.ConstantState state = drawable.getConstantState();
- // 对drawable 进行重新实例化、包装、可变操作
- return DrawableCompat.wrap(state == null ? drawable : state.newDrawable()).mutate();
- }
-}
\ No newline at end of file
diff --git a/src/main/java/com/gizwits/opensource/appkit/utils/ToolUtils.java b/src/main/java/com/gizwits/opensource/appkit/utils/ToolUtils.java
deleted file mode 100644
index 577e18a..0000000
--- a/src/main/java/com/gizwits/opensource/appkit/utils/ToolUtils.java
+++ /dev/null
@@ -1,146 +0,0 @@
-package com.gizwits.opensource.appkit.utils;
-
-import android.content.Context;
-import android.content.res.Resources;
-import android.graphics.Color;
-import android.graphics.drawable.Drawable;
-import android.widget.Toast;
-
-import com.gizwits.opensource.appkit.CommonModule.GosDeploy;
-import com.gizwits.opensource.appkit.R;
-
-import org.json.JSONArray;
-import org.json.JSONException;
-import org.json.JSONObject;
-
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * Created by admin on 2017/7/25.
- */
-
-public class ToolUtils {
- public static float getHue(int color) {
- float[] HSV = new float[3];
- Color.colorToHSV(color, HSV);
- return (HSV[0] * 255 / 360);
- }
-
- public static int getInnerColor(float hue) {
- float[] HSV = new float[3];
- HSV[0] = hue * 360 / 255;
- HSV[1] = 255;
- HSV[2] = 255;
- return Color.HSVToColor(HSV);
- }
-
- private static long lastClickTime = 0;
- public static final int MIN_CLICK_DELAY_TIME = 800;
-
- public static boolean noDoubleClick() {
- long currentTime = Calendar.getInstance().getTimeInMillis();
- if (currentTime - lastClickTime > MIN_CLICK_DELAY_TIME) {
- lastClickTime = currentTime;
- return true;
- } else {
- return false;
- }
- }
-
- public static List