use of com.abewy.klyph.items.TextButtonItem in project Klyph by jonathangerbaud.
the class KlyphFragment2 method startLoading.
protected void startLoading() {
loading = true;
if (isError == true && getAdapter().getCount() > 0) {
GraphObject lastObject = getAdapter().getLastItem();
if (lastObject instanceof TextButtonItem) {
getAdapter().remove(lastObject);
}
}
isError = false;
if (!firstLoad) {
if (!loadingObjectAsFirstItem)
getAdapter().add(loadingObject);
else
getAdapter().insert(loadingObject, 0);
getAdapter().notifyDataSetChanged();
}
}
use of com.abewy.klyph.items.TextButtonItem in project Klyph by jonathangerbaud.
the class KlyphFragment2 method onRequestError.
private void onRequestError(RequestError error) {
Log.d(TAG, "error " + error.toString());
// Crashlytics report on request error
try {
throw new Exception("Class :�" + this.getClass().getName() + "\n, Request " + requestType + ", Id " + elementId + ", Offset " + offset + "\n, Error " + error.getMessage());
} catch (Exception e) {
Crashlytics.logException(e);
}
if (getView() == null || getGridView() == null)
return;
isError = true;
loading = false;
int errorText = this.errorText;
if (!ConnectionState.getInstance(getActivity()).isOnline()) {
errorText = R.string.request_connexion_error;
}
// Fragment can be destroyed but receive the error
if (getAdapter() != null) {
if (getAdapter().isEmpty()) {
setEmptyText(errorText);
populate(new ArrayList<GraphObject>());
} else {
TextButtonItem errorItem = new TextButtonItem();
errorItem.setText(getString(errorText));
// TODO This is not a good coding practice !
errorItem.setButtonListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
retryRequestAfterError();
}
});
getAdapter().add(errorItem);
endLoading();
}
}
}
use of com.abewy.klyph.items.TextButtonItem in project Klyph by jonathangerbaud.
the class KlyphFragment2 method loadNewest.
protected void loadNewest() {
newestLoading = true;
if (getAdapter().getFirstItem() instanceof TextButtonItem) {
getAdapter().removeFirst();
getAdapter().notifyDataSetChanged();
}
String offset = null;
/*
* if (KlyphPreferences.getNewsfeedGoToTop() == false && getAdapter().getCount() > 0 && getAdapter().getCount() > insertNewestToIndex)
* {
* GraphObject first = (GraphObject) getAdapter().getItem(insertNewestToIndex);
* offset = getNewestOffset(first);
* }
*/
AsyncRequest request = new AsyncRequest(requestNewestType, getElementId(), offset, new AsyncRequest.Callback() {
public void onComplete(Response response) {
Log.i("StreamListFragment", "onCompleted");
onRequestNewestComplete(response);
}
});
request.execute();
}
use of com.abewy.klyph.items.TextButtonItem in project Klyph by jonathangerbaud.
the class KlyphFragment method loadNewest.
protected void loadNewest() {
newestLoading = true;
setPullToRefreshRefreshing(true);
if (getAdapter().getFirstItem() instanceof TextButtonItem) {
getAdapter().removeAt(0);
getAdapter().notifyDataSetChanged();
}
String offset = null;
AsyncRequest request = new AsyncRequest(requestNewestType, getElementId(), offset, new AsyncRequest.Callback() {
public void onComplete(Response response) {
onRequestNewestComplete(response);
}
});
request.execute();
}
use of com.abewy.klyph.items.TextButtonItem in project Klyph by jonathangerbaud.
the class KlyphFragment method startLoading.
protected void startLoading() {
loading = true;
if (isError == true && getAdapter().getCount() > 0) {
GraphObject lastObject = getAdapter().getLastItem();
if (lastObject instanceof TextButtonItem) {
getAdapter().remove(lastObject);
}
}
isError = false;
if (!firstLoad) {
if (!loadingObjectAsFirstItem)
getAdapter().add(loadingObject);
else
getAdapter().insert(loadingObject, 0);
getAdapter().notifyDataSetChanged();
}
}
Aggregations