Search in sources :

Example 16 with Response

use of com.abewy.android.apps.klyph.core.request.Response in project Klyph by jonathangerbaud.

the class StreamListFragment method onViewCreated.

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    MultiObjectAdapter adapter = /* KlyphPreferences.areBannerAdsEnabled() ? new NewsfeedAdapter(getListView()) : */
    new MultiObjectAdapter(getListView());
    if (KlyphPreferences.animateCards()) {
        GoogleCardStyleAdapter gcsAdapter = new GoogleCardStyleAdapter(adapter);
        gcsAdapter.setAbsListView(getListView());
        setListAdapter(gcsAdapter);
    } else {
        setListAdapter(adapter);
    }
    defineEmptyText(R.string.empty_list_no_stream);
    // getListView().setPadding(0, 8, 0, 0);
    // getListView().setDivider(getResources().getDrawable(R.drawable.hdivider_transparent));
    // getGridView().setVerticalSpacing(16);
    // getListView().setItemsCanFocus(false);
    getListView().setDrawSelectorOnTop(true);
    getListView().setSelector(AttrUtil.getResourceId(getActivity(), R.attr.streamSelector));
    setListVisible(false);
    if (KlyphData.getFriendLists() == null) {
        new AsyncRequest(Query.FRIEND_LISTS, "", "", new Callback() {

            @Override
            public void onComplete(Response response) {
                onRequestComplete(response);
            }
        }).execute();
    }
    super.onViewCreated(view, savedInstanceState);
}
Also used : Response(com.abewy.android.apps.klyph.core.request.Response) AsyncRequest(com.abewy.android.apps.klyph.request.AsyncRequest) Callback(com.abewy.android.apps.klyph.core.request.BaseAsyncRequest.Callback) MultiObjectAdapter(com.abewy.android.apps.klyph.adapter.MultiObjectAdapter) GoogleCardStyleAdapter(com.abewy.android.apps.klyph.adapter.animation.GoogleCardStyleAdapter)

Example 17 with Response

use of com.abewy.android.apps.klyph.core.request.Response in project Klyph by jonathangerbaud.

the class StreamButtonBar method doLikeAction.

private void doLikeAction(final IStreamHolder holder, final Stream stream, final GraphObject subStream) {
    manageLikeButton(holder, stream, subStream, false);
    final Context context = getContext(holder.getAuthorProfileImage());
    if (getUserLikes(stream, subStream) == false) {
        setLikes(stream, subStream, true);
        manageLikeButton(holder, stream, subStream, false);
        Log.d("StreamButtonBar", "doLikeAction: " + stream.getPost_id());
        Log.d("StreamButtonBar", "doLikeAction: " + subStream);
        Log.d("StreamButtonBar", "doLikeAction: " + getId(stream, subStream));
        new AsyncRequest(Query.POST_LIKE, getId(stream, subStream), "", new AsyncRequest.Callback() {

            @Override
            public void onComplete(Response response) {
                Log.d("onComplete", "" + response.getError());
                if (response.getError() != null) {
                    Toast.makeText(context, R.string.like_error, Toast.LENGTH_SHORT).show();
                    setLikes(stream, subStream, false);
                }
                manageLikeButton(holder, stream, subStream, true);
                getParentAdapter().notifyDataSetChanged();
            }
        }).execute();
    } else {
        setLikes(stream, subStream, false);
        manageLikeButton(holder, stream, subStream, false);
        new AsyncRequest(Query.POST_UNLIKE, getId(stream, subStream), "", new AsyncRequest.Callback() {

            @Override
            public void onComplete(Response response) {
                Log.d("onComplete", "" + response.getError());
                if (response.getError() != null) {
                    Toast.makeText(context, R.string.unlike_error, Toast.LENGTH_SHORT).show();
                    setLikes(stream, subStream, true);
                }
                manageLikeButton(holder, stream, subStream, true);
                getParentAdapter().notifyDataSetChanged();
            }
        }).execute();
    }
}
Also used : Context(android.content.Context) Response(com.abewy.android.apps.klyph.core.request.Response) AsyncRequest(com.abewy.android.apps.klyph.request.AsyncRequest) IFbPermissionCallback(com.abewy.android.apps.klyph.facebook.IFbPermissionCallback)

Example 18 with Response

use of com.abewy.android.apps.klyph.core.request.Response in project Klyph by jonathangerbaud.

