This commit is contained in:
renjianbo0118
2021-03-10 23:48:19 +08:00
parent 90471f4849
commit b5fb4c1a2b
13 changed files with 1029 additions and 52 deletions

View File

@@ -142,6 +142,10 @@ android {
implementation 'com.zhihu.android:matisse:0.5.2-beta2'
implementation 'com.tencent.bugly:crashreport:latest.release' //其中latest.release指代最新Bugly SDK版本号也可以指定明确的版本号例如2.2.0
implementation 'com.tencent.mm.opensdk:wechat-sdk-android-without-mta:+'
//引入ormlite
implementation 'com.j256.ormlite:ormlite-core:5.1'
implementation 'com.j256.ormlite:ormlite-android:5.1'
}
}

View File

@@ -8,6 +8,7 @@ import android.support.multidex.MultiDex;
import android.util.Log;
import com.lzy.ninegrid.NineGridView;
import com.sl.house_property.db.dao.DataBaseHelper;
import com.tencent.bugly.Bugly;
import java.util.LinkedList;
@@ -74,7 +75,7 @@ public class MyApplication extends Application{
StrictMode.setVmPolicy(builder.build());
NineGridView.setImageLoader(new NineImageLoader());
DataBaseHelper.initOrmLite(this);
}

View File

@@ -0,0 +1,42 @@
package com.sl.house_property.db;
import com.j256.ormlite.field.DatabaseField;
import com.j256.ormlite.table.DatabaseTable;
import java.io.Serializable;
@DatabaseTable(tableName = "tab_comment")
public class CommentBeanData extends DbBean implements Serializable {
@DatabaseField(id = true,columnName = "Id")
private String id;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getComment() {
return comment;
}
public void setComment(String comment) {
this.comment = comment;
}
@DatabaseField(columnName = "comment")
private String comment;
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
@DatabaseField(columnName = "type")
private String type;//1.评论话术 2.私信话术 3.直播话术 4.回访话术 5.首关话术
}

View File

@@ -0,0 +1,4 @@
package com.sl.house_property.db;
public class DbBean {
}

View File

@@ -0,0 +1,120 @@
package com.sl.house_property.db.dao;
import android.content.Context;
import android.database.SQLException;
import com.j256.ormlite.dao.Dao;
import com.sl.house_property.db.CommentBeanData;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class CommentDao {
private static Dao<CommentBeanData, Integer> userAccountDao;
public CommentDao(Context mContext) {
DataBaseHelper dataBaseHelper = DataBaseHelper.getInstance(mContext);
try {
try {
userAccountDao = dataBaseHelper.getDao(CommentBeanData.class);
} catch (java.sql.SQLException e) {
e.printStackTrace();
}
} catch (SQLException e) {
e.printStackTrace();
}
}
public long addInsert(CommentBeanData userData) {
int id = 0;
try {
try {
id = userAccountDao.create(userData);
} catch (java.sql.SQLException e) {
e.printStackTrace();
}
} catch (SQLException e) {
e.printStackTrace();
}
return id;
}
public List<CommentBeanData> queryByCustom(String columnName, String columnValue) {
List<CommentBeanData> ormTables = new ArrayList<>();
try {
ormTables = userAccountDao.queryBuilder().where().eq(columnName, columnValue).query();
} catch (java.sql.SQLException e) {
e.printStackTrace();
}
return ormTables;
}
public List<CommentBeanData> queryByCustomtwo(String columnName, String columnValue) {
List<CommentBeanData> ormTables = new ArrayList<>();
try {
// ormTables = userAccountDao.queryBuilder().where().eq(columnName, columnValue).query();
ormTables= userAccountDao.queryBuilder().where().like("phone", "%"+columnValue+"%").or().like("name","%"+columnValue+"%").query();
} catch (java.sql.SQLException e) {
e.printStackTrace();
}
return ormTables;
}
public boolean updateData(CommentBeanData userData) {
try {
int result = userAccountDao.update(userData);
if (result != -1) {
return true;
}
} catch (java.sql.SQLException e) {
e.printStackTrace();
return false;
}
return false;
}
public static List<CommentBeanData> queryInByCustom(String columnName, String columnValues){
List<CommentBeanData> ormTables = new ArrayList<>();
try {
List<String> strings = Arrays.asList(columnValues.split(","));
ormTables = userAccountDao.queryBuilder().where().in(columnName,strings ).query();
}catch (java.sql.SQLException e){
e.printStackTrace();
}
return ormTables;
}
public ArrayList<CommentBeanData> queryAll() {
ArrayList<CommentBeanData> userAccountList = new ArrayList<>();
try {
userAccountList = (ArrayList<CommentBeanData>) userAccountDao.queryForAll();
} catch (java.sql.SQLException e) {
e.printStackTrace();
}
return userAccountList;
}
public long delete(List<CommentBeanData> DATA){
int id = 0;
try {
try {
id = userAccountDao.delete(DATA);
} catch (java.sql.SQLException e) {
e.printStackTrace();
}
} catch (SQLException e) {
e.printStackTrace();
}
return id;
}
}

