两个android平台组件【天气预报、日期】View组件-亚博取款出款速度

日期:2021-07-10 01:03:01 | 人气: 14484

两个android平台组件【天气预报、日期】View组件-亚博取款出款速度 本文摘要:这篇文章内容将共享资源2个VIEW组件,一个气温组件和一个时间组件,这两个组件原本是一个AppWidget之后,我觉得著笑话段子,将她们遮住一个VIEW的组件,能够像用于WindowsPhone7的客户控制一样扯放到你要的新项目中。

亚博取款速度非常快

亚博取款出款速度

这篇文章内容将共享资源2个VIEW组件,一个气温组件和一个时间组件,这两个组件原本是一个AppWidget之后,我觉得著笑话段子,将她们遮住一个VIEW的组件,能够像用于WindowsPhone7的客户控制一样扯放到你要的新项目中。这篇将展现这两个组件的撰写全过程,工程文件以下:    包名解读:  com.terry.weather  程序流程的通道包在  com.yaomei.adapter  天气预报组件用于到的数据库  com.yaomei.model  天气预报用于到的实体模型包在  com.yaomei.util  出示天气数据的工具箱  com.yaomei.widget  天气预报组件、时间组件的储放在方向  从包名能够显出,撰写一个天气预报所务必的编码成交量放大撰写一个时间VIEW所务必的编码量要很少,那麼大家再作把天气预报的一些搭建构思跟大伙儿讲下。  最先,本案例用于的天气预报是一个能够自身现代化的气温组件VIEW,能看下图,将所务必的URL都放入ANDROID自身的现代化文件夹名称里边,例如汉语得话就是这样写成:  《stringname=googleWeatherApi》  《![CDATA[.yaomei.widget;  importjava.io.ByteArrayInputStream;  importjava.io.ByteArrayOutputStream;  importjava.util.ArrayList;  importjava.util.Calendar;  importjava.util.List;  importjava.util.Timer;  importjava.util.TimerTask;  importorg.apache.commons.codec.binary.Base64;  importandroid.app.Activity;  importandroid.content.Context;  importandroid.content.SharedPreferences;  importandroid.content.res.TypedArray;  importandroid.graphics.Bitmap.CompressFormat;  importandroid.graphics.drawable.BitmapDrawable;  importandroid.graphics.drawable.Drawable;  importandroid.os.Handler;  importandroid.os.Message;  importandroid.text.Html;  importandroid.util.AttributeSet;  importandroid.view.LayoutInflater;  importandroid.view.View;  importandroid.widget.GridView;  importandroid.widget.ImageView;  importandroid.widget.LinearLayout;  importandroid.widget.TextView;  importandroid.widget.Toast;  importcom.terry.weather.R;  importcom.yaomei.adapter.weatherAdapter;  importcom.yaomei.model.WeatherMdoel;  importcom.yaomei.util.strHelpeUtil;  publicclassWeatherViewextendsLinearLayout{  privatestaticfinalStringHour_COMPARE=hour_compare;  privatestaticfinalStringDAY_OF_WEEK=day_of_week;  privatestaticfinalStringLOW=low;  privatestaticfinalStringHIGH=high;  privatestaticfinalStringCONDITION=condition;  privatestaticfinalStringIMAGE=image;  privatestaticfinalStringDATE_COMPARE=date_compare;  privatestaticfinalStringCITYNAE_SHARE=cityNameShare;  privateImageViewiv_weather;  privateTextViewtv_state,tv_position,tv;  WeatherMdoelmodel;  privateList《WeatherMdoel》weatherList=null;  GridViewgv;  Timertimer;  Handlerhandler=newHandler(){  publicvoidhandleMessage(Messagemsg){  if(msg.arg1==1){  if(weatherList.size()》0){  gv  .setAdapter(newweatherAdapter(getContext(),  weatherList));  init();  }else{  Toast.makeText(getContext(),搜索接近数据信息,1000).show();  }  //msg.recycle();  }  };  };  /**  *全自动载入气温  */  privatebooleanautoLoad=false;  publicbooleangetAutoLoad(){  returnautoLoad;  }  publicvoidsetAutoLoad(booleanisLoad){  this.autoLoad=isLoad;  }  /**  *城市名称  */  privateStringcityName=;  publicStringgetCityName(){  returncityName;  }  publicvoidsetCityName(StringcityName){  this.cityName=cityName;  }  /**  *设定每几个小时重做一次  */  privateintupdateHour;  publicintgetUpdateHour(){  returnupdateHour;  }  publicvoidsetUpdateHour(inthour){  this.updateHour=hour;  }  publicWeatherView(Contextcontext){  this(context,null);  //TODOAuto-generatedconstructorstub  }  publicWeatherView(Contextcontext,AttributeSetattrs){  super(context,attrs);  intresouceID=-1;  TypedArraytyedArray=context.obtainStyledAttributes(attrs,  R.styleable.WeatherView);  intN=tyedArray.getIndexCount();  for(inti=0;i《N;i ){  intattr=tyedArray.getIndex(i);  switch(attr){  caseR.styleable.WeatherView_AutoLoad:  setAutoLoad(tyedArray.getBoolean(  R.styleable.WeatherView_AutoLoad,false));  break;  caseR.styleable.WeatherView_CityName:  resouceID=tyedArray.getResourceId(  R.styleable.WeatherView_CityName,0);  setCityName(resouceID》0?tyedArray.getResources().getText(  resouceID).toString():tyedArray  .getString(R.styleable.WeatherView_CityName));  break;  caseR.styleable.WeatherView_UpdateHour:  setUpdateHour(tyedArray.getInteger(  R.styleable.WeatherView_UpdateHour,3));  break;  }  }  Viewview=LayoutInflater.from(getContext()).inflate(  R.layout.weather_layout,this);  tv=(TextView)view.findViewById(R.id.tv_temperature);  gv=(GridView)view.findViewById(R.id.grid);  iv_weather=(ImageView)view.findViewById(R.id.iv_weather);  tv_state=(TextView)view.findViewById(R.id.tv_state);  tv_position=(TextView)view.findViewById(R.id.tv_position);  timer=newTimer();  if(getAutoLoad()){  startLoadWeather();  }  tyedArray.recycle();  }  /**  *刚开始载入  */  publicvoidstartLoadWeather(){  timer.schedule(newTimerTask(){  @Override  publicvoidrun(){  SharedPreferencesshare=getContext().getSharedPreferences(  weather,Activity.MODE_PRIVATE);  longtime=System.currentTimeMillis();  finalCalendarmCalendar=Calendar.getInstance();  mCalendar.setTimeInMillis(time);  StringtempDate=mCalendar.get(Calendar.YEAR) -   mCalendar.get(Calendar.MONTH) -   mCalendar.get(Calendar.DAY_OF_MONTH);  if(share.contains(DATE_COMPARE)){  if(share.getString(CITYNAE_SHARE,).equals(cityName)){  inttime_cop=mCalendar.get(Calendar.HOUR)  -share.getInt(Hour_COMPARE,0);  Stringdate=share.getString(DATE_COMPARE,);  if(time_cop》=getUpdateHour()  ||!date.equals(tempDate)){  saveWeatherList(mCalendar.get(Calendar.HOUR),  tempDate);  }elseif(time_cop《getUpdateHour()){  wea therList=newArrayList《WeatherMdoel》();  for(inti=0;i《4;i ){  WeatherMdoelmodel=newWeatherMdoel();  model.setWeek(share.getString(DAY_OF_WEEK i,  ));  model.setLowTemp(share.getString(LOW i,));  model  .setHighTemp(share.getString(HIGH i,  ));  model.setConditions(share.getString(CONDITION   i,));  Stringimage=share.getString(IMAGE i,);  byte[]base64Bytes=Base64.decodeBase64(image  .getBytes());  ByteArrayInputStreambais=newByteArrayInputStream(  base64Bytes);  model.setImageUrl();  model  .setImageDrawable(Drawable  .createFromStream(bais,  weather_image));  weatherList.add(model);  }  }  }else{  saveWeatherList(mCalendar.get(Calendar.HOUR),tempDate);  }  }else{  saveWeatherList(mCalendar.get(Calendar.HOUR),tempDate);  }  //把适度的操作者放进于进程中继续执行,不阻塞UI  if(handler.hasMessages(1))  handler.obtainMessage().recycle();  else{  Messagemsg=handler.obtainMessage();  msg.arg1=1;  msg.sendToTarget();  }  }  },0,getUpdateHour()*3600*1000);  }  /**  *第一次或是此外新的载入  */  voidsaveWeatherList(inthour,Stringday){  weatherList=newArrayList《WeatherMdoel》();  weatherList=strHelpeUtil.searchWeather(Html.fromHtml(  getContext().getResources()  .getString(R.string.googleWeatherApi)).toString(),  getCityName());  SharedPreferences.EditorshareEditor=getContext()  .getSharedPreferences(weather,Activity.MODE_PRIVATE).edit();  shareEditor.clear();  inti=0;  for(WeatherMdoelmodel:weatherList){  shareEditor.putString(DAY_OF_WEEK i,model.getWeek());  shareEditor.putString(LOW i,model.getLowTemp());  shareEditor.putString(HIGH i,model.getHighTemp());  shareEditor.putString(CONDITION i,model.getConditions());  /**  *将图片现钱  */  ByteArrayOutputStreambaos=newByteArrayOutputStream();  ((BitmapDrawable)strHelpeUtil.loadImage(model.getImageUrl()))  .getBitmap().compress(CompressFormat.JPEG,50,baos);  StringImageBase64=newString(Base64.encodeBase64(baos  .toByteArray()));  shareEditor.putString(IMAGE i,ImageBase64);  i ;  }  shareEditor.putString(DATE_COMPARE,day);  shareEditor.putInt(Hour_COMPARE,hour);  shareEditor.putString(CITYNAE_SHARE,cityName);  shareEditor.commit();  }  /**  *复位部件信息  */  voidinit(){  model=weatherList.get(0);  iv_weather.setImageDrawable(model.getImageUrl()==?model  .getImageDrawable():strHelpeUtil.loadImage(model  .getImageUrl()));  tv_state.setText(model.getConditions());  tv_position.setText(getCityName());  tv.setText(getContext().getResources().getString(R.string.temp_format,  model.getLowTemp(),model.getHighTemp()));  }  /**  *获释目标  */  publicvoidreleaseTimer(){  timer.。

亚博取款出款速度


本文关键词:亚博取款出款速度,亚博取款速度非常快

本文来源:亚博取款出款速度-www.relicage.com

产品中心