the class PostActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Intent intent = getIntent();
    if (intent.getStringExtra(KlyphBundleExtras.EVENT_ID) != null) {
        elementId = intent.getStringExtra(KlyphBundleExtras.EVENT_ID);
        isEventMessage = true;
    } else if (intent.getStringExtra(KlyphBundleExtras.PAGE_ID) != null) {
        elementId = intent.getStringExtra(KlyphBundleExtras.PAGE_ID);
        isPageMessage = true;
    } else if (intent.getStringExtra(KlyphBundleExtras.GROUP_ID) != null) {
        elementId = intent.getStringExtra(KlyphBundleExtras.GROUP_ID);
        isGroupMessage = true;
    } else {
        elementId = KlyphSession.getSessionUserId();
    }
    Log.d("PostActivity", "event " + isEventMessage + " page " + isPageMessage + " group " + isGroupMessage);
    boolean shareLink = intent.getBooleanExtra(KlyphBundleExtras.SHARE, false);
    String action = intent.getAction();
    String type = intent.getType();
    setTitle(isEventMessage == false ? R.string.publish_new_status : R.string.publish_new_event_message);
    photoUris = new ArrayList<String>();
    messageTextView = (TextView) findViewById(R.id.message_textview);
    friendsTextView = (TextView) findViewById(R.id.friends_textview);
    placeTextView = (TextView) findViewById(R.id.place_textview);
    photosFragment = (PostPhotos) getFragmentManager().findFragmentById(R.id.photos_fragment);
    albumsFragment = (PostAlbums) getFragmentManager().findFragmentById(R.id.albums_fragment);
    linkFragment = (PostLink) getFragmentManager().findFragmentById(R.id.link_fragment);
    shareFragment = (PostShare) getFragmentManager().findFragmentById(R.id.share_fragment);
    getFragmentManager().beginTransaction().hide(photosFragment).commitAllowingStateLoss();
    getFragmentManager().beginTransaction().hide(albumsFragment).commitAllowingStateLoss();
    getFragmentManager().beginTransaction().hide(linkFragment).commitAllowingStateLoss();
    if (shareLink == true) {
        shareFragment.initWithIntent(getIntent());
        shareFragmentVisible = true;
    } else {
        getFragmentManager().beginTransaction().hide(shareFragment).commit();
    }
    if (isEventMessage == true) {
        LinearLayout buttonBar = (LinearLayout) findViewById(R.id.button_bar);
        buttonBar.setVisibility(View.GONE);
    } else {
        ImageButton placeDeleteButton = (ImageButton) findViewById(R.id.place_delete_button);
        ImageButton friendsDeleteButton = (ImageButton) findViewById(R.id.friends_delete_button);
        friendsButton = (ImageButton) findViewById(R.id.friends_button);
        photosButton = (ImageButton) findViewById(R.id.picture_button);
        placeButton = (ImageButton) findViewById(R.id.place_button);
        linkButton = (ImageButton) findViewById(R.id.link_button);
        privacyButton = (ImageButton) findViewById(R.id.privacy_button);
        placeDeleteButton.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                clearPlace();
                updateButtonStatus();
            }
        });
        friendsDeleteButton.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                clearFriends();
                updateButtonStatus();
            }
        });
        friendsButton.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                Intent intent = new Intent(PostActivity.this, FriendPickerActivity.class);
                if (friends != null && friends.size() > 0) {
                    ArrayList<String> ids = new ArrayList<String>();
                    ids.addAll(friends.keySet());
                    intent.putStringArrayListExtra(KlyphBundleExtras.FRIEND_PICKER_IDS, ids);
                }
                startActivityForResult(intent, FRIEND_PICKER);
            }
        });
        photosButton.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                startGallery();
            }
        });
        placeButton.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                startActivityForResult(new Intent(PostActivity.this, PlacePickerActivity.class), PLACE_PICKER);
            }
        });
        linkButton.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                linkFragment.reset();
                getFragmentManager().beginTransaction().show(linkFragment).commitAllowingStateLoss();
                linkFragmentVisible = true;
                updateButtonStatus();
            }
        });
        setPrivacyListenerApi11();
        setPrivacy(KlyphPreferences.getPrivacy());
        if (Intent.ACTION_SEND.equals(action) && type != null) {
            displayBackArrow(false);
            setAppIconBackToHomeEnabled(false);
            if ("text/plain".equals(type)) {
                String sharedText = intent.getStringExtra(Intent.EXTRA_TEXT);
                String sharedSubject = intent.getStringExtra(Intent.EXTRA_SUBJECT);
                if (sharedText != null) {
                    boolean isUrl = false;
                    try {
                        new URL(sharedText);
                        isUrl = true;
                    } catch (MalformedURLException e) {
                        isUrl = false;
                    }
                    if (isUrl == true) {
                        linkFragment.setUrl(sharedText);
                        linkFragment.setTitle(sharedSubject);
                        getFragmentManager().beginTransaction().show(linkFragment).commitAllowingStateLoss();
                    } else {
                        messageTextView.setText(sharedText);
                    }
                }
            } else if (type.startsWith("image/")) {
                Uri imageUri = (Uri) intent.getParcelableExtra(Intent.EXTRA_STREAM);
                if (imageUri != null) {
                    // Update UI to reflect image being shared
                    photoUris = new ArrayList<String>();
                    if (StringUtils.startsWith(imageUri.toString(), "content://")) {
                        photoUris.add(getRealPathFromURI(imageUri));
                    } else {
                        photoUris.add(imageUri.getPath());
                    }
                    photosFragment.setImages(photoUris);
                    getFragmentManager().beginTransaction().show(photosFragment).commitAllowingStateLoss();
                    photosFragment.updateLayout();
                }
            }
        } else if (Intent.ACTION_SEND_MULTIPLE.equals(action) && type != null) {
            displayBackArrow(false);
            setAppIconBackToHomeEnabled(false);
            if (type.startsWith("image/")) {
                ArrayList<Uri> imageUris = intent.getParcelableArrayListExtra(Intent.EXTRA_STREAM);
                if (imageUris != null) {
                    // Update UI to reflect multiple images being shared
                    photoUris = new ArrayList<String>();
                    for (Uri uri : imageUris) {
                        if (StringUtils.startsWith(uri.toString(), "content://")) {
                            photoUris.add(getRealPathFromURI(uri));
                        } else {
                            photoUris.add(uri.getPath());
                        }
                    }
                    photosFragment.setImages(photoUris);
                    getFragmentManager().beginTransaction().show(photosFragment).commitAllowingStateLoss();
                    photosFragment.updateLayout();
                }
            }
        } else {
            Log.d("PostActivity", "Received other");
        }
        updateButtonStatus();
        privacyButton.setVisibility(isGroupMessage == true || isEventMessage == true ? View.GONE : View.VISIBLE);
    }
    if (KlyphData.getFriendLists() == null) {
        new AsyncRequest(Query.FRIEND_LISTS, "", "", new Callback() {

            @Override
            public void onComplete(Response response) {
                onRequestComplete(response);
            }
        }).execute();
    }
}
Also used : MalformedURLException(java.net.MalformedURLException) AsyncRequest(com.abewy.android.apps.klyph.request.AsyncRequest) ArrayList(java.util.ArrayList) Intent(android.content.Intent) View(android.view.View) TextView(android.widget.TextView) Uri(android.net.Uri) URL(java.net.URL) Response(com.abewy.android.apps.klyph.core.request.Response) ImageButton(android.widget.ImageButton) Callback(com.abewy.android.apps.klyph.core.request.BaseAsyncRequest.Callback) IFbPermissionCallback(com.abewy.android.apps.klyph.facebook.IFbPermissionCallback) TagCallback(com.abewy.android.apps.klyph.util.TextViewUtil.TagCallback) LinearLayout(android.widget.LinearLayout)

