src/eu/inmite/android/plugin/butterknifezelezny/InjectWriter.java
protected void generateAdapter() {
        String holderClassName;
        if(mInjectType == InjectType.BUTTERKNIFE) {
            holderClassName = sButterKnifeViewHolderName;
        } else {
            holderClassName = sNativeFindsViewHolderName;
        }
		// view holder class
		StringBuilder holderBuilder = new StringBuilder();
        holderBuilder.append(holderClassName);
		holderBuilder.append("(android.view.View view) {");
        if(mInjectType == InjectType.BUTTERKNIFE) {
            holderBuilder.append("butterknife.Views.inject(this, view);");
        } else {
            holderBuilder.append(generateFindViews("view"));
        }
		holderBuilder.append("}");

		PsiClass viewHolder = mFactory.createClassFromText(holderBuilder.toString(), mClass);
		viewHolder.setName(holderClassName);

		// add injections into view holder
		for (Element element : mElements) {
			if (!element.used) {
				continue;
			}

			String rPrefix;
			if (element.isAndroidNS) {
				rPrefix = "android.R.id.";
			} else {
				rPrefix = "R.id.";
			}

			StringBuilder injection = new StringBuilder();
            if(mInjectType == InjectType.BUTTERKNIFE) {
                injection.append("@butterknife.InjectView("); // annotation
                injection.append(rPrefix);
                injection.append(element.id);
                injection.append(") ");
            }
			if (element.nameFull != null && element.nameFull.length() > 0) { // custom package+class
				injection.append(element.nameFull);
			} else if (Defintions.paths.containsKey(element.name)) { // listed class
				injection.append(Defintions.paths.get(element.name));
			} else { // android.widget
				injection.append("android.widget.");
				injection.append(element.name);
			}
			injection.append(" ");
			injection.append(element.fieldName);
			injection.append(";");

			viewHolder.add(mFactory.createFieldFromText(injection.toString(), mClass));
		}

		mClass.add(viewHolder);

		// add view holder's comment
		StringBuilder comment = new StringBuilder();
		comment.append("/**\n");
		comment.append(" * This class contains all butterknife-injected Views & Layouts from layout file '");
		comment.append(mLayoutFileName);
		comment.append("'\n");
		comment.append("* for easy to all layout elements.\n");
		comment.append(" *\n");
		comment.append(" * @author\tAndroid Butter Zelezny, plugin for IntelliJ IDEA/Android Studio by Inmite (www.inmite.eu)\n");
		comment.append("*/");

		mClass.addBefore(mFactory.createCommentFromText(comment.toString(), mClass), mClass.findInnerClassByName(holderClassName, true));
		mClass.addBefore(mFactory.createKeyword("static", mClass), mClass.findInnerClassByName(holderClassName, true));
	}
/**
	 * Create ViewHolder for adapters with injections
	 */
Create ViewHolder for adapters with injections
Create ViewHolder for adapters with injections
protected void generateAdapter() {
        String holderClassName;
        if(mInjectType == InjectType.BUTTERKNIFE) {
            holderClassName = sButterKnifeViewHolderName;
        } else {
            holderClassName = sNativeFindsViewHolderName;
        }
		StringBuilder holderBuilder = new StringBuilder();
        holderBuilder.append(holderClassName);
		holderBuilder.append("(android.view.View view) {");
        if(mInjectType == InjectType.BUTTERKNIFE) {
            holderBuilder.append("butterknife.Views.inject(this, view);");
        } else {
            holderBuilder.append(generateFindViews("view"));
        }
		holderBuilder.append("}");
		PsiClass viewHolder = mFactory.createClassFromText(holderBuilder.toString(), mClass);
		viewHolder.setName(holderClassName);
		for (Element element : mElements) {
			if (!element.used) {
				continue;
			}
			String rPrefix;
			if (element.isAndroidNS) {
				rPrefix = "android.R.id.";
			} else {
				rPrefix = "R.id.";
			}
			StringBuilder injection = new StringBuilder();
            if(mInjectType == InjectType.BUTTERKNIFE) {
                injection.append("@butterknife.InjectView("); 
                injection.append(rPrefix);
                injection.append(element.id);
                injection.append(") ");
            }
			if (element.nameFull != null && element.nameFull.length() > 0) { 
				injection.append(element.nameFull);
			} else if (Defintions.paths.containsKey(element.name)) { 
				injection.append(Defintions.paths.get(element.name));
			} else { 
				injection.append("android.widget.");
				injection.append(element.name);
			}
			injection.append(" ");
			injection.append(element.fieldName);
			injection.append(";");
			viewHolder.add(mFactory.createFieldFromText(injection.toString(), mClass));
		}
		mClass.add(viewHolder);
		StringBuilder comment = new StringBuilder();
		comment.append("/**\n");
		comment.append(" * This class contains all butterknife-injected Views & Layouts from layout file '");
		comment.append(mLayoutFileName);
		comment.append("'\n");
		comment.append("* for easy to all layout elements.\n");
		comment.append(" *\n");
		comment.append(" * @author\tAndroid Butter Zelezny, plugin for IntelliJ IDEA/Android Studio by Inmite (www.inmite.eu)\n");
		comment.append("*/");
		mClass.addBefore(mFactory.createCommentFromText(comment.toString(), mClass), mClass.findInnerClassByName(holderClassName, true));
		mClass.addBefore(mFactory.createKeyword("static", mClass), mClass.findInnerClassByName(holderClassName, true));
	}
