Skip to content

Commit

Permalink
step4优化分类美化记账图标
Browse files Browse the repository at this point in the history
  • Loading branch information
guohuan78 committed Dec 16, 2022
1 parent f70f763 commit 492b9f1
Show file tree
Hide file tree
Showing 146 changed files with 185 additions and 124 deletions.
5 changes: 5 additions & 0 deletions .idea/dictionaries/78121.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 17 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

| 主界面入口 | 账单记录界面展示 |
| :----------------------------------------: | :------------------------------------------: |
| ![step1图1主界面图标展示](img/step1_1.png) | ![step1图1账单记录界面展示](img/step1_2.png) |
| ![step1图1主界面图标展示](img/step1_1.png) | ![step1图2账单记录界面展示](img/step1_2.png) |

### step 2

Expand All @@ -41,13 +41,24 @@
5. 完成关于界面
6. 完成设置界面

| 主界面入口 | 更多界面 | **账单详情界面** |
| :--------------------------------------: | :--------------------------------------: | -------------------------------------------- |
| 主界面入口 | 更多界面 | 账单详情界面 |
| :--------------------------------------: | :--------------------------------------: | :------------------------------------------: |
| ![step3图1主界面展示](img/step3_1.png) | ![step3图2更多界面展示](img/step3_2.png) | ![step3图3账单详情界面展示](img/step3_3.png) |
| **关于界面** | 设置界面 | |
| **关于界面** | **设置界面** | |
| ![step3图4关于界面展示](img/step3_4.png) | ![step3图5设置界面展示](img/step3_5.png) | |

### step4

1. 更改了数据库的表结构,将`typetb``sImageId`属性删去。
2. 更改分类
3. 更改图标为彩色图标

