コード例 #1
0
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    fa = super.getActivity();
    ll = (LinearLayout) inflater.inflate(R.layout.saturate_frag, container, false);
    prefs = fa.getSharedPreferences(C.PREF, Context.MODE_PRIVATE);
    mUtils = new Utils(fa);
    wm = WallpaperManager.getInstance(fa);
    image = (ImageView) ll.findViewById(R.id.main_image);
    try {
      WallpaperInfo info = wm.getWallpaperInfo();
      info.toString();
      mUtils.sendToast(getResources().getString(R.string.live_wallpaper));
    } catch (NullPointerException ignore) {
    }
    time_text = (TextView) ll.findViewById(R.id.time_text);
    seek = (SeekBar) ll.findViewById(R.id.seeker);
    seek.setMax(23);
    Calendar cal = Calendar.getInstance();
    hour = cal.get(Calendar.HOUR_OF_DAY);
    time_text.setText(mUtils.getHour(hour));
    seek.setOnSeekBarChangeListener(
        new SeekBar.OnSeekBarChangeListener() {

          @Override
          public void onProgressChanged(SeekBar v, int num, boolean isU) {
            if (!isRunning) {
              time_text.setText(mUtils.getHour(num));
              seekerFl = mUtils.getFloat(num);
              Drawable d = mUtils.convertToGrayscale(wm.getDrawable(), seekerFl);
              image.setImageDrawable(d);
            }
          }

          @Override
          public void onStartTrackingTouch(SeekBar arg0) {
            // TODO Auto-generated method stub
          }

          @Override
          public void onStopTrackingTouch(SeekBar arg0) {
            // TODO Auto-generated method stub
          }
        });

    if (!prefs.getBoolean(C.PREF_SATURATE_FIRST_RUN_MAIN, false)) {
      prefs.edit().putBoolean(C.PREF_SATURATE_FIRST_RUN_MAIN, true).commit();
      String title = getResources().getString(R.string.main_title_saturate);
      String message = getResources().getString(R.string.saturate_description);
      new CustomDialogs().openFirstDialog(fa, title, message);
    }
    setHasOptionsMenu(true);
    return ll;
  }
コード例 #2
0
 private void stopRunning() {
   mUtils.stopSaturatedAlarms();
   mUtils.sendToast(SaturateFrag.this.getResources().getString(R.string.stopped_sat));
   prefs.edit().putBoolean(C.PREF_SATURATE_START, false).commit();
 }