Example 19 with Response

use of com.abewy.android.apps.klyph.core.request.Response in project Klyph by jonathangerbaud.

the class PostActivity method sendRequest.

private void sendRequest(int query, String id, Bundle params) {
    if (dialog == null) {
        dialog = AlertUtil.showAlert(this, R.string.status, R.string.publishing);
        dialog.setCancelable(false);
    }
    new AsyncRequest(query, id, params, new AsyncRequest.Callback() {

        @Override
        public void onComplete(Response response) {
            onRequestResponse(response);
        }
    }).execute();
}
Also used : Response(com.abewy.android.apps.klyph.core.request.Response) AsyncRequest(com.abewy.android.apps.klyph.request.AsyncRequest) Callback(com.abewy.android.apps.klyph.core.request.BaseAsyncRequest.Callback) IFbPermissionCallback(com.abewy.android.apps.klyph.facebook.IFbPermissionCallback) TagCallback(com.abewy.android.apps.klyph.util.TextViewUtil.TagCallback)

Example 20 with Response

use of com.abewy.android.apps.klyph.core.request.Response in project Klyph by jonathangerbaud.

the class PostPhotosActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    photoUris = new ArrayList<String>();
    setTitle(R.string.publish_new_photos);
    messageTextView = (TextView) findViewById(R.id.message_textview);
    friendsTextView = (TextView) findViewById(R.id.friends_textview);
    placeTextView = (TextView) findViewById(R.id.place_textview);
    photosFragment = (PostPhotos) getFragmentManager().findFragmentById(R.id.photos_fragment);
    albumsFragment = (AlbumSpinner) getFragmentManager().findFragmentById(R.id.albums_fragment);
    albumsFragment.setDefaultAlbumId(getIntent().getExtras().getString(KlyphBundleExtras.ALBUM_ID));
    albumsFragment.setOnSelectionChangeListener(this);
    getFragmentManager().beginTransaction().hide(photosFragment).commit();
    ImageButton placeDeleteButton = (ImageButton) findViewById(R.id.place_delete_button);
    ImageButton friendsDeleteButton = (ImageButton) findViewById(R.id.friends_delete_button);
    friendsButton = (ImageButton) findViewById(R.id.friends_button);
    ImageButton add = (ImageButton) findViewById(R.id.add_button);
    ImageButton place = (ImageButton) findViewById(R.id.place_button);
    privacyButton = (ImageButton) findViewById(R.id.privacy_button);
    privacyButton.setEnabled(false);
    placeDeleteButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            clearPlace();
        }
    });
    friendsDeleteButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            clearFriends();
        }
    });
    friendsButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            Intent intent = new Intent(PostPhotosActivity.this, FriendPickerActivity.class);
            if (friends != null && friends.size() > 0) {
                ArrayList<String> ids = new ArrayList<String>();
                ids.addAll(friends.keySet());
                intent.putStringArrayListExtra(KlyphBundleExtras.FRIEND_PICKER_IDS, ids);
            }
            startActivityForResult(intent, FRIEND_PICKER);
        }
    });
    add.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            startGallery();
        }
    });
    place.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            startActivityForResult(new Intent(PostPhotosActivity.this, PlacePickerActivity.class), PLACE_PICKER);
        }
    });
    setPrivacyListenerApi11();
    setPrivacy(KlyphPreferences.getPrivacy());
    if (KlyphData.getFriendLists() == null) {
        new AsyncRequest(Query.FRIEND_LISTS, "", "", new Callback() {

            @Override
            public void onComplete(Response response) {
                onRequestComplete(response);
            }
        }).execute();
    }
}
Also used : Response(com.abewy.android.apps.klyph.core.request.Response) ImageButton(android.widget.ImageButton) AsyncRequest(com.abewy.android.apps.klyph.request.AsyncRequest) IFbPermissionCallback(com.abewy.android.apps.klyph.facebook.IFbPermissionCallback) Callback(com.abewy.android.apps.klyph.core.request.BaseAsyncRequest.Callback) TagCallback(com.abewy.android.apps.klyph.util.TextViewUtil.TagCallback) ArrayList(java.util.ArrayList) Intent(android.content.Intent) View(android.view.View) TextView(android.widget.TextView)

Aggregations

Response (com.abewy.android.apps.klyph.core.request.Response)34 AsyncRequest (com.abewy.android.apps.klyph.request.AsyncRequest)34 IFbPermissionCallback (com.abewy.android.apps.klyph.facebook.IFbPermissionCallback)17 AlertDialog (android.app.AlertDialog)9 ArrayList (java.util.ArrayList)5 Bundle (android.os.Bundle)4 Callback (com.abewy.android.apps.klyph.core.request.BaseAsyncRequest.Callback)4 Context (android.content.Context)3 GraphObject (com.abewy.android.apps.klyph.core.graph.GraphObject)3 TagCallback (com.abewy.android.apps.klyph.util.TextViewUtil.TagCallback)3 Intent (android.content.Intent)2 View (android.view.View)2 ImageButton (android.widget.ImageButton)2 TextView (android.widget.TextView)2 Photo (com.abewy.android.apps.klyph.core.fql.Photo)2 TextButtonItem (com.abewy.klyph.items.TextButtonItem)2 Uri (android.net.Uri)1 FragmentActivity (android.support.v4.app.FragmentActivity)1 ViewGroup (android.view.ViewGroup)1 InputMethodManager (android.view.inputmethod.InputMethodManager)1