图标来源:主要来源[iconfont-阿里巴巴矢量图标库](https://www.iconfont.cn/collections/detail?spm=a313x.7781069.1998910419.d9df05512&cid=42149),和此作者的其余多彩系列,个别来源于同网站其他作者

| 主界面支出图标 | 主界面收入图标 |
| :--------------------------------------------: | :--------------------------------------------: |
| ![step4图1主界面支出图标展示](img/step4_1.png) | ![step4图2主界面收入图标展示](img/step4_2.png) |

### todo

1. 更改分类的数据库内容
2. 更改分类的图标
1. 继续美化界面,更改系统的 `更多` `返回` `关闭`等 按钮图标
Binary file added app/release/easy_bookkeeping_step4.apk
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public View getView(int position, View convertView, ViewGroup parent) {
holder = (ViewHolder) convertView.getTag();
}
AccountBean bean = mDatas.get(position);
holder.typeIv.setImageResource(bean.getsImageId());
holder.typeIv.setImageResource(bean.getImageId());
holder.typeTv.setText(bean.getTypename());
holder.beizhuTv.setText(bean.getBeizhu());
holder.moneyTv.setText("¥ "+bean.getMoney());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public View getView(int position, View convertView, ViewGroup parent) {
}
// 获取显示内容
ChartItemBean bean = mDatas.get(position);
holder.iv.setImageResource(bean.getsImageId());
holder.iv.setImageResource(bean.getImageId());
holder.typeTv.setText(bean.getType());
float ratio = bean.getRatio();
String pert = FloatUtils.ratioToPercent(ratio);
Expand Down
14 changes: 7 additions & 7 deletions app/src/main/java/com/eb/easy_bookkeeping/db/AccountBean.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
public class AccountBean {
int id;
String typename; //类型
int sImageId; //被选中类型图片
int ImageId; //类型图片
String beizhu; //备注
float money; //价格
String time ; //保存时间字符串
Expand All @@ -28,12 +28,12 @@ public void setTypename(String typename) {
this.typename = typename;
}

public int getsImageId() {
return sImageId;
public int getImageId() {
return ImageId;
}

public void setsImageId(int sImageId) {
this.sImageId = sImageId;
public void setImageId(int ImageId) {
this.ImageId = ImageId;
}

public String getBeizhu() {
Expand Down Expand Up @@ -95,10 +95,10 @@ public void setKind(int kind) {
public AccountBean() {
}

public AccountBean(int id, String typename, int sImageId, String beizhu, float money, String time, int year, int month, int day, int kind) {
public AccountBean(int id, String typename, int ImageId, String beizhu, float money, String time, int year, int month, int day, int kind) {
this.id = id;
this.typename = typename;
this.sImageId = sImageId;
this.ImageId = ImageId;
this.beizhu = beizhu;
this.money = money;
this.time = time;
Expand Down
14 changes: 7 additions & 7 deletions app/src/main/java/com/eb/easy_bookkeeping/db/ChartItemBean.java
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
package com.eb.easy_bookkeeping.db;

public class ChartItemBean {
int sImageId;
int ImageId;
String type;
float ratio; //所占比例
float totalMoney; //此项的总钱数

public ChartItemBean() {
}

public void setsImageId(int sImageId) {
this.sImageId = sImageId;
public void setImageId(int ImageId) {
this.ImageId = ImageId;
}

public void setType(String type) {
Expand All @@ -25,8 +25,8 @@ public void setTotalMoney(float totalMoney) {
this.totalMoney = totalMoney;
}

public int getsImageId() {
return sImageId;
public int getImageId() {
return ImageId;
}

public String getType() {
Expand All @@ -41,8 +41,8 @@ public float getTotalMoney() {
return totalMoney;
}

public ChartItemBean(int sImageId, String type, float ratio, float totalMoney) {
this.sImageId = sImageId;
public ChartItemBean(int ImageId, String type, float ratio, float totalMoney) {
this.ImageId = ImageId;
this.type = type;
this.ratio = ratio;
this.totalMoney = totalMoney;
Expand Down
21 changes: 10 additions & 11 deletions app/src/main/java/com/eb/easy_bookkeeping/db/DBManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,9 @@ public static List<TypeBean> getTypeList(int kind){
while (cursor.moveToNext()) {
String typename = cursor.getString(cursor.getColumnIndex("typename"));
int imageId = cursor.getInt(cursor.getColumnIndex("imageId"));
int sImageId = cursor.getInt(cursor.getColumnIndex("sImageId"));
int kind1 = cursor.getInt(cursor.getColumnIndex("kind"));
// int kind1 = cursor.getInt(cursor.getColumnIndex("kind"));
int id = cursor.getInt(cursor.getColumnIndex("id"));
TypeBean typeBean = new TypeBean(id, typename, imageId, sImageId, kind);
TypeBean typeBean = new TypeBean(id, typename, imageId, kind);
list.add(typeBean);
}
return list;
Expand All @@ -45,7 +44,7 @@ public static List<TypeBean> getTypeList(int kind){
public static void insertItemToAccounttb(AccountBean bean){
ContentValues values = new ContentValues();
values.put("typename",bean.getTypename());
values.put("sImageId",bean.getsImageId());
values.put("ImageId",bean.getImageId());
values.put("beizhu",bean.getBeizhu());
values.put("money",bean.getMoney());
values.put("time",bean.getTime());
Expand Down Expand Up @@ -88,11 +87,11 @@ public static int deleteItemFromAccounttbById(int id){
String typename = cursor.getString(cursor.getColumnIndex("typename"));
String beizhu = cursor.getString(cursor.getColumnIndex("beizhu"));
String time = cursor.getString(cursor.getColumnIndex("time"));
int sImageId = cursor.getInt(cursor.getColumnIndex("sImageId"));
int ImageId = cursor.getInt(cursor.getColumnIndex("ImageId"));
int kind = cursor.getInt(cursor.getColumnIndex("kind"));
float money = cursor.getFloat(cursor.getColumnIndex("money"));
int day = cursor.getInt(cursor.getColumnIndex("day"));
AccountBean accountBean = new AccountBean(id, typename, sImageId, beizhu, money, time, year, month, day, kind);
AccountBean accountBean = new AccountBean(id, typename, ImageId, beizhu, money, time, year, month, day, kind);
list.add(accountBean);
}
return list;
Expand All @@ -109,13 +108,13 @@ public static int deleteItemFromAccounttbById(int id){
String typename = cursor.getString(cursor.getColumnIndex("typename"));
String bz = cursor.getString(cursor.getColumnIndex("beizhu"));
String time = cursor.getString(cursor.getColumnIndex("time"));
int sImageId = cursor.getInt(cursor.getColumnIndex("sImageId"));
int ImageId = cursor.getInt(cursor.getColumnIndex("ImageId"));
int kind = cursor.getInt(cursor.getColumnIndex("kind"));
float money = cursor.getFloat(cursor.getColumnIndex("money"));
int year = cursor.getInt(cursor.getColumnIndex("year"));
int month = cursor.getInt(cursor.getColumnIndex("month"));
int day = cursor.getInt(cursor.getColumnIndex("day"));
AccountBean accountBean = new AccountBean(id, typename, sImageId, bz, money, time, year, month, day, kind);
AccountBean accountBean = new AccountBean(id, typename, ImageId, bz, money, time, year, month, day, kind);
list.add(accountBean);
}
return list;
Expand Down Expand Up @@ -183,16 +182,16 @@ public static void deleteAllAccount(){
public static List<ChartItemBean>getChartListFromAccounttb(int year,int month,int kind){
List<ChartItemBean>list = new ArrayList<>();
float sumMoneyOneMonth = getSumMoneyOneMonth(year, month, kind); //求出支出或者收入总钱数
String sql = "select typename,sImageId,sum(money)as total from accounttb where year=? and month=? and kind=? group by typename " +
String sql = "select typename,ImageId,sum(money)as total from accounttb where year=? and month=? and kind=? group by typename " +
"order by total desc";
Cursor cursor = db.rawQuery(sql, new String[]{year + "", month + "", kind + ""});
while (cursor.moveToNext()) {
int sImageId = cursor.getInt(cursor.getColumnIndex("sImageId"));
int ImageId = cursor.getInt(cursor.getColumnIndex("ImageId"));
String typename = cursor.getString(cursor.getColumnIndex("typename"));
float total = cursor.getFloat(cursor.getColumnIndex("total"));
//计算所占百分比 total /sumMonth
float ratio = FloatUtils.div(total,sumMoneyOneMonth);
ChartItemBean bean = new ChartItemBean(sImageId, typename, ratio, total);
ChartItemBean bean = new ChartItemBean(ImageId, typename, ratio, total);
list.add(bean);
}
return list;
Expand Down
54 changes: 26 additions & 28 deletions app/src/main/java/com/eb/easy_bookkeeping/db/DBOpenHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,50 +10,48 @@

public class DBOpenHelper extends SQLiteOpenHelper {
public DBOpenHelper(@Nullable Context context) {
super(context,"tally.db" , null, 1);
super(context,"eb.db" , null, 1);
}

// 创建数据库的方法,只有项目第一次运行时,会被调用
@Override
public void onCreate(SQLiteDatabase db) {
// 创建表示类型的表
String sql = "create table typetb(id integer primary key autoincrement,typename varchar(10),imageId integer,sImageId integer,kind integer)";
String sql = "create table typetb(id integer primary key autoincrement,typename varchar(10),imageId integer,kind integer)";
db.execSQL(sql);
insertType(db);
//创建记账表
sql = "create table accounttb(id integer primary key autoincrement,typename varchar(10),sImageId integer,beizhu varchar(80),money float," +
sql = "create table accounttb(id integer primary key autoincrement,typename varchar(10),ImageId integer,beizhu varchar(80),money float," +
"time varchar(60),year integer,month integer,day integer,kind integer)";
db.execSQL(sql);
}

private void insertType(SQLiteDatabase db) {
// 向typetb表当中插入元素
String sql = "insert into typetb (typename,imageId,sImageId,kind) values (?,?,?,?)";
db.execSQL(sql,new Object[]{"其他", R.mipmap.ic_qita,R.mipmap.ic_qita_fs,0});
db.execSQL(sql,new Object[]{"餐饮", R.mipmap.ic_canyin,R.mipmap.ic_canyin_fs,0});
db.execSQL(sql,new Object[]{"交通", R.mipmap.ic_jiaotong,R.mipmap.ic_jiaotong_fs,0});
db.execSQL(sql,new Object[]{"购物", R.mipmap.ic_gouwu,R.mipmap.ic_gouwu_fs,0});
db.execSQL(sql,new Object[]{"服饰", R.mipmap.ic_fushi,R.mipmap.ic_fushi_fs,0});
db.execSQL(sql,new Object[]{"日用品", R.mipmap.ic_riyongpin,R.mipmap.ic_riyongpin_fs,0});
db.execSQL(sql,new Object[]{"娱乐", R.mipmap.ic_yule,R.mipmap.ic_yule_fs,0});
db.execSQL(sql,new Object[]{"零食", R.mipmap.ic_lingshi,R.mipmap.ic_lingshi_fs,0});
db.execSQL(sql,new Object[]{"烟酒茶", R.mipmap.ic_yanjiu,R.mipmap.ic_yanjiu_fs,0});
db.execSQL(sql,new Object[]{"学习", R.mipmap.ic_xuexi,R.mipmap.ic_xuexi_fs,0});
db.execSQL(sql,new Object[]{"医疗", R.mipmap.ic_yiliao,R.mipmap.ic_yiliao_fs,0});
db.execSQL(sql,new Object[]{"住宅", R.mipmap.ic_zhufang,R.mipmap.ic_zhufang_fs,0});
db.execSQL(sql,new Object[]{"水电煤", R.mipmap.ic_shuidianfei,R.mipmap.ic_shuidianfei_fs,0});
db.execSQL(sql,new Object[]{"通讯", R.mipmap.ic_tongxun,R.mipmap.ic_tongxun_fs,0});
db.execSQL(sql,new Object[]{"人情往来", R.mipmap.ic_renqingwanglai,R.mipmap.ic_renqingwanglai_fs,0});
String sql = "insert into typetb (typename,imageId,kind) values (?,?,?)";
db.execSQL(sql,new Object[]{"三餐", R.mipmap.ic_meal,0});
db.execSQL(sql,new Object[]{"零食", R.mipmap.ic_snack,0});
db.execSQL(sql,new Object[]{"水果", R.mipmap.ic_fruit,0});
db.execSQL(sql,new Object[]{"饮品", R.mipmap.ic_drink,0});
db.execSQL(sql,new Object[]{"日用", R.mipmap.ic_daily,0});
db.execSQL(sql,new Object[]{"通讯", R.mipmap.ic_comm,0});
db.execSQL(sql,new Object[]{"交通", R.mipmap.ic_traffic,0});
db.execSQL(sql,new Object[]{"服饰", R.mipmap.ic_clothes,0});
db.execSQL(sql,new Object[]{"学习", R.mipmap.ic_study,0});
db.execSQL(sql,new Object[]{"娱乐", R.mipmap.ic_game,0});
db.execSQL(sql,new Object[]{"数码", R.mipmap.ic_digital,0});
db.execSQL(sql,new Object[]{"礼品", R.mipmap.ic_gift,0});
db.execSQL(sql,new Object[]{"购物", R.mipmap.ic_shopping,0});
db.execSQL(sql,new Object[]{"医疗", R.mipmap.ic_medical,0});
db.execSQL(sql,new Object[]{"其他", R.mipmap.ic_other,0});

db.execSQL(sql,new Object[]{"工资", R.mipmap.ic_salary,1});
db.execSQL(sql,new Object[]{"红包", R.mipmap.ic_hongbao,1});
db.execSQL(sql,new Object[]{"打赏", R.mipmap.ic_reward,1});
db.execSQL(sql,new Object[]{"利息", R.mipmap.ic_interest,1});
db.execSQL(sql,new Object[]{"兼职", R.mipmap.ic_parttime,1});
db.execSQL(sql,new Object[]{"其他", R.mipmap.ic_other,1});

db.execSQL(sql,new Object[]{"其他", R.mipmap.in_qt,R.mipmap.in_qt_fs,1});
db.execSQL(sql,new Object[]{"薪资", R.mipmap.in_xinzi,R.mipmap.in_xinzi_fs,1});
db.execSQL(sql,new Object[]{"奖金", R.mipmap.in_jiangjin,R.mipmap.in_jiangjin_fs,1});
db.execSQL(sql,new Object[]{"借入", R.mipmap.in_jieru,R.mipmap.in_jieru_fs,1});
db.execSQL(sql,new Object[]{"收债", R.mipmap.in_shouzhai,R.mipmap.in_shouzhai_fs,1});
db.execSQL(sql,new Object[]{"利息收入", R.mipmap.in_lixifuji,R.mipmap.in_lixifuji_fs,1});
db.execSQL(sql,new Object[]{"投资回报", R.mipmap.in_touzi,R.mipmap.in_touzi_fs,1});
db.execSQL(sql,new Object[]{"二手交易", R.mipmap.in_ershoushebei,R.mipmap.in_ershoushebei_fs,1});
db.execSQL(sql,new Object[]{"意外所得", R.mipmap.in_yiwai,R.mipmap.in_yiwai_fs,1});
}

// 数据库版本在更新时发生改变,会调用此方法
Expand Down
22 changes: 6 additions & 16 deletions app/src/main/java/com/eb/easy_bookkeeping/db/TypeBean.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
public class TypeBean {
int id;
String typename; //类型名称
int imageId; //未被选中图片id
int simageId; //被选中图片id
int ImageId; //图片id
int kind; //收入-1 支出-0

public int getId() {
Expand All @@ -24,19 +23,11 @@ public void setTypename(String typename) {
}

public int getImageId() {
return imageId;
return ImageId;
}

public void setImageId(int imageId) {
this.imageId = imageId;
}

public int getSimageId() {
return simageId;
}

public void setSimageId(int simageId) {
this.simageId = simageId;
public void setImageId(int ImageId) {
this.ImageId = ImageId;
}

public int getKind() {
Expand All @@ -50,11 +41,10 @@ public void setKind(int kind) {
public TypeBean() {
}

public TypeBean(int id, String typename, int imageId, int simageId, int kind) {
public TypeBean(int id, String typename, int ImageId, int kind) {
this.id = id;
this.typename = typename;
this.imageId = imageId;
this.simageId = simageId;
this.ImageId = ImageId;
this.kind = kind;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ public abstract class BaseRecordFragment extends Fragment implements View.OnClic
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
accountBean = new AccountBean(); //创建对象
accountBean.setTypename("其他");
accountBean.setsImageId(R.mipmap.ic_qita_fs);
accountBean.setTypename("三餐");
accountBean.setImageId(R.mipmap.ic_meal);
}

@Override
Expand Down Expand Up @@ -91,9 +91,9 @@ public void onItemClick(AdapterView<?> parent, View view, int position, long id)
String typename = typeBean.getTypename();
typeTv.setText(typename);
accountBean.setTypename(typename);
int simageId = typeBean.getSimageId();
typeIv.setImageResource(simageId);
accountBean.setsImageId(simageId);
int ImageId = typeBean.getImageId();
typeIv.setImageResource(ImageId);
accountBean.setImageId(ImageId);
}
});
}
Expand Down
Loading

0 comments on commit 492b9f1

Please sign in to comment.