Search in sources :

Example 1 with Stream

use of com.abewy.android.apps.klyph.core.fql.Stream in project Klyph by jonathangerbaud.

the class StreamActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    Log.d("StreamActivity", "onCreate: ");
    super.onCreate(savedInstanceState);
    Log.d("StreamActivity", "onCreate: 2");
    // Let the Application class know that the first launch is complete
    // If we come from a notification, then do not show the ads
    // When going back to main activity
    KlyphApplication.getInstance().launchComplete();
    if (Session.getActiveSession() == null) {
        Log.d("StreamActivity", "Session is null ");
        Session.openActiveSessionFromCache(this);
    }
    StreamFragment streamFragment = (StreamFragment) getFragmentManager().findFragmentById(R.id.stream_fragment);
    // setTitle("Messages");
    Stream stream = getIntent().getParcelableExtra(KlyphBundleExtras.STREAM_PARCELABLE);
    if (stream != null) {
        Log.d("StreamActivity", "setStreamAndLoad ");
        streamFragment.setStreamAndLoad(stream);
    } else {
        Log.d("StreamAct", "Received id " + getIntent().getStringExtra(KlyphBundleExtras.STREAM_ID) + " " + getIntent().getBooleanExtra(KlyphBundleExtras.STREAM_GROUP, false));
        streamFragment.setElementId(getIntent().getStringExtra(KlyphBundleExtras.STREAM_ID));
        if (getIntent().getBooleanExtra(KlyphBundleExtras.STREAM_GROUP, false) == true) {
            Log.d("StreamAct", "is group ");
            streamFragment.setIsStreamGroup();
        }
        Log.d("StreamActivity", "load ");
        streamFragment.load();
    }
}
Also used : StreamFragment(com.abewy.android.apps.klyph.fragment.StreamFragment) Stream(com.abewy.android.apps.klyph.core.fql.Stream)

Example 2 with Stream

use of com.abewy.android.apps.klyph.core.fql.Stream in project Klyph by jonathangerbaud.

the class EventFragment method onGridItemClick.

@Override
protected void onGridItemClick(KlyphGridView gridView, View view, int position, long id) {
    GraphObject o = (GraphObject) gridView.getItemAtPosition(position);
    if (o instanceof Stream) {
        Stream stream = (Stream) o;
        startActivity(Klyph.getIntentForGraphObject(getActivity(), stream));
    }
}
Also used : Stream(com.abewy.android.apps.klyph.core.fql.Stream) GraphObject(com.abewy.android.apps.klyph.core.graph.GraphObject)

Example 3 with Stream

use of com.abewy.android.apps.klyph.core.fql.Stream in project Klyph by jonathangerbaud.

the class StreamListFragment method populateNewest.

@Override
protected void populateNewest(List<GraphObject> data) {
    int n = data.size();
    if (n > 0) {
        int index = getListView().getFirstVisiblePosition();
        View v = getListView().getChildAt(index);
        int top = v == null ? 0 : v.getTop();
        int lastIndex = -1;
        if (KlyphPreferences.getNewsfeedGoToTop() == false) {
            List<GraphObject> list = new ArrayList<GraphObject>();
            list.addAll(getAdapter().getItems());
            // Looking for a matching post
            outer: for (int i = 0; i < n; i++) {
                Stream stream = (Stream) data.get(i);
                for (int j = 0, m = list.size(); j < m; j++) {
                    if (list.get(j) instanceof Stream) {
                        Stream s = (Stream) list.get(j);
                        Log.d("StreamListFragment", "populateNewest: " + stream.getPost_id() + " " + s.getPost_id());
                        if (stream.getPost_id().equals(s.getPost_id())) {
                            lastIndex = i;
                            // list.add(stream);
                            break outer;
                        }
                    }
                }
            }
            Log.d("StreamListFragment", "populateNewest: " + lastIndex);
            // If no match, then insert all the data
            if (lastIndex == -1)
                lastIndex = data.size();
            // Insert filtered data
            for (int i = lastIndex - 1; i >= 0; i--) {
                list.add(0, data.get(i));
            }
            getAdapter().clear(false);
            getAdapter().addAll(list);
        } else {
            getAdapter().clear(false);
            getAdapter().addAll(data);
            setOffset(((Stream) data.get(data.size() - 1)).getCreated_time());
        }
        if (getListAdapter() instanceof KlyphAnimationAdapter) {
            int firstVisiblePosition = getListView().getFirstVisiblePosition();
            int lastVisiblePosition = getListView().getLastVisiblePosition();
            if (firstVisiblePosition != lastVisiblePosition)
                ((KlyphAnimationAdapter) getListAdapter()).deactivateNext(lastVisiblePosition - firstVisiblePosition);
            else
                ((KlyphAnimationAdapter) getListAdapter()).deactivateNext(1);
        }
        getAdapter().notifyDataSetChanged();
        if (KlyphPreferences.getNewsfeedGoToTop() == false) {
            getListView().setSelectionFromTop(lastIndex, top);
        }
    }
    setNewestLoading(false);
    setPullToRefreshRefreshing(false);
    if (data.size() > 0) {
        storeSessionStreams();
        storeData();
    }
}
Also used : KlyphAnimationAdapter(com.abewy.android.apps.klyph.adapter.animation.KlyphAnimationAdapter) ArrayList(java.util.ArrayList) Stream(com.abewy.android.apps.klyph.core.fql.Stream) GraphObject(com.abewy.android.apps.klyph.core.graph.GraphObject) View(android.view.View) ListView(android.widget.ListView)

