public void gridviewInit() {
    GridAdapter adapter = new GridAdapter(this);
    adapter.setSelectedPosition(0);
    int size = 0;
    if (bmp.size() < 6) {
      size = bmp.size() + 1;
    } else {
      size = bmp.size();
    }
    GridView gridview = (GridView) findViewById(R.id.onlinedebug_showrecord_gridview);
    LayoutParams params = gridview.getLayoutParams();
    final int width = size * (int) (20 * 9.4f);
    params.width = width;
    gridview.setLayoutParams(params);
    gridview.setColumnWidth((int) (20 * 9.4f));
    gridview.setStretchMode(GridView.NO_STRETCH);
    gridview.setNumColumns(size);
    gridview.setAdapter(adapter);
    gridview.setOnItemClickListener(this);

    final HorizontalScrollView hsvSelectImg =
        (HorizontalScrollView) findViewById(R.id.onlinedebug_showrecord_horizontalscrollview);
    hsvSelectImg
        .getViewTreeObserver()
        .addOnPreDrawListener(
            new OnPreDrawListener() {
              public boolean onPreDraw() {
                hsvSelectImg.scrollTo(width, 0);
                hsvSelectImg.getViewTreeObserver().removeOnPreDrawListener(this);
                return false;
              }
            });
  }
  private void refreshMembers() {
    adapter.clear();

    List<String> members = new ArrayList<String>();
    members.addAll(group.getMembers());
    adapter.addAll(members);

    adapter.notifyDataSetChanged();
  }
Esempio n. 3
0
  private void showResult(ArrayList<String> paths) {
    if (mResults == null) {
      mResults = new ArrayList<String>();
    }
    mResults.clear();
    mResults.addAll(paths);

    try {
      JSONArray obj = new JSONArray(mResults);
      Log.e("--", obj.toString());
    } catch (Exception e) {
      e.printStackTrace();
    }

    if (mAdapter == null) {
      mAdapter = new GridAdapter(mResults);
      mGrideView.setAdapter(mAdapter);
    } else {
      mAdapter.notifyDataSetChanged();
    }
  }
