当我刷新时,SwipeRefreshLayout的动画会显示,但在onRefresh()运行时会被冻结,只有当onRefresh()完成后才开始旋转。
主活动(MainActivity)。
主活动(MainActivity)。
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
myFAB = (FloatingActionButton) findViewById(R.id.myFAB);
recyclerView = (RecyclerView) findViewById(R.id.rv);
recyclerView.setHasFixedSize(true);
LinearLayoutManager llm = new LinearLayoutManager(this);
recyclerView.setLayoutManager(llm);
recyclerView.addItemDecoration(new SimpleDividerItemDecoration(this));
callCadastroEncoemnda();
callPackageList();
swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipeRefreshLayout);
swipeRefreshLayout.setOnRefreshListener(this);
swipeRefreshLayout.setColorSchemeResources(
android.R.color.holo_blue_bright,
android.R.color.holo_green_light,
android.R.color.holo_orange_light,
android.R.color.holo_red_light);
}
onRefresh:
@Override
public void onRefresh() {
swipeRefreshLayout.setRefreshing(true);
Update.updateAll(MainActivity.this);
//Check if the data change
if (!packages.equals(dao.getPackages())) {
adapter.updateList(dao.getPackages());
}
swipeRefreshLayout.setRefreshing(false);
}