use of com.scwang.refreshlayout.util.DynamicTimeFormat in project SmartRefreshLayout by scwang90.
the class ClassicsStyleActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_style_classics);
mToolbar = (Toolbar) findViewById(R.id.toolbar);
mToolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
mRefreshLayout = (RefreshLayout) findViewById(R.id.refreshLayout);
int delta = new Random().nextInt(7 * 24 * 60 * 60 * 1000);
mClassicsHeader = (ClassicsHeader) mRefreshLayout.getRefreshHeader();
mClassicsHeader.setLastUpdateTime(new Date(System.currentTimeMillis() - delta));
mClassicsHeader.setTimeFormat(new SimpleDateFormat("更新于 MM-dd HH:mm", Locale.CHINA));
mClassicsHeader.setTimeFormat(new DynamicTimeFormat("更新于 %s"));
// mDrawableProgress = mClassicsHeader.getProgressView().getDrawable();
mDrawableProgress = ((ImageView) mClassicsHeader.findViewById(ClassicsHeader.ID_IMAGE_PROGRESS)).getDrawable();
if (mDrawableProgress instanceof LayerDrawable) {
mDrawableProgress = ((LayerDrawable) mDrawableProgress).getDrawable(0);
}
View view = findViewById(R.id.recyclerView);
if (view instanceof RecyclerView) {
RecyclerView recyclerView = (RecyclerView) view;
recyclerView.setLayoutManager(new LinearLayoutManager(this));
recyclerView.addItemDecoration(new DividerItemDecoration(this, VERTICAL));
recyclerView.setItemAnimator(new DefaultItemAnimator());
recyclerView.setAdapter(mAdpater = new BaseRecyclerAdapter<Item>(Arrays.asList(Item.values()), simple_list_item_2, this) {
@Override
protected void onBindViewHolder(SmartViewHolder holder, Item model, int position) {
holder.text(android.R.id.text1, model.name());
holder.text(android.R.id.text2, model.nameId);
holder.textColorId(android.R.id.text2, R.color.colorTextAssistant);
}
});
mRecyclerView = recyclerView;
}
if (isFirstEnter) {
isFirstEnter = false;
// 触发自动刷新
mRefreshLayout.autoRefresh();
}
}
Aggregations