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


Java Story类代码示例

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


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

示例1: getCustomTabIntent

import io.plaidapp.data.api.designernews.model.Story; //导入依赖的package包/类
public static CustomTabsIntent.Builder getCustomTabIntent(@NonNull Context context,
                                                          @NonNull Story story,
                                                          @Nullable CustomTabsSession session) {
    Intent upvoteStory = new Intent(context, UpvoteStoryService.class);
    upvoteStory.setAction(UpvoteStoryService.ACTION_UPVOTE);
    upvoteStory.putExtra(UpvoteStoryService.EXTRA_STORY_ID, story.id);
    PendingIntent pendingIntent = PendingIntent.getService(context, 0, upvoteStory, 0);
    return new CustomTabsIntent.Builder(session)
            .setToolbarColor(ContextCompat.getColor(context, R.color.designer_news))
            .setActionButton(ImageUtils.vectorToBitmap(context,
                            R.drawable.ic_upvote_filled_24dp_white),
                    context.getString(R.string.upvote_story),
                    pendingIntent,
                    false)
            .setShowTitle(true)
            .enableUrlBarHiding()
            .addDefaultShareMenuItem();
}
 
开发者ID:liulinbo,项目名称:Amumu,代码行数:19,代码来源:DesignerNewsStory.java

示例2: onBindViewHolder

import io.plaidapp.data.api.designernews.model.Story; //导入依赖的package包/类
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
    switch (getItemViewType(position)) {
        case TYPE_DESIGNER_NEWS_STORY:
            bindDesignerNewsStory((Story) getItem(position), (DesignerNewsStoryHolder) holder);
            break;
        case TYPE_DRIBBBLE_SHOT:
            bindDribbbleShotHolder((Shot) getItem(position), (DribbbleShotHolder) holder);
            break;
        case TYPE_PRODUCT_HUNT_POST:
            bindProductHuntPostView((Post) getItem(position), (ProductHuntStoryHolder) holder);
            break;
        case TYPE_LOADING_MORE:
            bindLoadingViewHolder((LoadingMoreHolder) holder);
            break;
    }
}
 
开发者ID:liulinbo,项目名称:Amumu,代码行数:18,代码来源:FeedAdapter.java

示例3: handleActionUpvote

import io.plaidapp.data.api.designernews.model.Story; //导入依赖的package包/类
private void handleActionUpvote(long storyId) {
    if (storyId == 0L) return;
    final DesignerNewsPrefs designerNewsPrefs = DesignerNewsPrefs.get(this);
    if (!designerNewsPrefs.isLoggedIn()) {
        // TODO prompt for login
        return;
    }

    final Call<Story> upvoteStoryCall = designerNewsPrefs.getApi().upvoteStory(storyId);
    try {
        final Response<Story> response = upvoteStoryCall.execute();
        // int newVotesCount = response.body().vote_count;
        // TODO report success
    } catch (Exception e) {
        // TODO report failure
    }
}
 
开发者ID:yongjhih,项目名称:android-proguards,代码行数:18,代码来源:UpvoteStoryService.java

示例4: onBindViewHolder

import io.plaidapp.data.api.designernews.model.Story; //导入依赖的package包/类
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
    switch (getItemViewType(position)) {
        case TYPE_DESIGNER_NEWS_STORY:
            bindDesignerNewsStory((Story) getItem(position), (DesignerNewsStoryHolder) holder);
            break;
        case TYPE_DRIBBBLE_SHOT:
            bindDribbbleShotHolder(
                    (Shot) getItem(position), (DribbbleShotHolder) holder, position);
            break;
        case TYPE_PRODUCT_HUNT_POST:
            bindProductHuntPostView((Post) getItem(position), (ProductHuntStoryHolder) holder);
            break;
        case TYPE_LOADING_MORE:
            bindLoadingViewHolder((LoadingMoreHolder) holder, position);
            break;
    }
}
 
