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

updates #303

Merged
merged 8 commits into from
Feb 16, 2016
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
5 changes: 4 additions & 1 deletion UltimateRecyclerView/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@
android:label="TestExpandableRV" />
<activity
android:name=".loadmoredemo.DebugLoadMoreActivity"
android:label="DebugLoadMoreActivity" />
android:label="DebugLoadMoreActivity">


</activity>
<activity
android:name=".scrollableobservable.ScrollObservablesActivity"
android:label="ScrollObservablesActivity" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Handler;
import android.support.v4.widget.SwipeRefreshLayout;
import android.os.Bundle;
Expand All @@ -25,7 +26,8 @@
import com.marshalchen.ultimaterecyclerview.UltimateRecyclerView;
import com.marshalchen.ultimaterecyclerview.animators.BaseItemAnimator;
import com.marshalchen.ultimaterecyclerview.animators.*;
import com.marshalchen.ultimaterecyclerview.demo.basicdemo.SimpleAdapter;
import com.marshalchen.ultimaterecyclerview.demo.basicdemo.sectionCommonAdapter;
import com.marshalchen.ultimaterecyclerview.demo.basicdemo.sectionZeroAdapter;
import com.marshalchen.ultimaterecyclerview.demo.modules.FastBinding;
import com.marshalchen.ultimaterecyclerview.itemTouchHelper.SimpleItemTouchHelperCallback;
import com.marshalchen.ultimaterecyclerview.stickyheadersrecyclerview.StickyRecyclerHeadersDecoration;
Expand All @@ -37,7 +39,7 @@
public class MainActivity extends AppCompatActivity implements ActionMode.Callback {

UltimateRecyclerView ultimateRecyclerView;
SimpleAdapter RVAdapter = null;
sectionCommonAdapter RVAdapter = null;
LinearLayoutManager linearLayoutManager;
int moreNum = 2;
private ActionMode actionMode;
Expand All @@ -47,6 +49,7 @@ public class MainActivity extends AppCompatActivity implements ActionMode.Callba

private ItemTouchHelper mItemTouchHelper;


@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Expand All @@ -61,85 +64,40 @@ protected void onCreate(Bundle savedInstanceState) {
ultimateRecyclerView.setHasFixedSize(false);
final List<String> stringList = new ArrayList<>();

stringList.add("111");
stringList.add("aaa");
stringList.add("222");
stringList.add("33");
stringList.add("44");
stringList.add("55");
stringList.add("66");
stringList.add("11771");
RVAdapter = new SimpleAdapter(stringList);
stringList.add("E19");
stringList.add("P32");
stringList.add("G22");
stringList.add("B33");
stringList.add("T44");
stringList.add("R55");
stringList.add("B66");
stringList.add("Q17");

RVAdapter = new sectionCommonAdapter(stringList);

linearLayoutManager = new LinearLayoutManager(this);
ultimateRecyclerView.setLayoutManager(linearLayoutManager);
ultimateRecyclerView.setAdapter(RVAdapter);

StickyRecyclerHeadersDecoration headersDecor = new StickyRecyclerHeadersDecoration(RVAdapter);
ultimateRecyclerView.addItemDecoration(headersDecor);
// ultimateRecyclerView.setEmptyView(getResources().getIdentifier("empty_view","layout",getPackageName()));
// ultimateRecyclerView.showEmptyView();
ultimateRecyclerView.enableLoadmore();

RVAdapter.setCustomLoadMoreView(LayoutInflater.from(this)
.inflate(R.layout.custom_bottom_progressbar, null));

ultimateRecyclerView.setParallaxHeader(getLayoutInflater().inflate(R.layout.parallax_recyclerview_header, ultimateRecyclerView.mRecyclerView, false));
// ultimateRecyclerView.setNormalHeader(getLayoutInflater().inflate(R.layout.parallax_recyclerview_header, ultimateRecyclerView.mRecyclerView, false));
ultimateRecyclerView.setOnParallaxScroll(new UltimateRecyclerView.OnParallaxScroll() {
@Override
public void onParallaxScroll(float percentage, float offset, View parallax) {
Drawable c = toolbar.getBackground();
c.setAlpha(Math.round(127 + percentage * 128));
toolbar.setBackgroundDrawable(c);
}
});
// ultimateRecyclerView.setEmptyView(getResources().getIdentifier("empty_view","layout",getPackageName()));
// ultimateRecyclerView.showEmptyView();
enableLoadMore();
// enableHeader();
// enableParalax();
ultimateRecyclerView.setRecylerViewBackgroundColor(Color.parseColor("#ffffff"));
ultimateRecyclerView.setDefaultOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
RVAdapter.insert(moreNum++ + " Refresh things", 0);
ultimateRecyclerView.setRefreshing(false);
// ultimateRecyclerView.scrollBy(0, -50);
linearLayoutManager.scrollToPosition(0);
// ultimateRecyclerView.setAdapter(RVAdapter);
// RVAdapter.notifyDataSetChanged();
}
}, 1000);
}
});
enableRefreshGoogleMaterialStyle();

