This commit is contained in:
jinyuer
2020-08-14 17:07:43 +08:00
parent fa1413fc30
commit fda8305a13
28 changed files with 1686 additions and 287 deletions

View File

@@ -24,7 +24,7 @@ public class BottomNavigationViewHelper {
for (int i = 0; i < menuView.getChildCount(); i++) {
BottomNavigationItemView item = (BottomNavigationItemView) menuView.getChildAt(i);
//noinspection RestrictedApi
item.setShiftingMode(false);
// item.setShiftingMode(false);
// set once again checked value, so view will be updated
//noinspection RestrictedApi
item.setChecked(item.getItemData().isChecked());

View File

@@ -0,0 +1,42 @@
package utils;
import android.content.Context;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
/**
* @author yiw
* @ClassName: CommonUtils
* @Description:
* @date 2015-12-28 下午4:16:01
*/
public class CommonUtils {
public static void showSoftInput(Context context, View view) {
InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
imm.toggleSoftInput(0, InputMethodManager.HIDE_NOT_ALWAYS);
//imm.showSoftInput(view, InputMethodManager.SHOW_FORCED);
}
public static void hideSoftInput(Context context, View view) {
InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(view.getWindowToken(), 0); //强制隐藏键盘
}
public static boolean isShowSoftInput(Context context) {
InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
//获取状态信息
return imm.isActive();//true 打开
}
/**
* 是否显示,显示则关闭,没显示则显示
*
* @param context
*/
public static void isShow(Context context) {
InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
imm.toggleSoftInput(0, InputMethodManager.HIDE_NOT_ALWAYS);
}
}

View File

@@ -0,0 +1,480 @@
package utils;
import android.text.TextUtils;
import android.util.Log;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.Locale;
/**
* 日期2017.01.12
* <p>
* 作者chigan
* <p>
* 描述:目期工具类
*/
public class DateUtils {
private static final String TAG = "DateUtils";
public static String getTimeStart(String timeString) {
String timeStamp = "";
SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日");
Date d = new Date();
try {
d = sdf.parse(timeString);
long l = d.getTime();
if (String.valueOf(l).length() > 10) {
l = l / 10;
}
timeStamp = String.valueOf(l);
} catch (Exception e) {
}
return timeStamp;
}
public static String getTimeEnd(String timeString) {
String timeStamp = "";
SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日HH:mm");
Date d = new Date();
try {
d = sdf.parse((timeString + "23:59"));
long l = d.getTime();
if (String.valueOf(l).length() > 10) {
l = l / 10;
}
timeStamp = String.valueOf(l);
} catch (Exception e) {
}
return timeStamp;
}
public static String getDate(String mtime) {
return getTimeStrByLong(dataOne(mtime));
}
/**
* 获取时间串
*
* @param longStr 秒
* @return 1月前 1周前 1天前 1小时前 1分钟前
*/
public static String getTimeStrByLong(String longStr) {
try {
Calendar calendar = new GregorianCalendar();
Date date = calendar.getTime();
Long clv = date.getTime();
Long olv = Long.valueOf(longStr);
calendar.setTimeInMillis(olv); // 转毫秒
Date date2 = calendar.getTime();
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String curtime = format.format(date2);
Long belv = clv - olv;
String retStr = "";
// 24 * 60 * 60 * 1000;
Long daylong = Long.valueOf("86400000");
Long hourlong = Long.valueOf("3600000");
Long minlong = Long.valueOf("60000");
Long seclong = Long.valueOf("1000");
if (belv >= daylong * 30) {// 月
Long mul = belv / (daylong * 30);
retStr = retStr + mul + "";
belv = belv % (daylong * 30);
return retStr + "";
}
if (belv >= daylong * 7) {// 周
Long mul = belv / (daylong * 7);
retStr = retStr + mul + "";
belv = belv % (daylong * 7);
return retStr + "";
}
if (belv >= daylong) {// 天
Long mul = belv / daylong;
retStr = retStr + mul + "";
belv = belv % daylong;
return retStr + "";
}
if (belv >= hourlong) {// 时
Long mul = belv / hourlong;
retStr = retStr + mul + "小时";
belv = belv % hourlong;
return retStr + "";
}
if (belv >= minlong) {// 分
Long mul = belv / minlong;
retStr = retStr + mul + "分钟";
return retStr + "";
}
if (belv >= seclong) {
Long mul = belv / seclong;
retStr = retStr + mul + "";
return retStr + "";
}
} catch (Exception e) {
Log.e("ttterr", longStr);
return "";
}
return "";
}
/**
* 返回xxxx年-xx月xx日 xx时:xx分xx秒
*
* @param strMis 毫秒的字符串形式
* @return
*/
public static String getStringDataMilli(String strMis) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
return sdf.format(new Date(Long.parseLong(strMis)));
}
/**
* 返回xx月xx日 xx时:xx分
*
* @return
*/
public static String getStringDataMilliNoy() {
SimpleDateFormat sdf = new SimpleDateFormat("MM-dd HH:mm");
return sdf.format(new Date(System.currentTimeMillis()));
}
/**
* 返回xxxx年-xx月xx日 xx时:xx分xx秒
*
* @param strSecond 秒的字符串形式所以要*1000
* @return
*/
public static String getStringDataSecond(String strSecond) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
return sdf.format(new Date(Long.parseLong(strSecond) * 1000));
}
/**
* 返回xxxx年-xx月xx日
*
* @param strMis
* @return
*/
public static String getStringYMD(String strMis) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
if (TextUtils.isEmpty(strMis)) {
return "";
}
return sdf.format(new Date(Long.parseLong(strMis) * 1000));
}
/**
* 返回xxxx年-xx月xx日
*
* @param date
* @return
*/
public static String getStringYMD(Date date) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
return sdf.format(date);
}
/**
* 返回xxxx年-xx月xx日 xx时xx分
*
* @param strMis
* @return
*/
public static String getStringYMDHM(String strMis) {
// Log.d(TAG, "getStringYMDHM: " + strMis);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
return sdf.format(new Date(Long.parseLong(strMis) * 1000));
}
/**
* 返回xxxx年-xx月xx日 xx时xx分
*
* @param date
* @return
*/
public static String getStringYMDHM(Date date) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
return sdf.format(date);
}
/**
* 获取当前是哪一天
*
* @return
*/
public static int getCurrentDay() {
SimpleDateFormat sdf = new SimpleDateFormat("dd");
return Integer.parseInt(sdf.format(new Date(System.currentTimeMillis())));
}
/**
* 获取当前是哪个月
*
* @return
*/
public static int getCurrentMonth() {
SimpleDateFormat sdf = new SimpleDateFormat("MM");
return Integer.parseInt(sdf.format(new Date(System.currentTimeMillis()))) - 1;
}
/**
* 获取当前是哪一年
*
* @return
*/
public static int getCurrentYear() {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy");
return Integer.parseInt(sdf.format(new Date(System.currentTimeMillis())));
}
/**
* 根据一个时间磋,获取是多少天
*
* @param time
* @return
*/
public static int getDay(long time) {
long day = (time * 1000) / (24 * 60 * 60 * 1000);
return (int) day;
}
/**
* 获取时间戳 是多少分钟
*
* @param timestamp
* @return
*/
public static int getMinute(long timestamp) {
long minute = timestamp * 1000 / (60 * 1000);
return (int) minute;
}
/**
* 计算多少天开始
*
* @param starTime 时间轴
* @return 天数
*/
public static int beginDate(String starTime) {
long now = System.currentTimeMillis();
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH");
String d = format.format(Long.valueOf(starTime) * 1000);
Long start = null;
try {
start = format.parse(d).getTime();
} catch (ParseException e) {
e.printStackTrace();
}
long b = start - now;
float f = (float) (b * 1.0 / 60 / 60 / 24 / 1000);
double days = (b * 1.0 / 60 / 60 / 24 / 1000);
return (int) Math.ceil(days);
}
/**
* 返回一个时间轴和现在的相隔时间 如果时间在当前时间之前则返回空
*
* @param longStr
* @return
*/
public static String getTimeStrToBegin(String longStr) {
Calendar calendar = new GregorianCalendar();
Date date = calendar.getTime();
Long clv = date.getTime();
Long olv = Long.valueOf(longStr);
calendar.setTimeInMillis(olv); // 转毫秒
Date date2 = calendar.getTime();
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String curtime = format.format(date2);
Long belv = olv * 1000 - clv;
String retStr = "";
// 24 * 60 * 60 * 1000;
Long daylong = Long.valueOf("86400000");
Long hourlong = Long.valueOf("3600000");
Long minlong = Long.valueOf("60000");
Long seclong = Long.valueOf("1000");
if (belv >= daylong * 30) {// 月
Long mul = belv / (daylong * 30);
retStr = retStr + mul + "";
belv = belv % (daylong * 30);
return retStr;
}
if (belv >= daylong * 7) {// 周
Long mul = belv / (daylong * 7);
retStr = retStr + mul + "";
belv = belv % (daylong * 7);
return retStr;
}
if (belv >= daylong) {// 天
Long mul = belv / daylong;
retStr = retStr + mul + "";
belv = belv % daylong;
return retStr;
}
if (belv >= hourlong) {// 时
Long mul = belv / hourlong;
retStr = retStr + mul + "小时";
belv = belv % hourlong;
return retStr;
}
if (belv >= minlong) {// 分
Long mul = belv / minlong;
retStr = retStr + mul + "分钟";
return retStr;
}
if (belv >= seclong) {
Long mul = belv / seclong;
retStr = retStr + mul + "";
return retStr;
}
return "";
}
/**
* 调此方法输入所要转换的时间输入例如("2014-06-14-16-09-00")返回时间戳
*
* @param time
* @return
*/
public static String dataOne(String time) {
SimpleDateFormat sdr = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss",
Locale.CHINA);
Date date = null;
try {
date = sdr.parse(time);
return date.getTime() + "";
} catch (ParseException e) {
e.printStackTrace();
}
return "";
}
public static Long getUnitDate(String time){
SimpleDateFormat sdr = new SimpleDateFormat("yyyy-MM-dd",
Locale.CHINA);
Date date = null;
try {
date = sdr.parse(time);
return date.getTime() ;
} catch (ParseException e) {
e.printStackTrace();
}
return 0l;
}
public static String getSpecifiedDayAfter(String specifiedDay) {
Calendar c = Calendar.getInstance();
Date date = null;
try {
date = new SimpleDateFormat("yy-MM-dd").parse(specifiedDay);
} catch (ParseException e) {
e.printStackTrace();
}
c.setTime(date);
int day = c.get(Calendar.DATE);
c.set(Calendar.DATE, day + 1);
String dayAfter = new SimpleDateFormat("yyyy-MM-dd")
.format(c.getTime());
return dayAfter;
}
/**
* 月份+i
*
* @param i
* @return
*/
public static String getmonthAdd(int i, String specifiedDay) {
Calendar c = Calendar.getInstance();
Date date = null;
try {
date = new SimpleDateFormat("yy-MM-dd").parse(specifiedDay);
} catch (ParseException e) {
e.printStackTrace();
}
c.setTime(date);
int month = c.get(Calendar.MONTH);
c.set(Calendar.MONTH, month + i);
String dayAfter = new SimpleDateFormat("yyyy-MM-dd")
.format(c.getTime());
return dayAfter;
}
public static Calendar getParkingStart(String info) {
Calendar c = Calendar.getInstance();
Date date = null;
try {
date = new SimpleDateFormat("yy-MM-dd").parse(DateUtils.getSpecifiedDayAfter(info));
} catch (ParseException e) {
e.printStackTrace();
}
c.setTime(date);
return c;
}
public static Calendar getParkingMaxEnd(String info) {
Calendar c = Calendar.getInstance();
Date date = null;
try {
date = new SimpleDateFormat("yy-MM-dd").parse(DateUtils.getSpecifiedDayAfter(info));
} catch (ParseException e) {
e.printStackTrace();
}
c.setTime(date);
int month = c.get(Calendar.MONTH);
c.set(Calendar.MONTH, month + 12);
return c;
}
public static String getUnit(String info) {
if (TextUtils.isEmpty(info)) {
return "";
}
boolean numericZidai = isNumericZidai(info);
if (numericZidai) {
return info + "单元";
} else {
return info;
}
}
public static boolean isNumericZidai(String str) {
for (int i = 0; i < str.length(); i++) {
System.out.println(str.charAt(i));
if (!Character.isDigit(str.charAt(i))) {
return false;
}
}
return true;
}
}

