当前位置: 首页>>代码示例>>Java>>正文


Java Thing类代码示例

本文整理汇总了Java中net.dean.jraw.models.Thing的典型用法代码示例。如果您正苦于以下问题:Java Thing类的具体用法?Java Thing怎么用?Java Thing使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Thing类属于net.dean.jraw.models包,在下文中一共展示了Thing类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getSummoningComment

import net.dean.jraw.models.Thing; //导入依赖的package包/类
@Override
public Comment getSummoningComment(Message message) {
    String id = message.data("name");
    if (id == null) {
        LOG.warn("Comment ID is null for passed in Message(id: %s)", message.getFullName());
        return null;
    }

    Listing<Thing> listing;
    try {
        listing = getRedditClient().get(id);
    } catch (Exception e) {
        LOG.error("Could not get summoning comment with id(%s): %s", id, e.getMessage());
        return null;
    }

    if (listing == null || listing.size() == 0) {
        LOG.error("No Comment returned for passed in Message: %s", message.getFullName());
        return null;
    }

    return (Comment) listing.get(0);
}
 
开发者ID:sgskinner,项目名称:StashThisBot,代码行数:24,代码来源:RedditServiceImpl.java

示例2: getSubmissionById

import net.dean.jraw.models.Thing; //导入依赖的package包/类
@Override
public Submission getSubmissionById(String submissionId) {
    Listing<Thing> listing;
    try {
        listing = getRedditClient().get(submissionId);
    } catch (Exception e) {
        LOG.error("Could not get subbmission by id(%s): %s", submissionId, e.getMessage());
        return null;
    }

    if (listing == null || listing.size() == 0) {
        LOG.warn("Submission with id(%s) came back null or empty.", submissionId);
        return null;
    }

    return (Submission) listing.get(0);
}
 
开发者ID:sgskinner,项目名称:StashThisBot,代码行数:18,代码来源:RedditServiceImpl.java

示例3: getTargetPostable

import net.dean.jraw.models.Thing; //导入依赖的package包/类
@Override
public Postable getTargetPostable(Message message) {
    String targetId = message.getParentId();
    if (targetId == null) {
        LOG.warn("Target ID is null for passed in Message: %s", message.getFullName());
        return null;
    }

    Listing<Thing> listing = null;
    try {
        listing = getRedditClient().get(targetId);
    } catch (Exception e) {
        LOG.error("Could not get listing for target reddit Thing with id(%s): %s", targetId, e.getMessage());
    }

    if (listing == null || listing.size() == 0) {
        LOG.warn("No comment returned for passed in Message: %s", message.getFullName());
        return null;
    }

    return new Postable(listing.get(0));
}
 
开发者ID:sgskinner,项目名称:StashThisBot,代码行数:23,代码来源:RedditServiceImpl.java

示例4: buildRedditCommentUrl

import net.dean.jraw.models.Thing; //导入依赖的package包/类
private String buildRedditCommentUrl(Submission submission, Thing thing) {
    // |--------------------------------------------- 1 ---------------------------------------------------------||-- 2 --|
    // https://www.reddit.com/r/ArchiveThisBotSandbox/comments/6qdqub/yatr_yet_another_test_run_here_we_are_again/dkwgsdw/
    // 1. submission.getUrl()
    // 2. commentNode.getComment().getId()
    return submission.getUrl() + thing.getId();
}
 
开发者ID:sgskinner,项目名称:StashThisBot,代码行数:8,代码来源:StashResult.java

示例5: Postable

import net.dean.jraw.models.Thing; //导入依赖的package包/类
public Postable(Thing thing) {
    this.thing = thing;
}
 
开发者ID:sgskinner,项目名称:StashThisBot,代码行数:4,代码来源:Postable.java

示例6: getThing

import net.dean.jraw.models.Thing; //导入依赖的package包/类
public Thing getThing() {
    return thing;
}
 
开发者ID:sgskinner,项目名称:StashThisBot,代码行数:4,代码来源:Postable.java

示例7: doInBackground

