Skip to content

Commit

Permalink
Merge pull request willowtreeapps#80 from willowtreeapps/feature/vert…
Browse files Browse the repository at this point in the history
…ical-paging-controls

Example app controls
  • Loading branch information
bret-fears authored Apr 4, 2017
2 parents 3cfbb3d + 7fc8804 commit 34dc42a
Show file tree
Hide file tree
Showing 15 changed files with 918 additions and 603 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ Animator spruceAnimator = new Spruce
Definitely play around with the stock `SortFunction` implementations until you find the one that is perfect for you! Check out the example app if you want to get previews of what each `SortFunction` will look like.

### The Animators
The animations used in Spruce are produced by leveraging the `Animtor` class. You may provide your own custom animations by creating your own `Animator` and provide it to the as part of an `Animator[]` to `SpruceBuilder.animateWith(Animator... animators)`. For more information on using the `Animator` class please check out https://developer.android.com/reference/android/animation/Animator.html
The animations used in Spruce are produced by leveraging the `Animator` class. You may provide your own custom animations by creating your own `Animator` and provide it to the as part of an `Animator[]` to `SpruceBuilder.animateWith(Animator... animators)`. For more information on using the `Animator` class please check out https://developer.android.com/reference/android/animation/Animator.html

### Standard Animation
The `DefaultAnimation` class provides simple `Animator` methods to apply the change `Animator` to the views. Use this class if you want to have a stock linear movement of the changes.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,36 +27,54 @@
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.Spinner;

import com.willowtreeapps.spurceexampleapp.fragments.ControlsFragment;
import com.willowtreeapps.spurceexampleapp.fragments.ViewFragment;
import com.willowtreeapps.spurceexampleapp.pager.VerticalViewPager;

public class SpruceActivity extends AppCompatActivity {
import java.util.ArrayList;
import java.util.List;

public class SpruceActivity extends AppCompatActivity
implements ViewFragment.OnParentAndChildCreationListener {

public ViewGroup parent;
public List<View> children = new ArrayList<>();
public Spinner sortDropDown;

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

setContentView(R.layout.activity_fragment);
setContentView(R.layout.fragment_pager);

FragmentManager fm = getSupportFragmentManager();
Fragment viewFragment = fm.findFragmentById(R.id.view_fragment);

if (viewFragment == null) {
viewFragment = ViewFragment.newInstance();
fm.beginTransaction()
.add(R.id.view_fragment, viewFragment)
.commit();
}
VerticalViewPager verticalPager = (VerticalViewPager) findViewById(R.id.vertical_pager);
VerticalPagerAdapter adapter = new VerticalPagerAdapter(fm);
verticalPager.setAdapter(adapter);

Toolbar toolBar = (Toolbar) findViewById(R.id.tool_bar);
setSupportActionBar(toolBar);
if (getSupportActionBar() != null) {
getSupportActionBar().setDisplayShowTitleEnabled(false);
}

sortDropDown = (Spinner) findViewById(R.id.sort_selection);
ArrayAdapter<CharSequence> spinnerAdapter = ArrayAdapter.createFromResource(this,
R.array.sort_functions,
R.layout.spinner_item);
spinnerAdapter.setDropDownViewResource(R.layout.support_simple_spinner_dropdown_item);
sortDropDown.setAdapter(spinnerAdapter);
}

@Override
Expand All @@ -77,4 +95,33 @@ public boolean onOptionsItemSelected(MenuItem item) {
}
return super.onOptionsItemSelected(item);
}

@Override
public void onParentAndChildrenPrepared(ViewGroup parent, List<View> children) {
this.parent = parent;
this.children = children;
}

private class VerticalPagerAdapter extends FragmentStatePagerAdapter {

VerticalPagerAdapter(FragmentManager fm) {
super(fm);
}

@Override
public Fragment getItem(int position) {
switch (position) {
case 1:
return ControlsFragment.newInstance();
default:
return ViewFragment.newInstance();
}
}

@Override
public int getCount() {
return 2;
}

}
}
Loading

0 comments on commit 34dc42a

Please sign in to comment.