Search in sources :

Example 1 with EhRequest

use of com.hippo.ehviewer.client.EhRequest in project EhViewer by seven332.

the class GalleryCommentsScene method voteComment.

private void voteComment(long id, int vote) {
    Context context = getContext2();
    MainActivity activity = getActivity2();
    if (null == context || null == activity) {
        return;
    }
    EhRequest request = new EhRequest().setMethod(EhClient.METHOD_VOTE_COMMENT).setArgs(mApiUid, mApiKey, mGid, mToken, id, vote).setCallback(new VoteCommentListener(context, activity.getStageId(), getTag()));
    EhApplication.getEhClient(context).execute(request);
}
Also used : Context(android.content.Context) MainActivity(com.hippo.ehviewer.ui.MainActivity) EhRequest(com.hippo.ehviewer.client.EhRequest)

Example 2 with EhRequest

use of com.hippo.ehviewer.client.EhRequest in project EhViewer by seven332.

the class GalleryCommentsScene method onClick.

@Override
public void onClick(View v) {
    Context context = getContext2();
    MainActivity activity = getActivity2();
    if (null == context || null == activity || null == mEditText) {
        return;
    }
    if (mFab == v) {
        if (!mInAnimation) {
            prepareNewComment();
            showEditPanel(true);
        }
    } else if (mSendImage == v) {
        if (!mInAnimation) {
            String comment = mEditText.getText().toString();
            if (TextUtils.isEmpty(comment)) {
                // Comment is empty
                return;
            }
            String url = getGalleryDetailUrl();
            if (url == null) {
                return;
            }
            // Request
            EhRequest request = new EhRequest().setMethod(EhClient.METHOD_GET_COMMENT_GALLERY).setArgs(url, comment, mCommentId != 0 ? Long.toString(mCommentId) : null).setCallback(new CommentGalleryListener(context, activity.getStageId(), getTag(), mCommentId));
            EhApplication.getEhClient(context).execute(request);
            hideSoftInput();
            hideEditPanel(true);
        }
    }
}
Also used : Context(android.content.Context) MainActivity(com.hippo.ehviewer.ui.MainActivity) SpannableString(android.text.SpannableString) EhRequest(com.hippo.ehviewer.client.EhRequest)

Example 3 with EhRequest

use of com.hippo.ehviewer.client.EhRequest in project EhViewer by seven332.

the class GalleryDetailScene method request.

private boolean request() {
    Context context = getContext2();
    MainActivity activity = getActivity2();
    String url = getGalleryDetailUrl(false);
    if (null == context || null == activity || null == url) {
        return false;
    }
    EhClient.Callback callback = new GetGalleryDetailListener(context, activity.getStageId(), getTag());
    mRequestId = ((EhApplication) context.getApplicationContext()).putGlobalStuff(callback);
    EhRequest request = new EhRequest().setMethod(EhClient.METHOD_GET_GALLERY_DETAIL).setArgs(url).setCallback(callback);
    EhApplication.getEhClient(context).execute(request);
    return true;
}
Also used : Context(android.content.Context) MainActivity(com.hippo.ehviewer.ui.MainActivity) EhClient(com.hippo.ehviewer.client.EhClient) EhRequest(com.hippo.ehviewer.client.EhRequest)

Example 4 with EhRequest

use of com.hippo.ehviewer.client.EhRequest in project EhViewer by seven332.

the class CommonOperations method removeFromFavorites.

public static void removeFromFavorites(Activity activity, GalleryInfo galleryInfo, final EhClient.Callback<Void> listener) {
    EhDB.removeLocalFavorites(galleryInfo.gid);
    EhClient client = EhApplication.getEhClient(activity);
    EhRequest request = new EhRequest();
    request.setMethod(EhClient.METHOD_ADD_FAVORITES);
    request.setArgs(galleryInfo.gid, galleryInfo.token, -1, "");
    request.setCallback(new DelegateFavoriteCallback(listener, galleryInfo, null, -2));
    client.execute(request);
}
Also used : EhClient(com.hippo.ehviewer.client.EhClient) EhRequest(com.hippo.ehviewer.client.EhRequest)

Example 5 with EhRequest

use of com.hippo.ehviewer.client.EhRequest in project EhViewer by seven332.

the class ProgressScene method doJobs.

private boolean doJobs() {
    Context context = getContext2();
    MainActivity activity = getActivity2();
    if (null == context || null == activity) {
        return false;
    }
    if (ACTION_GALLERY_TOKEN.equals(mAction)) {
        if (mGid == -1 || mPToken == null || mPage == -1) {
            return false;
        }
        EhRequest request = new EhRequest().setMethod(EhClient.METHOD_GET_GALLERY_TOKEN).setArgs(mGid, mPToken, mPage).setCallback(new GetGalleryTokenListener(context, activity.getStageId(), getTag()));
        EhApplication.getEhClient(context).execute(request);
        return true;
    }
    return false;
}
Also used : Context(android.content.Context) MainActivity(com.hippo.ehviewer.ui.MainActivity) EhRequest(com.hippo.ehviewer.client.EhRequest)

Aggregations

EhRequest (com.hippo.ehviewer.client.EhRequest)9 MainActivity (com.hippo.ehviewer.ui.MainActivity)7 Context (android.content.Context)6 EhClient (com.hippo.ehviewer.client.EhClient)3 SpannableString (android.text.SpannableString)2 ClickableSpan (android.text.style.ClickableSpan)1 URLSpan (android.text.style.URLSpan)1 RecyclerView (androidx.recyclerview.widget.RecyclerView)1 EasyRecyclerView (com.hippo.easyrecyclerview.EasyRecyclerView)1 IOException (java.io.IOException)1 JSONException (org.json.JSONException)1