import net.dean.jraw.models.Thing; //导入依赖的package包/类
@Override
protected ArrayList<Contribution> doInBackground(String... subredditPaginators) {
    ArrayList<Contribution> newData = new ArrayList<>();
    try {
        if (reset || paginator == null) {
            ArrayList<String> ids = new ArrayList<>();
            HashMap<Long, String> idsSorted = new HashMap<>();
            Map<String, String> values;
            if (prefix.isEmpty()) {
                values = KVStore.getInstance().getByContains("");
            } else {
                values = KVStore.getInstance().getByPrefix(prefix);
            }


            for (Map.Entry<String, String> entry : values.entrySet()) {
                Object done;
                if (entry.getValue().equals("true") || entry.getValue().equals("false")) {
                    done = Boolean.valueOf(entry.getValue());
                } else {
                    done = Long.valueOf(entry.getValue());
                }
                if (prefix.isEmpty()) {
                    if (!entry.getKey().contains("readLater")) {
                        if (entry.getKey().length() == 6 && done instanceof Boolean) {
                            ids.add("t3_" + entry.getKey());
                        } else if (done instanceof Long) {
                            if (entry.getKey().contains("_")) {
                                idsSorted.put((Long) done, entry.getKey());
                            } else {
                                idsSorted.put((Long) done, "t3_" + entry.getKey());
                            }
                        }
                    }
                } else {
                    String key = entry.getKey();
                    if(!key.contains("_")){
                        key = "t3_" + key;
                    }
                    idsSorted.put((Long) done, key.replace(prefix, ""));
                }
            }

            if (!idsSorted.isEmpty()) {
                TreeMap<Long, String> result2 = new TreeMap<>(Collections.reverseOrder());
                result2.putAll(idsSorted);
                ids.addAll(0, result2.values());
            }

            paginator = new FullnamesPaginator(Authentication.reddit,
                    ids.toArray(new String[ids.size()-1]));


        }

        if (!paginator.hasNext()) {
            nomore = true;
            return new ArrayList<>();
        }

        for (Thing c : paginator.next()) {
            if (c instanceof Contribution) {
                newData.add((Contribution) c);
            }
        }

        return newData;
    } catch (Exception e) {
        e.printStackTrace();
        return null;
    }
}
 
开发者ID:ccrama,项目名称:Slide,代码行数:73,代码来源:HistoryPosts.java

示例8: approveSubmission

import net.dean.jraw.models.Thing; //导入依赖的package包/类
private <T extends Thing> void approveSubmission(final Context mContext, final List<T> posts,
        final Submission submission, final RecyclerView recyclerview,
        final SubmissionViewHolder holder) {
    new AsyncTask<Void, Void, Boolean>() {

        @Override
        public void onPostExecute(Boolean b) {
            if (b) {
                SubmissionCache.approved.add(submission.getFullName());
                SubmissionCache.removed.remove(submission.getFullName());
                SubmissionCache.updateInfoSpannable(submission, mContext,
                        submission.getSubredditName());

                if (mContext instanceof ModQueue) {
                    final int pos = posts.indexOf(submission);
                    posts.remove(submission);

                    if (pos == 0) {
                        recyclerview.getAdapter().notifyDataSetChanged();
                    } else {
                        recyclerview.getAdapter().notifyItemRemoved(pos + 1);
                    }
                } else {
                    recyclerview.getAdapter().notifyItemChanged(holder.getAdapterPosition());
                }

                try {
                    Snackbar s = Snackbar.make(holder.itemView, R.string.mod_approved,
                            Snackbar.LENGTH_LONG);
                    View view = s.getView();
                    TextView tv = (TextView) view.findViewById(
                            android.support.design.R.id.snackbar_text);
                    tv.setTextColor(Color.WHITE);
                    s.show();
                } catch (Exception ignored) {

                }

            } else {
                new AlertDialogWrapper.Builder(mContext).setTitle(R.string.err_general)
                        .setMessage(R.string.err_retry_later)
                        .show();
            }
        }

        @Override
        protected Boolean doInBackground(Void... params) {
            try {
                new ModerationManager(Authentication.reddit).approve(submission);
            } catch (ApiException e) {
                e.printStackTrace();
                return false;

            }
            return true;
        }
    }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
 
开发者ID:ccrama,项目名称:Slide,代码行数:59,代码来源:PopulateSubmissionViewHolder.java


注:本文中的net.dean.jraw.models.Thing类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。