diff --git a/UltimateRecyclerView/app/src/main/AndroidManifest.xml b/UltimateRecyclerView/app/src/main/AndroidManifest.xml
index 31fbf6f4..242143f8 100644
--- a/UltimateRecyclerView/app/src/main/AndroidManifest.xml
+++ b/UltimateRecyclerView/app/src/main/AndroidManifest.xml
@@ -37,10 +37,10 @@
android:name=".loadmoredemo.PullToRefreshActivity"
android:label="CustomSwipeToRefreshRefreshActivity" />
li = new ArrayList();
- li.add("i " + moreNum++);
- li.add("i " + moreNum++);
- li.add("i " + moreNum++);
+ li.add("No. ====" + itemsCount + "=======");
+ SampleDataboxset.genItems(10, li);
simpleRecyclerViewAdapter.insert(li);
}
}, 1000);
@@ -99,7 +95,7 @@ public void run() {
}
private void enableEmptyView() {
- ultimateRecyclerView.setEmptyView(R.layout.empty_view, UltimateRecyclerView.EMPTY_KEEP_HEADER_AND_LOARMORE);
+ ultimateRecyclerView.setEmptyView(R.layout.empty_view, UltimateRecyclerView.EMPTY_KEEP_HEADER_AND_LOARMORE, UltimateRecyclerView.STARTWITH_ONLINE_ITEMS);
}
private void enableClick() {
@@ -139,12 +135,7 @@ protected void onCreate(Bundle savedInstanceState) {
/**
* working example 2 with multiple called Adviews
*/
- simpleRecyclerViewAdapter = new admobdfpadapter(createadmob(), 11, SampleDataboxset.newListFromGen(), new AdmobAdapter.AdviewListener() {
- @Override
- public AdView onGenerateAdview() {
- return createadmob();
- }
- });
+ simpleRecyclerViewAdapter = new ZeroStickyAdvertistmentAdapter(createadmob(), SampleDataboxset.newListFromGen());
linearLayoutManager = new LinearLayoutManager(this);
ultimateRecyclerView.setLayoutManager(linearLayoutManager);
ultimateRecyclerView.setAdapter(simpleRecyclerViewAdapter);
diff --git a/UltimateRecyclerView/app/src/main/java/com/marshalchen/ultimaterecyclerview/demo/admobdemo/TestAdvancedAdmobActivity.java b/UltimateRecyclerView/app/src/main/java/com/marshalchen/ultimaterecyclerview/demo/admobdemo/TestAdvancedAdmobActivity.java
index 050415c6..eefdd14d 100644
--- a/UltimateRecyclerView/app/src/main/java/com/marshalchen/ultimaterecyclerview/demo/admobdemo/TestAdvancedAdmobActivity.java
+++ b/UltimateRecyclerView/app/src/main/java/com/marshalchen/ultimaterecyclerview/demo/admobdemo/TestAdvancedAdmobActivity.java
@@ -6,6 +6,7 @@
import android.support.annotation.NonNull;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
+import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;
import android.util.DisplayMetrics;
import android.view.View;
@@ -21,14 +22,13 @@
import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.AdSize;
import com.google.android.gms.ads.AdView;
-import com.marshalchen.ultimaterecyclerview.AdmobAdapter;
+import com.marshalchen.ultimaterecyclerview.quickAdapter.AdmobAdapter;
import com.marshalchen.ultimaterecyclerview.URLogs;
import com.marshalchen.ultimaterecyclerview.UltimateRecyclerView;
import com.marshalchen.ultimaterecyclerview.UltimateRecyclerviewViewHolder;
import com.marshalchen.ultimaterecyclerview.demo.R;
import com.marshalchen.ultimaterecyclerview.demo.modules.SampleDataboxset;
import com.marshalchen.ultimaterecyclerview.quickAdapter.easyRegularAdapter;
-import com.marshalchen.ultimaterecyclerview.quickAdapter.simpleAdmobAdapter;
import com.marshalchen.ultimaterecyclerview.quickAdapter.BiAdAdapterSwitcher;
import com.marshalchen.ultimaterecyclerview.ui.AdGoogleDisplaySupport;
@@ -45,16 +45,12 @@ public class TestAdvancedAdmobActivity extends AppCompatActivity {
private Toolbar toolbar;
private BiAdAdapterSwitcher bi_sw;
- public static class adap extends simpleAdmobAdapter {
+ public static class adap extends AdmobAdapter {
- public adap(RelativeLayout v, boolean insertOnce, int setInterval, List L, AdviewListener listener) {
- super(v, insertOnce, setInterval, L, listener);
+ public adap(RelativeLayout v, List L) {
+ super(v, false, 13, L, null);
}
- @Override
- protected void withBindHolder(VMoler var1, String var2, int var3) {
- bindthisInhere(var1, var2, var3);
- }
@Override
protected int getNormalLayoutResId() {
@@ -63,13 +59,25 @@ protected int getNormalLayoutResId() {
@Override
- protected VMoler newViewHolder(View mview) {
- return new VMoler(mview);
+ protected SingleItemHolder newViewHolder(View mview) {
+ return new SingleItemHolder(mview, VIEW_TYPES.NORMAL);
+ }
+
+ /**
+ * binding normal view holder
+ *
+ * @param holder holder class
+ * @param data data
+ * @param position position
+ */
+ @Override
+ protected void withBindHolder(SingleItemHolder holder, String data, int position) {
+ bindthisInhere(holder, data, position);
}
}
- public static class regular extends easyRegularAdapter {
+ public static class regular extends easyRegularAdapter {
public regular(List list) {
super(list);
@@ -81,17 +89,17 @@ protected int getNormalLayoutResId() {
}
@Override
- protected VMoler newViewHolder(View view) {
- return new VMoler(view);
+ protected SingleItemHolder newViewHolder(View view) {
+ return new SingleItemHolder(view, VIEW_TYPES.NORMAL);
}
@Override
- protected void withBindHolder(VMoler holderm, String data, int position) {
+ protected void withBindHolder(SingleItemHolder holderm, String data, int position) {
bindthisInhere(holderm, data, position);
}
}
- private static void bindthisInhere(VMoler d, String data, int pos) {
+ private static void bindthisInhere(SingleItemHolder d, String data, int pos) {
d.textViewSample.setText(data);
d.num.setText("@:" + pos);
}
@@ -154,45 +162,11 @@ public void onAdLoaded() {
}
- public static class VMoler extends UltimateRecyclerviewViewHolder implements
- View.OnClickListener, View.OnLongClickListener {
- public TextView textViewSample, num;
- public ImageView imageViewSample;
- public ProgressBar progressBarSample;
-
- public VMoler(View itemView) {
- super(itemView);
- textViewSample = (TextView) itemView.findViewById(R.id.textview);
- num = (TextView) itemView.findViewById(R.id.numb_coun);
- imageViewSample = (ImageView) itemView.findViewById(R.id.imageview);
- progressBarSample = (ProgressBar) itemView.findViewById(R.id.progressbar);
- progressBarSample.setVisibility(View.GONE);
- }
-
- @Override
- public void onClick(@NonNull View v) {
- URLogs.d(textViewSample.getText() + " clicked!");
- }
-
- @Override
- public boolean onLongClick(@NonNull View v) {
- URLogs.d(textViewSample.getText() + " long clicked!");
- return true;
- }
- }
-
-
/**
* example 1 implementation of the switch view
*/
private BiAdAdapterSwitcher imple_switch_view(final UltimateRecyclerView rv) {
- final adap adp1 = new adap(createadmob(), false, 10, new ArrayList(),
- new AdmobAdapter.AdviewListener() {
- @Override
- public RelativeLayout onGenerateAdview() {
- return createadmob();
- }
- });
+ final adap adp1 = new adap(createadmob(), new ArrayList());
final regular adp2 = new regular(new ArrayList());
final BiAdAdapterSwitcher switchable = new BiAdAdapterSwitcher(rv, adp2, adp1);
return switchable;
diff --git a/UltimateRecyclerView/app/src/main/java/com/marshalchen/ultimaterecyclerview/demo/admobdemo/ZeroStickyAdvertistmentAdapter.java b/UltimateRecyclerView/app/src/main/java/com/marshalchen/ultimaterecyclerview/demo/admobdemo/ZeroStickyAdvertistmentAdapter.java
new file mode 100644
index 00000000..8a658638
--- /dev/null
+++ b/UltimateRecyclerView/app/src/main/java/com/marshalchen/ultimaterecyclerview/demo/admobdemo/ZeroStickyAdvertistmentAdapter.java
@@ -0,0 +1,81 @@
+package com.marshalchen.ultimaterecyclerview.demo.admobdemo;
+
+import android.graphics.Color;
+import android.support.v7.widget.RecyclerView;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.TextView;
+
+import com.google.android.gms.ads.AdView;
+import com.marshalchen.ultimaterecyclerview.quickAdapter.AdmobAdapter;
+import com.marshalchen.ultimaterecyclerview.URLogs;
+import com.marshalchen.ultimaterecyclerview.UltimateRecyclerviewViewHolder;
+import com.marshalchen.ultimaterecyclerview.demo.R;
+import com.marshalchen.ultimaterecyclerview.demo.basicdemo.binderCommon;
+
+import java.util.List;
+
+/**
+ * Created by hesk on 20/5/15.
+ */
+public class ZeroStickyAdvertistmentAdapter extends AdmobAdapter {
+
+
+ public ZeroStickyAdvertistmentAdapter(AdView v, List f) {
+ super(v, false, 12, f);
+ }
+
+ public ZeroStickyAdvertistmentAdapter(AdView v, int e, List f, AdviewListener listener) {
+ super(v, false, e, f, listener);
+ }
+
+ @Override
+ protected int getNormalLayoutResId() {
+ return R.layout.recycler_view_adapter;
+ }
+
+ @Override
+ protected SingleItemCommonLayout newViewHolder(View mview) {
+ return new SingleItemCommonLayout(mview, VIEW_TYPES.NORMAL);
+ }
+
+
+ /**
+ * binding normal view holder
+ *
+ * @param holder holder class
+ * @param data data
+ * @param position position
+ */
+ @Override
+ protected void withBindHolder(SingleItemCommonLayout holder, String data, int position) {
+ holder.textViewSample.setText(data);
+ }
+
+ @Override
+ public void onBindHeaderViewHolder(RecyclerView.ViewHolder viewHolder, int i) {
+ // TextView textView = (TextView) viewHolder.itemView;
+ // textView.setText(String.valueOf(getItem(i).charAt(0)));
+ // viewHolder.itemView.setBackgroundColor(Color.parseColor("#AA70DB93"));
+ }
+
+/*
+
+ @Override
+ public long getHeaderId(int position) {
+ if (position == 0) {
+ return -1;
+ } else {
+ return getItem(position).charAt(0);
+ }
+ }
+*/
+
+
+ @Override
+ public UltimateRecyclerviewViewHolder getViewHolder(View view) {
+ return new UltimateRecyclerviewViewHolder(view);
+ }
+
+}
diff --git a/UltimateRecyclerView/app/src/main/java/com/marshalchen/ultimaterecyclerview/demo/admobdemo/admobdfpadapter.java b/UltimateRecyclerView/app/src/main/java/com/marshalchen/ultimaterecyclerview/demo/admobdemo/admobdfpadapter.java
deleted file mode 100644
index 4ba4a7ce..00000000
--- a/UltimateRecyclerView/app/src/main/java/com/marshalchen/ultimaterecyclerview/demo/admobdemo/admobdfpadapter.java
+++ /dev/null
@@ -1,107 +0,0 @@
-package com.marshalchen.ultimaterecyclerview.demo.admobdemo;
-
-import android.graphics.Color;
-import android.support.v7.widget.RecyclerView;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.ImageView;
-import android.widget.ListView;
-import android.widget.TextView;
-
-import com.google.android.gms.ads.AdView;
-import com.marshalchen.ultimaterecyclerview.AdmobAdapter;
-import com.marshalchen.ultimaterecyclerview.URLogs;
-import com.marshalchen.ultimaterecyclerview.UltimateRecyclerviewViewHolder;
-import com.marshalchen.ultimaterecyclerview.demo.R;
-import com.marshalchen.ultimaterecyclerview.demo.basicdemo.binderCommon;
-
-import java.util.List;
-
-/**
- * Created by hesk on 20/5/15.
- */
-public class admobdfpadapter extends AdmobAdapter {
- public admobdfpadapter(AdView v, int e, List f) {
- super(v, false, e, f);
- }
-
- public admobdfpadapter(AdView v, int e, List f, AdviewListener listener) {
- super(v, false, e, f, listener);
- }
-
-
- @Override
- protected int getNormalLayoutResId() {
- return R.layout.recycler_view_adapter;
- }
-
- @Override
- protected binderCommon newViewHolder(View mview) {
- return new binderCommon(mview, true);
- }
-
- /**
- * no sticky header
- *
- * @param position pos
- * @return none
- */
- @Override
- public long generateHeaderId(int position) {
- URLogs.d("position--" + position + " " + getItem(position));
- /* if (getItem(position).length() > 0)
- return getItem(position).charAt(0);
- else
- */
- return -1;
- }
-
-
- @Override
- public void onBindViewHolder(UltimateRecyclerviewViewHolder holder, int position) {
- if (onActionToBindData(position, list)) {
- ((binderCommon) holder).textViewSample.setText((String) list.get(getDataArrayPosition(position)));
- }
- }
-
-
- @Override
- public RecyclerView.ViewHolder onCreateHeaderViewHolder(ViewGroup viewGroup) {
- View view = LayoutInflater.from(viewGroup.getContext())
- .inflate(R.layout.stick_header_item, viewGroup, false);
- return new RecyclerView.ViewHolder(view) {
- };
- }
-
- @Override
- public void onBindHeaderViewHolder(RecyclerView.ViewHolder viewHolder, int i) {
- TextView textView = (TextView) viewHolder.itemView;
- textView.setText(String.valueOf(getItem(i).charAt(0)));
- viewHolder.itemView.setBackgroundColor(Color.parseColor("#AA70DB93"));
- }
-
- public String getItem(int position) {
- return (String) super.getItem(position);
- }
-
-
- @Override
- public long getHeaderId(int position) {
- if (position == 0) {
- return -1;
- } else {
- return getItem(position).charAt(0);
- }
- }
-
-
- @Override
- public UltimateRecyclerviewViewHolder getViewHolder(View view) {
- return new UltimateRecyclerviewViewHolder(view);
- }
-
- public void swapPositions(int from, int to) {
- swapPositions(list, from, to);
- }
-}
diff --git a/UltimateRecyclerView/app/src/main/java/com/marshalchen/ultimaterecyclerview/demo/expandemo/TestExpandableRV.java b/UltimateRecyclerView/app/src/main/java/com/marshalchen/ultimaterecyclerview/demo/expandemo/TestExpandableRV.java
index 6bc623d0..18a7468b 100644
--- a/UltimateRecyclerView/app/src/main/java/com/marshalchen/ultimaterecyclerview/demo/expandemo/TestExpandableRV.java
+++ b/UltimateRecyclerView/app/src/main/java/com/marshalchen/ultimaterecyclerview/demo/expandemo/TestExpandableRV.java
@@ -93,11 +93,6 @@ private void toggleSelection(int position) {
actionMode.setTitle("Selected " + "1");
}
- @Override
- protected void onDestroy() {
- super.onDestroy();
- }
-
public int getScreenHeight() {
return findViewById(android.R.id.content).getHeight();
}
diff --git a/UltimateRecyclerView/app/src/main/java/com/marshalchen/ultimaterecyclerview/demo/loadmoredemo/BasicFunctions.java b/UltimateRecyclerView/app/src/main/java/com/marshalchen/ultimaterecyclerview/demo/loadmoredemo/BasicFunctions.java
index 27a0b5e0..58f0fc8f 100644
--- a/UltimateRecyclerView/app/src/main/java/com/marshalchen/ultimaterecyclerview/demo/loadmoredemo/BasicFunctions.java
+++ b/UltimateRecyclerView/app/src/main/java/com/marshalchen/ultimaterecyclerview/demo/loadmoredemo/BasicFunctions.java
@@ -1,7 +1,5 @@
package com.marshalchen.ultimaterecyclerview.demo.loadmoredemo;
-import android.content.Context;
-import android.content.Intent;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.os.Handler;
@@ -30,35 +28,6 @@
* Created by hesk on 19/2/16.
*/
public abstract class BasicFunctions extends AppCompatActivity {
- enum Route {
- CUSTOM_PULL_HEADER("Custom Pull", PullToRefreshActivity.class),
- LOADMORE_TEST("No Header", DNoHeaderLoadMoreActivity.class),
- LOADMORE_HEADER("Header Pallx", DebugLoadMoreActivity.class),;
-
- private String name;
- private Class> clazzna;
-
- Route(String name, Class> clazz) {
- this.name = name;
- this.clazzna = clazz;
- }
-
- public Route getAnimator() {
-
- return this;
- }
-
-
- public String getNameDisplay() {
- return name;
- }
-
- public void start(final Context ctx) {
- Intent intent = new Intent(ctx, clazzna);
- intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- ctx.startActivity(intent);
- }
- }
protected UltimateRecyclerView ultimateRecyclerView;
diff --git a/UltimateRecyclerView/app/src/main/java/com/marshalchen/ultimaterecyclerview/demo/loadmoredemo/DNoHeaderLoadMoreActivity.java b/UltimateRecyclerView/app/src/main/java/com/marshalchen/ultimaterecyclerview/demo/loadmoredemo/DebugNoHeaderLoadMoreActivity.java
similarity index 97%
rename from UltimateRecyclerView/app/src/main/java/com/marshalchen/ultimaterecyclerview/demo/loadmoredemo/DNoHeaderLoadMoreActivity.java
rename to UltimateRecyclerView/app/src/main/java/com/marshalchen/ultimaterecyclerview/demo/loadmoredemo/DebugNoHeaderLoadMoreActivity.java
index d42ffb89..12e184e9 100644
--- a/UltimateRecyclerView/app/src/main/java/com/marshalchen/ultimaterecyclerview/demo/loadmoredemo/DNoHeaderLoadMoreActivity.java
+++ b/UltimateRecyclerView/app/src/main/java/com/marshalchen/ultimaterecyclerview/demo/loadmoredemo/DebugNoHeaderLoadMoreActivity.java
@@ -14,7 +14,7 @@
/**
* Created by hesk on 19/2/16.
*/
-public class DNoHeaderLoadMoreActivity extends BasicFunctions {
+public class DebugNoHeaderLoadMoreActivity extends BasicFunctions {
private sectionZeroAdapter simpleRecyclerViewAdapter = null;
@Override
diff --git a/UltimateRecyclerView/app/src/main/java/com/marshalchen/ultimaterecyclerview/demo/loadmoredemo/Route.java b/UltimateRecyclerView/app/src/main/java/com/marshalchen/ultimaterecyclerview/demo/loadmoredemo/Route.java
new file mode 100644
index 00000000..2d84c3de
--- /dev/null
+++ b/UltimateRecyclerView/app/src/main/java/com/marshalchen/ultimaterecyclerview/demo/loadmoredemo/Route.java
@@ -0,0 +1,37 @@
+package com.marshalchen.ultimaterecyclerview.demo.loadmoredemo;
+
+import android.content.Context;
+import android.content.Intent;
+
+/**
+ * Created by hesk on 24/2/16.
+ */
+public enum Route {
+ CUSTOM_PULL_HEADER("Custom Pull", PullToRefreshActivity.class),
+ LOADMORE_TEST("No Header", DebugNoHeaderLoadMoreActivity.class),
+ LOADMORE_HEADER("Header Pallx", DebugLoadMoreActivity.class),;
+
+ private String name;
+ private Class> clazzna;
+
+ Route(String name, Class> clazz) {
+ this.name = name;
+ this.clazzna = clazz;
+ }
+
+ public Route getAnimator() {
+
+ return this;
+ }
+
+
+ public String getNameDisplay() {
+ return name;
+ }
+
+ public void start(final Context ctx) {
+ Intent intent = new Intent(ctx, clazzna);
+ intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+ ctx.startActivity(intent);
+ }
+}
diff --git a/UltimateRecyclerView/app/src/main/java/com/marshalchen/ultimaterecyclerview/demo/modules/FastBinding.java b/UltimateRecyclerView/app/src/main/java/com/marshalchen/ultimaterecyclerview/demo/modules/FastBinding.java
index 77d7ee1e..f7a8b95c 100644
--- a/UltimateRecyclerView/app/src/main/java/com/marshalchen/ultimaterecyclerview/demo/modules/FastBinding.java
+++ b/UltimateRecyclerView/app/src/main/java/com/marshalchen/ultimaterecyclerview/demo/modules/FastBinding.java
@@ -8,7 +8,7 @@
import com.marshalchen.ultimaterecyclerview.demo.griddemo.GridLayoutRVTest;
import com.marshalchen.ultimaterecyclerview.demo.multiitemdemo.MultiViewTypesActivity;
import com.marshalchen.ultimaterecyclerview.demo.R;
-import com.marshalchen.ultimaterecyclerview.demo.admobdemo.TestAdMob;
+import com.marshalchen.ultimaterecyclerview.demo.admobdemo.TestAdMobClassicActivity;
import com.marshalchen.ultimaterecyclerview.demo.loadmoredemo.DebugLoadMoreActivity;
import com.marshalchen.ultimaterecyclerview.demo.admobdemo.TestAdvancedAdmobActivity;
import com.marshalchen.ultimaterecyclerview.demo.scrollableobservable.ScrollObservablesActivity;
@@ -20,7 +20,7 @@
public enum FastBinding {
action_bottom(R.id.action_bottom, MultiViewTypesActivity.class),
action_custom(R.id.action_custom, PullToRefreshActivity.class),
- admob(R.id.admob, TestAdMob.class),
+ admob(R.id.admob, TestAdMobClassicActivity.class),
scrollactivity(R.id.scrollactivity, ScrollObservablesActivity.class),
// swipe_and_drag(R.id.swipe_and_drag, SwipeListViewExampleActivity.class),
debug_load_more(R.id.debug_load_more, DebugLoadMoreActivity.class),
diff --git a/UltimateRecyclerView/app/src/main/java/com/marshalchen/ultimaterecyclerview/demo/modules/SampleDataboxset.java b/UltimateRecyclerView/app/src/main/java/com/marshalchen/ultimaterecyclerview/demo/modules/SampleDataboxset.java
index b0b1c1df..5e217a35 100644
--- a/UltimateRecyclerView/app/src/main/java/com/marshalchen/ultimaterecyclerview/demo/modules/SampleDataboxset.java
+++ b/UltimateRecyclerView/app/src/main/java/com/marshalchen/ultimaterecyclerview/demo/modules/SampleDataboxset.java
@@ -1,7 +1,7 @@
package com.marshalchen.ultimaterecyclerview.demo.modules;
import com.marshalchen.ultimaterecyclerview.demo.R;
-import com.marshalchen.ultimaterecyclerview.demo.admobdemo.admobdfpadapter;
+import com.marshalchen.ultimaterecyclerview.demo.admobdemo.ZeroStickyAdvertistmentAdapter;
import com.marshalchen.ultimaterecyclerview.demo.basicdemo.sectionZeroAdapter;
import java.util.ArrayList;
@@ -45,10 +45,10 @@ public static List newListFromGen() {
return s;
}
- private static void genItems(final int howmany, final List list) {
+ public static void genItems(final int howmany, final List list) {
for (int i = 0; i < howmany; i++) {
Random e = new Random();
- list.add(girl_name[e.nextInt(girl_name.length)]);
+ list.add("No." + i + " " + girl_name[e.nextInt(girl_name.length)]);
}
}
@@ -86,7 +86,7 @@ public static int getGirlImageRandom() {
return res[e.nextInt(res.length)];
}
- public static void insertMore(admobdfpadapter sd, int howmany) {
+ public static void insertMore(ZeroStickyAdvertistmentAdapter sd, int howmany) {
for (int i = 0; i < howmany; i++) {
sd.insertFirst("More items " + i);
}
diff --git a/UltimateRecyclerView/ultimaterecyclerview/src/main/java/com/marshalchen/ultimaterecyclerview/AdmobAdapter.java b/UltimateRecyclerView/ultimaterecyclerview/src/main/java/com/marshalchen/ultimaterecyclerview/AdmobAdapter.java
deleted file mode 100644
index f450b096..00000000
--- a/UltimateRecyclerView/ultimaterecyclerview/src/main/java/com/marshalchen/ultimaterecyclerview/AdmobAdapter.java
+++ /dev/null
@@ -1,400 +0,0 @@
-package com.marshalchen.ultimaterecyclerview;
-
-import android.util.Log;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-
-import java.util.List;
-
-/**
- * Enhanced Google Admob implementation
- * Created by hesk on 20/5/15.
- */
-public abstract class AdmobAdapter extends UltimateViewAdapter {
- public interface AdviewListener {
- Adv onGenerateAdview();
- }
-
- protected final Adv advertise_view;
- /**
- * There is an AD between the amount of the data items. adfrequency is known as the amount.
- */
- protected int adfrequency;
- /**
- * The ad is only insert once and no more.
- */
- protected boolean once;
- protected List list;
- protected AdviewListener adviewlistener;
-
- public static final int POSITION_ON_AD = -1;
-
- /**
- * This is the enhanced listview injection model that will be able to work with Googlge Admob, DoubleClick, and
- * related custom cell injection on the fly. It provides two specific options for the view to be taken place.
- * While insertOnce=true will increase the performance and false will slow down a little bit on the performance but it is insignificant.
- *
- * @param adview The AD mob view
- * @param insertOnce only insert once and hold into the adapter object, that means the ad will only shown once in the list view
- * @param setInterval the order of item to show the ad. if @insertOnce=false the ad will show on interval bases.
- * @param L the data source
- */
- public AdmobAdapter(Adv adview, boolean insertOnce, int setInterval, List L) {
- this(adview, insertOnce, setInterval, L, null);
- }
-
-
- /**
- * This is same to the above method
- *
- * @param adview The AD mob view
- * @param insertOnce only insert once and hold into the adapter object, that means the ad will only shown once in the list view
- * @param setInterval the order of item to show the ad. if @insertOnce=false the ad will show on interval bases.
- * @param L the data source
- * @param listener The listener for the admob cell to reveal when the cell is close to appear on the screen
- */
- public AdmobAdapter(Adv adview, boolean insertOnce, int setInterval, List L, AdviewListener listener) {
- advertise_view = adview;
- // setHasStableIds(true);
-
- /**
- * Disable focus for sub-views of the AdView to avoid problems with
- * trackpad navigation of the list.
- */
- for (int i = 0; i < advertise_view.getChildCount(); i++) {
- advertise_view.getChildAt(i).setFocusable(false);
- }
- advertise_view.setFocusable(false);
-
- once = insertOnce;
- adfrequency = setInterval + 1;
- /* registerAdapterDataObserver(new RecyclerView.AdapterDataObserver() {
- @Override
- public void onChanged() {
- super.onChanged();
- notifyDataSetChanged();
- }
- });*/
- list = L;
- }
-
- /**
- * the layout id for the normal data
- *
- * @return the ID
- */
- protected abstract int getNormalLayoutResId();
-
- /**
- * create a new view holder for data binding
- *
- * @param mview the view layout with resource initialized
- * @return the view type
- */
- // @Deprecated
- protected abstract V newViewHolder(View mview);
-
- /*
- @Override
- public V getViewHolder(View view) { return }
- */
- public static class AdHolder extends UltimateRecyclerviewViewHolder {
- public AdHolder(AdviewListener adviewlistener) {
- super(adviewlistener.onGenerateAdview());
- }
- }
-
- /**
- * only on the first creation
- *
- * @param parent parent resource
- * @return the UtimateView
- */
- @Override
- public UltimateRecyclerviewViewHolder onCreateViewHolder(ViewGroup parent) {
- View v = LayoutInflater.from(parent.getContext()).inflate(getNormalLayoutResId(), parent, false);
- return newViewHolder(v);
- }
-
- @Override
- public UltimateRecyclerviewViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
- // if (parent == null)
- // Log.d("getItemCountE2", "parent is null on viewType: " + viewType);
- if (viewType == VIEW_TYPES.ADVIEW) {
- UltimateRecyclerviewViewHolder adview_holder;
- if (adviewlistener != null) {
- try {
- adview_holder = new AdHolder(adviewlistener);
- } catch (NullPointerException e) {
- adview_holder = new UltimateRecyclerviewViewHolder(advertise_view);
- } catch (Exception e) {
- adview_holder = new UltimateRecyclerviewViewHolder(advertise_view);
- }
- } else {
- adview_holder = new UltimateRecyclerviewViewHolder(advertise_view);
- }
- return adview_holder;
- } else {
- return super.onCreateViewHolder(parent, viewType);
- }
- }
-
-/* @Override
- public int getItemViewType(int position) {
- int type = super.getItemViewType(position);
- if (type == VIEW_TYPES.NORMAL) {
- if (!once) {
- if (position > 0 && isOnAdView(position)) {
- return VIEW_TYPES.ADVIEW;
- } else return type;
- } else {
- if (isOnAdView(position) && adfrequency == position + 1) {
- return VIEW_TYPES.ADVIEW;
- } else return type;
- }
- } else {
- return type;
- }
- }*/
-
- /**
- * Returns the number of items in the adapter bound to the parent RecyclerView.
- *
- * @return The number of items in the bound adapter
- */
- @Override
- public int getAdapterItemCount() {
- return list.size();
- }
-
- /**
- * get the display item count
- *
- * @return the final items for display
- */
- @Override
- public int getItemCount() {
- final int base = super.getItemCount();
- if (once) {
- if (adfrequency > 0) {
- return base + 1;
- } else {
- return base;
- }
- } else {
- final int check_sum = (adfrequency > 0 ? atAdPos(base) : 0) + base;
- Log.d("getItemCountE2", check_sum + "");
- return check_sum;
- }
- }
-
- public void insert(List new_data) {
- insertInternal(new_data, list);
- }
-
- public void removeAll() {
- clearInternal(list);
- }
-
- public void insertFirst(T item) {
- insertFirstInternal(list, item);
- }
-
- public void insertLast(T item) {
- insertLastInternal(list, item);
- }
-
- public void removeLast() {
- removeLastInternal(list);
- }
-
- public void removeFirst() {
- removeFirstInternal(list);
- }
-
- public void removeAt(int position) {
- removeInternal(list, position);
- }
-
- /* @Override
-
- public final void insert(final List list, final T object, final int first_insert_data_pos) {
- try {
- list.add(first_insert_data_pos, object);
- final int offset = getReverseDataArrayPosition(first_insert_data_pos);
- if (isOnAdView(offset) && first_insert_data_pos > 0) {
- notifyItemRangeChanged(offset, offset + 1);
- } else {
- notifyItemInserted(offset);
- }
- } catch (ArrayIndexOutOfBoundsException e) {
- Log.d("admobErrorMr3", e.getMessage());
- } catch (IndexOutOfBoundsException e) {
- Log.d("admobErrorMr3", e.getMessage());
- }
- }*/
-
- /**
- * to insert data with a new list
- *
- * @param original_list the original list
- * @param new_list the list that items are in it
- * @param first_insert_pos the first item
- * @param the list type holder
- */
- /* public void insert(final List original_list, final List new_list, final int first_insert_pos) {
- try {
- original_list.addAll(first_insert_pos, new_list);
- final int view_pos_1 = getReverseDataArrayPosition(first_insert_pos);
- final int view_pos_2 = getReverseDataArrayPosition(first_insert_pos + new_list.size());
- notifyItemRangeChanged(view_pos_1, view_pos_2);
- } catch (ArrayIndexOutOfBoundsException e) {
- Log.d("admobErrorMr3", e.getMessage());
- } catch (IndexOutOfBoundsException e) {
- Log.d("admobErrorMr3", e.getMessage());
- }
- }*/
-
- /**
- * default insert that will append the object at the end
- *
- * @param object data object
- */
-
-
- /**
- * Todo: need to resolve this problem when it crash
- * Remove a item of the list of the adapter
- *
- * @param list the data source
- * @param position with the position on the list
- */
- /* public void remove(List> list, int position) {
- try {
- if (list.size() > 0 && position < list.size()) {
- list.remove(position);
- final int offset = getReverseDataArrayPosition(position);
- notifyItemRemoved(offset);
- if (offset > 1 && isOnAdView(offset) && position > 0) {
- notifyItemRemoved(offset - 1);
- }
- Log.d("normaladmob", "offset final: " + offset);
- } else {
- throw new ArrayIndexOutOfBoundsException("no data or the remove position is not exist p:" + position + ", list size:" + list.size());
- }
- } catch (ArrayIndexOutOfBoundsException e) {
- Log.d("admobError r1", e.getMessage());
- } catch (IndexOutOfBoundsException e) {
- Log.d("admobError r2", e.getMessage());
- }
-
- }*/
-
- /**
- * this is the mask to calculate whether the position of the item should be proceeded with data binding
- *
- * @param pos machine loaded position in int
- * @param list the source data list
- * @return the decision to tell whether the data binding should be taken place
- */
- protected boolean onActionToBindData(final int pos, final List list) {
- int getType = getItemViewType(pos);
- if (pos < getItemCount() && getType == VIEW_TYPES.NORMAL)
- if (customHeaderView != null) {
- return pos <= list.size() && pos > 0;
- } else {
- return pos < list.size();
- }
- else {
- return false;
- }
- }
-
-
- protected T getItem(int pos) {
- return list.get(getDataArrayPosition(pos));
- }
-
- /**
- * data binding related position shifting
- *
- * @param pos machine loaded position in int
- * @return the final confirmed position for data binding
- */
- protected int getDataArrayPosition(final int pos) {
- int shift = 0;
- if (customHeaderView != null) shift--;
- if (adfrequency > 0) {
- if (once) {
- if (pos >= adfrequency) shift--;
- } else {
- shift -= atAdPos(pos);
- }
- }
- return pos + shift;
- }
-
- /**
- * this is the {getDataArrayPosition} reverse from data position to layout position
- *
- * @param dataPos position on the data list
- * @return offset
- */
- protected int getReverseDataArrayPosition(final int dataPos) {
- int shift = 0;
- if (customHeaderView != null) shift++;
- if (adfrequency > 0) {
- if (once) {
- if (dataPos >= adfrequency) shift++;
- } else {
- shift += atAdPos(dataPos);
- }
- }
- return dataPos + shift;
- }
-
- /**
- * indicate if the touch position is at the Adview
- *
- * @param pos in raw
- * @return in raw
- */
- @Override
- protected boolean isOnAdView(int pos) {
- final int zero_for_admob_selection = (pos + 1) % adfrequency;
- return zero_for_admob_selection == 0;
- }
-
- /**
- * the API access for adview indication
- *
- * @param pos position to be final
- * @return bool
- */
- public final boolean isPosOnAdView(final int pos) {
- return isOnAdView(pos);
- }
-
- /**
- * to display the accumulator for the Ad position
- *
- * @param pos raw touch position
- * @return the placement for the ad position
- */
- public int atAdPos(final int pos) {
- final int take_int = (int) Math.floor((pos + 1) / adfrequency);
- Log.d("atAdPosE2", take_int + "");
- return take_int;
- }
-
- /**
- * for external shift number adjustment
- *
- * @param pos initial number
- * @return the number
- */
- public int getFinalShiftPosition(int pos) {
- return getDataArrayPosition(pos);
- }
-}
diff --git a/UltimateRecyclerView/ultimaterecyclerview/src/main/java/com/marshalchen/ultimaterecyclerview/ItemTouchListenerAdapter.java b/UltimateRecyclerView/ultimaterecyclerview/src/main/java/com/marshalchen/ultimaterecyclerview/ItemTouchListenerAdapter.java
index 2e43c7f7..b4430e56 100644
--- a/UltimateRecyclerView/ultimaterecyclerview/src/main/java/com/marshalchen/ultimaterecyclerview/ItemTouchListenerAdapter.java
+++ b/UltimateRecyclerView/ultimaterecyclerview/src/main/java/com/marshalchen/ultimaterecyclerview/ItemTouchListenerAdapter.java
@@ -21,6 +21,8 @@
import android.view.MotionEvent;
import android.view.View;
+import com.marshalchen.ultimaterecyclerview.quickAdapter.AdmobAdapter;
+
/**
* As RecyclerView does not have standard way to add click listeners to the items,
* this RecyclerView.OnItemTouchListener intercepts touch events and translates them to simple
diff --git a/UltimateRecyclerView/ultimaterecyclerview/src/main/java/com/marshalchen/ultimaterecyclerview/UltimateViewAdapter.java b/UltimateRecyclerView/ultimaterecyclerview/src/main/java/com/marshalchen/ultimaterecyclerview/UltimateViewAdapter.java
index 4286c41c..f019dce2 100644
--- a/UltimateRecyclerView/ultimaterecyclerview/src/main/java/com/marshalchen/ultimaterecyclerview/UltimateViewAdapter.java
+++ b/UltimateRecyclerView/ultimaterecyclerview/src/main/java/com/marshalchen/ultimaterecyclerview/UltimateViewAdapter.java
@@ -56,12 +56,12 @@ public boolean hasHeaderView() {
*
* @param customview the inflated view
*/
- public void setCustomLoadMoreView(@Nullable View customview) {
+ public final void setCustomLoadMoreView(@Nullable View customview) {
customLoadMoreView = customview;
}
- public View getCustomLoadMoreView() {
+ public final View getCustomLoadMoreView() {
return customLoadMoreView;
}
@@ -70,7 +70,7 @@ public View getCustomLoadMoreView() {
*
* @return determine this is a get function
*/
- public boolean enableLoadMore() {
+ public final boolean enableLoadMore() {
return enabled_custom_load_more_view;
}
@@ -79,7 +79,7 @@ public boolean enableLoadMore() {
*
* @param b bool
*/
- public void enableLoadMore(boolean b) {
+ public final void enableLoadMore(boolean b) {
enabled_custom_load_more_view = b;
if (!b && loadmoresetingswatch > 0 && customLoadMoreView != null) {
notifyItemRemoved(getItemCount() - 1);
@@ -90,11 +90,11 @@ public void enableLoadMore(boolean b) {
loadmoresetingswatch++;
}
- public void setEmptyViewPolicy(final int policy) {
+ public final void setEmptyViewPolicy(final int policy) {
mEmptyViewPolicy = policy;
}
- public void setEmptyViewOnInitPolicy(final int policy) {
+ public final void setEmptyViewOnInitPolicy(final int policy) {
mEmptyViewOnInitPolicy = policy;
}
diff --git a/UltimateRecyclerView/ultimaterecyclerview/src/main/java/com/marshalchen/ultimaterecyclerview/appPaginator/PageControlConst.java b/UltimateRecyclerView/ultimaterecyclerview/src/main/java/com/marshalchen/ultimaterecyclerview/appPaginator/PageControlConst.java
new file mode 100644
index 00000000..635225d1
--- /dev/null
+++ b/UltimateRecyclerView/ultimaterecyclerview/src/main/java/com/marshalchen/ultimaterecyclerview/appPaginator/PageControlConst.java
@@ -0,0 +1,17 @@
+package com.marshalchen.ultimaterecyclerview.appPaginator;
+
+/**
+ * Created by zJJ on 2/21/2016.
+ */
+public class PageControlConst {
+ public static String FRAGMENTTITLE = "fragment_title";
+ public static String SAVELOADDATA = "item_list";
+ public static String HASSAVEFILTER = "filter";
+ public static String URL = "data_url";
+
+ public final static String
+ BRAND_NAME = "BrandName",
+ SLUGTAG = "slug",
+ REQUEST_TYPE = "typerequest";
+
+}
diff --git a/UltimateRecyclerView/ultimaterecyclerview/src/main/java/com/marshalchen/ultimaterecyclerview/appPaginator/catelogGrid.java b/UltimateRecyclerView/ultimaterecyclerview/src/main/java/com/marshalchen/ultimaterecyclerview/appPaginator/catelogGrid.java
index f9621caf..3fe7f4c0 100644
--- a/UltimateRecyclerView/ultimaterecyclerview/src/main/java/com/marshalchen/ultimaterecyclerview/appPaginator/catelogGrid.java
+++ b/UltimateRecyclerView/ultimaterecyclerview/src/main/java/com/marshalchen/ultimaterecyclerview/appPaginator/catelogGrid.java
@@ -30,6 +30,12 @@ public abstract class catelogGrid extends paginator {
+ public static String TAG = "catelog";
+ public final static String BRAND_NAME = "BrandName", SLUG = "slug", REQUEST_TYPE = "typerequest";
+ public UltimateRecyclerView listview_layout;
+
+ public static String URL = "data_url";
+ public static String FRAGMENTTITLE = "fragment_title";
+ public static String SAVELOADDATA = "item_list";
+ public static String HASSAVEFILTER = "filter";
+ protected GridLayoutManager mLayoutManager;
+ protected adapter madapter;
+
+ protected abstract adapter getAdatperWithdata();
+
+ protected abstract void setUltimateRecyclerViewExtra(final UltimateRecyclerView listview, final adapter madapter);
+
+ @Override
+ public void onAttach(Activity activity) {
+ super.onAttach(activity);
+ }
+
+ @Override
+ public void onAttach(Context activity) {
+ super.onAttach(activity);
+ }
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
+ return inflater.inflate(getFragmentResId(), container, false);
+ }
+
+ @Override
+ @IdRes
+ protected int getUltimate_recycler_viewResId() {
+ return R.id.urv_main_list;
+ }
+
+ @Override
+ @IdRes
+ protected int getRefresherProgressBarId() {
+ return R.id.urv_main_progress_bar;
+ }
+
+ protected abstract int getColumn();
+
+
+ /**
+ * step 1:
+ * takes the arguement form the intent bundle and determine if there is a need to queue a loading process. If that is a yes then we need to load up the data before displaying the list out.
+ *
+ * @param r and the data bundle
+ * @return tells if there is a loading process to be done before hand
+ */
+ protected abstract boolean onArguments(final Bundle r);
+
+ /**
+ * step 2:
+ * this is the call for the loading the data stream externally
+ *
+ * @param confirmAdapter the adapter
+ */
+ protected abstract void loadDataInitial(final adapter confirmAdapter);
+
+
+ protected void renderviewlayout(View view) throws Exception {
+ listview_layout = (UltimateRecyclerView) view.findViewById(getUltimate_recycler_viewResId());
+ listview_layout.setHasFixedSize(true);
+ listview_layout.setSaveEnabled(true);
+ if (mLayoutManager == null) {
+ mLayoutManager = new GridLayoutManager(view.getContext(), getColumn(), LinearLayoutManager.VERTICAL, false);
+ }
+ listview_layout.setLayoutManager(mLayoutManager);
+ getProgressbar(view);
+ listview_layout.setAdapter(madapter = getAdatperWithdata());
+ setUltimateRecyclerViewExtra(listview_layout, madapter);
+ }
+
+
+ @Override
+ public void onViewCreated(View view, Bundle savedInstanceState) {
+ try {
+ renderviewlayout(view);
+ if (getArguments() != null) {
+ if (onArguments(getArguments())) {
+ showLoadingCircle();
+ initPaginator();
+ loadDataInitial(madapter);
+ }
+ }
+ } catch (Exception e) {
+ Log.d(TAG, e.getMessage());
+ }
+
+ }
+
+}
diff --git a/UltimateRecyclerView/ultimaterecyclerview/src/main/java/com/marshalchen/ultimaterecyclerview/appPaginator/v4/catelogLinear.java b/UltimateRecyclerView/ultimaterecyclerview/src/main/java/com/marshalchen/ultimaterecyclerview/appPaginator/v4/catelogLinear.java
new file mode 100644
index 00000000..a32165b2
--- /dev/null
+++ b/UltimateRecyclerView/ultimaterecyclerview/src/main/java/com/marshalchen/ultimaterecyclerview/appPaginator/v4/catelogLinear.java
@@ -0,0 +1,115 @@
+package com.marshalchen.ultimaterecyclerview.appPaginator.v4;
+
+import android.app.Activity;
+import android.content.Context;
+import android.os.Bundle;
+import android.support.annotation.IdRes;
+import android.support.v7.widget.LinearLayoutManager;
+import android.util.Log;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+
+import com.marshalchen.ultimaterecyclerview.R;
+import com.marshalchen.ultimaterecyclerview.UltimateRecyclerView;
+import com.marshalchen.ultimaterecyclerview.UltimateRecyclerviewViewHolder;
+import com.marshalchen.ultimaterecyclerview.quickAdapter.easyRegularAdapter;
+import com.marshalchen.ultimaterecyclerview.uiUtils.ScrollSmoothLineaerLayoutManager;
+
+/**
+ * Created by hesk on 30/6/15.
+ */
+public abstract class catelogLinear extends paginator {
+ public static String TAG = "catelog";
+ public final static String BRAND_NAME = "BrandName", SLUG = "slug", REQUEST_TYPE = "typerequest";
+ public UltimateRecyclerView listview_layout;
+ public static String URL = "data_url";
+ public static String FRAGMENTTITLE = "fragment_title";
+ public static String SAVELOADDATA = "item_list";
+ public static String HASSAVEFILTER = "filter";
+ protected LinearLayoutManager mLayoutManager;
+ protected adapter madapter;
+
+ protected abstract adapter getAdatperWithdata();
+
+ protected abstract void setUltimateRecyclerViewExtra(final UltimateRecyclerView listview, final adapter madapter);
+
+ @Override
+ public void onAttach(Activity activity) {
+ super.onAttach(activity);
+ }
+
+ @Override
+ public void onAttach(Context activity) {
+ super.onAttach(activity);
+ }
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
+ return inflater.inflate(getFragmentResId(), container, false);
+ }
+
+ @IdRes
+ protected int getUltimate_recycler_viewResId() {
+ return R.id.urv_main_list;
+ }
+
+ @IdRes
+ protected int getRefresherProgressBarId() {
+ return R.id.urv_main_progress_bar;
+ }
+
+ /**
+ * step 1:
+ * takes the arguement form the intent bundle and determine if there is a need to queue a loading process. If that is a yes then we need to load up the data before displaying the list out.
+ *
+ * @param r and the data bundle
+ * @return tells if there is a loading process to be done before hand
+ */
+ protected abstract boolean onArguments(final Bundle r);
+
+ /**
+ * step 2:
+ * this is the call for the loading the data stream externally
+ *
+ * @param confirmAdapter the adapter
+ */
+ protected abstract void loadDataInitial(final adapter confirmAdapter);
+
+
+ protected void renderviewlayout(View view) throws Exception {
+ listview_layout = (UltimateRecyclerView) view.findViewById(getUltimate_recycler_viewResId());
+ listview_layout.setHasFixedSize(true);
+ listview_layout.setSaveEnabled(true);
+ if (mLayoutManager == null) {
+ mLayoutManager = new ScrollSmoothLineaerLayoutManager(view.getContext(), LinearLayoutManager.VERTICAL, false, getSmoothDuration());
+ }
+ listview_layout.setLayoutManager(mLayoutManager);
+ listview_layout.setAdapter(madapter = getAdatperWithdata());
+ getProgressbar(view);
+ setUltimateRecyclerViewExtra(listview_layout, madapter);
+ }
+
+ protected int getSmoothDuration() {
+ return 300;
+ }
+
+ @Override
+ public void onViewCreated(View view, Bundle savedInstanceState) {
+ try {
+ renderviewlayout(view);
+ if (getArguments() != null) {
+ if (onArguments(getArguments())) {
+ showLoadingCircle();
+ initPaginator();
+ loadDataInitial(madapter);
+ }
+ }
+ } catch (Exception e) {
+ Log.d(TAG, e.getMessage());
+ }
+
+ }
+
+
+}
\ No newline at end of file
diff --git a/UltimateRecyclerView/ultimaterecyclerview/src/main/java/com/marshalchen/ultimaterecyclerview/appPaginator/v4/paginator.java b/UltimateRecyclerView/ultimaterecyclerview/src/main/java/com/marshalchen/ultimaterecyclerview/appPaginator/v4/paginator.java
new file mode 100644
index 00000000..dd5627bf
--- /dev/null
+++ b/UltimateRecyclerView/ultimaterecyclerview/src/main/java/com/marshalchen/ultimaterecyclerview/appPaginator/v4/paginator.java
@@ -0,0 +1,166 @@
+package com.marshalchen.ultimaterecyclerview.appPaginator.v4;
+
+
+import android.os.Build;
+import android.support.annotation.IdRes;
+import android.support.annotation.LayoutRes;
+import android.support.v4.app.Fragment;
+import android.view.View;
+import android.widget.ProgressBar;
+
+/**
+ * Created by hesk on 15/2/16.
+ */
+public abstract class paginator extends Fragment {
+ private int currentPage, totalPages, pagePerItems, landscape_common_colums = 4, portrait_common_colums = 2;
+ private String tag_keyword, fullEndPoint, searchKeyword;
+ private boolean enable_load_more, is_new_search;
+ protected ProgressBar mProgress;
+
+ protected void getProgressbar(View view, @IdRes final int progress_bar_id) {
+ try {
+ mProgress = (ProgressBar) view.findViewById(progress_bar_id);
+ } catch (Exception e) {
+ //unable to find loading progress bar
+ }
+ }
+
+ protected void getProgressbar(View view) {
+ try {
+ mProgress = (ProgressBar) view.findViewById(getRefresherProgressBarId());
+ } catch (Exception e) {
+ //unable to find loading progress bar
+ }
+ }
+
+ @IdRes
+ protected abstract int getRefresherProgressBarId();
+
+ @IdRes
+ protected abstract int getUltimate_recycler_viewResId();
+
+ @LayoutRes
+ protected abstract int getFragmentResId();
+
+ protected abstract void onClickItem(final String route);
+
+ protected abstract void onClickItem(final long route_id);
+
+
+ protected void showLoadingCircle() {
+ if (mProgress != null) {
+ mProgress.setVisibility(View.VISIBLE);
+ mProgress.animate().alpha(1f);
+ }
+ }
+
+ protected void hideLoadingCircle() {
+ if (mProgress != null && mProgress.getVisibility() == View.VISIBLE) {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
+ mProgress.animate().alpha(0f).withEndAction(new Runnable() {
+ @Override
+ public void run() {
+ mProgress.setVisibility(View.INVISIBLE);
+ }
+ });
+ } else {
+ mProgress.setVisibility(View.INVISIBLE);
+ }
+ }
+ }
+
+ protected int getItemsShownPerPage() {
+ return 16;
+ }
+
+ protected void initPaginator() {
+ currentPage = 1;
+ totalPages = 1;
+ pagePerItems = getItemsShownPerPage();
+ enable_load_more = false;
+ is_new_search = false;
+ }
+
+
+ public String getSearchKeyword() {
+ return searchKeyword;
+ }
+
+ public void setSearchKeyword(String searchKeyword) {
+ this.searchKeyword = searchKeyword;
+ }
+
+ public String getTagKeyword() {
+ return tag_keyword;
+ }
+
+ public void setTagKeyword(String tag_keyword) {
+ this.tag_keyword = tag_keyword;
+ }
+
+ public String getFullEndPoint() {
+ return fullEndPoint;
+ }
+
+ public void setFullEndPoint(String fullEndPoint) {
+ this.fullEndPoint = fullEndPoint;
+ }
+
+ public boolean isNewSearch() {
+ return is_new_search;
+ }
+
+ public void setEnablNewSearch(boolean is_new_search) {
+ this.is_new_search = is_new_search;
+ }
+
+ protected int getCurrentPage() {
+ return currentPage;
+ }
+
+ protected int getTotalPages() {
+ return totalPages;
+ }
+
+ protected int getPagePerItems() {
+ return pagePerItems;
+ }
+
+ protected void setCurrentPage(int n) {
+ currentPage = n;
+ }
+
+ protected void nextPage() {
+ if (currentPage < totalPages) {
+ enable_load_more = true;
+ currentPage++;
+ }
+ }
+
+ protected void setTotalPages(int n) {
+ totalPages = n;
+ if (currentPage >= totalPages) {
+ enable_load_more = false;
+ } else {
+ enable_load_more = true;
+ }
+ }
+
+ protected boolean shouldEnableLoadMore() {
+ return enable_load_more;
+ }
+
+ public void triggerNewSearchKeyWord(String word) {
+ setEnablNewSearch(true);
+ setSearchKeyword(word);
+ }
+
+ protected abstract void makeBasicRequest();
+
+ protected abstract void makeRefreshRequest();
+
+ protected void makeNextRequest() {
+ nextPage();
+ makeBasicRequest();
+ }
+}
diff --git a/UltimateRecyclerView/ultimaterecyclerview/src/main/java/com/marshalchen/ultimaterecyclerview/quickAdapter/AdItemHolder.java b/UltimateRecyclerView/ultimaterecyclerview/src/main/java/com/marshalchen/ultimaterecyclerview/quickAdapter/AdItemHolder.java
new file mode 100644
index 00000000..d2b1327a
--- /dev/null
+++ b/UltimateRecyclerView/ultimaterecyclerview/src/main/java/com/marshalchen/ultimaterecyclerview/quickAdapter/AdItemHolder.java
@@ -0,0 +1,27 @@
+package com.marshalchen.ultimaterecyclerview.quickAdapter;
+
+import android.view.View;
+
+import com.marshalchen.ultimaterecyclerview.UltimateRecyclerviewViewHolder;
+import com.marshalchen.ultimaterecyclerview.UltimateViewAdapter;
+
+/**
+ * Created by hesk on 24/2/16.
+ */
+public abstract class AdItemHolder extends UltimateRecyclerviewViewHolder {
+ private final int innerType;
+
+ public AdItemHolder(View itemView, int type) {
+ super(itemView);
+ innerType = type;
+ if (innerType == UltimateViewAdapter.VIEW_TYPES.NORMAL) {
+ bindNormal(itemView);
+ } else if (innerType == UltimateViewAdapter.VIEW_TYPES.ADVIEW) {
+ bindAd(itemView);
+ }
+ }
+
+ protected abstract void bindNormal(View view);
+
+ protected abstract void bindAd(View view);
+}
diff --git a/UltimateRecyclerView/ultimaterecyclerview/src/main/java/com/marshalchen/ultimaterecyclerview/quickAdapter/AdmobAdapter.java b/UltimateRecyclerView/ultimaterecyclerview/src/main/java/com/marshalchen/ultimaterecyclerview/quickAdapter/AdmobAdapter.java
new file mode 100644
index 00000000..b8bc4f7f
--- /dev/null
+++ b/UltimateRecyclerView/ultimaterecyclerview/src/main/java/com/marshalchen/ultimaterecyclerview/quickAdapter/AdmobAdapter.java
@@ -0,0 +1,243 @@
+package com.marshalchen.ultimaterecyclerview.quickAdapter;
+
+import android.support.annotation.Nullable;
+import android.support.v7.widget.RecyclerView;
+import android.util.Log;
+import android.view.View;
+import android.view.ViewGroup;
+
+import java.util.List;
+
+/**
+ * Enhanced Google Admob implementation
+ * Created by hesk on 20/5/15.
+ */
+public abstract class AdmobAdapter extends easyRegularAdapter {
+ public interface AdviewListener {
+ Adv onGenerateAdview();
+ }
+
+ protected final Adv advertise_view;
+ /**
+ * There is an AD between the amount of the data items. adfrequency is known as the amount.
+ */
+ protected int adfrequency;
+ /**
+ * The ad is only insert once and no more.
+ */
+ protected boolean once;
+ protected AdviewListener adviewlistener;
+ public static final int POSITION_ON_AD = -1;
+
+ /**
+ * This is the enhanced listview injection model that will be able to work with Googlge Admob, DoubleClick, and
+ * related custom cell injection on the fly. It provides two specific options for the view to be taken place.
+ * While insertOnce=true will increase the performance and false will slow down a little bit on the performance but it is insignificant.
+ *
+ * @param adview The AD mob view
+ * @param insertOnce only insert once and hold into the adapter object, that means the ad will only shown once in the list view
+ * @param setInterval the order of item to show the ad. if @insertOnce=false the ad will show on interval bases.
+ * @param L the data source
+ */
+ public AdmobAdapter(Adv adview, boolean insertOnce, int setInterval, List L) {
+ this(adview, insertOnce, setInterval, L, null);
+ }
+
+
+ /**
+ * This is same to the above method
+ *
+ * @param advertisement_view The AD mob view
+ * @param insertOnce only insert once and hold into the adapter object, that means the ad will only shown once in the list view
+ * @param setInterval the order of item to show the ad. if @insertOnce=false the ad will show on interval bases.
+ * @param L the data source
+ * @param listener The listener for the admob cell to reveal when the cell is close to appear on the screen
+ */
+ public AdmobAdapter(
+ final Adv advertisement_view,
+ boolean insertOnce,
+ int setInterval,
+ List L,
+ @Nullable AdviewListener listener) {
+ super(L);
+
+ // setHasStableIds(true);
+ /**
+ * Disable focus for sub-views of the AdView to avoid problems with
+ * trackpad navigation of the list.
+ */
+ for (int i = 0; i < advertisement_view.getChildCount(); i++) {
+ advertisement_view.getChildAt(i).setFocusable(false);
+ }
+ advertisement_view.setFocusable(false);
+ once = insertOnce;
+ adfrequency = setInterval + 1;
+ advertise_view = advertisement_view;
+ if (listener == null) {
+ adviewlistener = new AdviewListener() {
+ @Override
+ public ViewGroup onGenerateAdview() {
+ return advertisement_view;
+ }
+ };
+ } else
+ adviewlistener = listener;
+ }
+
+ /**
+ * requirement: ADVIEW
+ *
+ * @param view v
+ * @return holder for this ADVIEW
+ */
+ @Override
+ public RecyclerView.ViewHolder getAdViewHolder(View view) {
+ return new AdItemHolder(adviewlistener.onGenerateAdview(), VIEW_TYPES.ADVIEW) {
+ @Override
+ protected void bindNormal(View view) {
+
+ }
+
+ @Override
+ protected void bindAd(View view) {
+
+ }
+ };
+ }
+
+
+ /**
+ * get the display item count
+ *
+ * @return the final items for display
+ */
+ @Override
+ public int getItemCount() {
+ final int base = super.getItemCount();
+ if (once) {
+ if (adfrequency > 0) {
+ return base + 1;
+ } else {
+ return base;
+ }
+ } else {
+ final int check_sum = (adfrequency > 0 ? atAdPos(base) : 0) + base;
+ Log.d("getItemCountE2", check_sum + "");
+ return check_sum;
+ }
+ }
+
+
+ /**
+ * indicate if the touch position is at the Adview
+ *
+ * @param pos in raw
+ * @return in raw
+ */
+ @Override
+ protected boolean isOnAdView(int pos) {
+ final int zero_for_admob_selection = (pos + 1) % adfrequency;
+ return zero_for_admob_selection == 0;
+ }
+
+ /**
+ * Todo: need to resolve this problem when it crash
+ * Remove a item of the list of the adapter
+ *
+ * @param list the data source
+ * @param position with the position on the list
+ */
+ /* public void remove(List> list, int position) {
+ try {
+ if (list.size() > 0 && position < list.size()) {
+ list.remove(position);
+ final int offset = getReverseDataArrayPosition(position);
+ notifyItemRemoved(offset);
+ if (offset > 1 && isOnAdView(offset) && position > 0) {
+ notifyItemRemoved(offset - 1);
+ }
+ Log.d("normaladmob", "offset final: " + offset);
+ } else {
+ throw new ArrayIndexOutOfBoundsException("no data or the remove position is not exist p:" + position + ", list size:" + list.size());
+ }
+ } catch (ArrayIndexOutOfBoundsException e) {
+ Log.d("admobError r1", e.getMessage());
+ } catch (IndexOutOfBoundsException e) {
+ Log.d("admobError r2", e.getMessage());
+ }
+
+ }*/
+
+
+ /**
+ * data binding related position shifting
+ *
+ * @param touch_position pos machine loaded position in int
+ * @return the final confirmed position for data binding
+ */
+ @Override
+ protected int getItemDataPosFromInternalPos(int touch_position) {
+ int shift = 0;
+ if (hasHeaderView()) shift--;
+ if (adfrequency > 0) {
+ if (once) {
+ if (touch_position >= adfrequency) shift--;
+ } else {
+ shift -= atAdPos(touch_position);
+ }
+ }
+ return touch_position + shift;
+ }
+
+ /**
+ * this is the {getDataArrayPosition} reverse from data position to layout position
+ *
+ * @param dataPos position on the data list
+ * @return offset
+ */
+ protected int getReverseDataArrayPosition(final int dataPos) {
+ int shift = 0;
+ if (hasHeaderView()) shift++;
+ if (adfrequency > 0) {
+ if (once) {
+ if (dataPos >= adfrequency) shift++;
+ } else {
+ shift += atAdPos(dataPos);
+ }
+ }
+ return dataPos + shift;
+ }
+
+
+ /**
+ * the API access for adview indication
+ *
+ * @param pos position to be final
+ * @return bool
+ */
+ public final boolean isPosOnAdView(final int pos) {
+ return isOnAdView(pos);
+ }
+
+ /**
+ * to display the accumulator for the Ad position
+ *
+ * @param pos raw touch position
+ * @return the placement for the ad position
+ */
+ public final int atAdPos(final int pos) {
+ final int take_int = (int) Math.floor((pos + 1) / adfrequency);
+ Log.d("atAdPosE2", take_int + "");
+ return take_int;
+ }
+
+ /**
+ * for external shift number adjustment
+ *
+ * @param pos initial number
+ * @return the number
+ */
+ public final int getFinalShiftPosition(int pos) {
+ return getItemDataPosFromInternalPos(pos);
+ }
+}
diff --git a/UltimateRecyclerView/ultimaterecyclerview/src/main/java/com/marshalchen/ultimaterecyclerview/quickAdapter/BiAdAdapterSwitcher.java b/UltimateRecyclerView/ultimaterecyclerview/src/main/java/com/marshalchen/ultimaterecyclerview/quickAdapter/BiAdAdapterSwitcher.java
index 7861cad5..1ff17801 100644
--- a/UltimateRecyclerView/ultimaterecyclerview/src/main/java/com/marshalchen/ultimaterecyclerview/quickAdapter/BiAdAdapterSwitcher.java
+++ b/UltimateRecyclerView/ultimaterecyclerview/src/main/java/com/marshalchen/ultimaterecyclerview/quickAdapter/BiAdAdapterSwitcher.java
@@ -7,7 +7,6 @@
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
-import android.util.Log;
import android.view.Display;
import android.view.LayoutInflater;
import android.view.View;
@@ -30,13 +29,13 @@ public class BiAdAdapterSwitcher<
//DATA TYPE
T,
//The view holder
- B extends UltimateRecyclerviewViewHolder,
+ B extends AdItemHolder,
//THE regular adapter
EASY extends easyRegularAdapter,
//THE Viewgroup from the google Adview
V extends ViewGroup,
//the admobdapter
- ADMOB extends simpleAdmobAdapter>
+ ADMOB extends AdmobAdapter>
{
protected UltimateRecyclerView listview;
diff --git a/UltimateRecyclerView/ultimaterecyclerview/src/main/java/com/marshalchen/ultimaterecyclerview/quickAdapter/easyRegularAdapter.java b/UltimateRecyclerView/ultimaterecyclerview/src/main/java/com/marshalchen/ultimaterecyclerview/quickAdapter/easyRegularAdapter.java
index 04a9bcc9..ce6293ac 100644
--- a/UltimateRecyclerView/ultimaterecyclerview/src/main/java/com/marshalchen/ultimaterecyclerview/quickAdapter/easyRegularAdapter.java
+++ b/UltimateRecyclerView/ultimaterecyclerview/src/main/java/com/marshalchen/ultimaterecyclerview/quickAdapter/easyRegularAdapter.java
@@ -48,7 +48,12 @@ public UltimateRecyclerviewViewHolder getViewHolder(View view) {
return new UltimateRecyclerviewViewHolder(view);
}
-
+ /**
+ * this MUST BE USING THE NORMAL VIEW
+ *
+ * @param parent view group parent
+ * @return THE HOLDER
+ */
@Override
public UltimateRecyclerviewViewHolder onCreateViewHolder(ViewGroup parent) {
View v = LayoutInflater.from(parent.getContext()).inflate(getNormalLayoutResId(), parent, false);
@@ -73,29 +78,64 @@ public long generateHeaderId(int i) {
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
- if (position == getAdapterItemCount()) return;
- if (getItemViewType(position) == VIEW_TYPES.NORMAL) {
- withBindHolder((BINDHOLDER) holder, source.get(position), position);
+ // if (position >= getAdapterItemCount()) return;
+ if (getItemViewType(position) == VIEW_TYPES.ADVIEW) {
+ onBindAdViewHolder(holder, position);
+ } else if (getItemViewType(position) == VIEW_TYPES.CUSTOMVIEW) {
+ onBindCustomViewHolder(holder, position);
} else if (getItemViewType(position) == VIEW_TYPES.HEADER) {
- // bindHeader(holder, position);
+ onBindHeaderViewHolder(holder, position);
} else if (getItemViewType(position) == VIEW_TYPES.FOOTER) {
- // bindFooter(holder, position);
+ onBindFooterViewHolder(holder, position);
+ } else if (getItemViewType(position) == VIEW_TYPES.NORMAL) {
+ // if (position >= getAdapterItemCount()) return;
+ withBindHolder((BINDHOLDER) holder, source.get(getItemDataPosFromInternalPos(position)), position);
}
}
- protected void bindFooter(RecyclerView.ViewHolder holder, final int pos) {
+ protected int getItemDataPosFromInternalPos(final int touch_position) {
+ int shift = 0;
+ if (hasHeaderView()) shift--;
+ int prefinal = touch_position + shift;
+ if (prefinal >= getAdapterItemCount()) {
+ return 0;
+ } else if (prefinal < 0) {
+ return 0;
+ }
+ return prefinal;
}
- protected void bindHeader(RecyclerView.ViewHolder holder, final int pos) {
+
+ /**
+ * binding normal view holder
+ *
+ * @param holder holder class
+ * @param data data
+ * @param position position
+ */
+ protected abstract void withBindHolder(final BINDHOLDER holder, final T data, final int position);
+
+ /**
+ * this is the implementation from sticky viewholder interface
+ *
+ * @param viewHolder ViewHolder
+ * @param pos position
+ */
+ @Override
+ public void onBindHeaderViewHolder(RecyclerView.ViewHolder viewHolder, int pos) {
}
- protected abstract void withBindHolder(final BINDHOLDER holder, final T data, final int position);
+ protected void onBindFooterViewHolder(RecyclerView.ViewHolder holder, final int pos) {
+ }
- @Override
- public void onBindHeaderViewHolder(RecyclerView.ViewHolder viewHolder, int i) {
+ protected void onBindCustomViewHolder(RecyclerView.ViewHolder holder, final int pos) {
+
+ }
+
+ protected void onBindAdViewHolder(RecyclerView.ViewHolder holder, final int pos) {
}
@@ -138,8 +178,8 @@ public final void swapPositions(int from, int to) {
swapPositions(source, from, to);
}
- public void setStableId(boolean b){
- if(!hasObservers()){
+ public void setStableId(boolean b) {
+ if (!hasObservers()) {
setHasStableIds(b);
}
}
diff --git a/UltimateRecyclerView/ultimaterecyclerview/src/main/java/com/marshalchen/ultimaterecyclerview/quickAdapter/simpleAdmobAdapter.java b/UltimateRecyclerView/ultimaterecyclerview/src/main/java/com/marshalchen/ultimaterecyclerview/quickAdapter/simpleAdmobAdapter.java
deleted file mode 100644
index b32bd205..00000000
--- a/UltimateRecyclerView/ultimaterecyclerview/src/main/java/com/marshalchen/ultimaterecyclerview/quickAdapter/simpleAdmobAdapter.java
+++ /dev/null
@@ -1,61 +0,0 @@
-package com.marshalchen.ultimaterecyclerview.quickAdapter;
-
-import android.support.v7.widget.RecyclerView;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.ListView;
-
-import com.marshalchen.ultimaterecyclerview.AdmobAdapter;
-import com.marshalchen.ultimaterecyclerview.UltimateRecyclerviewViewHolder;
-
-import java.util.List;
-
-/**
- * Created by hesk on 4/8/15.
- */
-public abstract class simpleAdmobAdapter extends AdmobAdapter {
- public simpleAdmobAdapter(GoogleAdView adview, boolean insertOnce, int setInterval, List L) {
- super(adview, insertOnce, setInterval, L);
- }
-
- public simpleAdmobAdapter(GoogleAdView adview, boolean insertOnce, int setInterval, List L, AdviewListener listener) {
- super(adview, insertOnce, setInterval, L, listener);
- }
-
- @Override
- public UltimateRecyclerviewViewHolder getViewHolder(View view) {
- return new UltimateRecyclerviewViewHolder(view);
- }
-
- @Override
- public void onBindViewHolder(UltimateRecyclerviewViewHolder holder, int position) {
- if (onActionToBindData(position, list)) {
- this.withBindHolder((B) holder, this.list.get(position), position);
- }
- }
-
- protected abstract void withBindHolder(B var1, T var2, int var3);
-
-
- @Override
- public int getAdapterItemCount() {
- return super.getAdapterItemCount();
- }
-
- @Override
- public long generateHeaderId(int i) {
- return 0;
- }
-
- @Override
- public RecyclerView.ViewHolder onCreateHeaderViewHolder(ViewGroup viewGroup) {
- return null;
- }
-
- @Override
- public void onBindHeaderViewHolder(RecyclerView.ViewHolder viewHolder, int i) {
-
- }
-
-
-}