View File

@@ -0,0 +1,126 @@
package com.sl.house_property.db.dao;
import android.content.Context;
import android.database.SQLException;
import android.database.sqlite.SQLiteDatabase;
import com.j256.ormlite.android.apptools.OrmLiteSqliteOpenHelper;
import com.j256.ormlite.dao.Dao;
import com.j256.ormlite.support.ConnectionSource;
import com.j256.ormlite.table.TableUtils;
import com.sl.house_property.db.CommentBeanData;
public class DataBaseHelper extends OrmLiteSqliteOpenHelper {
/**
* 数据库名称
*/
private static final String TABLE_NAME = "sqlite-test.db";
/**
* 版本号
*/
private static final int DBVERSION = 1;
private static Context mContext;
/**
* 单例
*/
private static DataBaseHelper mInstance;
private static DataBaseHelper dataBaseHelper;
private DataBaseHelper(Context context) {
super(context, TABLE_NAME, null, DBVERSION);
}
public synchronized static DataBaseHelper getInstance(Context mContext) {
if (dataBaseHelper == null) {
dataBaseHelper = new DataBaseHelper(mContext);
}
return dataBaseHelper;
}
/**
* 初始化
*
* @param context
*/
public static void initOrmLite(Context context) {
mContext = context;
getIntence();
}
/**
* 创建数据库表
*
* @param database
* @param connectionSource
*/
@Override
public void onCreate(SQLiteDatabase database,
ConnectionSource connectionSource) {
try {
TableUtils.createTable(connectionSource, CommentBeanData.class);
} catch (SQLException e) {
e.printStackTrace();
} catch (java.sql.SQLException e) {
e.printStackTrace();
}
}
/**
* 升级数据库
*
* @param database
* @param connectionSource
* @param oldVersion
* @param newVersion
*/
@Override
public void onUpgrade(SQLiteDatabase database,
ConnectionSource connectionSource, int oldVersion, int newVersion) {
try {
onCreate(database, connectionSource);
} catch (SQLException e) {
e.printStackTrace();
}
}
/**
* 单例获取该Helper
*
* @param
* @return
*/
public static synchronized DataBaseHelper getIntence() {
if (null == mInstance) {
synchronized (DataBaseHelper.class) {
if (null == mInstance) {
mInstance = new DataBaseHelper(mContext);
}
}
}
return mInstance;
}
/**
* 获取数据对象
*
* @param classz 对应的表实体的字节码对象
* @return Dao<T, ID> :T表实体对象类型.ID对应的表实体中被指定为id字段的属性类型
* @throws SQLException
*/
@Override
public Dao getDao(Class classz) throws SQLException, java.sql.SQLException {
return super.getDao(classz);
}
}

View File

