Skip to content
This repository has been archived by the owner on Aug 22, 2020. It is now read-only.

Commit

Permalink
IStepperAdapter: Rename
Browse files Browse the repository at this point in the history
Signed-off-by: Fung <[email protected]>
  • Loading branch information
fython committed Aug 9, 2017
1 parent 245ec88 commit 78cc9d8
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,10 @@ public boolean onNavigationItemSelected(@NonNull MenuItem item) {
mDrawerLayout.closeDrawer(mNavigationView);
switch (item.getItemId()) {
case R.id.item_vertical_stepper:
getSupportFragmentManager().beginTransaction()
.replace(R.id.container, mVerticalStepperDemoFragment).commit();
replaceFragment(mVerticalStepperDemoFragment);
return true;
case R.id.item_vertical_stepper_adapter:
getSupportFragmentManager().beginTransaction()
.replace(R.id.container, mVerticalStepperAdapterDemoFragment).commit();
replaceFragment(mVerticalStepperAdapterDemoFragment);
return true;
case R.id.action_alipay_donate:
if (AlipayZeroSdk.hasInstalledAlipayClient(this)) {
Expand All @@ -98,6 +96,10 @@ public void onClick(DialogInterface dialogInterface, int i) {
}
}

private void replaceFragment(Fragment fragment) {
getSupportFragmentManager().beginTransaction().replace(R.id.container, fragment).commit();
}

private void openWebsite(String url) {
CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder();
builder.setToolbarColor(getResources().getColor(R.color.colorPrimary));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TextView;
import moe.feng.common.stepperview.IStepperViewAdapter;
import moe.feng.common.stepperview.IStepperAdapter;
import moe.feng.common.stepperview.VerticalStepperItemView;
import moe.feng.common.stepperview.VerticalStepperView;
import moe.feng.common.stepperview.demo.R;

public class VerticalStepperAdapterDemoFragment extends Fragment implements IStepperViewAdapter {
public class VerticalStepperAdapterDemoFragment extends Fragment implements IStepperAdapter {

private VerticalStepperView mVerticalStepperView;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import android.view.View;
import android.view.ViewGroup;

public interface IStepperViewAdapter {
public interface IStepperAdapter {

String getTitle(int index);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

interface IStepperView {

IStepperViewAdapter getViewAdapter();
IStepperAdapter getViewAdapter();
int getCurrentStep();

@ColorInt int getNormalColor();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ public void addView(View child, int index, ViewGroup.LayoutParams layoutParams)
}
}

FrameLayout getCustomView() {
return mCustomView;
}

public void removeCustomView() {
mCustomView.removeAllViews();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import moe.feng.common.stepperview.internal.VerticalSpaceItemDecoration;
Expand All @@ -15,7 +16,7 @@ public class VerticalStepperView extends FrameLayout implements IStepperView {
private RecyclerView mListView;
private ItemAdapter mAdapter;

private IStepperViewAdapter mViewAdapter;
private IStepperAdapter mViewAdapter;
private int mCurrentStep = 0;
private boolean mAnimationEnabled;

Expand Down Expand Up @@ -74,7 +75,7 @@ private void prepareListView(Context context) {
addView(mListView, new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
}

public void setViewAdapter(IStepperViewAdapter viewAdapter) {
public void setViewAdapter(IStepperAdapter viewAdapter) {
mViewAdapter = viewAdapter;
mAdapter.notifyDataSetChanged();
}
Expand Down Expand Up @@ -118,7 +119,7 @@ public boolean prevStep() {
}

@Override
public IStepperViewAdapter getViewAdapter() {
public IStepperAdapter getViewAdapter() {
return mViewAdapter;
}

Expand Down Expand Up @@ -193,7 +194,10 @@ public void onBindViewHolder(ItemHolder holder, int position) {
holder.mItemView.setState(VerticalStepperItemView.STATE_SELECTED);
}
holder.mItemView.removeCustomView();
holder.mItemView.addView(getViewAdapter().onCreateCustomView(position, getContext(), holder.mItemView));
View customView = getViewAdapter().onCreateCustomView(position, getContext(), holder.mItemView);
if (customView != null) {
holder.mItemView.addView(customView);
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
import android.content.Context;
import android.view.View;

public abstract class StepperViewAdapter implements IStepperViewAdapter {
public abstract class ViewBasedStepperAdapter implements IStepperAdapter {

private View mViews[];

public StepperViewAdapter() {
public ViewBasedStepperAdapter() {

}

public StepperViewAdapter(View[] views) {
public ViewBasedStepperAdapter(View[] views) {
mViews = views;
}

Expand Down

0 comments on commit 78cc9d8

Please sign in to comment.