Google電子市場3--應用,Google電子市場3--

來源:互聯網
上載者:User

Google電子市場3--應用,Google電子市場3--

 

public class AppFragment extends BaseFragment {    ArrayList<AppInfo> mList = null;    @Override    public View onCreateSuccessView() {        MyListView view = new MyListView(UIUtils.getContext());        view.setAdapter(new AppAdapter(mList));        return view;    }    @Override    public ResultState onLoad() {        AppProtocol protocol = new AppProtocol();        mList = protocol.getData(0);        return check(mList);    }    class AppAdapter extends MyBaseAdapter<AppInfo> {        public AppAdapter(ArrayList<AppInfo> list) {            super(list);        }        @Override        public BaseHolder<AppInfo> getHolder(int position) {            return new AppHolder();        }        @Override        public ArrayList<AppInfo> onLoadMore() {            AppProtocol protocol = new AppProtocol();            ArrayList<AppInfo> moreData = protocol.getData(getListSize());            return moreData;        }    }}--------------------------------------/** * 應用頁訪問網路 *  * @author Kevin *  */public class AppProtocol extends BaseProtocol<ArrayList<AppInfo>> {    private ArrayList<AppInfo> mAppList;// 應用列表集合    @Override    public String getKey() {        return "app";    }    @Override    public String getParams() {        return "";    }    @Override    public ArrayList<AppInfo> parseJson(String result) {        try {            JSONArray ja = new JSONArray(result);            mAppList = new ArrayList<AppInfo>();            for (int i = 0; i < ja.length(); i++) {                AppInfo info = new AppInfo();                JSONObject jo1 = (JSONObject) ja.get(i);                info.des = jo1.getString("des");                info.downloadUrl = jo1.getString("downloadUrl");                info.iconUrl = jo1.getString("iconUrl");                info.id = jo1.getString("id");                info.name = jo1.getString("name");                info.packageName = jo1.getString("packageName");                info.size = jo1.getLong("size");                info.stars = jo1.getDouble("stars");                mAppList.add(info);            }            return mAppList;        } catch (Exception e) {            e.printStackTrace();        }        return null;    }}-----------------------------------/** * 應用頁holder *  * @author Kevin *  */public class AppHolder extends BaseHolder<AppInfo> {    private TextView tvName;    private ImageView ivIcon;    private TextView tvSize;    private TextView tvDesc;    private RatingBar rbStar;    private BitmapUtils mBitmapUtils;    @Override    public View initView() {        View view = View.inflate(UIUtils.getContext(), R.layout.list_item_home,                null);        tvName = (TextView) view.findViewById(R.id.tv_name);        ivIcon = (ImageView) view.findViewById(R.id.iv_icon);        tvSize = (TextView) view.findViewById(R.id.tv_size);        tvDesc = (TextView) view.findViewById(R.id.tv_desc);        rbStar = (RatingBar) view.findViewById(R.id.rb_star);        mBitmapUtils = BitmapHelper.getBitmapUtils();        mBitmapUtils.configDefaultLoadingImage(R.drawable.ic_default);        return view;    }    @Override    public void refreshView(AppInfo data) {        if (data != null) {            tvName.setText(data.name);            tvSize.setText(Formatter.formatFileSize(UIUtils.getContext(),                    data.size));            tvDesc.setText(data.des);            rbStar.setRating((float) data.stars);            mBitmapUtils.display(ivIcon, HttpHelper.URL + "image?name="                    + data.iconUrl);        }    }}

  

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.