示例#1
0
  @Override
  public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    showToolbar(view, null);
    initDrawLayout(view);
    initNavigationView(view);
    initViewPager(view);
    initWeather(view);
  }
示例#2
0
 @Override
 public void handleMessage(Message msg) {
   switch (msg.what) {
     case WEATHER:
       {
         Weather weather = (Weather) msg.obj;
         if (weather != null) {
           MainFragment.this.weather.setText(
               weather.getToday().getWeatherStart()
                   + "-"
                   + weather.getToday().getWeatherEnd());
           MainFragment.this.temp.setText(weather.getRealtime().getTemp());
           // MenuFragment.this.place.setText(weather.getRealtime().getCity());
           MainFragment.this.min2max.setText(
               weather.getToday().getTempMin()
                   + "℃/"
                   + weather.getToday().getTempMax()
                   + "℃");
           String t = weather.getRealtime().getWeather();
           if (t.contains("晴")) {
             weatherIcon.setImageBitmap(
                 BitmapFactory.decodeResource(getResources(), R.mipmap.ic_action_sun));
           } else if (t.contains("云")) {
             weatherIcon.setImageBitmap(
                 BitmapFactory.decodeResource(getResources(), R.mipmap.ic_action_cloudy));
           } else if (t.contains("雨")) {
             weatherIcon.setImageBitmap(
                 BitmapFactory.decodeResource(getResources(), R.mipmap.ic_action_rain));
           } else if (t.contains("阴")) {
             weatherIcon.setImageBitmap(
                 BitmapFactory.decodeResource(getResources(), R.mipmap.ic_action_cloud));
           } else if (t.contains("雪")) {
             weatherIcon.setImageBitmap(
                 BitmapFactory.decodeResource(getResources(), R.mipmap.ic_action_rain));
           }
         }
         break;
       }
   }
   super.handleMessage(msg);
 }
示例#3
0
 @Override
 public void onFragmentResult(int requestCode, int resultCode, Intent data) {
   super.onFragmentResult(requestCode, resultCode, data);
   // 扫描二维码/条码回传
   if (requestCode == REQUEST_CODE_SCAN && resultCode == Activity.RESULT_OK) {
     if (data != null) {
       String content = data.getStringExtra(DECODED_CONTENT_KEY);
       Log.e("TAG", content);
       if (content.startsWith("zafu")) {
         String[] temp = content.split("\\|");
         Bundle bundle = new Bundle();
         NewsItem item = new NewsItem();
         item.setUrl(temp[1]);
         item.setTitle(temp[2]);
         bundle.putSerializable("news_item", item);
         openPage("newscontent", bundle, CoreAnim.slide);
       } else {
         Toast.makeText(getActivity(), "非法二维码,请使用新闻网客户端生成的二维码!", Toast.LENGTH_LONG).show();
       }
     }
     return;
   }
 }
示例#4
0
 @Override
 public void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   setHasOptionsMenu(true);
 }