@@ -14,6 +14,8 @@ import com.lxj.xpopup.XPopup;
import com.selectpicker.OptionsPopupWindow;
import com.sl.house_property.BaseActivity;
import com.sl.house_property.R;
import com.sl.house_property.db.CommentBeanData;
import com.sl.house_property.db.dao.CommentDao;
import org.json.JSONArray;
import org.json.JSONException;
@@ -32,18 +34,22 @@ import my_loader.Resultcode;
import rx.Subscription;
import rx.functions.Action1;
import tools.Config;
import utils.DateUtils;
import utils.DateUtilss;
import utils.Md5;
public class ShareCodeActivity extends BaseActivity<com.sl.house_property.databinding.ActivityEntranceguardControl2Binding> {
private String user_home_id;
private String fangchan,time;
private CommentDao commentDao;
@Override
protected int getLayoutResId() {
return R.layout.activity_entranceguard_control2;
}
private int timeday = 7;
private int timeday = 1;
private OptionsPopupWindow alarmOptionPop;
@Override
@@ -55,18 +61,19 @@ public class ShareCodeActivity extends BaseActivity<com.sl.house_property.databi
finish();
}
}, 0, null, 0, null, 0, null, "");
// Map<String, String> map = new HashMap<>();
// RegisterUser registerUser = Config.getInstance(ShareCodeActivity.this).getUser();
// if (registerUser != null) {
// map.put("userid", registerUser.getUserid());
// } else {
// map.put("userid", 0 + "");
// }
//
// map.put("sign", Md5.md5("Cas" + "GetMyAddress" + Md5.secret));
// map.put("app", "Cas");
// map.put("class", "GetMyAddress");
// getGankList(ApiConfig.BASE_URL, map, "", 0);
commentDao = new CommentDao(ShareCodeActivity.this);
Map<String, String> map = new HashMap<>();
RegisterUser registerUser = Config.getInstance(ShareCodeActivity.this).getUser();
if (registerUser != null) {
map.put("userid", registerUser.getUserid());
} else {
map.put("userid", 0 + "");
}
map.put("sign", Md5.md5("Cas" + "GetMyAddress" + Md5.secret));
map.put("app", "Cas");
map.put("class", "GetMyAddress");
getGankList(ApiConfig.BASE_URL, map, "", 0);
user_home_id= getIntent().getStringExtra("id");
// String address = getIntent().getStringExtra("address");
@@ -74,6 +81,9 @@ public class ShareCodeActivity extends BaseActivity<com.sl.house_property.databi
mDataBinding.myradio2.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup radioGroup, int i) {
if (i == R.id.myradio20) {
timeday = 1;
}
if (i == R.id.myradio21) {
timeday = 7;
}
@@ -190,6 +200,7 @@ public class ShareCodeActivity extends BaseActivity<com.sl.house_property.databi
list = new Gson().fromJson(jsonArray.toString(), type);
if (list != null && !list.isEmpty()) {
mDataBinding.tvAddress.setText(list.get(0).getAddress());
fangchan=list.get(0).getAddress();
user_home_id = list.get(0).getUser_home_id();
}
} catch (JSONException e) {
@@ -280,6 +291,7 @@ public class ShareCodeActivity extends BaseActivity<com.sl.house_property.databi
map.put("app", "Door");
map.put("class", "SendCustomerCode");
map.put("type", "password");
map.put("validity_time", timeday + "");
// map.put("phone", mDataBinding.telephone.getText().toString().trim());
// map.put("validity_time", mDataBinding.daytiems.getText().toString().trim());
map.put("user_home_id", user_home_id);
@@ -299,9 +311,30 @@ public class ShareCodeActivity extends BaseActivity<com.sl.house_property.databi
JSONObject jsonArray = new JSONObject(s);
String pwd = jsonArray.optString("code", "");
// time= DateUtilss.getDate();
time= DateUtilss.getDateTime();
ArrayList<CommentBeanData> commentBeanData1 = commentDao.queryAll();
if(commentBeanData1.size()>5){
setToast("最多只能申请5条秘钥");
return;
}else {
CommentBeanData commentBeanData = new CommentBeanData();
commentBeanData.setId("1");
commentBeanData.setComment(fangchan);
commentBeanData.setType(time);
if (null != commentDao.queryByCustom("Id", commentBeanData.getId()) && commentDao.queryByCustom("Id", commentBeanData.getId()).size() > 0) {
commentDao.updateData(commentBeanData);
} else {
commentDao.addInsert(commentBeanData);
}
}
ShareCodeDialog shareCodeDialog = new ShareCodeDialog(ShareCodeActivity.this);
shareCodeDialog.setCode(code);
shareCodeDialog.setPwd(pwd);
shareCodeDialog.setPwd(pwd,time,fangchan);
new XPopup.Builder(ShareCodeActivity.this).asCustom(shareCodeDialog).show();
} catch (JSONException e) {

View File

@@ -3,8 +3,10 @@ package com.sl.house_property.discovery;
import android.content.Context;
import android.graphics.Bitmap;
import android.support.annotation.NonNull;
import android.text.Html;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.lxj.xpopup.core.CenterPopupView;
@@ -15,15 +17,18 @@ import com.tencent.mm.opensdk.modelmsg.WXMediaMessage;
import com.tencent.mm.opensdk.openapi.IWXAPI;
import com.tencent.mm.opensdk.openapi.WXAPIFactory;
import java.util.ArrayList;
import utils.QRCodeUtil;
public class ShareCodeDialog extends CenterPopupView {
private String pwd;
private String pwd,time,fangchan;
private String code;
private TextView tvPwd;
private TextView tvPwd,title3,title5;
private ImageView ivCode;
private TextView tvShare;
private TextView tvCancel;
private LinearLayout ly_all;
// APP_ID 替换为你的应用从官方网站申请到的合法appID
private static final String APP_ID = "wx7e09fff168f6e58d";
// IWXAPI 是第三方app和微信通信的openApi接口
@@ -61,9 +66,12 @@ public class ShareCodeDialog extends CenterPopupView {
protected void onCreate() {
super.onCreate();
tvPwd = findViewById(R.id.title2);
title3 = findViewById(R.id.title3);
title5 = findViewById(R.id.title5);
ivCode = findViewById(R.id.myImage);
tvShare = findViewById(R.id.tv_share);
tvCancel = findViewById(R.id.tv_cancel);
ly_all = findViewById(R.id.ly_all);
tvCancel.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
@@ -78,15 +86,37 @@ public class ShareCodeDialog extends CenterPopupView {
dismiss();
}
});
tvPwd.setText("密码:" + pwd);
ArrayList<String> strings = new ArrayList<>();
for (int i = 0; i < pwd.length(); i++) {
char item = pwd.charAt(i);
strings.add(String.valueOf(item));
}
StringBuffer sb = new StringBuffer();
sb.append(strings.get(0));
sb.append(" ");//空格
sb.append(strings.get(1));
sb.append(" ");//空格
sb.append(strings.get(2));
sb.append(" ");//空格
sb.append(strings.get(3));
String pwdd = sb.toString();
tvPwd.setText("" + pwdd);
// title3.setText("注:分享临时门禁给访客,扫描二维码或输入密码开门" +"(有效期至"+ time+"时)");
title3.setText(Html.fromHtml("注:分享临时门禁给访客,扫描二维码或输入密码开门" +"(有效期至"+"<font color='#ff0000'>"+ time +"</font>"+"分)"));
title5.setText("" + fangchan);
final Bitmap qrCodeBitmap = QRCodeUtil.createQRCodeBitmap(code, QRCodeUtil.dip2px(getContext(), 220), QRCodeUtil.dip2px(getContext(), 220));
ivCode.setImageBitmap(qrCodeBitmap);
findViewById(R.id.tv_share).setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Bitmap bitmap_view = takeScreenShotOfView(ly_all);
//初始化 WXImageObject 和 WXMediaMessage 对象
WXImageObject imgObj = new WXImageObject(qrCodeBitmap);
// WXImageObject imgObj = new WXImageObject(qrCodeBitmap);
WXImageObject imgObj = new WXImageObject(bitmap_view);
WXMediaMessage msg = new WXMediaMessage();
msg.mediaObject = imgObj;
msg.title = "临时门禁";
@@ -103,9 +133,19 @@ public class ShareCodeDialog extends CenterPopupView {
});
}
public Bitmap takeScreenShotOfView(View v) {
v.setDrawingCacheEnabled(true);
v.buildDrawingCache(true);
public void setPwd(String pwd) {
Bitmap b = Bitmap.createBitmap(v.getDrawingCache());
v.setDrawingCacheEnabled(false); // clear drawing cache
return b;
}
public void setPwd(String pwd,String time,String fangchan) {
this.pwd = pwd;
this.time = time;
this.fangchan = fangchan;
}

View File

@@ -0,0 +1,574 @@
/*
* Copyright (C) 2016 android@19code.com
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package utils;
import android.app.Activity;
import android.content.Context;
import android.graphics.Color;
import android.util.Log;
import android.view.View;
import android.widget.TextView;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Locale;
/**
* Create by h4de5ing 2016/5/7 007
* 日期工具类
*
*/
public class DateUtilss {
private static final String TAG = "InviteMessageFragment";
private static final SimpleDateFormat DATE_FORMAT_DATETIME = new SimpleDateFormat("yyyy-MM-dd HH:mm");
private static final SimpleDateFormat DATE_FORMAT_DATE = new SimpleDateFormat("yyyy-MM-dd");
private static final SimpleDateFormat DATE_FORMAT_TIME = new SimpleDateFormat("HH:mm:ss");
/**
* 日期格式yyyy-MM-dd HH:mm:ss
*/
public static final String DATE_LONG = "yyyy-MM-dd HH:mm:ss";
/**
* 日期格式yyyy-MM-dd
*/
public static final String DATE_SHORT = "yyyy-MM-dd";
/**
* 日期格式yyyy-MM
*/
public static final String MONTH_SHORT = "yyyy-MM";
/**
* 日期格式 yyyyMMdd
*/
public static final String DATE_NORMAL = "yyyyMMdd";
/**
* 将字符串转位日期类型
*
* @param sdate
* @return
*/
public static Date toDate(String sdate) {
try {
return dateFormater.get().parse(sdate);
} catch (ParseException e) {
return null;
}
}
private final static ThreadLocal<SimpleDateFormat> dateFormater = new ThreadLocal<SimpleDateFormat>() {
@Override
protected SimpleDateFormat initialValue() {
return new SimpleDateFormat("yyyy-MM-dd");
}
};
// private final static ThreadLocal<SimpleDateFormat> dateFormater = new ThreadLocal<SimpleDateFormat>() {
// @Override
// protected SimpleDateFormat initialValue() {
// return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
// }
// };
private final static ThreadLocal<SimpleDateFormat> dateFormater2 = new ThreadLocal<SimpleDateFormat>() {
@Override
protected SimpleDateFormat initialValue() {
return new SimpleDateFormat("yyyy-MM-dd");
}
};
private static ThreadLocal<SimpleDateFormat> DateLocal = new ThreadLocal<SimpleDateFormat>();
/**
* 判断是否为今天(效率比较高)
*
* @param day 传入的 时间 "2016-06-28 10:10:30" "2016-06-28" 都可以
* @return true今天 false不是
* @throws ParseException
*/
public static boolean IsToday(String day) throws ParseException {
Calendar pre = Calendar.getInstance();
Date predate = new Date(System.currentTimeMillis());
pre.setTime(predate);
Calendar cal = Calendar.getInstance();
Date date = getDateFormat().parse(day);
cal.setTime(date);
if (cal.get(Calendar.YEAR) == (pre.get(Calendar.YEAR))) {
int diffDay = cal.get(Calendar.DAY_OF_YEAR)
- pre.get(Calendar.DAY_OF_YEAR);
if (diffDay == 0) {
return true;
}
}
return false;
}
/**
* 判断是否为昨天(效率比较高)
*
* @param day 传入的 时间 "2016-06-28 10:10:30" "2016-06-28" 都可以
* @return true今天 false不是
* @throws ParseException
*/
public static boolean IsYesterday(String day) throws ParseException {
Calendar pre = Calendar.getInstance();
Date predate = new Date(System.currentTimeMillis());
pre.setTime(predate);
Calendar cal = Calendar.getInstance();
Date date = getDateFormat().parse(day);
cal.setTime(date);
if (cal.get(Calendar.YEAR) == (pre.get(Calendar.YEAR))) {
int diffDay = cal.get(Calendar.DAY_OF_YEAR)
- pre.get(Calendar.DAY_OF_YEAR);
if (diffDay == -1) {
return true;
}
}
return false;
}
public static SimpleDateFormat getDateFormat() {
if (null == DateLocal.get()) {
DateLocal.set(new SimpleDateFormat("yyyy-MM-dd", Locale.CHINA));
}
return DateLocal.get();
}
/**
* 获取当前时间字符串
*
* @return
*/
public static String getNowString() {
return dateFormat(new Date());
}
public static Date getNowDate() {
return new Date();
}
/**
* 获取精确到秒的时间戳
* @param date
* @return
*/
public static int getSecondTimestampTwo(Date date){
if (null == date) {
return 0;
}
String timestamp = String.valueOf(date.getTime()/1000);
return Integer.valueOf(timestamp);
}
/**
* @description 获取两个时间相差多少秒
* @param
* @return
*/
public static int calLastedTime(Date startDate) {
long a = new Date().getTime();
long b = startDate.getTime();
int c = (int)((b - a) / 1000);
return c;
}
/**
* Java Date与String的相互转换
*/
public static Date stringToDate(String time) {
DateFormat format = new SimpleDateFormat("yyyy-MM-dd");//日期格式
Date date = null;
try {
date = format.parse(time);
} catch (ParseException e) {
e.printStackTrace();
}
return date;
}
/**
* JDate转为String
*/
public static String dateToString(Date date) {
SimpleDateFormat sformat = new SimpleDateFormat("yyyy-MM-dd");//日期格式
String tiem = sformat.format(date);
return tiem;
}
/**
* 从时间格式化字符串
* 默认格式为yyyy-MM-dd HH:mm:ss
*
* @param date
* @return
*/
public static String dateFormat(Date date) {
return dateFormat(date, DATE_LONG);
}
/**
* 从时间格式化字符串
*
* @param date
* @param format
* @return
*/
public static String dateFormat(Date date, String format) {
if (date == null) {
date = new Date();
}
if (format == null || format.equals("")) {
format = DATE_LONG;
}
SimpleDateFormat sdf = new SimpleDateFormat(format);
return sdf.format(date);
}
/**
* 从字符串格式化时间
*
* @param dateStr
* @param format
* @return
*/
public static Date dateFromString(String dateStr, String format) {
if (!dateStr.equals("") && !format.equals("")) {
DateFormat sdf = new SimpleDateFormat(format);
try {
return sdf.parse(dateStr);
} catch (ParseException e) {
e.printStackTrace();
}
}
return null;
}
/**
* 增加时间数
*
* @param date
* @param field
* @param interval
* @return
*/
public static Date addOnField(Date date, int field, int interval) {
Calendar ca = Calendar.getInstance();
ca.setTime(date);
ca.add(field, interval);
return ca.getTime();
}
/**
* 获取某个块
*
* @param date
* @param field
* @return
*/
public static int getFieldOfDate(Date date, int field) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
return calendar.get(field);
}
public static String formatDataTime(long date) {
return DATE_FORMAT_DATETIME.format(new Date(date));
}
public static String formatDate(long date) {
return DATE_FORMAT_DATE.format(new Date(date));
}
public static String formatTime(long date) {
return DATE_FORMAT_TIME.format(new Date(date));
}
public static String formatDateCustom(String beginDate, String format) {
return new SimpleDateFormat(format).format(new Date(Long.parseLong(beginDate)));
}
public static String formatDateCustom(Date beginDate, String format) {
return new SimpleDateFormat(format).format(beginDate);
}
public static Date string2Date(String s, String style) {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat();
simpleDateFormat.applyPattern(style);
Date date = null;
if (s == null || s.length() < 6) {
return null;
}
try {
date = simpleDateFormat.parse(s);
} catch (ParseException e) {
e.printStackTrace();
}
return date;
}
public static String getTime() {
Calendar cal = Calendar.getInstance();
cal.setTimeInMillis(System.currentTimeMillis());
return cal.get(Calendar.HOUR_OF_DAY) + ":" + cal.get(Calendar.MINUTE) + ":" + cal.get(Calendar.SECOND);
}
/**
* 获得当前日期
* @return
*/
public static String getDate() {
return DATE_FORMAT_DATE.format(System.currentTimeMillis());
}
/**
*获取月末日期
* @return
*/
public static String getLastDayOfMonth() {
Calendar cale = null;
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
String lastday;
cale = Calendar.getInstance();
cale.add(Calendar.MONTH, 1);
cale.set(Calendar.DAY_OF_MONTH, 0);
lastday = format.format(cale.getTime());
return lastday;
}
public static String getDateTime(){
return DATE_FORMAT_DATETIME.format(System.currentTimeMillis());
}
public static String getDateTime(String format){
return new SimpleDateFormat(format).format(System.currentTimeMillis());
}
public static long subtractDate(Date dateStart, Date dateEnd) {
return dateEnd.getTime() - dateStart.getTime();
}
public static Date getDateAfter(Date d, int day) {
Calendar now = Calendar.getInstance();
now.setTime(d);
now.set(Calendar.DATE, now.get(Calendar.DATE) + day);
return now.getTime();
}
public static int getWeekOfMonth() {
Calendar calendar = Calendar.getInstance();
int week = calendar.get(Calendar.WEEK_OF_MONTH);
return week - 1;
}
public static int getDayOfWeek() {
Calendar calendar = Calendar.getInstance();
int day = calendar.get(Calendar.DAY_OF_WEEK);
if (day == 1) {
day = 7;
} else {
day = day - 1;
}
return day;
}
public static String getNextDay(){
SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd");
Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.DAY_OF_MONTH,1);
String nextDay = sf.format(calendar.getTime());
return nextDay;
}
public static String gettimenow() {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.CHINA);
String now = sdf.format(new Date());
return now;
}
public static String gettime() {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");// HH:mm:ss
Date date = new Date(System.currentTimeMillis());
String format = simpleDateFormat.format(date);
Log.d(TAG, "当前的系统时间==" + format);
return format;
}
private static String gettimethtee() {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy年MM月dd日 HH:mm:ss");// HH:mm:ss
Date date = new Date(System.currentTimeMillis());
String format = simpleDateFormat.format(date);
return format;
}
public static String gettimetwo() {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy年MM月dd日");// HH:mm:ss
Date date = new Date(System.currentTimeMillis());
String format = simpleDateFormat.format(date);
Log.d(TAG, "当前的系统时间(年月日格式)==" + format);
return format;
}
public static String gettimethree() {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy年MM月");// HH:mm:ss
Date date = new Date(System.currentTimeMillis());
String format = simpleDateFormat.format(date);
Log.d(TAG, "当前的系统时间(年月格式)==" + format);
return format;
}
/**
* 判断时间是不是今天
* @param date
* @return 是返回true不是返回false
*/
public static boolean isNow(Date date) {
//当前时间
Date now = new Date();
SimpleDateFormat sf = new SimpleDateFormat("yyyyMMdd");
//获取今天的日期
String nowDay = sf.format(now);
//对比的时间
String day = sf.format(date);
return day.equals(nowDay);
}
/**
* 获取明天的时间
*
* @return
*/
public static String getTomorrowTime() {
//获取当前时间
SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd");
Calendar c = Calendar.getInstance();
// System.out.println("当前日期:"+sf.format(c.getTime()));
c.add(Calendar.DAY_OF_MONTH, 1);
// System.out.println("增加一天后日期:"+sf.format(c.getTime()));
return sf.format(c.getTime());
}
/**
* 将秒数转换为基于00:00的时间
* 如541=9*60+1表示09:01
* @param minutes
* @return
*/
public static String getTimeByMinutes(int minutes){
//处理小时
int hour = minutes / 60;
String hourTime = "";
if(hour >= 0 && hour < 10){
hourTime = "0" + hour;// 1 --> 01
}else if(hour >= 10 && hour < 24){
hourTime = "" + hour;
}else if(hour >= 24){
hourTime = "0" + (hour-24);
}
//处理分钟
int min = minutes % 60;
String minTime = "";
if(min >= 0 && min < 10){
minTime = "0" + min;// 1 --> 01
}else{
minTime = "" + min;
}
return hourTime + ":" + minTime;
}
/**
* 秒钟转换成这种格式的时间00:00:10
* @param time
* @return
*/
public static String secToTime(int time) {
String timeStr = null;
int hour = time / 3600;
int minute = time / 60 % 60;
int second = time % 60;
timeStr = unitFormat(hour) + ":" + unitFormat(minute) + ":" + unitFormat(second);
return timeStr;
}
public static String unitFormat(int i) {
String retStr = null;
if (i >= 0 && i < 10)
retStr = "0" + Integer.toString(i);
else
retStr = "" + i;
return retStr;
}
/**
* 00:00:10 这种格式的时间转化成秒钟
* @param time
* @return
*/
public static int timeToSec(String time){
String[] timeArray = time.split(":");
int hour = Integer.parseInt(timeArray[0])*3600;
int min = Integer.parseInt(timeArray[1])*60;
int sec = Integer.parseInt(timeArray[2]);
return hour+min+sec;
}
/**
* 毫秒换算
* 将毫秒换算成天、时、分、秒
*
*/
public static String formatDuring(long mss) {
long days = mss / (1000 * 60 * 60 * 24);
long hours = (mss % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60);
long minutes = (mss % (1000 * 60 * 60)) / (1000 * 60);
long seconds = (mss % (1000 * 60)) / 1000;
// return days + "天" + hours + "时" + minutes + "分"
// + seconds + "秒 ";
return days + "" + hours + ":" + minutes + ":"
+ seconds + " ";
}
}

