-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
make request and enhance loading mechanism
- Loading branch information
Showing
5 changed files
with
425 additions
and
0 deletions.
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
...iew/src/main/java/com/marshalchen/ultimaterecyclerview/appPaginator/PageControlConst.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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"; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
118 changes: 118 additions & 0 deletions
118
...rview/src/main/java/com/marshalchen/ultimaterecyclerview/appPaginator/v4/catelogGrid.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
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.GridLayoutManager; | ||
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; | ||
|
||
|
||
/** | ||
* Created by hesk on 15/2/16. | ||
*/ | ||
public abstract class catelogGrid<adapter extends easyRegularAdapter, binder extends UltimateRecyclerviewViewHolder> 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()); | ||
} | ||
|
||
} | ||
|
||
} |
115 changes: 115 additions & 0 deletions
115
...iew/src/main/java/com/marshalchen/ultimaterecyclerview/appPaginator/v4/catelogLinear.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<adapter extends easyRegularAdapter, binder extends UltimateRecyclerviewViewHolder> 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()); | ||
} | ||
|
||
} | ||
|
||
|
||
} |
Oops, something went wrong.