Android Open Source - FxExplorer Menu Adapter






From Project

Back to project page FxExplorer.

License

The source code is released under:

Apache License

If you think the Android project FxExplorer listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package info.breezes.fxmanager;
/*from   w  ww .j  a  va  2s  . c  om*/
import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import info.breezes.fxmanager.model.DrawerMenu;

/**
 * menu adapter
 * Created by admin on 2014/12/30.
 */
public class MenuAdapter extends RecyclerView.Adapter<MenuAdapter.DrawerMenuHolder> {

    public static class DrawerMenuHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
        private final View itemView;
        private final TextView textView;
        private final ImageView iconView;
        private final MenuAdapter adapter;
        private DrawerMenu drawMenu;

        public DrawerMenuHolder(View itemView, MenuAdapter adapter) {
            super(itemView);
            this.adapter = adapter;
            this.itemView = itemView;
            this.textView = (TextView) itemView.findViewById(R.id.textView);
            this.iconView = (ImageView) itemView.findViewById(R.id.icon);
            this.itemView.setOnClickListener(this);
        }

        public void setDrawMenu(DrawerMenu drawMenu) {
            this.drawMenu = drawMenu;
            textView.setText(drawMenu.title);
            iconView.setImageDrawable(drawMenu.icon);
        }

        public DrawerMenu getDrawMenu() {
            return drawMenu;
        }

        @Override
        public void onClick(View v) {
            if (adapter != null && adapter.getOnItemClickListener() != null) {
                adapter.getOnItemClickListener().onItemClick(getDrawMenu());
            }
        }
    }

    private final Context context;
    private DrawerMenu[] menus;

    private OnItemClickListener onItemClickListener;

    public MenuAdapter(Context context, DrawerMenu[] menus) {
        this.context = context;
        this.menus = menus;
    }

    public void update(DrawerMenu[] drawerMenus) {
        this.menus = drawerMenus;
        notifyDataSetChanged();
    }

    @Override
    public DrawerMenuHolder onCreateViewHolder(ViewGroup viewGroup, int i) {
        View itemView = LayoutInflater.from(context).inflate(R.layout.drawer_menu_item, viewGroup, false);
        return new DrawerMenuHolder(itemView, this);
    }

    @Override
    public void onBindViewHolder(DrawerMenuHolder drawerMenuHolder, int i) {
        DrawerMenu menu = menus[i];
        drawerMenuHolder.setDrawMenu(menu);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public int getItemCount() {
        return menus == null ? 0 : menus.length;
    }

    public void setOnItemClickListener(OnItemClickListener onItemClickListener) {
        this.onItemClickListener = onItemClickListener;
    }

    public OnItemClickListener getOnItemClickListener() {
        return onItemClickListener;
    }

    public interface OnItemClickListener {
        public void onItemClick(DrawerMenu item);
    }
}




Java Source Code List

info.breezes.fx.downloader.ApplicationTest.java
info.breezes.fx.downloader.DlMainActivity.java
info.breezes.fx.editor.ApplicationTest.java
info.breezes.fx.editor.EditorMainActivity.java
info.breezes.fx.player.ApplicationTest.java
info.breezes.fx.player.MainActivity.java
info.breezes.fx.viewer.ApplicationTest.java
info.breezes.fx.viewer.BigImageView.java
info.breezes.fx.viewer.ImageUtility.java
info.breezes.fx.viewer.MainActivity.java
info.breezes.fxmanager.ApplicationTest.java
info.breezes.fxmanager.FxApplication.java
info.breezes.fxmanager.LocalFileSystemProvider.java
info.breezes.fxmanager.MainActivity.java
info.breezes.fxmanager.MediaFragment.java
info.breezes.fxmanager.MediaItemUtil.java
info.breezes.fxmanager.MediaProvider.java
info.breezes.fxmanager.MenuAdapter.java
info.breezes.fxmanager.MimeTypeMap.java
info.breezes.fxmanager.NetUtils.java
info.breezes.fxmanager.PackagesProvider.java
info.breezes.fxmanager.ScanResultActivity.java
info.breezes.fxmanager.ScannerActivity.java
info.breezes.fxmanager.SettingsActivity.java
info.breezes.fxmanager.ShellUtil.java
info.breezes.fxmanager.StorageTool.java
info.breezes.fxmanager.ThemeChooserActivity.java
info.breezes.fxmanager.android.app.QAlertDialog.java
info.breezes.fxmanager.countly.CountlyActivity.java
info.breezes.fxmanager.countly.CountlyEvent.java
info.breezes.fxmanager.countly.CountlyFragment.java
info.breezes.fxmanager.countly.CountlyUtils.java
info.breezes.fxmanager.dialog.ApkInfoDialog.java
info.breezes.fxmanager.dialog.FileInfoDialog.java
info.breezes.fxmanager.dialog.HashInfoDialog.java
info.breezes.fxmanager.model.DrawerMenu.java
info.breezes.fxmanager.model.MediaItem.java
info.breezes.fxmanager.qrcode.QrBitmapDecoder.java
info.breezes.fxmanager.service.FileService.java
net.gescobar.httpserver.Handler.java
net.gescobar.httpserver.HttpConnection.java
net.gescobar.httpserver.HttpServer.java
net.gescobar.httpserver.Request.java
net.gescobar.httpserver.Response.java