protected void generateAdapter ( ) { String holderClassName ; if ( mInjectType == InjectType . BUTTERKNIFE ) { holderClassName = sButterKnifeViewHolderName ; } else { holderClassName = sNativeFindsViewHolderName ; } StringBuilder holderBuilder = new StringBuilder ( ) ; holderBuilder . append ( holderClassName ) ; holderBuilder . append ( "(android.view.View view) {" ) ; if ( mInjectType == InjectType . BUTTERKNIFE ) { holderBuilder . append ( "butterknife.Views.inject(this, view);" ) ; } else { holderBuilder . append ( generateFindViews ( "view" ) ) ; } holderBuilder . append ( "}" ) ; PsiClass viewHolder = mFactory . createClassFromText ( holderBuilder . toString ( ) , mClass ) ; viewHolder . setName ( holderClassName ) ; for ( Element element : mElements ) { if ( ! element . used ) { continue ; } String rPrefix ; if ( element . isAndroidNS ) { rPrefix = "android.R.id." ; } else { rPrefix = "R.id." ; } StringBuilder injection = new StringBuilder ( ) ; if ( mInjectType == InjectType . BUTTERKNIFE ) { injection . append ( "@butterknife.InjectView(" ) ; injection . append ( rPrefix ) ; injection . append ( element . id ) ; injection . append ( ") " ) ; } if ( element . nameFull != null && element . nameFull . length ( ) > 0 ) { injection . append ( element . nameFull ) ; } else if ( Defintions . paths . containsKey ( element . name ) ) { injection . append ( Defintions . paths . get ( element . name ) ) ; } else { injection . append ( "android.widget." ) ; injection . append ( element . name ) ; } injection . append ( " " ) ; injection . append ( element . fieldName ) ; injection . append ( ";" ) ; viewHolder . add ( mFactory . createFieldFromText ( injection . toString ( ) , mClass ) ) ; } mClass . add ( viewHolder ) ; StringBuilder comment = new StringBuilder ( ) ; comment . append ( "/**\n" ) ; comment . append ( " * This class contains all butterknife-injected Views & Layouts from layout file '" ) ; comment . append ( mLayoutFileName ) ; comment . append ( "'\n" ) ; comment . append ( "* for easy to all layout elements.\n" ) ; comment . append ( " *\n" ) ; comment . append ( " * @author\tAndroid Butter Zelezny, plugin for IntelliJ IDEA/Android Studio by Inmite (www.inmite.eu)\n" ) ; comment . append ( "*/" ) ; mClass . addBefore ( mFactory . createCommentFromText ( comment . toString ( ) , mClass ) , mClass . findInnerClassByName ( holderClassName , true ) ) ; mClass . addBefore ( mFactory . createKeyword ( "static" , mClass ) , mClass . findInnerClassByName ( holderClassName , true ) ) ; }
Create ViewHolder for adapters with injections
Create ViewHolder for adapters with injections
// view holder class // add injections into view holder // annotation // custom package+class // listed class // android.widget // add view holder's comment