mirror of
https://github.com/sifacaii/VlcJellyfin
synced 2025-06-03 00:58:06 -04:00
添加jellyfin client
This commit is contained in:
parent
9d61b575a9
commit
f0fbed8e82
2
.idea/misc.xml
generated
2
.idea/misc.xml
generated
@ -23,7 +23,7 @@
|
||||
<entry key="..\:/work/VlcJellyfin/app/src/main/res/drawable/shape_user_focus_vholder.xml" value="0.1625" />
|
||||
<entry key="..\:/work/VlcJellyfin/app/src/main/res/layout/activebar_custom.xml" value="0.14895833333333333" />
|
||||
<entry key="..\:/work/VlcJellyfin/app/src/main/res/layout/activity_collection.xml" value="0.14895833333333333" />
|
||||
<entry key="..\:/work/VlcJellyfin/app/src/main/res/layout/activity_detail.xml" value="0.14895833333333333" />
|
||||
<entry key="..\:/work/VlcJellyfin/app/src/main/res/layout/activity_detail.xml" value="0.1" />
|
||||
<entry key="..\:/work/VlcJellyfin/app/src/main/res/layout/activity_main.xml" value="0.2957427536231884" />
|
||||
<entry key="..\:/work/VlcJellyfin/app/src/main/res/layout/activity_search.xml" value="0.14791666666666667" />
|
||||
<entry key="..\:/work/VlcJellyfin/app/src/main/res/layout/activity_vlc_player.xml" value="0.14895833333333333" />
|
||||
|
@ -25,18 +25,14 @@ import com.owen.tvrecyclerview.widget.V7LinearLayoutManager;
|
||||
import com.squareup.picasso.Picasso;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
public class DetailActivity extends BaseActivity implements JAdapter.OnItemClickListener {
|
||||
private String TAG = "详情:";
|
||||
private String ItemId;
|
||||
private ImageView tvCover;
|
||||
private TextView tvTitle;
|
||||
private TextView tvGenres;
|
||||
private TextView tvRating;
|
||||
private TextView tvVideo;
|
||||
private TextView tvAudio;
|
||||
private TextView tvSubtitle;
|
||||
private TextView tvOverview;
|
||||
private TextView tvDetails;
|
||||
private ImageView tvPlay;
|
||||
private JRecyclerView mGridView;
|
||||
private JRecyclerView mPeopleGridView;
|
||||
@ -58,12 +54,7 @@ public class DetailActivity extends BaseActivity implements JAdapter.OnItemClick
|
||||
private void init() {
|
||||
tvCover = findViewById(R.id.tvCover);
|
||||
tvTitle = findViewById(R.id.tvTitle);
|
||||
tvGenres = findViewById(R.id.tvGenres);
|
||||
tvRating = findViewById(R.id.tvRating);
|
||||
tvVideo = findViewById(R.id.tvVideo);
|
||||
tvAudio = findViewById(R.id.tvAudio);
|
||||
tvSubtitle = findViewById(R.id.tvSubtitle);
|
||||
tvOverview = findViewById(R.id.tvOverview);
|
||||
tvDetails = findViewById(R.id.tvDetails);
|
||||
tvPlay = findViewById(R.id.tvPlay);
|
||||
mGridView = findViewById(R.id.mGridView);
|
||||
tvPeopleLayout = findViewById(R.id.tvPersonLayout);
|
||||
@ -112,9 +103,11 @@ public class DetailActivity extends BaseActivity implements JAdapter.OnItemClick
|
||||
String Overview = JfClient.strFromGson(detailObj, "Overview");
|
||||
|
||||
tvTitle.setText(Name);
|
||||
tvGenres.setText("年份:" + ProductionYear + " 风格:" + Genres);
|
||||
tvRating.setText("评分:" + CommunityRating + " 评级:" + OfficialRating);
|
||||
tvOverview.setText("简介: " + Overview);
|
||||
tvDetails.append(ProductionYear.equals("") ? "" : "年份:" + ProductionYear + " ");
|
||||
tvDetails.append(Genres.equals("") ? "" : "风格:" + Genres + "\n");
|
||||
tvDetails.append(CommunityRating.equals("") ? "" : "评分:" + CommunityRating + " ");
|
||||
tvDetails.append(OfficialRating.equals("") ? "" : "评级:" + OfficialRating + "\n");
|
||||
|
||||
|
||||
JsonArray MediaStreams = null;
|
||||
if (detailObj.has("MediaStreams")) {
|
||||
@ -135,13 +128,11 @@ public class DetailActivity extends BaseActivity implements JAdapter.OnItemClick
|
||||
else subtitle += JfClient.strFromGson(ms, "Codec") + ";";
|
||||
}
|
||||
}
|
||||
String finalVideo = video;
|
||||
String finalAudio = audio;
|
||||
String finalSubtitle = subtitle;
|
||||
tvVideo.setText("视频:" + finalVideo);
|
||||
tvAudio.setText("音频:" + finalAudio);
|
||||
tvSubtitle.setText("字幕:" + finalSubtitle);
|
||||
tvDetails.append(video.equals("") ? "" : "视频:" + video + "\n");
|
||||
tvDetails.append(audio.equals("") ? "" : "音频:" + audio + "\n");
|
||||
tvDetails.append(subtitle.equals("") ? "" : "字幕:" + subtitle + "\n");
|
||||
}
|
||||
tvDetails.append("简介: " + Overview );
|
||||
|
||||
//填充列表
|
||||
String type = JfClient.strFromGson(detailObj, "Type");
|
||||
@ -156,47 +147,64 @@ public class DetailActivity extends BaseActivity implements JAdapter.OnItemClick
|
||||
fillEpisodes(SeriesId, SeasonId);
|
||||
} else if (type.equals("Movie")) {
|
||||
fillMovie(detailObj);
|
||||
} else if (type.equals("Person")){
|
||||
JsonElement ProductionLocations = JfClient.jeFromGson(detailObj,"ProductionLocations");
|
||||
String PremiereDate = JfClient.strFromGson(detailObj,"PremiereDate");
|
||||
tvDetails.append("出生日期:" +PremiereDate+"\n");
|
||||
tvDetails.append("出生地:" + ProductionLocations == null ? "" : ProductionLocations.toString());
|
||||
fillItemsByPerson(Id);
|
||||
}
|
||||
|
||||
JsonElement People = JfClient.jeFromGson(detailObj,"People");
|
||||
if(People != null){
|
||||
fillPeople(People.getAsJsonArray());
|
||||
JsonArray peoples = People.getAsJsonArray();
|
||||
if(peoples.size() > 0) {
|
||||
fillPeople(People.getAsJsonArray());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void fillMovie(JsonObject item) {
|
||||
tvPlay.setVisibility(View.VISIBLE);
|
||||
tvPlay.setOnFocusChangeListener(new View.OnFocusChangeListener() {
|
||||
@Override
|
||||
public void onFocusChange(View view, boolean b) {
|
||||
if (view.hasFocus()) {
|
||||
view.animate().scaleX(1.05f).scaleY(1.05f).setDuration(300).setInterpolator(new BounceInterpolator()).start();
|
||||
} else {
|
||||
view.animate().scaleX(1.0f).scaleY(1.0f).setDuration(300).setInterpolator(new BounceInterpolator()).start();
|
||||
}
|
||||
}
|
||||
});
|
||||
tvPlay.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
JfClient.playList.clear();
|
||||
JfClient.playList.add(getMedia(item));
|
||||
JfClient.playIndex = 0;
|
||||
toVlcPlayer();
|
||||
}
|
||||
});
|
||||
tvPlay.requestFocus();
|
||||
// tvPlay.setVisibility(View.VISIBLE);
|
||||
// tvPlay.setOnFocusChangeListener(new View.OnFocusChangeListener() {
|
||||
// @Override
|
||||
// public void onFocusChange(View view, boolean b) {
|
||||
// if (view.hasFocus()) {
|
||||
// view.animate().scaleX(1.05f).scaleY(1.05f).setDuration(300).setInterpolator(new BounceInterpolator()).start();
|
||||
// } else {
|
||||
// view.animate().scaleX(1.0f).scaleY(1.0f).setDuration(300).setInterpolator(new BounceInterpolator()).start();
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
// tvPlay.setOnClickListener(new View.OnClickListener() {
|
||||
// @Override
|
||||
// public void onClick(View view) {
|
||||
// JfClient.playList.clear();
|
||||
// JfClient.playList.add(getMedia(item));
|
||||
// JfClient.playIndex = 0;
|
||||
// toVlcPlayer();
|
||||
// }
|
||||
// });
|
||||
// tvPlay.requestFocus();
|
||||
|
||||
String Name = JfClient.strFromGson(item,"Name");
|
||||
Name = "播放: " + Name;
|
||||
item.remove("Name");
|
||||
item.addProperty("Name" ,Name);
|
||||
|
||||
JsonArray plja = new JsonArray();
|
||||
plja.add(item);
|
||||
if (item.has("PartCount")) {
|
||||
String Id = JfClient.strFromGson(item, "Id");
|
||||
JfClient.GetAddPart(Id, new JfClient.JJCallBack() {
|
||||
@Override
|
||||
public void onSuccess(JsonArray parts) {
|
||||
fillItems(parts);
|
||||
plja.addAll(parts);
|
||||
fillItems(plja);
|
||||
}
|
||||
}, null);
|
||||
} else {
|
||||
dismissLoadingDialog();
|
||||
fillItems(plja);
|
||||
}
|
||||
}
|
||||
|
||||
@ -241,6 +249,10 @@ public class DetailActivity extends BaseActivity implements JAdapter.OnItemClick
|
||||
dismissLoadingDialog();
|
||||
}
|
||||
|
||||
/**
|
||||
* 填充定员表
|
||||
* @param items
|
||||
*/
|
||||
private void fillPeople(JsonArray items) {
|
||||
tvPeopleLayout.setVisibility(View.VISIBLE);
|
||||
JAdapter jAdapter = new JAdapter(items, false);
|
||||
@ -251,6 +263,37 @@ public class DetailActivity extends BaseActivity implements JAdapter.OnItemClick
|
||||
mPeopleGridView.setAdapter(jAdapter);
|
||||
}
|
||||
|
||||
/**
|
||||
* 填充演员作品
|
||||
* @param personid
|
||||
*/
|
||||
private void fillItemsByPerson(String personid) {
|
||||
String Term = "&SortBy=DateCreated&SortOrder=Descending&PersonIds=" + personid;
|
||||
JfClient.GetItemsByTerm(Term,new JfClient.JJCallBack(){
|
||||
@Override
|
||||
public void onSuccess(JsonObject jsonObject) {
|
||||
JsonArray items = jsonObject.get("Items").getAsJsonArray();
|
||||
JAdapter jAdapter = new JAdapter(items, false);
|
||||
V7GridLayoutManager layoutManager = new V7GridLayoutManager(mGridView.getContext(),4);
|
||||
jAdapter.setOnItemClickListener(new JAdapter.OnItemClickListener() {
|
||||
@Override
|
||||
public void onClick(JsonObject jo) {
|
||||
//点击
|
||||
}
|
||||
});
|
||||
mGridView.setVisibility(View.VISIBLE);
|
||||
mGridView.setLayoutManager(layoutManager);
|
||||
mGridView.setAdapter(jAdapter);
|
||||
dismissLoadingDialog();
|
||||
}
|
||||
},new JfClient.JJCallBack(){
|
||||
@Override
|
||||
public void onError(String str) {
|
||||
dismissLoadingDialog();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(JsonObject jo) {
|
||||
String itemId = jo.get("Id").getAsString();
|
||||
@ -281,7 +324,9 @@ public class DetailActivity extends BaseActivity implements JAdapter.OnItemClick
|
||||
JfClient.playIndex = 0;
|
||||
toVlcPlayer();
|
||||
}else if(type.equals("Actor")){
|
||||
|
||||
intent = new Intent(this, DetailActivity.class);
|
||||
intent.putExtra("itemId", itemId);
|
||||
startActivity(intent);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -227,6 +227,28 @@ public class JfClient {
|
||||
}, errcb);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据条件获取条目列表
|
||||
* @param term 可以是 &Limit、&SortBy、&IncludeItemTypes、&PersonIds 等
|
||||
* @param scb
|
||||
* @param errcb
|
||||
*/
|
||||
public static void GetItemsByTerm(String term,JJCallBack scb,JJCallBack errcb){
|
||||
String BaseUrl = config.getJellyfinUrl() + "/Users/"+UserId+"/Items?Recursive=true&StartIndex=0&CollapseBoxSetItems=false";
|
||||
BaseUrl += term;
|
||||
SendGet(BaseUrl,new JJCallBack(){
|
||||
@Override
|
||||
public void onSuccess(String str) {
|
||||
JsonObject items = strToGson(str,JsonObject.class);
|
||||
if(items == null){
|
||||
errcb.onError("内容空!");
|
||||
}else{
|
||||
scb.onSuccess(items);
|
||||
}
|
||||
}
|
||||
},errcb);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取合集条目
|
||||
*
|
||||
|
@ -48,55 +48,11 @@
|
||||
android:textSize="30dp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvGenres"
|
||||
android:id="@+id/tvDetails"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="28dp"
|
||||
android:layout_marginTop="2dp"
|
||||
android:text="风格:"
|
||||
android:textColor="@android:color/white"
|
||||
android:textSize="20dp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvRating"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="28dp"
|
||||
android:text="评分:"
|
||||
android:textColor="@android:color/white"
|
||||
android:textSize="20dp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvVideo"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="28dp"
|
||||
android:text="视频:"
|
||||
android:textColor="@android:color/white"
|
||||
android:textSize="20dp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvAudio"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="28dp"
|
||||
android:text="音频:"
|
||||
android:textColor="@android:color/white"
|
||||
android:textSize="20dp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvSubtitle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="28dp"
|
||||
android:text="字幕:"
|
||||
android:textColor="@android:color/white"
|
||||
android:textSize="20dp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvOverview"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="110dp"
|
||||
android:layout_marginTop="6dp"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="4"
|
||||
android:text="简介:"
|
||||
android:textColor="@android:color/white"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="260dp"
|
||||
android:layout_marginTop="20dp"
|
||||
android:textSize="20dp" />
|
||||
|
||||
<ImageView
|
||||
@ -115,7 +71,7 @@
|
||||
<org.sifacai.vlcjellyfin.JRecyclerView
|
||||
android:id="@+id/mGridView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="312dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="20dp"
|
||||
android:clipChildren="false"
|
||||
android:clipToPadding="false"
|
||||
@ -128,6 +84,7 @@
|
||||
app:tv_verticalSpacingWithMargins="@dimen/vh_space_width" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
|
Loading…
x
Reference in New Issue
Block a user