Android使用Dribble Api

使用Dribble提供的Api获取上面的设计分享

  • 使用了Material Design、SceneTransitionAnimation
  • 使用了Volley Gson

d1a897a5c834cffc.png

1. 申请Dribble开发者应用

https://dribbble.com/account/applications/new

申请成功之后,就会生成

  • Client ID
  • Client Secret
  • Client Access Token

4b500a29b679faca.png

2. 使用Dribble的Api

d778b39f0f480131.png

还可加page参数获取分页数据

构建类似这样的数据

public class DribbleShot{
    @SerializedName("animated")
    public Boolean mAnimated;
    @SerializedName("attachments_count")
    public Long mAttachmentsCount;
    @SerializedName("attachments_url")
    public String mAttachmentsUrl;
    @SerializedName("buckets_count")
    public Long mBucketsCount;
    @SerializedName("buckets_url")
    public String mBucketsUrl;
    @SerializedName("comments_count")
    public Long mCommentsCount;
    @SerializedName("comments_url")
    public String mCommentsUrl;
    @SerializedName("created_at")
    public String mCreatedAt;
    @SerializedName("description")
    public String mDescription;
    @SerializedName("height")
    public Long mHeight;
    @SerializedName("html_url")
    public String mHtmlUrl;
    @SerializedName("id")
    public Long mId;
    @SerializedName("images")
    public DribbleShotImages mDribbleShotImages;
    @SerializedName("likes_count")
    public Long mLikesCount;
    @SerializedName("likes_url")
    public String mLikesUrl;
    @SerializedName("projects_url")
    public String mProjectsUrl;
    @SerializedName("rebounds_count")
    public Long mReboundsCount;
    @SerializedName("rebounds_url")
    public String mReboundsUrl;
    @SerializedName("tags")
    public List<String> mTags;
    @SerializedName("team")
    public DribbleShotTeam mDribbleShotTeam;
    @SerializedName("title")
    public String mTitle;
    @SerializedName("updated_at")
    public String mUpdatedAt;
    @SerializedName("user")
    public DribbleShotUser mDribbleShotUser;
    @SerializedName("views_count")
    public Long mViewsCount;
    @SerializedName("width")
    public Long mWidth;
}

使用Volley获取数据,Gson解析

private void getData() {
        final String shotUrl = "https://api.dribbble.com/v1/shots?access_token=" + DRIBBLE_Token;
        StringRequest request = new StringRequest(Request.Method.GET, shotUrl, new Response.Listener<String>() {
            @Override
            public void onResponse(String response) {
                Gson gson = new Gson();
                Type type = new TypeToken<ArrayList<DribbleShot>>() {
                }.getType();
                dribbleShots = gson.fromJson(response, type);
                //填充到list
            }
        }, new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError error) {
                Toast.makeText(getActivity(), error.getMessage(), Toast.LENGTH_SHORT).show();
            }
        });
        RequestQueue queue = Volley.newRequestQueue(context);
        queue.add(request);
   }

3. Activity View转场动画

  1. 在跳转的Activity使用ActivityOptionsCompat.makeSceneTransitionAnimation()
    Intent intent = new Intent(context, ShotItemActivity.class); ActivityOptionsCompat optionsCompat = ActivityOptionsCompat.makeSceneTransitionAnimation(context, view, "TRASATION_ANIMATION"); ActivityCompat.startActivity(context, itent, optionsCompat.toBundle());

    • view 为发生转场动画的控件
  2. 在目标Activity使用ViewCompat.setTransitionName()设定转场动画的接收控件

    ViewCompat.setTransitionName(imageView, "TRASATION_ANIMATION");
    • 注意制定的TRANATION_ANIMATION需要保持一致。

转载于:https://www.cnblogs.com/jiy-for-you/p/6906146.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值