Example #1
0
 @Override
 public void handleMessage(Message msg) {
   super.handleMessage(msg);
   switch (msg.what) {
     case 1:
       setmap(urlstr);
       calssAdapter = new CalssAdapter(array, ReplyPhoto.this);
       calss.setAdapter(calssAdapter);
       break;
     case 2:
       Toast.makeText(ReplyPhoto.this, "获取分类失败,请检查网络", Toast.LENGTH_SHORT).show();
       break;
     case 3:
       Toast.makeText(ReplyPhoto.this, "暂无分类", Toast.LENGTH_SHORT).show();
       break;
     case 4:
       dialog.dismiss();
       Toast.makeText(ReplyPhoto.this, "失败", Toast.LENGTH_SHORT).show();
       break;
     case 5:
       dialog.dismiss();
       JSONObject jsonObject = JSON.parseObject(str);
       int a = jsonObject.getIntValue("ret");
       if (a == 200) {
         JSONObject jsonObject1 = jsonObject.getJSONObject("data");
         int b = jsonObject1.getIntValue("code");
         if (b == 0) {
           //                            Bimp.tempSelectBitmap.clear();
           Bimp.tempSelectBitmap.clear();
           Bimp.max = 0;
           Intent intent = new Intent("data.broadcast.action");
           sendBroadcast(intent);
           for (int i = 0; i < PublicWay.activityList.size(); i++) {
             if (null != PublicWay.activityList.get(i)) {
               PublicWay.activityList.get(i).finish();
             }
           }
           //                            finish();
           Intent intent1 = new Intent();
           intent1.setAction("com.servicedemo4");
           intent1.putExtra("getmeeage", "4");
           ReplyPhoto.this.sendBroadcast(intent1);
         } else {
           handlers.sendEmptyMessage(4);
         }
       } else {
         handlers.sendEmptyMessage(4);
       }
       break;
   }
 }
Example #2
0
  public void Init() {

    pop = new PopupWindow(ReplyPhoto.this);

    View view = getLayoutInflater().inflate(R.layout.item_popupwindows, null);

    ll_popup = (LinearLayout) view.findViewById(R.id.ll_popup);

    pop.setWidth(ViewGroup.LayoutParams.MATCH_PARENT);
    pop.setHeight(ViewGroup.LayoutParams.WRAP_CONTENT);
    pop.setBackgroundDrawable(new BitmapDrawable());
    pop.setFocusable(true);
    pop.setOutsideTouchable(true);
    pop.setContentView(view);

    RelativeLayout parent = (RelativeLayout) view.findViewById(R.id.parent);
    Button bt1 = (Button) view.findViewById(R.id.item_popupwindows_camera);
    Button bt2 = (Button) view.findViewById(R.id.item_popupwindows_Photo);
    Button bt3 = (Button) view.findViewById(R.id.item_popupwindows_cancel);
    parent.setOnClickListener(
        new View.OnClickListener() {

          @Override
          public void onClick(View v) {
            // TODO Auto-generated method stub
            pop.dismiss();
            ll_popup.clearAnimation();
          }
        });
    bt1.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View v) {
            photo();
            pop.dismiss();
            ll_popup.clearAnimation();
          }
        });
    bt2.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View v) {
            Intent intent = new Intent(ReplyPhoto.this, AlbumActivity.class);
            startActivity(intent);
            overridePendingTransition(R.anim.activity_translate_in, R.anim.activity_translate_out);
            pop.dismiss();
            ll_popup.clearAnimation();
          }
        });
    bt3.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View v) {
            pop.dismiss();
            ll_popup.clearAnimation();
          }
        });
    content = (EditText) findViewById(R.id.content);
    activity_selectimg_send = (TextView) findViewById(R.id.activity_selectimg_send);
    city = (TextView) findViewById(R.id.city);
    City =
        ((LocationApplication) getApplication()).city
            + " "
            + ((LocationApplication) getApplication()).getStreet;
    city.setText(City);
    back = (ImageView) findViewById(R.id.back);
    calss = (MyGridView) findViewById(R.id.calss);
    noScrollgridview = (MyGridView) findViewById(R.id.noScrollgridview);
    noScrollgridview.setSelector(new ColorDrawable(Color.TRANSPARENT));
    adapter = new GridAdapter(this);
    adapter.update();
    noScrollgridview.setAdapter(adapter);
    city.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            Intent intent = new Intent();
            intent.setClass(ReplyPhoto.this, CityList.class);
            ReplyPhoto.this.startActivity(intent);
          }
        });
    activity_selectimg_send.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            contents = content.getText().toString();
            if (contents.length() == 0) {
              Toast.makeText(ReplyPhoto.this, "请输入内容", Toast.LENGTH_SHORT).show();
            } else if (classid == null) {
              Toast.makeText(ReplyPhoto.this, "请选择标签", Toast.LENGTH_SHORT).show();
            } else if (Bimp.tempSelectBitmap.size() == 0) {
              Toast.makeText(ReplyPhoto.this, "请至少选择一张图片", Toast.LENGTH_SHORT).show();
            } else {
              getclass(1);
              dialog.show();
            }
          }
        });
    calss.setOnItemClickListener(
        new AdapterView.OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            classid = array.get(position).get("id");
            myguigearray.clear();
            for (int i = 0; i < array.size(); i++) {
              hashMap = new HashMap<String, String>();
              hashMap.put("id", array.get(i).get("id"));
              hashMap.put("title", array.get(i).get("title"));
              hashMap.put("path", array.get(i).get("path"));
              hashMap.put("select", array.get(i).get("select"));
              myguigearray.add(hashMap);
            }
            array.clear();
            for (int i = 0; i < myguigearray.size(); i++) {
              hashMap = new HashMap<String, String>();
              hashMap.put("id", myguigearray.get(i).get("id"));
              hashMap.put("title", myguigearray.get(i).get("title"));
              hashMap.put("path", myguigearray.get(i).get("path"));
              if (i == position) {
                hashMap.put("select", "1");
              } else {
                hashMap.put("select", "0");
              }
              array.add(hashMap);
            }
            calssAdapter.notifyDataSetChanged();
          }
        });
    back.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            finish();
          }
        });
    noScrollgridview.setOnItemClickListener(
        new AdapterView.OnItemClickListener() {

          public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
            if (arg2 == Bimp.tempSelectBitmap.size()) {
              Log.i("ddddddd", "----------");
              ll_popup.startAnimation(
                  AnimationUtils.loadAnimation(ReplyPhoto.this, R.anim.activity_translate_in));
              pop.showAtLocation(parentView, Gravity.BOTTOM, 0, 0);
            } else {
              Intent intent = new Intent(ReplyPhoto.this, GalleryActivity.class);
              intent.putExtra("position", "1");
              intent.putExtra("ID", arg2);
              startActivity(intent);
            }
          }
        });
  }