Skip to content

Commit

Permalink
#53 fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
HotBitmapGG committed Jul 4, 2017
1 parent 45901aa commit 6fe8254
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 262 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.hotbitmapgg.bilibili.adapter.helper.AbsRecyclerViewAdapter;
import com.hotbitmapgg.bilibili.entity.user.UserContributeInfo;
import com.hotbitmapgg.bilibili.network.auxiliary.UrlHelper;
import com.hotbitmapgg.ohmybilibili.R;

import java.util.List;
Expand Down Expand Up @@ -46,7 +45,7 @@ public void onBindViewHolder(ClickableViewHolder holder, int position) {
UserContributeInfo.DataBean.VlistBean vlistBean = userVideoList.get(position);

Glide.with(getContext())
.load(UrlHelper.getClearVideoPreviewUrl(vlistBean.getPic()))
.load("http:" + vlistBean.getPic())
.centerCrop()
.diskCacheStrategy(DiskCacheStrategy.ALL)
.placeholder(R.drawable.bili_default_image_tv)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public void onBindViewHolder(ClickableViewHolder holder, int position) {
UserContributeInfo.DataBean.VlistBean vlistBean = userContributes.get(position);

Glide.with(getContext())
.load(vlistBean.getPic())
.load("http:" + vlistBean.getPic())
.centerCrop()
.diskCacheStrategy(DiskCacheStrategy.ALL)
.placeholder(R.drawable.bili_default_image_tv)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,18 @@
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.hotbitmapgg.bilibili.adapter.UserHomePagerChaseBangumiAdapter;
import com.hotbitmapgg.bilibili.adapter.UserHomePagerCoinsAdapter;
import com.hotbitmapgg.bilibili.adapter.UserHomePagerContributeAdapter;
import com.hotbitmapgg.bilibili.adapter.UserHomePagerInterestQuanAdapter;
import com.hotbitmapgg.bilibili.adapter.UserHomePagerPlayGameAdapter;
import com.hotbitmapgg.bilibili.base.RxLazyFragment;
import com.hotbitmapgg.bilibili.entity.user.UserChaseBangumiInfo;
import com.hotbitmapgg.bilibili.entity.user.UserCoinsInfo;
import com.hotbitmapgg.bilibili.entity.user.UserContributeInfo;
import com.hotbitmapgg.bilibili.entity.user.UserInterestQuanInfo;
import com.hotbitmapgg.bilibili.entity.user.UserLiveRoomStatusInfo;
import com.hotbitmapgg.bilibili.entity.user.UserPlayGameInfo;
import com.hotbitmapgg.bilibili.utils.ConstantUtil;
import com.hotbitmapgg.ohmybilibili.R;
import com.hotbitmapgg.bilibili.entity.user.UserContributeInfo;
import com.hotbitmapgg.bilibili.entity.user.UserFavoritesInfo;
import com.hotbitmapgg.bilibili.entity.user.UserLiveRoomStatusInfo;
import com.hotbitmapgg.bilibili.widget.FavoritesItemLayout;

import java.util.List;

Expand All @@ -50,14 +46,6 @@ public class UserHomePageFragment extends RxLazyFragment {
TextView mCoinsCount;
@BindView(R.id.coins_recycler)
RecyclerView mCoinsRecycler;
@BindView(R.id.favorites_count)
TextView mFavoritesCount;
@BindView(R.id.favorites_layout)
FavoritesItemLayout mFavoritesLayout;
@BindView(R.id.chase_bangumi_count)
TextView mChaseBangumiCount;
@BindView(R.id.chase_bangumi_recycler)
RecyclerView mChaseBangumiRecycler;
@BindView(R.id.quanzi_count)
TextView mQuanziCount;
@BindView(R.id.quanzi_recycler)
Expand All @@ -70,10 +58,6 @@ public class UserHomePageFragment extends RxLazyFragment {
RelativeLayout contributeLayout;
@BindView(R.id.coins_layout)
RelativeLayout coinsLayout;
@BindView(R.id.favorites_head_layout)
RelativeLayout favoritesHeadLayout;
@BindView(R.id.chase_bangumi_layout)
RelativeLayout chaseBangumiLayout;
@BindView(R.id.quanzi_layout)
RelativeLayout quanziLayout;
@BindView(R.id.play_game_layout)
Expand All @@ -88,23 +72,18 @@ public class UserHomePageFragment extends RxLazyFragment {
private UserCoinsInfo mUserCoinsInfo;
private UserPlayGameInfo mUserPlayGameInfo;
private UserContributeInfo mUserContributeInfo;
private UserFavoritesInfo mUserFavoritesInfo;
private UserChaseBangumiInfo mUserChaseBangumiInfo;
private UserInterestQuanInfo mUserInterestQuanInfo;
private UserLiveRoomStatusInfo mUserLiveRoomStatusInfo;


public static UserHomePageFragment newInstance(
UserContributeInfo userContributeInfo, UserFavoritesInfo userFavoritesInfo,
UserChaseBangumiInfo userChaseBangumiInfo, UserInterestQuanInfo userInterestQuanInfo,
UserCoinsInfo userCoinsInfo, UserPlayGameInfo userPlayGameInfo,
UserLiveRoomStatusInfo userLiveRoomStatusInfo) {
public static UserHomePageFragment newInstance(UserContributeInfo userContributeInfo,
UserInterestQuanInfo userInterestQuanInfo,
UserCoinsInfo userCoinsInfo,
UserPlayGameInfo userPlayGameInfo,
UserLiveRoomStatusInfo userLiveRoomStatusInfo) {

UserHomePageFragment mFragment = new UserHomePageFragment();
Bundle bundle = new Bundle();
bundle.putParcelable(ConstantUtil.USER_CONTRIBUTE, userContributeInfo);
bundle.putParcelable(ConstantUtil.USER_FAVORITES, userFavoritesInfo);
bundle.putParcelable(ConstantUtil.USER_CHASE_BANGUMI, userChaseBangumiInfo);
bundle.putParcelable(ConstantUtil.USER_INTEREST_QUAN, userInterestQuanInfo);
bundle.putParcelable(ConstantUtil.USER_COINS, userCoinsInfo);
bundle.putParcelable(ConstantUtil.USER_PLAY_GAME, userPlayGameInfo);
Expand All @@ -122,8 +101,6 @@ public int getLayoutResId() {
@Override
public void finishCreateView(Bundle state) {
mUserContributeInfo = getArguments().getParcelable(ConstantUtil.USER_CONTRIBUTE);
mUserFavoritesInfo = getArguments().getParcelable(ConstantUtil.USER_FAVORITES);
mUserChaseBangumiInfo = getArguments().getParcelable(ConstantUtil.USER_CHASE_BANGUMI);
mUserInterestQuanInfo = getArguments().getParcelable(ConstantUtil.USER_INTEREST_QUAN);
mUserCoinsInfo = getArguments().getParcelable(ConstantUtil.USER_COINS);
mUserPlayGameInfo = getArguments().getParcelable(ConstantUtil.USER_PLAY_GAME);
Expand All @@ -132,8 +109,6 @@ public void finishCreateView(Bundle state) {
setLive();
setContribute();
setCoins();
setFavorites();
setChaseBangumi();
setQuanzi();
setPlayGame();
}
Expand Down Expand Up @@ -183,31 +158,6 @@ private void setQuanzi() {
mQuanziCount.setText(String.valueOf(total_count));
}

private void setChaseBangumi() {
int count = mUserChaseBangumiInfo.getData().getCount();
if (count == 0) {
chaseBangumiLayout.setVisibility(View.GONE);
}
List<UserChaseBangumiInfo.DataBean.ResultBean> result = mUserChaseBangumiInfo.getData().getResult();
mChaseBangumiRecycler.setHasFixedSize(false);
mChaseBangumiRecycler.setNestedScrollingEnabled(false);
mChaseBangumiRecycler.setLayoutManager(new GridLayoutManager(getActivity(), 3));
mChaseBangumiRecycler.setAdapter(new UserHomePagerChaseBangumiAdapter(mChaseBangumiRecycler, result));
mChaseBangumiCount.setText(String.valueOf(count));
}

private void setFavorites() {
int size = mUserFavoritesInfo.getData().size();
if (size == 0) {
favoritesHeadLayout.setVisibility(View.GONE);
}
List<UserFavoritesInfo.DataBean> data = mUserFavoritesInfo.getData();
List<UserFavoritesInfo.DataBean.VideosBean> videos = data.get(0).getVideos();
mFavoritesLayout.setImages(videos);
mFavoritesCount.setText(String.valueOf(size));
}


private void setCoins() {
int count = mUserCoinsInfo.getData().getCount();
if (count == 0) {
Expand Down Expand Up @@ -235,38 +185,26 @@ private void setContribute() {
}


@OnClick(R.id.contribute_more)
void gotoContributePager() {
((UserInfoDetailsActivity) getActivity()).switchPager(1);
}


@OnClick(R.id.favorites_more)
void gotoFavoritesPager() {
((UserInfoDetailsActivity) getActivity()).switchPager(2);
}


@OnClick(R.id.chase_bangumi_more)
void gotoChaseBangumiPager() {
((UserInfoDetailsActivity) getActivity()).switchPager(3);
}


@OnClick(R.id.quanzi_more)
void gotoQuanziPager() {
((UserInfoDetailsActivity) getActivity()).switchPager(4);
}

@OnClick({R.id.contribute_more, R.id.quanzi_more, R.id.coins_more, R.id.play_game_more})
void onClick(View view) {
switch (view.getId()) {
case R.id.contribute_more:
//更多投稿
((UserInfoDetailsActivity) getActivity()).switchPager(1);
break;
case R.id.quanzi_more:
//更多圈子
((UserInfoDetailsActivity) getActivity()).switchPager(2);
break;
case R.id.coins_more:
//更多投币
((UserInfoDetailsActivity) getActivity()).switchPager(3);
break;
case R.id.play_game_more:
//更多游戏
((UserInfoDetailsActivity) getActivity()).switchPager(4);
break;

@OnClick(R.id.coins_more)
void gotoCoinsPager() {
((UserInfoDetailsActivity) getActivity()).switchPager(5);
}


@OnClick(R.id.play_game_more)
void gotoPlayGamePager() {
((UserInfoDetailsActivity) getActivity()).switchPager(6);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,9 @@
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.flyco.tablayout.SlidingTabLayout;
import com.hotbitmapgg.bilibili.base.RxBaseActivity;
import com.hotbitmapgg.bilibili.entity.user.UserChaseBangumiInfo;
import com.hotbitmapgg.bilibili.entity.user.UserCoinsInfo;
import com.hotbitmapgg.bilibili.entity.user.UserContributeInfo;
import com.hotbitmapgg.bilibili.entity.user.UserDetailsInfo;
import com.hotbitmapgg.bilibili.entity.user.UserFavoritesInfo;
import com.hotbitmapgg.bilibili.entity.user.UserInterestQuanInfo;
import com.hotbitmapgg.bilibili.entity.user.UserLiveRoomStatusInfo;
import com.hotbitmapgg.bilibili.entity.user.UserPlayGameInfo;
Expand All @@ -36,6 +34,7 @@
import com.hotbitmapgg.bilibili.utils.LogUtil;
import com.hotbitmapgg.bilibili.utils.NumberUtil;
import com.hotbitmapgg.bilibili.utils.SystemBarHelper;
import com.hotbitmapgg.bilibili.utils.ToastUtil;
import com.hotbitmapgg.bilibili.widget.CircleImageView;
import com.hotbitmapgg.bilibili.widget.CircleProgressView;
import com.hotbitmapgg.bilibili.widget.NoScrollViewPager;
Expand Down Expand Up @@ -95,26 +94,20 @@ public class UserInfoDetailsActivity extends RxBaseActivity {
private String name = "";
private String avatar_url;
private int userContributeCount;
private int userFavoritesCount;
private int userChaseBangumiCount;
private int userInterestQuanCount;
private int userCoinsCount;
private int userPlayGameCount;
private UserDetailsInfo mUserDetailsInfo;
private UserCoinsInfo mUserCoinsInfo;
private UserPlayGameInfo mUserPlayGameInfo;
private UserFavoritesInfo mUserFavoritesInfo;
private UserContributeInfo mUserContributeInfo;
private UserChaseBangumiInfo mUserChaseBangumiInfo;
private UserInterestQuanInfo mUserInterestQuanInfo;
private UserLiveRoomStatusInfo mUserLiveRoomStatusInfo;
private List<String> titles = new ArrayList<>();
private List<Fragment> fragments = new ArrayList<>();
private List<UserFavoritesInfo.DataBean> userFavorites = new ArrayList<>();
private List<UserCoinsInfo.DataBean.ListBean> userCoins = new ArrayList<>();
private List<UserPlayGameInfo.DataBean.GamesBean> userPlayGames = new ArrayList<>();
private List<UserContributeInfo.DataBean.VlistBean> userContributes = new ArrayList<>();
private List<UserChaseBangumiInfo.DataBean.ResultBean> userChaseBangumis = new ArrayList<>();
private List<UserInterestQuanInfo.DataBean.ResultBean> userInterestQuans = new ArrayList<>();
private static final String EXTRA_USER_NAME = "extra_user_name", EXTRA_MID = "extra_mid", EXTRA_AVATAR_URL = "extra_avatar_url";

Expand Down Expand Up @@ -261,32 +254,12 @@ private void getUserAllData() {
RetrofitHelper.getUserAPI()
.getUserContributeVideos(mid, 1, 10)
.compose(this.bindToLifecycle())
.flatMap(new Func1<UserContributeInfo, Observable<UserFavoritesInfo>>() {
.flatMap(new Func1<UserContributeInfo, Observable<UserInterestQuanInfo>>() {
@Override
public Observable<UserFavoritesInfo> call(UserContributeInfo userContributeInfo) {
public Observable<UserInterestQuanInfo> call(UserContributeInfo userContributeInfo) {
mUserContributeInfo = userContributeInfo;
userContributeCount = userContributeInfo.getData().getCount();
userContributes.addAll(userContributeInfo.getData().getVlist());
return RetrofitHelper.getBiliAPI().getUserFavorites(mid);
}
})
.compose(bindToLifecycle())
.flatMap(new Func1<UserFavoritesInfo, Observable<UserChaseBangumiInfo>>() {
@Override
public Observable<UserChaseBangumiInfo> call(UserFavoritesInfo userFavoritesInfo) {
mUserFavoritesInfo = userFavoritesInfo;
userFavoritesCount = userFavoritesInfo.getData().size();
userFavorites.addAll(userFavoritesInfo.getData());
return RetrofitHelper.getUserAPI().getUserChaseBangumis(mid);
}
})
.compose(bindToLifecycle())
.flatMap(new Func1<UserChaseBangumiInfo, Observable<UserInterestQuanInfo>>() {
@Override
public Observable<UserInterestQuanInfo> call(UserChaseBangumiInfo userChaseBangumiInfo) {
mUserChaseBangumiInfo = userChaseBangumiInfo;
userChaseBangumiCount = userChaseBangumiInfo.getData().getCount();
userChaseBangumis.addAll(userChaseBangumiInfo.getData().getResult());
return RetrofitHelper.getIm9API().getUserInterestQuanData(mid, 1, 10);
}
})
Expand Down Expand Up @@ -326,15 +299,17 @@ public Observable<UserLiveRoomStatusInfo> call(UserPlayGameInfo userPlayGameInfo
.subscribe(userLiveRoomStatusInfo -> {
mUserLiveRoomStatusInfo = userLiveRoomStatusInfo;
initViewPager();
}, throwable -> hideProgressBar());
}, throwable -> {
ToastUtil.ShortToast("用户隐私未公开");
hideProgressBar();
});
}


private void initViewPager() {
fragments.add(UserHomePageFragment.newInstance(mUserContributeInfo, mUserFavoritesInfo, mUserChaseBangumiInfo, mUserInterestQuanInfo, mUserCoinsInfo, mUserPlayGameInfo, mUserLiveRoomStatusInfo));
fragments.add(UserHomePageFragment.newInstance(mUserContributeInfo,
mUserInterestQuanInfo, mUserCoinsInfo, mUserPlayGameInfo, mUserLiveRoomStatusInfo));
fragments.add(UserContributeFragment.newInstance(mid, mUserContributeInfo));
fragments.add(UserFavoritesFragment.newInstance(mUserFavoritesInfo));
fragments.add(UserChaseBangumiFragment.newInstance(mUserChaseBangumiInfo));
fragments.add(UserInterestQuanFragment.newInstance(mid, mUserInterestQuanInfo));
fragments.add(UserCoinsVideoFragment.newInstance(mUserCoinsInfo));
fragments.add(UserPlayGameFragment.newInstance(mUserPlayGameInfo));
Expand Down Expand Up @@ -365,8 +340,6 @@ public void onPageScrollStateChanged(int state) {
private void setPagerTitles() {
titles.add("主页");
titles.add("投稿 " + userContributeCount);
titles.add("收藏 " + userFavoritesCount);
titles.add("追番 " + userChaseBangumiCount);
titles.add("兴趣圈 " + userInterestQuanCount);
titles.add("投币 " + userCoinsCount);
titles.add("游戏 " + userPlayGameCount);
Expand Down Expand Up @@ -447,12 +420,6 @@ public void switchPager(int index) {
case 4:
mViewPager.setCurrentItem(4);
break;
case 5:
mViewPager.setCurrentItem(5);
break;
case 6:
mViewPager.setCurrentItem(6);
break;
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
package com.hotbitmapgg.bilibili.network.api;

import com.hotbitmapgg.bilibili.entity.bangumi.SpecialTopic;
import com.hotbitmapgg.bilibili.entity.bangumi.SpecialTopicIResult;
import com.hotbitmapgg.bilibili.entity.discover.TopicCenterInfo;
import com.hotbitmapgg.bilibili.entity.attention.AttentionDynamicInfo;
import com.hotbitmapgg.bilibili.entity.bangumi.BangumiDetailsCommentInfo;
import com.hotbitmapgg.bilibili.entity.bangumi.SpecialTopic;
import com.hotbitmapgg.bilibili.entity.bangumi.SpecialTopicIResult;
import com.hotbitmapgg.bilibili.entity.discover.ActivityCenterInfo;
import com.hotbitmapgg.bilibili.entity.user.UserFavoritesInfo;
import com.hotbitmapgg.bilibili.entity.discover.TopicCenterInfo;
import com.hotbitmapgg.bilibili.entity.video.VideoCommentInfo;

import retrofit2.http.GET;
Expand Down Expand Up @@ -49,11 +48,6 @@ public interface BiliApiService {
@GET("event/getlist?device=phone&mobi_app=iphone")
Observable<ActivityCenterInfo> getActivityCenterList(@Query("page") int page, @Query("pagesize") int pageSize);

/**
* 用户收藏夹
*/
@GET("x/app/favourite/folder?")
Observable<UserFavoritesInfo> getUserFavorites(@Query("mid") int mid);

/**
* 首页关注
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package com.hotbitmapgg.bilibili.network.auxiliary;

import android.util.Log;

import com.hotbitmapgg.bilibili.entity.user.UserDetailsInfo;

/**
Expand All @@ -16,22 +14,6 @@
public class UrlHelper {
private static final String HDSLB_HOST = "http://i2.hdslb.com";

private static boolean isVideoUrl(String url) {
return url.contains("bilibili.com/video/av");
}

public static int getAVfromVideoUrl(String url) {
if (!isVideoUrl(url)) {
return -1;
}
String av = url;
av = av.substring(av.indexOf("bilibili.com/video/av") + "bilibili.com/video/av".length());
Log.i("test", av);
av = av.substring(0, av.indexOf("/"));
Log.i("test", av);
return Integer.parseInt(av);
}

public static String getFaceUrl(UserDetailsInfo info) {
if (info.getCard().getFace().contains(".hdslb.com")) {
return info.getCard().getFace();
Expand Down
Loading

0 comments on commit 6fe8254

Please sign in to comment.