Skip to content
This repository has been archived by the owner on Feb 26, 2023. It is now read-only.

Commit

Permalink
Refactor holders which decorate another holder
Browse files Browse the repository at this point in the history
  • Loading branch information
WonderCsabo committed Dec 28, 2014
1 parent a33913e commit 8c12b25
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,10 @@
import com.sun.codemodel.JMethod;
import com.sun.codemodel.JVar;

public class BundleExtractionHolder implements HasBundleExtraction {

protected EComponentHolder holder;
public class BundleExtractionHolder extends GeneratedClassHolderDecorator<EComponentHolder> implements HasBundleExtraction {

public BundleExtractionHolder(EComponentHolder holder) {
this.holder = holder;
super(holder);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,18 @@
import com.sun.codemodel.JClass;
import com.sun.codemodel.JExpression;

public class FoundViewHolder {
public class FoundViewHolder extends GeneratedClassHolderDecorator<GeneratedClassHolder> {

private GeneratedClassHolder holder;
private JClass viewClass;
private JExpression view;
private JBlock ifNotNullBlock;
private boolean ifNotNullCreated = false;

public FoundViewHolder(GeneratedClassHolder holder, JClass viewClass, JExpression view, JBlock block) {
this.holder = holder;
super(holder);
this.viewClass = viewClass;
this.view = view;
this.ifNotNullBlock = block;
ifNotNullBlock = block;
}

public JExpression getView() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/**
* Copyright (C) 2010-2014 eBusiness Information, Excilys Group
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed To in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package org.androidannotations.holder;

public class GeneratedClassHolderDecorator<T extends GeneratedClassHolder> {

protected T holder;

public GeneratedClassHolderDecorator(T holder) {
this.holder = holder;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@
import com.sun.codemodel.JMod;
import com.sun.codemodel.JVar;

public class OnSeekBarChangeListenerHolder {
public class OnSeekBarChangeListenerHolder extends GeneratedClassHolderDecorator<EComponentWithViewSupportHolder> {

private EComponentWithViewSupportHolder holder;
private JDefinedClass listenerClass;
private JBlock onProgressChangedBody;
private JVar onProgressChangedSeekBarParam;
Expand All @@ -35,8 +34,8 @@ public class OnSeekBarChangeListenerHolder {
private JVar onStopTrackingTouchSeekBarParam;

public OnSeekBarChangeListenerHolder(EComponentWithViewSupportHolder holder, JDefinedClass onSeekbarChangeListenerClass) {
this.holder = holder;
this.listenerClass = onSeekbarChangeListenerClass;
super(holder);
listenerClass = onSeekbarChangeListenerClass;
createOnProgressChanged();
createOnStartTrackingTouch();
createOnStopTrackingTouch();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,13 @@
import com.sun.codemodel.JExpression;
import com.sun.codemodel.JFieldVar;

public class ReceiverRegistrationHolder {
public class ReceiverRegistrationHolder extends GeneratedClassHolderDecorator<EComponentHolder> {

private EComponentHolder holder;
private Map<IntentFilterData, JFieldVar> intentFilterFields = new HashMap<IntentFilterData, JFieldVar>();
private IllegalStateException illegalStateException = new IllegalStateException("This shouldn't happen unless the validation is bad");

public ReceiverRegistrationHolder(EComponentHolder holder) {
this.holder = holder;
super(holder);
}

public JFieldVar getIntentFilterField(String[] actions, String[] dataSchemes) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@
import com.sun.codemodel.JMethod;
import com.sun.codemodel.JVar;

public class RoboGuiceHolder {
public class RoboGuiceHolder extends GeneratedClassHolderDecorator<EActivityHolder> {

private EActivityHolder holder;

// TODO access for these fields should be refactored

Expand All @@ -44,7 +43,7 @@ public class RoboGuiceHolder {
protected JBlock onContentChangedAfterSuperBlock;

public RoboGuiceHolder(EActivityHolder holder) {
this.holder = holder;
super(holder);
}

public JFieldVar getEventManagerField() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@
import com.sun.codemodel.JPrimitiveType;
import com.sun.codemodel.JVar;

public class TextWatcherHolder {
public class TextWatcherHolder extends GeneratedClassHolderDecorator<EComponentWithViewSupportHolder> {

private EComponentWithViewSupportHolder holder;
private JVar textViewVariable;
private JDefinedClass listenerClass;
private JBlock beforeTextChangedBody;
Expand All @@ -41,9 +40,9 @@ public class TextWatcherHolder {
private JVar afterTextChangedEditableParam;

public TextWatcherHolder(EComponentWithViewSupportHolder holder, JVar viewVariable, JDefinedClass onTextChangeListenerClass) {
this.holder = holder;
this.textViewVariable = viewVariable;
this.listenerClass = onTextChangeListenerClass;
super(holder);
textViewVariable = viewVariable;
listenerClass = onTextChangeListenerClass;
createBeforeTextChanged();
createOnTextChanged();
createAfterTextChanged();
Expand Down

0 comments on commit 8c12b25

Please sign in to comment.