这大概是什么意思?

longtime
  • 9
12-28 02:56:29.954 1336-1336/? E/EGL_emulation: tid 1336: eglCreateSyncKHR(1881): error 0x3004 (EGL_BAD_ATTRIBUTE)

12-28 02:56:42.774 3081-5020/com.google.android.gms.unstable E/DG: FSC error

                                                               java.net.SocketTimeoutException: connect timed out
                                                                   at java.net.PlainSocketImpl.socketConnect(Native Method)
                                                                   at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:334)
                                                                   at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:196)
                                                                   at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:178)
                                                                   at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:356)
                                                                   at java.net.Socket.connect(Socket.java:605)
                                                                   at com.android.okhttp.internal.Platform.connectSocket(Platform.java:113)
                                                                   at com.android.okhttp.Connection.connectSocket(Connection.java:196)
                                                                   at com.android.okhttp.Connection.connect(Connection.java:172)
                                                                   at com.android.okhttp.Connection.connectAndSetOwner(Connection.java:367)
                                                                   at com.android.okhttp.OkHttpClient$1.connectAndSetOwner(OkHttpClient.java:130)
                                                                   at com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:329)
                                                                   at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:246)
                                                                   at com.android.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:457)
                                                                   at com.android.okhttp.internal.huc.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:126)
                                                                   at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getOutputStream(HttpURLConnectionImpl.java:257)
                                                                   at com.android.okhttp.internal.huc.DelegatingHttpsURLConnection.getOutputStream(DelegatingHttpsURLConnection.java:218)
                                                                   at com.android.okhttp.internal.huc.HttpsURLConnectionImpl.getOutputStream(HttpsURLConnectionImpl.java)
                                                                   at phy.a(:com.google.android.gms@11509470:20)
                                                                   at phy.a(:com.google.android.gms@11509470:4)
                                                                   at pju.a(:com.google.android.gms@11509470:4)
                                                                   at com.google.android.gms.droidguard.DroidGuardChimeraService.onHandleIntent(:com.google.android.gms@11509470:21)
                                                                   at btz.handleMessage(:com.google.android.gms@11509470)
                                                                   at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                   at android.os.Looper.loop(Looper.java:154)
                                                                   at android.os.HandlerThread.run(HandlerThread.java:61)

图片描述

图片描述

斜体文字
当我操作这加入购物车后再按旁边的购物车是空白的

具体代码

、、、Android

public class ShoppingCartActivity extends Activity {
private TextView tvShopcartEdit;
private RecyclerView recyclerview;
private LinearLayout llCheckAll;
private CheckBox checkboxAll;
private TextView tvShopcartTotal;
private Button btnCheckOut;
private LinearLayout llDelete;
private CheckBox cbAll;
private Button btnDelete;
private Button btnCollection;
private ImageView ivEmpty;
private TextView tvEmptyCartTobuy;
private LinearLayout ll_empty_shopcart;

/**
 * 编辑状态
 */
private static final int ACTION_EDIT = 0;

/**
 * 完成状态
 */
private static final int ACTION_COMPLETE = 1;
private ShopCartAdapter adapter;
public Context mContext;
private void findViews(View view) {
    tvShopcartEdit = (TextView) view.findViewById(R.id.tv_shopcart_edit);
    recyclerview = (RecyclerView) view.findViewById(R.id.recyclerview);
    llCheckAll = (LinearLayout) view.findViewById(R.id.ll_check_all);
    checkboxAll = (CheckBox) view.findViewById(R.id.checkbox_all);
    tvShopcartTotal = (TextView) view.findViewById(R.id.tv_shopcart_total);
    btnCheckOut = (Button) view.findViewById(R.id.btn_check_out);
    llDelete = (LinearLayout) view.findViewById(R.id.ll_delete);
    cbAll = (CheckBox) view.findViewById(R.id.cb_all);
    btnDelete = (Button) view.findViewById(R.id.btn_delete);
    btnCollection = (Button) view.findViewById(R.id.btn_collection);
    ivEmpty = (ImageView) view.findViewById(R.id.iv_empty);
    tvEmptyCartTobuy = (TextView) view.findViewById(R.id.tv_empty_cart_tobuy);
    ll_empty_shopcart = (LinearLayout) view.findViewById(R.id.ll_empty_shopcart);
    tvEmptyCartTobuy.setClickable(true);

}

@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mContext= ShoppingCartActivity.this;
    View view = View.inflate(mContext, R.layout.frgment_shoppingcart, null);
    findViews(view);
    initData();



}



private void initData() {
    initListener();
    tvShopcartEdit.setTag(ACTION_EDIT);
    tvShopcartEdit.setText("编辑");
    llCheckAll.setVisibility(View.VISIBLE);
    showData();

}

