use of com.scwang.smart.refresh.header.BezierRadarHeader in project Diary by HibaraAi.
the class MainActivity method bindViewAndSetListener.
@SuppressLint("NonConstantResourceId")
private void bindViewAndSetListener() {
toolbar = findViewById(R.id.main_toolbar);
SharedPreferences sharedPreferences = BaseUtils.getDefaultSharedPreferences();
boolean showUsernameInBar = sharedPreferences.getBoolean("showUsernameInBar", false);
if (showUsernameInBar) {
CollapsingToolbarLayout toolbarLayout = findViewById(R.id.main_title);
toolbarLayout.setTitle(MyConfiguration.getInstance().getUsername());
}
setSupportActionBar(toolbar);
drawerLayout = findViewById(R.id.drawer_activity_main);
navView = findViewById(R.id.nav_view);
ActionBar actionBar = getSupportActionBar();
if (null != actionBar) {
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setHomeAsUpIndicator(R.drawable.nav_home);
actionBar.setTitle("");
}
// 侧滑菜单的按钮事件在这
navView.setNavigationItemSelectedListener(item -> {
switch(item.getItemId()) {
case R.id.nav_mine:
{
BaseUtils.gotoActivity(MainActivity.this, MineGameActivity.class);
break;
}
case R.id.nav_settings:
{
BaseUtils.gotoActivity(MainActivity.this, SettingsActivity.class);
break;
}
case R.id.nav_help:
{
BaseUtils.gotoActivity(MainActivity.this, HelpActivity.class);
break;
}
case R.id.nav_time:
{
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("查找指定时间段的日记");
builder.setMessage("提示:如果时间段内的日记数量很多,则查找过程可能会很久,尽量缩短查找时间段。\n只选一个日期则查找当天的日记\n");
TextView timeOne = new TextView(MainActivity.this);
TextView timeTwo = new TextView(MainActivity.this);
timeOne.setOnClickListener(v -> {
Calendar calendar = Calendar.getInstance();
DatePickerDialog datePickerDialog = new DatePickerDialog(MainActivity.this, (view, year, month, dayOfMonth) -> {
timeOne.setText(year + "-" + (month + 1) + "-" + dayOfMonth);
}, calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DAY_OF_MONTH));
datePickerDialog.setCancelable(false);
datePickerDialog.show();
});
timeTwo.setOnClickListener(v -> {
Calendar calendar = Calendar.getInstance();
DatePickerDialog datePickerDialog = new DatePickerDialog(MainActivity.this, (view, year, month, dayOfMonth) -> {
timeTwo.setText(year + "-" + (month + 1) + "-" + dayOfMonth);
}, calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DAY_OF_MONTH));
datePickerDialog.setCancelable(false);
datePickerDialog.show();
});
timeOne.setBackgroundResource(R.drawable.background_input);
timeOne.setHint("点击选择日期一");
timeTwo.setBackgroundResource(R.drawable.background_input);
timeTwo.setHint("点击选择日期二");
LinearLayout linearLayout = new LinearLayout(this);
linearLayout.setOrientation(LinearLayout.VERTICAL);
linearLayout.addView(timeOne);
linearLayout.addView(timeTwo);
builder.setView(linearLayout);
builder.setCancelable(false);
builder.setPositiveButton("确定", (dialog1, which) -> {
String timeOneStr = timeOne.getText().toString();
String timeTwoStr = timeTwo.getText().toString();
if (!"".equals(timeOneStr) || !"".equals(timeTwoStr)) {
if ("".equals(timeOneStr)) {
timeOneStr = timeTwoStr;
} else if ("".equals(timeTwoStr)) {
timeTwoStr = timeOneStr;
}
Intent intent = new Intent(MainActivity.this, DiaryListActivity.class);
intent.putExtra(DiaryListActivity.OPEN_FROM_TYPE, DiaryListActivity.OPEN_FROM_TIME_AXIS);
intent.putExtra(DiaryListActivity.DATE_ONE, timeOneStr);
intent.putExtra(DiaryListActivity.DATE_TWO, timeTwoStr);
startActivity(intent);
} else {
BaseUtils.longTipInCoast(MainActivity.this, "一个日期都不选?就是你这种不按照正常逻辑使用软件的人,才导致我们程序员要考虑各种各样的奇怪情况!");
}
});
builder.setNegativeButton("取消", null);
builder.show();
break;
}
case R.id.nav_temp:
{
Intent intent = new Intent(MainActivity.this, DiaryListActivity.class);
intent.putExtra(DiaryListActivity.OPEN_FROM_TYPE, DiaryListActivity.OPEN_FROM_TEMP_DIARY);
startActivity(intent);
break;
}
case R.id.nav_asc:
{
Intent intent = new Intent(this, PicturesActivity.class);
intent.putExtra(PicturesActivity.OPEN_FROM_TYPE, PicturesActivity.OPEN_FROM_VIDEO);
startActivity(intent);
break;
}
case R.id.nav_label:
{
Intent intent = new Intent(MainActivity.this, DiaryListActivity.class);
intent.putExtra(DiaryListActivity.OPEN_FROM_TYPE, DiaryListActivity.OPEN_FROM_LABEL_LIST);
startActivity(intent);
break;
}
case R.id.nav_former_years:
{
Intent intent = new Intent(MainActivity.this, TimeAscActivity.class);
intent.putExtra(TimeAscActivity.OPEN_FROM_TYPE, TimeAscActivity.OPEN_FROM_FORMER_YEARS);
startActivity(intent);
break;
}
case R.id.nav_special_day:
{
BaseUtils.gotoActivity(this, SpecialDayActivity.class);
break;
}
case R.id.nav_pic:
{
BaseUtils.gotoActivity(this, PicturesActivity.class);
break;
}
default:
{
Toast.makeText(MainActivity.this, item.getTitle(), Toast.LENGTH_SHORT).show();
break;
}
}
return true;
});
// 下拉刷新控件及RecyclerView
recyclerView = findViewById(R.id.main_recyclerview);
refreshLayout = findViewById(R.id.main_refresh);
refreshLayout.setRefreshHeader(new BezierRadarHeader(this).setEnableHorizontalDrag(true).setPrimaryColor(Color.parseColor("#FA7298")));
refreshLayout.setRefreshFooter(new BallPulseFooter(this).setSpinnerStyle(SpinnerStyle.FixedBehind));
refreshLayout.setOnRefreshListener(refreshLayout -> {
refreshDiary();
refreshLayout.finishRefresh();
});
refreshLayout.setOnLoadMoreListener(refreshLayout -> {
loadMoreDiary();
refreshLayout.finishLoadMore();
});
initNavHeader();
}
use of com.scwang.smart.refresh.header.BezierRadarHeader in project Diary by HibaraAi.
the class TimeAscActivity method bindViewAndSetListener.
@SuppressLint("NonConstantResourceId")
private void bindViewAndSetListener() {
setSupportActionBar(findViewById(R.id.default_toolbar_inc));
actionBar = getSupportActionBar();
if (null != actionBar) {
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setTitle("时间升序浏览");
}
fab = findViewById(R.id.asc_fab);
fab.setOnClickListener(v -> {
recyclerView.scrollToPosition(0);
BaseUtils.shortTipInSnack(this.recyclerView, "已返回顶部 OvO");
});
recyclerView = findViewById(R.id.asc_recyclerview);
refreshLayout = findViewById(R.id.asc_refresh);
refreshLayout.setRefreshHeader(new BezierRadarHeader(this).setEnableHorizontalDrag(true).setPrimaryColor(Color.parseColor("#FA7298")));
refreshLayout.setRefreshFooter(new BallPulseFooter(this).setSpinnerStyle(SpinnerStyle.FixedBehind));
refreshLayout.setOnRefreshListener(refreshLayout -> {
refreshDiary();
refreshLayout.finishRefresh();
});
refreshLayout.setOnLoadMoreListener(refreshLayout -> {
loadMoreDiary();
refreshLayout.finishLoadMore();
});
}
Aggregations