本文整理汇总了Java中com.scwang.smartrefresh.layout.api.RefreshLayout.autoRefresh方法的典型用法代码示例。如果您正苦于以下问题:Java RefreshLayout.autoRefresh方法的具体用法?Java RefreshLayout.autoRefresh怎么用?Java RefreshLayout.autoRefresh使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.scwang.smartrefresh.layout.api.RefreshLayout
的用法示例。
在下文中一共展示了RefreshLayout.autoRefresh方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCreate
import com.scwang.smartrefresh.layout.api.RefreshLayout; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_practice_feedlist);
final Toolbar toolbar = (Toolbar)findViewById(R.id.toolbar);
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
final RefreshLayout refreshLayout = (RefreshLayout) findViewById(R.id.refreshLayout);
if (isFirstEnter) {
isFirstEnter = false;
refreshLayout.autoRefresh();
}
}
示例2: onCreate
import com.scwang.smartrefresh.layout.api.RefreshLayout; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_practice_banner);
final Toolbar toolbar = (Toolbar)findViewById(R.id.toolbar);
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
final RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recyclerView);
final RefreshLayout refreshLayout = (RefreshLayout) findViewById(R.id.refreshLayout);
mAdapter = new QuickAdapter();
recyclerView.addItemDecoration(new DividerItemDecoration(this, VERTICAL));
recyclerView.setLayoutManager(new LinearLayoutManager(this));
recyclerView.setAdapter(mAdapter);
refreshLayout.autoRefresh();
refreshLayout.setOnRefreshListener(new OnRefreshListener() {
@Override
public void onRefresh(final RefreshLayout refreshlayout) {
refreshlayout.getLayout().postDelayed(new Runnable() {
@Override
public void run() {
if (mAdapter.getItemCount() < 2) {
List<Movie> movies = new Gson().fromJson(JSON_MOVIES, new TypeToken<ArrayList<Movie>>() {}.getType());
mAdapter.replaceData(movies);
}
refreshlayout.finishRefresh();
}
},2000);
}
});
//添加Header
View header = LayoutInflater.from(this).inflate(R.layout.listitem_movie_header, recyclerView, false);
Banner banner = (Banner) header;
banner.setImageLoader(new GlideImageLoader());
banner.setImages(BANNER_ITEMS);
banner.start();
mAdapter.addHeaderView(banner);
//状态栏透明和间距处理
StatusBarUtil.immersive(this);
StatusBarUtil.setPaddingSmart(this, toolbar);
StatusBarUtil.setPaddingSmart(this, recyclerView);
StatusBarUtil.setMargin(this, findViewById(R.id.header));
StatusBarUtil.setPaddingSmart(this, findViewById(R.id.blurview));
}
示例3: onCreate
import com.scwang.smartrefresh.layout.api.RefreshLayout; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_using_custom);
final Toolbar toolbar = (Toolbar)findViewById(R.id.toolbar);
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
ListView listView = (ListView) findViewById(R.id.listview);
listView.setAdapter(mAdapter = new BaseRecyclerAdapter<Void>(simple_list_item_2) {
@Override
protected void onBindViewHolder(SmartViewHolder holder, Void model, int position) {
holder.text(android.R.id.text1, String.format(Locale.CHINA, "第%02d条数据", position));
holder.text(android.R.id.text2, String.format(Locale.CHINA, "这是测试的第%02d条数据", position));
holder.textColorId(android.R.id.text2, R.color.colorTextAssistant);
}
});
final RefreshLayout refreshLayout = (RefreshLayout) findViewById(R.id.refreshLayout);
refreshLayout.setOnRefreshListener(new OnRefreshListener() {
@Override
public void onRefresh(final RefreshLayout refreshlayout) {
refreshlayout.getLayout().postDelayed(new Runnable() {
@Override
public void run() {
mAdapter.refresh(initData());
refreshlayout.finishRefresh();
}
}, 2000);
}
});
refreshLayout.setRefreshHeader(new ClassicsHeader(this));
refreshLayout.setHeaderHeight(60);
//触发自动刷新
if (isFirstEnter) {
isFirstEnter = false;
refreshLayout.autoRefresh();
} else {
mAdapter.refresh(initData());
}
}