开发者ID:yongjhih,项目名称:android-proguards,代码行数:19,代码来源:FeedAdapter.java

示例5: getCustomTabIntent

import io.plaidapp.data.api.designernews.model.Story; //导入依赖的package包/类
public static CustomTabsIntent.Builder getCustomTabIntent(@NonNull Context context,
                                                          @NonNull Story story,
                                                          @Nullable CustomTabsSession session) {
    Intent upvoteStory = new Intent(context, UpvoteStoryService.class);
    upvoteStory.setAction(UpvoteStoryService.ACTION_UPVOTE);
    upvoteStory.putExtra(UpvoteStoryService.EXTRA_STORY_ID, story.id);
    PendingIntent pendingIntent = PendingIntent.getService(context, 0, upvoteStory, 0);
    return new CustomTabsIntent.Builder(session)
            .setToolbarColor(ContextCompat.getColor(context, R.color.designer_news))
            .setActionButton(DrawableUtils.drawableToBitmap(context,
                            R.drawable.ic_upvote_filled_24dp_white),
                    context.getString(R.string.upvote_story),
                    pendingIntent,
                    false)
            .setShowTitle(true)
            .enableUrlBarHiding()
            .addDefaultShareMenuItem();
}
 
开发者ID:nickbutcher,项目名称:plaid,代码行数:19,代码来源:DesignerNewsStory.java

示例6: getItemViewType

import io.plaidapp.data.api.designernews.model.Story; //导入依赖的package包/类
@Override
public int getItemViewType(int position) {
    if (position < getDataItemCount()
            && getDataItemCount() > 0) {
        PlaidItem item = getItem(position);
        if (item instanceof Story) {
            return TYPE_DESIGNER_NEWS_STORY;
        } else if (item instanceof Shot) {
            return TYPE_DRIBBBLE_SHOT;
        } else if (item instanceof Post) {
            return TYPE_PRODUCT_HUNT_POST;
        }
    }
    return TYPE_LOADING_MORE;
}
 
开发者ID:liulinbo,项目名称:Amumu,代码行数:16,代码来源:FeedAdapter.java

示例7: onHandleIntent

import io.plaidapp.data.api.designernews.model.Story; //导入依赖的package包/类
@Override
protected void onHandleIntent(Intent intent) {
    if (intent == null) return;
    if (ACTION_POST_NEW_STORY.equals(intent.getAction())) {
        final boolean broadcastResult = intent.getBooleanExtra(EXTRA_BROADCAST_RESULT, false);
        final DesignerNewsPrefs designerNewsPrefs = DesignerNewsPrefs.get(this);
        if (!designerNewsPrefs.isLoggedIn()) return; // shouldn't happen...

        final String title = intent.getStringExtra(EXTRA_STORY_TITLE);
        final String url = intent.getStringExtra(EXTRA_STORY_URL);
        final String comment = intent.getStringExtra(EXTRA_STORY_COMMENT);
        if (TextUtils.isEmpty(title)) return;
        NewStoryRequest storyToPost = null;
        if (!TextUtils.isEmpty(url)) {
            storyToPost = NewStoryRequest.createWithUrl(title, url);
        } else if (!TextUtils.isEmpty(comment)) {
            storyToPost = NewStoryRequest.createWithComment(title, comment);
        }
        if (storyToPost == null) return;

        final Call<StoriesResponse> postStoryCall =
                designerNewsPrefs.getApi().postStory(storyToPost);
        try {
            final Response<StoriesResponse> response = postStoryCall.execute();
            final StoriesResponse story = response.body();
            if (story != null && story.stories != null && !story.stories.isEmpty()) {
                if (broadcastResult) {
                    final Intent success = new Intent(BROADCAST_ACTION_SUCCESS);
                    // API doesn't fill in author details so add them here
                    final Story returnedStory = story.stories.get(0);
                    final Story.Builder builder = Story.Builder.from(returnedStory)
                            .setUserId(designerNewsPrefs.getUserId())
                            .setUserDisplayName(designerNewsPrefs.getUserName())
                            .setUserPortraitUrl(designerNewsPrefs.getUserAvatar());
                    // API doesn't add a self URL, so potentially add one for consistency
                    if (TextUtils.isEmpty(returnedStory.url)) {
                        builder.setDefaultUrl(returnedStory.id);
                    }
                    final Story newStory = builder.build();
                    newStory.dataSource = SOURCE_NEW_DN_POST;
                    success.putExtra(EXTRA_NEW_STORY, newStory);
                    LocalBroadcastManager.getInstance(getApplicationContext())
                            .sendBroadcast(success);
                } else {
                    Toast.makeText(getApplicationContext(), "Story posted",
                            Toast.LENGTH_SHORT).show();
                }
            }
        } catch (Exception e) {
            final String reason = e.getMessage();
            if (broadcastResult) {
                final Intent failure = new Intent(BROADCAST_ACTION_FAILURE);
                failure.putExtra(BROADCAST_ACTION_FAILURE_REASON, reason);
                LocalBroadcastManager.getInstance(getApplicationContext())
                        .sendBroadcast(failure);
            } else {
                Toast.makeText(getApplicationContext(), reason, Toast.LENGTH_SHORT).show();
            }
        }
    }
}
 
