// Service call for getting data from server
ServiceFactory.getProfessionalResourceService().getProductList(
SearchagainActivity.this, fileType, searchText,token,Appversion,
new IRequestListener<ProductProfessionalResponse>() {
@Override
public void onRequestFailure(VolleyError error) {
// TODO Auto-generated method stub
CommonUtilities.showErrorDialog(SearchagainActivity.this, null);
}
@Override
public void onRequestSuccess(ProductProfessionalResponse response) {
// TODO Auto-generated method stub
if(response !=null&& response.getmServerResponse().getmStatus().equalsIgnoreCase("success"))
{
mProductSearch=new ArrayList();
mProduct=new ArrayList<Product>();
mProfessional=new ArrayList<ProfessionalResource>();
ProductProfessional details = response.getmFavourites();
mProduct=details.getmProductList();
mProfessional=details.getmFilesList();
if (mProfessional != null && !mProfessional.isEmpty())
//get professional resource from server {
mAdapter=new ProfResCustomGalleryAdapter(getApplicationContext(), mProfessional);
mRecyclerView.setAdapter(mAdapter);
}else
{
//getting product from server
mAdapterProduct=new ProductListAdapter(getApplicationContext(), mProduct);
mRecyclerView.setAdapter(mAdapterProduct);
}
/* */
/*if (bFavouriteMode)
resetFileAdapter(true);
else
refreshAdapter(true);*/
//mRecyclerView.setAdapter(mAdapterProduct);
}
}
@Override
public void onResponseError(String errorCode) {
// TODO Auto-generated method stub
//CommonUtilities.showErrorDialog(SearchagainActivity.this, null);
mTvErrorMsg.setText("Product is not available");
dialog.show();
}
} );
}
/* *//**
* to get the search string entered in the searchBox of the
/**
* Set RecyclerView's LayoutManager to the one given.
*
* @param layoutManagerType Type of layout manager to switch to.
*/
/ 将布局附加到Recycler视图,这是我将布局附加到recyclerview的方法 / public void setRecyclerViewLayoutManager(){ ; // Log.d(TAG,“setRecyclerViewLayoutManager()”); int scrollPosition = 0;
// If a layout manager has already been set, get current scroll
// position.
if (mRecyclerView.getLayoutManager() != null) {
scrollPosition = ((LinearLayoutManager)mRecyclerView.getLayoutManager())
.findFirstCompletelyVisibleItemPosition();
}
mLayoutManager = new GridLayoutManager(this, SPAN_COUNT);
mRecyclerView.setLayoutManager(mLayoutManager);
mRecyclerView.scrollToPosition(scrollPosition);
}
答案 0 :(得分:0)
当没有附加布局管理器时,由recyclerview记录错误,直到时间布局管理器基本上每当它将尝试布局视图时,它将检查是否附加了布局管理器,如果没有,它将记录错误