@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); MobclickAgent.onError(this); UMFeedbackService.enableNewReplyNotification(this, NotificationType.AlertDialog); setContentView(R.layout.activity_main); mGoodsAdapter = new GoodsItemAdapter(this, R.id.imageView1, GoodsItemManager.instance().getGoodsItems()); // mAdapter = new SGVAdapter(this); mSGV = (StaggeredGridView) findViewById(R.id.grid); // mSGV.setColumnCount(-1); // mSGV.setAdapter(mAdapter); mSGV.setAdapter(mGoodsAdapter); // mSGV.setAdapter(new EndlessGoodsItemAdapter(this, mGoodsAdapter, R.id.textView1)); mSGV.setItemMargin(10); mGoodsAdapter.notifyDataSetChanged(); mProgress = (ProgressBar) findViewById(R.id.progress); mGaInstance = GoogleAnalytics.getInstance(this); mGaTracker = mGaInstance.getTracker("UA-39513550-1"); }
@Override protected void onResume() { super.onResume(); if (GoodsItemManager.instance().getGoodsItems().size() == 0) { refreshGoodsItems(); } MobclickAgent.onResume(this); // refreshGoodsItems(); }
public void onLoadFinished() { if (mLoadSuccess) { mGoodsAdapter = new GoodsItemAdapter(this, R.id.imageView1, GoodsItemManager.instance().getGoodsItems()); mSGV.setAdapter(mGoodsAdapter); } else { Toast.makeText(this, "Network error!", Toast.LENGTH_SHORT).show(); } if (mRefreshItem != null && mRefreshItem.getActionView() != null) { mRefreshItem.getActionView().clearAnimation(); mRefreshItem.setActionView(null); } mSGV.setVisibility(View.VISIBLE); mProgress.setVisibility(View.GONE); }
private void refreshGoodsItems() { mProgress.setVisibility(View.VISIBLE); if (checkInternet()) { GoodsItemManager.instance() .refresh( new OnGoodsItemLoadListener() { @Override public void onComplete(ArrayList<GoodsItem> mGoodsItems) { // TODO Auto-generated method stub mHandler.postDelayed( new Runnable() { @Override public void run() { onLoadFinished(); } }, 1000); mLoadSuccess = true; } @Override public void onError(ApiError error) { // TODO Auto-generated method stub Log.d("SD_TRACE", "load api error" + error.toString()); mLoadSuccess = false; } @Override public void onException(Exception e) { // TODO Auto-generated method stub Log.d("SD_TRACE", "load api exception" + e.toString()); mLoadSuccess = false; } }); } else { mLoadSuccess = false; onLoadFinished(); } }