// Path: app/src/main/java/org/cnodejs/android/md/util/ResUtils.java
// public final class ResUtils {
// 
//     private ResUtils() {}
// 
//     public static int getStatusBarHeight(@NonNull Context context) {
//         int resourceId = context.getResources().getIdentifier("status_bar_height", "dimen", "android");
//         return resourceId > 0 ? context.getResources().getDimensionPixelSize(resourceId) : 0;
//     }
// 
//     @ColorInt
//     public static int getThemeAttrColor(@NonNull Context context, @AttrRes int attr) {
//         TypedArray a = context.obtainStyledAttributes(null, new int[]{attr});
//         try {
//             return a.getColor(0, 0);
//         } finally {
//             a.recycle();
//         }
//     }
// 
//     public static String getRawString(@NonNull Context context, @RawRes int rawId) throws IOException {
//         InputStream is = context.getResources().openRawResource(rawId);
//         BufferedReader reader = new BufferedReader(new InputStreamReader(is, StandardCharsets.UTF_8));
//         StringBuilder sb = new StringBuilder();
//         String line;
//         while ((line = reader.readLine()) != null) {
//             sb.append(line).append("\n");
//         }
//         if (sb.length() > 0) {
//             sb.deleteCharAt(sb.length() - 1);
//         }
//         reader.close();
//         return sb.toString();
//     }
// 
// }


import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.support.annotation.AttrRes;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.annotation.RequiresApi;
import android.support.annotation.StyleRes;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Checkable;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.TextView;
import org.cnodejs.android.md.R;
import org.cnodejs.android.md.util.ResUtils;
import butterknife.BindView;
import butterknife.ButterKnife;
    }

    public NavigationItem(@NonNull Context context, @Nullable AttributeSet attrs, @AttrRes int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        init(context, attrs, defStyleAttr, 0);
    }

    @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
    public NavigationItem(@NonNull Context context, @Nullable AttributeSet attrs, @AttrRes int defStyleAttr, @StyleRes int defStyleRes) {
        super(context, attrs, defStyleAttr, defStyleRes);
        init(context, attrs, defStyleAttr, defStyleRes);
    }

    private void init(@NonNull Context context, @Nullable AttributeSet attrs, @AttrRes int defStyleAttr, @StyleRes int defStyleRes) {
        LayoutInflater.from(context).inflate(R.layout.widget_navigation_item, this, true);
        ButterKnife.bind(this, this);

        TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.NavigationItem, defStyleAttr, defStyleRes);

        iconNormal = a.getDrawable(R.styleable.NavigationItem_iconNormal);
        iconChecked = a.getDrawable(R.styleable.NavigationItem_iconChecked);
        checked = a.getBoolean(R.styleable.NavigationItem_android_checked, false);

        imgIcon.setImageDrawable(checked ? iconChecked : iconNormal);
        tvTitle.setTextColor(ResUtils.getThemeAttrColor(context, checked ? R.attr.colorAccent : android.R.attr.textColorPrimary));
        iconItem.setBackgroundColor(checked ? ResUtils.getThemeAttrColor(context, R.attr.widgetBackgroundDark) : Color.TRANSPARENT);

        tvTitle.setText(a.getText(R.styleable.NavigationItem_title));
        setBadge(a.getInt(R.styleable.NavigationItem_badge, 0));

// Path: app/src/main/java/org/cnodejs/android/md/util/ResUtils.java
// public final class ResUtils {
// 
//     private ResUtils() {}
// 
//     public static int getStatusBarHeight(@NonNull Context context) {
//         int resourceId = context.getResources().getIdentifier("status_bar_height", "dimen", "android");
//         return resourceId > 0 ? context.getResources().getDimensionPixelSize(resourceId) : 0;
//     }
// 
//     @ColorInt
//     public static int getThemeAttrColor(@NonNull Context context, @AttrRes int attr) {
//         TypedArray a = context.obtainStyledAttributes(null, new int[]{attr});
//         try {
//             return a.getColor(0, 0);
//         } finally {
//             a.recycle();
//         }
//     }
// 
//     public static String getRawString(@NonNull Context context, @RawRes int rawId) throws IOException {
//         InputStream is = context.getResources().openRawResource(rawId);
//         BufferedReader reader = new BufferedReader(new InputStreamReader(is, StandardCharsets.UTF_8));
//         StringBuilder sb = new StringBuilder();
//         String line;
//         while ((line = reader.readLine()) != null) {
//             sb.append(line).append("\n");
//         }
//         if (sb.length() > 0) {
//             sb.deleteCharAt(sb.length() - 1);
//         }
//         reader.close();
//         return sb.toString();
//     }
// 
// }


// Path: app/src/main/java/org/cnodejs/android/md/ui/widget/NavigationItem.java
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.support.annotation.AttrRes;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.annotation.RequiresApi;
import android.support.annotation.StyleRes;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Checkable;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.TextView;
import org.cnodejs.android.md.R;
import org.cnodejs.android.md.util.ResUtils;
import butterknife.BindView;
import butterknife.ButterKnife;

    }

    public NavigationItem(@NonNull Context context, @Nullable AttributeSet attrs, @AttrRes int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        init(context, attrs, defStyleAttr, 0);
    }

    @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
    public NavigationItem(@NonNull Context context, @Nullable AttributeSet attrs, @AttrRes int defStyleAttr, @StyleRes int defStyleRes) {
        super(context, attrs, defStyleAttr, defStyleRes);
        init(context, attrs, defStyleAttr, defStyleRes);
    }

    private void init(@NonNull Context context, @Nullable AttributeSet attrs, @AttrRes int defStyleAttr, @StyleRes int defStyleRes) {
        LayoutInflater.from(context).inflate(R.layout.widget_navigation_item, this, true);
        ButterKnife.bind(this, this);

        TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.NavigationItem, defStyleAttr, defStyleRes);

        iconNormal = a.getDrawable(R.styleable.NavigationItem_iconNormal);
        iconChecked = a.getDrawable(R.styleable.NavigationItem_iconChecked);
        checked = a.getBoolean(R.styleable.NavigationItem_android_checked, false);

        imgIcon.setImageDrawable(checked ? iconChecked : iconNormal);
        tvTitle.setTextColor(ResUtils.getThemeAttrColor(context, checked ? R.attr.colorAccent : android.R.attr.textColorPrimary));
        iconItem.setBackgroundColor(checked ? ResUtils.getThemeAttrColor(context, R.attr.widgetBackgroundDark) : Color.TRANSPARENT);

        tvTitle.setText(a.getText(R.styleable.NavigationItem_title));
        setBadge(a.getInt(R.styleable.NavigationItem_badge, 0));

        a.recycle();