Skip to content

Commit

Permalink
Fallback to rowType to FormRowDescriptorTypeDetail
Browse files Browse the repository at this point in the history
  • Loading branch information
Toni Möckel committed Mar 14, 2017
1 parent da4d5a9 commit ebdceb2
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 5 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
classpath 'com.android.tools.build:gradle:2.3.0'
}
}

Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
classpath 'com.android.tools.build:gradle:2.3.0'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'

// NOTE: Do not place your application dependencies here; they belong
Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Fri Feb 24 15:17:40 CET 2017
#Tue Mar 14 15:01:01 CET 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
15 changes: 14 additions & 1 deletion lib/QMBForm/src/main/java/com/quemb/qmbform/CellViewFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,13 @@ public CellViewFactory() {
int currentapiVersion = Build.VERSION.SDK_INT;

mViewRowTypeMap = new HashMap<String, Class<? extends FormBaseCell>>();

//---
// Deprecated
mViewRowTypeMap.put(RowDescriptor.FormRowDescriptorTypeName, FormDetailTextFieldCell.class);
mViewRowTypeMap.put(RowDescriptor.FormRowDescriptorTypeNameVertical, FormDetailTextInlineFieldCell.class);
// --

mViewRowTypeMap.put(RowDescriptor.FormRowDescriptorTypeDetailInline, FormDetailTextInlineFieldCell.class);
mViewRowTypeMap.put(RowDescriptor.FormRowDescriptorTypeDetail, FormDetailTextFieldCell.class);
mViewRowTypeMap.put(RowDescriptor.FormRowDescriptorTypeText, FormEditTextFieldCell.class);
Expand Down Expand Up @@ -129,7 +136,13 @@ public Cell createViewForFormItemDescriptor(Context context, FormItemDescriptor
try {
FormBaseCell formBaseCell;

formBaseCell = mViewRowTypeMap.get(row.getRowType()).getConstructor(Context.class, RowDescriptor.class).newInstance(
// Fallback to FormRowDescriptorTypeDetail if no RowType is defined
String rowType = row.getRowType();
if (!mViewRowTypeMap.containsKey(rowType)){
rowType = RowDescriptor.FormRowDescriptorTypeDetail;
}

formBaseCell = mViewRowTypeMap.get(rowType).getConstructor(Context.class, RowDescriptor.class).newInstance(
context, row);
rowView = formBaseCell;
} catch (InstantiationException e) {
Expand Down

0 comments on commit ebdceb2

Please sign in to comment.