-
Notifications
You must be signed in to change notification settings - Fork 191
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add record wechat envelope function.
- Loading branch information
Showing
19 changed files
with
441 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
app/src/main/java/com/carlos/grabredenvelope/db/GreenDaoManager.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package com.carlos.grabredenvelope.data | ||
import com.carlos.grabredenvelope.MyApplication | ||
import com.carlos.grabredenvelope.db.DaoMaster | ||
import com.carlos.grabredenvelope.db.DaoSession | ||
|
||
/** | ||
* _ooOoo_ | ||
* o8888888o | ||
* 88" . "88 | ||
* (| -_- |) | ||
* O\ = /O | ||
* ____/`---'\____ | ||
* .' \\| |// `. | ||
* / \\||| : |||// \ | ||
* / _||||| -:- |||||- \ | ||
* | | \\\ - /// | | | ||
* | \_| ''\---/'' | | | ||
* \ .-\__ `-` ___/-. / | ||
* ___`. .' /--.--\ `. . __ | ||
* ."" '< `.___\_<|>_/___.' >'"". | ||
* | | : `- \`.;`\ _ /`;.`/ - ` : | | | ||
* \ \ `-. \_ __\ /__ _/ .-` / / | ||
* ======`-.____`-.___\_____/___.-`____.-'====== | ||
* `=---=' | ||
* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
* 佛祖保佑 永无BUG | ||
* 佛曰: | ||
* 写字楼里写字间,写字间里程序员; | ||
* 程序人员写程序,又拿程序换酒钱。 | ||
* 酒醒只在网上坐,酒醉还来网下眠; | ||
* 酒醉酒醒日复日,网上网下年复年。 | ||
* 但愿老死电脑间,不愿鞠躬老板前; | ||
* 奔驰宝马贵者趣,公交自行程序员。 | ||
* 别人笑我忒疯癫,我笑自己命太贱; | ||
* 不见满街漂亮妹,哪个归得程序员? | ||
*/ | ||
|
||
/** | ||
* Github: https://github.com/xbdcc/. | ||
* Created by caochang on 2017/8/27. | ||
*/ | ||
|
||
class GreenDaoManager { | ||
var master: DaoMaster //以一定的模式管理Dao类的数据库对象 | ||
var session: DaoSession //管理制定模式下的所有可用Dao对象 | ||
var newSession: DaoSession? = null | ||
get() { | ||
session = master.newSession() | ||
return session | ||
} | ||
|
||
init { | ||
val devOpenHelper = DaoMaster.DevOpenHelper(MyApplication.instance.applicationContext, "grabredenvelope", null) | ||
master = DaoMaster(devOpenHelper.writableDatabase) | ||
session = master.newSession() | ||
} | ||
|
||
companion object { | ||
val instance by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED) { | ||
GreenDaoManager() | ||
} | ||
} | ||
} |
77 changes: 77 additions & 0 deletions
77
app/src/main/java/com/carlos/grabredenvelope/db/WechatRedEnvelope.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
package com.carlos.grabredenvelope.db; | ||
|
||
import org.greenrobot.greendao.annotation.Entity; | ||
import org.greenrobot.greendao.annotation.Id; | ||
import org.greenrobot.greendao.annotation.Generated; | ||
|
||
/** | ||
* _ooOoo_ | ||
* o8888888o | ||
* 88" . "88 | ||
* (| -_- |) | ||
* O\ = /O | ||
* ____/`---'\____ | ||
* .' \\| |// `. | ||
* / \\||| : |||// \ | ||
* / _||||| -:- |||||- \ | ||
* | | \\\ - /// | | | ||
* | \_| ''\---/'' | | | ||
* \ .-\__ `-` ___/-. / | ||
* ___`. .' /--.--\ `. . __ | ||
* ."" '< `.___\_<|>_/___.' >'"". | ||
* | | : `- \`.;`\ _ /`;.`/ - ` : | | | ||
* \ \ `-. \_ __\ /__ _/ .-` / / | ||
* ======`-.____`-.___\_____/___.-`____.-'====== | ||
* `=---=' | ||
* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
* 佛祖保佑 永无BUG | ||
* 佛曰: | ||
* 写字楼里写字间,写字间里程序员; | ||
* 程序人员写程序,又拿程序换酒钱。 | ||
* 酒醒只在网上坐,酒醉还来网下眠; | ||
* 酒醉酒醒日复日,网上网下年复年。 | ||
* 但愿老死电脑间,不愿鞠躬老板前; | ||
* 奔驰宝马贵者趣,公交自行程序员。 | ||
* 别人笑我忒疯癫,我笑自己命太贱; | ||
* 不见满街漂亮妹,哪个归得程序员? | ||
*/ | ||
|
||
/** | ||
* Github: https://github.com/xbdcc/. | ||
* Created by caochang on 2017/8/27. | ||
*/ | ||
|
||
@Entity | ||
public class WechatRedEnvelope { | ||
@Id(autoincrement = true) | ||
private Long id; | ||
private long time = System.currentTimeMillis(); | ||
private String count = ""; | ||
@Generated(hash = 1534010414) | ||
public WechatRedEnvelope(Long id, long time, String count) { | ||
this.id = id; | ||
this.time = time; | ||
this.count = count; | ||
} | ||
@Generated(hash = 1019243491) | ||
public WechatRedEnvelope() { | ||
} | ||
public Long getId() { | ||
return this.id; | ||
} | ||
public void setId(Long id) { | ||
this.id = id; | ||
} | ||
public long getTime() { | ||
return this.time; | ||
} | ||
public void setTime(long time) { | ||
this.time = time; | ||
} | ||
public String getCount() { | ||
return this.count; | ||
} | ||
public void setCount(String count) { | ||
this.count = count; | ||
} | ||
} |
52 changes: 52 additions & 0 deletions
52
app/src/main/java/com/carlos/grabredenvelope/db/WechatRedEnvelopeDb.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package com.carlos.grabredenvelope.db | ||
|
||
import com.carlos.grabredenvelope.data.GreenDaoManager | ||
|
||
/** | ||
* _ooOoo_ | ||
* o8888888o | ||
* 88" . "88 | ||
* (| -_- |) | ||
* O\ = /O | ||
* ____/`---'\____ | ||
* .' \\| |// `. | ||
* / \\||| : |||// \ | ||
* / _||||| -:- |||||- \ | ||
* | | \\\ - /// | | | ||
* | \_| ''\---/'' | | | ||
* \ .-\__ `-` ___/-. / | ||
* ___`. .' /--.--\ `. . __ | ||
* ."" '< `.___\_<|>_/___.' >'"". | ||
* | | : `- \`.;`\ _ /`;.`/ - ` : | | | ||
* \ \ `-. \_ __\ /__ _/ .-` / / | ||
* ======`-.____`-.___\_____/___.-`____.-'====== | ||
* `=---=' | ||
* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
* 佛祖保佑 永无BUG | ||
* 佛曰: | ||
* 写字楼里写字间,写字间里程序员; | ||
* 程序人员写程序,又拿程序换酒钱。 | ||
* 酒醒只在网上坐,酒醉还来网下眠; | ||
* 酒醉酒醒日复日,网上网下年复年。 | ||
* 但愿老死电脑间,不愿鞠躬老板前; | ||
* 奔驰宝马贵者趣,公交自行程序员。 | ||
* 别人笑我忒疯癫,我笑自己命太贱; | ||
* 不见满街漂亮妹,哪个归得程序员? | ||
*/ | ||
|
||
/** | ||
* Github: https://github.com/xbdcc/. | ||
* Created by Carlos on 2020-01-22. | ||
*/ | ||
object WechatRedEnvelopeDb { | ||
|
||
private val sQQRedEnvelopeDao = GreenDaoManager.instance.session.wechatRedEnvelopeDao | ||
|
||
val allData: List<WechatRedEnvelope> | ||
@Synchronized get() = sQQRedEnvelopeDao.loadAll() | ||
|
||
@Synchronized | ||
fun insertData(qqRedEnvelope: WechatRedEnvelope) { | ||
sQQRedEnvelopeDao.insert(qqRedEnvelope) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.