Commit 5cad9bc1 by Krishna Vemulavada

Merge remote-tracking branch 'origin/development' into development

parents 02f200e1 ff2f9aa9
...@@ -64,8 +64,7 @@ public class MyRequestAdapter extends BaseAdapter { ...@@ -64,8 +64,7 @@ public class MyRequestAdapter extends BaseAdapter {
convertView = mInflater.inflate(R.layout.request_list_item, parent, false); convertView = mInflater.inflate(R.layout.request_list_item, parent, false);
holder = new ViewHolder(); holder = new ViewHolder();
holder.number = (TextView) convertView.findViewById(R.id.number); holder.number = (TextView) convertView.findViewById(R.id.number);
holder.dueDate = (TextView) convertView.findViewById(R.id.dueDate); holder.shortDescription = (TextView) convertView.findViewById(R.id.shotrDescription);
holder.shotrDescription = (TextView) convertView.findViewById(R.id.shotrDescription);
holder.approval = (TextView) convertView.findViewById(R.id.approval); holder.approval = (TextView) convertView.findViewById(R.id.approval);
holder.statusIndicator = (ImageView) convertView.findViewById(R.id.approval_image); holder.statusIndicator = (ImageView) convertView.findViewById(R.id.approval_image);
convertView.setTag(holder); convertView.setTag(holder);
...@@ -75,9 +74,7 @@ public class MyRequestAdapter extends BaseAdapter { ...@@ -75,9 +74,7 @@ public class MyRequestAdapter extends BaseAdapter {
MyRequest req = mReqList.get(position); MyRequest req = mReqList.get(position);
holder.number.setText(req.getNumber()); holder.number.setText(req.getNumber());
String dueDate="Due : "+ req.getDueDate(); holder.shortDescription.setText(req.getShotrDescription());
holder.dueDate.setText(dueDate);
holder.shotrDescription.setText(req.getShotrDescription());
if(!req.getApproval().isEmpty()) { if(!req.getApproval().isEmpty()) {
if (req.getApproval().equalsIgnoreCase("requested")) { if (req.getApproval().equalsIgnoreCase("requested")) {
...@@ -99,8 +96,7 @@ public class MyRequestAdapter extends BaseAdapter { ...@@ -99,8 +96,7 @@ public class MyRequestAdapter extends BaseAdapter {
static class ViewHolder { static class ViewHolder {
private TextView number; private TextView number;
private TextView dueDate; private TextView shortDescription;
private TextView shotrDescription;
private TextView approval; private TextView approval;
private ImageView statusIndicator; private ImageView statusIndicator;
} }
......
...@@ -89,9 +89,10 @@ public class MyRequestApiManager { ...@@ -89,9 +89,10 @@ public class MyRequestApiManager {
List<MyRequest> catalogueList = new ArrayList<>(catalogueJsonArray.length()); List<MyRequest> catalogueList = new ArrayList<>(catalogueJsonArray.length());
for (int i = 0; i < catalogueJsonArray.length(); i++) { for (int i = 0; i < catalogueJsonArray.length(); i++) {
JSONObject expenseJsonObject = catalogueJsonArray.getJSONObject(i); JSONObject myRequestJsonObject = catalogueJsonArray.getJSONObject(i);
MyRequest catalogue = gson.fromJson(expenseJsonObject.toString(), MyRequest.class); MyRequest myRequest = gson.fromJson(myRequestJsonObject.toString(), MyRequest.class);
catalogueList.add(catalogue); myRequest.parseJson(myRequestJsonObject);
catalogueList.add(myRequest);
} }
listener.onDoneApiCall(catalogueList); listener.onDoneApiCall(catalogueList);
} else { } else {
......
...@@ -2,6 +2,10 @@ package com.vsoft.uoflservicenow.db.models; ...@@ -2,6 +2,10 @@ package com.vsoft.uoflservicenow.db.models;
import com.google.gson.annotations.Expose; import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName; import com.google.gson.annotations.SerializedName;
import com.vsoft.uoflservicenow.utils.Util;
import org.json.JSONException;
import org.json.JSONObject;
/** /**
* Created by kvemulavada on 8/30/2016. * Created by kvemulavada on 8/30/2016.
...@@ -12,9 +16,9 @@ public class MyRequest { ...@@ -12,9 +16,9 @@ public class MyRequest {
@Expose @Expose
private String number; private String number;
@SerializedName("due_date") @SerializedName("sys_updated_on")
@Expose // @Expose
private String dueDate; private long updateOn;
@SerializedName("short_description") @SerializedName("short_description")
@Expose @Expose
...@@ -32,12 +36,12 @@ public class MyRequest { ...@@ -32,12 +36,12 @@ public class MyRequest {
this.number = number; this.number = number;
} }
public String getDueDate() { public long getUpdateOn() {
return dueDate; return updateOn;
} }
public void setDueDate(String dueDate) { public void setUpdateOn(long updateOn) {
this.dueDate = dueDate; this.updateOn = updateOn;
} }
public String getShotrDescription() { public String getShotrDescription() {
...@@ -56,8 +60,20 @@ public class MyRequest { ...@@ -56,8 +60,20 @@ public class MyRequest {
this.approval = approval; this.approval = approval;
} }
public void parseJson(JSONObject jsonObject) {
String dueDate = null;
try {
dueDate = jsonObject.getString(Json.DUE_DATE);
} catch (JSONException e) {
e.printStackTrace();
}
this.setUpdateOn(Util.getDateTimeForMyRequestFromString(dueDate));
}
public static class Json { public static class Json {
public static final String URL_PARAM_CATALOGUE_SYSPRM_QUERY_VALUE = "request.requested_for=javascript:gs.getUserID()"; public static final String URL_PARAM_CATALOGUE_SYSPRM_QUERY_VALUE = "request.requested_for=javascript:gs.getUserID()";
public static final String DUE_DATE = "sys_updated_on";
} }
} }
...@@ -22,6 +22,8 @@ import com.vsoft.uoflservicenow.enums.SyncStatus; ...@@ -22,6 +22,8 @@ import com.vsoft.uoflservicenow.enums.SyncStatus;
import com.vsoft.uoflservicenow.utils.DialogUtils; import com.vsoft.uoflservicenow.utils.DialogUtils;
import com.vsoft.uoflservicenow.utils.Util; import com.vsoft.uoflservicenow.utils.Util;
import java.util.Collections;
import java.util.Comparator;
import java.util.List; import java.util.List;
import butterknife.BindView; import butterknife.BindView;
...@@ -104,11 +106,20 @@ public class MyRequestActivity extends AppCompatActivity { ...@@ -104,11 +106,20 @@ public class MyRequestActivity extends AppCompatActivity {
private void setData(final List<MyRequest> reqList) { private void setData(final List<MyRequest> reqList) {
MyRequestAdapter adapter = new MyRequestAdapter(MyRequestActivity.this); MyRequestAdapter adapter = new MyRequestAdapter(MyRequestActivity.this);
Collections.sort(reqList, new StringDateComparator());
adapter.setRequestList(reqList); adapter.setRequestList(reqList);
mListView.setAdapter(adapter); mListView.setAdapter(adapter);
} }
class StringDateComparator implements Comparator<MyRequest> {
public int compare(MyRequest lhs, MyRequest rhs) {
return lhs.getUpdateOn()>rhs.getUpdateOn() ? -1 : 1;
}
}
@Override @Override
public boolean onOptionsItemSelected(MenuItem menuItem) { public boolean onOptionsItemSelected(MenuItem menuItem) {
if (menuItem.getItemId() == android.R.id.home) { if (menuItem.getItemId() == android.R.id.home) {
......
...@@ -300,6 +300,17 @@ public class Util { ...@@ -300,6 +300,17 @@ public class Util {
return date.getTime(); return date.getTime();
} }
public static long getDateTimeForMyRequestFromString(String strDate) {
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.US);
Date date = null;
try {
date = df.parse(strDate);
} catch (ParseException e) {
e.printStackTrace();
}
return date.getTime();
}
/*Record a screen view hit for the visible*/ /*Record a screen view hit for the visible*/
public static void sendScreenName(Tracker tracker, String name) { public static void sendScreenName(Tracker tracker, String name) {
tracker.setScreenName(name); tracker.setScreenName(name);
......
...@@ -19,21 +19,6 @@ ...@@ -19,21 +19,6 @@
android:textSize="@dimen/ruquest_descps_text_size" android:textSize="@dimen/ruquest_descps_text_size"
android:textStyle="bold" /> android:textStyle="bold" />
<TextView
android:id="@+id/dueDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/number"
android:layout_alignParentRight="true"
android:layout_below="@+id/number"
android:layout_marginRight="@dimen/my_request_top"
android:layout_marginTop="@dimen/my_request_top"
android:text="Large Text"
android:textColor="#8e8e8e"
android:textSize="@dimen/ruquest_descps_text_size"
android:visibility="gone" />
<TextView <TextView
android:id="@+id/shotrDescription" android:id="@+id/shotrDescription"
android:layout_width="wrap_content" android:layout_width="wrap_content"
...@@ -69,5 +54,4 @@ ...@@ -69,5 +54,4 @@
android:text="Large Text" android:text="Large Text"
android:textColor="#8e8e8e" android:textColor="#8e8e8e"
android:textSize="@dimen/ruquest_status_text_size" /> android:textSize="@dimen/ruquest_status_text_size" />
</RelativeLayout> </RelativeLayout>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment