use of com.abewy.android.apps.klyph.core.graph.GraphObject 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();
}
}
}
use of com.abewy.android.apps.klyph.core.graph.GraphObject in project Klyph by jonathangerbaud.
the class KlyphFragment2 method populate.
protected void populate(List<GraphObject> data) {
if (getView() != null && getAdapter() != null) {
MultiObjectAdapter adapter = getAdapter();
for (GraphObject graphObject : data) {
adapter.add(graphObject);
}
// adapter.addAll(data); is only available in api 11
endLoading();
boolean requestHasMoreData = request != null && request.hasMoreData();
if (data.size() == 0 || !requestHasMoreData)
noMoreData = true;
else
offset = String.valueOf(adapter.getCount());
}
}
use of com.abewy.android.apps.klyph.core.graph.GraphObject 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.android.apps.klyph.core.graph.GraphObject 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.android.apps.klyph.core.graph.GraphObject in project Klyph by jonathangerbaud.
the class NewAlbumDialog method onCreateDialog.
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
LayoutInflater inflater = (LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View view = inflater.inflate(R.layout.dialog_new_album, null);
name = (TextView) view.findViewById(R.id.name);
location = (TextView) view.findViewById(R.id.location);
description = (TextView) view.findViewById(R.id.description);
privacy = (Spinner) view.findViewById(R.id.privacy);
/*ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(getActivity(), R.array.privacy,
android.R.layout.simple_spinner_item);
// Specify the layout to use when the list of choices appears
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);*/
MultiObjectAdapter adapter = new MultiObjectAdapter(null, SpecialLayout.DROP_DOWN_ITEM);
FriendList publicFL = new FriendList();
publicFL.setName(getActivity().getString(R.string.menu_privacy_public));
FriendList friendsFL = new FriendList();
friendsFL.setName(getActivity().getString(R.string.menu_privacy_friends));
FriendList selfFL = new FriendList();
selfFL.setName(getActivity().getString(R.string.menu_privacy_self));
adapter.add(publicFL);
adapter.add(friendsFL);
adapter.add(selfFL);
List<GraphObject> friendLists = KlyphData.getFriendLists();
if (friendLists != null) {
for (GraphObject graphObject : friendLists) {
adapter.add(graphObject);
}
}
privacy.setAdapter(adapter);
privacy.setSelection(KlyphPreferences.getPrivacy());
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setView(view);
builder.setTitle(R.string.new_album).setPositiveButton(R.string.create, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
createAlbum();
}
}).setNegativeButton(R.string.cancel, null);
return builder.create();
}
Aggregations