I have seen others ask this question but it seems to me that I have done all the things that are required and I'm still not getting it to work. I am getting the No setter/field for Vehicle Type found on class No setter/field for Time of Arrival found on class No setter/field for Driver Number found on class No setter/field for Vehicle Number found on class No setter/field for Time of Departure found on class No setter/field for Partial Amount Paid found on class
public class TruckDetailsActivity {
//name and address string
@JsonProperty("Transporter")
private String Transporter;
@JsonProperty("Driver Name")
private String DriverName;
public void setVehicleType(String vehicleType) {
VehicleType = vehicleType;
}
@JsonProperty("Driver Number")
private String DriverNumber;
@JsonProperty("Vehicle Number")
private String VehicleNumber;
@JsonProperty("Date")
private String Date;
@JsonProperty("aps")
private String aps;
@JsonProperty("email")
private String email;
private String key;
@JsonProperty("Time of Arrival")
private String TimeofArrival;
@JsonProperty("Cost")
private String Cost;
@JsonProperty("Time of Departure")
private String TimeofDeparture;
@JsonProperty("Partial Amount Paid")
private String PartialAmountPaid;
@JsonProperty("Vehicle Type")
private String VehicleType;
@JsonProperty("Cash Handover")
private String CashHandover;
@JsonProperty("Operator")
private String Operator;
public TruckDetailsActivity() {
/*Blank default constructor essential for Firebase*/
}
public TruckDetailsActivity(String a){
}
public TruckDetailsActivity(String k, String s, String index, String index1, String index2, String index3) {
this.key=k;
email=s;
Transporter =index;
DriverNumber =index1;
Date =index2;
aps =index3;
}
@JsonProperty("Key")
public String getKey(){
return this.key;
}
public void setKey(String key){
this.key=key;
}
//Getters and setters
public String getTransporter() {
return this.Transporter;
}
public void setTransporter(String contractorname) {
this.Transporter = contractorname;
}
public String getDriverName() {
return this.DriverName;
}
public void setDriverName(String driverName) {
this.DriverName = driverName;
}
public String getDriverNumber() {
return this.DriverNumber;
}
public String getVehicleNumber() {
return this.VehicleNumber;
}
public String getDate() {
return this.Date;
}
public void setDate(String date) {
this.Date = date;
}
public String getAps() {
return this.aps;
}
public void setAps(String aps) {
this.aps = aps;
}
public String getEmail() {
return this.email;
}
public void setEmail(String email){this.email=email;}
public String getTimeofArrival() {
return this.TimeofArrival;
}
public String getCost() {
return this.Cost;
}
public void setCost(String T) {
this.Cost = T;
}
public String getTimeofDeparture() {
return TimeofDeparture;
}
public String getPartialAmountPaid() {
return PartialAmountPaid;
}
public String getVehicleType() {
return VehicleType;
}
public String getCashHandover() {
return CashHandover;
}
public void setCashHandover(String cashHandover) {
CashHandover = cashHandover;
}
public String getOperator() {
return Operator;
}
public void setOperator(String operator){this.Operator=operator;}
This is my Java file from where i call the above class.
Query queryRef = reference.child("users").child("data").orderByChild(sort);
queryRef.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
for(DataSnapshot ds:dataSnapshot.getChildren()){
TruckDetailsActivity post = ds.getValue(TruckDetailsActivity.class);
post.setKey(ds.getKey());
Log.d("post", post.getKey());
TruckDetailsActivity obj = new TruckDetailsActivity(post.getKey(), post.getEmail(), post.getTransporter(), post.getDriverNumber(), post.getDate(), post.getAps());
list.add(index, obj);
Log.d("list", String.valueOf(list.get(index)));
index++;
}
mAdapter = new MyRecyclerViewAdapter(list);
mAdapter.notifyDataSetChanged();
Log.d("count of list", String.valueOf(mAdapter.getItemCount()));
mRecyclerView.setAdapter(mAdapter);
pb.setVisibility(View.GONE);
linearLayout.setVisibility(View.VISIBLE);
}
@Override
public void onCancelled(DatabaseError firebaseError) {
}
});
Gradle Build
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.potenza_pvt_ltd.AAPS"
minSdkVersion 15
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE-FIREBASE.txt'
exclude 'META-INF/NOTICE'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.2.1'
compile 'com.android.support:design:22.2.1'
compile 'com.android.support:cardview-v7:22.0.0'
compile 'com.android.support:recyclerview-v7:22.0.0'
//compile 'com.firebase:firebase-client-android:2.3.1'
compile 'com.github.brnunes:swipeablerecyclerview:1.0.2'
compile 'com.google.firebase:firebase-database:9.0.0'
compile 'com.google.firebase:firebase-auth:9.0.0'
compile 'com.google.firebase:firebase-storage:9.0.0'
compile files('libs/poi-3.14-20160307.jar')
compile files('libs/joda-time-2.9.4.jar')
compile files('libs/jackson-annotations-2.2.3.jar')
}
apply plugin: 'com.google.gms.google-services'