开发者ID:liulinbo,项目名称:Amumu,代码行数:62,代码来源:PostStoryService.java

示例8: createDesignerNewsStoryHolder

import io.plaidapp.data.api.designernews.model.Story; //导入依赖的package包/类
@NonNull
private DesignerNewsStoryHolder createDesignerNewsStoryHolder(ViewGroup parent) {
    final DesignerNewsStoryHolder holder = new DesignerNewsStoryHolder(layoutInflater.inflate(
            R.layout.designer_news_story_item, parent, false), pocketIsInstalled);
    holder.itemView.setOnClickListener(
            new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    final Story story = (Story) getItem(holder.getAdapterPosition());
                    CustomTabActivityHelper.openCustomTab(host,
                            DesignerNewsStory.getCustomTabIntent(host, story, null).build(),
                            Uri.parse(story.url));
                }
            }
                                      );
    holder.comments.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View commentsView) {
            final Intent intent = new Intent();
            intent.setClass(host, DesignerNewsStory.class);
            intent.putExtra(DesignerNewsStory.EXTRA_STORY,
                    (Story) getItem(holder.getAdapterPosition()));
            setGridItemContentTransitions(holder.itemView);
            final ActivityOptions options =
                    ActivityOptions.makeSceneTransitionAnimation(host,
                            Pair.create(holder.itemView,
                                    host.getString(R.string.transition_story_title_background)),
                            Pair.create(holder.itemView,
                                    host.getString(R.string.transition_story_background)));
            host.startActivity(intent, options.toBundle());
        }
    });
    if (pocketIsInstalled) {
        holder.pocket.setImageAlpha(178); // grumble... no xml setter, grumble...
        holder.pocket.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(final View view) {
                PocketUtils.addToPocket(host,
                        ((Story) getItem(holder.getAdapterPosition())).url);
                // notify changed with a payload asking RV to run the anim
                notifyItemChanged(holder.getAdapterPosition(),
                        HomeGridItemAnimator.ANIMATE_ADD_POCKET);
            }
        });
    }
    return holder;
}
 
开发者ID:liulinbo,项目名称:Amumu,代码行数:48,代码来源:FeedAdapter.java

示例9: bindDesignerNewsStory

import io.plaidapp.data.api.designernews.model.Story; //导入依赖的package包/类
private void bindDesignerNewsStory(final Story story, final DesignerNewsStoryHolder holder) {
    holder.title.setText(story.title);
    holder.comments.setText(String.valueOf(story.comment_count));
}
 
开发者ID:liulinbo,项目名称:Amumu,代码行数:5,代码来源:FeedAdapter.java

