Search in sources :

Example 1 with ResponseHandler

use of me.yluo.ruisiapp.myhttp.ResponseHandler in project Ruisi by freedom10086.

the class PostActivity method startBlock.

private void startBlock(int position) {
    String url = "forum.php?mod=topicadmin&action=banpost" + "&fid=" + fid + "&tid=" + tid + "&topiclist[]=" + datas.get(position).pid + "&mobile=2&inajax=1";
    params = null;
    HttpUtil.get(url, new ResponseHandler() {

        @Override
        public void onSuccess(byte[] response) {
            Document document = RuisUtils.getManageContent(response);
            params = RuisUtils.getForms(document, "topicadminform");
        }

        @Override
        public void onFailure(Throwable e) {
            super.onFailure(e);
            showToast("网络错误!请重试");
        }
    });
}
Also used : ResponseHandler(me.yluo.ruisiapp.myhttp.ResponseHandler) Document(org.jsoup.nodes.Document)

Example 2 with ResponseHandler

use of me.yluo.ruisiapp.myhttp.ResponseHandler in project Ruisi by freedom10086.

the class PostActivity method closeArticle.

// 打开或者关闭帖子
private void closeArticle(String[] str) {
    if (str.length == 3) {
        params.put("expirationclose", str[1] + " " + str[2]);
    } else {
        params.put("expirationclose", "");
    }
    if (str[0].equals("打开")) {
        params.put("operations[]", "open");
    } else if (str[0].equals("关闭")) {
        params.put("operations[]", "close");
    }
    params.put("reason", "手机版主题操作");
    HttpUtil.post(UrlUtils.getCloseArticleUrl(), params, new ResponseHandler() {

        @Override
        public void onSuccess(byte[] response) {
            String res = new String(response);
            if (res.contains("成功")) {
                showToast(str[0] + "帖子操作成功,刷新帖子即可看到效果");
            } else {
                showToast("管理操作失败,我也不知道哪里有问题");
            }
        }

        @Override
        public void onFailure(Throwable e) {
            super.onFailure(e);
            showToast("网络错误," + str[0] + "帖子失败!");
        }
    });
}
Also used : ResponseHandler(me.yluo.ruisiapp.myhttp.ResponseHandler)

Example 3 with ResponseHandler

use of me.yluo.ruisiapp.myhttp.ResponseHandler in project Ruisi by freedom10086.

the class PostActivity method getArticleData.

// 文章一页的html 根据页数 tid
private void getArticleData(final int page) {
    String url;
    final boolean api = App.IS_SCHOOL_NET;
    if (App.IS_SCHOOL_NET) {
        url = UrlUtils.getArticleApiUrl(tid, currentPage, 20);
    } else {
        url = UrlUtils.getSingleArticleUrl(tid, page, false);
    }
    HttpUtil.get(url, new ResponseHandler() {

        @Override
        public void onSuccess(byte[] response) {
            // if (api) {
            // new DealWithArticleDataApi(PostActivity.this).execute(response);
            // } else {
            new DealWithArticleData(PostActivity.this).execute(new String(response));
        // }
        }

        @Override
        public void onFailure(Throwable e) {
            if (e != null && e == SyncHttpClient.NeedLoginError) {
                isLogin();
                showToast("此贴需要登录才能查看");
                return;
            }
            enableLoadMore = true;
            adapter.changeLoadMoreState(BaseAdapter.STATE_LOAD_FAIL);
            showToast("加载失败(Error -1)");
        }
    });
}
Also used : ResponseHandler(me.yluo.ruisiapp.myhttp.ResponseHandler)

Example 4 with ResponseHandler

use of me.yluo.ruisiapp.myhttp.ResponseHandler in project Ruisi by freedom10086.

the class PostActivity method startWarn.

private void startWarn(int position) {
    if (App.IS_SCHOOL_NET) {
        // computer
        params = new HashMap<>();
        params.put("fid", fid);
        params.put("page", "1");
        params.put("tid", tid);
        params.put("handlekey", "mods");
        params.put("topiclist[]", datas.get(position).pid);
        params.put("reason", " 手机版主题操作");
    } else {
        String url = "forum.php?mod=topicadmin&action=warn&fid=" + fid + "&tid=" + tid + "&operation=&optgroup=&page=&topiclist[]=" + datas.get(position).pid + "&mobile=2&inajax=1";
        // url = forum.php?mod=topicadmin&action=warn&fid=72&tid=922824&handlekey=mods&infloat=yes&nopost=yes&r0.8544855790245922&inajax=1
        params = null;
        HttpUtil.get(url, new ResponseHandler() {

            @Override
            public void onSuccess(byte[] response) {
                Document document = getManageContent(response);
                params = RuisUtils.getForms(document, "topicadminform");
            }

            @Override
            public void onFailure(Throwable e) {
                super.onFailure(e);
            }
        });
    }
}
Also used : ResponseHandler(me.yluo.ruisiapp.myhttp.ResponseHandler) Document(org.jsoup.nodes.Document)

Example 5 with ResponseHandler

use of me.yluo.ruisiapp.myhttp.ResponseHandler in project Ruisi by freedom10086.

the class PostsActivity method getData.

private void getData() {
    adapter.changeLoadMoreState(BaseAdapter.STATE_LOADING);
    String url;
    if (!App.IS_SCHOOL_NET) {
        url = UrlUtils.getArticleListUrl(FID, currentPage, false);
    } else if (getType() == PostListAdapter.TYPE_IMAGE) {
        url = UrlUtils.getArticleListUrl(FID, currentPage, true);
    } else {
        url = UrlUtils.getArticleListApiUrl(FID, currentPage);
    }
    url = url + orders[currentTabindex];
    HttpUtil.get(url, new ResponseHandler() {

        @Override
        public void onSuccess(byte[] response) {
            switch(getType()) {
                case PostListAdapter.TYPE_IMAGE:
                    new getImagePosts().execute(new String(response));
                    break;
                case PostListAdapter.TYPE_NORMAL:
                    new getPostsApi().execute(response);
                    break;
                case PostListAdapter.TYPE_NORMAL_MOBILE:
                    // 外网
                    new getPostsMe().execute(new String(response));
                    break;
            }
        }

        @Override
        public void onFailure(Throwable e) {
            refreshLayout.postDelayed(() -> refreshLayout.setRefreshing(false), 500);
            adapter.changeLoadMoreState(BaseAdapter.STATE_LOAD_FAIL);
        }
    });
}
Also used : ResponseHandler(me.yluo.ruisiapp.myhttp.ResponseHandler)

Aggregations

ResponseHandler (me.yluo.ruisiapp.myhttp.ResponseHandler)38 Document (org.jsoup.nodes.Document)13 HashMap (java.util.HashMap)12 ProgressDialog (android.app.ProgressDialog)8 Bundle (android.os.Bundle)8 Element (org.jsoup.nodes.Element)7 Elements (org.jsoup.select.Elements)7 Intent (android.content.Intent)5 View (android.view.View)5 R (me.yluo.ruisiapp.R)5 HttpUtil (me.yluo.ruisiapp.myhttp.HttpUtil)5 GetId (me.yluo.ruisiapp.utils.GetId)5 SharedPreferences (android.content.SharedPreferences)4 ArrayList (java.util.ArrayList)4 List (java.util.List)4 App (me.yluo.ruisiapp.App)4 Context (android.content.Context)3 PackageInfo (android.content.pm.PackageInfo)3 PackageManager (android.content.pm.PackageManager)3 Log (android.util.Log)3