推荐影片图标
ServicesActivity.java
package com.example.smartcity.activity.movie;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.FrameLayout;
import com.example.smartcity.R;
import com.example.smartcity.fragment.movie.FilmFragment;
public class ServicesActivity extends AppCompatActivity {
private FrameLayout mFragmentBox;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_services);
mFragmentBox = (FrameLayout) findViewById(R.id.fragment_box);
//切换fragment
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_box,new FilmFragment()).commit();
}
}
activity_services.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".activity.movie.ServicesActivity"
android:orientation="vertical">
<FrameLayout
android:id="@+id/fragment_box"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</LinearLayout>
预告图标
PreviewActivity.java
package com.example.smartcity.activity.movie;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.SearchView;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.WebView;
import android.widget.ListView;
import android.widget.TextView;
import com.example.smartcity.R;
import com.example.smartcity.adpter.SuperBase;
import com.example.smartcity.http.initMovieHttp;
import com.example.smartcity.info.movie.RecommendInfo;
import java.util.ArrayList;
import static com.example.smartcity.utils.CacheUtils.recommendInfo;
import static com.example.smartcity.utils.ConstantsUtils.RECOMMEND_WHAT;
import static com.example.smartcity.utils.ConstantsUtils.VIDEO;
import static com.example.smartcity.utils.ConstantsUtils.VIDEO_REPLACE;
public class PreviewActivity extends AppCompatActivity {
private TextView mAddress;
private SearchView mEdtPreview;
private ListView mPreviewList;
Handler handler = new Handler(Looper.myLooper()){
@Override
public void handleMessage(Message msg) {
super.handleMessage(msg);
switch (msg.what){
case RECOMMEND_WHAT:
loadPreviewFilm();
break;
}
}
};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_preview);
initView();
new initMovieHttp(handler).recommendFilmData();
}
public void loadPreviewFilm(){
//将不为空的数据放入新的集合
ArrayList<RecommendInfo.RowsDTO> rowsDTOS = new ArrayList<>();
for (int i = 0; i < recommendInfo.getRows().size(); i++) {
if (recommendInfo.getRows().get(i).getVideo()!=null){
rowsDTOS.add(recommendInfo.getRows().get(i));
}
}
Log.e("TAG", "数组:"+rowsDTOS);
SuperBase superBase = new SuperBase(rowsDTOS.size()) {
private WebView mPreviewFilmVideo;
private TextView mPreviewFilmName;
@Override
public View getView(int position, View convertView, ViewGroup parent) {
convertView = LayoutInflater.from(PreviewActivity.this).inflate(R.layout.item_preview_film,parent,false);
mPreviewFilmVideo = (WebView) convertView.findViewById(R.id.preview_film_video);
mPreviewFilmName = (TextView) convertView.findViewById(R.id.preview_film_name);
mPreviewFilmName.setText(rowsDTOS.get(position).getName());
String replace = rowsDTOS.get(position).getVideo().replace(VIDEO_REPLACE,"");
String path = VIDEO + replace;
mPreviewFilmVideo.loadData("<video width=\"100%\"\" height=\"100%\" src=\""+path+"\" controls=\"controls\"></video>","text/html","UTF-8");
return convertView;
}
};
mPreviewList.setAdapter(superBase);
}
//初始化
public void initView(){
mAddress = (TextView) findViewById(R.id.address);
mEdtPreview = (SearchView) findViewById(R.id.edt_preview);
mPreviewList = (ListView) findViewById(R.id.preview_list);
}
}
activity_preview.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".activity.movie.PreviewActivity"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="horizontal">
<TextView
android:id="@+id/address"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="大连市"
android:textSize="20dp"
android:gravity="center"
android:layout_marginLeft="20dp"/>
<androidx.appcompat.widget.SearchView
android:id="@+id/edt_preview"
android:layout_width="250dp"
android:layout_height="wrap_content"
android:background="@drawable/bg_login"
android:layout_marginTop="10dp"
android:layout_marginLeft="10dp"
android:imeOptions="actionSearch"/>
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#000000"/>
<ListView
android:layout_marginTop="10dp"
android:id="@+id/preview_list"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="9"
android:background="#ECECEC"/>
</LinearLayout>
星闻图标
StarNewsActivity.java
package com.example.smartcity.activity.movie;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;
import com.example.smartcity.R;
import com.example.smartcity.adpter.SuperBase;
import com.example.smartcity.bean.StarNewsSkipContent;
import com.example.smartcity.http.initMovieHttp;
import com.example.smartcity.info.movie.StarNews;
import com.example.smartcity.utils.GetNetImage;
import static com.example.smartcity.utils.CacheUtils.starNews;
import static com.example.smartcity.utils.ConstantsUtils.STAR_NEWS_WHAT;
import static com.example.smartcity.utils.KeyUtils.STAR;
public class StarNewsActivity extends AppCompatActivity {
private ImageView mBack;
private ListView mStarNewsList;
Handler handler = new Handler(Looper.myLooper()){
@Override
public void handleMessage(Message msg) {
super.handleMessage(msg);
switch (msg.what){
case STAR_NEWS_WHAT:
loadStarNews();
break;
}
}
};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_star_news);
initView();
new initMovieHttp(handler).starNewsData();
mStarNewsList.setOnItemClickListener(new starNewsListItemClick());
}
//点击条目跳转详情界面
class starNewsListItemClick implements AdapterView.OnItemClickListener{
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
//将信息封装成对象,传值
StarNewsSkipContent starNewsSkipContent = new StarNewsSkipContent();
StarNews.RowsDTO rowsDTO = starNews.getRows().get(position);
starNewsSkipContent.setName(rowsDTO.getTitle());
starNewsSkipContent.setImage(rowsDTO.getCover());
starNewsSkipContent.setLikeNum(rowsDTO.getLikeNum());
starNewsSkipContent.setContent(rowsDTO.getContent());
starNewsSkipContent.setId(rowsDTO.getId());
Intent intent = new Intent(StarNewsActivity.this,StarNewsInfoActivity.class);
intent.putExtra(STAR,starNewsSkipContent);
startActivity(intent);
}
}
//设置数据
public void loadStarNews(){
SuperBase superBase = new SuperBase(starNews.getRows().size()) {
private ImageView mFilmImg;
private TextView mStarNewsTitle;
private TextView mStarNewsTitleOthers;
private TextView mStarNewsDate;
private TextView mStarNewsThumbs;
@Override
public View getView(int position, View convertView, ViewGroup parent) {
convertView = LayoutInflater.from(StarNewsActivity.this).inflate(R.layout.item_star_news,parent,false);
mFilmImg = (ImageView) convertView.findViewById(R.id.film_img);
mStarNewsTitle = (TextView) convertView.findViewById(R.id.star_news_title);
mStarNewsTitleOthers = (TextView) convertView.findViewById(R.id.star_news_title_others);
mStarNewsDate = (TextView) convertView.findViewById(R.id.star_news_date);
mStarNewsThumbs = (TextView) convertView.findViewById(R.id.star_news_thumbs);
//设置数据
StarNews.RowsDTO rowsDTO = starNews.getRows().get(position);
new GetNetImage(StarNewsActivity.this,rowsDTO.getCover(),mFilmImg);
mStarNewsTitle.setText(rowsDTO.getTitle());
mStarNewsDate.setText("发布日期:"+rowsDTO.getPublishDate());
mStarNewsThumbs.setText("点赞数"+rowsDTO.getLikeNum());
return convertView;
}
};
mStarNewsList.setAdapter(superBase);
}
public void initView(){
mBack = (ImageView) findViewById(R.id.back);
mStarNewsList = (ListView) findViewById(R.id.star_news_list);
mBack.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
}
}
activity_star_news.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".activity.movie.StarNewsActivity"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="60dp"
android:background="#CA3939"
android:orientation="horizontal">
<ImageView
android:id="@+id/back"
android:layout_width="30dp"
android:layout_height="30dp"
android:background="@drawable/ic_back"
android:layout_gravity="center"
android:layout_marginLeft="20dp"/>
<TextView
android:layout_width="280dp"
android:layout_height="match_parent"
android:text="星 闻"
android:textSize="25dp"
android:textColor="@color/white"
android:gravity="center"/>
</LinearLayout>
<ListView
android:id="@+id/star_news_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ECECEC" />
</LinearLayout>
星闻详情
StarNewsInfoActivity.java
package com.example.smartcity.activity.movie;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.WebView;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.ProgressBar;
import android.widget.RatingBar;
import android.widget.TextView;
import com.example.smartcity.R;
import com.example.smartcity.adpter.SuperBase;
import com.example.smartcity.bean.StarNewsSkipContent;
import com.example.smartcity.http.initMovieHttp;
import com.example.smartcity.info.movie.StarNewsComment;
import com.example.smartcity.utils.GetNetImage;
import java.util.ArrayList;
import static com.example.smartcity.utils.CacheUtils.starNewsComment;
import static com.example.smartcity.utils.ConstantsUtils.STAR_NEWS_COMMENT_WHAT;
import static com.example.smartcity.utils.KeyUtils.STAR;
public class StarNewsInfoActivity extends AppCompatActivity {
private ImageView mBack;
private TextView mFilmName;
private ImageView mStarNewsImg;
private TextView mThrumbsNum;
private TextView mLoveThrumbs;
private WebView mStarNewsContent;
private Button mBtnStarEwsComment;
private ListView mStarNewsComment;
private ProgressBar load_star_news_comment;
private StarNewsSkipContent starNewsSkipContent;
private int id;//获取新闻列表id
Handler handler = new Handler(Looper.myLooper()){
@Override
public void handleMessage(Message msg) {
super.handleMessage(msg);
switch (msg.what){
case STAR_NEWS_COMMENT_WHAT:
loadStarNewsComment();
load_star_news_comment.setVisibility(View.GONE);
break;
}
}
};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_star_news_info);
initView();
initData();
new initMovieHttp(handler).starNewsCommentData();//初始化
}
//设置评论数据
public void loadStarNewsComment(){
ArrayList<StarNewsComment.RowsDTO> rowsDTOS = new ArrayList<>();
for (int i = 0; i < starNewsComment.getRows().size(); i++) {
if (starNewsComment.getRows().get(i).getNewsId() == id){
rowsDTOS.add(starNewsComment.getRows().get(i));
}
}
//设置适配器
SuperBase superBase = new SuperBase(rowsDTOS.size()) {
private ImageView mFilmCommentHeadImg;
private TextView mFilmCommentUsername;
private RatingBar mFilmCommentScore;
private TextView mFilmCommentContent;
private TextView mFilmCommentTime;
private TextView mFilmCommentThumbs;
@Override
public View getView(int position, View convertView, ViewGroup parent) {
convertView = LayoutInflater.from(StarNewsInfoActivity.this).inflate(R.layout.item_film_comment,parent,false);
mFilmCommentHeadImg = (ImageView) convertView.findViewById(R.id.film_comment_head_img);
mFilmCommentUsername = (TextView) convertView.findViewById(R.id.film_comment_username);
mFilmCommentScore = (RatingBar) convertView.findViewById(R.id.film_comment_score);
mFilmCommentContent = (TextView) convertView.findViewById(R.id.film_comment_content);
mFilmCommentTime = (TextView) convertView.findViewById(R.id.film_comment_time);
mFilmCommentThumbs = (TextView) convertView.findViewById(R.id.film_comment_thumbs);
//排序
mFilmCommentUsername.setText(rowsDTOS.get(rowsDTOS.size()-1-position).getUserName());
mFilmCommentContent.setText(rowsDTOS.get(rowsDTOS.size()-1-position).getContent());
mFilmCommentTime.setText("评论时间"+rowsDTOS.get(rowsDTOS.size()-1-position).getCommentDate());
mFilmCommentThumbs.setVisibility(View.GONE);
return convertView;
}
};
mStarNewsComment.setAdapter(superBase);
}
//初始化数据
public void initData(){
starNewsSkipContent = (StarNewsSkipContent) getIntent().getSerializableExtra(STAR);//获取值
//返回
mBack.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
//设置值
mFilmName.setText(starNewsSkipContent.getName());
new GetNetImage(StarNewsInfoActivity.this,starNewsSkipContent.getImage(),mStarNewsImg);
mThrumbsNum.setText(starNewsSkipContent.getLikeNum()+"");
mStarNewsContent.loadData(starNewsSkipContent.getContent(),"text/html","UTF-8");
id = starNewsSkipContent.getId();//获取新闻列表id
Log.e("TAG", "新闻评论列表: "+id );
}
//初始化视图
public void initView(){
mBack = (ImageView) findViewById(R.id.back);
mFilmName = (TextView) findViewById(R.id.film_name);
mStarNewsImg = (ImageView) findViewById(R.id.star_news_img);
mThrumbsNum = (TextView) findViewById(R.id.thrumbs_num);
mLoveThrumbs = (TextView) findViewById(R.id.love_thrumbs);
mStarNewsContent = (WebView) findViewById(R.id.star_news_content);
mBtnStarEwsComment = (Button) findViewById(R.id.btn_star_ews_comment);
mStarNewsComment = (ListView) findViewById(R.id.star_news_comment);
load_star_news_comment = findViewById(R.id.load_star_news_comment);
}
}
activity_star_news_info.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".activity.movie.StarNewsInfoActivity"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="60dp"
android:background="#CA3939"
android:orientation="horizontal">
<ImageView
android:id="@+id/back"
android:layout_width="30dp"
android:layout_height="30dp"
android:background="@drawable/ic_back"
android:layout_gravity="center"
android:layout_marginLeft="20dp"/>
<TextView
android:id="@+id/film_name"
android:layout_width="280dp"
android:layout_height="match_parent"
android:text="title"
android:textSize="25dp"
android:textColor="@color/white"
android:gravity="center"/>
</LinearLayout>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ImageView
android:id="@+id/star_news_img"
android:layout_width="match_parent"
android:layout_height="400dp"
android:scaleType="fitXY"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="30dp"
android:orientation="horizontal"
android:layout_marginTop="10dp">
<TextView
android:id="@+id/thrumbs_num"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="123"
android:layout_gravity="center"
android:layout_marginLeft="280dp"/>
<TextView
android:id="@+id/love_thrumbs"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_gravity="center"
android:text="❤"/>
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#000000"/>
<WebView
android:id="@+id/star_news_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"/>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#000000"
android:layout_marginTop="10dp"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="800dp"
android:orientation="vertical"
android:layout_marginTop="10dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:orientation="horizontal">
<Button
android:id="@+id/btn_star_ews_comment"
android:layout_width="70dp"
android:layout_height="40dp"
android:background="@drawable/btn_normal"
android:text="评 论"
android:textColor="@color/white"
android:layout_marginLeft="255dp"
android:layout_marginTop="5dp"/>
</LinearLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ProgressBar
android:id="@+id/load_star_news_comment"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_gravity="center"/>
<ListView
android:id="@+id/star_news_comment"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</FrameLayout>
</LinearLayout>
</LinearLayout>
</ScrollView>
</LinearLayout>