use of com.github.asifmujteba.easyvolleysample.Models.Product in project EasyVolley by asifmujteba.
the class ProductsActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
productsAdapter = new ProductsAdapter(mContext, new ArrayList<Product>());
gridView.setEmptyView(emptyElement);
gridView.setAdapter(productsAdapter);
gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Product product = productsAdapter.getItem(position);
DetailsActivity.launch(mContext, product, (ImageView) view.findViewById(R.id.imageView));
}
});
swipeContainer.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
loadProducts();
}
});
loadProducts();
}
use of com.github.asifmujteba.easyvolleysample.Models.Product in project EasyVolley by asifmujteba.
the class ServerController method getWomenClothingProducts.
public void getWomenClothingProducts(Object subscriber, final OnServerResponseListener<ArrayList<Product>> listener) {
EasyVolley.withGlobalQueue().load(URLWomenClothing).addParam("p1", "something").asJsonObject().setSubscriber(subscriber).setCallback(new ASFRequestListener<JsonObject>() {
@Override
public void onSuccess(JsonObject response) {
JsonArray results = response.get("metadata").getAsJsonObject().getAsJsonArray("results");
ArrayList<Product> products = Product.parseJsonArray(results);
if (listener != null) {
listener.onSuccess(products);
}
}
@Override
public void onFailure(Exception e) {
if (listener != null) {
listener.onError(e);
}
}
}).start();
}
use of com.github.asifmujteba.easyvolleysample.Models.Product in project EasyVolley by asifmujteba.
the class ProductsAdapter method getView.
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder = null;
if (convertView == null) {
convertView = layoutInflater.inflate(R.layout.item_product, parent, false);
holder = new ViewHolder(convertView);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
Product product = products.get(position);
holder.lblTitle.setText(product.getData().getName());
holder.lblPrice.setText("RM " + product.getData().getPrice());
if (product.getImages().length > 0) {
holder.imageView.setImageResource(R.mipmap.unknown);
App.getInstance().getServerController().loadImage(product.getImages()[0].getPath() + "?thumb=1").setMaxWidth(375).setMaxHeight(375).setScaleType(ImageView.ScaleType.CENTER_INSIDE).into(holder.imageView).start();
}
return convertView;
}
Aggregations