package com.account.work.activity;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Rect;
import android.os.Build;
import android.os.Handler;
import android.os.Looper;
import android.support.design.widget.AppBarLayout;
import android.support.design.widget.FloatingActionButton;
import android.support.v4.app.ActivityCompat;
import android.support.v4.app.ActivityOptionsCompat;
import android.support.v4.widget.NestedScrollView;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AlertDialog;
import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;
import android.text.TextUtils;
import android.transition.Fade;
import android.transition.Slide;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.Window;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.account.work.R;
import com.account.work.activity.base.BaseActivity;
import com.account.work.adapter.MaterialAdapter;
import com.account.work.adapter.TimeLineAdapter;
import com.account.work.adapter.base.RecyclerBaseAdapter;
import com.account.work.app.Contants;
import com.account.work.db.DbHelper;
import com.account.work.helper.TimeHelper;
import com.account.work.model.Bill;
import com.account.work.model.Budget;
import com.account.work.utils.LogUtils;
import com.account.work.utils.MatcherUtils;
import com.account.work.utils.Preferences;
import com.account.work.utils.ScreenUtils;
import com.account.work.utils.SnackbarUtils;
import com.account.work.utils.building.BindLayout;
import com.account.work.utils.building.BindView;
import com.account.work.utils.depend.AppBarStateChangeListener;
import com.chaychan.viewlib.NumberRunningTextView;
import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.Calendar;
/**
* Setting interface
*/
@BindLayout(R.layout.activity_main)
public class MainActivity extends BaseActivity implements View.OnClickListener {
@BindView(R.id.fab)
FloatingActionButton fab;
@BindView(R.id.toolbar)
Toolbar toolbar;
@BindView(R.id.appbar_layout)
AppBarLayout appBarLayout;
@BindView(R.id.tv_money)
NumberRunningTextView tvExpendMoney;
@BindView(R.id.tv_income)
TextView tvShowIncome;
@BindView(R.id.tv_budget)
TextView tvShowBudget;
@BindView(R.id.tv_overspend)
TextView tvOverSpend;
@BindView(R.id.nsv_scroll_view)
NestedScrollView nsvScrollView;
@BindView(R.id.recycler_view)
RecyclerView recyclerView;
@BindView(R.id.ll_status_nothing)
LinearLayout llStatusNothing;
protected Handler handler = new Handler(Looper.getMainLooper());
private ArrayList<Bill> billsList = new ArrayList<>();
private RecyclerBaseAdapter itemAdapter;
private LinearLayoutManager linearLayoutManager;
private boolean isTimeLineTheme;
private Bill deleteBill;
private int deleteItem;
private int yearMonth;
private float budgetValue;
@Override
protected void initWindow() {
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
// Page Jump animation
getWindow().setEnterTransition(new Slide().setDuration(500));
getWindow().setReenterTransition(new Fade().setDuration(300));
getWindow().setExitTransition(new Fade().setDuration(300));
// Use element sharing animations to add
getWindow().requestFeature(Window.FEATURE_CONTENT_TRANSITIONS);
}
}
@Override
protected void initView() {
initToolbar();
initRecyclerView();
updateHeader();
}
private void updateHeader() {
initYearMonth();
updateBudget(yearMonth);
}
private void updateBudget(final int yearMonth) {
new Thread(new Runnable() {
@Override
public void run() {
final Budget queryBudget = new DbHelper().queryBudget(yearMonth);
handler.post(new Runnable() {
@Override
public void run() {
if (queryBudget == null) {
tvShowBudget.setText("预算");
return;
}
budgetValue = queryBudget.getValue();
tvShowBudget.setText(budgetValue + "");
}
});
}
}).start();
}
private void initToolbar() {
setSupportActionBar(toolbar);
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
Calendar calendar = Calendar.getInstance();
int month = calendar.get(Calendar.MONTH) + 1;
actionBar.setTitle(month + " 月");
}
}
/**
* Initialize to today's date
*/
private void initYearMonth() {
Calendar calendar = Calendar.getInstance();
int year = calendar.get(Calendar.YEAR);
int month = calendar.get(Calendar.MONTH) + 1;
yearMonth = year * 100 + month;
}
private void initRecyclerView() {
linearLayoutManager = new LinearLayoutManager(this);
recyclerView.setItemAnimator(new DefaultItemAnimator());
linearLayoutManager.setSmoothScrollbarEnabled(true);
linearLayoutManager.setAutoMeasureEnabled(true);
recyclerView.setLayoutManager(linearLayoutManager);
recyclerView.setHasFixedSize(true);
recyclerView.setNestedScrollingEnabled(false);
selectAdapter();
}
private void selectAdapter() {
isTimeLineTheme = getIsTimeLime();
if (isTimeLineTheme) {
itemAdapter = new TimeLineAdapter(R.layout.item_time_line, billsList);
recyclerView.addItemDecoration(new RecyclerView.ItemDecoration() {
@Override
public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
outRect.set(0, 0, 0, 0);
}
});
} else {
itemAdapter = new MaterialAdapter(R.layout.item_material, billsList);
recyclerView.addItemDecoration(new RecyclerView.ItemDecoration() {
@Override
public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
outRect.set(0, ScreenUtils.dp2px(2), 0, 0);
}
});
}
setItemClickListener(itemAdapter);
notifyView();
recyclerView.setAdapter(itemAdapter);
}
/**
* Judge whether it is timeline style
*/
private boolean getIsTimeLime() {
boolean result = Preferences.getBoolean(Contants.KEY_TIME_LINE_THEME, false);
return result;
}
@Override
protected void onResume() {
super.onResume();
/**
* When you return to the page, check to see if the settings change
*/
applyChanged();
}
private void applyChanged() {
boolean isTimeLimeTheme = getIsTimeLime();
if (isTimeLimeTheme != this.isTimeLineTheme) {
recreate();
}
updateHeader();
}
@Override
protected void initListener() {
tvShowBudget.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(MainActivity.this, HomeActivity.class);
startActivity(intent);
}
});
fab.setOnClickListener(this);
appBarLayout.addOnOffsetChangedListener(new AppBarStateChangeListener() {
@Override
public void onStateChanged(AppBarLayout appBarLayout, State state) {
if (state == State.EXPANDED) {
fab.show();
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
基于Android Studio开发的个记账工具APP源码,Android 个人记账APP源码.zip于安卓基础知识点开发的个人记账工具,其中包括记录当天收支情况,计算当天以及当月共收支总钱数,能查看历史账单,能对于每月收支情况进行图标分析,百分比分析, 能够搜索用户关于某种记录的全部收支情况等功能。基本上能够解决个人记账的所有问题,界面简约美观,滑动流畅。 项目重要技术点: 1-绘制布局,掌握android基本view控件的属性和使用 2-熟练掌握Activity页面展示,跳转和传值 3-使用碎片加载界面,滑动视图切换页面 4-自定义对话框 5-自定义软键盘绘制和使用 6-列表视图以及网格视图的适配器使用和页面加载 7-使用Android自带数据库,熟练创建表,并进行增删改查 8-定义drawable文件,设定布局以及控件样式 9-使用MPAndroidChart第三方框架绘制柱状图 基于Android Studio开发的个记账工具APP源码,Android 个人记账APP源码.zip于安卓基础知识点开发的个人记账工具,其中包括记录当天收支情况,计算当天以及当月共收支总钱数,能查看历
资源推荐
资源详情
资源评论
收起资源包目录
基于Android Studio开发的个记账工具APP源码,Android 个人记账APP源码.zip (375个子文件)
gradlew.bat 2KB
gradlew.bat 2KB
.gitignore 118B
.gitignore 47B
.gitignore 7B
build.gradle 2KB
build.gradle 576B
settings.gradle 19B
gradlew 5KB
gradlew 5KB
bmob-sdk-3.4.6.jar 488KB
gradle-wrapper.jar 52KB
gradle-wrapper.jar 52KB
demo.jar 6KB
MainActivity.java 18KB
AddActivity.java 16KB
TypeSelectFragment.java 15KB
RecyclerViewFragment.java 13KB
TimeLineAdapter.java 10KB
DbHelper.java 10KB
SPUtils.java 9KB
ImageEditUtils.java 9KB
StatActivity.java 7KB
HomeActivity.java 7KB
StatViewAdapter.java 6KB
MainActivity.java 6KB
RecyclerBaseAdapter.java 5KB
SplashActivity.java 5KB
TimeHelper.java 5KB
MaterialAdapter.java 4KB
GuiUtils.java 4KB
ScreenUtils.java 4KB
EditNoteActivity.java 4KB
DialogHelper.java 4KB
PChartHelper.java 3KB
LoginActivity.java 3KB
DBManager.java 3KB
ListDialogHelper.java 3KB
ChartStat.java 3KB
Cache.java 3KB
EditDialogHelper.java 3KB
BaseLazyFragment.java 3KB
BillDatabaseHelper.java 3KB
Preferences.java 3KB
MoneyEditHelper.java 3KB
PreferenceSwitchView.java 2KB
MyAdapter.java 2KB
BaseActivity.java 2KB
Bill.java 2KB
ColorImageView.java 2KB
TypeAdapter.java 2KB
Binder.java 2KB
DateCheckHelper.java 2KB
BottomDialog.java 2KB
LogUtils.java 2KB
FragmentAdapter.java 1KB
TimeUtils.java 1KB
AppBarStateChangeListener.java 1KB
SnackbarUtils.java 1KB
ArrayUtils.java 1KB
MatcherUtils.java 1KB
NoteDBOpenHelper.java 1KB
ToastUtils.java 1KB
app.java 877B
MinorType.java 875B
BizierEvaluator2.java 842B
Contants.java 802B
ProgressDialogHelper.java 792B
BaseFragment.java 769B
ExampleInstrumentedTest.java 746B
SpacesItemDecoration.java 706B
Note.java 685B
MyValueFormatter.java 667B
Budget.java 600B
ExampleUnitTest.java 399B
BindLayout.java 382B
DialogListener.java 359B
BindView.java 351B
StatCustomTimeOperation.java 309B
Stat.java 253B
head_img.jpg 10KB
home_bg.png 100KB
ic_launcher_accent.png 45KB
ic_launcher.png 45KB
ic_launcher.png 13KB
ic_launcher.png 9KB
ic_bus.png 8KB
notes.png 7KB
ic_breakfast.png 7KB
ic_part_time_jab.png 6KB
ic_travel.png 6KB
ic_music.png 6KB
ic_shoping.png 6KB
ic_lend.png 6KB
ic_game.png 6KB
ic_home.png 6KB
ic_custom.png 6KB
ic_launcher.png 5KB
ic_flight.png 5KB
ic_car.png 5KB
共 375 条
- 1
- 2
- 3
- 4
资源评论
程序员张小妍
- 粉丝: 1w+
- 资源: 3173
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功