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 {
convertView = mInflater.inflate(R.layout.request_list_item, parent, false);
holder = new ViewHolder();
holder.number = (TextView) convertView.findViewById(R.id.number);
holder.dueDate = (TextView) convertView.findViewById(R.id.dueDate);
holder.shotrDescription = (TextView) convertView.findViewById(R.id.shotrDescription);
holder.shortDescription = (TextView) convertView.findViewById(R.id.shotrDescription);
holder.approval = (TextView) convertView.findViewById(R.id.approval);
holder.statusIndicator = (ImageView) convertView.findViewById(R.id.approval_image);
convertView.setTag(holder);
......@@ -75,9 +74,7 @@ public class MyRequestAdapter extends BaseAdapter {
MyRequest req = mReqList.get(position);
holder.number.setText(req.getNumber());
String dueDate="Due : "+ req.getDueDate();
holder.dueDate.setText(dueDate);
holder.shotrDescription.setText(req.getShotrDescription());
holder.shortDescription.setText(req.getShotrDescription());
if(!req.getApproval().isEmpty()) {
if (req.getApproval().equalsIgnoreCase("requested")) {
......@@ -99,8 +96,7 @@ public class MyRequestAdapter extends BaseAdapter {
static class ViewHolder {
private TextView number;
private TextView dueDate;
private TextView shotrDescription;
private TextView shortDescription;
private TextView approval;
private ImageView statusIndicator;
}
......
......@@ -89,9 +89,10 @@ public class MyRequestApiManager {
List<MyRequest> catalogueList = new ArrayList<>(catalogueJsonArray.length());
for (int i = 0; i < catalogueJsonArray.length(); i++) {
JSONObject expenseJsonObject = catalogueJsonArray.getJSONObject(i);
MyRequest catalogue = gson.fromJson(expenseJsonObject.toString(), MyRequest.class);
catalogueList.add(catalogue);
JSONObject myRequestJsonObject = catalogueJsonArray.getJSONObject(i);
MyRequest myRequest = gson.fromJson(myRequestJsonObject.toString(), MyRequest.class);
myRequest.parseJson(myRequestJsonObject);
catalogueList.add(myRequest);
}
listener.onDoneApiCall(catalogueList);
} else {
......
......@@ -2,6 +2,10 @@ package com.vsoft.uoflservicenow.db.models;
import com.google.gson.annotations.Expose;
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.
......@@ -12,9 +16,9 @@ public class MyRequest {
@Expose
private String number;
@SerializedName("due_date")
@Expose
private String dueDate;
@SerializedName("sys_updated_on")
// @Expose
private long updateOn;
@SerializedName("short_description")
@Expose
......@@ -32,12 +36,12 @@ public class MyRequest {
this.number = number;
}
public String getDueDate() {
return dueDate;
public long getUpdateOn() {
return updateOn;
}
public void setDueDate(String dueDate) {
this.dueDate = dueDate;
public void setUpdateOn(long updateOn) {
this.updateOn = updateOn;
}
public String getShotrDescription() {
......@@ -56,8 +60,20 @@ public class MyRequest {
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 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;
import com.vsoft.uoflservicenow.utils.DialogUtils;
import com.vsoft.uoflservicenow.utils.Util;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import butterknife.BindView;
......@@ -104,11 +106,20 @@ public class MyRequestActivity extends AppCompatActivity {
private void setData(final List<MyRequest> reqList) {
MyRequestAdapter adapter = new MyRequestAdapter(MyRequestActivity.this);
Collections.sort(reqList, new StringDateComparator());
adapter.setRequestList(reqList);
mListView.setAdapter(adapter);
}
class StringDateComparator implements Comparator<MyRequest> {
public int compare(MyRequest lhs, MyRequest rhs) {
return lhs.getUpdateOn()>rhs.getUpdateOn() ? -1 : 1;
}
}
@Override
public boolean onOptionsItemSelected(MenuItem menuItem) {
if (menuItem.getItemId() == android.R.id.home) {
......
......@@ -300,6 +300,17 @@ public class Util {
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*/
public static void sendScreenName(Tracker tracker, String name) {
tracker.setScreenName(name);
......
......@@ -19,21 +19,6 @@
android:textSize="@dimen/ruquest_descps_text_size"
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
android:id="@+id/shotrDescription"
android:layout_width="wrap_content"
......@@ -69,5 +54,4 @@
android:text="Large Text"
android:textColor="#8e8e8e"
android:textSize="@dimen/ruquest_status_text_size" />
</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