mirror of
https://github.com/sifacaii/VlcJellyfin
synced 2025-06-03 00:58:06 -04:00
添加search
This commit is contained in:
parent
02ea0ee07a
commit
8cc08ebe2e
@ -266,24 +266,7 @@ public class DetailActivity extends BaseActivity implements JAdapter.OnItemClick
|
||||
});
|
||||
}
|
||||
|
||||
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();
|
||||
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.config.getJellyfinUrl() + "/videos/" + media.Id + "/stream.mp4?static=true&a";
|
||||
if (item.has("UserData")) {
|
||||
JsonObject userdata = item.get("UserData").getAsJsonObject();
|
||||
media.startPositionTicks = userdata.get("PlaybackPositionTicks").getAsLong();
|
||||
}
|
||||
|
||||
return media;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(JsonObject jo) {
|
||||
@ -317,6 +300,30 @@ public class DetailActivity extends BaseActivity implements JAdapter.OnItemClick
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 组合播放媒体
|
||||
* @param item
|
||||
* @return
|
||||
*/
|
||||
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();
|
||||
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.config.getJellyfinUrl() + "/videos/" + media.Id + "/stream.mp4?static=true&a";
|
||||
if (item.has("UserData")) {
|
||||
JsonObject userdata = item.get("UserData").getAsJsonObject();
|
||||
media.startPositionTicks = userdata.get("PlaybackPositionTicks").getAsLong();
|
||||
}
|
||||
|
||||
return media;
|
||||
}
|
||||
|
||||
public void toVlcPlayer() {
|
||||
Intent intent = new Intent(this, VlcPlayerActivity.class);
|
||||
this.startActivity(intent);
|
||||
|
@ -107,7 +107,6 @@ public class MainActivity extends BaseActivity {
|
||||
* 添加类别行
|
||||
*/
|
||||
private void addRowTvRecyclerView(String title, JsonArray data, boolean horizon) {
|
||||
Log.d(TAG, "addRowTvRecyclerView: " + data.toString());
|
||||
JRecyclerView tvRecyclerView = (JRecyclerView) LayoutInflater.from(this)
|
||||
.inflate(R.layout.home_horizon_tvrecycler, null);
|
||||
((V7LinearLayoutManager) tvRecyclerView.getLayoutManager()).setOrientation(V7LinearLayoutManager.HORIZONTAL);
|
||||
|
@ -1,6 +1,9 @@
|
||||
package org.sifacai.vlcjellyfin;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.telecom.Call;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
@ -13,8 +16,8 @@ import com.google.gson.JsonObject;
|
||||
import com.owen.tvrecyclerview.widget.TvRecyclerView;
|
||||
import com.owen.tvrecyclerview.widget.V7GridLayoutManager;
|
||||
|
||||
public class SearchActivity extends BaseActivity{
|
||||
private TvRecyclerView mGridContiner;
|
||||
public class SearchActivity extends BaseActivity implements JAdapter.OnItemClickListener {
|
||||
private TvRecyclerView mGridView;
|
||||
private JAdapter adapter;
|
||||
private final int limit = 24;
|
||||
private String BaseUrl;
|
||||
@ -40,13 +43,14 @@ public class SearchActivity extends BaseActivity{
|
||||
}
|
||||
}
|
||||
|
||||
mGridContiner = findViewById(R.id.mGridView);
|
||||
mGridView = findViewById(R.id.mGridView);
|
||||
V7GridLayoutManager v7GridLayoutManager = new V7GridLayoutManager(this, 6);
|
||||
mGridContiner.setLayoutManager(v7GridLayoutManager);
|
||||
mGridContiner.setItemAnimator(null); //防崩溃
|
||||
mGridView.setLayoutManager(v7GridLayoutManager);
|
||||
mGridView.setItemAnimator(null); //防崩溃
|
||||
|
||||
adapter = new JAdapter(new JsonArray());
|
||||
mGridContiner.setAdapter(adapter);
|
||||
adapter.setOnItemClickListener(this);
|
||||
mGridView.setAdapter(adapter);
|
||||
|
||||
BaseUrl = "/Users/" + Utils.UserId + "/Items?";
|
||||
BaseUrl += "Fields=PrimaryImageAspectRatio,CanDelete,BasicSyncInfo,MediaSourceCount";
|
||||
@ -61,6 +65,7 @@ public class SearchActivity extends BaseActivity{
|
||||
public void onClick(View view) {
|
||||
String st = searchTermEdit.getText().toString().trim();
|
||||
if (st.length() > 0) {
|
||||
adapter.clearItems();
|
||||
Search(st);
|
||||
}
|
||||
}
|
||||
@ -95,9 +100,28 @@ public class SearchActivity extends BaseActivity{
|
||||
mAA.runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
adapter.clearItems();
|
||||
adapter.addItems(items);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(JsonObject jo) {
|
||||
String itemId = jo.get("Id").getAsString();
|
||||
String type = jo.get("Type").getAsString();
|
||||
Intent intent = null;
|
||||
switch (type) {
|
||||
case "Series":
|
||||
case "Season":
|
||||
case "Episode":
|
||||
case "Movie":
|
||||
case "Video":
|
||||
intent = new Intent(this, DetailActivity.class);
|
||||
intent.putExtra("itemId", itemId);
|
||||
this.startActivity(intent);
|
||||
break;
|
||||
default:
|
||||
ShowToask("未知媒体类型!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,20 +5,15 @@ import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.PopupMenu;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.SeekBar;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import org.videolan.libvlc.LibVLC;
|
||||
import org.videolan.libvlc.Media;
|
||||
import org.videolan.libvlc.MediaPlayer;
|
||||
import org.videolan.libvlc.interfaces.IMedia;
|
||||
import org.videolan.libvlc.util.VLCVideoLayout;
|
||||
|
||||
import java.util.Timer;
|
||||
|
@ -6,37 +6,32 @@
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="1200dp"
|
||||
android:layout_height="32dp"
|
||||
android:padding="@dimen/padding_border"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="60dp"
|
||||
android:gravity="center"
|
||||
android:paddingLeft="60dp"
|
||||
android:paddingRight="60dp"
|
||||
android:orientation="horizontal" >
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="TTTTT" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/searchTermEdit"
|
||||
android:layout_width="600dp"
|
||||
android:layout_width="0dp"
|
||||
android:layout_weight="1"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@drawable/shape_user_focus"
|
||||
android:maxLength="20"
|
||||
android:maxLines="1"
|
||||
android:focusable="true"
|
||||
android:tooltipText="关键字" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/searchBtn"
|
||||
android:layout_width="100dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_height="40dp"
|
||||
android:layout_marginLeft="@dimen/button_margin_left"
|
||||
android:focusable="true"
|
||||
android:src="@drawable/ic_outline_search_48"
|
||||
android:background="@drawable/shape_user_focus"
|
||||
android:layout_marginLeft="@dimen/button_margin_left" />
|
||||
android:src="@drawable/ic_outline_search_48" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="TTTTT" />
|
||||
</LinearLayout>
|
||||
|
||||
<org.sifacai.vlcjellyfin.JRecyclerView
|
||||
@ -49,4 +44,5 @@
|
||||
app:tv_horizontalSpacingWithMargins="@dimen/vh_space_width"
|
||||
app:tv_selectedItemIsCentered="true"
|
||||
app:tv_verticalSpacingWithMargins="@dimen/vh_space_width" />
|
||||
|
||||
</LinearLayout>
|
Loading…
x
Reference in New Issue
Block a user