团队冲刺阶段二(9)
对已完成的代码检查并进行优化。
已经完成了大部分的工作,现在要做的就是对代码的检查和修改,发现其中的问题。
工作中的部分代码如下:
public class firstFragment extends Fragment {
private ProgressDialog progressDialog;
private String mContentText;
ImageView img;
TextView text;
String str;
Bitmap bitmap;
Handler handler=new Handler(){
@Override
public void handleMessage(Message msg) {
super.handleMessage(msg);
byte[] bye=(byte[])msg.obj;
bitmap = ((BitmapDrawable) img.getDrawable()).getBitmap();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.PNG, 100, baos);
String str1="";
for(int i=0;i<30;i++){
str1=str1+baos.toByteArray()[i]+"A"+i+"a";
}
text.setText(str1);
bye=baos.toByteArray();
//progressDialog = MaskUtil.firshowProgressDialog("拼命加载中",firstFragment.this);
bitmap=BitmapFactory.decodeByteArray(bye, 0, bye.length);
//text.setText(baos.toByteArray()[0]+"a"+baos.toByteArray()[1]+"b");
img.setImageBitmap(bitmap);
//bitmap=BitmapFactory.decodeResource(getResources(),R.mipmap.dibu);
//contentTv.setText("size:"+L.size());
//img.setImageBitmap(bitmap);
// progressDialog.dismiss();
}
};
public firstFragment(){
}
//联网方法
public void netmethod(){
progressDialog = MaskUtil.firshowProgressDialog("拼命加载中",firstFragment.this);
String path = "";
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url(path)
.get()
.build();
client.newCall(request).enqueue(new Callback() {
@Override
public void onFailure(Call call, IOException e) {
Looper.prepare();
progressDialog.dismiss();
AlertDialog alertDialog = new AlertDialog.Builder(getActivity()).create();
alertDialog.setMessage("网络或服务器原因连接失败");
alertDialog.setButton(DialogInterface.BUTTON_NEGATIVE, "我知道了", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
}
});
alertDialog.show();
Looper.loop();
}
@Override
public void onResponse(Call call, Response response) throws IOException {
//progressDialog.dismiss();
//Looper.prepare();
//String result = response.body().string();
byte[] piby=response.body().bytes();
Message mes=handler.obtainMessage();
mes.obj=piby;
handler.sendMessage(mes);
progressDialog.dismiss();
}
});
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//getinformation();
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View rootView = inflater.inflate(R.layout.activity_first_fragment, container, false);
img=(ImageView)rootView.findViewById(R.id.firimg);
text=rootView.findViewById(R.id.textView2);
//byte[] bytt=
//Bitmap bip=BitmapFactory.decodeByteArray(list.get(0).getTupian(), 0, list.get(0).getTupian().length);
netmethod();
//contentTv.setText("信息:"+L.size());
return rootView;
}
}
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· AI技术革命,工作效率10个最佳AI工具