View File

@@ -1,12 +1,14 @@
package utils;
import android.app.Activity;
import android.content.Context;
import android.inputmethodservice.Keyboard;
import android.inputmethodservice.KeyboardView;
import android.text.Editable;
import android.text.InputType;
import android.view.View;
import android.view.WindowManager;
import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;
import com.sl.house_property.R;
@@ -144,6 +146,16 @@ public class KeyboardUtil {
mKeyboardView.setVisibility(View.VISIBLE);
}
}
/**
* 显示软键盘
*
* @param context 当前Activity
*/
public static void showSoftInput(Context context) {
InputMethodManager inputMethodManager =
(InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
inputMethodManager.toggleSoftInput(0, InputMethodManager.HIDE_NOT_ALWAYS);
}
/**
* 软键盘隐藏

View File

@@ -5,12 +5,18 @@ import android.graphics.Bitmap;
import android.widget.ImageView;
import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import com.lzy.ninegrid.NineGridView;
import com.sl.house_property.R;
public class NineImageLoader implements NineGridView.ImageLoader {
@Override
public void onDisplayImage(Context context, ImageView imageView, String url) {
Glide.with(context).load(url).into(imageView);
RequestOptions requestOptions = new RequestOptions();
requestOptions.placeholder(R.mipmap.icon_default_rectangle);
requestOptions.error(R.mipmap.icon_default_rectangle);
requestOptions .skipMemoryCache(false);
Glide.with(context).load(url).apply(requestOptions).into(imageView);
}
@Override

View File

@@ -0,0 +1,42 @@
package utils;
import android.app.Activity;
import android.content.Context;
import android.os.IBinder;
import android.view.MotionEvent;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;
public class UtilHelpers {
/**
* 根据传入控件的坐标和用户的焦点坐标,判断是否隐藏键盘,如果点击的位置在控件内,则不隐藏键盘
*
* @param view 控件view
* @param event 焦点位置
* @return 是否隐藏
*/
public static boolean hideKeyboard(MotionEvent event, View view,
Activity activity) {
try {
if (view != null && view instanceof EditText) {
int[] location = {0, 0};
view.getLocationInWindow(location);
int left = location[0], top = location[1], right = left
+ view.getWidth(), bootom = top + view.getHeight();
// 判断焦点位置坐标是否在空间内,如果位置在控件外,则隐藏键盘
if (event.getRawX() < left || event.getRawX() > right
|| event.getY() < top || event.getRawY() > bootom) {
// // 隐藏键盘
return true;
}
}
} catch (Exception e) {
e.printStackTrace();
}
return false;
}
}