Search in sources :

Example 1 with IconicsDrawable

use of com.mikepenz.iconics.IconicsDrawable in project LikeButton by jd-alexander.

the class MainActivity method usingCustomIcons.

public void usingCustomIcons() {
    //shown when the button is in its default state or when unLiked.
    smileButton.setUnlikeDrawable(new BitmapDrawable(getResources(), new IconicsDrawable(this, CommunityMaterial.Icon.cmd_emoticon).colorRes(android.R.color.darker_gray).sizeDp(25).toBitmap()));
    //shown when the button is liked!
    smileButton.setLikeDrawable(new BitmapDrawable(getResources(), new IconicsDrawable(this, CommunityMaterial.Icon.cmd_emoticon).colorRes(android.R.color.holo_purple).sizeDp(25).toBitmap()));
}
Also used : BitmapDrawable(android.graphics.drawable.BitmapDrawable) IconicsDrawable(com.mikepenz.iconics.IconicsDrawable)

Example 2 with IconicsDrawable

use of com.mikepenz.iconics.IconicsDrawable in project FastAdapter by mikepenz.

the class EndlessScrollListActivity method onCreateOptionsMenu.

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu items for use in the action bar
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.search, menu);
    //search icon
    menu.findItem(R.id.search).setIcon(new IconicsDrawable(this, MaterialDesignIconic.Icon.gmi_search).color(Color.BLACK).actionBar());
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        final SearchView searchView = (SearchView) menu.findItem(R.id.search).getActionView();
        searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {

            @Override
            public boolean onQueryTextSubmit(String s) {
                touchCallback.setIsDragEnabled(false);
                fastItemAdapter.filter(s);
                return true;
            }

            @Override
            public boolean onQueryTextChange(String s) {
                fastItemAdapter.filter(s);
                touchCallback.setIsDragEnabled(TextUtils.isEmpty(s));
                return true;
            }
        });
    } else {
        menu.findItem(R.id.search).setVisible(false);
    }
    return super.onCreateOptionsMenu(menu);
}
Also used : SearchView(android.support.v7.widget.SearchView) MenuInflater(android.view.MenuInflater) IconicsDrawable(com.mikepenz.iconics.IconicsDrawable)

Example 3 with IconicsDrawable

use of com.mikepenz.iconics.IconicsDrawable in project FastAdapter by mikepenz.

the class SwipeListActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    findViewById(android.R.id.content).setSystemUiVisibility(findViewById(android.R.id.content).getSystemUiVisibility() | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_sample);
    // Handle Toolbar
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    //style our ui
    new MaterializeBuilder().withActivity(this).build();
    //create our FastAdapter which will manage everything
    fastItemAdapter = new FastItemAdapter<>();
    //configure our fastAdapter
    fastItemAdapter.withOnClickListener(new FastAdapter.OnClickListener<SwipeableItem>() {

        @Override
        public boolean onClick(View v, IAdapter<SwipeableItem> adapter, SwipeableItem item, int position) {
            Toast.makeText(v.getContext(), (item).name.getText(v.getContext()), Toast.LENGTH_LONG).show();
            return false;
        }
    });
    //configure the itemAdapter
    fastItemAdapter.withFilterPredicate(new IItemAdapter.Predicate<SwipeableItem>() {

        @Override
        public boolean filter(SwipeableItem item, CharSequence constraint) {
            //return false to keep it
            return !item.name.getText().toLowerCase().contains(constraint.toString().toLowerCase());
        }
    });
    //get our recyclerView and do basic setup
    RecyclerView recyclerView = (RecyclerView) findViewById(R.id.rv);
    recyclerView.setLayoutManager(new LinearLayoutManager(this));
    recyclerView.setItemAnimator(new DefaultItemAnimator());
    recyclerView.setAdapter(fastItemAdapter);
    //fill with some sample data
    int x = 0;
    List<SwipeableItem> items = new ArrayList<>();
    for (String s : ALPHABET) {
        int count = new Random().nextInt(20);
        for (int i = 1; i <= count; i++) {
            SwipeableItem swipeableItem = new SwipeableItem().withName(s + " Test " + x).withIdentifier(100 + x);
            swipeableItem.withIsSwipeable(i % 5 != 0);
            items.add(swipeableItem);
            x++;
        }
    }
    fastItemAdapter.add(items);
    //add drag and drop for item
    //and add swipe as well
    Drawable leaveBehindDrawableLeft = new IconicsDrawable(this).icon(MaterialDesignIconic.Icon.gmi_delete).color(Color.WHITE).sizeDp(24);
    Drawable leaveBehindDrawableRight = new IconicsDrawable(this).icon(MaterialDesignIconic.Icon.gmi_archive).color(Color.WHITE).sizeDp(24);
    touchCallback = new SimpleSwipeDragCallback(this, this, leaveBehindDrawableLeft, ItemTouchHelper.LEFT, ContextCompat.getColor(this, R.color.md_red_900)).withBackgroundSwipeRight(ContextCompat.getColor(this, R.color.md_blue_900)).withLeaveBehindSwipeRight(leaveBehindDrawableRight);
    // Create ItemTouchHelper and pass with parameter the SimpleDragCallback
    touchHelper = new ItemTouchHelper(touchCallback);
    // Attach ItemTouchHelper to RecyclerView
    touchHelper.attachToRecyclerView(recyclerView);
    //restore selections (this has to be done after the items were added
    fastItemAdapter.withSavedInstanceState(savedInstanceState);
    //set the back arrow in the toolbar
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setHomeButtonEnabled(false);
}
Also used : SimpleSwipeDragCallback(com.mikepenz.fastadapter_extensions.swipe.SimpleSwipeDragCallback) SwipeableItem(com.mikepenz.fastadapter.app.items.SwipeableItem) ArrayList(java.util.ArrayList) IconicsDrawable(com.mikepenz.iconics.IconicsDrawable) Drawable(android.graphics.drawable.Drawable) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) MaterializeBuilder(com.mikepenz.materialize.MaterializeBuilder) SearchView(android.support.v7.widget.SearchView) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) DefaultItemAnimator(android.support.v7.widget.DefaultItemAnimator) ItemTouchHelper(android.support.v7.widget.helper.ItemTouchHelper) Random(java.util.Random) IItemAdapter(com.mikepenz.fastadapter.IItemAdapter) RecyclerView(android.support.v7.widget.RecyclerView) FastAdapter(com.mikepenz.fastadapter.FastAdapter) IconicsDrawable(com.mikepenz.iconics.IconicsDrawable) Toolbar(android.support.v7.widget.Toolbar)

