private String getSnackContent(int current) { Random random = new Random(); random.setSeed(System.currentTimeMillis()); return getResources() .getString( getResources() .getIdentifier( "magicasrkura_prompt_" + random.nextInt(3), "string", getPackageName())) + ThemeHelper.getName(current); }
@Override public void onConfirm(int currentTheme) { if (ThemeHelper.getTheme(MainActivity.this) != currentTheme) { ThemeHelper.setTheme(MainActivity.this, currentTheme); ThemeUtils.refreshUI( MainActivity.this, new ThemeUtils.ExtraRefreshable() { @Override public void refreshGlobal(Activity activity) { // for global setting, just do once if (Build.VERSION.SDK_INT >= 21) { final MainActivity context = MainActivity.this; ActivityManager.TaskDescription taskDescription = new ActivityManager.TaskDescription( null, null, ThemeUtils.getThemeAttrColor(context, android.R.attr.colorPrimary)); setTaskDescription(taskDescription); getWindow() .setStatusBarColor( ThemeUtils.getColorById(context, R.color.theme_color_primary_dark)); } } @Override public void refreshSpecificView(View view) { // TODO: will do this for each traversal } }); View view = findViewById(R.id.snack_layout); if (view != null) { TextView textView = (TextView) view.findViewById(R.id.content); textView.setText(getSnackContent(currentTheme)); SnackAnimationUtil.with(this, R.anim.snack_in, R.anim.snack_out) .setDismissDelayTime(1000) .setTarget(view) .play(); } } }