@Override
public void onResume() {

    super.onResume();
    showData();
}

private void initListener() {

    btnCheckOut.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            // pay(v);
        }
    });
    tvShopcartEdit.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            //设置编辑的点击事件
            int tag = (int) tvShopcartEdit.getTag();
            if (tag == ACTION_EDIT) {
                //变成完成状态
                showDelete();
            } else {
                //变成编辑状态
                hideDelete();
            }
        }
    });
    btnDelete.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            adapter.deleteData();
            adapter.showTotalPrice();
            //显示空空如也
            checkData();
            adapter.checkAll();
        }
    });
    tvEmptyCartTobuy.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent intent = new Intent(mContext, MainActivity.class);
            startActivity(intent);
            Constants.isBackHome = true;
        }
    });
}

private void hideDelete() {
    tvShopcartEdit.setText("编辑");
    tvShopcartEdit.setTag(ACTION_EDIT);
    adapter.checkAll_none(true);
    llDelete.setVisibility(View.GONE);
    llCheckAll.setVisibility(View.VISIBLE);
    adapter.showTotalPrice();
}


private void showDelete() {
    tvShopcartEdit.setText("完成");
    tvShopcartEdit.setTag(ACTION_COMPLETE);
    adapter.checkAll_none(false);
    cbAll.setChecked(false);
    checkboxAll.setChecked(false);
    llDelete.setVisibility(View.VISIBLE);
    llCheckAll.setVisibility(View.GONE);
    adapter.showTotalPrice();
}

private void checkData() {
    if (adapter != null && adapter.getItemCount() > 0) {
        tvShopcartEdit.setVisibility(View.VISIBLE);
        ll_empty_shopcart.setVisibility(View.GONE);
    } else {
        ll_empty_shopcart.setVisibility(View.VISIBLE);
        tvShopcartEdit.setVisibility(View.GONE);
    }
}

private void showData() {
    CartProvider cartProvider = CartProvider.getInstance();
    List<GoodsBean> datas = cartProvider.getDataFromLocal();
    if (datas != null && datas.size() > 0) {
        tvShopcartEdit.setVisibility(View.VISIBLE);
        adapter = new ShopCartAdapter(mContext, datas, tvShopcartTotal, cartProvider, checkboxAll, cbAll);
        recyclerview.setLayoutManager(new LinearLayoutManager(mContext));
        recyclerview.setAdapter(adapter);
        ll_empty_shopcart.setVisibility(View.GONE);
        llDelete.setVisibility(View.GONE);
        llCheckAll.setVisibility(View.GONE);
        tvShopcartEdit.setText("编辑");
        tvShopcartEdit.setTag(ACTION_EDIT);
    } else {
        //显示空的
        tvShopcartEdit.setVisibility(View.GONE);
        ll_empty_shopcart.setVisibility(View.VISIBLE);
        tvShopcartEdit.setVisibility(View.GONE);
        llDelete.setVisibility(View.GONE);
    }
}

}
上面这个是点购物车按钮要跳转的
、、、
下面这个是有关那个加入购物车按钮的代码

package com.weather.com.welcomeactivity.app;

import android.app.Activity;

import android.content.Context;
import android.content.Intent;

import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;

import android.support.v7.widget.RecyclerView;

import android.util.Log;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.WindowManager;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.PopupWindow;
import android.widget.TextView;
import android.widget.Toast;

import com.bumptech.glide.Glide;
import com.weather.com.welcomeactivity.R;

import com.weather.com.welcomeactivity.home.bean.GoodsBean;

import com.weather.com.welcomeactivity.shoppingcart.activity.ShoppingCartActivity;
import com.weather.com.welcomeactivity.shoppingcart.utils.CartProvider;
import com.weather.com.welcomeactivity.shoppingcart.view.NumberAddSubView;
import com.weather.com.welcomeactivity.utils.Constants;

import java.util.List;

/**

  • 商品信息列表

*/

