@TargetApi(11) public SpringConfiguratorView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); this.mSpringConfigs = new ArrayList(); this.mTextColor = Color.argb(255, Opcodes.SHR_INT_LIT8, Opcodes.SHR_INT_LIT8, Opcodes .SHR_INT_LIT8); SpringSystem springSystem = SpringSystem.create(); this.springConfigRegistry = SpringConfigRegistry.getInstance(); this.spinnerAdapter = new SpinnerAdapter(context); Resources resources = getResources(); this.mRevealPx = (float) Util.dpToPx(40.0f, resources); this.mStashPx = (float) Util.dpToPx(280.0f, resources); this.mRevealerSpring = springSystem.createSpring(); this.mRevealerSpring.setCurrentValue(PathListView.NO_ZOOM).setEndValue(PathListView .NO_ZOOM).addListener(new RevealerSpringListener()); addView(generateHierarchy(context)); SeekbarListener seekbarListener = new SeekbarListener(); this.mTensionSeekBar.setMax(MAX_SEEKBAR_VAL); this.mTensionSeekBar.setOnSeekBarChangeListener(seekbarListener); this.mFrictionSeekBar.setMax(MAX_SEEKBAR_VAL); this.mFrictionSeekBar.setOnSeekBarChangeListener(seekbarListener); this.mSpringSelectorSpinner.setAdapter(this.spinnerAdapter); this.mSpringSelectorSpinner.setOnItemSelectedListener(new SpringSelectedListener()); refreshSpringConfigurations(); setTranslationY(this.mStashPx); }
@TargetApi(Build.VERSION_CODES.HONEYCOMB) public SpringConfiguratorView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); SpringSystem springSystem = SpringSystem.create(); springConfigRegistry = SpringConfigRegistry.getInstance(); spinnerAdapter = new SpinnerAdapter(context); Resources resources = getResources(); mRevealPx = dpToPx(40, resources); mStashPx = dpToPx(280, resources); mRevealerSpring = springSystem.createSpring(); SpringListener revealerSpringListener = new RevealerSpringListener(); mRevealerSpring .setCurrentValue(1) .setEndValue(1) .addListener(revealerSpringListener); addView(generateHierarchy(context)); SeekbarListener seekbarListener = new SeekbarListener(); mTensionSeekBar.setMax(MAX_SEEKBAR_VAL); mTensionSeekBar.setOnSeekBarChangeListener(seekbarListener); mFrictionSeekBar.setMax(MAX_SEEKBAR_VAL); mFrictionSeekBar.setOnSeekBarChangeListener(seekbarListener); mSpringSelectorSpinner.setAdapter(spinnerAdapter); mSpringSelectorSpinner.setOnItemSelectedListener(new SpringSelectedListener()); refreshSpringConfigurations(); this.setTranslationY(mStashPx); }
public SpringOverScroller(Context context, Interpolator interpolator, boolean flywheel) { mSpringSystem = SpringSystem.create(); mSpringX = mSpringSystem .createSpring() .addListener(this); mSpringY = mSpringSystem .createSpring() .addListener(this); SpringConfigRegistry .getInstance() .addSpringConfig(RUBBERBANDING_CONFIG, "rubber-banding"); SpringConfigRegistry .getInstance() .addSpringConfig(COASTING_CONFIG, "coasting"); }
@TargetApi(Build.VERSION_CODES.HONEYCOMB) public SpringConfiguratorView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); SpringSystem springSystem = SpringSystem.create(); springConfigRegistry = SpringConfigRegistry.getInstance(); spinnerAdapter = new SpinnerAdapter(context); Resources resources = getResources(); mRevealPx = dpToPx(40, resources); mStashPx = dpToPx(280, resources); mRevealerSpring = springSystem.createSpring(); SpringListener revealerSpringListener = new RevealerSpringListener(); mRevealerSpring .setCurrentValue(1) .setEndValue(1) .addListener(revealerSpringListener); addView(generateHierarchy(context)); SeekbarListener seekbarListener = new SeekbarListener(); mTensionSeekBar.setMax(MAX_SEEKBAR_VAL); mTensionSeekBar.setOnSeekBarChangeListener(seekbarListener); mFrictionSeekBar.setMax(MAX_SEEKBAR_VAL); mFrictionSeekBar.setOnSeekBarChangeListener(seekbarListener); mSpringSelectorSpinner.setAdapter(spinnerAdapter); mSpringSelectorSpinner.setOnItemSelectedListener(new SpringSelectedListener()); refreshSpringConfigurations(); //this.setTranslationY(mStashPx); }
private void init(Context context, ChatHeadConfig chatHeadDefaultConfig) { chatHeadContainer.onInitialized(this); DisplayMetrics metrics = new DisplayMetrics(); WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); windowManager.getDefaultDisplay().getMetrics(metrics); this.displayMetrics = metrics; this.config = chatHeadDefaultConfig; //TODO : needs cleanup chatHeads = new ArrayList<>(5); arrowLayout = new UpArrowLayout(context); arrowLayout.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); chatHeadContainer.addView(arrowLayout, arrowLayout.getLayoutParams()); arrowLayout.setVisibility(View.GONE); springSystem = SpringSystem.create(); closeButton = new ChatHeadCloseButton(context, this, maxHeight, maxWidth); ViewGroup.LayoutParams layoutParams = chatHeadContainer.createLayoutParams(chatHeadDefaultConfig.getCloseButtonHeight(), chatHeadDefaultConfig.getCloseButtonWidth(), Gravity.TOP | Gravity.START, 0); closeButton.setListener(this); chatHeadContainer.addView(closeButton, layoutParams); closeButtonShadow = new ImageView(getContext()); ViewGroup.LayoutParams shadowLayoutParams = chatHeadContainer.createLayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.MATCH_PARENT, Gravity.BOTTOM, 0); closeButtonShadow.setImageResource(R.drawable.dismiss_shadow); closeButtonShadow.setVisibility(View.GONE); chatHeadContainer.addView(closeButtonShadow, shadowLayoutParams); arrangements.put(MinimizedArrangement.class, new MinimizedArrangement(this)); arrangements.put(MaximizedArrangement.class, new MaximizedArrangement<T>(this)); setupOverlay(context); setConfig(chatHeadDefaultConfig); SpringConfigRegistry.getInstance().addSpringConfig(SpringConfigsHolder.DRAGGING, "dragging mode"); SpringConfigRegistry.getInstance().addSpringConfig(SpringConfigsHolder.NOT_DRAGGING, "not dragging mode"); }
public OrigamiExample(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); // Inflate the layout. LayoutInflater inflater = LayoutInflater.from(context); ViewGroup root = (ViewGroup) inflater.inflate(R.layout.origami_example, this, false); addView(root); // Listen for clicks on the root view. root.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { handleClick(v); } }); // Get references to our views. mPhotoGrid = root.findViewById(R.id.grid); mSelectedPhoto = root.findViewById(R.id.selection); mFeedbackBar = root.findViewById(R.id.feedback); mSpringConfiguratorView = (SpringConfiguratorView) root.findViewById(R.id.spring_configurator); // Setup the Spring by creating a SpringSystem adding a SimpleListener that renders the // animation whenever the spring is updated. mSpring = SpringSystem .create() .createSpring() .setSpringConfig(ORIGAMI_SPRING_CONFIG) .addListener(new SimpleSpringListener() { @Override public void onSpringUpdate(Spring spring) { // Just tell the UI to update based on the springs current state. render(); } }); // Here we just wait until the first layout pass finishes and call our render method to update // the animation to the initial resting state of the spring. mPhotoGrid.getViewTreeObserver().addOnGlobalLayoutListener( new ViewTreeObserver.OnGlobalLayoutListener() { @Override public void onGlobalLayout() { render(); mPhotoGrid.getViewTreeObserver().removeOnGlobalLayoutListener(this); } }); /** Optional - Live Spring Tuning **/ // Put our config into a registry. This is optional, but it gives you the ability to live tune // the spring using the SpringConfiguratorView which will show up at the bottom of the screen. SpringConfigRegistry.getInstance().addSpringConfig(ORIGAMI_SPRING_CONFIG, "origami animation spring"); // Tell the SpringConfiguratorView that we've updated the registry to allow you to live tune the animation spring. mSpringConfiguratorView.refreshSpringConfigurations(); // Uncomment this line to actually show the SpringConfiguratorView allowing you to live tune // the Spring constants as you manipulate the UI. mSpringConfiguratorView.setVisibility(View.VISIBLE); }
public OrigamiExample(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); // Inflate the layout. LayoutInflater inflater = LayoutInflater.from(context); ViewGroup root = (ViewGroup) inflater.inflate(R.layout.origami_example, this, false); addView(root); // Listen for clicks on the root view. root.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { handleClick(v); } }); // Get references to our views. mPhotoGrid = root.findViewById(R.id.grid); mSelectedPhoto = root.findViewById(R.id.selection); mFeedbackBar = root.findViewById(R.id.feedback); mSpringConfiguratorView = (SpringConfiguratorView) root.findViewById(R.id.spring_configurator); // Setup the Spring by creating a SpringSystem adding a SimpleListener that renders the // animation whenever the spring is updated. mSpring = SpringSystem .create() .createSpring() .setSpringConfig(ORIGAMI_SPRING_CONFIG) .addListener(new SimpleSpringListener() { @Override public void onSpringUpdate(Spring spring) { // Just tell the UI to update based on the springs current state. render(); } }); // Here we just wait until the first layout pass finishes and call our render method to update // the animation to the initial resting state of the spring. mPhotoGrid.getViewTreeObserver().addOnGlobalLayoutListener( new ViewTreeObserver.OnGlobalLayoutListener() { @Override public void onGlobalLayout() { render(); mPhotoGrid.getViewTreeObserver().removeGlobalOnLayoutListener(this); } }); /** Optional - Live Spring Tuning **/ // Put our config into a registry. This is optional, but it gives you the ability to live tune // the spring using the SpringConfiguratorView which will show up at the bottom of the screen. SpringConfigRegistry.getInstance().addSpringConfig(ORIGAMI_SPRING_CONFIG, "origami animation spring"); // Tell the SpringConfiguratorView that we've updated the registry to allow you to live tune the animation spring. mSpringConfiguratorView.refreshSpringConfigurations(); // Uncomment this line to actually show the SpringConfiguratorView allowing you to live tune // the Spring constants as you manipulate the UI. mSpringConfiguratorView.setVisibility(View.VISIBLE); }