Commit bbf3b96e by Kunj Gupta

UOFLMA-71 - Catalog category and item, implement image API.

parent 49e2e455
...@@ -66,4 +66,5 @@ dependencies { ...@@ -66,4 +66,5 @@ dependencies {
compile('com.crashlytics.sdk.android:crashlytics:2.6.2@aar') { compile('com.crashlytics.sdk.android:crashlytics:2.6.2@aar') {
transitive = true; transitive = true;
} }
compile 'com.squareup.picasso:picasso:2.5.2'
} }
...@@ -5,10 +5,13 @@ import android.view.LayoutInflater; ...@@ -5,10 +5,13 @@ import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.BaseAdapter; import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
import com.squareup.picasso.Picasso;
import com.vsoft.uoflservicenow.R; import com.vsoft.uoflservicenow.R;
import com.vsoft.uoflservicenow.db.models.Catalogue; import com.vsoft.uoflservicenow.db.models.Catalogue;
import com.vsoft.uoflservicenow.utils.Constants;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
...@@ -19,8 +22,10 @@ import java.util.List; ...@@ -19,8 +22,10 @@ import java.util.List;
public class CatalogueCategoryAdapter extends BaseAdapter { public class CatalogueCategoryAdapter extends BaseAdapter {
private final List<Catalogue> mCatalogueList = new ArrayList<>(0); private final List<Catalogue> mCatalogueList = new ArrayList<>(0);
private LayoutInflater mInflater; private LayoutInflater mInflater;
private Context mContext;
public CatalogueCategoryAdapter(Context context) { public CatalogueCategoryAdapter(Context context) {
mContext = context;
mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
} }
...@@ -60,6 +65,7 @@ public class CatalogueCategoryAdapter extends BaseAdapter { ...@@ -60,6 +65,7 @@ public class CatalogueCategoryAdapter extends BaseAdapter {
holder = new ViewHolder(); holder = new ViewHolder();
holder.titleTextView = (TextView) convertView.findViewById(R.id.catalogue_category_adapter_title_tv); holder.titleTextView = (TextView) convertView.findViewById(R.id.catalogue_category_adapter_title_tv);
holder.desTextView = (TextView) convertView.findViewById(R.id.catalogue_category_adapter_des_tv); holder.desTextView = (TextView) convertView.findViewById(R.id.catalogue_category_adapter_des_tv);
holder.image = (ImageView) convertView.findViewById(R.id.catalogue_category_adapter_image);
convertView.setTag(holder); convertView.setTag(holder);
} else { } else {
holder = (ViewHolder) convertView.getTag(); holder = (ViewHolder) convertView.getTag();
...@@ -67,7 +73,7 @@ public class CatalogueCategoryAdapter extends BaseAdapter { ...@@ -67,7 +73,7 @@ public class CatalogueCategoryAdapter extends BaseAdapter {
Catalogue catalogue = mCatalogueList.get(position); Catalogue catalogue = mCatalogueList.get(position);
holder.titleTextView.setText(catalogue.getTitle()); holder.titleTextView.setText(catalogue.getTitle());
if(!catalogue.getDescription().isEmpty()) { if(catalogue.getDescription() != null && !catalogue.getDescription().isEmpty()) {
holder.desTextView.setVisibility(View.VISIBLE); holder.desTextView.setVisibility(View.VISIBLE);
holder.desTextView.setText(catalogue.getDescription()); holder.desTextView.setText(catalogue.getDescription());
} else { } else {
...@@ -75,6 +81,14 @@ public class CatalogueCategoryAdapter extends BaseAdapter { ...@@ -75,6 +81,14 @@ public class CatalogueCategoryAdapter extends BaseAdapter {
holder.desTextView.setText(catalogue.getDescription()); holder.desTextView.setText(catalogue.getDescription());
} }
if(catalogue.getIcon() != null && !catalogue.getIcon().isEmpty()) {
StringBuilder builder = new StringBuilder();
builder.append(Constants.DOMAIN);
builder.append(catalogue.getIcon());
Picasso.with(mContext).load(builder.toString()).into(holder.image);
}
return convertView; return convertView;
} }
...@@ -82,5 +96,6 @@ public class CatalogueCategoryAdapter extends BaseAdapter { ...@@ -82,5 +96,6 @@ public class CatalogueCategoryAdapter extends BaseAdapter {
static class ViewHolder { static class ViewHolder {
private TextView titleTextView; private TextView titleTextView;
private TextView desTextView; private TextView desTextView;
private ImageView image;
} }
} }
\ No newline at end of file
...@@ -5,10 +5,13 @@ import android.view.LayoutInflater; ...@@ -5,10 +5,13 @@ import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.BaseAdapter; import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
import com.squareup.picasso.Picasso;
import com.vsoft.uoflservicenow.R; import com.vsoft.uoflservicenow.R;
import com.vsoft.uoflservicenow.db.models.CatalogueItem; import com.vsoft.uoflservicenow.db.models.CatalogueItem;
import com.vsoft.uoflservicenow.utils.Constants;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
...@@ -19,8 +22,10 @@ import java.util.List; ...@@ -19,8 +22,10 @@ import java.util.List;
public class CatalogueCategoryItemAdapter extends BaseAdapter { public class CatalogueCategoryItemAdapter extends BaseAdapter {
private final List<CatalogueItem> mCatalogueItemList = new ArrayList<>(0); private final List<CatalogueItem> mCatalogueItemList = new ArrayList<>(0);
private LayoutInflater mInflater; private LayoutInflater mInflater;
private Context mContext;
public CatalogueCategoryItemAdapter(Context context) { public CatalogueCategoryItemAdapter(Context context) {
mContext = context;
mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
} }
...@@ -60,6 +65,7 @@ public class CatalogueCategoryItemAdapter extends BaseAdapter { ...@@ -60,6 +65,7 @@ public class CatalogueCategoryItemAdapter extends BaseAdapter {
holder = new ViewHolder(); holder = new ViewHolder();
holder.nameTextView = (TextView) convertView.findViewById(R.id.catalogue_category_item_adapter_name_tv); holder.nameTextView = (TextView) convertView.findViewById(R.id.catalogue_category_item_adapter_name_tv);
holder.desTextView = (TextView) convertView.findViewById(R.id.catalogue_category_item_adapter_des_tv); holder.desTextView = (TextView) convertView.findViewById(R.id.catalogue_category_item_adapter_des_tv);
holder.image = (ImageView) convertView.findViewById(R.id.catalogue_category_item_adapter_image);
convertView.setTag(holder); convertView.setTag(holder);
} else { } else {
holder = (ViewHolder) convertView.getTag(); holder = (ViewHolder) convertView.getTag();
...@@ -67,7 +73,7 @@ public class CatalogueCategoryItemAdapter extends BaseAdapter { ...@@ -67,7 +73,7 @@ public class CatalogueCategoryItemAdapter extends BaseAdapter {
CatalogueItem catalogueItem = mCatalogueItemList.get(position); CatalogueItem catalogueItem = mCatalogueItemList.get(position);
holder.nameTextView.setText(catalogueItem.getName()); holder.nameTextView.setText(catalogueItem.getName());
if(!catalogueItem.getShortDescription().isEmpty()) { if(catalogueItem.getShortDescription()!=null && !catalogueItem.getShortDescription().isEmpty()) {
holder.desTextView.setVisibility(View.VISIBLE); holder.desTextView.setVisibility(View.VISIBLE);
holder.desTextView.setText(catalogueItem.getShortDescription()); holder.desTextView.setText(catalogueItem.getShortDescription());
} else { } else {
...@@ -75,11 +81,20 @@ public class CatalogueCategoryItemAdapter extends BaseAdapter { ...@@ -75,11 +81,20 @@ public class CatalogueCategoryItemAdapter extends BaseAdapter {
holder.desTextView.setText(catalogueItem.getShortDescription()); holder.desTextView.setText(catalogueItem.getShortDescription());
} }
if(catalogueItem.getIcon() != null && !catalogueItem.getIcon().isEmpty()) {
StringBuilder builder = new StringBuilder();
builder.append(Constants.DOMAIN);
builder.append(catalogueItem.getIcon());
Picasso.with(mContext).load(builder.toString()).into(holder.image);
}
return convertView; return convertView;
} }
static class ViewHolder { static class ViewHolder {
private TextView nameTextView; private TextView nameTextView;
private TextView desTextView; private TextView desTextView;
private ImageView image;
} }
} }
\ No newline at end of file
...@@ -17,7 +17,8 @@ public interface CatalogueCategoryApi { ...@@ -17,7 +17,8 @@ public interface CatalogueCategoryApi {
// Get Catalogue API // Get Catalogue API
@GET(Constants.URL_GET_CATALOGUE) @GET(Constants.URL_GET_CATALOGUE)
Call<ResponseBody> getCatalogue(@Query(Constants.URL_PARAM_SYSPRM_QUERY) String sysparmQuery, Call<ResponseBody> getCatalogue(@Query(Constants.URL_PARAM_SYSPRM_QUERY) String sysparmQuery,
@Query(Constants.URL_PARAM_SYSPRM_FIELDS) String sysParmFields); @Query(Constants.URL_PARAM_SYSPRM_FIELDS) String sysParmFields,
@Query(Constants.URL_PARAM_SYSPRM_DISPLAY_VALUE) String sysParmDisplayValue);
} }
...@@ -17,7 +17,8 @@ public interface CatalogueCategoryItemApi { ...@@ -17,7 +17,8 @@ public interface CatalogueCategoryItemApi {
// Get Catalogue Item API // Get Catalogue Item API
@GET(Constants.URL_GET_CATALOGUE_ITEM) @GET(Constants.URL_GET_CATALOGUE_ITEM)
Call<ResponseBody> getCatalogueItem(@Query(Constants.URL_PARAM_SYSPRM_QUERY) String sysparmQuery, Call<ResponseBody> getCatalogueItem(@Query(Constants.URL_PARAM_SYSPRM_QUERY) String sysparmQuery,
@Query(Constants.URL_PARAM_SYSPRM_FIELDS) String sysParmFields); @Query(Constants.URL_PARAM_SYSPRM_FIELDS) String sysParmFields,
@Query(Constants.URL_PARAM_SYSPRM_DISPLAY_VALUE) String sysParmDisplayValue);
} }
...@@ -43,7 +43,7 @@ public class CatalogueApiManager { ...@@ -43,7 +43,7 @@ public class CatalogueApiManager {
CatalogueLog.d("CatalogueApiManager: getCatalogues: request parameter: "+stringBuilder.toString()); CatalogueLog.d("CatalogueApiManager: getCatalogues: request parameter: "+stringBuilder.toString());
final Retrofit retrofit = RestClient.getInitializedRestAdapter(Constants.API_AUTH_PARAM_USER_NAME, Constants.API_AUTH_PARAM_PASSWORD); final Retrofit retrofit = RestClient.getInitializedRestAdapter(Constants.API_AUTH_PARAM_USER_NAME, Constants.API_AUTH_PARAM_PASSWORD);
Call<ResponseBody> call = retrofit.create(CatalogueCategoryApi.class).getCatalogue(stringBuilder.toString(), "sys_id,title,description"); Call<ResponseBody> call = retrofit.create(CatalogueCategoryApi.class).getCatalogue(stringBuilder.toString(), "sys_id,title,description,icon", "true");
try { try {
//Retrofit synchronous call //Retrofit synchronous call
Response<ResponseBody> response = call.execute(); Response<ResponseBody> response = call.execute();
......
...@@ -44,7 +44,7 @@ public class CatalogueItemApiManager { ...@@ -44,7 +44,7 @@ public class CatalogueItemApiManager {
CatalogueLog.d("CatalogueItemApiManager: getCatalogueItems: request parameter: "+stringBuilder.toString()); CatalogueLog.d("CatalogueItemApiManager: getCatalogueItems: request parameter: "+stringBuilder.toString());
final Retrofit retrofit = RestClient.getInitializedRestAdapter(Constants.API_AUTH_PARAM_USER_NAME, Constants.API_AUTH_PARAM_PASSWORD); final Retrofit retrofit = RestClient.getInitializedRestAdapter(Constants.API_AUTH_PARAM_USER_NAME, Constants.API_AUTH_PARAM_PASSWORD);
Call<ResponseBody> call = retrofit.create(CatalogueCategoryItemApi.class).getCatalogueItem(stringBuilder.toString(), "sys_id,short_description,name,description"); Call<ResponseBody> call = retrofit.create(CatalogueCategoryItemApi.class).getCatalogueItem(stringBuilder.toString(), "sys_id,short_description,name,description,icon", "true");
try { try {
//Retrofit synchronous call //Retrofit synchronous call
Response<ResponseBody> response = call.execute(); Response<ResponseBody> response = call.execute();
......
...@@ -17,6 +17,9 @@ public class Catalogue { ...@@ -17,6 +17,9 @@ public class Catalogue {
@SerializedName("sys_id") @SerializedName("sys_id")
@Expose @Expose
private String sysId; private String sysId;
@SerializedName("icon")
@Expose
private String icon;
/** /**
* *
...@@ -72,6 +75,24 @@ public class Catalogue { ...@@ -72,6 +75,24 @@ public class Catalogue {
this.sysId = sysId; this.sysId = sysId;
} }
/**
*
* @return
* The icon
*/
public String getIcon() {
return icon;
}
/**
*
* @param icon
* The icon
*/
public void setIcon(String icon) {
this.icon = icon;
}
public static class Json { public static class Json {
public static final String URL_PARAM_CATALOGUE_SYSPRM_QUERY_VALUE = "sc_catalog"; public static final String URL_PARAM_CATALOGUE_SYSPRM_QUERY_VALUE = "sc_catalog";
} }
...@@ -79,9 +100,10 @@ public class Catalogue { ...@@ -79,9 +100,10 @@ public class Catalogue {
@Override @Override
public String toString() { public String toString() {
return "Catalogue{" + return "Catalogue{" +
", title='" + title + '\'' + "title='" + title + '\'' +
", description='" + description + '\'' + ", description='" + description + '\'' +
", sysId='" + sysId + '\'' + ", sysId='" + sysId + '\'' +
", icon='" + icon + '\'' +
'}'; '}';
} }
} }
...@@ -20,6 +20,9 @@ public class CatalogueItem { ...@@ -20,6 +20,9 @@ public class CatalogueItem {
@SerializedName("sys_id") @SerializedName("sys_id")
@Expose @Expose
private String sysId; private String sysId;
@SerializedName("icon")
@Expose
private String icon;
/** /**
* *
...@@ -93,6 +96,24 @@ public class CatalogueItem { ...@@ -93,6 +96,24 @@ public class CatalogueItem {
this.sysId = sysId; this.sysId = sysId;
} }
/**
*
* @return
* The icon
*/
public String getIcon() {
return icon;
}
/**
*
* @param icon
* The icon
*/
public void setIcon(String icon) {
this.icon = icon;
}
public static class Json { public static class Json {
public static final String URL_PARAM_CATALOGUE_SYSPRM_QUERY_VALUE = "category"; public static final String URL_PARAM_CATALOGUE_SYSPRM_QUERY_VALUE = "category";
public static final String SYS_ID = "sys_id"; public static final String SYS_ID = "sys_id";
...@@ -101,10 +122,11 @@ public class CatalogueItem { ...@@ -101,10 +122,11 @@ public class CatalogueItem {
@Override @Override
public String toString() { public String toString() {
return "CatalogueItem{" + return "CatalogueItem{" +
", shortDescription='" + shortDescription + '\'' + "shortDescription='" + shortDescription + '\'' +
", description='" + description + '\'' + ", description='" + description + '\'' +
", name='" + name + '\'' + ", name='" + name + '\'' +
", sysId='" + sysId + '\'' + ", sysId='" + sysId + '\'' +
", icon='" + icon + '\'' +
'}'; '}';
} }
} }
...@@ -34,6 +34,7 @@ public class Constants { ...@@ -34,6 +34,7 @@ public class Constants {
*/ */
public static final String URL_PARAM_SYSPRM_QUERY = "sysparm_query"; public static final String URL_PARAM_SYSPRM_QUERY = "sysparm_query";
public static final String URL_PARAM_SYSPRM_FIELDS = "sysparm_fields"; public static final String URL_PARAM_SYSPRM_FIELDS = "sysparm_fields";
public static final String URL_PARAM_SYSPRM_DISPLAY_VALUE = "sysparm_display_value";
public static final String URL_PARAM_SYSPRM_USERNAME = "user_name"; public static final String URL_PARAM_SYSPRM_USERNAME = "user_name";
public static final String URL_PARAM_SYSPRM_LIMIT = "sysparm_limit"; public static final String URL_PARAM_SYSPRM_LIMIT = "sysparm_limit";
...@@ -131,8 +132,10 @@ public class Constants { ...@@ -131,8 +132,10 @@ public class Constants {
public static final String URL_POST_CATALOGUE_ITEM = "api/uno33/uofl_mobile"; public static final String URL_POST_CATALOGUE_ITEM = "api/uno33/uofl_mobile";
public static final String URL_GET_REFERENCE = API_PATH; public static final String URL_GET_REFERENCE = API_PATH;
/*Request API*/
public static final String URL_GET_MYREQUEST = API_PATH + "sc_req_item"; public static final String URL_GET_MYREQUEST = API_PATH + "sc_req_item";
public static final String URL_GET_USERDETAILS = API_PATH + "sys_user"; public static final String URL_GET_USERDETAILS = API_PATH + "sys_user";
/*Incident API */ /*Incident API */
public static final String URL_GET_INCIDENTS = API_PATH + "incident"; public static final String URL_GET_INCIDENTS = API_PATH + "incident";
public static final String URL_POST_INCIDENT = API_PATH + "incident"; public static final String URL_POST_INCIDENT = API_PATH + "incident";
......
...@@ -8,11 +8,12 @@ ...@@ -8,11 +8,12 @@
android:background="@drawable/list_view_item_bg_with_border"> android:background="@drawable/list_view_item_bg_with_border">
<ImageView <ImageView
android:id="@+id/catalogue_category_adapter_image"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="match_parent"
android:layout_weight="3" android:layout_weight="3"
android:layout_gravity="center" android:layout_gravity="center"
android:src="@drawable/dummy_image"/> android:padding="@dimen/normal_margin"/>
<LinearLayout <LinearLayout
android:layout_width="0dp" android:layout_width="0dp"
......
...@@ -8,11 +8,12 @@ ...@@ -8,11 +8,12 @@
android:background="@drawable/list_view_item_bg_with_border"> android:background="@drawable/list_view_item_bg_with_border">
<ImageView <ImageView
android:id="@+id/catalogue_category_item_adapter_image"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="match_parent"
android:layout_weight="3" android:layout_weight="3"
android:layout_gravity="center" android:layout_gravity="center"
android:src="@drawable/dummy_image"/> android:padding="@dimen/normal_margin"/>
<LinearLayout <LinearLayout
android:layout_width="0dp" android:layout_width="0dp"
......
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