public class GoodsInfoActivity extends Activity implements View.OnClickListener {

private ImageButton ibGoodInfoBack;
private ImageButton ibGoodInfoMore;
private ImageView ivGoodInfoImage;
private TextView tvGoodInfoName;
private TextView tvGoodInfoDesc;
private TextView tvGoodInfoPrice;
private TextView tvGoodInfoStore;
private TextView tvGoodInfoStyle;
private WebView wbGoodInfoMore;
private LinearLayout llGoodsroot;
private TextView tvGoodInfoCallcenter;
private TextView tvGoodInfoCollection;
private TextView tvGoodInfoCart;
private Button btnGoodInfoAddcart;


private TextView tvMoreShare;
private TextView tvMoreSearch;
private TextView tvMoreHome;
private LinearLayout ll_root;
private Button btn_more;
private CartProvider cartProvider;
//private Boolean isFirst =true;

/*//模拟商家的数组
private String[] sellers =new String[]{"尚硅谷","画影工作室","Wacom"};
private List<GoodsList>goodsLists;
private GoodsList goodsList;
 */
private GoodsBean goods_bean;
private List<GoodsBean> goodsBeans;
private ImageView ivPopImg;
private TextView tvPopInfo;
private NumberAddSubView numberAddSubView;
private Button btnCancel;
private Button btnComfirm;
private TextView tvPopPrice;

private void findViews() {

    ibGoodInfoBack = (ImageButton) findViewById(R.id.ib_good_info_back);
    ibGoodInfoMore = (ImageButton) findViewById(R.id.ib_good_info_more);
    ivGoodInfoImage = (ImageView) findViewById(R.id.iv_good_info_image);
    tvGoodInfoName = (TextView) findViewById(R.id.tv_good_info_name);
    tvGoodInfoDesc = (TextView) findViewById(R.id.tv_good_info_desc);
    tvGoodInfoPrice = (TextView) findViewById(R.id.tv_good_info_price);
    tvGoodInfoStore = (TextView) findViewById(R.id.tv_good_info_store);
    tvGoodInfoStyle = (TextView) findViewById(R.id.tv_good_info_style);
    wbGoodInfoMore = (WebView) findViewById(R.id.wb_good_info_more);
    llGoodsroot = (LinearLayout) findViewById(R.id.ll_goods_root);
    tvGoodInfoCallcenter = (TextView) findViewById(R.id.tv_good_info_callcenter);
    tvGoodInfoCollection = (TextView) findViewById(R.id.tv_good_info_collection);
    tvGoodInfoCart = (TextView) findViewById(R.id.tv_good_info_cart);
    btnGoodInfoAddcart = (Button) findViewById(R.id.btn_good_info_addcart);
    ll_root = (LinearLayout) findViewById(R.id.ll_root);
    tvMoreShare = (TextView) findViewById(R.id.tv_more_share);
    tvMoreSearch = (TextView) findViewById(R.id.tv_more_search);
    tvMoreHome = (TextView) findViewById(R.id.tv_more_home);
    btn_more = (Button) findViewById(R.id.btn_more);


    btn_more.setOnClickListener(this);

    ibGoodInfoBack.setOnClickListener(this);
    ibGoodInfoMore.setOnClickListener(this);


    tvMoreShare.setOnClickListener(this);
    tvMoreSearch.setOnClickListener(this);
    tvMoreHome.setOnClickListener(this);
    tvGoodInfoCallcenter.setOnClickListener(this);
    tvGoodInfoCollection.setOnClickListener(this);
    tvGoodInfoCart.setOnClickListener(this);
    btnGoodInfoAddcart.setOnClickListener(this);
    tvGoodInfoCallcenter.setOnClickListener(this);
}


@Override
public void onClick(View v) {
    if (v.getId() == R.id.ib_good_info_back) {
        finish();
    } else if (v.getId() == R.id.ib_good_info_more) {
        if (ll_root.getVisibility() == View.VISIBLE) {
            ll_root.setVisibility(View.GONE);
        } else {
            ll_root.setVisibility(View.VISIBLE);
        }
    } else if (v.getId() == R.id.btn_more) {
        ll_root.setVisibility(View.GONE);
    } else if (v.getId() == R.id.tv_more_share) {
        Toast.makeText(GoodsInfoActivity.this, "分享", Toast.LENGTH_SHORT).show();
        // showShare();
    } else if (v.getId() == R.id.tv_more_search) {
        Toast.makeText(GoodsInfoActivity.this, "搜索", Toast.LENGTH_SHORT).show();
    } else if (v.getId() == R.id.tv_more_home) {
        Constants.isBackHome = true;
        finish();
    } else if (v.getId() == R.id.tv_good_info_callcenter) {
        Toast.makeText(GoodsInfoActivity.this, "客服", Toast.LENGTH_SHORT).show();

// Intent intent = new Intent(this,CallCenterActivity.class);
// startActivity(intent);

    } else if (v.getId() == R.id.tv_good_info_collection) {
        Toast.makeText(GoodsInfoActivity.this, "收藏", Toast.LENGTH_SHORT).show();
    } else if (v.getId() == R.id.tv_good_info_cart) {


        Toast.makeText(GoodsInfoActivity.this, "购物车", Toast.LENGTH_SHORT).show();
        Intent intent = new Intent(this, ShoppingCartActivity.class);
        startActivity(intent);
    } else if (v.getId() == R.id.btn_good_info_addcart) {
        //添加购物车

// cartProvider.addData(goods_bean);

        cartProvider = CartProvider.getInstance();
        showPopwindow();

// Toast.makeText(GoodsInfoActivity.this, "添加购物车成功", Toast.LENGTH_SHORT).show();

    }
}

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_goods_info);

    findViews();


    //取出 intent
    Intent intent = getIntent();
    goods_bean = (GoodsBean) intent.getSerializableExtra("goods_bean");
    if (goods_bean != null) {
        //本地获取存储的数据
        setDataFormView(goods_bean);
    }
}


