use of com.mikepenz.lollipopshowcase.adapter.ApplicationAdapter in project LollipopShowcase by mikepenz.
the class MainActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Handle Toolbar
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
final SharedPreferences pref = getSharedPreferences("com.mikepenz.applicationreader", 0);
drawer = new DrawerBuilder(this).withToolbar(toolbar).addDrawerItems(new SwitchDrawerItem().withOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(IDrawerItem drawerItem, CompoundButton compoundButton, boolean b) {
SharedPreferences.Editor editor = pref.edit();
editor.putBoolean("autouploadenabled", b);
editor.apply();
}
}).withName(R.string.drawer_switch).withChecked(pref.getBoolean("autouploadenabled", false))).addStickyDrawerItems(new SecondaryDrawerItem().withName(R.string.drawer_opensource).withIdentifier(DRAWER_ITEM_OPEN_SOURCE).withIcon(FontAwesome.Icon.faw_github).withSelectable(false)).withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {
@Override
public boolean onItemClick(View view, int i, IDrawerItem drawerItem) {
if (drawerItem.getIdentifier() == DRAWER_ITEM_OPEN_SOURCE) {
new LibsBuilder().withFields(R.string.class.getFields()).withVersionShown(true).withLicenseShown(true).withActivityTitle(getString(R.string.drawer_opensource)).withActivityStyle(Libs.ActivityStyle.LIGHT_DARK_TOOLBAR).start(MainActivity.this);
}
return false;
}
}).withSelectedItem(-1).withSavedInstance(savedInstanceState).build();
// Handle ProgressBar
mProgressBar = (ProgressBar) findViewById(R.id.progressBar);
// Fab Button
mFabButton = (FloatingActionButton) findViewById(R.id.fab_normal);
mFabButton.setImageDrawable(new IconicsDrawable(this, GoogleMaterial.Icon.gmd_file_upload).color(Color.WHITE).actionBar());
mFabButton.setOnClickListener(fabClickListener);
mRecyclerView = (RecyclerView) findViewById(R.id.list);
mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
mRecyclerView.setItemAnimator(new CustomItemAnimator());
// mRecyclerView.setItemAnimator(new ReboundItemAnimator());
mAdapter = new ApplicationAdapter(new ArrayList<AppInfo>(), R.layout.row_application, MainActivity.this);
mRecyclerView.setAdapter(mAdapter);
mSwipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipe_container);
mSwipeRefreshLayout.setColorSchemeColors(getResources().getColor(R.color.theme_accent));
mSwipeRefreshLayout.setRefreshing(true);
mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
new InitializeApplicationsTask().execute();
}
});
new InitializeApplicationsTask().execute();
if (savedInstanceState != null) {
if (uploadComponentInfoTask != null) {
if (uploadComponentInfoTask.isRunning) {
uploadComponentInfoTask.showProgress(this);
}
}
}
// show progress
mRecyclerView.setVisibility(View.GONE);
mProgressBar.setVisibility(View.VISIBLE);
}
Aggregations