use of org.wordpress.android.util.helpers.ListScrollPositionManager in project WordPress-Android by wordpress-mobile.
the class SelectCategoriesActivity method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
((WordPress) getApplication()).component().inject(this);
mDispatcher.register(this);
if (savedInstanceState == null) {
mSite = (SiteModel) getIntent().getSerializableExtra(WordPress.SITE);
} else {
mSite = (SiteModel) savedInstanceState.getSerializable(WordPress.SITE);
}
if (mSite == null) {
ToastUtils.showToast(this, R.string.blog_not_found, ToastUtils.Duration.SHORT);
finish();
return;
}
setContentView(R.layout.select_categories);
setTitle(getResources().getString(R.string.select_categories));
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.setHomeButtonEnabled(true);
actionBar.setDisplayHomeAsUpEnabled(true);
}
mListView = (ListView) findViewById(android.R.id.list);
mListScrollPositionManager = new ListScrollPositionManager(mListView, false);
mListView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
mListView.setItemsCanFocus(false);
mEmptyView = (TextView) findViewById(R.id.empty_view);
mListView.setEmptyView(mEmptyView);
mSelectedCategories = new HashSet<>();
Bundle extras = getIntent().getExtras();
if (extras != null) {
if (extras.containsKey(KEY_POST)) {
PostModel post = (PostModel) extras.getSerializable(KEY_POST);
if (post != null) {
for (Long categoryId : post.getCategoryIdList()) {
mSelectedCategories.add(categoryId);
}
}
}
}
// swipe to refresh setup
mSwipeToRefreshHelper = new SwipeToRefreshHelper(this, (CustomSwipeRefreshLayout) findViewById(R.id.ptr_layout), new RefreshListener() {
@Override
public void onRefreshStarted() {
if (!NetworkUtils.checkConnection(getBaseContext())) {
mSwipeToRefreshHelper.setRefreshing(false);
return;
}
refreshCategories();
}
});
populateCategoryList();
if (NetworkUtils.isNetworkAvailable(this)) {
mEmptyView.setText(R.string.empty_list_default);
if (isCategoryListEmpty()) {
refreshCategories();
}
} else {
mEmptyView.setText(R.string.no_network_title);
}
}
Aggregations