use of com.abewy.klyph.items.TextButtonItem in project Klyph by jonathangerbaud.
the class TextButtonItemAdapter method mergeViewWithData.
@Override
protected void mergeViewWithData(View view, GraphObject data) {
TextButtonItemHolder holder = (TextButtonItemHolder) view.getTag();
TextButtonItem item = (TextButtonItem) data;
holder.getText().setText(item.getText());
if (item.getButtonListener() != null) {
holder.getButton().setOnClickListener(item.getButtonListener());
}
}
use of com.abewy.klyph.items.TextButtonItem in project Klyph by jonathangerbaud.
the class KlyphDialogFragment method onRequestError.
private void onRequestError(RequestError error) {
Log.i(TAG, "error " + error.toString());
if (getView() != null) {
isError = true;
loading = false;
int errorText = this.errorText;
if (!ConnectionState.getInstance(getActivity()).isOnline()) {
errorText = R.string.request_connexion_error;
}
TextButtonItem errorItem = new TextButtonItem();
errorItem.setText(getString(errorText));
// TODO This is not a good copding 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 KlyphDialogFragment 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 onRequestNewestError.
private void onRequestNewestError(RequestError error) {
Log.d("StreamListFragment", "error " + error.toString());
if (getView() == null || getActivity() == null)
return;
int errorText = this.errorNewestText;
if (!ConnectionState.getInstance(getView().getContext()).isOnline()) {
errorText = R.string.request_connexion_error;
}
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) {
loadNewest();
}
});
getAdapter().insert(errorItem, 0);
getAdapter().notifyDataSetChanged();
mPullToRefreshLayout.setRefreshComplete();
newestLoading = false;
}
use of com.abewy.klyph.items.TextButtonItem in project Klyph by jonathangerbaud.
the class KlyphFragment method onRequestError.
private void onRequestError(RequestError error) {
Log.d(TAG, "error " + error.toString());
if (getView() == null || getListView() == 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();
}
}
}
Aggregations