Example 4 with IconicsDrawable

use of com.mikepenz.iconics.IconicsDrawable in project FastAdapter by mikepenz.

the class SampleActivity method onCreateOptionsMenu.

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.menu, menu);
    menu.findItem(R.id.item_add).setIcon(new IconicsDrawable(this, MaterialDesignIconic.Icon.gmi_plus_square).color(Color.BLACK).actionBar());
    menu.findItem(R.id.item_delete).setIcon(new IconicsDrawable(this, MaterialDesignIconic.Icon.gmi_minus_square).color(Color.BLACK).actionBar());
    menu.findItem(R.id.item_change).setIcon(new IconicsDrawable(this, MaterialDesignIconic.Icon.gmi_settings_square).color(Color.BLACK).actionBar());
    menu.findItem(R.id.item_move).setIcon(new IconicsDrawable(this, MaterialDesignIconic.Icon.gmi_format_valign_bottom).color(Color.BLACK).actionBar());
    return true;
}
Also used : MenuInflater(android.view.MenuInflater) IconicsDrawable(com.mikepenz.iconics.IconicsDrawable)

Example 5 with IconicsDrawable

use of com.mikepenz.iconics.IconicsDrawable in project FastAdapter by mikepenz.

the class SwipeListActivity method onCreateOptionsMenu.

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu items for use in the action bar
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.search, menu);
    //search icon
    menu.findItem(R.id.search).setIcon(new IconicsDrawable(this, MaterialDesignIconic.Icon.gmi_search).color(Color.BLACK).actionBar());
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        final SearchView searchView = (SearchView) menu.findItem(R.id.search).getActionView();
        searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {

            @Override
            public boolean onQueryTextSubmit(String s) {
                touchCallback.setIsDragEnabled(false);
                fastItemAdapter.filter(s);
                return true;
            }

            @Override
            public boolean onQueryTextChange(String s) {
                fastItemAdapter.filter(s);
                touchCallback.setIsDragEnabled(TextUtils.isEmpty(s));
                return true;
            }
        });
    } else {
        menu.findItem(R.id.search).setVisible(false);
    }
    return super.onCreateOptionsMenu(menu);
}
Also used : SearchView(android.support.v7.widget.SearchView) MenuInflater(android.view.MenuInflater) IconicsDrawable(com.mikepenz.iconics.IconicsDrawable)

Aggregations

IconicsDrawable (com.mikepenz.iconics.IconicsDrawable)28 View (android.view.View)13 MenuInflater (android.view.MenuInflater)9 Toolbar (android.support.v7.widget.Toolbar)7 SearchView (android.support.v7.widget.SearchView)6 DrawerBuilder (com.mikepenz.materialdrawer.DrawerBuilder)6 SecondaryDrawerItem (com.mikepenz.materialdrawer.model.SecondaryDrawerItem)6 ImageView (android.widget.ImageView)5 TextView (android.widget.TextView)5 ProfileDrawerItem (com.mikepenz.materialdrawer.model.ProfileDrawerItem)5 Context (android.content.Context)4 Intent (android.content.Intent)4 RecyclerView (android.support.v7.widget.RecyclerView)4 AccountHeaderBuilder (com.mikepenz.materialdrawer.AccountHeaderBuilder)4 Drawer (com.mikepenz.materialdrawer.Drawer)4 PrimaryDrawerItem (com.mikepenz.materialdrawer.model.PrimaryDrawerItem)4 SectionDrawerItem (com.mikepenz.materialdrawer.model.SectionDrawerItem)4 IDrawerItem (com.mikepenz.materialdrawer.model.interfaces.IDrawerItem)4 IProfile (com.mikepenz.materialdrawer.model.interfaces.IProfile)4 Drawable (android.graphics.drawable.Drawable)3