博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
灭霸—个人冲刺(7)
阅读量:5337 次
发布时间:2019-06-15

本文共 8563 字,大约阅读时间需要 28 分钟。

灵魂三问:昨天做了什么? 1.页面的信息罗列 6h 目标任务量:100%  完成任务量:37.5%

                  今天要做什么?1.页面的信息罗列 10h

                  遇到困难没有?由于数据量过大,加载时间太长。解决办法:分批读取

昨日内容展示:

package com.weicent.android.csma.ui.list;import android.content.Intent;import android.graphics.Color;import android.os.Bundle;import android.view.View;import android.widget.AdapterView;import android.widget.GridView;import android.widget.LinearLayout;import android.widget.RelativeLayout;import android.widget.TextView;import com.ab.activity.AbActivity;import com.ab.view.pullview.AbPullToRefreshView;import com.ab.view.titlebar.AbTitleBar;import com.weicent.android.csma.App;import com.weicent.android.csma.R;import com.weicent.android.csma.adapter.result.CommodityAdapter;import com.weicent.android.csma.data.Global;import com.weicent.android.csma.data.NetWorkWeb;import com.weicent.android.csma.data.ResultHandlerForJson;import com.weicent.android.csma.data.model.result.Category;import com.weicent.android.csma.data.request.model.ReqCommodity;import com.weicent.android.csma.data.result.list.ResCommodityList;import com.weicent.android.csma.support.CreateJsonTool;import com.weicent.android.csma.support.T;import com.weicent.android.csma.ui.IBinDing;import com.weicent.android.csma.ui.detail.CommodityDetailActivity;import org.apache.http.Header;import butterknife.Bind;import butterknife.ButterKnife;/** * Commodity列表 */public class CommodityListActivity extends AbActivity implements IBinDing, AbPullToRefreshView.OnHeaderRefreshListener        , AbPullToRefreshView.OnFooterLoadListener {    @Bind(R.id.layoutLoading)    RelativeLayout layoutLoading;    @Bind(R.id.layoutMsg)    RelativeLayout layoutMsg;    @Bind(R.id.textMsg)    TextView textMsg;    @Bind(R.id.layoutContext)    LinearLayout layoutContext;    @Bind(R.id.gridView)    GridView gridView;    @Bind(R.id.abPullToRefreshView)    AbPullToRefreshView abPullToRefreshView;    private CommodityAdapter adapter = null;//数据适配器    private int currentPage = 1;//当前页    private int total = 0;//页总数    private int pageSize = 5;//页大小    private AbTitleBar abTitleBar = null;    private Category model;    @Override    protected void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        setAbContentView(R.layout.activity_commodity_list);        ButterKnife.bind(this);        initView();    }    @Override    public void initView() {        model = getIntent().getParcelableExtra(App.MODEL_NAME);        abTitleBar = this.getTitleBar();        abTitleBar.setTitleText(model.categoryName);        abTitleBar.setLogo(R.drawable.button_selector_back);        abTitleBar.setTitleBarBackgroundColor(Color.parseColor("#FC5720"));        abTitleBar.setTitleTextMargin(10, 0, 0, 0);        abTitleBar.setLogoLine(R.drawable.line);        layoutMsg.setOnClickListener(new View.OnClickListener() {            @Override            public void onClick(View v) {                initData();            }        });        abPullToRefreshView.setOnHeaderRefreshListener(this);        abPullToRefreshView.setOnFooterLoadListener(this);        abPullToRefreshView.getHeaderView().setHeaderProgressBarDrawable(this.getResources().getDrawable(R.drawable.progress_circular));        abPullToRefreshView.getFooterView().setFooterProgressBarDrawable(this.getResources().getDrawable(R.drawable.progress_circular));        adapter = new CommodityAdapter(this, null);        gridView.setAdapter(adapter);        gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {            @Override            public void onItemClick(AdapterView
parent, View view, int position, long id) { if (position >= 0 && position < adapter.getCount()) { startActivity(new Intent(CommodityListActivity.this, CommodityDetailActivity.class).putExtra(App.MODEL_NAME, adapter.getItem(position))); } } }); initData(); } @Override public void initData() { layoutContext.setVisibility(View.GONE); layoutLoading.setVisibility(View.VISIBLE); layoutMsg.setVisibility(View.GONE); onHeaderRefresh(null); } @Override public void onHeaderRefresh(AbPullToRefreshView view) { ReqCommodity reqCommodity = new ReqCommodity(); reqCommodity.data.setCategoryID(model.id); reqCommodity.paging = true; reqCommodity.page_no = 1; reqCommodity.page_size = pageSize; NetWorkWeb.getInstance().doRequest(Global.URL_COMMODITY_SERVLET, new ResultHandlerForJson
(ResCommodityList.class) { @Override public void onSuccess(int statusCode, Header[] headers, ResCommodityList resultJson) { if (resultJson.errorcode == 0) { NetWorkWeb.getInstance().doLogResultDataString("CommodityServlet first", resultJson.data); if (adapter != null) adapter.update(resultJson.data); total = resultJson.total; if (resultJson.data.size() > 0) { //显示内容 layoutMsg.setVisibility(View.GONE); layoutContext.setVisibility(View.VISIBLE); } else { //显示重试 textMsg.setText("暂无数据,请点击屏幕重试"); layoutMsg.setVisibility(View.VISIBLE); layoutContext.setVisibility(View.GONE); } } else { //显示重试 textMsg.setText("请求出错,请点击屏幕重试"); layoutMsg.setVisibility(View.VISIBLE); layoutContext.setVisibility(View.GONE); } } @Override public void onFailure(int statusCode, Header[] headers, String resultString, Throwable throwable) { if (adapter.isEmpty()) { textMsg.setText("请求出错,请点击屏幕重试"); layoutMsg.setVisibility(View.VISIBLE); layoutContext.setVisibility(View.GONE); } else { T.showShort(CommodityListActivity.this, App.NET_OUT_MSG); } } @Override public void onFinish() { currentPage = 1; abPullToRefreshView.onHeaderRefreshFinish(); layoutLoading.setVisibility(View.GONE); } }, CreateJsonTool.createJsonString(reqCommodity), 7); } @Override public void onFooterLoad(AbPullToRefreshView view) { ReqCommodity reqCommodity = new ReqCommodity(); reqCommodity.data.setCategoryID(model.id); reqCommodity.paging = true; reqCommodity.page_no = currentPage; reqCommodity.page_size = pageSize; if (adapter.getCount() >= total) { abPullToRefreshView.onFooterLoadFinish(); T.showShort(CommodityListActivity.this, App.NOT_DATA_MSG); } else { currentPage++; NetWorkWeb.getInstance().doRequest(Global.URL_COMMODITY_SERVLET, new ResultHandlerForJson
(ResCommodityList.class) { @Override public void onSuccess(int statusCode, Header[] headers, ResCommodityList resultJson) { if (resultJson.errorcode == 0) { NetWorkWeb.getInstance().doLogResultDataString("CommodityServlet more", resultJson.data); if (adapter != null) adapter.addAll(resultJson.data); } else { currentPage--; T.showShort(CommodityListActivity.this, App.NET_OUT_MSG); } } @Override public void onFailure(int statusCode, Header[] headers, String resultString, Throwable throwable) { currentPage--; T.showShort(CommodityListActivity.this, App.NET_OUT_MSG); } @Override public void onFinish() { abPullToRefreshView.onFooterLoadFinish(); } }, CreateJsonTool.createJsonString(reqCommodity), 7); } } @Override protected void onDestroy() { super.onDestroy(); if (NetWorkWeb.getInstance().getHttpClient() == null) {// AbLogUtil.d("cancelAllRequests", " is null"); return; } else { NetWorkWeb.getInstance().getHttpClient().cancelAllRequests(true);//关闭所有请求// AbLogUtil.d("cancelAllRequests"," is ok"); } }}

 

转载于:https://www.cnblogs.com/quxiangjia/p/10800293.html

你可能感兴趣的文章
PAT 1038. Recover the Smallest Number
查看>>
解决can't connect to redis-server
查看>>
【MINA】OrderedThreadPoolExecutor和UnorderedThreadPoolExecutor的事件监听线程池的选择
查看>>
限制图片目录有文件的执行权限
查看>>
OSChina中远程GIT仓库同步探索
查看>>
(转载)国内国外最好的java开发论坛及站点
查看>>
[LeetCode] 502. IPO 上市
查看>>
取整函数
查看>>
调试exynos4412—ARM嵌入式Linux—LEDS/GPIO驱动之三
查看>>
Static了解和复习继承。
查看>>
cocos2dx - 制作纵版射击游戏:喵星战争 (五)
查看>>
一. python基础
查看>>
字符流
查看>>
文本处理三剑客之gawk
查看>>
测试与代码质量
查看>>
Eclipse Access Restriction
查看>>
行间距
查看>>
20145305 《网络对抗》Web基础
查看>>
GDB调试器使用总结
查看>>
linux 常用命令
查看>>