Example 4 with Stream

use of com.abewy.android.apps.klyph.core.fql.Stream in project Klyph by jonathangerbaud.

the class StreamAdapter2 method manageAttachment.

private void manageAttachment(StreamHolder holder, Stream stream) {
    Attachment attachment = stream.getAttachment();
    Media media = attachment.getMedia().size() > 0 ? attachment.getMedia().get(0) : null;
    int type = stream.getType();
    if ((type == 245 || type == 257) && stream.getParent_stream() != null) {
        final Stream parentStream = stream.getParent_stream();
        headerAdapter.mergeData(holder, parentStream, true);
        messageAdapter.mergeData(holder, parentStream);
        buttonBarAdapter.mergeData(holder, stream);
    }
    if (type == 161 && stream.getDescription_tags().size() > 0 && stream.getLiked_pages().size() > 0) {
        linkAdapter.manageLikedPage(holder, stream);
    }
    if (stream.isStatus()) {
        statusAdapter.mergeData(holder, stream);
    } else if (stream.isPhoto()) {
        photoAdapter.mergeData(holder, stream, stream.getPhoto());
    } else if (stream.isVideo()) {
        photoAdapter.mergeData(holder, stream, stream.getVideo());
    } else if (attachment.isPhoto() || ((media != null && media.isFydv()))) {
        photoAdapter.mergeData(holder, stream);
        buttonBarAdapter.mergeData(holder, stream);
    } else if (attachment.isAlbum()) {
        albumAdapter.mergeData(holder, stream);
        buttonBarAdapter.mergeData(holder, stream);
    } else if (attachment.isCheckin()) {
        manageAttachmentCheckin(holder, stream);
        buttonBarAdapter.mergeData(holder, stream);
    } else if (stream.getLink().isEventLink()) {
        linkAdapter.mergeData(holder, stream, stream.getLink());
    } else if (stream.getType() == 161 || attachment.getMedia().size() > 0) {
        linkAdapter.mergeData(holder, stream);
        buttonBarAdapter.mergeData(holder, stream);
    } else if (stream.isLink()) {
        linkAdapter.mergeData(holder, stream, stream.getLink());
    } else {
        buttonBarAdapter.mergeData(holder, stream);
    }
}
Also used : Media(com.abewy.android.apps.klyph.core.fql.Media) Attachment(com.abewy.android.apps.klyph.core.fql.Attachment) Stream(com.abewy.android.apps.klyph.core.fql.Stream)

Example 5 with Stream

use of com.abewy.android.apps.klyph.core.fql.Stream in project Klyph by jonathangerbaud.

the class StreamAdapter2 method mergeViewWithData.

@Override
protected void mergeViewWithData(View view, GraphObject data) {
    super.mergeViewWithData(view, data);
    if (buttonBarAdapter == null)
        buttonBarAdapter = new StreamButtonBar(parentAdapter, specialLayout);
    if (photoAdapter == null)
        photoAdapter = new StreamPhoto(parentAdapter, specialLayout);
    if (linkAdapter == null)
        linkAdapter = new StreamLink(parentAdapter, specialLayout);
    if (statusAdapter == null)
        statusAdapter = new StreamStatus(parentAdapter, specialLayout);
    final StreamHolder holder = (StreamHolder) getHolder(view);
    setData(view, data);
    final Stream stream = (Stream) data;
    setData(holder, stream);
}
Also used : StreamButtonBar(com.abewy.android.apps.klyph.adapter.subAdapter.StreamButtonBar) StreamPhoto(com.abewy.android.apps.klyph.adapter.subAdapter.StreamPhoto) Stream(com.abewy.android.apps.klyph.core.fql.Stream) StreamStatus(com.abewy.android.apps.klyph.adapter.subAdapter.StreamStatus) StreamLink(com.abewy.android.apps.klyph.adapter.subAdapter.StreamLink) StreamHolder(com.abewy.android.apps.klyph.adapter.holder.StreamHolder)

Aggregations

Stream (com.abewy.android.apps.klyph.core.fql.Stream)16 GraphObject (com.abewy.android.apps.klyph.core.graph.GraphObject)7 ArrayList (java.util.ArrayList)4 Attachment (com.abewy.android.apps.klyph.core.fql.Attachment)3 Media (com.abewy.android.apps.klyph.core.fql.Media)3 Friend (com.abewy.android.apps.klyph.core.fql.Friend)2 Page (com.abewy.android.apps.klyph.core.fql.Page)2 Tag (com.abewy.android.apps.klyph.core.fql.Tag)2 Intent (android.content.Intent)1 View (android.view.View)1 ViewGroup (android.view.ViewGroup)1 ListView (android.widget.ListView)1 KlyphAnimationAdapter (com.abewy.android.apps.klyph.adapter.animation.KlyphAnimationAdapter)1 StreamHolder (com.abewy.android.apps.klyph.adapter.holder.StreamHolder)1 StreamButtonBar (com.abewy.android.apps.klyph.adapter.subAdapter.StreamButtonBar)1 StreamLink (com.abewy.android.apps.klyph.adapter.subAdapter.StreamLink)1 StreamPhoto (com.abewy.android.apps.klyph.adapter.subAdapter.StreamPhoto)1 StreamStatus (com.abewy.android.apps.klyph.adapter.subAdapter.StreamStatus)1 EventActivity (com.abewy.android.apps.klyph.app.EventActivity)1 GroupActivity (com.abewy.android.apps.klyph.app.GroupActivity)1