Skip to content

Commit

Permalink
fix(*):修复执行算法的bug,加入执行动画,将代码封装和优化
Browse files Browse the repository at this point in the history
  • Loading branch information
dyjcow committed Jul 5, 2022
1 parent 620da6c commit c633b92
Show file tree
Hide file tree
Showing 9 changed files with 303 additions and 255 deletions.
2 changes: 1 addition & 1 deletion .idea/misc.xml

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

3 changes: 3 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ dependencies {
implementation 'com.github.bumptech.glide:glide:4.13.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.13.0'

//沉浸式
implementation 'com.gitee.zackratos:UltimateBarX:0.8.0'


testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,18 +83,18 @@ protected void onDestroy() {
}

@Override
public void showLoading() {
MyUtil.showLoading(this);
public void showLoading(boolean isShow) {
if (isShow) MyUtil.showLoading(this);
}

@Override
public void SuccessHideLoading() {
new Handler().postDelayed(MyUtil::dismissSuccessLoading,500);
public void SuccessHideLoading(boolean isShow) {
if (isShow) new Handler().postDelayed(MyUtil::dismissSuccessLoading,500);
}

@Override
public void FailedHideLoading() {
new Handler().postDelayed(MyUtil::dismissFailedLoading,500);
public void FailedHideLoading(boolean isShow) {
if (isShow) new Handler().postDelayed(MyUtil::dismissFailedLoading,500);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ public interface BaseView {
/**
* 展示载入动画
*/
void showLoading();
void showLoading(boolean isShow);

/**
* 操作成功隐藏dialog和显示成功
*/
void SuccessHideLoading();
void SuccessHideLoading(boolean isShow);

/**
* 操作失败隐藏dialog和显示失败
*/
void FailedHideLoading();
void FailedHideLoading(boolean isShow);
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.dyj.requestpagingscheduleemulator.module.main.activity;

import android.graphics.Color;
import android.os.Handler;

import com.dyj.requestpagingscheduleemulator.base.BaseActivity;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
package com.dyj.requestpagingscheduleemulator.module.result.activity;

import androidx.appcompat.app.AppCompatActivity;

import android.view.View;

import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import android.graphics.Color;
import android.os.Bundle;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.bumptech.glide.request.RequestOptions;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.dyj.requestpagingscheduleemulator.R;
import com.dyj.requestpagingscheduleemulator.base.BaseActivity;
import com.dyj.requestpagingscheduleemulator.bean.PageData;
Expand All @@ -22,6 +23,7 @@
import com.dyj.requestpagingscheduleemulator.util.ActivityUtil;
import com.dyj.requestpagingscheduleemulator.util.MyUtil;
import com.dyj.requestpagingscheduleemulator.util.ToastUtil;
import com.zackratos.ultimatebarx.ultimatebarx.java.UltimateBarX;

import java.util.List;

Expand All @@ -43,7 +45,9 @@ protected ResultPresenter createPresenter() {
*/
@Override
protected void initView() {
getWindow().setStatusBarColor(Color.TRANSPARENT);
UltimateBarX.statusBarOnly(this)
.transparent()
.apply();
String PIC_URL = "https://www.lxtlovely.top/getpic.php?rand=true";
showPic(PIC_URL);
}
Expand All @@ -54,23 +58,17 @@ protected void initView() {
@Override
protected void initData() {
int data = ActivityUtil.getIntentData();
getBinding().button1CreateData.setOnClickListener(v -> presenter.random());
switch (data){
case GlobalConstant.OPT:
getBinding().button1Todo.setOnClickListener(v -> presenter.OPT());
break;
case GlobalConstant.LRU:
getBinding().button1Todo.setOnClickListener(v -> presenter.LRU());
break;
case GlobalConstant.FIFO:
getBinding().button1Todo.setOnClickListener(v -> presenter.FIFO());
break;
default:
break;

}
getBinding().button1CreateData.setOnClickListener(v -> presenter.random(true));
getBinding().button2Todo.setOnClickListener(v -> presenter.option(data,true));
getBinding().refreshLayout.setOnRefreshListener(v -> {
presenter.random(false);
presenter.option(data,false);
getBinding().refreshLayout.finishRefresh(500);
});
}



/**
* 展示背景图
*/
Expand All @@ -93,6 +91,8 @@ public void showPic(String url) {
@Override
public void showInstructions(List<Integer> datas) {
DataAdapter adapter = new DataAdapter(R.layout.item_data,datas);
adapter.setAnimationWithDefault(BaseQuickAdapter.AnimationType.ScaleIn);
adapter.setAnimationFirstOnly(true);
getBinding().rvDatas.setAdapter(adapter);
getBinding().rvDatas.setLayoutManager(new LinearLayoutManager(this, RecyclerView.VERTICAL, false));

Expand All @@ -104,6 +104,8 @@ public void showInstructions(List<Integer> datas) {
@Override
public void showPages(List<PageData> list) {
PageAdapter adapter = new PageAdapter(R.layout.item_page,list);
adapter.setAnimationWithDefault(BaseQuickAdapter.AnimationType.ScaleIn);
adapter.setAnimationFirstOnly(true);
getBinding().rvPages.setAdapter(adapter);
getBinding().rvPages.setLayoutManager(new LinearLayoutManager(this, RecyclerView.HORIZONTAL, false));
}
Expand All @@ -115,11 +117,30 @@ public void showPages(List<PageData> list) {
public void showMissingPageRate(int lost) {
double res = (double)lost/320;
String text = 100*res + "%";
getBinding().missingPageRate.setText(text);
getBinding().tvMissingPageRate.setText(text);
}

/**
* 展示error toast
*/
@Override
public void showReInit() {
ToastUtil.showToast(MyUtil.getString(R.string.reinit));
}

/**
* 展示data数据
*/
@Override
public void showRVData() {
if (getBinding().rvDatas.getVisibility() == View.GONE) getBinding().rvDatas.setVisibility(View.VISIBLE);
}

/**
* 展示pages数据
*/
@Override
public void showRVPages() {
if (getBinding().rvPages.getVisibility() == View.GONE) getBinding().rvPages.setVisibility(View.VISIBLE);
}
}
Loading

0 comments on commit c633b92

Please sign in to comment.