private void setWebView(String product_id) {
    if (product_id != null) {

//http://192.168.51.104:8080/atguigu/json/GOODSINFO_URL.json2691 //wbGoodInfoMore.loadUrl(Constants.GOODSINFO_URL + product_id);

        wbGoodInfoMore.loadUrl("http://www.jd.com");
        //覆盖 WebView 默认使用第三方或系统默认浏览器打开网页的行为,使网页用 WebView 打开
        wbGoodInfoMore.setWebViewClient(new WebViewClient() {
            @Override
            public boolean shouldOverrideUrlLoading(WebView view, String url) {
                //返回值是 true 的时候控制去 WebView 打开,为 false 调用
                //系统浏览器或第三方浏览器
                view.loadUrl(url);
                return true;
            }
        });
        //启用支持 javascript
        WebSettings settings = wbGoodInfoMore.getSettings();
        settings.setJavaScriptEnabled(true);
        settings.setUseWideViewPort(true);

        //优先使用缓存

        wbGoodInfoMore.getSettings().setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
    }
}

public void setDataFormView(GoodsBean goodsBean) {
    String name = goodsBean.getName();
    String cover_price = goodsBean.getCover_price();
    String figure = goodsBean.getFigure();
    String product_id = goodsBean.getProduct_id();
    Glide.with(this).load(Constants.Base_URl_IMAGE + figure).into(ivGoodInfoImage);
    if (name != null) {
        tvGoodInfoName.setText(name);
    }
    if (cover_price != null) {

        tvGoodInfoPrice.setText("¥" + cover_price);
    }
    setWebView(product_id);
}

public void showPopwindow() {
    LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View view = inflater.inflate(R.layout.popwindow_add_product, null);

    final PopupWindow window = new PopupWindow(view,
            WindowManager.LayoutParams.MATCH_PARENT,
            WindowManager.LayoutParams.WRAP_CONTENT);
    window.setFocusable(true);
    window.setTouchable(true);
    window.setOutsideTouchable(true);
    window.setBackgroundDrawable(new ColorDrawable());

    window.showAtLocation(view, Gravity.BOTTOM, 0, 0);

    ViewHolder holder = new ViewHolder(view);
    holder.setData(goods_bean, window);

}

class ViewHolder extends RecyclerView.ViewHolder {
    private Context mContext;

    public ViewHolder(View view) {
        super(view);
        ivPopImg = (ImageView) view.findViewById(R.id.iv_pop_img);
        tvPopInfo = (TextView) view.findViewById(R.id.tv_pop_info);
        numberAddSubView = (NumberAddSubView) view.findViewById(R.id.number_add_sub_view);
        btnCancel = (Button) view.findViewById(R.id.btn_cancel);
        btnComfirm = (Button) view.findViewById(R.id.btn_comfirm);
        tvPopPrice = (TextView) view.findViewById(R.id.tv_pop_price);
        //查百度查到的,很开心。mContext可以用了^-^。还是中文容易懂。
        mContext = view.getContext();
    }


    public void setData(final GoodsBean goodsBean, final PopupWindow window) {

        Glide.with(mContext).load(Constants.Base_URl_IMAGE + goodsBean.getFigure()).into(ivPopImg);
        tvPopInfo.setText(goodsBean.getName());
        tvPopPrice.setText("¥" + goodsBean.getCover_price());

        numberAddSubView.setValue(goodsBean.getNumber());

        numberAddSubView.setOnNumberChangeListener(new NumberAddSubView.OnNumberChangeListener() {
            @Override
            public void addNumber(View view, int value) {
                goodsBean.setNumber(value);
            }

            @Override
            public void subNumber(View view, int value) {
                goodsBean.setNumber(value);
            }
        });

        btnComfirm.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                cartProvider.addData(goodsBean);
                Log.e("TAG", "onClick111 ");
                window.dismiss();
                Toast.makeText(GoodsInfoActivity.this, "加入购物车", Toast.LENGTH_SHORT).show();
            }
        });

        btnCancel.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Log.e("TAG", "onClick222 ");
                window.dismiss();
                Toast.makeText(GoodsInfoActivity.this, "取消加入购物车", Toast.LENGTH_SHORT).show();
            }
        });


    }
}

}

回复
阅读 3.7k
1 个回答
宣传栏