diff --git a/app/build.gradle b/app/build.gradle index c338556..5a684d6 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -14,6 +14,7 @@ android { versionName "1.0" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + vectorDrawables.useSupportLibrary = true } // signingConfigs { @@ -39,6 +40,8 @@ android { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + + } } diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 0609d79..606c8a5 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -1,37 +1,37 @@ + xmlns:tools="http://schemas.android.com/tools"> - - - - - + + + + + - + - - - - - - - - + + + + + + + + + + diff --git a/app/src/main/java/com/viontv/app/VTApplication.java b/app/src/main/java/com/viontv/app/VTApplication.java index 2be85c0..93da632 100644 --- a/app/src/main/java/com/viontv/app/VTApplication.java +++ b/app/src/main/java/com/viontv/app/VTApplication.java @@ -19,6 +19,8 @@ public class VTApplication extends Application { public static VTApplication AppContext; + public static boolean isCurrentPage = true; + public static VTApplication getAppContext() { return AppContext; } diff --git a/app/src/main/java/com/viontv/app/api/VTApiService.java b/app/src/main/java/com/viontv/app/api/VTApiService.java index 6aef191..3c63961 100644 --- a/app/src/main/java/com/viontv/app/api/VTApiService.java +++ b/app/src/main/java/com/viontv/app/api/VTApiService.java @@ -1,23 +1,20 @@ package com.viontv.app.api; -import com.viontv.app.model.HomeBottomListBean; +import com.viontv.app.model.VTVideoListBean; import com.viontv.app.model.HomeTopBannerBean; import com.viontv.app.model.HomeTopBean; import com.viontv.app.model.RegisteredBean; import com.viontv.app.model.TabItemBean; +import com.viontv.app.model.VTUserInfoBean; import com.viontv.app.model.VTVideoDetailsBean; - -import java.util.List; -import java.util.Map; +import com.viontv.app.model.VTVideoExploreListBean; import io.reactivex.Observable; -import retrofit2.http.Body; import retrofit2.http.Field; import retrofit2.http.FormUrlEncoded; import retrofit2.http.GET; import retrofit2.http.POST; -import retrofit2.http.Path; import retrofit2.http.Query; @@ -28,10 +25,14 @@ public interface VTApiService { * 正式测试服 */ boolean isProduce = false; - String URL = isProduce ? "https://admin-viontv.guyantv.com" : "https://test1-api.guyantv.com"; + String URL = isProduce ? "https://api-zyreotv.zyreotv.com/7834f11d/" : "https://test1-api.guyantv.com"; + + public static final String rankTop10Type = "most_trending"; + public static final String ZyreoTV_Private = "https://www.zyreotv.com/private"; + public static final String ZyreoTV_USERAgreement = "https://www.zyreotv.com/user_policy"; + - public static final String rankTop10Type="most_trending"; /** * 注册 * @@ -64,7 +65,7 @@ public interface VTApiService { */ @FormUrlEncoded @POST("/newShortPlay") - Observable> newShortPlay(@Field("current_page") int currentpage,@Field("page_size") int pagesize); + Observable> newShortPlay(@Field("current_page") int currentpage, @Field("page_size") int pagesize); /** @@ -74,7 +75,7 @@ public interface VTApiService { */ @FormUrlEncoded @POST("/homeRanking") - Observable> homeTop10(@Field("type") String type); + Observable> homeTop10(@Field("type") String type); /** @@ -93,7 +94,7 @@ public interface VTApiService { */ @FormUrlEncoded @POST("/revenge") - Observable> getTabItemBanner(@Field("category_id") String category_id); + Observable> getTabItemBanner(@Field("category_id") int category_id); /** @@ -102,8 +103,87 @@ public interface VTApiService { * @return */ @GET("/videoList") - Observable> getVideoList(@Query("category_id") String category_id,@Query("current_page") int current,@Query("page_size") int pageSize,@Query("search") String search); + Observable> getVideoList(@Query("category_id") int category_id, @Query("current_page") int current, @Query("page_size") int pageSize, @Query("search") String search); + /** + * 播放上报历史 + * + * @return + */ + @FormUrlEncoded + @POST("/createHistory") + Observable createVideoHistory(@Field("short_play_id") int shorplayId, @Field("video_id") int videoId); + + + /** + * Search Hot List + * + * @return + */ + @GET("/search/hots") + Observable> getSearchHotList(); + + /** + * Search Content List + * + * @return + */ + @GET("/search") + Observable> getSearchContentList(@Query("search") String search); + + + /** + * 搜索点击上报 + * + * @return + */ + @FormUrlEncoded + @POST("/search/click") + Observable searchClick(@Field("short_play_id") int shorplayId); + + /** + * 首页推荐列表 + * + * @return + */ + @GET("/getRecommands") + Observable> getExploreList(@Query("current_page") int current, @Query("page_size") int pageSize); + + + /** + * 收藏 + * + * @return + */ + @FormUrlEncoded + @POST("/collect") + Observable collect(@Field("short_play_id") int shorplayId, @Field("video_id") int videoId); + + + /** + * 取消收藏 + * + * @return + */ + @FormUrlEncoded + @POST("/cancelCollect") + Observable cancelCollect(@Field("short_play_id") int shorplayId); + + /** + * 获取用户信息 + * + * @return + */ + @GET("/customer/info") + Observable> getUserInfo(); + + /** + * 获取观看历史列表 + * + * @return + */ + @GET("/myHistorys") + Observable> getVideoHistoryList(@Query("current_page") int currentpage, @Query("page_size") int pageSize); } diff --git a/app/src/main/java/com/viontv/app/model/ItemBean.java b/app/src/main/java/com/viontv/app/model/ItemBean.java index 01b9b85..62cc66b 100644 --- a/app/src/main/java/com/viontv/app/model/ItemBean.java +++ b/app/src/main/java/com/viontv/app/model/ItemBean.java @@ -38,6 +38,9 @@ public class ItemBean { private List category; + private List categoryList; //搜索结果 + + @@ -168,4 +171,13 @@ public class ItemBean { public void setCategory(List category) { this.category = category; } + + + public List getCategoryList() { + return categoryList; + } + + public void setCategoryList(List categoryList) { + this.categoryList = categoryList; + } } diff --git a/app/src/main/java/com/viontv/app/model/SearchCateGoryItemBean.java b/app/src/main/java/com/viontv/app/model/SearchCateGoryItemBean.java new file mode 100644 index 0000000..2aa8fac --- /dev/null +++ b/app/src/main/java/com/viontv/app/model/SearchCateGoryItemBean.java @@ -0,0 +1,23 @@ +package com.viontv.app.model; + +public class SearchCateGoryItemBean { + + private String name; + private int id; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } +} diff --git a/app/src/main/java/com/viontv/app/model/VTUserInfoBean.java b/app/src/main/java/com/viontv/app/model/VTUserInfoBean.java new file mode 100644 index 0000000..8687164 --- /dev/null +++ b/app/src/main/java/com/viontv/app/model/VTUserInfoBean.java @@ -0,0 +1,76 @@ +package com.viontv.app.model; + +public class VTUserInfoBean { + +// "id": "S72866 (t)", +// "customer_id": "S72866 (t)", +// "is_guide_vip": true, +// "is_tourist": true, +// "family_name": "訪客", +// "giving_name": "", +// "vip_end_time": 0, +// "third_access_id": "", +// "is_vip": false, +// "coin_left_total": 0, +// "vip_type": "", +// "email": "", +// "third_access_platform": "", +// "ip_address": "116.128.252.77", +// "country_code": "CN", +// "user_level": "normal", +// "send_coin_left_total": 0, +// "avator": "", +// "sign_in_status": 0, +// "registered_days": 1, +// "ln": "ed590219f82c44d5a40d19cdff3cb6de49ccb0b3bf61ccd8214764105d736dbe", +// "country": "9fc4508238942e7cf40354d962db0c18c5ceec7320e0a3b9f69a0a7836efa50c" + + public String family_name; + public boolean is_vip; + + public String avator; + + public String id; + + public String customer_id; + + public String getFamily_name() { + return family_name; + } + + public void setFamily_name(String family_name) { + this.family_name = family_name; + } + + public boolean isIs_vip() { + return is_vip; + } + + public void setIs_vip(boolean is_vip) { + this.is_vip = is_vip; + } + + public String getAvator() { + return avator; + } + + public void setAvator(String avator) { + this.avator = avator; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getCustomer_id() { + return customer_id; + } + + public void setCustomer_id(String customer_id) { + this.customer_id = customer_id; + } +} diff --git a/app/src/main/java/com/viontv/app/model/VTVideoDetailsBean.java b/app/src/main/java/com/viontv/app/model/VTVideoDetailsBean.java index 4be06c8..06051cd 100644 --- a/app/src/main/java/com/viontv/app/model/VTVideoDetailsBean.java +++ b/app/src/main/java/com/viontv/app/model/VTVideoDetailsBean.java @@ -15,7 +15,8 @@ public class VTVideoDetailsBean { public ShortPlayInfo shortPlayInfo; - public VideoInfo video_info; + public VideoInfoBean video_info; + @@ -151,6 +152,10 @@ public class VTVideoDetailsBean { int short_id; int watch_total; + int short_play_id; + + + public int getAll_coins() { return all_coins; } @@ -247,6 +252,14 @@ public class VTVideoDetailsBean { this.watch_total = watch_total; } + public int getShort_play_id() { + return short_play_id; + } + + public void setShort_play_id(int short_play_id) { + this.short_play_id = short_play_id; + } + protected ShortPlayInfo(Parcel in) { all_coins = in.readInt(); buy_type = in.readInt(); @@ -260,6 +273,7 @@ public class VTVideoDetailsBean { process = in.readInt(); short_id = in.readInt(); watch_total = in.readInt(); + short_play_id = in.readInt(); } public static final Creator CREATOR = new Creator() { @@ -293,133 +307,8 @@ public class VTVideoDetailsBean { dest.writeInt(process); dest.writeInt(short_id); dest.writeInt(watch_total); - } - } - - public static class VideoInfo implements Parcelable{ - - int coins; - int episode; - int id; - int is_vip; - int short_id; - int short_play_id; - int short_play_video_id; - String video_url; - int vip_coins; - - public int getCoins() { - return coins; - } - - public void setCoins(int coins) { - this.coins = coins; - } - - public int getEpisode() { - return episode; - } - - public void setEpisode(int episode) { - this.episode = episode; - } - - public int getId() { - return id; - } - - public void setId(int id) { - this.id = id; - } - - public int getIs_vip() { - return is_vip; - } - - public void setIs_vip(int is_vip) { - this.is_vip = is_vip; - } - - public int getShort_id() { - return short_id; - } - - public void setShort_id(int short_id) { - this.short_id = short_id; - } - - public int getShort_play_id() { - return short_play_id; - } - - public void setShort_play_id(int short_play_id) { - this.short_play_id = short_play_id; - } - - public int getShort_play_video_id() { - return short_play_video_id; - } - - public void setShort_play_video_id(int short_play_video_id) { - this.short_play_video_id = short_play_video_id; - } - - public String getVideo_url() { - return video_url; - } - - public void setVideo_url(String video_url) { - this.video_url = video_url; - } - - public int getVip_coins() { - return vip_coins; - } - - public void setVip_coins(int vip_coins) { - this.vip_coins = vip_coins; - } - - protected VideoInfo(Parcel in) { - coins = in.readInt(); - episode = in.readInt(); - id = in.readInt(); - is_vip = in.readInt(); - short_id = in.readInt(); - short_play_id = in.readInt(); - short_play_video_id = in.readInt(); - video_url = in.readString(); - vip_coins = in.readInt(); - } - - public static final Creator CREATOR = new Creator() { - @Override - public VideoInfo createFromParcel(Parcel in) { - return new VideoInfo(in); - } - - @Override - public VideoInfo[] newArray(int size) { - return new VideoInfo[size]; - } - }; - - @Override - public int describeContents() { - return 0; - } - - @Override - public void writeToParcel(@NonNull Parcel dest, int flags) { - dest.writeInt(coins); - dest.writeInt(episode); - dest.writeInt(id); - dest.writeInt(is_vip); - dest.writeInt(short_id); dest.writeInt(short_play_id); - dest.writeInt(short_play_video_id); - dest.writeString(video_url); - dest.writeInt(vip_coins); } } + } diff --git a/app/src/main/java/com/viontv/app/model/VTVideoExploreBean.java b/app/src/main/java/com/viontv/app/model/VTVideoExploreBean.java new file mode 100644 index 0000000..f030126 --- /dev/null +++ b/app/src/main/java/com/viontv/app/model/VTVideoExploreBean.java @@ -0,0 +1,179 @@ +package com.viontv.app.model; + +import java.util.List; + +public class VTVideoExploreBean { + + + private int id; + + private int short_id; + + private int short_play_id; + + private String name; + + private String description; + + private int process; + + private String image_url; + + private String horizontally_img; + + private int buy_type; + + private String tag_type; + + private int all_coins; + + private int collect_total; + + private int watch_total; + + private int episode_total; + + private int search_click_total; + + private boolean is_collect; + + + public VideoInfoBean video_info; + + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public int getShort_id() { + return short_id; + } + + public void setShort_id(int short_id) { + this.short_id = short_id; + } + + public int getShort_play_id() { + return short_play_id; + } + + public void setShort_play_id(int short_play_id) { + this.short_play_id = short_play_id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public int getProcess() { + return process; + } + + public void setProcess(int process) { + this.process = process; + } + + public String getImage_url() { + return image_url; + } + + public void setImage_url(String image_url) { + this.image_url = image_url; + } + + public String getHorizontally_img() { + return horizontally_img; + } + + public void setHorizontally_img(String horizontally_img) { + this.horizontally_img = horizontally_img; + } + + public int getBuy_type() { + return buy_type; + } + + public void setBuy_type(int buy_type) { + this.buy_type = buy_type; + } + + public String getTag_type() { + return tag_type; + } + + public void setTag_type(String tag_type) { + this.tag_type = tag_type; + } + + public int getAll_coins() { + return all_coins; + } + + public void setAll_coins(int all_coins) { + this.all_coins = all_coins; + } + + public int getCollect_total() { + return collect_total; + } + + public void setCollect_total(int collect_total) { + this.collect_total = collect_total; + } + + public int getWatch_total() { + return watch_total; + } + + public void setWatch_total(int watch_total) { + this.watch_total = watch_total; + } + + public int getEpisode_total() { + return episode_total; + } + + public void setEpisode_total(int episode_total) { + this.episode_total = episode_total; + } + + public int getSearch_click_total() { + return search_click_total; + } + + public void setSearch_click_total(int search_click_total) { + this.search_click_total = search_click_total; + } + + public boolean isIs_collect() { + return is_collect; + } + + public void setIs_collect(boolean is_collect) { + this.is_collect = is_collect; + } + + public VideoInfoBean getVideo_info() { + return video_info; + } + + public void setVideo_info(VideoInfoBean video_info) { + this.video_info = video_info; + } +} diff --git a/app/src/main/java/com/viontv/app/model/VTVideoExploreListBean.java b/app/src/main/java/com/viontv/app/model/VTVideoExploreListBean.java new file mode 100644 index 0000000..326a932 --- /dev/null +++ b/app/src/main/java/com/viontv/app/model/VTVideoExploreListBean.java @@ -0,0 +1,18 @@ +package com.viontv.app.model; + +import java.util.List; + +public class VTVideoExploreListBean { + + + public List list; + + + public List getList() { + return list; + } + + public void setList(List list) { + this.list = list; + } +} diff --git a/app/src/main/java/com/viontv/app/model/HomeBottomListBean.java b/app/src/main/java/com/viontv/app/model/VTVideoListBean.java similarity index 93% rename from app/src/main/java/com/viontv/app/model/HomeBottomListBean.java rename to app/src/main/java/com/viontv/app/model/VTVideoListBean.java index 3998290..0a0cea0 100644 --- a/app/src/main/java/com/viontv/app/model/HomeBottomListBean.java +++ b/app/src/main/java/com/viontv/app/model/VTVideoListBean.java @@ -2,7 +2,7 @@ package com.viontv.app.model; import java.util.List; -public class HomeBottomListBean { +public class VTVideoListBean { private List short_play_list; private List list; diff --git a/app/src/main/java/com/viontv/app/model/VideoInfoBean.java b/app/src/main/java/com/viontv/app/model/VideoInfoBean.java new file mode 100644 index 0000000..3ba3210 --- /dev/null +++ b/app/src/main/java/com/viontv/app/model/VideoInfoBean.java @@ -0,0 +1,135 @@ +package com.viontv.app.model; + +import android.os.Parcel; +import android.os.Parcelable; + +import androidx.annotation.NonNull; + +public class VideoInfoBean implements Parcelable { + + + int coins; + int episode; + int id; + int is_vip; + int short_id; + int short_play_id; + int short_play_video_id; + String video_url; + int vip_coins; + + protected VideoInfoBean(Parcel in) { + coins = in.readInt(); + episode = in.readInt(); + id = in.readInt(); + is_vip = in.readInt(); + short_id = in.readInt(); + short_play_id = in.readInt(); + short_play_video_id = in.readInt(); + video_url = in.readString(); + vip_coins = in.readInt(); + } + + public static final Creator CREATOR = new Creator() { + @Override + public VideoInfoBean createFromParcel(Parcel in) { + return new VideoInfoBean(in); + } + + @Override + public VideoInfoBean[] newArray(int size) { + return new VideoInfoBean[size]; + } + }; + + public int getCoins() { + return coins; + } + + public void setCoins(int coins) { + this.coins = coins; + } + + public int getEpisode() { + return episode; + } + + public void setEpisode(int episode) { + this.episode = episode; + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public int getIs_vip() { + return is_vip; + } + + public void setIs_vip(int is_vip) { + this.is_vip = is_vip; + } + + public int getShort_id() { + return short_id; + } + + public void setShort_id(int short_id) { + this.short_id = short_id; + } + + public int getShort_play_id() { + return short_play_id; + } + + public void setShort_play_id(int short_play_id) { + this.short_play_id = short_play_id; + } + + public int getShort_play_video_id() { + return short_play_video_id; + } + + public void setShort_play_video_id(int short_play_video_id) { + this.short_play_video_id = short_play_video_id; + } + + public String getVideo_url() { + return video_url; + } + + public void setVideo_url(String video_url) { + this.video_url = video_url; + } + + public int getVip_coins() { + return vip_coins; + } + + public void setVip_coins(int vip_coins) { + this.vip_coins = vip_coins; + } + + + @Override + public int describeContents() { + return 0; + } + + @Override + public void writeToParcel(@NonNull Parcel dest, int flags) { + dest.writeInt(coins); + dest.writeInt(episode); + dest.writeInt(id); + dest.writeInt(is_vip); + dest.writeInt(short_id); + dest.writeInt(short_play_id); + dest.writeInt(short_play_video_id); + dest.writeString(video_url); + dest.writeInt(vip_coins); + } +} diff --git a/app/src/main/java/com/viontv/app/ui/activity/VTMainActivity.java b/app/src/main/java/com/viontv/app/ui/activity/VTMainActivity.java index 2187c7c..b160244 100644 --- a/app/src/main/java/com/viontv/app/ui/activity/VTMainActivity.java +++ b/app/src/main/java/com/viontv/app/ui/activity/VTMainActivity.java @@ -1,10 +1,8 @@ package com.viontv.app.ui.activity; -import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.widget.AppCompatTextView; import androidx.fragment.app.Fragment; -import android.os.Bundle; import android.view.View; import com.viontv.app.R; @@ -14,7 +12,7 @@ import com.viontv.app.ui.activity.explore.VTExploreFragment; import com.viontv.app.ui.activity.home.VTHomeFragment; import com.viontv.app.ui.activity.me.VTMeFragment; import com.viontv.app.ui.activity.mylist.VTMyListFragment; -import com.viontv.app.ui.adapter.FragmentAdapter; +import com.viontv.app.ui.adapter.VTFragmentAdapter; import java.util.ArrayList; import java.util.List; @@ -31,7 +29,7 @@ public class VTMainActivity extends VTCommonActivity impl ActivityMainVtBinding binding; - private FragmentAdapter fragmentAdapter; + private VTFragmentAdapter fragmentAdapter; @@ -55,7 +53,7 @@ public class VTMainActivity extends VTCommonActivity impl fragments.add(VTExploreFragment); fragments.add(VTMyListFragment); fragments.add(VTMeFragment); - fragmentAdapter = new FragmentAdapter(this); + fragmentAdapter = new VTFragmentAdapter(this); fragmentAdapter.setFragmentList(fragments); binding.container.setUserInputEnabled(false); binding.container.setAdapter(fragmentAdapter); diff --git a/app/src/main/java/com/viontv/app/ui/activity/WebViewActivity.java b/app/src/main/java/com/viontv/app/ui/activity/WebViewActivity.java new file mode 100644 index 0000000..221b405 --- /dev/null +++ b/app/src/main/java/com/viontv/app/ui/activity/WebViewActivity.java @@ -0,0 +1,69 @@ +package com.viontv.app.ui.activity; + +import android.annotation.SuppressLint; +import android.os.Build; +import android.webkit.CookieManager; +import android.webkit.WebSettings; + +import com.viontv.app.databinding.ActivityMainVtBinding; +import com.viontv.app.databinding.ActivityWebviewBinding; +import com.viontv.app.ui.activity.basic.VTCommonActivity; +import com.viontv.app.utils.VTAppConstants; + +public class WebViewActivity extends VTCommonActivity { + + public ActivityWebviewBinding binding; + + private String webUrl; + private String webTitle; + + @Override + public void init() { + getWindow().setNavigationBarColor(getResources().getColor(android.R.color.black)); + binding = ActivityWebviewBinding.inflate(getLayoutInflater()); + setContentView(binding.getRoot()); + webUrl = getIntent().getStringExtra(VTAppConstants.Constants_Page_WebUrl); + webTitle = getIntent().getStringExtra(VTAppConstants.Constants_Page_WebTitle); + } + + + @Override + public void initView() { + + binding.ivWebviewBack.setOnClickListener(v -> finish()); + binding.tvWebviewTitle.setText(webTitle); + binding.webview.getSettings(); + WebSettings settings = binding.webview.getSettings(); + settings.setDomStorageEnabled(true); + CookieManager.getInstance().setAcceptThirdPartyCookies(binding.webview, true); + settings.setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW); + // settings.setAppCacheEnabled(true); + settings.setCacheMode(WebSettings.LOAD_DEFAULT); +// settings.setCacheMode(WebSettings.LOAD_NO_CACHE); + + settings.setJavaScriptEnabled(true); + settings.setLoadWithOverviewMode(true); +// settings.setAppCachePath(APP_CACHE_DIRNAME); + // 设置允许访问文件数据 + settings.setAllowFileAccess(true); + settings.setAllowContentAccess(true); + settings.setDatabaseEnabled(true); + settings.setSavePassword(false); + settings.setSaveFormData(false); + settings.setUseWideViewPort(true); + settings.setJavaScriptCanOpenWindowsAutomatically(true); + // 设置在WebView内部是否允许通过file url加载的 Js代码读取其他的本地文件 + // Android 4.1前默认允许,4.1后默认禁止 + settings.setAllowFileAccessFromFileURLs(true); + // 设置WebView内部是否允许通过 file url 加载的 Javascript 可以访问其他的源(包括http、https等源) + // Android 4.1前默认允许,4.1后默认禁止 + settings.setAllowUniversalAccessFromFileURLs(true); + binding.webview.loadUrl(webUrl); + + } + + @Override + public void logic() { + + } +} diff --git a/app/src/main/java/com/viontv/app/ui/activity/basic/VTCommonActivity.java b/app/src/main/java/com/viontv/app/ui/activity/basic/VTCommonActivity.java index fa4b0fe..6bcc56c 100644 --- a/app/src/main/java/com/viontv/app/ui/activity/basic/VTCommonActivity.java +++ b/app/src/main/java/com/viontv/app/ui/activity/basic/VTCommonActivity.java @@ -24,7 +24,7 @@ public abstract class VTCommonActivity extends AppCompatActivity { protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // 调用 HibitStatusBarTools 类的 pageDarkMode 方法,设置页面为深色模式 - VTStatusBarUtils.pageDarkMode(this, true); + VTStatusBarUtils.pageDarkMode(this, false); // 设置窗口标志,防止屏幕内容被截屏或录制 getWindow().setFlags( WindowManager.LayoutParams.FLAG_SECURE, diff --git a/app/src/main/java/com/viontv/app/ui/activity/explore/VTExploreFragment.java b/app/src/main/java/com/viontv/app/ui/activity/explore/VTExploreFragment.java index 9cf02b5..5c89958 100644 --- a/app/src/main/java/com/viontv/app/ui/activity/explore/VTExploreFragment.java +++ b/app/src/main/java/com/viontv/app/ui/activity/explore/VTExploreFragment.java @@ -1,5 +1,6 @@ package com.viontv.app.ui.activity.explore; +import android.annotation.SuppressLint; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; @@ -7,17 +8,53 @@ import android.view.ViewGroup; import androidx.annotation.NonNull; import androidx.annotation.Nullable; +import androidx.appcompat.widget.AppCompatImageView; +import androidx.appcompat.widget.AppCompatTextView; import androidx.fragment.app.Fragment; +import androidx.lifecycle.Observer; import androidx.lifecycle.ViewModelProvider; +import androidx.recyclerview.widget.RecyclerView; +import androidx.viewpager2.widget.ViewPager2; +import com.viontv.app.R; +import com.viontv.app.VTApplication; +import com.viontv.app.api.VTResult; +import com.viontv.app.databinding.FragmentExploreVtBinding; import com.viontv.app.databinding.FragmentMainVtBinding; +import com.viontv.app.model.VTVideoDetailsBean; +import com.viontv.app.model.VTVideoExploreBean; +import com.viontv.app.model.VTVideoExploreListBean; +import com.viontv.app.ui.activity.basic.VTBaseEventBus; import com.viontv.app.ui.activity.home.MainViewModel; +import com.viontv.app.ui.activity.play.VTVideoPlayerActivity; +import com.viontv.app.ui.activity.play.VTVideoViewModel; +import com.viontv.app.ui.adapter.VTGooglePlayerAdapter; +import com.viontv.app.ui.adapter.VTGooglePlayerExploreAdapter; +import com.viontv.app.ui.view.VTHomeGoogleExoPlayerView; +import com.viontv.app.utils.IntentUtils; +import com.viontv.app.utils.SingleClickUtils; +import com.viontv.app.utils.TimeUtils; +import com.viontv.app.utils.ToastUtils; +import com.viontv.app.utils.TranslatesUtils; +import com.viontv.app.utils.VTAppConstants; + +import org.greenrobot.eventbus.EventBus; +import org.greenrobot.eventbus.Subscribe; +import org.greenrobot.eventbus.ThreadMode; -public class VTExploreFragment extends Fragment { +public class VTExploreFragment extends Fragment implements VTGooglePlayerExploreAdapter.PlayerDetailCollection { private MainViewModel mViewModel; - private FragmentMainVtBinding binding; + private FragmentExploreVtBinding viewBinding; + + private VTVideoExploreBean bean = null; + private VTGooglePlayerExploreAdapter vtGooglePlayerAdapter = null; + private int currentPosition = 0; + + private boolean first = true; + private int pageHome = 1; + public static VTExploreFragment newInstance() { return new VTExploreFragment(); @@ -27,6 +64,7 @@ public class VTExploreFragment extends Fragment { public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); mViewModel = new ViewModelProvider(this).get(MainViewModel.class); + // TODO: Use the ViewModel } @@ -34,8 +72,204 @@ public class VTExploreFragment extends Fragment { @Override public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { - binding = FragmentMainVtBinding.inflate(inflater); - return binding.getRoot(); + EventBus.getDefault().register(this); + viewBinding = FragmentExploreVtBinding.inflate(inflater); + return viewBinding.getRoot(); + } + + @Override + public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { + super.onViewCreated(view, savedInstanceState); + viewBinding.avi.smoothToShow(); + mViewModel.getExploreVideoList(pageHome, 10); + viewBinding.viewPagerExploreEpisode.registerOnPageChangeCallback(new ViewPager2.OnPageChangeCallback() { + @SuppressLint("NotifyDataSetChanged") + @Override + public void onPageSelected(int position) { + super.onPageSelected(position); + currentPosition = position; + int previousPosition = vtGooglePlayerAdapter != null ? vtGooglePlayerAdapter.getCurrentEpisodePlayingPosition() : -1; + if (previousPosition != position) { + vtGooglePlayerAdapter.getRecyclerView().post(() -> vtGooglePlayerAdapter.notifyDataSetChanged()); + } + vtGooglePlayerAdapter.setCurrentEpisodePlayingPosition(position); + } + + @Override + public void onPageScrollStateChanged(int state) { + super.onPageScrollStateChanged(state); + if (state == ViewPager2.SCROLL_STATE_IDLE) { + if (viewBinding.viewPagerExploreEpisode.getCurrentItem() == viewBinding.viewPagerExploreEpisode.getAdapter().getItemCount() - 1) { + if (!first) { + pageHome++; + mViewModel.getExploreVideoList(pageHome, 10); + } else { + first = false; + } + } + } + } + }); + logic(); + } + + public void logic() { + + mViewModel.getExploreVideoLiveData().observe(getViewLifecycleOwner(), data -> { + if (data != null) { + if (pageHome == 1) { + if (data.data.getList().isEmpty()) { + viewBinding.layoutEmpty.setVisibility(View.VISIBLE); + } else { + vtGooglePlayerAdapter = new VTGooglePlayerExploreAdapter(); + viewBinding.viewPagerExploreEpisode.setAdapter(vtGooglePlayerAdapter); + vtGooglePlayerAdapter.setPlayerDetailCollection(this::collection); + vtGooglePlayerAdapter.submitList(data.data.getList()); + viewBinding.layoutEmpty.setVisibility(View.GONE); + + } + } else { + if (!data.data.getList().isEmpty()) { + vtGooglePlayerAdapter.addAll(data.data.getList()); + } else { + ToastUtils.revealToast(TranslatesUtils.translates() != null ? TranslatesUtils.translates().getNo_more_data() : "no more data.", 0); + } + } + } else { + viewBinding.layoutEmpty.setVisibility(View.VISIBLE); + ToastUtils.revealToast(TranslatesUtils.translates() != null ? TranslatesUtils.translates().getNetwork_error() : getString(R.string.vt_network_error_please_check_the_network), 0); + } + viewBinding.avi.smoothToHide(); +// viewBinding.refreshHome.finishRefresh(); + }); + + mViewModel.getCollectionLiveData().observe(getViewLifecycleOwner(), data -> { + if (data != null && data.isSuccessful()) { + AppCompatImageView imageView = getHomePlayerView().findViewById(R.id.iv_collection_controller); + AppCompatTextView textView = getHomePlayerView().findViewById(R.id.tv_collection_num_controller); + imageView.setImageResource(R.mipmap.iv_vt_collect_h); + bean.setCollect_total(bean.getCollect_total() + 1); + vtGooglePlayerAdapter.getItems().get(currentPosition).setCollect_total(bean.getCollect_total()); + vtGooglePlayerAdapter.getItems().get(currentPosition).setIs_collect(true); + textView.setText(TimeUtils.formatNumber(bean.getCollect_total())); + ToastUtils.revealToast(TranslatesUtils.translates() != null ? TranslatesUtils.translates().getSuccess() : "Success", 0); + } + }); + + mViewModel.getCollectioncancelLiveData().observe(getViewLifecycleOwner(), data -> { + if (data != null && data.isSuccessful()) { + AppCompatImageView imageView = getHomePlayerView().findViewById(R.id.iv_collection_controller); + AppCompatTextView textView = getHomePlayerView().findViewById(R.id.tv_collection_num_controller); + imageView.setImageResource(R.mipmap.iv_vt_collect_n); + bean.setCollect_total(bean.getCollect_total() - 1); + vtGooglePlayerAdapter.getItems().get(currentPosition).setCollect_total(bean.getCollect_total()); + vtGooglePlayerAdapter.getItems().get(currentPosition).setIs_collect(false); + textView.setText(TimeUtils.formatNumber(bean.getCollect_total())); + ToastUtils.revealToast(TranslatesUtils.translates() != null ? TranslatesUtils.translates().getSuccess() : "Success", 0); + } + }); + + + } + + + @Override + public void collection(VTVideoExploreBean videoExploreBean) { + SingleClickUtils.singleClick(() -> { + bean = videoExploreBean; + if (bean.isIs_collect()) { + mViewModel.cancelcollection(bean.getVideo_info().getShort_play_id()); + } else { + mViewModel.collection(bean.getVideo_info().getShort_play_id(), bean.getVideo_info().getShort_play_video_id()); + } + }); + } + + @Subscribe(threadMode = ThreadMode.MAIN) + public void onEvent(String event) { + if (VTAppConstants.Constants_Google_PLAYER_STATUS_FINISH.equals(event)) { + if (viewBinding.viewPagerExploreEpisode.getCurrentItem() == viewBinding.viewPagerExploreEpisode.getAdapter().getItemCount() - 1) { + viewBinding.viewPagerExploreEpisode.setCurrentItem(0); + } else { + vtGooglePlayerAdapter.setCurrentEpisodePlayingPosition(vtGooglePlayerAdapter.getCurrentEpisodePlayingPosition() + 1); + viewBinding.viewPagerExploreEpisode.setCurrentItem(vtGooglePlayerAdapter.getCurrentEpisodePlayingPosition()); + } + } + if (VTAppConstants.Constants_PlayerView_DetialsEvent.equals(event)) { + int item = viewBinding.viewPagerExploreEpisode.getCurrentItem(); + IntentUtils.startPlayerDetails(getActivity(), vtGooglePlayerAdapter.getItem(item).getShort_play_id(), 0); + } + if (VTAppConstants.Constants_PlayerView_SearchEvent.equals(event)) { + IntentUtils.startSearch(getActivity()); + } + + + } + + @Subscribe(threadMode = ThreadMode.MAIN) + public void onEvent(VTBaseEventBus event) { + if (VTAppConstants.Constants_Episodes_Series_DataExample.equals(event.getCode())) { + if( event.getData().getShort_play_id() == vtGooglePlayerAdapter.getItems().get(currentPosition).getShort_play_id()){ + AppCompatImageView imageView = getHomePlayerView().findViewById(R.id.iv_collection_controller); + AppCompatTextView textView = getHomePlayerView().findViewById(R.id.tv_collection_num_controller); + imageView.setImageResource(event.getData().isIs_collect() ? R.mipmap.iv_vt_collect_h : R.mipmap.iv_vt_collect_n); + vtGooglePlayerAdapter.getItems().get(currentPosition).setCollect_total(event.getData().getCollect_total()); + vtGooglePlayerAdapter.getItems().get(currentPosition).setIs_collect(event.getData().isIs_collect()); + textView.setText(TimeUtils.formatNumber(event.getData().getCollect_total())); + } + } + } + +// @Subscribe(threadMode = ThreadMode.MAIN) +// public void onEventFa(BaseEventBus event) { +// if (HibitAppConstants.Constants_Episodes_Series_DataFavorites.equals(event.getCode())) { +// if (event.getData().getName().equals(hibitHomePlayerAdapter.getItems().get(currentPosition).getName())) { +// AppCompatImageView imageView = getHomePlayerView().findViewById(R.id.iv_collection_controller); +// AppCompatTextView textView = getHomePlayerView().findViewById(R.id.tv_collection_num_controller); +// imageView.setImageResource(R.drawable.iv_hibit_like_n); +// int collectTotal = hibitHomePlayerAdapter.getItems().get(currentPosition).getCollect_total() - 1; +// hibitHomePlayerAdapter.getItems().get(currentPosition).setIs_collect(false); +// textView.setText(String.valueOf(collectTotal)); +// } +// } +// } + + private VTHomeGoogleExoPlayerView getHomePlayerView() { + RecyclerView recyclerView = (RecyclerView) viewBinding.viewPagerExploreEpisode.getChildAt(0); + return (VTHomeGoogleExoPlayerView) recyclerView.getLayoutManager().findViewByPosition(currentPosition); + } + + @Override + public void onHiddenChanged(boolean hidden) { + super.onHiddenChanged(hidden); + if (!hidden) { + if (getHomePlayerView() != null) getHomePlayerView().start(); + VTApplication.isCurrentPage = true; + } else { + VTApplication.isCurrentPage = false; + if (getHomePlayerView() != null) getHomePlayerView().suspend(); + } + } + + @Override + public void onResume() { + super.onResume(); + VTApplication.isCurrentPage = true; + } + + @Override + public void onPause() { + super.onPause(); + VTApplication.isCurrentPage = false; + if (getHomePlayerView() != null) getHomePlayerView().suspend(); + + } + + @Override + public void onDestroy() { + if (getHomePlayerView() != null) getHomePlayerView().release(); + super.onDestroy(); + EventBus.getDefault().unregister(this); } } \ No newline at end of file diff --git a/app/src/main/java/com/viontv/app/ui/activity/home/MainViewModel.java b/app/src/main/java/com/viontv/app/ui/activity/home/MainViewModel.java index 74e9774..84a81d4 100644 --- a/app/src/main/java/com/viontv/app/ui/activity/home/MainViewModel.java +++ b/app/src/main/java/com/viontv/app/ui/activity/home/MainViewModel.java @@ -1,7 +1,93 @@ package com.viontv.app.ui.activity.home; +import android.util.Log; + +import androidx.lifecycle.MutableLiveData; import androidx.lifecycle.ViewModel; +import com.viontv.app.api.VTApi; +import com.viontv.app.api.VTBaseObserver; +import com.viontv.app.api.VTResult; +import com.viontv.app.model.VTVideoDetailsBean; +import com.viontv.app.model.VTVideoExploreListBean; + +import io.reactivex.android.schedulers.AndroidSchedulers; +import io.reactivex.schedulers.Schedulers; + public class MainViewModel extends ViewModel { // TODO: Implement the ViewModel + + + private final MutableLiveData> exploreVideoList = new MutableLiveData<>(); + private final MutableLiveData collectioncancelLiveData = new MutableLiveData<>(); + private final MutableLiveData collectionLiveData = new MutableLiveData<>(); + + public MutableLiveData> getExploreVideoLiveData() { + return exploreVideoList; + } + + public MutableLiveData getCollectionLiveData() { + return collectionLiveData; + } + + public MutableLiveData getCollectioncancelLiveData() { + return collectioncancelLiveData; + } + + + public void getExploreVideoList(int currentpage, int pagesize) { + VTApi.getInstance().getExploreList(currentpage, pagesize) + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe(new VTBaseObserver>() { + @Override + public void onSuccess(VTResult feedbackResp) { + exploreVideoList.setValue(feedbackResp); + } + + @Override + public void onError(int code, String msg) { + Log.i("tag===", msg + ""); + exploreVideoList.setValue(null); + } + }); + } + + public void collection(int shortplayId, int videoId) { + VTApi.getInstance().collect(shortplayId, videoId) + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe(new VTBaseObserver() { + @Override + public void onSuccess(VTResult feedbackResp) { + collectionLiveData.setValue(feedbackResp); + } + + @Override + public void onError(int code, String msg) { + Log.i("tag===", msg + ""); + collectionLiveData.setValue(null); + } + }); + } + + public void cancelcollection(int shortplayId) { + VTApi.getInstance().cancelCollect(shortplayId) + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe(new VTBaseObserver() { + @Override + public void onSuccess(VTResult feedbackResp) { + collectioncancelLiveData.setValue(feedbackResp); + } + + @Override + public void onError(int code, String msg) { + Log.i("tag===", msg + ""); + collectioncancelLiveData.setValue(null); + } + }); + } + + } \ No newline at end of file diff --git a/app/src/main/java/com/viontv/app/ui/activity/home/VTHomeFragment.java b/app/src/main/java/com/viontv/app/ui/activity/home/VTHomeFragment.java index 586f206..aa43aaf 100644 --- a/app/src/main/java/com/viontv/app/ui/activity/home/VTHomeFragment.java +++ b/app/src/main/java/com/viontv/app/ui/activity/home/VTHomeFragment.java @@ -10,6 +10,7 @@ import androidx.annotation.Nullable; import androidx.fragment.app.Fragment; import androidx.viewpager2.adapter.FragmentStateAdapter; +import android.os.CountDownTimer; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -22,6 +23,8 @@ import com.viontv.app.api.VTResult; import com.viontv.app.databinding.FragmentMainVtBinding; import com.viontv.app.model.CateGoryItemBean; import com.viontv.app.model.HomeTopBean; +import com.viontv.app.model.ItemBean; +import com.viontv.app.utils.IntentUtils; import java.util.ArrayList; import java.util.List; @@ -62,10 +65,14 @@ public class VTHomeFragment extends Fragment { public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); getTopTitles(); - + myCountDownTimer = new MyCountDownTimer(365 * 24 * 60 * 60, 5000); } + int item = 0; + private List itemSearchList; + private void getTopTitles() { + binding.layoutSearch.setOnClickListener(v -> IntentUtils.startSearch(getActivity())); VTApi.getInstance().homeTop() .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) @@ -73,9 +80,19 @@ public class VTHomeFragment extends Fragment { @Override public void onSuccess(VTResult feedbackResp) { - List itemBeans = feedbackResp.data.getCategory(); - tabShow(itemBeans); - binding.tvHomeSearch.setHint(feedbackResp.data.getHotData().get(0).getName()); + if (feedbackResp.data != null) { + List itemBeans = feedbackResp.data.getCategory(); + tabShow(itemBeans); + + itemSearchList = feedbackResp.data.getHotData(); + item = 0; + binding.tvHomeSearch.setHint(itemSearchList.get(item).getName()); + if (itemSearchList.size() > 1) { + myCountDownTimer.start(); + } + + } + } @Override @@ -92,7 +109,7 @@ public class VTHomeFragment extends Fragment { listFragment = new ArrayList<>(); listFragment.add(VTHotFragment.newInstance()); listFragment.add(VTTopFragment.newInstance()); - for (CateGoryItemBean itemBean:itemBeans){ + for (CateGoryItemBean itemBean : itemBeans) { titles.add(itemBean.getCategory_name()); listFragment.add(VTTabItemFragment.newInstance(itemBean.getCategory_id())); } @@ -128,4 +145,42 @@ public class VTHomeFragment extends Fragment { } + + MyCountDownTimer myCountDownTimer; + + + private class MyCountDownTimer extends CountDownTimer { + + public MyCountDownTimer(long millisInFuture, long countDownInterval) { + super(millisInFuture, countDownInterval); + } + + //计时过程 + @Override + public void onTick(long l) { + //防止计时过程中重复点击 + if (itemSearchList.size() - 1 > item) { + item++; + } else { + item = 0; + } + binding.tvHomeSearch.setHint(itemSearchList.get(item).getName()); + } + + @Override + public void onFinish() { + + + } + } + + + @Override + public void onDestroy() { + super.onDestroy(); + if (myCountDownTimer != null) { + myCountDownTimer.cancel(); + myCountDownTimer = null; + } + } } \ No newline at end of file diff --git a/app/src/main/java/com/viontv/app/ui/activity/home/VTHotFragment.java b/app/src/main/java/com/viontv/app/ui/activity/home/VTHotFragment.java index a36aade..2a479e7 100644 --- a/app/src/main/java/com/viontv/app/ui/activity/home/VTHotFragment.java +++ b/app/src/main/java/com/viontv/app/ui/activity/home/VTHotFragment.java @@ -1,6 +1,5 @@ package com.viontv.app.ui.activity.home; -import android.content.Intent; import android.os.Bundle; import android.util.Log; import android.view.LayoutInflater; @@ -21,17 +20,16 @@ import com.viontv.app.api.VTResult; import com.viontv.app.databinding.FragmentHotVtBinding; import com.viontv.app.databinding.ItemHomeExploreVtBinding; import com.viontv.app.databinding.ItemHotSquareVtBinding; -import com.viontv.app.model.HomeBottomListBean; +import com.viontv.app.model.VTVideoListBean; import com.viontv.app.model.HomeNineSquareBean; import com.viontv.app.model.HomeTopBannerBean; import com.viontv.app.model.ItemBean; -import com.viontv.app.ui.adapter.BannerHomeAdapter; -import com.viontv.app.ui.adapter.CommonAdapter; -import com.viontv.app.ui.adapter.HotBottomListAdapter; -import com.viontv.app.ui.adapter.NineSquareAdapter; +import com.viontv.app.ui.adapter.VTBannerHomeAdapter; +import com.viontv.app.ui.adapter.VTHotBottomListAdapter; +import com.viontv.app.ui.adapter.VTNineSquareAdapter; import com.viontv.app.utils.IntentUtils; -import com.youth.banner.listener.OnBannerListener; +import java.util.ArrayList; import java.util.List; import io.reactivex.android.schedulers.AndroidSchedulers; @@ -45,7 +43,7 @@ public class VTHotFragment extends Fragment { private int currentPage = 1; - HotBottomListAdapter adapter; + VTHotBottomListAdapter adapter; LinearLayoutManager layoutManager; public static VTHotFragment newInstance() { @@ -70,24 +68,39 @@ public class VTHotFragment extends Fragment { @Override public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); + initRefreshLayout(); initShow(); } + private void initRefreshLayout() { + binding.smartrefreshlayoutHot.setEnableRefresh(true); + binding.smartrefreshlayoutHot.setEnableLoadMore(true); + binding.smartrefreshlayoutHot.setOnRefreshListener(refreshlayout -> { + currentPage = 1; + getBottomData(); + }); + binding.smartrefreshlayoutHot.setOnLoadMoreListener(refreshLayout -> { + currentPage++; + getBottomData(); + + }); + } + public void initShow() { binding.banner.addBannerLifecycleObserver(this); initBannerAndSquare(); initHomeBottom(); - binding.recyclerviewGenres.addOnScrollListener(new RecyclerView.OnScrollListener() { - @Override - public void onScrollStateChanged(@NonNull RecyclerView recyclerView, int newState) { - super.onScrollStateChanged(recyclerView, newState); - } - - @Override - public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) { - super.onScrolled(recyclerView, dx, dy); - } - }); +// binding.recyclerviewGenres.addOnScrollListener(new RecyclerView.OnScrollListener() { +// @Override +// public void onScrollStateChanged(@NonNull RecyclerView recyclerView, int newState) { +// super.onScrollStateChanged(recyclerView, newState); +// } +// +// @Override +// public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) { +// super.onScrolled(recyclerView, dx, dy); +// } +// }); } public void initBannerAndSquare() { @@ -116,40 +129,40 @@ public class VTHotFragment extends Fragment { public void initHomeBottom() { layoutManager = new LinearLayoutManager(getActivity()); binding.recyclerviewGenres.setLayoutManager(layoutManager); - adapter = new HotBottomListAdapter(getActivity(), ItemHomeExploreVtBinding.class); + adapter = new VTHotBottomListAdapter(getActivity(), ItemHomeExploreVtBinding.class); adapter.setItemClickListener((data, holder) -> { IntentUtils.startPlayerDetails(getActivity(), data.getShort_play_id(), 0); }); binding.recyclerviewGenres.setAdapter(adapter); - binding.recyclerviewGenres.addOnScrollListener(new RecyclerView.OnScrollListener() { - @Override - public void onScrollStateChanged(@NonNull RecyclerView recyclerView, int newState) { - super.onScrollStateChanged(recyclerView, newState); - if (newState == RecyclerView.SCROLL_STATE_IDLE) { - int position = layoutManager.findLastCompletelyVisibleItemPosition(); - int position2 = layoutManager.findLastVisibleItemPosition(); - Log.i("Home+++++++++++++++", "position==" + position); - Log.i("Home+++++++++++++++", "position2==" + position2); - if (position == adapter.getItemCount() - 1) { - Log.i("Home+++++++++++++++", "page++++"); - currentPage++; - getBottomData(); - } -// if (adapter.getItemCount() < position + LOAD_MORE_DIFF -// && adapter.getItemCount() > 0) { +// binding.recyclerviewGenres.addOnScrollListener(new RecyclerView.OnScrollListener() { +// @Override +// public void onScrollStateChanged(@NonNull RecyclerView recyclerView, int newState) { +// super.onScrollStateChanged(recyclerView, newState); +// if (newState == RecyclerView.SCROLL_STATE_IDLE) { +// int position = layoutManager.findLastCompletelyVisibleItemPosition(); +// int position2 = layoutManager.findLastVisibleItemPosition(); +// Log.i("Home+++++++++++++++", "position==" + position); +// Log.i("Home+++++++++++++++", "position2==" + position2); +// if (position == adapter.getItemCount() - 1) { // Log.i("Home+++++++++++++++", "page++++"); // currentPage++; // getBottomData(); // } - } - } - - @Override - public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) { - super.onScrolled(recyclerView, dx, dy); - } - }); +//// if (adapter.getItemCount() < position + LOAD_MORE_DIFF +//// && adapter.getItemCount() > 0) { +//// Log.i("Home+++++++++++++++", "page++++"); +//// currentPage++; +//// getBottomData(); +//// } +// } +// } +// +// @Override +// public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) { +// super.onScrolled(recyclerView, dx, dy); +// } +// }); currentPage = 1; getBottomData(); } @@ -158,10 +171,12 @@ public class VTHotFragment extends Fragment { VTApi.getInstance().newShortPlay(currentPage, 10) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) - .subscribe(new VTBaseObserver>() { + .subscribe(new VTBaseObserver>() { @Override - public void onSuccess(VTResult feedbackResp) { + public void onSuccess(VTResult feedbackResp) { + binding.smartrefreshlayoutHot.finishRefresh(); + binding.smartrefreshlayoutHot.finishLoadMore(); if (currentPage == 1) { adapter.addDataList(feedbackResp.data.getShort_play_list(), true); } else { @@ -173,7 +188,8 @@ public class VTHotFragment extends Fragment { @Override public void onError(int code, String msg) { - + binding.smartrefreshlayoutHot.finishRefresh(); + binding.smartrefreshlayoutHot.finishLoadMore(); } }); } @@ -181,7 +197,7 @@ public class VTHotFragment extends Fragment { public void initBanner(List itemBeans) { - binding.banner.setAdapter(new BannerHomeAdapter(itemBeans)). + binding.banner.setAdapter(new VTBannerHomeAdapter(itemBeans)). setCurrentItem(0, true) .addBannerLifecycleObserver(this) .setOnBannerListener((data, position) -> IntentUtils.startPlayerDetails(getActivity(), itemBeans.get(position).getShort_play_id(), 0)) @@ -199,7 +215,7 @@ public class VTHotFragment extends Fragment { binding.trendingTv.setText(homeNineSquareBean.getTitle()); binding.recyclerviewTrending.setLayoutManager(new GridLayoutManager(getActivity(), 3)); - NineSquareAdapter adapter = new NineSquareAdapter(getActivity(), ItemHotSquareVtBinding.class); + VTNineSquareAdapter adapter = new VTNineSquareAdapter(getActivity(), ItemHotSquareVtBinding.class); adapter.setItemClickListener((data, holder) -> { IntentUtils.startPlayerDetails(getActivity(), data.getShort_play_id(), 0); }); diff --git a/app/src/main/java/com/viontv/app/ui/activity/home/VTTabItemFragment.java b/app/src/main/java/com/viontv/app/ui/activity/home/VTTabItemFragment.java index 1f27d58..7fd0f84 100644 --- a/app/src/main/java/com/viontv/app/ui/activity/home/VTTabItemFragment.java +++ b/app/src/main/java/com/viontv/app/ui/activity/home/VTTabItemFragment.java @@ -18,20 +18,12 @@ import com.viontv.app.api.VTApi; import com.viontv.app.api.VTBaseObserver; import com.viontv.app.api.VTResult; import com.viontv.app.databinding.FragmentCategoryItemBinding; -import com.viontv.app.databinding.FragmentHotVtBinding; -import com.viontv.app.databinding.FragmentTopVtBinding; -import com.viontv.app.databinding.ItemHomeExploreVtBinding; import com.viontv.app.databinding.ItemHomeTablistVtBinding; -import com.viontv.app.databinding.ItemHotSquareVtBinding; -import com.viontv.app.model.HomeBottomListBean; -import com.viontv.app.model.HomeNineSquareBean; -import com.viontv.app.model.HomeTopBannerBean; +import com.viontv.app.model.VTVideoListBean; import com.viontv.app.model.ItemBean; import com.viontv.app.model.TabItemBean; -import com.viontv.app.ui.adapter.BannerHomeAdapter; -import com.viontv.app.ui.adapter.HotBottomListAdapter; -import com.viontv.app.ui.adapter.NineSquareAdapter; -import com.viontv.app.ui.adapter.TabItemListAdapter; +import com.viontv.app.ui.adapter.VTBannerHomeAdapter; +import com.viontv.app.ui.adapter.VTTabItemListAdapter; import com.viontv.app.utils.IntentUtils; import java.util.List; @@ -47,7 +39,7 @@ public class VTTabItemFragment extends Fragment { private int currentPage = 1; - TabItemListAdapter adapter; + VTTabItemListAdapter adapter; LinearLayoutManager layoutManager; private int categoryId; @@ -101,7 +93,7 @@ public class VTTabItemFragment extends Fragment { } public void initBannerData() { - VTApi.getInstance().getTabItemBanner(String.valueOf(categoryId)) + VTApi.getInstance().getTabItemBanner(categoryId) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(new VTBaseObserver>() { @@ -126,7 +118,7 @@ public class VTTabItemFragment extends Fragment { public void initGridList() { layoutManager = new GridLayoutManager(getActivity(), 2); binding.recyclerviewGrid.setLayoutManager(layoutManager); - adapter = new TabItemListAdapter(getActivity(), ItemHomeTablistVtBinding.class); + adapter = new VTTabItemListAdapter(getActivity(), ItemHomeTablistVtBinding.class); adapter.setItemClickListener((data, holder) -> { IntentUtils.startPlayerDetails(getActivity(), data.getShort_play_id(), 0); }); @@ -165,13 +157,13 @@ public class VTTabItemFragment extends Fragment { } public void getBottomData() { - VTApi.getInstance().getVideoList(String.valueOf(categoryId), currentPage, 10, "") + VTApi.getInstance().getVideoList(categoryId, currentPage, 10, "") .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) - .subscribe(new VTBaseObserver>() { + .subscribe(new VTBaseObserver>() { @Override - public void onSuccess(VTResult feedbackResp) { + public void onSuccess(VTResult feedbackResp) { if (currentPage == 1) { adapter.addDataList(feedbackResp.data.getList(), true); } else { @@ -191,7 +183,7 @@ public class VTTabItemFragment extends Fragment { public void initBanner(List itemBeans) { - binding.banner.setAdapter(new BannerHomeAdapter(itemBeans)). + binding.banner.setAdapter(new VTBannerHomeAdapter(itemBeans)). setCurrentItem(0, true) .addBannerLifecycleObserver(this) .setOnBannerListener((data, position) -> IntentUtils.startPlayerDetails(getActivity(), itemBeans.get(position).getShort_play_id(), 0)) diff --git a/app/src/main/java/com/viontv/app/ui/activity/home/VTTopFragment.java b/app/src/main/java/com/viontv/app/ui/activity/home/VTTopFragment.java index d3230a4..f13f664 100644 --- a/app/src/main/java/com/viontv/app/ui/activity/home/VTTopFragment.java +++ b/app/src/main/java/com/viontv/app/ui/activity/home/VTTopFragment.java @@ -18,9 +18,9 @@ import com.viontv.app.api.VTResult; import com.viontv.app.databinding.FragmentTopVtBinding; import com.viontv.app.databinding.ItemHomeExploreVtBinding; -import com.viontv.app.model.HomeBottomListBean; +import com.viontv.app.model.VTVideoListBean; -import com.viontv.app.ui.adapter.Top10ListAdapter; +import com.viontv.app.ui.adapter.VTTop10ListAdapter; import io.reactivex.android.schedulers.AndroidSchedulers; import io.reactivex.schedulers.Schedulers; @@ -32,7 +32,7 @@ public class VTTopFragment extends Fragment { private FragmentTopVtBinding binding; - Top10ListAdapter adapter; + VTTop10ListAdapter adapter; LinearLayoutManager layoutManager; public static VTTopFragment newInstance() { @@ -65,7 +65,7 @@ public class VTTopFragment extends Fragment { binding.rvFragmentHometop.setLayoutManager(layoutManager); layoutManager = new LinearLayoutManager(getActivity()); binding.rvFragmentHometop.setLayoutManager(layoutManager); - adapter = new Top10ListAdapter(getActivity(), ItemHomeExploreVtBinding.class); + adapter = new VTTop10ListAdapter(getActivity(), ItemHomeExploreVtBinding.class); binding.rvFragmentHometop.setAdapter(adapter); getTop10Data(); } @@ -74,10 +74,10 @@ public class VTTopFragment extends Fragment { VTApi.getInstance().homeTop10(VTApiService.rankTop10Type) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) - .subscribe(new VTBaseObserver>() { + .subscribe(new VTBaseObserver>() { @Override - public void onSuccess(VTResult feedbackResp) { + public void onSuccess(VTResult feedbackResp) { adapter.addDataList(feedbackResp.data.getList(), true); } diff --git a/app/src/main/java/com/viontv/app/ui/activity/me/VTMeFragment.java b/app/src/main/java/com/viontv/app/ui/activity/me/VTMeFragment.java index 345fcb9..4aff09d 100644 --- a/app/src/main/java/com/viontv/app/ui/activity/me/VTMeFragment.java +++ b/app/src/main/java/com/viontv/app/ui/activity/me/VTMeFragment.java @@ -1,5 +1,6 @@ package com.viontv.app.ui.activity.me; +import android.content.Intent; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; @@ -9,15 +10,42 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.fragment.app.Fragment; import androidx.lifecycle.ViewModelProvider; +import androidx.recyclerview.widget.LinearLayoutManager; +import com.bumptech.glide.Glide; +import com.viontv.app.R; +import com.viontv.app.api.VTApiService; import com.viontv.app.databinding.FragmentMainVtBinding; +import com.viontv.app.databinding.FragmentMeBinding; +import com.viontv.app.databinding.ItemHomeExploreVtBinding; +import com.viontv.app.databinding.ItemVideoHistoryBinding; +import com.viontv.app.model.ItemBean; +import com.viontv.app.ui.activity.WebViewActivity; import com.viontv.app.ui.activity.home.MainViewModel; +import com.viontv.app.ui.adapter.VTCommonAdapter; +import com.viontv.app.ui.adapter.VTGooglePlayerExploreAdapter; +import com.viontv.app.ui.adapter.VTTop10ListAdapter; +import com.viontv.app.ui.adapter.VTUserVideoHistoryAdapter; +import com.viontv.app.utils.IntentUtils; +import com.viontv.app.utils.ToastUtils; +import com.viontv.app.utils.TranslatesUtils; +import com.viontv.app.utils.VTAppConstants; + +import org.greenrobot.eventbus.EventBus; +import org.greenrobot.eventbus.Subscribe; +import org.greenrobot.eventbus.ThreadMode; + +import java.util.Objects; public class VTMeFragment extends Fragment { - private MainViewModel mViewModel; - private FragmentMainVtBinding binding; + private VTUserViewModel mViewModel; + private FragmentMeBinding binding; + + private int currentPage = 1; + + private VTUserVideoHistoryAdapter adapter; public static VTMeFragment newInstance() { return new VTMeFragment(); @@ -26,7 +54,7 @@ public class VTMeFragment extends Fragment { @Override public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); - mViewModel = new ViewModelProvider(this).get(MainViewModel.class); + mViewModel = new ViewModelProvider(this).get(VTUserViewModel.class); // TODO: Use the ViewModel } @@ -34,8 +62,67 @@ public class VTMeFragment extends Fragment { @Override public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { - binding = FragmentMainVtBinding.inflate(inflater); + binding = FragmentMeBinding.inflate(inflater); + EventBus.getDefault().register(this); return binding.getRoot(); } + @Override + public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { + super.onViewCreated(view, savedInstanceState); + mViewModel.getUserInfo(); + mViewModel.getHistory(currentPage, 10); + + LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity(), LinearLayoutManager.HORIZONTAL, false); + binding.recyclerviewHistory.setLayoutManager(layoutManager); + + adapter = new VTUserVideoHistoryAdapter(getActivity(), ItemVideoHistoryBinding.class); + adapter.setItemClickListener((data, holder) -> { + IntentUtils.startPlayerDetails(getActivity(), data.getShort_play_id(), 0); + }); + binding.recyclerviewHistory.setAdapter(adapter); + binding.tvPrivatePolicy.setOnClickListener(v -> startWebActivity(VTApiService.ZyreoTV_Private, getResources().getString(R.string.tabme_private_policy))); + binding.tvUserAgreement.setOnClickListener(v -> startWebActivity(VTApiService.ZyreoTV_USERAgreement, getResources().getString(R.string.tabme_user_agreement))); + logic(); + } + + private void startWebActivity(String url, String title) { + startActivity(new Intent(getActivity(), WebViewActivity.class).putExtra(VTAppConstants.Constants_Page_WebUrl, url).putExtra(VTAppConstants.Constants_Page_WebTitle, title)); + } + + public void logic() { + mViewModel.getGetUserInfoLiveData().observe(getViewLifecycleOwner(), data -> { + if (data != null) { + binding.tvMeName.setText(data.data.getFamily_name()); + binding.tvMeId.setText("ID:" + data.data.getId()); + Glide.with(requireActivity()).load(data.data.getAvator()).error(R.mipmap.ic_default_head).into(binding.ivHead); + } + }); + + mViewModel.getUserVideoHistoryLiveData().observe(getViewLifecycleOwner(), vtVideoListBeanVTResult -> { + if (vtVideoListBeanVTResult != null && !vtVideoListBeanVTResult.data.getList().isEmpty()) { + if (currentPage == 1) { + adapter.addDataList(vtVideoListBeanVTResult.data.getList(), true); + } else { + adapter.addDataList(vtVideoListBeanVTResult.data.getList(), false); + } + } + }); + } + + @Subscribe(threadMode = ThreadMode.MAIN) + public void onEvent(String event) { + if (VTAppConstants.Constants_PlayerView_CreateHistoryEvent.equals(event)) { + currentPage = 1; + mViewModel.getHistory(1, 10); + } + + + } + + @Override + public void onDestroy() { + super.onDestroy(); + EventBus.getDefault().unregister(this); + } } \ No newline at end of file diff --git a/app/src/main/java/com/viontv/app/ui/activity/me/VTUserViewModel.java b/app/src/main/java/com/viontv/app/ui/activity/me/VTUserViewModel.java new file mode 100644 index 0000000..853a051 --- /dev/null +++ b/app/src/main/java/com/viontv/app/ui/activity/me/VTUserViewModel.java @@ -0,0 +1,75 @@ +package com.viontv.app.ui.activity.me; + +import android.util.Log; + +import androidx.lifecycle.MutableLiveData; +import androidx.lifecycle.ViewModel; + +import com.viontv.app.api.VTApi; +import com.viontv.app.api.VTBaseObserver; +import com.viontv.app.api.VTResult; +import com.viontv.app.model.VTUserInfoBean; +import com.viontv.app.model.VTVideoDetailsBean; +import com.viontv.app.model.VTVideoListBean; + +import io.reactivex.android.schedulers.AndroidSchedulers; +import io.reactivex.schedulers.Schedulers; + +/** + * 关于用户的接口 + */ +public class VTUserViewModel extends ViewModel { + + + private final MutableLiveData> userInfoLiveData = new MutableLiveData<>(); + private final MutableLiveData> userVideoHistoryLiveData = new MutableLiveData<>(); + + + public MutableLiveData> getGetUserInfoLiveData() { + return userInfoLiveData; + } + + public MutableLiveData> getUserVideoHistoryLiveData() { + return userVideoHistoryLiveData; + } + + public void getUserInfo() { + VTApi.getInstance().getUserInfo() + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe(new VTBaseObserver>() { + @Override + public void onSuccess(VTResult feedbackResp) { + + userInfoLiveData.setValue(feedbackResp); + } + + @Override + public void onError(int code, String msg) { + Log.i("tag===", msg + ""); + userInfoLiveData.setValue(null); + } + }); + } + + + public void getHistory(int currentPage, int pageSize) { + VTApi.getInstance().getVideoHistoryList(currentPage, pageSize) + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe(new VTBaseObserver>() { + @Override + public void onSuccess(VTResult feedbackResp) { + userVideoHistoryLiveData.setValue(feedbackResp); + } + + @Override + public void onError(int code, String msg) { + Log.i("tag===", msg + ""); + userVideoHistoryLiveData.setValue(null); + } + }); + } + + +} \ No newline at end of file diff --git a/app/src/main/java/com/viontv/app/ui/activity/play/VTEpisodesSelectDialogFragment.java b/app/src/main/java/com/viontv/app/ui/activity/play/VTEpisodesSelectDialogFragment.java index 9dbd360..54d413e 100644 --- a/app/src/main/java/com/viontv/app/ui/activity/play/VTEpisodesSelectDialogFragment.java +++ b/app/src/main/java/com/viontv/app/ui/activity/play/VTEpisodesSelectDialogFragment.java @@ -55,17 +55,17 @@ public class VTEpisodesSelectDialogFragment extends DialogFragment { hibitEpisodesSeriesAdapter.setOnItemClickListener((adapter, view1, position) -> { VTVideoDetailsBean.Episode item = (VTVideoDetailsBean.Episode) adapter.getItem(position); - if (position > 0) { - VTVideoDetailsBean.Episode item1 = (VTVideoDetailsBean.Episode) adapter.getItem(position - 1); - if (item1.isIs_lock()) { - String errorMessage = TranslatesUtils.translates() != null ? - TranslatesUtils.translates().getJump_unlock_error() : - "The prequel to this series is not unlocked. Please unlock the prequel before unlocking this series"; - ToastUtils.revealToast(errorMessage, 0); - dismiss(); - return; - } - } +// if (position > 0) { +// VTVideoDetailsBean.Episode item1 = (VTVideoDetailsBean.Episode) adapter.getItem(position - 1); +// if (item1.isIs_lock()) { +// String errorMessage = TranslatesUtils.translates() != null ? +// TranslatesUtils.translates().getJump_unlock_error() : +// "The prequel to this series is not unlocked. Please unlock the prequel before unlocking this series"; +// ToastUtils.revealToast(errorMessage, 0); +// dismiss(); +// return; +// } +// } pageEpisodesSeriesCallBack.chooseEpisodesSeries(item); dismiss(); }); diff --git a/app/src/main/java/com/viontv/app/ui/activity/play/VTVideoPlayerActivity.java b/app/src/main/java/com/viontv/app/ui/activity/play/VTVideoPlayerActivity.java index d5ec0de..c2dd76c 100644 --- a/app/src/main/java/com/viontv/app/ui/activity/play/VTVideoPlayerActivity.java +++ b/app/src/main/java/com/viontv/app/ui/activity/play/VTVideoPlayerActivity.java @@ -15,6 +15,7 @@ import androidx.recyclerview.widget.RecyclerView; import androidx.viewpager2.widget.ViewPager2; import com.viontv.app.R; +import com.viontv.app.VTApplication; import com.viontv.app.api.VTResult; import com.viontv.app.databinding.ActivityVideoDetailsVtBinding; import com.viontv.app.model.VTVideoDetailsBean; @@ -50,6 +51,7 @@ public class VTVideoPlayerActivity extends VTCommonActivity 1) { - viewBinding.viewPagerHibitEpisode.setCurrentItem(it.data.video_info.getEpisode() - 1, false); + viewBinding.viewPagerVtEpisode.setCurrentItem(it.data.video_info.getEpisode() - 1, false); } } } else { @@ -260,63 +263,64 @@ public class VTVideoPlayerActivity extends VTCommonActivity { -// if (it != null) { -// AppCompatImageView imageView = pageGoogleExoPlayerView() != null ? pageGoogleExoPlayerView().findViewById(R.id.iv_collection_controller) : null; -// AppCompatTextView textview = pageGoogleExoPlayerView() != null ? pageGoogleExoPlayerView().findViewById(R.id.tv_collection_num_controller) : null; -// if (shortVideoInfo != null) { -// shortVideoInfo.setIs_collect(true); -// shortVideoInfo.setCollect_total(shortVideoInfo.getCollect_total()+1); -// } -// if (imageView != null) { -// imageView.setImageResource(R.mipmap.iv_vt_collect_h); -// } -// if (textview != null && shortVideoInfo != null) { -// textview.setText(TimeUtils.formatNumber(shortVideoInfo.getCollect_total())); -// } -// if (vtGooglePlayerAdapter != null) { -// vtGooglePlayerAdapter.setShortVideoInfo(shortVideoInfo); -// } -// EventBus.getDefault().post(new VTBaseEventBus<>(VTAppConstants.Constants_Episodes_Series_DataExample, shortVideoInfo)); -// if (TranslatesUtils.translates() != null) { -// ToastUtils.revealToast(TranslatesUtils.translates().getSuccess(),0); -// } -// } else { -// if (TranslatesUtils.translates() != null) { -// ToastUtils.revealToast(TranslatesUtils.translates().getNetwork_error(),0); -// } else { -// ToastUtils.revealToast(getString(R.string.vt_network_error_please_check_the_network),0); -// } -// } -// }); -// -// vtViewModel.getCancelCollectData().observe(this, it -> { -// if (it != null) { -// AppCompatImageView imageView = pageGoogleExoPlayerView() != null ? pageGoogleExoPlayerView().findViewById(R.id.iv_collection_controller) : null; -// AppCompatTextView textview = pageGoogleExoPlayerView() != null ? pageGoogleExoPlayerView().findViewById(R.id.tv_collection_num_controller) : null; -// if (shortVideoInfo != null) { -// shortVideoInfo.setIs_collect(false); -// shortVideoInfo.setCollect_total(shortVideoInfo.getCollect_total()-1); -// } -// if (imageView != null) { -// imageView.setImageResource(R.mipmap.iv_vt_collect_n); -// } -// if (textview != null && shortVideoInfo != null) { -// textview.setText(TimeUtils.formatNumber(shortVideoInfo.getCollect_total())); -// } -// } else { -// if (TranslatesUtils.translates() != null) { -// ToastUtils.revealToast(TranslatesUtils.translates().getNetwork_error(),0); -// } else { -// ToastUtils.revealToast(getString(R.string.vt_network_error_please_check_the_network),0); -// } -// } -// }); + vtViewModel.getCollectionLiveData().observe(this, it -> { + if (it != null) { + AppCompatImageView imageView = pageGoogleExoPlayerView() != null ? pageGoogleExoPlayerView().findViewById(R.id.iv_collection_controller) : null; + AppCompatTextView textview = pageGoogleExoPlayerView() != null ? pageGoogleExoPlayerView().findViewById(R.id.tv_collection_num_controller) : null; + if (shortVideoInfo != null) { + shortVideoInfo.setIs_collect(true); + shortVideoInfo.setCollect_total(shortVideoInfo.getCollect_total() + 1); + } + if (imageView != null) { + imageView.setImageResource(R.mipmap.iv_vt_collect_h); + } + if (textview != null && shortVideoInfo != null) { + textview.setText(TimeUtils.formatNumber(shortVideoInfo.getCollect_total())); + } + if (vtGooglePlayerAdapter != null) { + vtGooglePlayerAdapter.setShortVideoInfo(shortVideoInfo); + } + EventBus.getDefault().post(new VTBaseEventBus<>(VTAppConstants.Constants_Episodes_Series_DataExample, shortVideoInfo)); + if (TranslatesUtils.translates() != null) { + ToastUtils.revealToast(TranslatesUtils.translates().getSuccess(), 0); + } + } else { + if (TranslatesUtils.translates() != null) { + ToastUtils.revealToast(TranslatesUtils.translates().getNetwork_error(), 0); + } else { + ToastUtils.revealToast(getString(R.string.vt_network_error_please_check_the_network), 0); + } + } + }); + + vtViewModel.getCollectioncancelLiveData().observe(this, it -> { + if (it != null) { + AppCompatImageView imageView = pageGoogleExoPlayerView() != null ? pageGoogleExoPlayerView().findViewById(R.id.iv_collection_controller) : null; + AppCompatTextView textview = pageGoogleExoPlayerView() != null ? pageGoogleExoPlayerView().findViewById(R.id.tv_collection_num_controller) : null; + if (shortVideoInfo != null) { + shortVideoInfo.setIs_collect(false); + shortVideoInfo.setCollect_total(shortVideoInfo.getCollect_total() - 1); + } + if (imageView != null) { + imageView.setImageResource(R.mipmap.iv_vt_collect_n); + } + if (textview != null && shortVideoInfo != null) { + textview.setText(TimeUtils.formatNumber(shortVideoInfo.getCollect_total())); + } + EventBus.getDefault().post(new VTBaseEventBus<>(VTAppConstants.Constants_Episodes_Series_DataExample, shortVideoInfo)); + } else { + if (TranslatesUtils.translates() != null) { + ToastUtils.revealToast(TranslatesUtils.translates().getNetwork_error(), 0); + } else { + ToastUtils.revealToast(getString(R.string.vt_network_error_please_check_the_network), 0); + } + } + }); } // 假设 pageGoogleExoPlayerView 方法在父类或者其他地方有定义 private VTGoogleExoPlayerView pageGoogleExoPlayerView() { - RecyclerView recyclerView = (RecyclerView) viewBinding.viewPagerHibitEpisode.getChildAt(0); + RecyclerView recyclerView = (RecyclerView) viewBinding.viewPagerVtEpisode.getChildAt(0); VTGoogleExoPlayerView googleExoPlayerView = (VTGoogleExoPlayerView) recyclerView.getLayoutManager().findViewByPosition(currentPosition); return googleExoPlayerView; } @@ -328,7 +332,6 @@ public class VTVideoPlayerActivity extends VTCommonActivity=0 ) { + if (vtGooglePlayerAdapter != null && vtGooglePlayerAdapter.getCurrentEpisodePlayingPosition() >= 0) { int nextPosition = vtGooglePlayerAdapter.getCurrentEpisodePlayingPosition() + 1; vtGooglePlayerAdapter.getItems(); if (nextPosition < vtGooglePlayerAdapter.getItems().size()) { @@ -354,7 +357,7 @@ public class VTVideoPlayerActivity extends VTCommonActivity collectioncancelLiveData = new MutableLiveData<>(); + private final MutableLiveData collectionLiveData = new MutableLiveData<>(); + + public MutableLiveData getCollectionLiveData() { + return collectionLiveData; + } + + public MutableLiveData getCollectioncancelLiveData() { + return collectioncancelLiveData; + } + public void getVideoDetails(int short_play_id, int video_id) { VTApi.getInstance().getVideoDetails(short_play_id, video_id) .subscribeOn(Schedulers.io()) @@ -41,5 +52,58 @@ public class VTVideoViewModel extends ViewModel { }); } + public void createHistory(int short_play_id,int video_id){ + VTApi.getInstance().createVideoHistory(short_play_id, video_id) + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe(new VTBaseObserver<>() { + @Override + public void onSuccess(VTResult feedbackResp) { + + } + + @Override + public void onError(int code, String msg) { + + } + }); + } + + public void collection(int shortplayId, int videoId) { + VTApi.getInstance().collect(shortplayId, videoId) + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe(new VTBaseObserver() { + @Override + public void onSuccess(VTResult feedbackResp) { + collectionLiveData.setValue(feedbackResp); + } + + @Override + public void onError(int code, String msg) { + Log.i("tag===", msg + ""); + collectionLiveData.setValue(null); + } + }); + } + + public void cancelcollection(int shortplayId) { + VTApi.getInstance().cancelCollect(shortplayId) + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe(new VTBaseObserver() { + @Override + public void onSuccess(VTResult feedbackResp) { + collectioncancelLiveData.setValue(feedbackResp); + } + + @Override + public void onError(int code, String msg) { + Log.i("tag===", msg + ""); + collectioncancelLiveData.setValue(null); + } + }); + } + } \ No newline at end of file diff --git a/app/src/main/java/com/viontv/app/ui/activity/search/VTSearchActivity.java b/app/src/main/java/com/viontv/app/ui/activity/search/VTSearchActivity.java new file mode 100644 index 0000000..9f84a47 --- /dev/null +++ b/app/src/main/java/com/viontv/app/ui/activity/search/VTSearchActivity.java @@ -0,0 +1,178 @@ +package com.viontv.app.ui.activity.search; + +import static android.view.View.GONE; +import static android.view.View.VISIBLE; + +import android.text.Editable; +import android.text.TextUtils; +import android.text.TextWatcher; +import android.view.inputmethod.EditorInfo; + +import androidx.lifecycle.ViewModelProvider; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.StaggeredGridLayoutManager; + +import com.google.gson.reflect.TypeToken; +import com.viontv.app.databinding.ActivitySearchVtBinding; +import com.viontv.app.databinding.ItemSearchDataVtBinding; +import com.viontv.app.databinding.ItemSearchHotVtBinding; +import com.viontv.app.ui.activity.basic.VTCommonActivity; +import com.viontv.app.ui.adapter.VTSearchDataAdapter; +import com.viontv.app.ui.adapter.VTSearchHistoryAdapter; +import com.viontv.app.ui.adapter.VTSearchHotListAdapter; +import com.viontv.app.utils.IntentUtils; +import com.viontv.app.utils.SharePreferenceUtils; +import com.viontv.app.utils.VTAppConstants; +import com.viontv.app.utils.VTGsonUtils; + +import java.util.ArrayList; + +public class VTSearchActivity extends VTCommonActivity { + + ActivitySearchVtBinding binding; + VTSearchViewModel vtSearchViewModel; + + VTSearchHotListAdapter adapter; + + VTSearchHistoryAdapter historyAdapter; + + VTSearchDataAdapter searchDataAdapter; + + @Override + public void init() { + vtSearchViewModel = new ViewModelProvider(this).get(VTSearchViewModel.class); + getWindow().setNavigationBarColor(getResources().getColor(android.R.color.black)); + binding = ActivitySearchVtBinding.inflate(getLayoutInflater()); + setContentView(binding.getRoot()); + } + + @Override + public void initView() { + binding.rvVtSearchHot.setLayoutManager(new LinearLayoutManager(this)); + adapter = new VTSearchHotListAdapter(this, ItemSearchHotVtBinding.class); + adapter.setItemClickListener((data, holder) -> { + IntentUtils.startPlayerDetails(this, data.getShort_play_id(), 0); + }); + binding.rvVtSearchHot.setAdapter(adapter); + vtSearchViewModel.getHotList(); + binding.ivBackSearch.setOnClickListener(v -> finish()); + + StaggeredGridLayoutManager staggeredGridLayoutManager = new StaggeredGridLayoutManager(4, StaggeredGridLayoutManager.VERTICAL); + binding.rvVtSearchHistory.setLayoutManager(staggeredGridLayoutManager); + historyAdapter = new VTSearchHistoryAdapter(); + binding.rvVtSearchHistory.setAdapter(historyAdapter); + historyAdapter.setOnItemClickListener((baseQuickAdapter, view, i) -> { + String name = historyAdapter.getItem(i); + binding.editHomeSearch.setText(name); + vtSearchViewModel.getSearchList(historyAdapter.getItem(i)); + }); + getHistoryData(); + binding.ivSearchHistoryDelete.setOnClickListener(v -> { + binding.editHomeSearch.setText(""); + SharePreferenceUtils.saveString(VTAppConstants.SEARCH_HISTORY, VTGsonUtils.beanToJSONString(new ArrayList())); + getHistoryData(); + }); + + binding.rvVtSearchData.setLayoutManager(new LinearLayoutManager(this)); + searchDataAdapter = new VTSearchDataAdapter(this, ItemSearchDataVtBinding.class); + searchDataAdapter.setItemClickListener((data, holder) -> { + vtSearchViewModel.setSearchClick(data.getShort_play_id()); + IntentUtils.startPlayerDetails(VTSearchActivity.this, data.getShort_play_id(), 0); + }); + binding.rvVtSearchData.setAdapter(searchDataAdapter); + binding.editHomeSearch.addTextChangedListener(new TextWatcher() { + @Override + public void beforeTextChanged(CharSequence s, int start, int count, int after) { + + } + + @Override + public void onTextChanged(CharSequence s, int start, int before, int count) { + + } + + @Override + public void afterTextChanged(Editable s) { + if (TextUtils.isEmpty(s.toString())) { + getHistoryData(); + searchDataAdapter.addDataList(null, true); + binding.layoutSearchHot.setVisibility(VISIBLE); + binding.layoutSearchHistory.setVisibility(VISIBLE); + binding.layoutSearchData.setVisibility(GONE); + hideKeyBord(binding.editHomeSearch, VTSearchActivity.this); + } + } + }); + binding.editHomeSearch.setOnEditorActionListener((v, actionId, event) -> { + if (actionId == EditorInfo.IME_ACTION_SEARCH) { + vtSearchViewModel.getSearchList(binding.editHomeSearch.getText().toString()); + hideKeyBord(binding.editHomeSearch, this); + saveSearchHistory(binding.editHomeSearch.getText().toString()); + } + return false; + }); + } + + @Override + public void logic() { + + vtSearchViewModel.getSearchHostList().observe(this, homeBottomListBeanVTResult -> { + if (homeBottomListBeanVTResult != null && homeBottomListBeanVTResult.data != null) { + adapter.addDataList(homeBottomListBeanVTResult.data.getList(), true); + binding.rvVtSearchHot.setVisibility(VISIBLE); + binding.rvVtSearchData.setVisibility(GONE); + } + }); + + vtSearchViewModel.searchDataList().observe(this, homeBottomListBeanVTResult -> { + binding.layoutSearchData.setVisibility(VISIBLE); + if (homeBottomListBeanVTResult != null && !homeBottomListBeanVTResult.data.getList().isEmpty()) { + searchDataAdapter.addDataList(homeBottomListBeanVTResult.data.getList(), true); + binding.rvVtSearchData.setVisibility(VISIBLE); + binding.layoutSearchEmpty.setVisibility(GONE); + } else { + binding.rvVtSearchData.setVisibility(GONE); + binding.layoutSearchEmpty.setVisibility(VISIBLE); + } + + binding.layoutSearchHot.setVisibility(GONE); + binding.layoutSearchHistory.setVisibility(GONE); + + }); + + + } + + + public void getHistoryData() { + String historyList = SharePreferenceUtils.getString(VTAppConstants.SEARCH_HISTORY, ""); + ArrayList arrayListHistory = VTGsonUtils.getListFromJSON(historyList, new TypeToken>() { + }.getType()); + if (arrayListHistory != null && !arrayListHistory.isEmpty()) { + binding.layoutSearchHistory.setVisibility(VISIBLE); + historyAdapter.submitList(arrayListHistory); + historyAdapter.notifyDataSetChanged(); + } else { + binding.layoutSearchHistory.setVisibility(GONE); + } + } + + public void saveSearchHistory(String content) { + String historyList = SharePreferenceUtils.getString(VTAppConstants.SEARCH_HISTORY, ""); + ArrayList arrayListHistory = VTGsonUtils.getListFromJSON(historyList, new TypeToken>() { + }.getType()); + if (arrayListHistory != null && !arrayListHistory.isEmpty()) { + for (String history : arrayListHistory) { + if (content.trim().equals(history)) { + break; + } + arrayListHistory.add(content); + } + } else { + arrayListHistory = new ArrayList<>(); + arrayListHistory.add(content); + } + + SharePreferenceUtils.saveString(VTAppConstants.SEARCH_HISTORY, VTGsonUtils.beanToJSONString(arrayListHistory)); + } +} diff --git a/app/src/main/java/com/viontv/app/ui/activity/search/VTSearchViewModel.java b/app/src/main/java/com/viontv/app/ui/activity/search/VTSearchViewModel.java new file mode 100644 index 0000000..e697782 --- /dev/null +++ b/app/src/main/java/com/viontv/app/ui/activity/search/VTSearchViewModel.java @@ -0,0 +1,90 @@ +package com.viontv.app.ui.activity.search; + +import android.util.Log; + +import androidx.lifecycle.MutableLiveData; +import androidx.lifecycle.ViewModel; + +import com.viontv.app.api.VTApi; +import com.viontv.app.api.VTBaseObserver; +import com.viontv.app.api.VTResult; +import com.viontv.app.model.VTVideoListBean; + +import io.reactivex.android.schedulers.AndroidSchedulers; +import io.reactivex.schedulers.Schedulers; + +public class VTSearchViewModel extends ViewModel { + + + private final MutableLiveData> searchHotListLiveData = new MutableLiveData<>(); + private final MutableLiveData> searchDataListLiveData = new MutableLiveData<>(); + + public MutableLiveData> getSearchHostList() { + return searchHotListLiveData; + } + + + public MutableLiveData> searchDataList() { + return searchDataListLiveData; + } + + + public void getHotList() { + VTApi.getInstance().getSearchHotList() + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe(new VTBaseObserver>() { + @Override + public void onSuccess(VTResult feedbackResp) { + searchHotListLiveData.setValue(feedbackResp); + } + + @Override + public void onError(int code, String msg) { + Log.i("tag===", msg + ""); + searchHotListLiveData.setValue(null); + } + + }); + } + + + public void getSearchList(String content) { + VTApi.getInstance().getSearchContentList(content) + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe(new VTBaseObserver>() { + @Override + public void onSuccess(VTResult feedbackResp) { + searchDataListLiveData.setValue(feedbackResp); + } + + @Override + public void onError(int code, String msg) { + Log.i("tag===", msg + ""); + searchDataListLiveData.setValue(null); + } + }); + } + + + public void setSearchClick(int shorplayId) { + VTApi.getInstance().searchClick(shorplayId) + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe(new VTBaseObserver() { + @Override + public void onSuccess(VTResult feedbackResp) { + + } + + @Override + public void onError(int code, String msg) { + Log.i("tag===", msg + ""); + } + }); + } + + + +} \ No newline at end of file diff --git a/app/src/main/java/com/viontv/app/ui/adapter/BannerHomeAdapter.java b/app/src/main/java/com/viontv/app/ui/adapter/VTBannerHomeAdapter.java similarity index 72% rename from app/src/main/java/com/viontv/app/ui/adapter/BannerHomeAdapter.java rename to app/src/main/java/com/viontv/app/ui/adapter/VTBannerHomeAdapter.java index b62fd4d..00db15f 100644 --- a/app/src/main/java/com/viontv/app/ui/adapter/BannerHomeAdapter.java +++ b/app/src/main/java/com/viontv/app/ui/adapter/VTBannerHomeAdapter.java @@ -1,28 +1,23 @@ package com.viontv.app.ui.adapter; -import android.media.Image; -import android.view.LayoutInflater; import android.view.ViewGroup; import android.widget.ImageView; import androidx.annotation.NonNull; import androidx.recyclerview.widget.RecyclerView; -import androidx.viewbinding.ViewBinding; import com.bumptech.glide.Glide; -import com.bumptech.glide.RequestBuilder; import com.bumptech.glide.load.resource.bitmap.RoundedCorners; import com.bumptech.glide.request.RequestOptions; -import com.viontv.app.databinding.ItemBannerVtBinding; import com.viontv.app.model.ItemBean; import com.youth.banner.adapter.BannerAdapter; import java.util.List; -public class BannerHomeAdapter extends BannerAdapter { +public class VTBannerHomeAdapter extends BannerAdapter { - public BannerHomeAdapter(List mData) { + public VTBannerHomeAdapter(List mData) { super(mData); } @@ -40,7 +35,11 @@ public class BannerHomeAdapter extends BannerAdapter - extends RecyclerView.Adapter> { +public class VTCommonAdapter + extends RecyclerView.Adapter> { private static final String TAG = "QChatCommonAdapter"; private static final String NAME_METHOD_INFLATE = "inflate"; protected final List dataSource = new ArrayList<>(); @@ -29,7 +29,7 @@ public class CommonAdapter protected OnClickListener clickListener; protected Method inflateMethod; - public CommonAdapter(Context context, Class viewBinding) { + public VTCommonAdapter(Context context, Class viewBinding) { this.context = context; try { inflateMethod = diff --git a/app/src/main/java/com/viontv/app/ui/adapter/VTEpisodesSeriesAdapter.java b/app/src/main/java/com/viontv/app/ui/adapter/VTEpisodesSeriesAdapter.java index 2f2fd20..c6717b3 100644 --- a/app/src/main/java/com/viontv/app/ui/adapter/VTEpisodesSeriesAdapter.java +++ b/app/src/main/java/com/viontv/app/ui/adapter/VTEpisodesSeriesAdapter.java @@ -31,7 +31,7 @@ public class VTEpisodesSeriesAdapter extends BaseQuickAdapter fragmentList; - public FragmentAdapter(@NonNull FragmentActivity fragmentActivity) { + public VTFragmentAdapter(@NonNull FragmentActivity fragmentActivity) { super(fragmentActivity); } - public FragmentAdapter(@NonNull Fragment fragment) { + public VTFragmentAdapter(@NonNull Fragment fragment) { super(fragment); } - public FragmentAdapter(@NonNull FragmentManager fragmentManager, @NonNull Lifecycle lifecycle) { + public VTFragmentAdapter(@NonNull FragmentManager fragmentManager, @NonNull Lifecycle lifecycle) { super(fragmentManager, lifecycle); } diff --git a/app/src/main/java/com/viontv/app/ui/adapter/VTGooglePlayerExploreAdapter.java b/app/src/main/java/com/viontv/app/ui/adapter/VTGooglePlayerExploreAdapter.java new file mode 100644 index 0000000..f9a88d2 --- /dev/null +++ b/app/src/main/java/com/viontv/app/ui/adapter/VTGooglePlayerExploreAdapter.java @@ -0,0 +1,78 @@ +// Copyright (c) 2022 NetEase, Inc. All rights reserved. +// Use of this source code is governed by a MIT license that can be +// found in the LICENSE file. + +package com.viontv.app.ui.adapter; + +import android.content.Context; +import android.view.ViewGroup; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.appcompat.widget.AppCompatImageView; +import androidx.media3.ui.PlayerView; + +import com.chad.library.adapter4.BaseQuickAdapter; +import com.chad.library.adapter4.viewholder.QuickViewHolder; +import com.viontv.app.R; +import com.viontv.app.model.VTVideoDetailsBean; +import com.viontv.app.model.VTVideoExploreBean; +import com.viontv.app.model.VTVideoExploreListBean; +import com.viontv.app.ui.view.VTGoogleExoPlayerView; +import com.viontv.app.ui.view.VTHomeGoogleExoPlayerView; + + +public class VTGooglePlayerExploreAdapter + extends BaseQuickAdapter { + + + public interface PlayerDetailCollection { + void collection(VTVideoExploreBean videoExploreBean); + } + + public PlayerDetailCollection playerDetailCollection; + + + public void setPlayerDetailCollection(PlayerDetailCollection playerDetailCollection) { + this.playerDetailCollection = playerDetailCollection; + } + + public int currentEpisodePlayingPosition = 0; + + + + public int getCurrentEpisodePlayingPosition() { + return currentEpisodePlayingPosition; + } + + public void setCurrentEpisodePlayingPosition(int currentEpisodePlayingPosition) { + this.currentEpisodePlayingPosition = currentEpisodePlayingPosition; + } + + + @NonNull + @Override + protected QuickViewHolder onCreateViewHolder(@NonNull Context context, @NonNull ViewGroup viewGroup, int i) { + + return new QuickViewHolder(R.layout.item_google_home_player_vt,viewGroup); + } + + @Override + protected void onBindViewHolder(@NonNull QuickViewHolder holder, int position, @Nullable VTVideoExploreBean bean) { + VTHomeGoogleExoPlayerView exampleDetailPlayerView = (VTHomeGoogleExoPlayerView) holder.getView(R.id.page_google_home_player); + PlayerView playerView = exampleDetailPlayerView.findViewById(R.id.player_view); + AppCompatImageView imageView = playerView.findViewById(R.id.iv_collection_controller); + imageView.setOnClickListener(v -> { + if (playerDetailCollection != null) { + playerDetailCollection.collection(bean); + } + }); + if (position == currentEpisodePlayingPosition) { + exampleDetailPlayerView.setMedia(bean); + } else { + exampleDetailPlayerView.stop(); + } + } + + +} diff --git a/app/src/main/java/com/viontv/app/ui/adapter/HotBottomListAdapter.java b/app/src/main/java/com/viontv/app/ui/adapter/VTHotBottomListAdapter.java similarity index 90% rename from app/src/main/java/com/viontv/app/ui/adapter/HotBottomListAdapter.java rename to app/src/main/java/com/viontv/app/ui/adapter/VTHotBottomListAdapter.java index 2b6a95b..d6be84c 100644 --- a/app/src/main/java/com/viontv/app/ui/adapter/HotBottomListAdapter.java +++ b/app/src/main/java/com/viontv/app/ui/adapter/VTHotBottomListAdapter.java @@ -11,16 +11,15 @@ import com.bumptech.glide.Glide; import com.bumptech.glide.load.engine.DiskCacheStrategy; import com.bumptech.glide.request.RequestOptions; import com.viontv.app.databinding.ItemHomeExploreVtBinding; -import com.viontv.app.databinding.ItemHotSquareVtBinding; import com.viontv.app.model.ItemBean; -public class HotBottomListAdapter - extends CommonAdapter { +public class VTHotBottomListAdapter + extends VTCommonAdapter { private Context mcontext; - public HotBottomListAdapter( + public VTHotBottomListAdapter( Context context, Class viewBinding) { super(context, viewBinding); this.mcontext = context; diff --git a/app/src/main/java/com/viontv/app/ui/adapter/NineSquareAdapter.java b/app/src/main/java/com/viontv/app/ui/adapter/VTNineSquareAdapter.java similarity index 85% rename from app/src/main/java/com/viontv/app/ui/adapter/NineSquareAdapter.java rename to app/src/main/java/com/viontv/app/ui/adapter/VTNineSquareAdapter.java index b3acd2e..08c565d 100644 --- a/app/src/main/java/com/viontv/app/ui/adapter/NineSquareAdapter.java +++ b/app/src/main/java/com/viontv/app/ui/adapter/VTNineSquareAdapter.java @@ -5,22 +5,20 @@ package com.viontv.app.ui.adapter; import android.content.Context; -import android.text.TextUtils; import com.bumptech.glide.Glide; import com.bumptech.glide.load.engine.DiskCacheStrategy; import com.bumptech.glide.request.RequestOptions; import com.viontv.app.databinding.ItemHotSquareVtBinding; import com.viontv.app.model.ItemBean; -import com.viontv.app.utils.IntentUtils; -public class NineSquareAdapter - extends CommonAdapter { +public class VTNineSquareAdapter + extends VTCommonAdapter { private Context mcontext; - public NineSquareAdapter( + public VTNineSquareAdapter( Context context, Class viewBinding) { super(context, viewBinding); this.mcontext = context; diff --git a/app/src/main/java/com/viontv/app/ui/adapter/VTSearchDataAdapter.java b/app/src/main/java/com/viontv/app/ui/adapter/VTSearchDataAdapter.java new file mode 100644 index 0000000..b1ebf02 --- /dev/null +++ b/app/src/main/java/com/viontv/app/ui/adapter/VTSearchDataAdapter.java @@ -0,0 +1,78 @@ +// Copyright (c) 2022 NetEase, Inc. All rights reserved. +// Use of this source code is governed by a MIT license that can be +// found in the LICENSE file. + +package com.viontv.app.ui.adapter; + +import android.content.Context; +import android.view.View; + +import com.bumptech.glide.Glide; +import com.bumptech.glide.load.engine.DiskCacheStrategy; +import com.bumptech.glide.request.RequestOptions; +import com.viontv.app.databinding.ItemSearchDataVtBinding; +import com.viontv.app.model.ItemBean; + + +public class VTSearchDataAdapter + extends VTCommonAdapter { + + private Context mcontext; + + private String msearchText; + + + + public String getMsearchText() { + return msearchText; + } + + public void setMsearchText(String msearchText) { + this.msearchText = msearchText; + } + + public VTSearchDataAdapter( + Context context, Class viewBinding) { + super(context, viewBinding); + this.mcontext = context; + } + + + + @Override + public void onBindViewHolder( + ItemSearchDataVtBinding binding, + int position, + ItemBean data, + int bingingAdapterPosition) { + + if (data != null) { +// ConstraintLayout.LayoutParams params = (ConstraintLayout.LayoutParams) binding.ivHotExploreItem.getLayoutParams(); +// params.dimensionRatio ="71:100"; +// binding.ivHotExploreItem.setLayoutParams(params); +// binding.ivHotExploreItem.requestLayout(); +// + Glide.with(mcontext) + .load(data.getImage_url()) + .apply(new RequestOptions().diskCacheStrategy(DiskCacheStrategy.RESOURCE)) + .into(binding.ivSearchDataItem); + binding.tvSearchDatatitleItem.setText(data.getName()); + binding.tvSearchDatadescItem.setText(data.getDescription()); + binding.tvSearchDatacategoryItem1.setVisibility(View.GONE); + binding.tvSearchDatacategoryItem1.setVisibility(View.GONE); + + if (data.getCategoryList() != null && !data.getCategoryList().isEmpty()) { + binding.tvSearchDatacategoryItem1.setVisibility(View.VISIBLE); + binding.tvSearchDatacategoryItem1.setText(data.getCategoryList().get(0).getName()); + if (data.getCategoryList().size() >= 2) { + binding.tvSearchDatacategoryItem2.setVisibility(View.VISIBLE); + binding.tvSearchDatacategoryItem2.setText(data.getCategoryList().get(1).getName()); + } + } + + + } + } + + +} diff --git a/app/src/main/java/com/viontv/app/ui/adapter/VTSearchHistoryAdapter.java b/app/src/main/java/com/viontv/app/ui/adapter/VTSearchHistoryAdapter.java new file mode 100644 index 0000000..8ebf7b7 --- /dev/null +++ b/app/src/main/java/com/viontv/app/ui/adapter/VTSearchHistoryAdapter.java @@ -0,0 +1,23 @@ +package com.viontv.app.ui.adapter; + +import com.chad.library.adapter4.BaseQuickAdapter; + +import android.content.Context; +import android.view.ViewGroup; + +import com.chad.library.adapter4.viewholder.QuickViewHolder; +import com.viontv.app.R; + +public class VTSearchHistoryAdapter extends BaseQuickAdapter { + + @Override + protected void onBindViewHolder(QuickViewHolder holder, int position, String item) { + holder.setText(R.id.tv_item_vt_search_history, item); + } + + @Override + public QuickViewHolder onCreateViewHolder(Context context, ViewGroup parent, int viewType) { + return new QuickViewHolder(R.layout.item_search_history_vt, parent); + } +} + diff --git a/app/src/main/java/com/viontv/app/ui/adapter/VTSearchHotListAdapter.java b/app/src/main/java/com/viontv/app/ui/adapter/VTSearchHotListAdapter.java new file mode 100644 index 0000000..4d6c5b6 --- /dev/null +++ b/app/src/main/java/com/viontv/app/ui/adapter/VTSearchHotListAdapter.java @@ -0,0 +1,75 @@ +// Copyright (c) 2022 NetEase, Inc. All rights reserved. +// Use of this source code is governed by a MIT license that can be +// found in the LICENSE file. + +package com.viontv.app.ui.adapter; + +import android.content.Context; +import android.view.View; + +import com.bumptech.glide.Glide; +import com.bumptech.glide.load.engine.DiskCacheStrategy; +import com.bumptech.glide.request.RequestOptions; +import com.viontv.app.R; +import com.viontv.app.databinding.ItemSearchHotVtBinding; +import com.viontv.app.model.ItemBean; +import com.viontv.app.utils.TimeUtils; + + +public class VTSearchHotListAdapter + extends VTCommonAdapter { + + private Context mcontext; + + public VTSearchHotListAdapter( + Context context, Class viewBinding) { + super(context, viewBinding); + this.mcontext = context; + } + + + @Override + public void onBindViewHolder( + ItemSearchHotVtBinding binding, + int position, + ItemBean data, + int bingingAdapterPosition) { + + if (data != null) { +// ConstraintLayout.LayoutParams params = (ConstraintLayout.LayoutParams) binding.ivHotExploreItem.getLayoutParams(); +// params.dimensionRatio ="71:100"; +// binding.ivHotExploreItem.setLayoutParams(params); +// binding.ivHotExploreItem.requestLayout(); +// + Glide.with(mcontext) + .load(data.getImage_url()) + .apply(new RequestOptions().diskCacheStrategy(DiskCacheStrategy.RESOURCE)) + .into(binding.ivHotSearchItem); + binding.tvSearchHottitleItem.setText(data.getName()); + binding.tvSearchHottotalItem.setText(TimeUtils.formatNumber(data.getWatch_total())); + binding.tvHotTopnumber.setVisibility(View.GONE); + if (bingingAdapterPosition < 10) { + binding.tvHotTopnumber.setVisibility(View.VISIBLE); + binding.tvHotTopnumber.setText(String.valueOf(bingingAdapterPosition + 1)); + binding.tvHotTopnumber.setBackgroundResource(R.drawable.bg_search_hot_top4_gradient); + if(bingingAdapterPosition==0){ + binding.tvHotTopnumber.setBackgroundResource(R.drawable.bg_search_hot_top1_gradient); + } + if(bingingAdapterPosition==1){ + binding.tvHotTopnumber.setBackgroundResource(R.drawable.bg_search_hot_top2_gradient); + } + if(bingingAdapterPosition==2){ + binding.tvHotTopnumber.setBackgroundResource(R.drawable.bg_search_hot_top3_gradient); + } + } + if (data.getCategory() != null && !data.getCategory().isEmpty()) { + binding.tvSearchHottagItem.setVisibility(View.VISIBLE); + binding.tvSearchHottagItem.setText(data.getCategory().get(0)); + } + + + } + } + + +} diff --git a/app/src/main/java/com/viontv/app/ui/adapter/TabItemListAdapter.java b/app/src/main/java/com/viontv/app/ui/adapter/VTTabItemListAdapter.java similarity index 78% rename from app/src/main/java/com/viontv/app/ui/adapter/TabItemListAdapter.java rename to app/src/main/java/com/viontv/app/ui/adapter/VTTabItemListAdapter.java index 9a470e2..a0a80a4 100644 --- a/app/src/main/java/com/viontv/app/ui/adapter/TabItemListAdapter.java +++ b/app/src/main/java/com/viontv/app/ui/adapter/VTTabItemListAdapter.java @@ -5,23 +5,20 @@ package com.viontv.app.ui.adapter; import android.content.Context; -import android.view.View; import com.bumptech.glide.Glide; import com.bumptech.glide.load.engine.DiskCacheStrategy; import com.bumptech.glide.request.RequestOptions; -import com.viontv.app.R; -import com.viontv.app.databinding.ItemHomeExploreVtBinding; import com.viontv.app.databinding.ItemHomeTablistVtBinding; import com.viontv.app.model.ItemBean; -public class TabItemListAdapter - extends CommonAdapter { +public class VTTabItemListAdapter + extends VTCommonAdapter { private Context mcontext; - public TabItemListAdapter( + public VTTabItemListAdapter( Context context, Class viewBinding) { super(context, viewBinding); this.mcontext = context; @@ -35,8 +32,12 @@ public class TabItemListAdapter int bingingAdapterPosition) { if (data != null) { + String imageUrl = data.getHorizontally_img(); + if (!imageUrl.endsWith(".jpg")) { + imageUrl = data.getImage_url(); + } Glide.with(mcontext) - .load(data.getHorizontally_img()) + .load(imageUrl) .apply(new RequestOptions().diskCacheStrategy(DiskCacheStrategy.RESOURCE)) .into(binding.ivHometabItem); binding.tvHometabTitleItem.setText(data.getName()); diff --git a/app/src/main/java/com/viontv/app/ui/adapter/Top10ListAdapter.java b/app/src/main/java/com/viontv/app/ui/adapter/VTTop10ListAdapter.java similarity index 92% rename from app/src/main/java/com/viontv/app/ui/adapter/Top10ListAdapter.java rename to app/src/main/java/com/viontv/app/ui/adapter/VTTop10ListAdapter.java index f2ba069..9bcebda 100644 --- a/app/src/main/java/com/viontv/app/ui/adapter/Top10ListAdapter.java +++ b/app/src/main/java/com/viontv/app/ui/adapter/VTTop10ListAdapter.java @@ -4,12 +4,9 @@ package com.viontv.app.ui.adapter; -import android.annotation.SuppressLint; import android.content.Context; import android.view.View; -import androidx.constraintlayout.widget.ConstraintLayout; - import com.bumptech.glide.Glide; import com.bumptech.glide.load.engine.DiskCacheStrategy; import com.bumptech.glide.request.RequestOptions; @@ -18,12 +15,12 @@ import com.viontv.app.model.ItemBean; import com.viontv.app.utils.TimeUtils; -public class Top10ListAdapter - extends CommonAdapter { +public class VTTop10ListAdapter + extends VTCommonAdapter { private Context mcontext; - public Top10ListAdapter( + public VTTop10ListAdapter( Context context, Class viewBinding) { super(context, viewBinding); this.mcontext = context; diff --git a/app/src/main/java/com/viontv/app/ui/adapter/VTUserVideoHistoryAdapter.java b/app/src/main/java/com/viontv/app/ui/adapter/VTUserVideoHistoryAdapter.java new file mode 100644 index 0000000..f57e4aa --- /dev/null +++ b/app/src/main/java/com/viontv/app/ui/adapter/VTUserVideoHistoryAdapter.java @@ -0,0 +1,54 @@ +// Copyright (c) 2022 NetEase, Inc. All rights reserved. +// Use of this source code is governed by a MIT license that can be +// found in the LICENSE file. + +package com.viontv.app.ui.adapter; + +import android.content.Context; +import android.view.View; + +import com.bumptech.glide.Glide; +import com.bumptech.glide.load.engine.DiskCacheStrategy; +import com.bumptech.glide.request.RequestOptions; +import com.viontv.app.databinding.ItemHomeExploreVtBinding; +import com.viontv.app.databinding.ItemVideoHistoryBinding; +import com.viontv.app.model.ItemBean; +import com.viontv.app.utils.TimeUtils; + + +public class VTUserVideoHistoryAdapter + extends VTCommonAdapter { + + private Context mcontext; + + public VTUserVideoHistoryAdapter( + Context context, Class viewBinding) { + super(context, viewBinding); + this.mcontext = context; + } + + + @Override + public void onBindViewHolder( + ItemVideoHistoryBinding binding, + int position, + ItemBean data, + int bingingAdapterPosition) { + + if (data != null) { +// ConstraintLayout.LayoutParams params = (ConstraintLayout.LayoutParams) binding.ivHotExploreItem.getLayoutParams(); +// params.dimensionRatio ="71:100"; +// binding.ivHotExploreItem.setLayoutParams(params); +// binding.ivHotExploreItem.requestLayout(); +// + Glide.with(mcontext) + .load(data.getImage_url()) + .apply(new RequestOptions().diskCacheStrategy(DiskCacheStrategy.RESOURCE)) + .into(binding.ivHistoryItem); + + + } + } + + +} diff --git a/app/src/main/java/com/viontv/app/ui/view/VTGoogleExoPlayerView.java b/app/src/main/java/com/viontv/app/ui/view/VTGoogleExoPlayerView.java index 16ce72a..c3e1453 100644 --- a/app/src/main/java/com/viontv/app/ui/view/VTGoogleExoPlayerView.java +++ b/app/src/main/java/com/viontv/app/ui/view/VTGoogleExoPlayerView.java @@ -22,6 +22,7 @@ import com.bumptech.glide.Glide; import com.viontv.app.R; import com.viontv.app.databinding.LayoutVideoplayVtBinding; import com.viontv.app.model.VTVideoDetailsBean; +import com.viontv.app.utils.TimeUtils; import com.viontv.app.utils.ToastUtils; import com.viontv.app.utils.TranslatesUtils; import com.viontv.app.utils.VTAppConstants; @@ -224,8 +225,8 @@ public class VTGoogleExoPlayerView extends FrameLayout { tv_des_player.setText(shortVideoInfo.getDescription()); Glide.with(getContext()).load(shortVideoInfo.getImage_url()).into(ivCoverPlayerDetail); ivCoverPlayerDetail.setVisibility(View.VISIBLE); - // iv_collection_controller.setImageResource(shortVideoInfo.isIs_collect() ? R.drawable.iv_hibit_like_h : R.drawable.iv_hibit_like_n); - // tv_collection_num_controller.setText(Timestamp.formatNumber(shortVideoInfo.getCollect_total())); + iv_collection_controller.setImageResource(shortVideoInfo.isIs_collect() ? R.mipmap.iv_vt_collect_h : R.mipmap.iv_vt_collect_n); + tv_collection_num_controller.setText(TimeUtils.formatNumber(shortVideoInfo.getCollect_total())); rl_ep.setOnClickListener(v -> EventBus.getDefault().post(VTAppConstants.Constants_PlayerView_MoreItemEvent) ); diff --git a/app/src/main/java/com/viontv/app/ui/view/VTHomeGoogleExoPlayerView.java b/app/src/main/java/com/viontv/app/ui/view/VTHomeGoogleExoPlayerView.java new file mode 100644 index 0000000..ab36673 --- /dev/null +++ b/app/src/main/java/com/viontv/app/ui/view/VTHomeGoogleExoPlayerView.java @@ -0,0 +1,262 @@ +package com.viontv.app.ui.view; + +import android.content.Context; +import android.net.Uri; +import android.util.AttributeSet; +import android.view.LayoutInflater; +import android.view.View; +import android.widget.FrameLayout; +import android.widget.LinearLayout; +import android.widget.RelativeLayout; +import android.widget.SeekBar; + +import androidx.appcompat.widget.AppCompatImageView; +import androidx.appcompat.widget.AppCompatSeekBar; +import androidx.appcompat.widget.AppCompatTextView; +import androidx.cardview.widget.CardView; +import androidx.media3.common.C; +import androidx.media3.common.MediaItem; +import androidx.media3.common.PlaybackException; +import androidx.media3.common.Player; +import androidx.media3.exoplayer.ExoPlayer; + +import com.bumptech.glide.Glide; +import com.viontv.app.R; +import com.viontv.app.VTApplication; +import com.viontv.app.databinding.LayoutVideoplayHomeVtBinding; +import com.viontv.app.databinding.LayoutVideoplayVtBinding; +import com.viontv.app.model.VTVideoDetailsBean; +import com.viontv.app.model.VTVideoExploreBean; +import com.viontv.app.utils.TimeUtils; +import com.viontv.app.utils.ToastUtils; +import com.viontv.app.utils.TranslatesUtils; +import com.viontv.app.utils.VTAppConstants; + +import org.greenrobot.eventbus.EventBus; + +import java.util.concurrent.Executors; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.ScheduledFuture; +import java.util.concurrent.TimeUnit; + +public class VTHomeGoogleExoPlayerView extends FrameLayout { + private ExoPlayer player; + // private Job progressJob; //任务调度器 + private ScheduledFuture progressJob; + + private boolean isDragging = false; + private AppCompatSeekBar seekBar; + private AppCompatImageView ivCoverPlayerDetail; + private AppCompatImageView ivPagePlay; + private AppCompatImageView iv_collection_controller; + + private AppCompatTextView tv_des_player; + private AppCompatImageView ivPlayerSeries; + private AppCompatImageView ivSearch; + + private AppCompatTextView tv_title_player; + private AppCompatTextView tv_collection_num_controller; + private AppCompatTextView tv_title_hibit_episode; + private ProgressLineView load_line; + private LinearLayout ll_ep; + + private CardView cardPlayer; + private boolean isEpisodePlaying = false; + + public VTHomeGoogleExoPlayerView(Context context, AttributeSet attrs) { + super(context, attrs); + player = new ExoPlayer.Builder(context).build(); + LayoutInflater inflater = LayoutInflater.from(context); + View inflate = inflater.inflate(R.layout.layout_videoplay_home_vt, this, true); + LayoutVideoplayHomeVtBinding bind = LayoutVideoplayHomeVtBinding.bind(inflate); + bind.playerView.setPlayer(player); + seekBar = bind.playerView.findViewById(R.id.seekBar_player_detail); + ivCoverPlayerDetail = bind.playerView.findViewById(R.id.iv_cover_player_detail); + ivPagePlay = bind.playerView.findViewById(R.id.iv_play_status); + iv_collection_controller = bind.playerView.findViewById(R.id.iv_collection_controller); + tv_collection_num_controller = bind.playerView.findViewById(R.id.tv_collection_num_controller); + tv_des_player = bind.playerView.findViewById(R.id.tv_des_player); //描述 + //跳转选集 + ivPlayerSeries = bind.playerView.findViewById(R.id.iv_homeplayer_video); //选集图片 + tv_title_player = bind.playerView.findViewById(R.id.tv_name_episode); + load_line = bind.playerView.findViewById(R.id.load_line); + cardPlayer = bind.playerView.findViewById(R.id.cardview_homeplayer_video); + ll_ep = bind.playerView.findViewById(R.id.ll_ep); + ivSearch = bind.playerView.findViewById(R.id.iv_search_home_videoplay); + + + player.addListener(new Player.Listener() { + @Override + public void onPlaybackStateChanged(int playbackState) { + Player.Listener.super.onPlaybackStateChanged(playbackState); + switch (playbackState) { + case Player.STATE_BUFFERING: + load_line.setVisibility(VISIBLE); + load_line.startAnimation(); + break; + case Player.STATE_READY: + bind.playerView.setEnabled(true); + if (VTApplication.isCurrentPage) { + start(); + setProgress(); + } + ivCoverPlayerDetail.setVisibility(View.INVISIBLE); + load_line.endAnimation(); + load_line.setVisibility(INVISIBLE); + break; + case Player.STATE_ENDED: + EventBus.getDefault().post(VTAppConstants.Constants_Google_PLAYER_STATUS_FINISH); + break; + case Player.STATE_IDLE: + bind.playerView.setEnabled(false); + break; + } + } + + @Override + public void onPlayerError(PlaybackException error) { + Player.Listener.super.onPlayerError(error); + ivCoverPlayerDetail.setVisibility(View.INVISIBLE); + load_line.setVisibility(INVISIBLE); + if (TranslatesUtils.translates() != null) { + ToastUtils.revealToast(TranslatesUtils.translates().getNetwork_error(), 0); + } else { + ToastUtils.revealToast(context.getString(R.string.vt_network_error_please_check_the_network), 0); + } + } + }); + + bind.playerView.setOnClickListener(v -> { + if (!VTAppConstants.isLock) { + if (isEpisodePlaying) { + ivPagePlay.setImageResource(R.mipmap.iv_play_vt); + suspend(); + } else { + ivPagePlay.setImageResource(R.mipmap.iv_stop_vt); + start(); + } + } + }); + } + + private void setProgress() { + if (progressJob != null) { + progressJob.cancel(true); + } + ScheduledExecutorService executor = Executors.newScheduledThreadPool(1); + progressJob = executor.scheduleWithFixedDelay(() -> { + if (!isDragging) { + long duration = player.getDuration(); + long position = player.getCurrentPosition(); + int progress = (int) (position * 100 / (duration == C.TIME_UNSET ? 1 : duration)); + if (seekBar != null) { + seekBar.setMax(100); + seekBar.setProgress(progress + 1); + } + } + }, 0, 1, TimeUnit.SECONDS); +// if (progressJob != null) { +// progressJob.cancel(null); +// } +// progressJob = launchKt.launch(Dispatchers.getMain(), null, null, coroutineScope -> { +// while (isActive(coroutineScope)) { +// if (!isDragging.get()) { +// long duration = player.getDuration(); +// long position = player.getCurrentPosition(); +// int progress = (int) (position * 100 / (duration == C.TIME_UNSET ? 1 : duration)); +// seekBar.setMax(100); +// seekBar.setProgress(progress + 1); +// } +// delayKt.delay(1000); +// } +// return null; +// }); + + seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { + @Override + public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { + if (fromUser) { + seekTo(progress); + } + } + + @Override + public void onStartTrackingTouch(SeekBar seekBar) { + isDragging = true; + } + + @Override + public void onStopTrackingTouch(SeekBar seekBar) { + isDragging = false; + } + }); + } + + public void start() { + player.play(); + ivPagePlay.setImageResource(R.mipmap.iv_stop_vt); + isEpisodePlaying = true; + isDragging = false; + } + + public void suspend() { + player.pause(); + ivPagePlay.setImageResource(R.mipmap.iv_play_vt); + isEpisodePlaying = false; + isDragging = true; + } + + public void seekTo(int progress) { + long duration = player.getDuration(); + player.seekTo(duration * progress / 100); + } + + public void setMedia(VTVideoExploreBean bean) { + VTAppConstants.isCanPlay = true; + tv_title_player.setText(bean.getName()); + +// if (TranslatesUtils.translates() != null) { +// tv_title_hibit_episode.setText(TranslatesUtils.replace( +// TranslatesUtils.translates().getEpisode_set(), +// String.valueOf(bean.getEpisode()) +// )); +// tv_episode_name.setText(TranslatesUtils.replace( +// TranslatesUtils.translates().getComplete_episode(), +// String.valueOf(shortVideoInfo.getEpisode_total()) +// )); +// } else { +// tv_title_hibit_episode.setText("Episode ".concat(String.valueOf(bean.getEpisode()))); +// tv_episode_name.setText("Complete set : ".concat(String.valueOf(shortVideoInfo.getEpisode_total()))); +// } + tv_des_player.setText(bean.getDescription()); + Glide.with(getContext()).load(bean.getImage_url()).into(ivCoverPlayerDetail); + Glide.with(getContext()).load(bean.getImage_url()).into(ivPlayerSeries); + ivCoverPlayerDetail.setVisibility(View.VISIBLE); + iv_collection_controller.setImageResource(bean.isIs_collect() ? R.mipmap.iv_vt_collect_h : R.mipmap.iv_vt_collect_n); + tv_collection_num_controller.setText(TimeUtils.formatNumber(bean.getCollect_total())); + ll_ep.setOnClickListener(v -> + EventBus.getDefault().post(VTAppConstants.Constants_PlayerView_DetialsEvent) + ); + cardPlayer.setOnClickListener(v -> { + EventBus.getDefault().post(VTAppConstants.Constants_PlayerView_DetialsEvent); + }); + ivSearch.setOnClickListener(v -> { + EventBus.getDefault().post(VTAppConstants.Constants_PlayerView_SearchEvent); + }); + + player.setMediaItem(MediaItem.fromUri(Uri.parse(bean.getVideo_info().getVideo_url()))); + player.prepare(); + } + + public void stop() { + player.stop(); + if (progressJob != null) { + progressJob.cancel(true); + progressJob = null; + } + } + + public void release() { + player.release(); + } +} \ No newline at end of file diff --git a/app/src/main/java/com/viontv/app/utils/IntentUtils.java b/app/src/main/java/com/viontv/app/utils/IntentUtils.java index d506959..089dea1 100644 --- a/app/src/main/java/com/viontv/app/utils/IntentUtils.java +++ b/app/src/main/java/com/viontv/app/utils/IntentUtils.java @@ -1,10 +1,12 @@ package com.viontv.app.utils; import android.app.Activity; +import android.content.Context; import android.content.Intent; import com.viontv.app.VTApplication; import com.viontv.app.ui.activity.play.VTVideoPlayerActivity; +import com.viontv.app.ui.activity.search.VTSearchActivity; public class IntentUtils { @@ -15,4 +17,9 @@ public class IntentUtils { intent.putExtra(VTAppConstants.Constants_Page_video_id,video_id); currentActivity.startActivity(intent); } + + public static void startSearch(Context context){ + Intent intent = new Intent(context, VTSearchActivity.class); + context.startActivity(intent); + } } diff --git a/app/src/main/java/com/viontv/app/utils/VTAppConstants.java b/app/src/main/java/com/viontv/app/utils/VTAppConstants.java index 50934cb..fc21ec5 100644 --- a/app/src/main/java/com/viontv/app/utils/VTAppConstants.java +++ b/app/src/main/java/com/viontv/app/utils/VTAppConstants.java @@ -11,10 +11,19 @@ public class VTAppConstants { public static final String Constants_HTTP_TOKEN = "Authorization"; public static final String Constants_Page_DetailId = "constants_page_detail_id"; public static final String Constants_Page_video_id = "Constants_Page_video_id"; + public static final String Constants_Page_WebUrl = "Constants_Page_WebUrl"; + public static final String Constants_Page_WebTitle = "Constants_Page_WebTitle"; public static final String Constants_Page_Episodes_Series_Data_VT = "constants_page_episodes_series_data"; public static final String Constants_Page_Episodes_Series_Data_List = "Constants_Page_Episodes_Series_Data_List"; public static final String Constants_PlayerView_MoreItemEvent = "Constants_PlayerView_MoreItem"; + public static final String Constants_PlayerView_DetialsEvent = + "Constants_PlayerView_Details"; + public static final String Constants_PlayerView_SearchEvent = + "Constants_PlayerView_SearchEvent"; + + public static final String Constants_PlayerView_CreateHistoryEvent = + "Constants_PlayerView_CreateHistoryEvent"; public static final String Constants_RecommendPlayerView_CLOSEExample = "Constants_RecommendPlayerView_CLOSEExample"; public static final String Constants_Page_Episodes_Series_Data_currentPosition = @@ -22,32 +31,12 @@ public class VTAppConstants { public static final String Constants_Google_PLAYER_STATUS_FINISH = "constants_google_player_status_finish"; public static final String Constants_Google_PLAYER_STATUS_FINISH_DETAIL = "constants_google_player_status_finish_detail"; - public static final String CONSTANTS_refresh_auth = "CONSTANTS_refresh_auth"; - public static final String CONSTANTS_out_login = "CONSTANTS_out_login"; - public static final String CONSTANTS_user_refresh = "CONSTANTS_user_refresh"; - public static final String LogEvent_af_app_recharge = "af_app_recharge"; - public static final String CONSTANTS_AppsFlyer = "axv4xFtouhau4js4GxqBX9"; public static final String Constants_Episodes_Series_DataExample = "Constants_Episodes_Series_DataExample"; - public static final String Constants_Episodes_Series_DataFavorites = "Constants_Episodes_Series_DataFavorites"; - public static final String CONSTANTS_GOOGLE_LOGIN = - "996139080527-njj3ehigooauk800e0o6hm785jofi2l5.apps.googleusercontent.com"; - public static final String CONSTANTS_device_id = "device-id"; - public static final String CONSTANTS_system_type = "system-type"; - public static final String CONSTANTS_model = "model"; - public static final String CONSTANTS_app_version = "app-version"; - public static final String CONSTANTS_app_name = "app-name"; - public static final String CONSTANTS_lang_key = "lang-key"; - public static final String CONSTANTS_time_zone = "time-zone"; - public static final String CONSTANTS_SEARCH_STRINGExample = "CONSTANTS_SEARCH_STRINGExample"; - public static final String CONSTANTS_User_STRING = "CONSTANTS_User_STRING"; - public static final int requestCodeByGoogleLogin = 666; + public static boolean isCanPlay = true; public static boolean isLock = false; - public static final String Constants_member_ship_agreement = - "https://www.hibitplay.com/member_ship_agreement_android.html"; - public static final String Constants_user_agreement = "https://www.hibitplay.com/user_policy_android.html"; - public static final String Constants_privacy_policy = "https://www.hibitplay.com/private_android.html"; - public static final String Constants_Web_Url = "Constants_Web_Url"; - public static final String CLIENT_KEY = "awp5nm8lwpyebwgv"; - public static final String REDIRECT_URL = "hibitapp://oauthresponse"; + + public static final String SEARCH_HISTORY = "searchhistory"; + + } diff --git a/app/src/main/res/drawable/bg_circle_headdefault_vt.xml b/app/src/main/res/drawable/bg_circle_headdefault_vt.xml new file mode 100644 index 0000000..5ab6b27 --- /dev/null +++ b/app/src/main/res/drawable/bg_circle_headdefault_vt.xml @@ -0,0 +1,8 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_home_series_gradient.xml b/app/src/main/res/drawable/bg_home_series_gradient.xml new file mode 100644 index 0000000..01d24e5 --- /dev/null +++ b/app/src/main/res/drawable/bg_home_series_gradient.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + diff --git a/app/src/main/res/drawable/bg_search_hot_gradient.xml b/app/src/main/res/drawable/bg_search_hot_gradient.xml new file mode 100644 index 0000000..a76522d --- /dev/null +++ b/app/src/main/res/drawable/bg_search_hot_gradient.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + diff --git a/app/src/main/res/drawable/bg_search_hot_top1_gradient.xml b/app/src/main/res/drawable/bg_search_hot_top1_gradient.xml new file mode 100644 index 0000000..c3b1094 --- /dev/null +++ b/app/src/main/res/drawable/bg_search_hot_top1_gradient.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + diff --git a/app/src/main/res/drawable/bg_search_hot_top2_gradient.xml b/app/src/main/res/drawable/bg_search_hot_top2_gradient.xml new file mode 100644 index 0000000..0d0589a --- /dev/null +++ b/app/src/main/res/drawable/bg_search_hot_top2_gradient.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + diff --git a/app/src/main/res/drawable/bg_search_hot_top3_gradient.xml b/app/src/main/res/drawable/bg_search_hot_top3_gradient.xml new file mode 100644 index 0000000..4320650 --- /dev/null +++ b/app/src/main/res/drawable/bg_search_hot_top3_gradient.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + diff --git a/app/src/main/res/drawable/bg_search_hot_top4_gradient.xml b/app/src/main/res/drawable/bg_search_hot_top4_gradient.xml new file mode 100644 index 0000000..5b4cde3 --- /dev/null +++ b/app/src/main/res/drawable/bg_search_hot_top4_gradient.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + diff --git a/app/src/main/res/drawable/bg_vt_episodes_home.xml b/app/src/main/res/drawable/bg_vt_episodes_home.xml new file mode 100644 index 0000000..109a4e2 --- /dev/null +++ b/app/src/main/res/drawable/bg_vt_episodes_home.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + diff --git a/app/src/main/res/drawable/cornor_1affffff_12dp.xml b/app/src/main/res/drawable/cornor_1affffff_12dp.xml new file mode 100644 index 0000000..f2f82c5 --- /dev/null +++ b/app/src/main/res/drawable/cornor_1affffff_12dp.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + diff --git a/app/src/main/res/layout/activity_search_vt.xml b/app/src/main/res/layout/activity_search_vt.xml new file mode 100644 index 0000000..a457e37 --- /dev/null +++ b/app/src/main/res/layout/activity_search_vt.xml @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_video_details_vt.xml b/app/src/main/res/layout/activity_video_details_vt.xml index 043e389..7e80c82 100644 --- a/app/src/main/res/layout/activity_video_details_vt.xml +++ b/app/src/main/res/layout/activity_video_details_vt.xml @@ -7,7 +7,7 @@ diff --git a/app/src/main/res/layout/activity_webview.xml b/app/src/main/res/layout/activity_webview.xml new file mode 100644 index 0000000..b3be0dd --- /dev/null +++ b/app/src/main/res/layout/activity_webview.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_explore_vt.xml b/app/src/main/res/layout/fragment_explore_vt.xml new file mode 100644 index 0000000..cdd623d --- /dev/null +++ b/app/src/main/res/layout/fragment_explore_vt.xml @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_hot_vt.xml b/app/src/main/res/layout/fragment_hot_vt.xml index 2049782..a91412c 100644 --- a/app/src/main/res/layout/fragment_hot_vt.xml +++ b/app/src/main/res/layout/fragment_hot_vt.xml @@ -1,22 +1,14 @@ - + android:layout_height="match_parent"> - - - - - - - - - - + + - - \ No newline at end of file + + + + + diff --git a/app/src/main/res/layout/fragment_main_vt.xml b/app/src/main/res/layout/fragment_main_vt.xml index 49c69b3..b3bd0df 100644 --- a/app/src/main/res/layout/fragment_main_vt.xml +++ b/app/src/main/res/layout/fragment_main_vt.xml @@ -28,9 +28,9 @@ android:textColorHint="#38ffffff" android:gravity="center_vertical" android:drawablePadding="@dimen/dp_7" - android:drawableStart="@mipmap/iv_homefragment_search" android:textColor="#38ffffff" - android:textSize="@dimen/sp_12" /> + android:textSize="@dimen/sp_12" + app:drawableStartCompat="@mipmap/iv_homefragment_search" /> diff --git a/app/src/main/res/layout/fragment_me.xml b/app/src/main/res/layout/fragment_me.xml new file mode 100644 index 0000000..40982d3 --- /dev/null +++ b/app/src/main/res/layout/fragment_me.xml @@ -0,0 +1,138 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/item_google_home_player_vt.xml b/app/src/main/res/layout/item_google_home_player_vt.xml new file mode 100644 index 0000000..d9aa8cc --- /dev/null +++ b/app/src/main/res/layout/item_google_home_player_vt.xml @@ -0,0 +1,7 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/item_home_explore_vt.xml b/app/src/main/res/layout/item_home_explore_vt.xml index ce37ae0..6e7ef9f 100644 --- a/app/src/main/res/layout/item_home_explore_vt.xml +++ b/app/src/main/res/layout/item_home_explore_vt.xml @@ -25,6 +25,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:scaleType="fitXY" + android:minHeight="@dimen/dp_100" app:layout_constraintDimensionRatio="82:110" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" /> diff --git a/app/src/main/res/layout/item_page_episodes_series_vt.xml b/app/src/main/res/layout/item_page_episodes_series_vt.xml index f5b62d2..66783bd 100644 --- a/app/src/main/res/layout/item_page_episodes_series_vt.xml +++ b/app/src/main/res/layout/item_page_episodes_series_vt.xml @@ -33,6 +33,7 @@ android:layout_alignParentRight="true" android:layout_marginTop="5dp" android:layout_marginRight="5dp" + android:visibility="gone" android:src="@mipmap/iv_lock" /> diff --git a/app/src/main/res/layout/item_search_data_vt.xml b/app/src/main/res/layout/item_search_data_vt.xml new file mode 100644 index 0000000..8909fde --- /dev/null +++ b/app/src/main/res/layout/item_search_data_vt.xml @@ -0,0 +1,88 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/item_search_history_vt.xml b/app/src/main/res/layout/item_search_history_vt.xml new file mode 100644 index 0000000..29a23c8 --- /dev/null +++ b/app/src/main/res/layout/item_search_history_vt.xml @@ -0,0 +1,13 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/item_search_hot_vt.xml b/app/src/main/res/layout/item_search_hot_vt.xml new file mode 100644 index 0000000..3ae5041 --- /dev/null +++ b/app/src/main/res/layout/item_search_hot_vt.xml @@ -0,0 +1,103 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/item_video_history.xml b/app/src/main/res/layout/item_video_history.xml new file mode 100644 index 0000000..d7a1924 --- /dev/null +++ b/app/src/main/res/layout/item_video_history.xml @@ -0,0 +1,15 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/layout_player_controller_vt.xml b/app/src/main/res/layout/layout_player_controller_vt.xml index 5271de9..43c166c 100644 --- a/app/src/main/res/layout/layout_player_controller_vt.xml +++ b/app/src/main/res/layout/layout_player_controller_vt.xml @@ -17,7 +17,7 @@ android:layout_height="24dp" android:layout_marginLeft="15dp" android:layout_marginTop="55dp" - android:src="@mipmap/iv_play_vt_episode_left" /> + android:src="@mipmap/ic_play_vt_episode_left" /> + android:src="@mipmap/ic_arrowright_vt_episode" /> @@ -123,7 +123,6 @@ android:layout_marginRight="16dp" android:layout_marginBottom="26dp" android:gravity="center" - android:visibility="gone" android:orientation="vertical"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/layout_videoplay_home_vt.xml b/app/src/main/res/layout/layout_videoplay_home_vt.xml new file mode 100644 index 0000000..03f1cdb --- /dev/null +++ b/app/src/main/res/layout/layout_videoplay_home_vt.xml @@ -0,0 +1,13 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-xxhdpi/iv_arrowright_vt_episode.webp b/app/src/main/res/mipmap-xxhdpi/ic_arrowright_vt_episode.webp similarity index 100% rename from app/src/main/res/mipmap-xxhdpi/iv_arrowright_vt_episode.webp rename to app/src/main/res/mipmap-xxhdpi/ic_arrowright_vt_episode.webp diff --git a/app/src/main/res/mipmap-xxhdpi/ic_default_head.png b/app/src/main/res/mipmap-xxhdpi/ic_default_head.png new file mode 100644 index 0000000..3c7d524 Binary files /dev/null and b/app/src/main/res/mipmap-xxhdpi/ic_default_head.png differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_enter.png b/app/src/main/res/mipmap-xxhdpi/ic_enter.png new file mode 100644 index 0000000..da3ab53 Binary files /dev/null and b/app/src/main/res/mipmap-xxhdpi/ic_enter.png differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_history_delete.png b/app/src/main/res/mipmap-xxhdpi/ic_history_delete.png new file mode 100644 index 0000000..61d62ed Binary files /dev/null and b/app/src/main/res/mipmap-xxhdpi/ic_history_delete.png differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_hot_search.png b/app/src/main/res/mipmap-xxhdpi/ic_hot_search.png new file mode 100644 index 0000000..668c83c Binary files /dev/null and b/app/src/main/res/mipmap-xxhdpi/ic_hot_search.png differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_me_about_us.png b/app/src/main/res/mipmap-xxhdpi/ic_me_about_us.png new file mode 100644 index 0000000..ac8691f Binary files /dev/null and b/app/src/main/res/mipmap-xxhdpi/ic_me_about_us.png differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_me_private_policy.png b/app/src/main/res/mipmap-xxhdpi/ic_me_private_policy.png new file mode 100644 index 0000000..74cee1a Binary files /dev/null and b/app/src/main/res/mipmap-xxhdpi/ic_me_private_policy.png differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_me_user_agreement.png b/app/src/main/res/mipmap-xxhdpi/ic_me_user_agreement.png new file mode 100644 index 0000000..c279e36 Binary files /dev/null and b/app/src/main/res/mipmap-xxhdpi/ic_me_user_agreement.png differ diff --git a/app/src/main/res/mipmap-xxhdpi/iv_play_vt_episode_left.png b/app/src/main/res/mipmap-xxhdpi/ic_play_vt_episode_left.png similarity index 100% rename from app/src/main/res/mipmap-xxhdpi/iv_play_vt_episode_left.png rename to app/src/main/res/mipmap-xxhdpi/ic_play_vt_episode_left.png diff --git a/app/src/main/res/mipmap-xxhdpi/ic_playlist.png b/app/src/main/res/mipmap-xxhdpi/ic_playlist.png new file mode 100644 index 0000000..394b07e Binary files /dev/null and b/app/src/main/res/mipmap-xxhdpi/ic_playlist.png differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_search_empty.png b/app/src/main/res/mipmap-xxhdpi/ic_search_empty.png new file mode 100644 index 0000000..e48ea42 Binary files /dev/null and b/app/src/main/res/mipmap-xxhdpi/ic_search_empty.png differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_search_history.png b/app/src/main/res/mipmap-xxhdpi/ic_search_history.png new file mode 100644 index 0000000..18ed56a Binary files /dev/null and b/app/src/main/res/mipmap-xxhdpi/ic_search_history.png differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_series_play.png b/app/src/main/res/mipmap-xxhdpi/ic_series_play.png new file mode 100644 index 0000000..0a7e991 Binary files /dev/null and b/app/src/main/res/mipmap-xxhdpi/ic_series_play.png differ diff --git a/app/src/main/res/mipmap-xxhdpi/iv_vt_collect_h.png b/app/src/main/res/mipmap-xxhdpi/iv_vt_collect_h.png index 00b67cb..835c0e9 100644 Binary files a/app/src/main/res/mipmap-xxhdpi/iv_vt_collect_h.png and b/app/src/main/res/mipmap-xxhdpi/iv_vt_collect_h.png differ diff --git a/app/src/main/res/mipmap-xxhdpi/iv_vt_collect_n.png b/app/src/main/res/mipmap-xxhdpi/iv_vt_collect_n.png index f69a1df..cf88577 100644 Binary files a/app/src/main/res/mipmap-xxhdpi/iv_vt_collect_n.png and b/app/src/main/res/mipmap-xxhdpi/iv_vt_collect_n.png differ diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index 817af1c..30acc37 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -10,4 +10,5 @@ #D2D2D2 #F564B6 #333333 + #FF4233 \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 9ea267d..a5407f5 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1,5 +1,5 @@ - VionTV + ZyreoTV Home Explore @@ -12,6 +12,18 @@ Hot Picks Top 10 + Enter the content + Search History + Search Result + No Search + Hot List + Series + No Data + Play List + Privacy Policy + User Agreement + About Us + Network error please check the network \ No newline at end of file diff --git a/app/src/main/res/values/themes.xml b/app/src/main/res/values/themes.xml index acb052b..87046dc 100644 --- a/app/src/main/res/values/themes.xml +++ b/app/src/main/res/values/themes.xml @@ -2,8 +2,9 @@ \ No newline at end of file diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 667d239..8b4ef0c 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -16,11 +16,11 @@ okhttp-logging= "4.12.0" constraintlayout = "2.1.4" lifecycleLivedataKtx = "2.6.1" lifecycleViewmodelKtx = "2.6.1" -refresh-layout = "2.1.0" -refresh-header = "2.1.0" -refresh-footer = "2.1.0" +refresh-layout = "3.0.0-alpha" +refresh-header = "3.0.0-alpha" +refresh-footer = "3.0.0-alpha" banner = "2.2.3" -recyclerview = "1.2.1" +recyclerview = "1.3.2" glide = "4.13.1" avloadingindicatorview="2.1.4" media3 ="1.4.0"