mirror of
https://github.com/sifacaii/VlcJellyfin
synced 2025-05-26 06:20:20 -04:00
添加排序
This commit is contained in:
parent
f5d3a4350a
commit
5cbe9ee7fc
@ -3,54 +3,57 @@ package org.sifacai.vlcjellyfin;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.ActionBar;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import me.jessyan.autosize.internal.CustomAdapt;
|
||||
|
||||
public class BaseActivity extends AppCompatActivity implements CustomAdapt {
|
||||
public AlertDialog alertDialogLoading;
|
||||
public AppCompatActivity mAA = this;
|
||||
private TextView activeBarBack;
|
||||
private ProgressDialog progressDialog;
|
||||
private ImageView activeBarBack;
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
ActionBar actionBar = getSupportActionBar();
|
||||
if(null != actionBar){
|
||||
if (null != actionBar) {
|
||||
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
|
||||
actionBar.setCustomView(R.layout.activebar_custom);
|
||||
}
|
||||
|
||||
activeBarBack = findViewById(R.id.activeBar_back);
|
||||
activeBarBack.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
mAA.finish();
|
||||
}
|
||||
});
|
||||
activeBarBack = findViewById(R.id.activeBar_back);
|
||||
activeBarBack.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
mAA.finish();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(@NonNull Menu menu) {
|
||||
getMenuInflater().inflate(R.menu.activebar_menu,menu);
|
||||
getMenuInflater().inflate(R.menu.activebar_menu, menu);
|
||||
return super.onCreateOptionsMenu(menu);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
|
||||
if(item.getItemId() == R.id.activeBar_option_logout){
|
||||
finish();
|
||||
if (item.getItemId() == R.id.activeBar_option_logout) {
|
||||
logout();
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
@ -58,7 +61,7 @@ public class BaseActivity extends AppCompatActivity implements CustomAdapt {
|
||||
/**
|
||||
* 禁用标题栏返回按钮
|
||||
*/
|
||||
public void disableActiveBarBack(){
|
||||
public void disableActiveBarBack() {
|
||||
activeBarBack.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
@ -86,57 +89,31 @@ public class BaseActivity extends AppCompatActivity implements CustomAdapt {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void showLoadingDialog(String msg) {
|
||||
mAA.runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
showLoadingDialog(1);
|
||||
setLoadingText(msg);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void showLoadingDialog() {
|
||||
mAA.runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
showLoadingDialog(1);
|
||||
}
|
||||
});
|
||||
|
||||
showLoadingDialog("");
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示加载动画框
|
||||
*/
|
||||
public void showLoadingDialog(int i) {
|
||||
if (null != alertDialogLoading && alertDialogLoading.isShowing()) {
|
||||
alertDialogLoading.dismiss();
|
||||
}
|
||||
alertDialogLoading = new AlertDialog.Builder(this).create();
|
||||
alertDialogLoading.getWindow().setBackgroundDrawable(new ColorDrawable());
|
||||
alertDialogLoading.setCancelable(false);
|
||||
alertDialogLoading.setOnKeyListener(new DialogInterface.OnKeyListener() {
|
||||
@Override
|
||||
public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
|
||||
if (keyCode == KeyEvent.KEYCODE_BACK) {
|
||||
alertDialogLoading.dismiss();
|
||||
mAA.finish();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
alertDialogLoading.show();
|
||||
alertDialogLoading.setContentView(R.layout.loading_alert);
|
||||
alertDialogLoading.setCanceledOnTouchOutside(false);
|
||||
}
|
||||
|
||||
public void dismissLoadingDialog() {
|
||||
public void showLoadingDialog(String title) {
|
||||
mAA.runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
dismissLoadingDialog(1);
|
||||
progressDialog = new ProgressDialog(mAA);
|
||||
progressDialog.setMessage(title);
|
||||
progressDialog.show();
|
||||
progressDialog.setOnKeyListener(new DialogInterface.OnKeyListener() {
|
||||
@Override
|
||||
public boolean onKey(DialogInterface dialogInterface, int i, KeyEvent keyEvent) {
|
||||
if (keyEvent.getKeyCode() == KeyEvent.KEYCODE_BACK) {
|
||||
dismissLoadingDialog();
|
||||
mAA.finish();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -144,34 +121,94 @@ public class BaseActivity extends AppCompatActivity implements CustomAdapt {
|
||||
/**
|
||||
* 隐藏加载框
|
||||
*/
|
||||
public void dismissLoadingDialog(int i) {
|
||||
if (null != alertDialogLoading && alertDialogLoading.isShowing()) {
|
||||
alertDialogLoading.dismiss();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置加载框文字
|
||||
* @param text
|
||||
*/
|
||||
public void setLoadingText(String text){
|
||||
public void dismissLoadingDialog() {
|
||||
mAA.runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (null != alertDialogLoading && alertDialogLoading.isShowing()) {
|
||||
TextView tv = alertDialogLoading.getWindow().getDecorView().findViewById(R.id.progressText);
|
||||
tv.setText(text);
|
||||
if (null != progressDialog && progressDialog.isShowing()) {
|
||||
progressDialog.dismiss();
|
||||
progressDialog = null;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void ShowToask(String msg){
|
||||
/**
|
||||
* 设置加载框文字
|
||||
*
|
||||
* @param text
|
||||
*/
|
||||
public void setLoadingText(String text) {
|
||||
mAA.runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Toast.makeText(mAA,msg,Toast.LENGTH_LONG).show();
|
||||
if (null != progressDialog && progressDialog.isShowing()) {
|
||||
progressDialog.setMessage(text);
|
||||
}else{
|
||||
showLoadingDialog(text);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void ShowToask(String msg) {
|
||||
mAA.runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Toast.makeText(mAA, msg, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 读取配置
|
||||
*/
|
||||
public void getConfigFromSP() {
|
||||
SharedPreferences sp = this.getSharedPreferences("Jellyfin", this.MODE_PRIVATE);
|
||||
Utils.JellyfinUrl = sp.getString("url", "");
|
||||
Utils.UserName = sp.getString("username", "");
|
||||
Utils.PassWord = sp.getString("password", "");
|
||||
Utils.SortBy = sp.getString("sortby","");
|
||||
Utils.SortOrder = sp.getString("sortorder","");
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存配置
|
||||
*
|
||||
* @param url
|
||||
* @param username
|
||||
* @param password
|
||||
*/
|
||||
public void saveConfigToSP(String url, String username, String password) {
|
||||
SharedPreferences sp = this.getSharedPreferences("Jellyfin", this.MODE_PRIVATE);
|
||||
SharedPreferences.Editor editor = sp.edit();
|
||||
editor.putString("url", url);
|
||||
editor.putString("username", username);
|
||||
editor.putString("password", password);
|
||||
editor.commit();
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存单项配置
|
||||
*/
|
||||
public void saveConfigToSP(String key, String value) {
|
||||
SharedPreferences sp = this.getSharedPreferences("Jellyfin", this.MODE_PRIVATE);
|
||||
SharedPreferences.Editor editor = sp.edit();
|
||||
editor.putString(key, value);
|
||||
editor.putString(key, value);
|
||||
editor.commit();
|
||||
}
|
||||
|
||||
/**
|
||||
* 登 出
|
||||
*/
|
||||
private void logout() {
|
||||
SharedPreferences sp = this.getSharedPreferences("Jellyfin", this.MODE_PRIVATE);
|
||||
SharedPreferences.Editor editor = sp.edit();
|
||||
editor.clear();
|
||||
editor.commit();
|
||||
Utils.UserId = "";
|
||||
Utils.AccessToken = "";
|
||||
System.exit(0);
|
||||
}
|
||||
}
|
||||
|
@ -7,8 +7,10 @@ import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.ActionMode;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.SubMenu;
|
||||
import android.view.View;
|
||||
import android.widget.PopupMenu;
|
||||
import android.widget.TextView;
|
||||
@ -50,7 +52,7 @@ public class CollectionActivity extends BaseActivity {
|
||||
|
||||
mActivity = this;
|
||||
mGridContiner = findViewById(R.id.mGridView);
|
||||
tvTitleTip = findViewById(R.id.tvTitleTip);
|
||||
tvTitleTip = findViewById(R.id.activeBar_titleTip);
|
||||
V7GridLayoutManager v7GridLayoutManager = new V7GridLayoutManager(this,6);
|
||||
mGridContiner.setLayoutManager(v7GridLayoutManager);
|
||||
mGridContiner.setItemAnimator(null); //防崩溃
|
||||
@ -74,22 +76,7 @@ public class CollectionActivity extends BaseActivity {
|
||||
}
|
||||
}).start();
|
||||
|
||||
sortMenuBtn = findViewById(R.id.activeBar_sortBtn);
|
||||
initSortByMenu(sortMenuBtn);
|
||||
sortMenuBtn.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
int i = 0;
|
||||
for(Utils.SortByType sbt : Utils.SortByType.values()){
|
||||
if(sbt.value.equals(Utils.SortBy)){
|
||||
i = sbt.ordinal();
|
||||
}
|
||||
}
|
||||
SortByMenu.getMenu().getItem(i).setCheckable(true);
|
||||
SortByMenu.getMenu().getItem(i).setChecked(true);
|
||||
SortByMenu.show();
|
||||
}
|
||||
});
|
||||
initSortByMenu();
|
||||
}
|
||||
}
|
||||
|
||||
@ -137,14 +124,11 @@ public class CollectionActivity extends BaseActivity {
|
||||
countPage = (int) Math.ceil((double) totalCount / limit);
|
||||
|
||||
JsonArray Items = ItemsObj.get("Items").getAsJsonArray();
|
||||
int oldcount = currItems.size();
|
||||
currItems.addAll(Items);
|
||||
mActivity.runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
dismissLoadingDialog();
|
||||
//currAdapter.notifyDataSetChanged();
|
||||
currAdapter.notifyItemRangeInserted(oldcount,Items.size());
|
||||
currAdapter.addItems(Items);
|
||||
setTitleTip();
|
||||
mGridContiner.finishLoadMore();
|
||||
}
|
||||
@ -196,18 +180,42 @@ public class CollectionActivity extends BaseActivity {
|
||||
tvTitleTip.setText(tip);
|
||||
}
|
||||
|
||||
private void initSortByMenu(View view){
|
||||
SortByMenu = new PopupMenu(this,view);
|
||||
private void initSortByMenu(){
|
||||
sortMenuBtn = findViewById(R.id.activeBar_sortBtn);
|
||||
sortMenuBtn.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
int i = 0;
|
||||
for(Utils.SortByType sbt : Utils.SortByType.values()){
|
||||
if(sbt.value.equals(Utils.SortBy)){
|
||||
i = sbt.ordinal();
|
||||
}
|
||||
}
|
||||
SortByMenu.show();
|
||||
}
|
||||
});
|
||||
|
||||
sortMenuBtn.setVisibility(View.VISIBLE);
|
||||
setSortMenuBtnText();
|
||||
SortByMenu = new PopupMenu(this,sortMenuBtn);
|
||||
Menu menu = SortByMenu.getMenu();
|
||||
Utils.SortByType[] Ss = Utils.SortByType.values();
|
||||
for (Utils.SortByType sortby:Ss) {
|
||||
menu.add(0,sortby.ordinal(),sortby.ordinal(),sortby.name());
|
||||
}
|
||||
for (Utils.SotrOrderType sot:Utils.SotrOrderType.values()){
|
||||
menu.add(1,sot.ordinal() + Ss.length,sot.ordinal() + Ss.length,sot.name());
|
||||
}
|
||||
SortByMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
|
||||
@Override
|
||||
public boolean onMenuItemClick(MenuItem menuItem) {
|
||||
Utils.SortBy = Utils.SortByType.valueOf(menuItem.getTitle().toString()).value;
|
||||
currItems = new JsonArray();
|
||||
if(menuItem.getGroupId() == 0) {
|
||||
Utils.SortBy = Utils.SortByType.valueOf(menuItem.getTitle().toString()).value;
|
||||
}else{
|
||||
Utils.SortOrder = Utils.SotrOrderType.valueOf(menuItem.getTitle().toString()).value;
|
||||
}
|
||||
setSortMenuBtnText();
|
||||
currAdapter.clearItems();
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@ -218,4 +226,28 @@ public class CollectionActivity extends BaseActivity {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void setSortMenuBtnText(){
|
||||
String s = "";
|
||||
Log.d(TAG, "setSortMenuBtnText: 排序规则:" + Utils.SortBy + "-" + Utils.SortOrder);
|
||||
for (Utils.SortByType Sb:Utils.SortByType.values()) {
|
||||
if(Sb.value.equals(Utils.SortBy)){
|
||||
s += Sb.name();
|
||||
}
|
||||
}
|
||||
s += "-";
|
||||
for (Utils.SotrOrderType Sot:Utils.SotrOrderType.values()) {
|
||||
if(Sot.value.equals(Utils.SortOrder)){
|
||||
s += Sot.name();
|
||||
}
|
||||
}
|
||||
sortMenuBtn.setText(s);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void finish() {
|
||||
saveConfigToSP("sortby",Utils.SortBy);
|
||||
saveConfigToSP("sortorder",Utils.SortOrder);
|
||||
super.finish();
|
||||
}
|
||||
}
|
@ -25,7 +25,7 @@ import com.squareup.picasso.Picasso;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class DetailActivity extends BaseActivity implements JAdapter.OnItemClickListener{
|
||||
public class DetailActivity extends BaseActivity implements JAdapter.OnItemClickListener {
|
||||
private String TAG = "详情:";
|
||||
private Activity mActivity;
|
||||
private String ItemId;
|
||||
@ -44,6 +44,7 @@ public class DetailActivity extends BaseActivity implements JAdapter.OnItemClick
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_detail);
|
||||
getSupportActionBar().hide();
|
||||
|
||||
if (Utils.UserId.equals("") || Utils.AccessToken.equals("")) {
|
||||
Intent intent = new Intent(this, MainActivity.class);
|
||||
@ -164,35 +165,34 @@ public class DetailActivity extends BaseActivity implements JAdapter.OnItemClick
|
||||
|
||||
//填充列表
|
||||
String type = Utils.getJsonString(detailObj, "Type").getAsString();
|
||||
if ( type.equals("Series") ) {
|
||||
if (type.equals("Series")) {
|
||||
fillSeason(ItemId);
|
||||
}else if( type.equals("Season") ){
|
||||
} else if (type.equals("Season")) {
|
||||
String SeriesId = detailObj.get("SeriesId").getAsString();
|
||||
fillEpisodes(SeriesId,ItemId);
|
||||
}else if(type.equals("Episode")){
|
||||
String SeriesId = Utils.getJsonString(detailObj,"SeriesId").getAsString();
|
||||
String SeasonId = Utils.getJsonString(detailObj,"SeasonId").getAsString();
|
||||
fillEpisodes(SeriesId,SeasonId);
|
||||
}else if( type.equals("Movie") ) {
|
||||
mActivity.runOnUiThread(new Runnable() {
|
||||
fillEpisodes(SeriesId, ItemId);
|
||||
} else if (type.equals("Episode")) {
|
||||
String SeriesId = Utils.getJsonString(detailObj, "SeriesId").getAsString();
|
||||
String SeasonId = Utils.getJsonString(detailObj, "SeasonId").getAsString();
|
||||
fillEpisodes(SeriesId, SeasonId);
|
||||
} else if (type.equals("Movie")) {
|
||||
mAA.runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
fillMovie(detailObj);
|
||||
dismissLoadingDialog();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void fillMovie(JsonObject item){
|
||||
private void fillMovie(JsonObject item) {
|
||||
tvPlay.setVisibility(View.VISIBLE);
|
||||
tvAudio.setOnFocusChangeListener(new View.OnFocusChangeListener() {
|
||||
tvPlay.setOnFocusChangeListener(new View.OnFocusChangeListener() {
|
||||
@Override
|
||||
public void onFocusChange(View view, boolean b) {
|
||||
if(view.hasFocus()){
|
||||
if (view.hasFocus()) {
|
||||
view.animate().scaleX(1.05f).scaleY(1.05f).setDuration(300).setInterpolator(new BounceInterpolator()).start();
|
||||
}else{
|
||||
} else {
|
||||
view.animate().scaleX(1.0f).scaleY(1.0f).setDuration(300).setInterpolator(new BounceInterpolator()).start();
|
||||
}
|
||||
}
|
||||
@ -207,6 +207,19 @@ public class DetailActivity extends BaseActivity implements JAdapter.OnItemClick
|
||||
}
|
||||
});
|
||||
tvPlay.requestFocus();
|
||||
|
||||
if (item.has("PartCount")) {
|
||||
String Id = Utils.getJsonString(item, "Id").getAsString();
|
||||
String AddPartUrl = "/Videos/" + Id + "/AdditionalParts?userId=" + Utils.UserId;
|
||||
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
String AddPartStr = Utils.okhttpSend(AddPartUrl);
|
||||
fillItems(AddPartStr);
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -218,24 +231,7 @@ public class DetailActivity extends BaseActivity implements JAdapter.OnItemClick
|
||||
String SeasonsUrl = "/Shows/" + SeriesId + "/Seasons?userId=" + Utils.UserId;
|
||||
SeasonsUrl += "&Fields=ItemCounts,PrimaryImageAspectRatio,BasicSyncInfo,MediaSourceCount";
|
||||
String SeasonsStr = Utils.okhttpSend(SeasonsUrl);
|
||||
ArrayList<String[]> result = new ArrayList<>();
|
||||
if (!SeasonsStr.equals("")) {
|
||||
JsonObject SeasonsObj = new Gson().fromJson(SeasonsStr, JsonObject.class);
|
||||
JsonArray Seasons = SeasonsObj.get("Items").getAsJsonArray();
|
||||
JAdapter seasonAdapter = new JAdapter(Seasons, false);
|
||||
V7LinearLayoutManager layoutManager = new V7LinearLayoutManager(mGridView.getContext());
|
||||
layoutManager.setOrientation(V7LinearLayoutManager.HORIZONTAL);
|
||||
seasonAdapter.setOnItemClickListener(this);
|
||||
mActivity.runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
mGridView.setVisibility(View.VISIBLE);
|
||||
mGridView.setLayoutManager(layoutManager);
|
||||
mGridView.setAdapter(seasonAdapter);
|
||||
dismissLoadingDialog();
|
||||
}
|
||||
});
|
||||
}
|
||||
fillItems(SeasonsStr);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -250,37 +246,42 @@ public class DetailActivity extends BaseActivity implements JAdapter.OnItemClick
|
||||
EpisodesUrl += "&userId=" + Utils.UserId;
|
||||
EpisodesUrl += "&Fields=ItemCounts,PrimaryImageAspectRatio,BasicSyncInfo,CanDelete,MediaSourceCount,Overview";
|
||||
String EpisodesStr = Utils.okhttpSend(EpisodesUrl);
|
||||
if (!EpisodesStr.equals("")) {
|
||||
JsonObject EpisodesObj = new Gson().fromJson(EpisodesStr, JsonObject.class);
|
||||
JsonArray Episodes = EpisodesObj.get("Items").getAsJsonArray();
|
||||
JAdapter episodeAdapter = new JAdapter(Episodes, false);
|
||||
V7LinearLayoutManager layoutManager = new V7LinearLayoutManager(mGridView.getContext());
|
||||
layoutManager.setOrientation(V7LinearLayoutManager.HORIZONTAL);
|
||||
episodeAdapter.setOnItemClickListener(this);
|
||||
mActivity.runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
mGridView.setVisibility(View.VISIBLE);
|
||||
mGridView.setLayoutManager(layoutManager);
|
||||
mGridView.setAdapter(episodeAdapter);
|
||||
dismissLoadingDialog();
|
||||
}
|
||||
});
|
||||
fillItems(EpisodesStr);
|
||||
}
|
||||
|
||||
public void fillItems(String jsonStr) {
|
||||
JsonObject item = Utils.JsonToObj(jsonStr, JsonObject.class);
|
||||
if (item == null) {
|
||||
return;
|
||||
}
|
||||
JsonArray items = item.get("Items").getAsJsonArray();
|
||||
JAdapter jAdapter = new JAdapter(items, false);
|
||||
V7LinearLayoutManager layoutManager = new V7LinearLayoutManager(mGridView.getContext());
|
||||
layoutManager.setOrientation(V7LinearLayoutManager.HORIZONTAL);
|
||||
jAdapter.setOnItemClickListener(this);
|
||||
mActivity.runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
mGridView.setVisibility(View.VISIBLE);
|
||||
mGridView.setLayoutManager(layoutManager);
|
||||
mGridView.setAdapter(jAdapter);
|
||||
dismissLoadingDialog();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public Video getMedia(JsonObject item) {
|
||||
//String playUrl = Utils.JellyfinUrl + "/videos/" + id + "/stream.mp4?static=true&a";
|
||||
Video media = new Video();
|
||||
media.Id = Utils.getJsonString(item,"Id").getAsString();
|
||||
media.Name = Utils.getJsonString(item,"Name").getAsString();
|
||||
media.Id = Utils.getJsonString(item, "Id").getAsString();
|
||||
media.Name = Utils.getJsonString(item, "Name").getAsString();
|
||||
JsonObject ImageTags = item.get("ImageTags").getAsJsonObject();
|
||||
if (ImageTags.has("Primary")) {
|
||||
String imgid = ImageTags.get("Primary").getAsString();
|
||||
media.cover = Utils.getImgUrl(media.Id, imgid);
|
||||
}
|
||||
media.Url = Utils.JellyfinUrl + "/videos/" + media.Id + "/stream.mp4?static=true&a";
|
||||
if (item.has("UserData")){
|
||||
if (item.has("UserData")) {
|
||||
JsonObject userdata = item.get("UserData").getAsJsonObject();
|
||||
media.startPositionTicks = userdata.get("PlaybackPositionTicks").getAsLong();
|
||||
}
|
||||
@ -293,26 +294,26 @@ public class DetailActivity extends BaseActivity implements JAdapter.OnItemClick
|
||||
String itemId = jo.get("Id").getAsString();
|
||||
String type = jo.get("Type").getAsString();
|
||||
Intent intent = null;
|
||||
if(type.equals("Season")){
|
||||
intent = new Intent(mActivity,DetailActivity.class);
|
||||
intent.putExtra("itemId",itemId);
|
||||
if (type.equals("Season")) {
|
||||
intent = new Intent(mActivity, DetailActivity.class);
|
||||
intent.putExtra("itemId", itemId);
|
||||
mActivity.startActivity(intent);
|
||||
}else if(type.equals("Episode")){
|
||||
} else if (type.equals("Episode")) {
|
||||
Utils.playList.clear();
|
||||
String Id = Utils.getJsonString(jo,"Id").getAsString();
|
||||
JAdapter JA = (JAdapter)mGridView.getAdapter();
|
||||
String Id = Utils.getJsonString(jo, "Id").getAsString();
|
||||
JAdapter JA = (JAdapter) mGridView.getAdapter();
|
||||
JsonArray ja = JA.getData();
|
||||
if(ja != null){
|
||||
for(int i=0;i<ja.size();i++){
|
||||
if (ja != null) {
|
||||
for (int i = 0; i < ja.size(); i++) {
|
||||
Video media = getMedia(ja.get(i).getAsJsonObject());
|
||||
Utils.playList.add(media);
|
||||
if(Id.equals(media.Id)){
|
||||
if (Id.equals(media.Id)) {
|
||||
Utils.playIndex = i;
|
||||
}
|
||||
}
|
||||
toVlcPlayer();
|
||||
}
|
||||
}else if(type.equals("Movie")){
|
||||
} else if (type.equals("Movie") || type.equals("Video")) {
|
||||
Utils.playList.clear();
|
||||
Utils.playList.add(getMedia(jo));
|
||||
Utils.playIndex = 0;
|
||||
@ -320,8 +321,8 @@ public class DetailActivity extends BaseActivity implements JAdapter.OnItemClick
|
||||
}
|
||||
}
|
||||
|
||||
public void toVlcPlayer(){
|
||||
Intent intent = new Intent(this,VlcPlayerActivity.class);
|
||||
public void toVlcPlayer() {
|
||||
Intent intent = new Intent(this, VlcPlayerActivity.class);
|
||||
this.startActivity(intent);
|
||||
}
|
||||
}
|
@ -116,9 +116,34 @@ public class JAdapter extends RecyclerView.Adapter {
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
int count = items.size();
|
||||
Log.d(TAG, "getItemCount: 数据总数:" + count);
|
||||
return count;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置数据
|
||||
* @param items
|
||||
*/
|
||||
public void setItems(JsonArray items){
|
||||
this.items = items;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加数据
|
||||
* @param items
|
||||
*/
|
||||
public void addItems(JsonArray items){
|
||||
int c = this.items.size();
|
||||
this.items.addAll(items);
|
||||
notifyItemRangeInserted(c,items.size());
|
||||
}
|
||||
|
||||
public void clearItems(){
|
||||
this.items = new JsonArray();
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
//定义OnItemClickListener接口
|
||||
public interface OnItemClickListener {
|
||||
void onClick(JsonObject jo);
|
||||
|
@ -69,7 +69,6 @@ public class MainActivity extends BaseActivity {
|
||||
@Override
|
||||
public void run() {
|
||||
showLoadingDialog("正在加载首页,请稍候…………");
|
||||
showLogoutBtn();
|
||||
tvContiner.removeAllViews();
|
||||
}
|
||||
});
|
||||
@ -166,7 +165,7 @@ public class MainActivity extends BaseActivity {
|
||||
mActivity.runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
showLogoutBtn();
|
||||
//showLogoutBtn();
|
||||
}
|
||||
});
|
||||
notL = false;
|
||||
@ -184,57 +183,6 @@ public class MainActivity extends BaseActivity {
|
||||
}
|
||||
}
|
||||
|
||||
private void showLogoutBtn() {
|
||||
tvLoginOut.setVisibility(View.VISIBLE);
|
||||
tvLoginOut.setText("注 销");
|
||||
tvLoginOut.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
logout();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 登 出
|
||||
*/
|
||||
private void logout() {
|
||||
SharedPreferences sp = this.getSharedPreferences("Jellyfin", this.MODE_PRIVATE);
|
||||
SharedPreferences.Editor editor = sp.edit();
|
||||
editor.clear();
|
||||
editor.commit();
|
||||
Utils.UserId = "";
|
||||
Utils.AccessToken = "";
|
||||
finish();
|
||||
}
|
||||
|
||||
/**
|
||||
* 读取配置
|
||||
*/
|
||||
private void getConfigFromSP() {
|
||||
SharedPreferences sp = this.getSharedPreferences("Jellyfin", this.MODE_PRIVATE);
|
||||
Utils.JellyfinUrl = sp.getString("url", "");
|
||||
Utils.UserName = sp.getString("username", "");
|
||||
Utils.PassWord = sp.getString("password", "");
|
||||
Utils.SortBy = sp.getString("sortby","");
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存配置
|
||||
*
|
||||
* @param url
|
||||
* @param username
|
||||
* @param password
|
||||
*/
|
||||
private void saveConfigToSP(String url, String username, String password) {
|
||||
SharedPreferences sp = this.getSharedPreferences("Jellyfin", this.MODE_PRIVATE);
|
||||
SharedPreferences.Editor editor = sp.edit();
|
||||
editor.putString("url", url);
|
||||
editor.putString("username", username);
|
||||
editor.putString("password", password);
|
||||
editor.commit();
|
||||
}
|
||||
|
||||
/**
|
||||
* 登录框
|
||||
*/
|
||||
@ -288,7 +236,7 @@ public class MainActivity extends BaseActivity {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
dialog.dismiss();
|
||||
mActivity.finish();
|
||||
System.exit(0);
|
||||
}
|
||||
});
|
||||
ll.addView(urlInput);
|
||||
|
@ -116,9 +116,6 @@ public class VlcPlayerActivity extends BaseActivity implements MediaPlayer.Event
|
||||
break;
|
||||
case MediaPlayer.Event.Buffering: //媒体加载public float getBuffering() 获取加载视频流的进度0-100
|
||||
int Buffering = (int) event.getBuffering();
|
||||
if (null == alertDialogLoading || !alertDialogLoading.isShowing()) {
|
||||
showLoadingDialog();
|
||||
}
|
||||
setLoadingText("加载进度:%" + Buffering);
|
||||
if (Buffering >= 100) {
|
||||
dismissLoadingDialog();
|
||||
|
@ -0,0 +1,5 @@
|
||||
<vector android:height="48dp" android:tint="#FFFFFF"
|
||||
android:viewportHeight="24" android:viewportWidth="24"
|
||||
android:width="48dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<path android:fillColor="@android:color/white" android:pathData="M17.51,3.87L15.73,2.1 5.84,12l9.9,9.9 1.77,-1.77L9.38,12l8.13,-8.13z"/>
|
||||
</vector>
|
@ -3,8 +3,8 @@
|
||||
<item android:state_focused="true">
|
||||
<shape>
|
||||
<corners android:radius="1dp" />
|
||||
<stroke android:width="1dp" android:color="@color/color_FFFFFF" />
|
||||
<solid android:color="@color/color_6C3D3D3D" />
|
||||
<stroke android:width="1dp" android:color="@color/color_BD0CADE2" />
|
||||
<solid android:color="@color/color_6CFFFFFF" />
|
||||
</shape>
|
||||
</item>
|
||||
<item android:state_focused="false">
|
||||
|
@ -3,8 +3,8 @@
|
||||
<item android:state_focused="true">
|
||||
<shape>
|
||||
<corners android:radius="1dp" />
|
||||
<stroke android:width="2dp" android:color="@color/color_FFFFFF" />
|
||||
<solid android:color="@color/color_6C3D3D3D" />
|
||||
<stroke android:width="2dp" android:color="@color/color_0CADE2" />
|
||||
<solid android:color="@color/color_6CFFFFFF" />
|
||||
</shape>
|
||||
</item>
|
||||
<item android:state_focused="false">
|
||||
|
@ -6,19 +6,18 @@
|
||||
android:gravity="center"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
<ImageView
|
||||
android:id="@+id/activeBar_back"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:focusable="true"
|
||||
android:gravity="center"
|
||||
android:text="《 " />
|
||||
android:background="@drawable/shape_user_focus"
|
||||
android:src="@drawable/ic_outline_arrow_back_ios_48"
|
||||
android:layout_width="20dp"
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/activeBar_banner"
|
||||
android:layout_width="100dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginLeft="@dimen/button_margin_left"
|
||||
android:scaleType="fitStart"
|
||||
app:srcCompat="@drawable/banner" />
|
||||
|
||||
@ -27,15 +26,33 @@
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:gravity="left"
|
||||
android:text=" 提示" />
|
||||
android:layout_marginLeft="@dimen/button_margin_left"
|
||||
android:gravity="center"
|
||||
android:textSize="18dp"
|
||||
android:text="" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/activeBar_titleTip"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:layout_marginLeft="@dimen/button_margin_left"
|
||||
android:gravity="center"
|
||||
android:textSize="18dp"
|
||||
android:text="" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/activeBar_sortBtn"
|
||||
android:layout_width="60dp"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:minWidth="100dp"
|
||||
android:gravity="center"
|
||||
android:focusable="true"
|
||||
android:text="排序" />
|
||||
android:textSize="18dp"
|
||||
android:layout_marginLeft="@dimen/button_margin_left"
|
||||
android:layout_marginRight="@dimen/button_margin_left"
|
||||
android:background="@drawable/shape_user_focus"
|
||||
android:text="排序"
|
||||
android:visibility="gone"/>
|
||||
|
||||
</LinearLayout>
|
@ -8,7 +8,7 @@
|
||||
android:orientation="vertical"
|
||||
tools:context=".CollectionActivity">
|
||||
|
||||
<include layout="@layout/item_title" />
|
||||
<!-- <include layout="@layout/item_title" />-->
|
||||
|
||||
<org.sifacai.vlcjellyfin.JRecyclerView
|
||||
android:id="@+id/mGridView"
|
||||
|
@ -8,7 +8,7 @@
|
||||
android:padding="@dimen/padding_border"
|
||||
tools:context=".MainActivity">
|
||||
|
||||
<include layout="@layout/item_title" />
|
||||
<!-- <include layout="@layout/item_title" />-->
|
||||
|
||||
<ScrollView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
|
@ -1,8 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="300dp"
|
||||
android:layout_height="160dp"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:background="@color/color_6CFFFFFF"
|
||||
android:orientation="vertical">
|
||||
|
||||
<ProgressBar
|
||||
@ -21,6 +22,7 @@
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:gravity="center"
|
||||
android:textSize="@dimen/title_size"
|
||||
android:text=""/>
|
||||
android:text=""
|
||||
android:visibility="gone"/>
|
||||
|
||||
</LinearLayout>
|
Loading…
Reference in New Issue
Block a user