Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

merge Develop #83

Merged
merged 2 commits into from
Apr 5, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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