Esempio n. 4
0
  public void Init() {
    noScrollgridview = (GridView) findViewById(R.id.noScrollgridview);
    noScrollgridview.setSelector(new ColorDrawable(Color.TRANSPARENT));
    adapter = new GridAdapter(this);
    adapter.update();
    noScrollgridview.setAdapter(adapter);
    noScrollgridview.setOnItemClickListener(
        new OnItemClickListener() {

          public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
            if (arg2 == Bimp.bmp.size()) {
              new PopupWindows(PublishedActivity.this, noScrollgridview);
            } else {
              Intent intent = new Intent(PublishedActivity.this, PhotoActivity.class);
              intent.putExtra("ID", arg2);
              startActivity(intent);
            }
          }
        });
    activity_selectimg_send = (TextView) findViewById(R.id.activity_selectimg_send);
    activity_selectimg_send.setOnClickListener(
        new OnClickListener() {

          public void onClick(View v) {
            Log.d("TCP", "onClick");
            for (int i = 0; i < Bimp.drr.size(); i++) {
              String Str = Bimp.drr.get(i).toString();
              Log.d("list", Str); // 文件绝对路径
              Intent serviceIntent =
                  new Intent(PublishedActivity.this, FileTransferService.class); // 注册客户端传文件的意图
              serviceIntent.setAction(FileTransferService.ACTION_SEND_FILE);
              serviceIntent.putExtra(FileTransferService.EXTRAS_FILE_PATH, Str);
              serviceIntent.putExtra(FileTransferService.EXTRAS_GROUP_OWNER_ADDRESS, adress);
              serviceIntent.putExtra(FileTransferService.EXTRAS_GROUP_OWNER_PORT, 8988);
              PublishedActivity.this.startService(serviceIntent);
              // 可以加临界区
              //					Intent data=new Intent();
              //					data.setData(Uri.fromFile(new File(Bimp.drr.get(i))));
              //					setResult(i, data);
            }
            //				Intent intent = new Intent();
            //				ArrayList list = new ArrayList();//这个arraylist是可以直接在bundle里传的,所以我们可以借用一下它的功能
            //				list.add(Bimp.drr);//这个list2才是你真正想要传过去的list。我们把它放在arraylis中,借助它传过去
            //				intent.putStringArrayListExtra("list", list);
            //				setResult(RESULT_OK,intent);
            //				finish();
            //				AlertDialog.Builder builder=new AlertDialog.Builder(PublishedActivity.this);//this
            // 出错
            //				builder.setTitle("title");
            ////				builder.setMessage(list.get(0));
            ////				AlertDialog dialog =builder.create();
            ////				dialog.show();
            //
            //			    List<String> list = new ArrayList<String>();
            //				for (int i = 0; i < Bimp.drr.size(); i++) {
            //					String Str = Bimp.drr.get(i).substring(
            //							Bimp.drr.get(i).lastIndexOf("/") + 1,
            //							Bimp.drr.get(i).lastIndexOf("."));
            //					list.add(FileUtils.SDPATH+Str+".JPEG");
            //					builder.setMessage(list.get(i));
            //					AlertDialog dialog =builder.create();
            //					dialog.show();
            //					Log.d("TCP",list.get(i) );
            //					Log.d("TCP",Bimp.drr.get(i) );
            //
            //						DataOutputStream dos;
            //				        FileInputStream fis;
            //				        File file;
            //				        int port=9091;
            //				    	String ip="192.168.1.104";
            //				        try {
            //				        	socket = new Socket();
            //				        	Log.d("TCP","0faile" );
            //				        	socket.bind(null);
            //				        	socket.connect(new InetSocketAddress(ip,port),5000);
            //
            //				        	 OutputStream out=socket.getOutputStream();
            //								String msg="Hello World123";
            //								out.write(msg.getBytes());
            //								Log.d("TCP","1faile" );
            //				            file = new File(list.get(i));
            //				            Log.d("TCP","2faile" );
            //				            if (file.length() == 0) {
            //				            	Log.d("TCP","faile" );
            //				            	return;
            //				            } else {
            //				            	Log.d("TCP","new socket" );
            //
            //						 dos = new DataOutputStream(socket.getOutputStream());
            //			                fis = new FileInputStream(file);
            //
            // dos.writeUTF(list.get(i).substring(list.get(i).lastIndexOf("/")+1));//截取图片名称
            //
            //			                dos.flush();
            //			                byte[] sendBytes = new byte[1024 * 8];
            //			                int length;
            //			                while ((length = fis.read(sendBytes, 0, sendBytes.length)) > 0) {
            //			                    dos.write(sendBytes, 0, length);
            //			                    dos.flush();// 发送给服务器
            //			                }
            //			                dos.close();//在发送消息完之后一定关闭,否则服务端无法继续接收信息后处理,手机卡机
            //			                fis.close();
            //			                socket.close();
            //			            }
            //			        } catch (UnknownHostException e) {
            //			            e.printStackTrace();
            //			        } catch (FileNotFoundException e) {
            //			            e.printStackTrace();
            //			        }catch (SocketTimeoutException e) {
            //			            e.printStackTrace();
            //			        }catch (IOException e) {
            //			            e.printStackTrace();
            //			        }

            //	new
            // SocketSend().seriesUpload("/storage/emulated/0/formats/434370832-94a4f46c3a19994.JPEG");
            Log.d("TCP", "success");
            //				}
            // 高清的压缩图片全部就在  list 路径里面了   //扯淡   ,真是路径为Bimp.drr.get(i)
            // 高清的压缩过的 bmp 对象  都在 Bimp.bmp里面
            // 完成上传服务器后 .........
            // 自行补全?

            //				AlertDialog.Builder builder=new AlertDialog.Builder(PublishedActivity.this);//this
            // 出错
            //				builder.setTitle("title");
            //				builder.setMessage(list.get(0));
            //				AlertDialog dialog =builder.create();
            //				dialog.show();

            //				FileUtils.deleteDir();
          }
        });
  }
Esempio n. 5
0
 protected void onRestart() {
   adapter.update();
   super.onRestart();
 }
Esempio n. 6
0
 protected void onRestart() {
   adapter.update();
   City = GlobalVariables.city;
   city.setText(City);
   super.onRestart();
 }
Esempio n. 7
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);
            }
          }
        });
  }