use of com.scwang.smart.refresh.layout.api.RefreshLayout 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.layout.api.RefreshLayout in project wanandroid by KnightAndroid.
the class HomeRecommendFragment method initView.
@Override
protected void initView(Bundle savedInstanceState) {
mDatabind.setClick(new ProxyClick());
EventBus.getDefault().register(this);
mSkeletonScreen = Skeleton.bind(mDatabind.flTest).load(R.layout.activity_home_skeleton).duration(1200).angle(0).show();
bindHeadView();
mTopArticleAdapter = new TopArticleAdapter(new ArrayList<>());
SetInitCustomView.initSwipeRecycleview(home_top_article_rv, new LinearLayoutManager(getActivity()), mTopArticleAdapter, false);
mOfficialAccountAdapter = new OfficialAccountAdapter(new ArrayList<>());
mHomeArticleAdapter = new HomeArticleAdapter(new ArrayList<>());
SetInitCustomView.initSwipeRecycleview(mDatabind.homeRecommendArticleBody, new LinearLayoutManager(getActivity()), mHomeArticleAdapter, true);
topArticleFootView = LayoutInflater.from(getActivity()).inflate(R.layout.home_toparticle_foot, null);
topArticleFootView.findViewById(R.id.home_ll_seemorearticles).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
HomeArticleLogic.getInstance().setArrowAnimate(mTopArticleAdapter, topArticleFootView.findViewById(R.id.home_iv_toparticlearrow), isShowOnlythree);
isShowOnlythree = !isShowOnlythree;
}
});
mDatabind.homeIconFab.setBackgroundTintList(ColorUtils.createColorStateList(CacheUtils.getThemeColor(), CacheUtils.getThemeColor()));
initTopAdapterClick();
initOfficialAccountClick();
initArticleListener();
initTwoLevel();
mDatabind.homeRefreshLayout.setOnMultiListener(new SimpleMultiListener() {
@Override
public void onHeaderMoving(RefreshHeader header, boolean isDragging, float percent, int offset, int headerHeight, int maxDragHeight) {
}
@Override
public void onRefresh(@NonNull RefreshLayout refreshLayout) {
lazyLoadData();
}
@Override
public void onStateChanged(@NonNull RefreshLayout refreshLayout, @NonNull RefreshState oldState, @NonNull RefreshState newState) {
if (oldState == RefreshState.TwoLevel) {
mDatabind.homeTwoLevelContent.animate().alpha(0).setDuration(0);
} else if (oldState == RefreshState.TwoLevelReleased) {
openTwoLevel = true;
mDatabind.homeIconFab.setImageDrawable(ContextCompat.getDrawable(getActivity(), R.drawable.base_icon_bottom));
} else if (oldState == RefreshState.TwoLevelFinish) {
openTwoLevel = false;
mDatabind.homeIconFab.setImageDrawable(ContextCompat.getDrawable(getActivity(), R.drawable.base_icon_up));
}
}
});
mDatabind.homeTwoLevelHeader.setOnTwoLevelListener(new OnTwoLevelListener() {
@Override
public boolean onTwoLevel(@NonNull RefreshLayout refreshLayout) {
mDatabind.homeTwoLevelContent.animate().alpha(1).setDuration(1000);
return true;
}
});
mDatabind.homeTwoLevelHeader.setEnablePullToCloseTwoLevel(false);
mDatabind.homeRefreshLayout.setEnableLoadMore(true);
mDatabind.homeRefreshLayout.setOnLoadMoreListener(this);
}
use of com.scwang.smart.refresh.layout.api.RefreshLayout in project wanandroid by KnightAndroid.
the class SquareFragment method initView.
@Override
protected void initView(Bundle savedInstanceState) {
mDatabind.setClick(new ProcyClick());
loadLoading(mDatabind.squareSharearticleFreshlayout);
mHotKeyAdapter = new HotKeyAdapter(new ArrayList<SearchHotKeyEntity>());
mSquareArticleAdapter = new SquareArticleAdapter(new ArrayList<SquareArticleEntity>());
initListener();
FlexboxLayoutManager flexboxLayoutManager = new FlexboxLayoutManager(getActivity());
// 方向 主轴为水平方向,起点在左端
flexboxLayoutManager.setFlexDirection(FlexDirection.ROW);
// 左对齐
flexboxLayoutManager.setJustifyContent(JustifyContent.FLEX_START);
// flexboxLayoutManager.setAlignItems(AlignItems.CENTER);
SetInitCustomView.initSwipeRecycleview(mDatabind.squareSearchhotRv, flexboxLayoutManager, mHotKeyAdapter, false);
SetInitCustomView.initSwipeRecycleview(mDatabind.squareArticleRv, new LinearLayoutManager(getActivity()), mSquareArticleAdapter, true);
mDatabind.squareSharearticleFreshlayout.setOnRefreshListener(this);
mDatabind.squareSharearticleFreshlayout.setOnLoadMoreListener(this);
EventBus.getDefault().register(this);
View QuestionMenu = LayoutInflater.from(getActivity()).inflate(R.layout.square_question_activity, null);
mSquareQuestionAdapter = new SquareQuestionAdapter(new ArrayList<>());
initAdapterListener();
baserecycleview = QuestionMenu.findViewById(R.id.base_body_rv);
smartRefreshLayout = (SmartRefreshLayout) QuestionMenu.findViewById(R.id.include_square_question);
tv_question_title = ((TextView) QuestionMenu.findViewById(R.id.square_question_tv_title));
tv_question_title.setText(getString(R.string.square_question));
smartRefreshLayout.setOnRefreshListener(refreshLayout -> {
questionPage = 1;
mPresenter.requestSquareQuestion(questionPage);
});
smartRefreshLayout.setOnLoadMoreListener(new OnLoadMoreListener() {
@Override
public void onLoadMore(@NonNull RefreshLayout refreshLayout) {
mPresenter.requestSquareQuestion(questionPage);
}
});
SetInitCustomView.initSwipeRecycleview(baserecycleview, new LinearLayoutManager(getActivity()), mSquareQuestionAdapter, true);
mDatabind.squareRoot.addView(QuestionMenu);
LoadSir loadSir = LoadSir.getDefault();
mViewLoadService = loadSir.register(QuestionMenu.findViewById(R.id.include_square_question), new Callback.OnReloadListener() {
@Override
public void onReload(View v) {
mViewLoadService.showCallback(LoadCallBack.class);
}
});
mViewLoadService.showCallback(LoadCallBack.class);
mRightLottieAnimation = new RightLottieAnimation.GuillotineBuilder(QuestionMenu, QuestionMenu.findViewById(R.id.square_question_lefticon), mDatabind.squareIvQuestion, mSquareQuestionAdapter).setStartDelay(RIPPLE_DURATION).setActionBarViewForAnimation(mDatabind.squareToolbar).setClosedOnStart(true).setGuillotineListener(new RightLottieListener() {
@Override
public void onRightLottieOpened() {
mDatabind.squareFabUp.setVisibility(View.GONE);
mViewLoadService.showCallback(LoadCallBack.class);
mPresenter.requestSquareQuestion(questionPage);
}
@Override
public void onRightLottieClosed() {
questionPage = 1;
mDatabind.squareFabUp.setVisibility(View.VISIBLE);
}
}).build();
}
use of com.scwang.smart.refresh.layout.api.RefreshLayout in project xxf_android by NBXXF.
the class BaseApplication method onCreate.
@Override
public void onCreate() {
super.onCreate();
Log.d("====>app", "app:" + ApplicationInitializer.applicationContext);
Toast.makeText(this, "yes:" + ApplicationInitializer.applicationContext, Toast.LENGTH_LONG).show();
INSTANCE = this;
RxJavaPlugins.setErrorHandler(new Consumer<Throwable>() {
@Override
public void accept(Throwable throwable) throws Exception {
Log.e("=============>", "t:" + Thread.currentThread().getName(), throwable);
}
});
XXF.init(new XXF.Builder(this, new ProgressHUDFactory.ProgressHUDProvider() {
@Override
public ProgressHUD onCreateProgressHUD(LifecycleOwner lifecycleOwner) {
if (lifecycleOwner instanceof FragmentActivity) {
return new XXFLoadingDialog((FragmentActivity) lifecycleOwner);
} else if (lifecycleOwner instanceof Fragment) {
return new XXFLoadingDialog(((Fragment) lifecycleOwner).getContext());
}
return null;
}
}).setUserInfoProvider(new XXFUserInfoProvider() {
@Override
public String getUserId() {
return "xxx_7764";
}
}).setErrorHandler(new BiConsumer<Integer, Throwable>() {
@Override
public void accept(Integer flag, Throwable throwable) throws Throwable {
ToastUtils.showToast("error:" + throwable, ToastUtils.ToastType.ERROR, flag);
}
}));
// 可做本module 相关sdk初始化
// 设置全局的Header构建器
SmartRefreshLayout.setDefaultRefreshHeaderCreator(new DefaultRefreshHeaderCreator() {
@NonNull
@Override
public RefreshHeader createRefreshHeader(@NonNull Context context, @NonNull RefreshLayout layout) {
return new XXFJumpRefreshHeader(context);
}
});
SmartRefreshLayout.setDefaultRefreshFooterCreator(new DefaultRefreshFooterCreator() {
@NonNull
@Override
public RefreshFooter createRefreshFooter(@NonNull Context context, @NonNull RefreshLayout layout) {
return new XXFJumpRefreshFooter(context);
}
});
// XXFStateLayout.setDefaultEmptyText(R.string.app_name);
List<Integer> ignores = new ArrayList<>();
ignores.addAll(ResourcesUtil.getStringResources(androidx.appcompat.R.class));
ignores.addAll(ResourcesUtil.getDrawableResources(androidx.appcompat.R.class));
// ResourcesUtil.checkResources(ignores);
setVmPolicy();
}
use of com.scwang.smart.refresh.layout.api.RefreshLayout in project iot-device-java by tencentyun.
the class TmeMainActivity method initView.
private void initView() {
mGetSongBtn = findViewById(R.id.request_song);
mSearchIv = findViewById(R.id.search);
mPreIv = findViewById(R.id.iv_pre);
mNextIv = findViewById(R.id.iv_next);
mPlayIv = findViewById(R.id.iv_play);
mPlayModeIv = findViewById(R.id.iv_play_mode);
mInputEt = findViewById(R.id.input);
mCurrentSongTv = findViewById(R.id.tv_current_song);
mPlayList = findViewById(R.id.play_list);
mSmartRefreshLayout = findViewById(R.id.smart_refreshLayout);
mTimeTv = findViewById(R.id.tv_time);
mSeekBar = findViewById(R.id.sb_seek_bar);
mVolumeSeekBar = findViewById(R.id.sb_volume);
mSwitch = findViewById(R.id.tb_switch);
mSpinner = findViewById(R.id.sp_quality);
mSmartRefreshLayout.setEnableLoadMore(true);
mSmartRefreshLayout.setRefreshFooter(new ClassicsFooter(this));
mGetSongBtn.setOnClickListener(this);
mSearchIv.setOnClickListener(this);
mPreIv.setOnClickListener(this);
mNextIv.setOnClickListener(this);
mPlayIv.setOnClickListener(this);
mPlayModeIv.setOnClickListener(this);
mPlayList.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false));
mPlayList.addItemDecoration(new DividerItemDecoration(this, DividerItemDecoration.VERTICAL));
mAdapter = new SongListAdapter(this, mSongList);
mAdapter.setOnItemClickListener(new SongListAdapter.ItemClickListener() {
@Override
public void onItemClick(View view, int position) {
Song song = mSongList.get(position);
mCurrentSongTv.setText(song.songName + "-" + song.singerName);
playSong(position);
}
});
mPlayList.setAdapter(mAdapter);
mSmartRefreshLayout.setOnLoadMoreListener(new OnLoadMoreListener() {
@Override
public void onLoadMore(RefreshLayout refreshLayout) {
refreshLayout.finishLoadMore();
page++;
if (operationType == TYPE_SEARCH) {
doSearch(keyword);
} else if (operationType == TYPE_SONG_LIST) {
getSongListById(songListId, songListType);
}
}
});
mSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
if (fromUser) {
TXLog.d(TAG, "seek =" + seekValue);
seekValue = progress;
UltimateSongPlayer.getInstance().seekTo(seekValue * 1000);
}
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
mIsSeekBarTouching = true;
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
if (seekValue >= 60) {
SongInfo songInfo = UltimateSongPlayer.getInstance().getSongInfo();
if (songInfo != null && songInfo.isTryListen()) {
TmeMainActivity.this.runOnUiThread(() -> ToastUtil.showS("当前歌曲只支持试听60秒~"));
}
}
UltimateSongPlayer.getInstance().seekTo(seekValue * 1000);
mIsSeekBarTouching = false;
reportProperty(Common.PROPERTY_PLAY_POSITION, seekValue);
}
});
mVolumeSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
if (fromUser) {
TXLog.d(TAG, "seek =" + volumeSeekValue);
volumeSeekValue = progress;
mAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC, progress, AudioManager.FLAG_PLAY_SOUND);
}
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
int volume = (int) ((volumeSeekValue / (maxVolume * 1.00)) * Common.TOTOAL_VOLUME_DURATION);
reportProperty(Common.PROPERTY_VOLUME, volume);
}
});
mSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
if (mDataTemplateSample != null)
return;
mDataTemplateSample = new TmeDataTemplateSample(TmeMainActivity.this, mBrokerURL, mProductID, mDevName, mDevPSK, new SelfMqttActionCallBack(mProductID, mDevName), JSON_FILE_NAME, new SelfDownStreamCallBack(), mAuthCallback);
mDataTemplateSample.connect();
} else {
if (mDataTemplateSample == null)
return;
mDataTemplateSample.disconnect();
mDataTemplateSample = null;
}
}
});
mSpinner.setAdapter(new ArrayAdapter<>(this, android.R.layout.simple_spinner_dropdown_item, qualityStrArray));
mSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
if (isGetStatusReply) {
UltimateSongPlayer.getInstance().changeQuality(qualities[position]);
isGetStatusReply = false;
} else {
if (UltimateSongPlayer.getInstance().getCurrentPlayQuality() == qualities[position]) {
return;
}
// 当前歌曲详情
SongInfo songInfo = UltimateSongPlayer.getInstance().getSongInfo();
if (songInfo == null) {
ToastUtil.showS("无法切换音质");
parent.setSelection(0);
return;
}
if (songInfo.isTryListen()) {
ToastUtil.showS("试听中,无法切换音质");
parent.setSelection(0);
return;
}
if (songInfo.getSupportQualities().contains(qualities[position])) {
UltimateSongPlayer.getInstance().changeQuality(qualities[position]);
reportProperty(Common.PROPERTY_RECOMMEND_QUALITY, position);
} else {
parent.setSelection(0);
ToastUtil.showS(String.format("当前歌曲不支持%s音质", qualityStrArray[position]));
}
}
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
});
}
Aggregations