示例10: onReceive

import io.plaidapp.data.api.designernews.model.Story; //导入依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
    ensurePostingProgressInflated();
    switch (intent.getAction()) {
        case PostStoryService.BROADCAST_ACTION_SUCCESS:
            // success animation
            AnimatedVectorDrawable complete =
                    (AnimatedVectorDrawable) getDrawable(R.drawable.avd_upload_complete);
            fabPosting.setImageDrawable(complete);
            complete.start();
            fabPosting.postDelayed(new Runnable() {
                @Override
                public void run() {
                    fabPosting.setVisibility(View.GONE);
                }
            }, 2100); // length of R.drawable.avd_upload_complete

            // actually add the story to the grid
            Story newStory = intent.getParcelableExtra(PostStoryService.EXTRA_NEW_STORY);
            adapter.addAndResort(Arrays.asList(new Story[]{ newStory }));
            break;
        case PostStoryService.BROADCAST_ACTION_FAILURE:
            // failure animation
            AnimatedVectorDrawable failed =
                    (AnimatedVectorDrawable) getDrawable(R.drawable.avd_upload_error);
            fabPosting.setImageDrawable(failed);
            failed.start();
            // remove the upload progress 'fab' and reshow the regular one
            fabPosting.animate()
                    .alpha(0f)
                    .rotation(90f)
                    .setStartDelay(2000L) // leave error on screen briefly
                    .setDuration(300L)
                    .setInterpolator(AnimUtils.getFastOutSlowInInterpolator(HomeActivity
                            .this))
                    .setListener(new AnimatorListenerAdapter() {
                        @Override
                        public void onAnimationEnd(Animator animation) {
                            fabPosting.setVisibility(View.GONE);
                            fabPosting.setAlpha(1f);
                            fabPosting.setRotation(0f);
                        }
                    });
            break;
    }
    unregisterPostStoryResultListener();
}
 
开发者ID:liulinbo,项目名称:Amumu,代码行数:48,代码来源:HomeActivity.java

示例11: getTopStories

import io.plaidapp.data.api.designernews.model.Story; //导入依赖的package包/类
@EnvelopePayload("stories")
@GET("api/v1/stories")
Call<List<Story>> getTopStories(@Query("page") Integer page);
 
开发者ID:yongjhih,项目名称:android-proguards,代码行数:4,代码来源:DesignerNewsService.java

示例12: getRecentStories

import io.plaidapp.data.api.designernews.model.Story; //导入依赖的package包/类
@EnvelopePayload("stories")
@GET("api/v1/stories/recent")
Call<List<Story>> getRecentStories(@Query("page") Integer page);
 
开发者ID:yongjhih,项目名称:android-proguards,代码行数:4,代码来源:DesignerNewsService.java

示例13: search

import io.plaidapp.data.api.designernews.model.Story; //导入依赖的package包/类
@EnvelopePayload("stories")
@GET("api/v1/stories/search")
Call<List<Story>> search(@Query("query") String query, @Query("page") Integer page);
 
开发者ID:yongjhih,项目名称:android-proguards,代码行数:4,代码来源:DesignerNewsService.java

示例14: upvoteStory

import io.plaidapp.data.api.designernews.model.Story; //导入依赖的package包/类
@EnvelopePayload("story")
@POST("api/v1/stories/{id}/upvote")
Call<Story> upvoteStory(@Path("id") long storyId);
 
开发者ID:yongjhih,项目名称:android-proguards,代码行数:4,代码来源:DesignerNewsService.java

示例15: postStory

import io.plaidapp.data.api.designernews.model.Story; //导入依赖的package包/类
@EnvelopePayload("stories")
@Headers("Content-Type: application/vnd.api+json")
@POST("api/v2/stories")
Call<List<Story>> postStory(@Body NewStoryRequest story);
 
开发者ID:yongjhih,项目名称:android-proguards,代码行数:5,代码来源:DesignerNewsService.java


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