Search in sources :

Example 1 with ApplicationAdapter

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);
}
Also used : IDrawerItem(com.mikepenz.materialdrawer.model.interfaces.IDrawerItem) OnCheckedChangeListener(com.mikepenz.materialdrawer.interfaces.OnCheckedChangeListener) SharedPreferences(android.content.SharedPreferences) ArrayList(java.util.ArrayList) SwitchDrawerItem(com.mikepenz.materialdrawer.model.SwitchDrawerItem) Drawer(com.mikepenz.materialdrawer.Drawer) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) SecondaryDrawerItem(com.mikepenz.materialdrawer.model.SecondaryDrawerItem) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) SwipeRefreshLayout(android.support.v4.widget.SwipeRefreshLayout) LibsBuilder(com.mikepenz.aboutlibraries.LibsBuilder) CustomItemAnimator(com.mikepenz.lollipopshowcase.itemanimator.CustomItemAnimator) DrawerBuilder(com.mikepenz.materialdrawer.DrawerBuilder) ApplicationAdapter(com.mikepenz.lollipopshowcase.adapter.ApplicationAdapter) IconicsDrawable(com.mikepenz.iconics.IconicsDrawable) CompoundButton(android.widget.CompoundButton) Toolbar(android.support.v7.widget.Toolbar)

Aggregations

SharedPreferences (android.content.SharedPreferences)1 SwipeRefreshLayout (android.support.v4.widget.SwipeRefreshLayout)1 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)1 RecyclerView (android.support.v7.widget.RecyclerView)1 Toolbar (android.support.v7.widget.Toolbar)1 View (android.view.View)1 CompoundButton (android.widget.CompoundButton)1 LibsBuilder (com.mikepenz.aboutlibraries.LibsBuilder)1 IconicsDrawable (com.mikepenz.iconics.IconicsDrawable)1 ApplicationAdapter (com.mikepenz.lollipopshowcase.adapter.ApplicationAdapter)1 CustomItemAnimator (com.mikepenz.lollipopshowcase.itemanimator.CustomItemAnimator)1 Drawer (com.mikepenz.materialdrawer.Drawer)1 DrawerBuilder (com.mikepenz.materialdrawer.DrawerBuilder)1 OnCheckedChangeListener (com.mikepenz.materialdrawer.interfaces.OnCheckedChangeListener)1 SecondaryDrawerItem (com.mikepenz.materialdrawer.model.SecondaryDrawerItem)1 SwitchDrawerItem (com.mikepenz.materialdrawer.model.SwitchDrawerItem)1 IDrawerItem (com.mikepenz.materialdrawer.model.interfaces.IDrawerItem)1 ArrayList (java.util.ArrayList)1