答案 0 :(得分:4)
将轴public class ToDoList extends Fragment implements BatListener, OnItemClickListener, OnOutsideClickedListener {
private BatRecyclerView mRecyclerView;
private BatAdapter mAdapter;
private List<BatModel> mGoals;
private BatItemAnimator mAnimator;
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View root = inflater.inflate(R.layout.todo_list_fragment, null);
return root;
}
public void onViewCreated(View view, Bundle savedInstanceState) {
// you can add listener of elements here
/*Button mButton = (Button) view.findViewById(R.id.button);
mButton.setOnClickListener(this); */
// Navigator
FoldingTabBar tabBar = (FoldingTabBar) view.findViewById(R.id.folding_tab_bar);
tabBar.setOnFoldingItemClickListener(new FoldingTabBar.OnFoldingItemSelectedListener() {
@Override
public boolean onFoldingItemSelected(@NotNull MenuItem item) {
switch (item.getItemId()) {
case R.id.menu_profile:
Intent intent0 = new Intent(ToDoList.this, Home.class);
startActivity(intent0);
break;
case R.id.menu_todo:
break;
case R.id.menu_schedule:
Intent intent1 = new Intent(ToDoList.this, TimeTable.class);
startActivity(intent1);
break;
case R.id.menu_settings:
break;
}
return false;
}
});
((AppCompatActivity)getActivity()).setSupportActionBar(toolbar);
((TextView) view.findViewById(R.id.text_title)).setTypeface(TypefaceUtil.getAvenirTypeface(this));
mRecyclerView = (BatRecyclerView) view.findViewById(R.id.bat_recycler_view);
mAnimator = new BatItemAnimator();
mRecyclerView.getView().setLayoutManager(new LinearLayoutManager(this));
mRecyclerView.getView().setAdapter(mAdapter = new BatAdapter(mGoals = new ArrayList<BatModel>() {{
}}, this, mAnimator).setOnItemClickListener(this).setOnOutsideClickListener(this));
ItemTouchHelper itemTouchHelper = new ItemTouchHelper(new BatCallback(this));
itemTouchHelper.attachToRecyclerView(mRecyclerView.getView());
mRecyclerView.getView().setItemAnimator(mAnimator);
mRecyclerView.setAddItemListener(this);
view.findViewById(R.id.root).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mRecyclerView.revertAnimation();
}
});
}
@Override
public void add(String string) {
mGoals.add(0, new Goal(string));
mAdapter.notify(AnimationType.ADD, 0);
}
@Override
public void delete(int position) {
mGoals.remove(position);
mAdapter.notify(AnimationType.REMOVE, position);
}
@Override
public void move(int from, int to) {
if (from >= 0 && to >= 0) {
mAnimator.setPosition(to);
BatModel model = mGoals.get(from);
mGoals.remove(model);
mGoals.add(to, model);
mAdapter.notify(AnimationType.MOVE, from, to);
if (from == 0 || to == 0) {
mRecyclerView.getView().scrollToPosition(Math.min(from, to));
}
}
}
@Override
public void onClick(BatModel item, int position) {
Toast.makeText(this, item.getText(), Toast.LENGTH_SHORT).show();
}
@Override
public void onOutsideClicked() {
mRecyclerView.revertAnimation();
}
}
属性更改为Layer
。
'top'