1
0
mirror of https://framagit.org/tom79/fedilab-tube synced 2025-02-17 20:40:43 +01:00

Fix an issue with overlapping views

This commit is contained in:
Thomas 2020-10-09 19:14:20 +02:00
parent c5269a3129
commit 3f1883fbbc
4 changed files with 56 additions and 18 deletions

View File

@ -123,6 +123,22 @@ public class MainActivity extends AppCompatActivity {
navView.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener); navView.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener);
Fragment fragment = getSupportFragmentManager().findFragmentByTag("5");
if(fragment != null)
getSupportFragmentManager().beginTransaction().remove(fragment).commit();
fragment = getSupportFragmentManager().findFragmentByTag("4");
if(fragment != null)
getSupportFragmentManager().beginTransaction().remove(fragment).commit();
fragment = getSupportFragmentManager().findFragmentByTag("3");
if(fragment != null)
getSupportFragmentManager().beginTransaction().remove(fragment).commit();
fragment = getSupportFragmentManager().findFragmentByTag("2");
if(fragment != null)
getSupportFragmentManager().beginTransaction().remove(fragment).commit();
fragment = getSupportFragmentManager().findFragmentByTag("1");
if(fragment != null)
getSupportFragmentManager().beginTransaction().remove(fragment).commit();
recentFragment = new DisplayVideosFragment(); recentFragment = new DisplayVideosFragment();
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();
bundle.putSerializable(Helper.TIMELINE_TYPE, TimelineVM.TimelineType.RECENT); bundle.putSerializable(Helper.TIMELINE_TYPE, TimelineVM.TimelineType.RECENT);
@ -161,7 +177,6 @@ public class MainActivity extends AppCompatActivity {
fm.beginTransaction().add(R.id.nav_host_fragment, trendingFragment, "2").hide(trendingFragment).commit(); fm.beginTransaction().add(R.id.nav_host_fragment, trendingFragment, "2").hide(trendingFragment).commit();
fm.beginTransaction().add(R.id.nav_host_fragment, overviewFragment, "1").commit(); fm.beginTransaction().add(R.id.nav_host_fragment, overviewFragment, "1").commit();
} }
toolbar.setOnClickListener(v->{ toolbar.setOnClickListener(v->{
if(active instanceof DisplayVideosFragment) { if(active instanceof DisplayVideosFragment) {
((DisplayVideosFragment) active).scrollToTop(); ((DisplayVideosFragment) active).scrollToTop();

View File

@ -66,7 +66,7 @@ public interface PeertubeService {
Call<WellKnownNodeinfo> getWellKnownNodeinfo(); Call<WellKnownNodeinfo> getWellKnownNodeinfo();
@GET("{nodeInfoPath}") @GET("{nodeInfoPath}")
Call<WellKnownNodeinfo.NodeInfo> getNodeinfo(@Path("nodeInfoPath") String nodeInfoPath); Call<WellKnownNodeinfo.NodeInfo> getNodeinfo(@Path(value = "nodeInfoPath", encoded = true) String nodeInfoPath);
@GET("{captionContent}") @GET("{captionContent}")
Call<String> getCaptionContent(@Path("captionContent") String captionContent); Call<String> getCaptionContent(@Path("captionContent") String captionContent);

View File

@ -25,6 +25,7 @@ import android.os.Looper;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.net.URL;
import java.net.URLDecoder; import java.net.URLDecoder;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
@ -959,13 +960,18 @@ public class RetrofitPeertubeAPI {
* @return APIResponse * @return APIResponse
*/ */
public WellKnownNodeinfo.NodeInfo getNodeInfo() { public WellKnownNodeinfo.NodeInfo getNodeInfo() {
PeertubeService peertubeService = init(); PeertubeService peertubeService = initTranslation();
try { try {
Call<WellKnownNodeinfo> wellKnownNodeinfoCall = peertubeService.getWellKnownNodeinfo(); Call<WellKnownNodeinfo> wellKnownNodeinfoCall = peertubeService.getWellKnownNodeinfo();
Response<WellKnownNodeinfo> response = wellKnownNodeinfoCall.execute(); Response<WellKnownNodeinfo> response = wellKnownNodeinfoCall.execute();
if (response.isSuccessful() && response.body() != null) { if (response.isSuccessful() && response.body() != null) {
if (response.body().getHref() != null) { int size = response.body().getLinks().size();
Call<WellKnownNodeinfo.NodeInfo> nodeinfo = peertubeService.getNodeinfo(response.body().getHref()); String url = response.body().getLinks().get(size - 1).getHref();
if (size > 0 && url != null) {
peertubeService = initTranslation();
String path = new URL(url).getPath();
path = path.replaceFirst("/", "").trim();
Call<WellKnownNodeinfo.NodeInfo> nodeinfo = peertubeService.getNodeinfo(path);
Response<WellKnownNodeinfo.NodeInfo> responseNodeInfo = nodeinfo.execute(); Response<WellKnownNodeinfo.NodeInfo> responseNodeInfo = nodeinfo.execute();
return responseNodeInfo.body(); return responseNodeInfo.body();
} }

View File

@ -17,8 +17,24 @@ package app.fedilab.fedilabtube.client.entities;
import com.google.gson.annotations.SerializedName; import com.google.gson.annotations.SerializedName;
import java.util.List;
@SuppressWarnings({"unused", "RedundantSuppression"}) @SuppressWarnings({"unused", "RedundantSuppression"})
public class WellKnownNodeinfo { public class WellKnownNodeinfo {
@SerializedName("links")
private List<NodeInfoLinks> links;
public List<NodeInfoLinks> getLinks() {
return links;
}
public void setLinks(List<NodeInfoLinks> links) {
this.links = links;
}
public static class NodeInfoLinks {
@SerializedName("reel") @SerializedName("reel")
private String reel; private String reel;
@SerializedName("href") @SerializedName("href")
@ -39,6 +55,7 @@ public class WellKnownNodeinfo {
public void setHref(String href) { public void setHref(String href) {
this.href = href; this.href = href;
} }
}
public static class NodeInfo { public static class NodeInfo {
@SerializedName("version") @SerializedName("version")