|
@@ -0,0 +1,561 @@
|
|
|
|
|
+package com.usai.redant.apexdrivers.Home;
|
|
|
|
|
+
|
|
|
|
|
+import android.app.ProgressDialog;
|
|
|
|
|
+import android.content.Context;
|
|
|
|
|
+import android.content.Intent;
|
|
|
|
|
+import android.database.DataSetObserver;
|
|
|
|
|
+import android.graphics.Color;
|
|
|
|
|
+import android.os.Handler;
|
|
|
|
|
+import android.os.Message;
|
|
|
|
|
+import android.support.v4.widget.SwipeRefreshLayout;
|
|
|
|
|
+import android.support.v7.app.ActionBar;
|
|
|
|
|
+import android.support.v7.app.AlertDialog;
|
|
|
|
|
+import android.support.v7.app.AppCompatActivity;
|
|
|
|
|
+import android.os.Bundle;
|
|
|
|
|
+import android.text.TextUtils;
|
|
|
|
|
+import android.view.Gravity;
|
|
|
|
|
+import android.view.LayoutInflater;
|
|
|
|
|
+import android.view.MenuItem;
|
|
|
|
|
+import android.view.View;
|
|
|
|
|
+import android.view.ViewGroup;
|
|
|
|
|
+import android.widget.AbsListView;
|
|
|
|
|
+import android.widget.AdapterView;
|
|
|
|
|
+import android.widget.BaseAdapter;
|
|
|
|
|
+import android.widget.ListView;
|
|
|
|
|
+import android.widget.TextView;
|
|
|
|
|
+
|
|
|
|
|
+import com.usai.redant.apexdrivers.Detail.DetailActivity;
|
|
|
|
|
+import com.usai.redant.apexdrivers.R;
|
|
|
|
|
+import com.usai.redant.rautils.Utils.Network;
|
|
|
|
|
+
|
|
|
|
|
+import org.json.JSONArray;
|
|
|
|
|
+import org.json.JSONException;
|
|
|
|
|
+import org.json.JSONObject;
|
|
|
|
|
+
|
|
|
|
|
+import java.lang.ref.WeakReference;
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
|
|
+
|
|
|
|
|
+import static com.usai.redant.rautils.Utils.RAUtil.dp2px;
|
|
|
|
|
+import static com.usai.redant.rautils.Utils.RAUtil.sp2px;
|
|
|
|
|
+
|
|
|
|
|
+public class HomeMoreActivity extends AppCompatActivity implements AbsListView.OnScrollListener {
|
|
|
|
|
+
|
|
|
|
|
+ private final static String OrderTypeKey = "OrderTypeKey";
|
|
|
|
|
+ private final static String TitleKey = "TitleKey";
|
|
|
|
|
+
|
|
|
|
|
+ private final static String SavedJsonKey = "SavedJsonKey";
|
|
|
|
|
+ private final static String SavedOrderTypeKey = "SavedOrderTypeKey";
|
|
|
|
|
+
|
|
|
|
|
+ public static Intent build(Context context, int orderType, String title) {
|
|
|
|
|
+
|
|
|
|
|
+ if (context == null) {
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ Intent intent = new Intent(context,HomeMoreActivity.class);
|
|
|
|
|
+ intent.putExtra(OrderTypeKey,orderType);
|
|
|
|
|
+ if (title != null) {
|
|
|
|
|
+ intent.putExtra(TitleKey,title);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return intent;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private final static int limit = 20;
|
|
|
|
|
+
|
|
|
|
|
+ private ListView mListView;
|
|
|
|
|
+ private SwipeRefreshLayout mRefresh;
|
|
|
|
|
+ private TextView footer;
|
|
|
|
|
+ private Context mContext = this;
|
|
|
|
|
+ private ArrayList<HomeOrderModel> mOrders = new ArrayList<>();
|
|
|
|
|
+ private HomeMoreListAdapter mAdapter;
|
|
|
|
|
+ private HomeMoreHandler mHandler;
|
|
|
|
|
+ private int mType;
|
|
|
|
|
+ private HomeOrderModel mSelectedModel;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ protected void onCreate(Bundle savedInstanceState) {
|
|
|
|
|
+ super.onCreate(savedInstanceState);
|
|
|
|
|
+ setContentView(R.layout.activity_home_more);
|
|
|
|
|
+
|
|
|
|
|
+ ActionBar actionBar = getSupportActionBar();
|
|
|
|
|
+ if (actionBar != null) {
|
|
|
|
|
+ actionBar.setHomeButtonEnabled(true);
|
|
|
|
|
+ actionBar.setDisplayHomeAsUpEnabled(true);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ mHandler = new HomeMoreHandler(this);
|
|
|
|
|
+
|
|
|
|
|
+ mRefresh = findViewById(R.id.home_more_refresh);
|
|
|
|
|
+ mRefresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void onRefresh() {
|
|
|
|
|
+ reload();
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ mListView = findViewById(R.id.home_more_list_view);
|
|
|
|
|
+ configureListView();
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * Data
|
|
|
|
|
+ * */
|
|
|
|
|
+ Intent intent = getIntent();
|
|
|
|
|
+ if (intent != null) {
|
|
|
|
|
+ mType = intent.getIntExtra(OrderTypeKey,0);
|
|
|
|
|
+ String title = intent.getStringExtra(TitleKey);
|
|
|
|
|
+ if (!TextUtils.isEmpty(title)) {
|
|
|
|
|
+ setTitle(title);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (savedInstanceState != null) {
|
|
|
|
|
+ mType = savedInstanceState.getInt(SavedOrderTypeKey);
|
|
|
|
|
+ String jsonStr = savedInstanceState.getString(SavedJsonKey);
|
|
|
|
|
+ if (jsonStr != null) {
|
|
|
|
|
+ try {
|
|
|
|
|
+
|
|
|
|
|
+ JSONObject json = new JSONObject(jsonStr);
|
|
|
|
|
+ handleJson(json,LoadDataOptionInitial);
|
|
|
|
|
+
|
|
|
|
|
+ } catch (JSONException e){
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (mOrders.size() == 0) {
|
|
|
|
|
+ loadData();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public boolean onOptionsItemSelected(MenuItem item) {
|
|
|
|
|
+ switch (item.getItemId()) {
|
|
|
|
|
+ case android.R.id.home: {
|
|
|
|
|
+ finish();
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return super.onOptionsItemSelected(item);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ protected void onSaveInstanceState(Bundle outState) {
|
|
|
|
|
+ super.onSaveInstanceState(outState);
|
|
|
|
|
+
|
|
|
|
|
+ outState.putInt(SavedOrderTypeKey,mType);
|
|
|
|
|
+ String json = prepareOrderForSave();
|
|
|
|
|
+ if (json != null) {
|
|
|
|
|
+ outState.putString(SavedJsonKey,json);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private String prepareOrderForSave() {
|
|
|
|
|
+
|
|
|
|
|
+ try {
|
|
|
|
|
+
|
|
|
|
|
+ JSONArray orders = new JSONArray();
|
|
|
|
|
+ for (HomeOrderModel model : mOrders) {
|
|
|
|
|
+
|
|
|
|
|
+ JSONObject json = new JSONObject();
|
|
|
|
|
+ json.put("status",model.status);
|
|
|
|
|
+ if (model.title != null) {
|
|
|
|
|
+ json.put("title",model.title);
|
|
|
|
|
+ }
|
|
|
|
|
+ if (model.orderNo != null) {
|
|
|
|
|
+ json.put("orderNo",model.orderNo);
|
|
|
|
|
+ }
|
|
|
|
|
+ if (model.orderID != null) {
|
|
|
|
|
+ json.put("orderID",model.orderID);
|
|
|
|
|
+ }
|
|
|
|
|
+ if (model.containerNo != null) {
|
|
|
|
|
+ json.put("containerNo",model.containerNo);
|
|
|
|
|
+ }
|
|
|
|
|
+ if (model.date != null) {
|
|
|
|
|
+ json.put("date",model.date);
|
|
|
|
|
+ }
|
|
|
|
|
+ orders.put(json);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ JSONObject json = new JSONObject();
|
|
|
|
|
+ json.put("orders",orders);
|
|
|
|
|
+
|
|
|
|
|
+ return json.toString();
|
|
|
|
|
+
|
|
|
|
|
+ } catch (JSONException e) {
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * Configure
|
|
|
|
|
+ * */
|
|
|
|
|
+ private void configureListView() {
|
|
|
|
|
+
|
|
|
|
|
+ footer = new TextView(mContext);
|
|
|
|
|
+ footer.setBackgroundColor(Color.WHITE);
|
|
|
|
|
+ footer.setGravity(Gravity.CENTER);
|
|
|
|
|
+ footer.setText("loading...");
|
|
|
|
|
+ footer.setTextSize(sp2px(mContext,7));
|
|
|
|
|
+ footer.setTextColor(Color.BLACK);
|
|
|
|
|
+ footer.setVisibility(View.INVISIBLE);
|
|
|
|
|
+
|
|
|
|
|
+ AbsListView.LayoutParams footerLayoutParams = new AbsListView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,dp2px(mContext,40));
|
|
|
|
|
+ footer.setLayoutParams(footerLayoutParams);
|
|
|
|
|
+
|
|
|
|
|
+ mListView.addFooterView(footer);
|
|
|
|
|
+ mListView.setOnScrollListener(this);
|
|
|
|
|
+
|
|
|
|
|
+ mAdapter = new HomeMoreListAdapter();
|
|
|
|
|
+ mListView.setAdapter(mAdapter);
|
|
|
|
|
+
|
|
|
|
|
+ mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ HomeOrderModel orderModel = mOrders.get(position);
|
|
|
|
|
+
|
|
|
|
|
+ if (mSelectedModel != null) {
|
|
|
|
|
+ mSelectedModel.setSelection(false);
|
|
|
|
|
+ }
|
|
|
|
|
+ mSelectedModel = orderModel;
|
|
|
|
|
+ if (mSelectedModel != null) {
|
|
|
|
|
+ mSelectedModel.setSelection(true);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ Intent intent = DetailActivity.build(mContext,orderModel.orderID);
|
|
|
|
|
+ mContext.startActivity(intent);
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * Scroll Listener
|
|
|
|
|
+ * */
|
|
|
|
|
+ private int last_index;
|
|
|
|
|
+ private int total_index;
|
|
|
|
|
+ private boolean isLoading = false;//表示是否正处于加载状态
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void onScrollStateChanged(AbsListView view, int scrollState) {
|
|
|
|
|
+ if(last_index == total_index && (scrollState == AbsListView.OnScrollListener.SCROLL_STATE_IDLE))
|
|
|
|
|
+ {
|
|
|
|
|
+ // 表示此时需要显示刷新视图界面进行新数据的加载(要等滑动停止)
|
|
|
|
|
+ if(!isLoading)
|
|
|
|
|
+ {
|
|
|
|
|
+ // 设置刷新界面可见
|
|
|
|
|
+ footer.setVisibility(View.VISIBLE);
|
|
|
|
|
+ loadMore();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
|
|
|
|
|
+ last_index = firstVisibleItem+visibleItemCount;
|
|
|
|
|
+ total_index = totalItemCount;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * Alert/Dialog
|
|
|
|
|
+ * */
|
|
|
|
|
+ private ProgressDialog mProgressDialog;
|
|
|
|
|
+ private void showProgressDialog() {
|
|
|
|
|
+ if (mProgressDialog == null) {
|
|
|
|
|
+ mProgressDialog = new ProgressDialog(mContext);
|
|
|
|
|
+ mProgressDialog.setMessage("loading...");
|
|
|
|
|
+ mProgressDialog.setCancelable(false);
|
|
|
|
|
+ mProgressDialog.show();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private void dismissProgressDialog() {
|
|
|
|
|
+ if (mProgressDialog != null && mProgressDialog.isShowing()) {
|
|
|
|
|
+ mProgressDialog.dismiss();
|
|
|
|
|
+ }
|
|
|
|
|
+ mProgressDialog = null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private void showWarningMsg(String msg) {
|
|
|
|
|
+ if (msg == null || msg.length() == 0) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ new AlertDialog.Builder(mContext).setTitle("Warning")
|
|
|
|
|
+ .setMessage(msg)
|
|
|
|
|
+ .setPositiveButton("Ok",null)
|
|
|
|
|
+ .show();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * Handler
|
|
|
|
|
+ * */
|
|
|
|
|
+ private static final class HomeMoreHandler extends Handler {
|
|
|
|
|
+
|
|
|
|
|
+ static final int HomeActionLoadData = 0;
|
|
|
|
|
+ static final int HomeActionError = 1;
|
|
|
|
|
+
|
|
|
|
|
+ WeakReference<HomeMoreActivity> mWeakHome;
|
|
|
|
|
+
|
|
|
|
|
+ HomeMoreHandler(HomeMoreActivity activity) {
|
|
|
|
|
+ mWeakHome = new WeakReference<>(activity);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void handleMessage(Message msg) {
|
|
|
|
|
+ super.handleMessage(msg);
|
|
|
|
|
+
|
|
|
|
|
+ HomeMoreActivity activity = mWeakHome.get();
|
|
|
|
|
+ activity.dismissProgressDialog();
|
|
|
|
|
+ switch (msg.what) {
|
|
|
|
|
+ case HomeActionLoadData: {
|
|
|
|
|
+
|
|
|
|
|
+ if (activity.mRefresh.isRefreshing()) {
|
|
|
|
|
+ activity.mRefresh.setRefreshing(false);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ activity.mAdapter.notifyDataSetChanged();
|
|
|
|
|
+ }
|
|
|
|
|
+ break;
|
|
|
|
|
+ case HomeActionError: {
|
|
|
|
|
+ String errMsg = (String) msg.obj;
|
|
|
|
|
+ activity.showWarningMsg(errMsg);
|
|
|
|
|
+ }
|
|
|
|
|
+ default:{
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * Load Data
|
|
|
|
|
+ * */
|
|
|
|
|
+ private final int LoadDataOptionInitial = 0;
|
|
|
|
|
+ private final int LoadDataOptionReload = 1;
|
|
|
|
|
+ private final int LoadDataOptionLoadMore = 2;
|
|
|
|
|
+
|
|
|
|
|
+ private void handleJson(JSONObject json, int option) {
|
|
|
|
|
+
|
|
|
|
|
+ if (json == null) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ JSONArray orders = json.optJSONArray("orders");
|
|
|
|
|
+ if (orders != null) {
|
|
|
|
|
+ if (option != LoadDataOptionLoadMore) {
|
|
|
|
|
+ mOrders.clear();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ for (int i = 0; i < orders.length(); i++) {
|
|
|
|
|
+ JSONObject order = orders.optJSONObject(i);
|
|
|
|
|
+ if (order != null) {
|
|
|
|
|
+ HomeOrderModel model = new HomeOrderModel();
|
|
|
|
|
+ model.status = order.optInt("status", 0);
|
|
|
|
|
+ model.title = order.optString("title");
|
|
|
|
|
+ model.orderNo = order.optString("orderNo");
|
|
|
|
|
+ model.containerNo = order.optString("containerNo");
|
|
|
|
|
+ model.date = order.optString("date");
|
|
|
|
|
+ model.orderID = order.optString("orderID");
|
|
|
|
|
+
|
|
|
|
|
+ mOrders.add(model);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ Message msg = new Message();
|
|
|
|
|
+ msg.what = HomeMoreHandler.HomeActionLoadData;
|
|
|
|
|
+ mHandler.sendMessage(msg);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private void loadData(final int option) {
|
|
|
|
|
+
|
|
|
|
|
+ if (isLoading) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ isLoading = true;
|
|
|
|
|
+
|
|
|
|
|
+ final int offset = option == LoadDataOptionLoadMore ? mOrders.size() : 0;
|
|
|
|
|
+
|
|
|
|
|
+ showProgressDialog();
|
|
|
|
|
+ new Thread(new Runnable() {
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void run() {
|
|
|
|
|
+
|
|
|
|
|
+ JSONObject json = com.usai.redant.apexdrivers.Network.Network.requestMoreOrder(mContext,mType,offset,limit);
|
|
|
|
|
+ if (json != null) {
|
|
|
|
|
+ try {
|
|
|
|
|
+
|
|
|
|
|
+ int restul = json.getInt("result");
|
|
|
|
|
+ if (restul == Network.RESULT_TRUE) {
|
|
|
|
|
+
|
|
|
|
|
+ mSelectedModel = null;
|
|
|
|
|
+ handleJson(json,option);
|
|
|
|
|
+
|
|
|
|
|
+ } else {
|
|
|
|
|
+
|
|
|
|
|
+ // error
|
|
|
|
|
+ Message msg = new Message();
|
|
|
|
|
+ msg.what = HomeMoreHandler.HomeActionError;
|
|
|
|
|
+
|
|
|
|
|
+ String errMsg = json.optString("err_msg");
|
|
|
|
|
+ if (errMsg == null || errMsg.length() == 0) {
|
|
|
|
|
+ errMsg = "Sorry,there is something wrong";
|
|
|
|
|
+ }
|
|
|
|
|
+ msg.obj = errMsg;
|
|
|
|
|
+
|
|
|
|
|
+ mHandler.sendMessage(msg);
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ } catch (JSONException e) {
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ // error
|
|
|
|
|
+ Message msg = new Message();
|
|
|
|
|
+ msg.what = HomeMoreHandler.HomeActionError;
|
|
|
|
|
+
|
|
|
|
|
+ String errMsg = "Sorry,there is something wrong";
|
|
|
|
|
+ msg.obj = errMsg;
|
|
|
|
|
+
|
|
|
|
|
+ mHandler.sendMessage(msg);
|
|
|
|
|
+ }
|
|
|
|
|
+ } else {
|
|
|
|
|
+ // error;
|
|
|
|
|
+ Message msg = new Message();
|
|
|
|
|
+ msg.what = HomeMoreHandler.HomeActionError;
|
|
|
|
|
+
|
|
|
|
|
+ String errMsg = "Sorry,there is something wrong";
|
|
|
|
|
+ msg.obj = errMsg;
|
|
|
|
|
+
|
|
|
|
|
+ mHandler.sendMessage(msg);
|
|
|
|
|
+ }
|
|
|
|
|
+ isLoading = false;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }).start();
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private void loadData() {
|
|
|
|
|
+ loadData(LoadDataOptionInitial);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private void reload() {
|
|
|
|
|
+ loadData(LoadDataOptionReload);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private void loadMore() {
|
|
|
|
|
+ loadData(LoadDataOptionLoadMore);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * Adapter
|
|
|
|
|
+ * */
|
|
|
|
|
+ private class HomeMoreListAdapter extends BaseAdapter {
|
|
|
|
|
+
|
|
|
|
|
+ private class OrderCellHolder {
|
|
|
|
|
+
|
|
|
|
|
+ WeakReference<HomeCellLayout> weakCell;
|
|
|
|
|
+
|
|
|
|
|
+ OrderCellHolder(View view) {
|
|
|
|
|
+
|
|
|
|
|
+ view.setTag(this);
|
|
|
|
|
+ weakCell = new WeakReference<>((HomeCellLayout) view);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ void bindOrderModel(HomeOrderModel model) {
|
|
|
|
|
+
|
|
|
|
|
+ if (weakCell != null && weakCell.get() != null) {
|
|
|
|
|
+ weakCell.get().bindOrderModel(model);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public boolean areAllItemsEnabled() {
|
|
|
|
|
+ return super.areAllItemsEnabled();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public boolean isEnabled(int position) {
|
|
|
|
|
+ return super.isEnabled(position);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void registerDataSetObserver(DataSetObserver observer) {
|
|
|
|
|
+ super.registerDataSetObserver(observer);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void unregisterDataSetObserver(DataSetObserver observer) {
|
|
|
|
|
+ super.unregisterDataSetObserver(observer);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public int getCount() {
|
|
|
|
|
+ return mOrders.size();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public Object getItem(int position) {
|
|
|
|
|
+ return mOrders.get(position);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public long getItemId(int position) {
|
|
|
|
|
+ return position;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public boolean hasStableIds() {
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public View getView(int position, View convertView, ViewGroup parent) {
|
|
|
|
|
+ View cell;
|
|
|
|
|
+ OrderCellHolder holder;
|
|
|
|
|
+ if (convertView == null) {
|
|
|
|
|
+
|
|
|
|
|
+ cell = LayoutInflater.from(mContext).inflate(R.layout.home_order_cell,null);
|
|
|
|
|
+ holder = new OrderCellHolder(cell);
|
|
|
|
|
+
|
|
|
|
|
+ } else {
|
|
|
|
|
+
|
|
|
|
|
+ cell = convertView;
|
|
|
|
|
+ holder = (OrderCellHolder)convertView.getTag();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ HomeOrderModel orderModel = mOrders.get(position);
|
|
|
|
|
+
|
|
|
|
|
+ holder.bindOrderModel(orderModel);
|
|
|
|
|
+
|
|
|
|
|
+ return cell;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public int getItemViewType(int position) {
|
|
|
|
|
+ return 0;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public int getViewTypeCount() {
|
|
|
|
|
+ return 1;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public boolean isEmpty() {
|
|
|
|
|
+ return super.isEmpty();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+}
|