View File

@@ -45,6 +45,7 @@
<LinearLayout
android:id="@+id/ll_address"
android:layout_width="match_parent"
android:visibility="gone"
android:layout_height="35dp"
android:background="@color/LightGraydddddd"
android:orientation="horizontal">

View File

@@ -28,32 +28,6 @@
android:orientation="vertical">
<LinearLayout
android:visibility="gone"
android:id="@+id/ll_address"
android:layout_width="match_parent"
android:layout_height="35dp"
android:background="@color/LightGraydddddd"
android:orientation="horizontal">
<TextView
android:id="@+id/tv_address"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="16dp"
android:layout_weight="1"
/>
<ImageView
android:layout_width="14dp"
android:layout_height="14dp"
android:layout_gravity="center_vertical"
android:layout_marginRight="16dp"
android:src="@mipmap/returnme"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
@@ -82,6 +56,16 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<RadioButton
android:id="@+id/myradio20"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="3dip"
android:background="@drawable/drawableforitemnormal"
android:button="@null"
android:padding="20dip"
android:checked="true"
android:text="1天" />
<RadioButton
android:id="@+id/myradio21"
@@ -91,7 +75,6 @@
android:background="@drawable/drawableforitemnormal"
android:button="@null"
android:padding="20dip"
android:checked="true"
android:text="7天" />
<RadioButton
@@ -163,6 +146,32 @@
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="@+id/ll_address"
android:layout_width="match_parent"
android:layout_height="35dp"
android:background="@color/LightGraydddddd"
android:orientation="horizontal">
<TextView
android:id="@+id/tv_address"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="16dp"
android:layout_weight="1"
/>
<ImageView
android:layout_width="14dp"
android:layout_height="14dp"
android:layout_gravity="center_vertical"
android:layout_marginRight="16dp"
android:src="@mipmap/returnme"
/>
</LinearLayout>
<TextView
android:id="@+id/confirm"

View File

@@ -4,9 +4,15 @@
android:layout_height="wrap_content"
android:background="@drawable/retacal_background"
android:orientation="vertical">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="300dp"
android:id="@+id/ly_all"
android:layout_height="wrap_content"
android:background="@drawable/retacal_background"
android:orientation="vertical">
<TextView
android:id="@+id/title1"
android:id="@+id/title5"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="17dip"
@@ -26,10 +32,12 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="17dip"
android:layout_marginTop="5dp"
android:gravity="center"
android:text="密码"
android:textSize="15sp" />
android:text=""
android:textStyle="bold"
android:textSize="40sp" />
<ImageView
android:id="@+id/myImage"
@@ -57,6 +65,9 @@
android:background="@color/gray" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="45dp"
@@ -86,4 +97,4 @@
android:text="取消"
android:textColor="@color/black" />
</LinearLayout>
</LinearLayout>
</LinearLayout>

View File

@@ -7,3 +7,15 @@
__________________________________________________________________
1 临时门禁 添加1天期限的临时密码
CodeActivity
ShareCodeActivity