Back end for timelines - #690
This commit is contained in:
parent
f9300c7af6
commit
20fae15abe
|
@ -2348,7 +2348,7 @@ public abstract class BaseMainActivity extends BaseActivity
|
||||||
}else if( position == 4) {
|
}else if( position == 4) {
|
||||||
bundle.putSerializable("type", RetrieveFeedsAsyncTask.Type.PLOCAL);
|
bundle.putSerializable("type", RetrieveFeedsAsyncTask.Type.PLOCAL);
|
||||||
}
|
}
|
||||||
|
bundle.putString("instanceType","PEERTUBE");
|
||||||
fragment.setArguments(bundle);
|
fragment.setArguments(bundle);
|
||||||
return fragment;
|
return fragment;
|
||||||
}
|
}
|
||||||
|
@ -2908,7 +2908,8 @@ public abstract class BaseMainActivity extends BaseActivity
|
||||||
federatedTimelines.setOnClickListener(new View.OnClickListener() {
|
federatedTimelines.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
new ManageListsAsyncTask(BaseMainActivity.this, ManageListsAsyncTask.action.GET_LIST, null, null, null, null, BaseMainActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
if( social == UpdateAccountInfoAsyncTask.SOCIAL.MASTODON)
|
||||||
|
new ManageListsAsyncTask(BaseMainActivity.this, ManageListsAsyncTask.action.GET_LIST, null, null, null, null, BaseMainActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||||
SQLiteDatabase db = Sqlite.getInstance(BaseMainActivity.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
SQLiteDatabase db = Sqlite.getInstance(BaseMainActivity.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||||
new InstancesDAO(BaseMainActivity.this, db).cleanDoublon();
|
new InstancesDAO(BaseMainActivity.this, db).cleanDoublon();
|
||||||
List<RemoteInstance> remoteInstances = new InstancesDAO(BaseMainActivity.this, db).getAllInstances();
|
List<RemoteInstance> remoteInstances = new InstancesDAO(BaseMainActivity.this, db).getAllInstances();
|
||||||
|
|
|
@ -26,6 +26,7 @@ import fr.gouv.etalab.mastodon.client.APIResponse;
|
||||||
import fr.gouv.etalab.mastodon.client.Entities.Peertube;
|
import fr.gouv.etalab.mastodon.client.Entities.Peertube;
|
||||||
import fr.gouv.etalab.mastodon.client.Entities.RemoteInstance;
|
import fr.gouv.etalab.mastodon.client.Entities.RemoteInstance;
|
||||||
import fr.gouv.etalab.mastodon.client.Entities.TagTimeline;
|
import fr.gouv.etalab.mastodon.client.Entities.TagTimeline;
|
||||||
|
import fr.gouv.etalab.mastodon.client.PeertubeAPI;
|
||||||
import fr.gouv.etalab.mastodon.helper.FilterToots;
|
import fr.gouv.etalab.mastodon.helper.FilterToots;
|
||||||
import fr.gouv.etalab.mastodon.interfaces.OnRetrieveFeedsInterface;
|
import fr.gouv.etalab.mastodon.interfaces.OnRetrieveFeedsInterface;
|
||||||
import fr.gouv.etalab.mastodon.sqlite.InstancesDAO;
|
import fr.gouv.etalab.mastodon.sqlite.InstancesDAO;
|
||||||
|
@ -251,6 +252,27 @@ public class RetrieveFeedsAsyncTask extends AsyncTask<Void, Void, Void> {
|
||||||
apiResponse.setSince_id(null);
|
apiResponse.setSince_id(null);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case PSUBSCRIPTIONS:
|
||||||
|
PeertubeAPI peertubeAPI = new PeertubeAPI(this.contextReference.get());
|
||||||
|
apiResponse = peertubeAPI.getSubscriptionsTL(max_id);
|
||||||
|
break;
|
||||||
|
case POVERVIEW:
|
||||||
|
peertubeAPI = new PeertubeAPI(this.contextReference.get());
|
||||||
|
apiResponse = peertubeAPI.getOverviewTL(max_id);
|
||||||
|
break;
|
||||||
|
case PTRENDING:
|
||||||
|
peertubeAPI = new PeertubeAPI(this.contextReference.get());
|
||||||
|
apiResponse = peertubeAPI.getTrendingTL(max_id);
|
||||||
|
break;
|
||||||
|
case PRECENTLYADDED:
|
||||||
|
peertubeAPI = new PeertubeAPI(this.contextReference.get());
|
||||||
|
apiResponse = peertubeAPI.getRecentlyAddedTL(max_id);
|
||||||
|
break;
|
||||||
|
case PLOCAL:
|
||||||
|
peertubeAPI = new PeertubeAPI(this.contextReference.get());
|
||||||
|
apiResponse = peertubeAPI.getLocalTL(max_id);
|
||||||
|
break;
|
||||||
case HASHTAG:
|
case HASHTAG:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,6 +42,8 @@ public class Peertube {
|
||||||
private Account account;
|
private Account account;
|
||||||
private List<String> resolution;
|
private List<String> resolution;
|
||||||
private boolean commentsEnabled;
|
private boolean commentsEnabled;
|
||||||
|
private boolean sensitive;
|
||||||
|
|
||||||
private JSONObject cache;
|
private JSONObject cache;
|
||||||
|
|
||||||
public Peertube() {
|
public Peertube() {
|
||||||
|
@ -217,4 +219,12 @@ public class Peertube {
|
||||||
public void setCache(JSONObject cache) {
|
public void setCache(JSONObject cache) {
|
||||||
this.cache = cache;
|
this.cache = cache;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isSensitive() {
|
||||||
|
return sensitive;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSensitive(boolean sensitive) {
|
||||||
|
this.sensitive = sensitive;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -706,29 +706,64 @@ public class PeertubeAPI {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves home timeline for the account *synchronously*
|
* Retrieves subscription videos *synchronously*
|
||||||
* @param max_id String id max
|
* @param max_id String id max
|
||||||
* @return APIResponse
|
* @return APIResponse
|
||||||
*/
|
*/
|
||||||
public APIResponse getHomeTimeline( String max_id) {
|
public APIResponse getSubscriptionsTL( String max_id) {
|
||||||
return getHomeTimeline(max_id, null, null, tootPerPage);
|
return getTL("/users/me/subscriptions/videos",null,null, max_id, null, null, tootPerPage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves overview videos *synchronously*
|
||||||
|
* @param max_id String id max
|
||||||
|
* @return APIResponse
|
||||||
|
*/
|
||||||
|
public APIResponse getOverviewTL( String max_id) {
|
||||||
|
return getTL("/overviews/videos",null,null, max_id, null, null, tootPerPage);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves trending videos *synchronously*
|
||||||
|
* @param max_id String id max
|
||||||
|
* @return APIResponse
|
||||||
|
*/
|
||||||
|
public APIResponse getTrendingTL( String max_id) {
|
||||||
|
return getTL("/videos/","trending", null,max_id, null, null, tootPerPage);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves trending videos *synchronously*
|
||||||
|
* @param max_id String id max
|
||||||
|
* @return APIResponse
|
||||||
|
*/
|
||||||
|
public APIResponse getRecentlyAddedTL( String max_id) {
|
||||||
|
return getTL("/videos/","-publishedAt",null,max_id, null, null, tootPerPage);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves trending videos *synchronously*
|
||||||
|
* @param max_id String id max
|
||||||
|
* @return APIResponse
|
||||||
|
*/
|
||||||
|
public APIResponse getLocalTL( String max_id) {
|
||||||
|
return getTL("/videos/",null, "local",max_id, null, null, tootPerPage);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves home timeline for the account since an Id value *synchronously*
|
* Retrieves home timeline for the account since an Id value *synchronously*
|
||||||
* @return APIResponse
|
* @return APIResponse
|
||||||
*/
|
*/
|
||||||
public APIResponse getHomeTimelineSinceId(String since_id) {
|
public APIResponse getSubscriptionsTLSinceId(String since_id) {
|
||||||
return getHomeTimeline(null, since_id, null, tootPerPage);
|
return getTL("/users/me/subscriptions/videos",null,null,null, since_id, null, tootPerPage);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves home timeline for the account from a min Id value *synchronously*
|
* Retrieves home timeline for the account from a min Id value *synchronously*
|
||||||
* @return APIResponse
|
* @return APIResponse
|
||||||
*/
|
*/
|
||||||
public APIResponse getHomeTimelineMinId(String min_id) {
|
public APIResponse getSubscriptionsTLMinId(String min_id) {
|
||||||
return getHomeTimeline(null, null, min_id, tootPerPage);
|
return getTL("/users/me/subscriptions/videos",null, null,null, null, min_id, tootPerPage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -739,54 +774,31 @@ public class PeertubeAPI {
|
||||||
* @param limit int limit - max value 40
|
* @param limit int limit - max value 40
|
||||||
* @return APIResponse
|
* @return APIResponse
|
||||||
*/
|
*/
|
||||||
private APIResponse getHomeTimeline(String max_id, String since_id, String min_id, int limit) {
|
private APIResponse getTL(String action, String sort, String filter, String max_id, String since_id, String min_id, int limit) {
|
||||||
|
|
||||||
HashMap<String, String> params = new HashMap<>();
|
HashMap<String, String> params = new HashMap<>();
|
||||||
if (max_id != null)
|
if (max_id != null)
|
||||||
params.put("max_id", max_id);
|
params.put("start", max_id);
|
||||||
if (since_id != null)
|
if (since_id != null)
|
||||||
params.put("since_id", since_id);
|
params.put("since_id", since_id);
|
||||||
if (min_id != null)
|
if (min_id != null)
|
||||||
params.put("min_id", min_id);
|
params.put("min_id", min_id);
|
||||||
if (0 > limit || limit > 80)
|
if (0 > limit || limit > 80)
|
||||||
limit = 80;
|
limit = 80;
|
||||||
params.put("limit",String.valueOf(limit));
|
params.put("count",String.valueOf(limit));
|
||||||
statuses = new ArrayList<>();
|
if( sort != null)
|
||||||
|
params.put("sort",sort);
|
||||||
|
else
|
||||||
|
params.put("sort","publishedAt");
|
||||||
|
if( filter != null)
|
||||||
|
params.put("filter",filter);
|
||||||
|
|
||||||
|
List<Peertube> peertubes = new ArrayList<>();
|
||||||
try {
|
try {
|
||||||
HttpsConnection httpsConnection = new HttpsConnection(context);
|
HttpsConnection httpsConnection = new HttpsConnection(context);
|
||||||
String response = httpsConnection.get(getAbsoluteUrl("/timelines/home"), 60, params, prefKeyOauthTokenT);
|
String response = httpsConnection.get(getAbsoluteUrl(action), 60, params, prefKeyOauthTokenT);
|
||||||
apiResponse.setSince_id(httpsConnection.getSince_id());
|
JSONArray values = new JSONObject(response).getJSONArray("data");
|
||||||
apiResponse.setMax_id(httpsConnection.getMax_id());
|
peertubes = parsePeertube(values);
|
||||||
statuses = parseStatuses(context, new JSONArray(response));
|
|
||||||
/*if( response != null) {
|
|
||||||
Thread thread = new Thread() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
try {
|
|
||||||
List<Status> statuses;
|
|
||||||
statuses = API.parseStatuses(context, new JSONArray(response));
|
|
||||||
SQLiteDatabase db = Sqlite.getInstance(context, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
|
||||||
|
|
||||||
List<Status> alreadyCached = new TimelineCacheDAO(context, db).getAllStatus(TimelineCacheDAO.HOME_TIMELINE);
|
|
||||||
ArrayList<String> cachedId = new ArrayList<>();
|
|
||||||
if(alreadyCached != null){
|
|
||||||
for(Status status: alreadyCached){
|
|
||||||
cachedId.add(status.getId());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for(Status status: statuses){
|
|
||||||
if(!cachedId.contains(status.getId())){
|
|
||||||
new TimelineCacheDAO(context, db).insertStatus(TimelineCacheDAO.HOME_TIMELINE, status, prefKeyOauthTokenT);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (JSONException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
thread.start();
|
|
||||||
}*/
|
|
||||||
} catch (HttpsConnection.HttpsConnectionException e) {
|
} catch (HttpsConnection.HttpsConnectionException e) {
|
||||||
setError(e.getStatusCode(), e);
|
setError(e.getStatusCode(), e);
|
||||||
} catch (NoSuchAlgorithmException e) {
|
} catch (NoSuchAlgorithmException e) {
|
||||||
|
@ -798,43 +810,13 @@ public class PeertubeAPI {
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
apiResponse.setStatuses(statuses);
|
apiResponse.setPeertubes(peertubes);
|
||||||
return apiResponse;
|
return apiResponse;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieves public pixelfed timeline for the account *synchronously*
|
|
||||||
* @param max_id String id max
|
|
||||||
* @return APIResponse
|
|
||||||
*/
|
|
||||||
public APIResponse getPixelfedTimeline(String remoteInstance, String max_id) {
|
|
||||||
|
|
||||||
HashMap<String, String> params = new HashMap<>();
|
|
||||||
if (max_id != null)
|
|
||||||
params.put("page", max_id);
|
|
||||||
statuses = new ArrayList<>();
|
|
||||||
try {
|
|
||||||
HttpsConnection httpsConnection = new HttpsConnection(context);
|
|
||||||
String response = httpsConnection.get(getAbsoluteUrlRemote(remoteInstance, "/timelines/public/"), 60, params, prefKeyOauthTokenT);
|
|
||||||
apiResponse.setSince_id(httpsConnection.getSince_id());
|
|
||||||
apiResponse.setMax_id(httpsConnection.getMax_id());
|
|
||||||
statuses = parseStatuses(context, new JSONArray(response));
|
|
||||||
} catch (HttpsConnection.HttpsConnectionException e) {
|
|
||||||
setError(e.getStatusCode(), e);
|
|
||||||
} catch (NoSuchAlgorithmException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
} catch (KeyManagementException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
} catch (JSONException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
apiResponse.setStatuses(statuses);
|
|
||||||
return apiResponse;
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* Retrieves Peertube videos from an instance *synchronously*
|
* Retrieves Peertube videos from an instance *synchronously*
|
||||||
* @return APIResponse
|
* @return APIResponse
|
||||||
|
@ -874,7 +856,7 @@ public class PeertubeAPI {
|
||||||
HttpsConnection httpsConnection = new HttpsConnection(context);
|
HttpsConnection httpsConnection = new HttpsConnection(context);
|
||||||
String response = httpsConnection.get(String.format("https://"+instance+"/api/v1/video-channels/%s/videos", name), 60, null, null);
|
String response = httpsConnection.get(String.format("https://"+instance+"/api/v1/video-channels/%s/videos", name), 60, null, null);
|
||||||
JSONArray jsonArray = new JSONObject(response).getJSONArray("data");
|
JSONArray jsonArray = new JSONObject(response).getJSONArray("data");
|
||||||
peertubes = parsePeertube(instance, jsonArray);
|
peertubes = parsePeertube(jsonArray);
|
||||||
} catch (HttpsConnection.HttpsConnectionException e) {
|
} catch (HttpsConnection.HttpsConnectionException e) {
|
||||||
setError(e.getStatusCode(), e);
|
setError(e.getStatusCode(), e);
|
||||||
} catch (NoSuchAlgorithmException e) {
|
} catch (NoSuchAlgorithmException e) {
|
||||||
|
@ -906,7 +888,7 @@ public class PeertubeAPI {
|
||||||
HttpsConnection httpsConnection = new HttpsConnection(context);
|
HttpsConnection httpsConnection = new HttpsConnection(context);
|
||||||
String response = httpsConnection.get("https://"+instance+"/api/v1/videos", 60, params, null);
|
String response = httpsConnection.get("https://"+instance+"/api/v1/videos", 60, params, null);
|
||||||
JSONArray jsonArray = new JSONObject(response).getJSONArray("data");
|
JSONArray jsonArray = new JSONObject(response).getJSONArray("data");
|
||||||
peertubes = parsePeertube(instance, jsonArray);
|
peertubes = parsePeertube(jsonArray);
|
||||||
} catch (HttpsConnection.HttpsConnectionException e) {
|
} catch (HttpsConnection.HttpsConnectionException e) {
|
||||||
setError(e.getStatusCode(), e);
|
setError(e.getStatusCode(), e);
|
||||||
} catch (NoSuchAlgorithmException e) {
|
} catch (NoSuchAlgorithmException e) {
|
||||||
|
@ -971,7 +953,7 @@ public class PeertubeAPI {
|
||||||
HttpsConnection httpsConnection = new HttpsConnection(context);
|
HttpsConnection httpsConnection = new HttpsConnection(context);
|
||||||
String response = httpsConnection.get("https://"+instance+"/api/v1/search/videos", 60, params, null);
|
String response = httpsConnection.get("https://"+instance+"/api/v1/search/videos", 60, params, null);
|
||||||
JSONArray jsonArray = new JSONObject(response).getJSONArray("data");
|
JSONArray jsonArray = new JSONObject(response).getJSONArray("data");
|
||||||
peertubes = parsePeertube(instance, jsonArray);
|
peertubes = parsePeertube(jsonArray);
|
||||||
} catch (HttpsConnection.HttpsConnectionException e) {
|
} catch (HttpsConnection.HttpsConnectionException e) {
|
||||||
setError(e.getStatusCode(), e);
|
setError(e.getStatusCode(), e);
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
@ -2818,14 +2800,14 @@ public class PeertubeAPI {
|
||||||
* @param jsonArray JSONArray
|
* @param jsonArray JSONArray
|
||||||
* @return List<Peertube>
|
* @return List<Peertube>
|
||||||
*/
|
*/
|
||||||
private List<Peertube> parsePeertube(String instance, JSONArray jsonArray){
|
private List<Peertube> parsePeertube(JSONArray jsonArray){
|
||||||
|
|
||||||
List<Peertube> peertubes = new ArrayList<>();
|
List<Peertube> peertubes = new ArrayList<>();
|
||||||
try {
|
try {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
while (i < jsonArray.length() ){
|
while (i < jsonArray.length() ){
|
||||||
JSONObject resobj = jsonArray.getJSONObject(i);
|
JSONObject resobj = jsonArray.getJSONObject(i);
|
||||||
Peertube peertube = parsePeertube(context, instance, resobj);
|
Peertube peertube = parsePeertube(context, resobj);
|
||||||
i++;
|
i++;
|
||||||
peertubes.add(peertube);
|
peertubes.add(peertube);
|
||||||
}
|
}
|
||||||
|
@ -2841,7 +2823,7 @@ public class PeertubeAPI {
|
||||||
* @param resobj JSONObject
|
* @param resobj JSONObject
|
||||||
* @return Peertube
|
* @return Peertube
|
||||||
*/
|
*/
|
||||||
public static Peertube parsePeertube(Context context, String instance, JSONObject resobj){
|
public static Peertube parsePeertube(Context context,JSONObject resobj){
|
||||||
Peertube peertube = new Peertube();
|
Peertube peertube = new Peertube();
|
||||||
try {
|
try {
|
||||||
peertube.setId(resobj.get("id").toString());
|
peertube.setId(resobj.get("id").toString());
|
||||||
|
@ -2853,11 +2835,11 @@ public class PeertubeAPI {
|
||||||
peertube.setPreviewPath(resobj.get("previewPath").toString());
|
peertube.setPreviewPath(resobj.get("previewPath").toString());
|
||||||
peertube.setThumbnailPath(resobj.get("thumbnailPath").toString());
|
peertube.setThumbnailPath(resobj.get("thumbnailPath").toString());
|
||||||
peertube.setAccount(parseAccountResponsePeertube(context, resobj.getJSONObject("account")));
|
peertube.setAccount(parseAccountResponsePeertube(context, resobj.getJSONObject("account")));
|
||||||
peertube.setInstance(instance);
|
|
||||||
peertube.setView(Integer.parseInt(resobj.get("views").toString()));
|
peertube.setView(Integer.parseInt(resobj.get("views").toString()));
|
||||||
peertube.setLike(Integer.parseInt(resobj.get("likes").toString()));
|
peertube.setLike(Integer.parseInt(resobj.get("likes").toString()));
|
||||||
peertube.setDislike(Integer.parseInt(resobj.get("dislikes").toString()));
|
peertube.setDislike(Integer.parseInt(resobj.get("dislikes").toString()));
|
||||||
peertube.setDuration(Integer.parseInt(resobj.get("duration").toString()));
|
peertube.setDuration(Integer.parseInt(resobj.get("duration").toString()));
|
||||||
|
peertube.setSensitive(Boolean.parseBoolean(resobj.get("nsfw").toString()));
|
||||||
try {
|
try {
|
||||||
peertube.setCreated_at(Helper.mstStringToDate(context, resobj.get("createdAt").toString()));
|
peertube.setCreated_at(Helper.mstStringToDate(context, resobj.get("createdAt").toString()));
|
||||||
} catch (ParseException e) {
|
} catch (ParseException e) {
|
||||||
|
|
|
@ -78,6 +78,8 @@ public class PeertubeAdapter extends RecyclerView.Adapter implements OnListActio
|
||||||
|
|
||||||
final PeertubeAdapter.ViewHolder holder = (PeertubeAdapter.ViewHolder) viewHolder;
|
final PeertubeAdapter.ViewHolder holder = (PeertubeAdapter.ViewHolder) viewHolder;
|
||||||
final Peertube peertube = peertubes.get(position);
|
final Peertube peertube = peertubes.get(position);
|
||||||
|
if( peertube.getInstance() == null)
|
||||||
|
peertube.setInstance(Helper.getLiveInstance(context));
|
||||||
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||||
int theme = sharedpreferences.getInt(Helper.SET_THEME, Helper.THEME_DARK);
|
int theme = sharedpreferences.getInt(Helper.SET_THEME, Helper.THEME_DARK);
|
||||||
if( theme == Helper.THEME_LIGHT){
|
if( theme == Helper.THEME_LIGHT){
|
||||||
|
@ -105,6 +107,8 @@ public class PeertubeAdapter extends RecyclerView.Adapter implements OnListActio
|
||||||
Glide.with(holder.peertube_video_image.getContext())
|
Glide.with(holder.peertube_video_image.getContext())
|
||||||
.load("https://" + peertube.getInstance() + peertube.getThumbnailPath())
|
.load("https://" + peertube.getInstance() + peertube.getThumbnailPath())
|
||||||
.into(holder.peertube_video_image);
|
.into(holder.peertube_video_image);
|
||||||
|
if( account.getAvatar() != null && !account.getAvatar().startsWith("http"))
|
||||||
|
account.setAvatar("https://" + peertube.getInstance() + account.getAvatar());
|
||||||
Helper.loadGiF(context, account.getAvatar(), holder.peertube_profile);
|
Helper.loadGiF(context, account.getAvatar(), holder.peertube_profile);
|
||||||
holder.main_container.setOnClickListener(new View.OnClickListener() {
|
holder.main_container.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -137,10 +137,11 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn
|
||||||
remoteInstance = bundle.getString("remote_instance", "");
|
remoteInstance = bundle.getString("remote_instance", "");
|
||||||
search_peertube = bundle.getString("search_peertube", null);
|
search_peertube = bundle.getString("search_peertube", null);
|
||||||
remote_channel_name = bundle.getString("remote_channel_name", null);
|
remote_channel_name = bundle.getString("remote_channel_name", null);
|
||||||
|
instanceType = bundle.getString("instanceType", null);
|
||||||
}
|
}
|
||||||
SQLiteDatabase db = Sqlite.getInstance(context, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
SQLiteDatabase db = Sqlite.getInstance(context, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||||
if( !remoteInstance.equals("")){
|
//instanceType should not be null only for Peertube accounts
|
||||||
|
if( !remoteInstance.equals("") && instanceType == null){
|
||||||
List<RemoteInstance> remoteInstanceObj = new InstancesDAO(context, db).getInstanceByName(remoteInstance);
|
List<RemoteInstance> remoteInstanceObj = new InstancesDAO(context, db).getInstanceByName(remoteInstance);
|
||||||
if( remoteInstanceObj != null && remoteInstanceObj.size() > 0)
|
if( remoteInstanceObj != null && remoteInstanceObj.size() > 0)
|
||||||
instanceType = remoteInstanceObj.get(0).getType();
|
instanceType = remoteInstanceObj.get(0).getType();
|
||||||
|
@ -186,6 +187,8 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn
|
||||||
statusListAdapter = new StatusListAdapter(context, type, targetedId, isOnWifi, this.statuses);
|
statusListAdapter = new StatusListAdapter(context, type, targetedId, isOnWifi, this.statuses);
|
||||||
lv_status.setAdapter(statusListAdapter);
|
lv_status.setAdapter(statusListAdapter);
|
||||||
}else {
|
}else {
|
||||||
|
if( remoteInstance != null) //if it's a Peertube account connected
|
||||||
|
remoteInstance = account.getInstance();
|
||||||
BaseMainActivity.displayPeertube = remoteInstance;
|
BaseMainActivity.displayPeertube = remoteInstance;
|
||||||
peertubeAdapater = new PeertubeAdapter(context, remoteInstance, this.peertubes);
|
peertubeAdapater = new PeertubeAdapter(context, remoteInstance, this.peertubes);
|
||||||
lv_status.setAdapter(peertubeAdapater);
|
lv_status.setAdapter(peertubeAdapater);
|
||||||
|
@ -416,7 +419,7 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//For remote Peertube remote instances
|
//For remote Peertube remote instances
|
||||||
if(( type == RetrieveFeedsAsyncTask.Type.REMOTE_INSTANCE ) && peertubeAdapater != null){
|
if(( instanceType != null && instanceType.equals("PEERTUBE") || (type == RetrieveFeedsAsyncTask.Type.REMOTE_INSTANCE ) && peertubeAdapater != null)){
|
||||||
int previousPosition = this.peertubes.size();
|
int previousPosition = this.peertubes.size();
|
||||||
if( max_id == null)
|
if( max_id == null)
|
||||||
max_id = "0";
|
max_id = "0";
|
||||||
|
|
Loading…
Reference in New Issue