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; }
protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == IMAGE_PICK && resultCode == RESULT_OK) { if (data != null && data.getData() != null) { Uri uri = data.getData(); addTemporaryWallpaperTile(uri, false); } } else if (requestCode == PICK_WALLPAPER_THIRD_PARTY_ACTIVITY) { setResult(RESULT_OK); finish(); } else if (requestCode == PICK_LIVE_WALLPAPER) { WallpaperManager wm = WallpaperManager.getInstance(this); final WallpaperInfo oldLiveWallpaper = mLiveWallpaperInfoOnPickerLaunch; final WallpaperInfo clickedWallpaper = mLastClickedLiveWallpaperInfo; WallpaperInfo newLiveWallpaper = wm.getWallpaperInfo(); // Try to figure out if a live wallpaper was set; if (newLiveWallpaper != null && (oldLiveWallpaper == null || !oldLiveWallpaper.getComponent().equals(newLiveWallpaper.getComponent()) || clickedWallpaper.getComponent().equals(oldLiveWallpaper.getComponent()))) { // Return if a live wallpaper was set setResult(RESULT_OK); finish(); } } }