ItemTouchHelper.Callback callback = new SimpleItemTouchHelperCallback(RVAdapter);
mItemTouchHelper = new ItemTouchHelper(callback);
mItemTouchHelper.attachToRecyclerView(ultimateRecyclerView.mRecyclerView);
RVAdapter.setOnDragStartListener(new SimpleAdapter.OnStartDragListener() {
RVAdapter.setOnDragStartListener(new sectionZeroAdapter.OnStartDragListener() {
@Override
public void onStartDrag(RecyclerView.ViewHolder viewHolder) {
mItemTouchHelper.startDrag(viewHolder);
}
});

ultimateRecyclerView.setOnLoadMoreListener(new UltimateRecyclerView.OnLoadMoreListener() {
@Override
public void loadMore(int itemsCount, final int maxLastVisiblePosition) {
Handler handler = new Handler();
handler.postDelayed(new Runnable() {
public void run() {
RVAdapter.insert("More " + moreNum++, RVAdapter.getAdapterItemCount());
RVAdapter.insert("More " + moreNum++, RVAdapter.getAdapterItemCount());
RVAdapter.insert("More " + moreNum++, RVAdapter.getAdapterItemCount());
}
}, 1000);
}
});

// ultimateRecyclerView.setDefaultSwipeToRefreshColorScheme(getResources().getColor(android.R.color.holo_blue_bright),
// getResources().getColor(android.R.color.holo_green_light),
// getResources().getColor(android.R.color.holo_orange_light),
// getResources().getColor(android.R.color.holo_red_light));

ultimateRecyclerView.setScrollViewCallbacks(new ObservableScrollViewCallbacks() {
@Override
Expand Down Expand Up @@ -225,14 +183,14 @@ public void onNothingSelected(AdapterView<?> parent) {
findViewById(R.id.add).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
RVAdapter.insert("newly added item", 1);
RVAdapter.insertLast("newly added item");
}
});

findViewById(R.id.del).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
RVAdapter.remove(1);
RVAdapter.removeLast();
}
});

Expand Down Expand Up @@ -271,6 +229,79 @@ public void onClick(View v) {

}



private void enableHeader() {
StickyRecyclerHeadersDecoration headersDecor = new StickyRecyclerHeadersDecoration(RVAdapter);
ultimateRecyclerView.addItemDecoration(headersDecor);
// ultimateRecyclerView.setParallaxHeader(getLayoutInflater().inflate(R.layout.parallax_recyclerview_header, ultimateRecyclerView.mRecyclerView, false));
ultimateRecyclerView.setNormalHeader(getLayoutInflater().inflate(R.layout.parallax_recyclerview_header, ultimateRecyclerView.mRecyclerView, false));

}

private void enableParalax() {
ultimateRecyclerView.setOnParallaxScroll(new UltimateRecyclerView.OnParallaxScroll() {
@Override
public void onParallaxScroll(float percentage, float offset, View parallax) {
Drawable c = toolbar.getBackground();
c.setAlpha(Math.round(127 + percentage * 128));
toolbar.setBackgroundDrawable(c);
}
});
}

private void enableLoadMore() {
ultimateRecyclerView.enableLoadmore();
RVAdapter.setCustomLoadMoreView(LayoutInflater.from(this).inflate(R.layout.custom_bottom_progressbar, null));
ultimateRecyclerView.setOnLoadMoreListener(new UltimateRecyclerView.OnLoadMoreListener() {
@Override
public void loadMore(int itemsCount, final int maxLastVisiblePosition) {
Handler handler = new Handler();
handler.postDelayed(new Runnable() {
public void run() {
RVAdapter.insertLast("more" + moreNum++);
RVAdapter.insertLast("more" + moreNum++);
RVAdapter.insertLast("more" + moreNum++);
}
}, 1000);
}
});
}

private void enableRefreshGoogleMaterialStyle() {
ultimateRecyclerView.setDefaultOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
moreNum++;
RVAdapter.insertLast(moreNum + " Refresh things");
ultimateRecyclerView.setRefreshing(false);
// ultimateRecyclerView.scrollBy(0, -50);
linearLayoutManager.scrollToPosition(0);
// ultimateRecyclerView.setAdapter(RVAdapter);
// RVAdapter.notifyDataSetChanged();
}
}, 1000);
}
});

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
ultimateRecyclerView.setDefaultSwipeToRefreshColorScheme(
getColor(android.R.color.holo_orange_light),
getColor(android.R.color.holo_orange_dark),
getColor(android.R.color.holo_red_dark),
getColor(android.R.color.holo_red_light));
} else {
ultimateRecyclerView.setDefaultSwipeToRefreshColorScheme(
getResources().getColor(android.R.color.holo_orange_light),
getResources().getColor(android.R.color.holo_orange_dark),
getResources().getColor(android.R.color.holo_red_dark),
getResources().getColor(android.R.color.holo_red_light));
}
}

private void toggleSelection(int position) {
RVAdapter.toggleSelection(position);
actionMode.setTitle("Selected " + "1");
Expand Down
Loading