List of usage examples for android.animation ValueAnimator start
@Override public void start()
From source file:xyz.klinker.blur.launcher3.Launcher.java
private void setupDrawer() { mWorkspace.setOnPageChangedListener(new Workspace.OnPageChangeListener() { @Override/*from w w w. ja va2 s.c o m*/ public void onPageChanged(int page) { if (mLauncherDrawer == null) { return; } if (mLauncherDrawer.getDrawerLockMode(Gravity.LEFT) == LauncherDrawerLayout.LOCK_MODE_LOCKED_CLOSED && !mWorkspace.isSmall()) { lockLauncherDrawer(false); } if (page == 0) { // on the first page mLauncherDrawer.setDrawerLeftEdgeSize(Launcher.this, 1.0f); } else { // somewhere in the middle mLauncherDrawer.setDrawerLeftEdgeSize(Launcher.this, .07f); } } @Override public void onScrollStart() { lockLauncherDrawer(true); } @Override public void onScrollEnd() { } }); mDrawerPager.setPageMargin(Utils.toDP(this, 15)); mDrawerPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override public void onPageSelected(int position) { mLauncherDrawer.setCurrentDrawerPage(position); } }); mLauncherDrawer.setDrawerListener(new LauncherDrawerLayout.DrawerListener() { @Override public void onDrawerSlide(View drawerView, float slideOffset) { mDragLayer.setTranslationX(getScreenWidth() * slideOffset); ((PagesFragmentAdapter) mDrawerPager.getAdapter()) .adjustFragmentBackgroundAlpha(mDrawerPager.getCurrentItem(), slideOffset); } @Override public void onDrawerOpened(View drawerView) { if (drawerView == mDrawerPager) { mDragLayer.setTranslationX(getScreenWidth()); } else { mDragLayer.setTranslationX(getScreenWidth() * -1); } adapter.pagesOpened(); if (Utilities.ATLEAST_MARSHMALLOW) { mLauncherDrawer.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR); } if (Utilities.ATLEAST_LOLLIPOP) { ValueAnimator animator = ValueAnimator.ofArgb(Color.TRANSPARENT, Color.parseColor("#22000000")); animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { int color = (Integer) valueAnimator.getAnimatedValue(); getWindow().setNavigationBarColor(color); getWindow().setStatusBarColor(color); } }); animator.setDuration(300); animator.start(); } } @Override public void onDrawerClosed(View drawerView) { mDragLayer.setTranslationX(0); adapter.pagesClosed(); InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(mLauncherDrawer.getWindowToken(), 0); if (Utilities.ATLEAST_MARSHMALLOW) { mLauncherDrawer.setSystemUiVisibility( mLauncherDrawer.getSystemUiVisibility() & ~View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR); } if (Utilities.ATLEAST_LOLLIPOP) { ValueAnimator animator = ValueAnimator.ofArgb(Color.parseColor("#22000000"), Color.TRANSPARENT); animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { int color = (Integer) valueAnimator.getAnimatedValue(); getWindow().setNavigationBarColor(color); getWindow().setStatusBarColor(color); } }); animator.setDuration(300); animator.start(); } } @Override public void onDrawerStateChanged(int newState) { } private int screenWidth = -1; private int getScreenWidth() { if (screenWidth == -1) { Display display = getWindowManager().getDefaultDisplay(); Point size = new Point(); display.getSize(size); screenWidth = size.x; } return screenWidth; } }); }
From source file:io.github.trulyfree.easyaspi.MainActivity.java
@Override public boolean setup() { downloadHandler = new DownloadHandler(this); fileHandler = new FileHandler(this); moduleHandler = new ModuleHandler(this); executorService = Executors.newCachedThreadPool(); setContentView(R.layout.activity_main); BottomNavigationView navigation = (BottomNavigationView) findViewById(R.id.navigation); navigation.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() { @Override/* w ww . j ava2s . co m*/ public boolean onNavigationItemSelected(@NonNull MenuItem item) { ViewSwitcher viewGroup = (ViewSwitcher) findViewById(R.id.content); int id = item.getItemId(); if ((id == R.id.navigation_home || id == R.id.navigation_modules) && id != currentID) { currentID = item.getItemId(); viewGroup.showNext(); return true; } return false; } }); ViewSwitcher viewSwitcher = (ViewSwitcher) findViewById(R.id.content); Animation in = AnimationUtils.loadAnimation(this, android.R.anim.slide_in_left); Animation out = AnimationUtils.loadAnimation(this, android.R.anim.slide_out_right); viewSwitcher.setInAnimation(in); viewSwitcher.setOutAnimation(out); resetConfigReturned(); Button getNewModule = (Button) findViewById(R.id.new_module_config_confirm); getNewModule.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { EditText editText = (EditText) findViewById(R.id.new_module_config_configurl); final String url = editText.getText().toString(); Toast.makeText(MainActivity.this, "Requested config from: " + url, Toast.LENGTH_SHORT).show(); executorService.submit(new Callable<Boolean>() { @Override public Boolean call() { ModuleConfig config; try { config = moduleHandler.getModuleConfig(url); } catch (MalformedURLException e) { e.printStackTrace(); runOnUiThread(new Runnable() { @Override public void run() { Toast.makeText(MainActivity.this, "Invalid URL. :(", Toast.LENGTH_LONG).show(); } }); return false; } catch (IOException e) { e.printStackTrace(); runOnUiThread(new Runnable() { @Override public void run() { Toast.makeText(MainActivity.this, "Failed to get module config. :(", Toast.LENGTH_LONG).show(); } }); return false; } catch (JsonParseException e) { e.printStackTrace(); runOnUiThread(new Runnable() { @Override public void run() { Toast.makeText(MainActivity.this, "Config loaded was invalid. :(", Toast.LENGTH_LONG).show(); } }); return false; } final ModuleConfig finalConfig = config; final ImageView configResponseBlock = (ImageView) findViewById(R.id.block_module_returned); final int colorFrom = ContextCompat.getColor(MainActivity.this, R.color.colorFillingTint); final int colorTo = ContextCompat.getColor(MainActivity.this, R.color.colorClear); final ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), colorFrom, colorTo); colorAnimation.setDuration(ANIMATION_DURATION); colorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animator) { configResponseBlock.setBackgroundColor((Integer) animator.getAnimatedValue()); } }); colorAnimation.addListener(new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animator) { } @Override public void onAnimationEnd(Animator animator) { LinearLayout layout = (LinearLayout) findViewById(R.id.module_returned_config); EditText moduleName = (EditText) findViewById(R.id.module_returned_configname); EditText moduleVersion = (EditText) findViewById( R.id.module_returned_configversion); EditText moduleConfigUrl = (EditText) findViewById(R.id.module_returned_configurl); EditText moduleJarUrl = (EditText) findViewById(R.id.module_returned_jarurl); LinearLayout moduleDependencies = (LinearLayout) findViewById( R.id.module_returned_dependencies); moduleDependencies.removeAllViewsInLayout(); try { configResponseBlock.setVisibility(View.GONE); moduleName.setText(finalConfig.getName()); moduleVersion.setText(finalConfig.getVersion()); moduleConfigUrl.setText(finalConfig.getConfUrl()); moduleJarUrl.setText(finalConfig.getJarUrl()); Config[] dependencies = finalConfig.getDependencies(); for (Config dependency : dependencies) { LinearLayout dependencyLayout = new LinearLayout(MainActivity.this); dependencyLayout.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); dependencyLayout.setOrientation(LinearLayout.HORIZONTAL); EditText name = new EditText(MainActivity.this); EditText jarUrl = new EditText(MainActivity.this); EditText[] loopThrough = { name, jarUrl }; LayoutParams params = new LayoutParams(0, LayoutParams.WRAP_CONTENT, 1.0f); for (EditText item : loopThrough) { item.setLayoutParams(params); item.setClickable(false); item.setInputType(InputType.TYPE_NULL); item.setCursorVisible(false); item.setFocusable(false); item.setFocusableInTouchMode(false); } name.setText(dependency.getName()); jarUrl.setText(dependency.getJarUrl()); dependencyLayout.addView(name); dependencyLayout.addView(jarUrl); moduleDependencies.addView(dependencyLayout); } layout.setClickable(true); Button validate = (Button) findViewById(R.id.module_returned_validate); Button cancel = (Button) findViewById(R.id.module_returned_cancel); validate.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Toast.makeText(MainActivity.this, "Requesting jars...", Toast.LENGTH_SHORT).show(); executorService.submit(new Callable<Boolean>() { @Override public Boolean call() { try { boolean success = true, refreshAllModification = true; Button refreshAll = null, getNewModule = (Button) findViewById( R.id.new_module_config_confirm); try { refreshAll = (Button) findViewById(R.id.refresh_all); refreshAll.setClickable(false); } catch (Throwable e) { refreshAllModification = false; } getNewModule.setClickable(false); final TextView stager = (TextView) findViewById( R.id.new_module_config_downloadstage); final ProgressBar progressBar = (ProgressBar) findViewById( R.id.new_module_config_downloadprogress); try { runOnUiThread(new Runnable() { @Override public void run() { resetConfigReturned(); } }); moduleHandler.getNewModule( makeModuleCallback(stager, progressBar), finalConfig, null, true); } catch (IOException e) { e.printStackTrace(); runOnUiThread(new Runnable() { @Override public void run() { stager.setText(""); progressBar.setProgress(0); } }); success = false; } getNewModule.setClickable(true); if (refreshAllModification) { refreshAll.setClickable(true); } return success; } catch (Throwable throwable) { throwable.printStackTrace(); return false; } } }); } }); cancel.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Toast.makeText(MainActivity.this, "Cancelling request...", Toast.LENGTH_SHORT).show(); resetConfigReturned(); } }); } catch (Exception e) { e.printStackTrace(); Toast.makeText(MainActivity.this, "Module config invalid. :(", Toast.LENGTH_LONG).show(); layout.setClickable(false); final int colorFrom = ContextCompat.getColor(MainActivity.this, R.color.colorClear); final int colorTo = ContextCompat.getColor(MainActivity.this, R.color.colorFillingTint); ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), colorFrom, colorTo); colorAnimation.setDuration(ANIMATION_DURATION); colorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animator) { configResponseBlock .setBackgroundColor((Integer) animator.getAnimatedValue()); } }); } } @Override public void onAnimationCancel(Animator animator) { } @Override public void onAnimationRepeat(Animator animator) { } }); runOnUiThread(new Runnable() { @Override public void run() { colorAnimation.start(); } }); return true; } }); } }); moduleHandler.setup(); refreshFilling(); return true; }