Search in sources :

Example 6 with MainActivity

use of com.hippo.ehviewer.ui.MainActivity in project EhViewer by seven332.

the class SignInScene method signIn.

private void signIn() {
    if (mSigningIn) {
        return;
    }
    Context context = getContext2();
    MainActivity activity = getActivity2();
    if (null == context || null == activity || null == mUsername || null == mPassword || null == mUsernameLayout || null == mPasswordLayout) {
        return;
    }
    String username = mUsername.getText().toString();
    String password = mPassword.getText().toString();
    if (username.isEmpty()) {
        mUsernameLayout.setError(getString(R.string.error_username_cannot_empty));
        return;
    } else {
        mUsernameLayout.setError(null);
    }
    if (password.isEmpty()) {
        mPasswordLayout.setError(getString(R.string.error_password_cannot_empty));
        return;
    } else {
        mPasswordLayout.setError(null);
    }
    hideSoftInput();
    showProgress(true);
    // Clean up for sign in
    EhUtils.signOut(context);
    String challenge = mRecaptchaView.getChallenge();
    String response = mRecaptcha.getText().toString();
    EhCallback callback = new SignInListener(context, activity.getStageId(), getTag());
    mRequestId = ((EhApplication) context.getApplicationContext()).putGlobalStuff(callback);
    EhRequest request = new EhRequest().setMethod(EhClient.METHOD_SIGN_IN).setArgs(username, password, challenge, response).setCallback(callback);
    EhApplication.getEhClient(context).execute(request);
    mSigningIn = true;
}
Also used : Context(android.content.Context) MainActivity(com.hippo.ehviewer.ui.MainActivity) EhRequest(com.hippo.ehviewer.client.EhRequest)

Example 7 with MainActivity

use of com.hippo.ehviewer.ui.MainActivity in project EhViewer by seven332.

the class SignInScene method redirectTo.

private void redirectTo() {
    Settings.putNeedSignIn(false);
    MainActivity activity = getActivity2();
    if (null != activity) {
        startSceneForCheckStep(CHECK_STEP_SIGN_IN, getArguments());
    }
    finish();
}
Also used : MainActivity(com.hippo.ehviewer.ui.MainActivity)

Example 8 with MainActivity

use of com.hippo.ehviewer.ui.MainActivity 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) {
            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).setCallback(new CommentGalleryListener(context, activity.getStageId(), getTag()));
            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 9 with MainActivity

use of com.hippo.ehviewer.ui.MainActivity 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 10 with MainActivity

use of com.hippo.ehviewer.ui.MainActivity in project EhViewer by seven332.

the class AnalyticsScene method onClick.

@Override
public void onClick(View v) {
    Context context = getContext2();
    if (null == context) {
        return;
    }
    if (mReject == v) {
        Settings.putEnableAnalytics(false);
    } else if (mAccept == v) {
        Settings.putEnableAnalytics(true);
        // Start Analytics
        Analytics.start(context);
    }
    Settings.putAskAnalytics(false);
    // Start new scene and finish it self
    MainActivity activity = getActivity2();
    if (null != activity) {
        startSceneForCheckStep(CHECK_STEP_ANALYTICS, getArguments());
    }
    finish();
}
Also used : Context(android.content.Context) MainActivity(com.hippo.ehviewer.ui.MainActivity)

Aggregations

MainActivity (com.hippo.ehviewer.ui.MainActivity)18 Context (android.content.Context)10 EhRequest (com.hippo.ehviewer.client.EhRequest)6 AlertDialog (android.support.v7.app.AlertDialog)3 GalleryInfo (com.hippo.ehviewer.client.data.GalleryInfo)3 DialogInterface (android.content.DialogInterface)2 Point (android.graphics.Point)2 ShowcaseView (com.github.amlcurran.showcaseview.ShowcaseView)2 SimpleShowcaseEventListener (com.github.amlcurran.showcaseview.SimpleShowcaseEventListener)2 CheckBoxDialogBuilder (com.hippo.app.CheckBoxDialogBuilder)2 Announcer (com.hippo.scene.Announcer)2 SuppressLint (android.annotation.SuppressLint)1 Dialog (android.app.Dialog)1 Intent (android.content.Intent)1 Bundle (android.os.Bundle)1 RecyclerView (android.support.v7.widget.RecyclerView)1 SpannableString (android.text.SpannableString)1 Display (android.view.Display)1 PointTarget (com.github.amlcurran.showcaseview.targets.PointTarget)1 ViewTarget (com.github.amlcurran.showcaseview.targets.ViewTarget)1