use of com.abewy.android.apps.klyph.core.fql.Stream in project Klyph by jonathangerbaud.
the class PostShare method initWithIntent.
public void initWithIntent(Intent intent) {
String photoId = intent.getStringExtra(KlyphBundleExtras.SHARE_PHOTO_ID);
String videoId = intent.getStringExtra(KlyphBundleExtras.SHARE_VIDEO_ID);
String albumId = intent.getStringExtra(KlyphBundleExtras.SHARE_ALBUM_ID);
Stream post = intent.getParcelableExtra(KlyphBundleExtras.SHARE_POST_ID);
String linkUrl = intent.getStringExtra(KlyphBundleExtras.SHARE_LINK_URL);
if (photoId != null) {
url = PHOTO + photoId;
new AsyncRequest(Query.PHOTO, photoId, "", new AsyncRequest.Callback() {
@Override
public void onComplete(Response response) {
onPhotoRequestComplete(response);
}
}).execute();
} else if (videoId != null) {
url = VIDEO + videoId;
new AsyncRequest(Query.VIDEO, videoId, "", new AsyncRequest.Callback() {
@Override
public void onComplete(Response response) {
onVideoRequestComplete(response);
}
}).execute();
} else if (albumId != null) {
url = ALBUM + albumId;
new AsyncRequest(Query.ALBUM, albumId, "", new AsyncRequest.Callback() {
@Override
public void onComplete(Response response) {
onAlbumRequestComplete(response);
}
}).execute();
} else if (post != null) {
url = post.getPermalink();
if (post.isStatus()) {
fillViews(post.getActor_name(), post.getMessage(), post.getActor_pic());
getActivity().setTitle(R.string.post_share_status);
} else {
Attachment att = post.getAttachment();
if (att.isPhoto() || att.isVideo() || att.isAlbum()) {
Media media = att.getMedia().get(0);
if (att.isAlbum()) {
fillViews(post.getActor_name(), att.getName(), media.getSrc());
} else {
fillViews(post.getActor_name(), media.getAlt(), media.getSrc());
}
if (att.isPhoto())
getActivity().setTitle(R.string.post_share_photo);
else if (att.isVideo())
getActivity().setTitle(R.string.post_share_video);
else
getActivity().setTitle(R.string.post_share_album);
} else {
getActivity().setTitle(R.string.post_share_status);
fillViews(post.getActor_name(), post.getMessage(), post.getActor_pic());
}
}
} else if (linkUrl != null) {
isLink = true;
url = linkUrl;
imageUrl = intent.getStringExtra(KlyphBundleExtras.SHARE_LINK_IMAGE_URL);
String linkName = intent.getStringExtra(KlyphBundleExtras.SHARE_LINK_NAME);
String linkDesc = intent.getStringExtra(KlyphBundleExtras.SHARE_LINK_DESC);
fillViews(linkName, linkDesc, imageUrl);
getActivity().setTitle(R.string.post_share_link);
} else {
Log.d("PostShare", "All null");
}
if (isLink == false) {
((ViewGroup) spinner.getParent()).setVisibility(View.GONE);
} else {
SpinnerAdapter adapter = new SpinnerAdapter(getActivity());
spinner.setAdapter(adapter);
Friend friend = new Friend();
friend.setName(getString(R.string.post_share_on_my_wall));
adapter.add(friend);
friend = new Friend();
friend.setName(getString(R.string.post_share_on_friend_wall));
adapter.add(friend);
adapter.notifyDataSetChanged();
spinner.setSelection(0);
spinner.setOnItemSelectedListener(this);
previousPosition = 0;
}
}
use of com.abewy.android.apps.klyph.core.fql.Stream in project Klyph by jonathangerbaud.
the class StreamFragment method populate.
@Override
protected void populate(List<GraphObject> data) {
if (data.size() > 0) {
if (isFirstLoad()) {
if (isStreamAvailableOnLaunch) {
GraphObject object = data.get(0);
if (object instanceof Status) {
initVariables((Status) object);
} else if (object instanceof Link) {
initVariables((Link) object);
} else if (object instanceof Photo) {
initVariables((Photo) object);
}
// Remove loading
getAdapter().removeAt(1);
likeTitle = new StreamLikeCount();
getAdapter().add(likeTitle);
refreshLikeCount();
data.remove(0);
if (stream.getComment_info().getCan_comment()) {
sendButton.setVisibility(View.VISIBLE);
sendEditText.setVisibility(View.VISIBLE);
}
if (getActivity() != null)
((FragmentActivity) getActivity()).invalidateOptionsMenu();
setRequestType(Query.COMMENTS);
setNoMoreData(false);
endLoading();
refresh();
} else {
if (data.get(0) instanceof Stream) {
Stream stream = (Stream) data.get(0);
// setIsFirstLoad(true);
setStreamAndLoad(stream);
refresh();
} else {
super.populate(new ArrayList<GraphObject>());
}
}
} else {
super.populate(data);
}
} else {
if (isFirstLoad() && isStreamAvailableOnLaunch) {
// Remove loading
getAdapter().removeAt(1);
}
super.populate(data);
}
setNoMoreData(!isFirstLoad() && (data.size() == 0 || (getRequest().getPagingNext() == null || getRequest().getPagingNext().length() == 0)));
if (getAdapter().getCount() > 2) {
setOffset(getAfterCursor());
}
}
use of com.abewy.android.apps.klyph.core.fql.Stream in project Klyph by jonathangerbaud.
the class StreamListFragment method storeSessionStreams.
private void storeSessionStreams() {
if (getAdapter() != null && getAdapter().getCount() > 0) {
// Make a copy of the list
List<GraphObject> streams = new ArrayList<GraphObject>();
// Add only the streams (e.g. no progress or error items)
for (GraphObject graphObject : getAdapter().getItems()) {
if (graphObject instanceof Stream)
streams.add(graphObject);
}
KlyphData.setLastStreams(streams);
}
}
use of com.abewy.android.apps.klyph.core.fql.Stream in project Klyph by jonathangerbaud.
the class StreamListFragment method load.
@Override
public void load() {
if (isFirstLoad) {
if (KlyphData.getLastStreams() != null) {
populate(KlyphData.getLastStreams());
if (stream_position_id != null) {
for (GraphObject graphObject : getAdapter().getItems()) {
if (graphObject instanceof Stream && stream_position_id.equals(((Stream) graphObject).getPost_id())) {
getListView().setSelection(getAdapter().getItemPosition(graphObject));
}
}
}
setNoMoreData(false);
} else {
readTask = new ReadDataTask();
readTask.execute();
}
} else {
super.load();
}
}
use of com.abewy.android.apps.klyph.core.fql.Stream in project Klyph by jonathangerbaud.
the class StreamListFragment method onPause.
@Override
public void onPause() {
if (getListView() != null && getAdapter() != null) {
int pos = getListView().getFirstVisiblePosition();
GraphObject o = getAdapter().getItem(pos);
if (pos < getAdapter().getCount() && o instanceof Stream) {
stream_position_id = ((Stream) o).getPost_id();
} else if (pos > 0) {
pos--;
if (pos < getAdapter().getCount() && o instanceof Stream)
stream_position_id = ((Stream) o).getPost_id();
}
}
setPullToRefreshRefreshing(false);
super.onPause();
}
Aggregations