Skip to content

Commit

Permalink
enhance grid request
Browse files Browse the repository at this point in the history
make request and enhance loading mechanism
  • Loading branch information
jjhesk committed Feb 24, 2016
1 parent 3240015 commit 6fb9903
Show file tree
Hide file tree
Showing 5 changed files with 425 additions and 0 deletions.
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";

}
Original file line number Diff line number Diff line change
Expand Up @@ -156,4 +156,13 @@ public void triggerNewSearchKeyWord(String word) {
setSearchKeyword(word);
}

protected abstract void makeBasicRequest();

protected abstract void makeRefreshRequest();

protected void makeNextRequest() {
nextPage();
makeBasicRequest();
}

}
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());
}

}

}
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());
}

}


}
Loading

0 comments on commit 6fb9903

Please sign in to comment.