summaryrefslogtreecommitdiffstats
path: root/app/src/main/java
diff options
context:
space:
mode:
authorstom79 <tschneider.ac@gmail.com>2019-01-14 18:16:45 +0100
committerstom79 <tschneider.ac@gmail.com>2019-01-14 18:16:45 +0100
commit937c16c0888c5201d3b39c6b3a71fd71bdc22fc5 (patch)
tree5596b98a3290db1d740397cce60ed92e6069c7cd /app/src/main/java
parent4568a4836c7dc78687deded852b406c144f4c526 (diff)
Prepare backend 3 - improve fragment
Diffstat (limited to 'app/src/main/java')
-rw-r--r--app/src/main/java/fr/gouv/etalab/mastodon/activities/BaseMainActivity.java65
-rw-r--r--app/src/main/java/fr/gouv/etalab/mastodon/drawers/ArtListAdapter.java31
-rw-r--r--app/src/main/java/fr/gouv/etalab/mastodon/drawers/PixelfedListAdapter.java76
-rw-r--r--app/src/main/java/fr/gouv/etalab/mastodon/fragments/DisplayStatusFragment.java208
-rw-r--r--app/src/main/java/fr/gouv/etalab/mastodon/helper/Helper.java14
5 files changed, 179 insertions, 215 deletions
diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/activities/BaseMainActivity.java b/app/src/main/java/fr/gouv/etalab/mastodon/activities/BaseMainActivity.java
index e48043751..bd85c0dc6 100644
--- a/app/src/main/java/fr/gouv/etalab/mastodon/activities/BaseMainActivity.java
+++ b/app/src/main/java/fr/gouv/etalab/mastodon/activities/BaseMainActivity.java
@@ -1079,35 +1079,25 @@ public abstract class BaseMainActivity extends BaseActivity
intent.putExtra("search", query);
startActivity(intent);
}else{ //Peertube search
+ DisplayStatusFragment statusFragment;
+ Bundle bundle = new Bundle();
+ statusFragment = new DisplayStatusFragment();
+ bundle.putSerializable("type", RetrieveFeedsAsyncTask.Type.REMOTE_INSTANCE);
+ bundle.putString("remote_instance", displayPeertube);
+ bundle.putString("instanceType", "PEERTUBE");
+ bundle.putString("search_peertube", query);
+ statusFragment.setArguments(bundle);
+ String fragmentTag = "REMOTE_INSTANCE";
+ FragmentManager fragmentManager = getSupportFragmentManager();
+ fragmentManager.beginTransaction()
+ .replace(R.id.main_app_container, statusFragment, fragmentTag).commit();
if( main_app_container.getVisibility() == View.GONE){
- DisplayStatusFragment statusFragment;
- Bundle bundle = new Bundle();
- statusFragment = new DisplayStatusFragment();
- bundle.putSerializable("type", RetrieveFeedsAsyncTask.Type.REMOTE_INSTANCE);
- bundle.putString("remote_instance", displayPeertube);
- bundle.putString("search_peertube", query);
- statusFragment.setArguments(bundle);
- String fragmentTag = "REMOTE_INSTANCE";
- FragmentManager fragmentManager = getSupportFragmentManager();
- fragmentManager.beginTransaction()
- .replace(R.id.main_app_container, statusFragment, fragmentTag).commit();
+
main_app_container.setVisibility(View.VISIBLE);
toolbarTitle.setVisibility(View.VISIBLE);
delete_instance.setVisibility(View.VISIBLE);
viewPager.setVisibility(View.GONE);
tabLayout.setVisibility(View.GONE);
- }else{
- DisplayStatusFragment statusFragment;
- Bundle bundle = new Bundle();
- statusFragment = new DisplayStatusFragment();
- bundle.putSerializable("type", RetrieveFeedsAsyncTask.Type.REMOTE_INSTANCE);
- bundle.putString("remote_instance", displayPeertube);
- bundle.putString("search_peertube", query);
- statusFragment.setArguments(bundle);
- String fragmentTag = "REMOTE_INSTANCE";
- FragmentManager fragmentManager = getSupportFragmentManager();
- fragmentManager.beginTransaction()
- .replace(R.id.main_app_container, statusFragment, fragmentTag).commit();
}
}
toolbar_search.setQuery("", false);
@@ -2352,7 +2342,7 @@ public abstract class BaseMainActivity extends BaseActivity
public static HashMap<String, DisplayStatusFragment> tagFragment = new HashMap<>();
/**
- * Page Adapter for Mastodon & Peertube
+ * Page Adapter for Mastodon & Peertube & PixelFed
*/
public class PagerAdapter extends FragmentStatePagerAdapter {
int mNumOfTabs;
@@ -2414,9 +2404,13 @@ public abstract class BaseMainActivity extends BaseActivity
tag = tagTimelines.get(0).getName();
bundle.putString("tag", tag);
+ if( tagTimelines != null && tagTimelines.size() > 0 && tagTimelines.get(0).isART() )
+ bundle.putString("instanceType","ART");
tagFragment.put(tag, statusFragment);
}
}
+ if (typePosition.get(position) == RetrieveFeedsAsyncTask.Type.ART)
+ bundle.putString("instanceType","ART");
statusFragment.setArguments(bundle);
return statusFragment;
}
@@ -3117,6 +3111,7 @@ public abstract class BaseMainActivity extends BaseActivity
bundle.putSerializable("type", RetrieveFeedsAsyncTask.Type.REMOTE_INSTANCE);
bundle.putString("remote_instance", remoteInstance.getHost());
bundle.putString("remote_channel_name", remoteInstance.getId());
+ bundle.putString("instanceType", "PEERTUBE");
statusFragment.setArguments(bundle);
instance_id = remoteInstance.getDbID();
String fragmentTag = "REMOTE_INSTANCE";
@@ -3148,6 +3143,7 @@ public abstract class BaseMainActivity extends BaseActivity
statusFragment = new DisplayStatusFragment();
bundle.putSerializable("type", RetrieveFeedsAsyncTask.Type.PIXELFED);
bundle.putString("remote_instance", remoteInstance.getHost());
+ bundle.putString("instanceType", "PIXELFED");
statusFragment.setArguments(bundle);
String fragmentTag = "REMOTE_INSTANCE";
instance_id = remoteInstance.getDbID();
@@ -3180,6 +3176,7 @@ public abstract class BaseMainActivity extends BaseActivity
bundle.putSerializable("type", RetrieveFeedsAsyncTask.Type.REMOTE_INSTANCE);
bundle.putString("remote_instance", remoteInstance.getHost());
statusFragment.setArguments(bundle);
+ bundle.putString("instanceType", "MISSKEY");
String fragmentTag = "REMOTE_INSTANCE";
instance_id = remoteInstance.getDbID();
FragmentManager fragmentManager = getSupportFragmentManager();
@@ -3265,17 +3262,23 @@ public abstract class BaseMainActivity extends BaseActivity
public void run() {
JSONObject resobj;
dialog.dismiss();
- if(radioGroup.getCheckedRadioButtonId() == R.id.mastodon_instance)
+ DisplayStatusFragment statusFragment;
+ Bundle bundle = new Bundle();
+ statusFragment = new DisplayStatusFragment();
+ if(radioGroup.getCheckedRadioButtonId() == R.id.mastodon_instance) {
new InstancesDAO(BaseMainActivity.this, db).insertInstance(instanceName, "MASTODON");
- else if( radioGroup.getCheckedRadioButtonId() == R.id.peertube_instance)
+ bundle.putString("instanceType", "MASTODON");
+ }else if( radioGroup.getCheckedRadioButtonId() == R.id.peertube_instance) {
new InstancesDAO(BaseMainActivity.this, db).insertInstance(instanceName, "PEERTUBE");
- else if( radioGroup.getCheckedRadioButtonId() == R.id.pixelfed_instance)
+ bundle.putString("instanceType", "PEERTUBE");
+ } else if( radioGroup.getCheckedRadioButtonId() == R.id.pixelfed_instance) {
new InstancesDAO(BaseMainActivity.this, db).insertInstance(instanceName, "PIXELFED");
- else if( radioGroup.getCheckedRadioButtonId() == R.id.misskey_instance)
+ bundle.putString("instanceType", "PIXELFED");
+ } else if( radioGroup.getCheckedRadioButtonId() == R.id.misskey_instance) {
new InstancesDAO(BaseMainActivity.this, db).insertInstance(instanceName, "MISSKEY");
- DisplayStatusFragment statusFragment;
- Bundle bundle = new Bundle();
- statusFragment = new DisplayStatusFragment();
+ bundle.putString("instanceType", "MISSKEY");
+ }
+
bundle.putSerializable("type", RetrieveFeedsAsyncTask.Type.REMOTE_INSTANCE);
bundle.putString("remote_instance", instanceName);
statusFragment.setArguments(bundle);
diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/drawers/ArtListAdapter.java b/app/src/main/java/fr/gouv/etalab/mastodon/drawers/ArtListAdapter.java
index d29f4997b..fa94be3da 100644
--- a/app/src/main/java/fr/gouv/etalab/mastodon/drawers/ArtListAdapter.java
+++ b/app/src/main/java/fr/gouv/etalab/mastodon/drawers/ArtListAdapter.java
@@ -15,7 +15,6 @@ package fr.gouv.etalab.mastodon.drawers;
* see <http://www.gnu.org/licenses>. */
import android.annotation.SuppressLint;
-import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
@@ -45,7 +44,6 @@ import fr.gouv.etalab.mastodon.R;
import fr.gouv.etalab.mastodon.activities.MediaActivity;
import fr.gouv.etalab.mastodon.activities.ShowAccountActivity;
import fr.gouv.etalab.mastodon.activities.ShowConversationActivity;
-import fr.gouv.etalab.mastodon.asynctasks.RetrieveFeedsAsyncTask;
import fr.gouv.etalab.mastodon.client.API;
import fr.gouv.etalab.mastodon.client.APIResponse;
import fr.gouv.etalab.mastodon.client.Entities.Attachment;
@@ -53,7 +51,6 @@ import fr.gouv.etalab.mastodon.client.Entities.Emojis;
import fr.gouv.etalab.mastodon.client.Entities.Error;
import fr.gouv.etalab.mastodon.client.Entities.Notification;
import fr.gouv.etalab.mastodon.client.Entities.Status;
-import fr.gouv.etalab.mastodon.client.Entities.TagTimeline;
import fr.gouv.etalab.mastodon.helper.Helper;
import fr.gouv.etalab.mastodon.interfaces.OnPostActionInterface;
import fr.gouv.etalab.mastodon.interfaces.OnRetrieveEmojiInterface;
@@ -73,38 +70,16 @@ public class ArtListAdapter extends RecyclerView.Adapter implements OnPostAction
private List<Status> statuses;
private LayoutInflater layoutInflater;
private ArtListAdapter statusListAdapter;
- private RetrieveFeedsAsyncTask.Type type;
private final int HIDDEN_STATUS = 0;
private static final int DISPLAYED_STATUS = 1;
private List<String> timedMute;
- private TagTimeline tagTimeline;
-
- public ArtListAdapter(Context context, RetrieveFeedsAsyncTask.Type type, List<Status> statuses){
- super();
- this.context = context;
- this.statuses = statuses;
- layoutInflater = LayoutInflater.from(this.context);
- statusListAdapter = this;
- this.type = type;
- }
-
- public ArtListAdapter(Context context, TagTimeline tagTimeline, List<Status> statuses){
- super();
- this.context = context;
- this.statuses = statuses;
- layoutInflater = LayoutInflater.from(this.context);
- statusListAdapter = this;
- this.type = RetrieveFeedsAsyncTask.Type.TAG;
- this.tagTimeline = tagTimeline;
- }
public ArtListAdapter(Context context, List<Status> statuses){
this.context = context;
this.statuses = statuses;
layoutInflater = LayoutInflater.from(this.context);
statusListAdapter = this;
- this.type = RetrieveFeedsAsyncTask.Type.CONTEXT;
}
public void updateMuted(List<String> timedMute){
@@ -180,7 +155,7 @@ public class ArtListAdapter extends RecyclerView.Adapter implements OnPostAction
@Override
public int getItemViewType(int position) {
- if( type != RetrieveFeedsAsyncTask.Type.REMOTE_INSTANCE && !Helper.filterToots(context, statuses.get(position), timedMute, type))
+ if( !Helper.filterToots(context, statuses.get(position), timedMute, null))
return HIDDEN_STATUS;
else
return DISPLAYED_STATUS;
@@ -189,7 +164,7 @@ public class ArtListAdapter extends RecyclerView.Adapter implements OnPostAction
@NonNull
@Override
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
- if( type == RetrieveFeedsAsyncTask.Type.ART || (tagTimeline != null && tagTimeline.isART()))
+ if( viewType != HIDDEN_STATUS)
return new ViewHolderArt(layoutInflater.inflate(R.layout.drawer_art, parent, false));
else
return new ViewHolderEmpty(layoutInflater.inflate(R.layout.drawer_empty, parent, false));
@@ -254,8 +229,6 @@ public class ArtListAdapter extends RecyclerView.Adapter implements OnPostAction
Bundle b = new Bundle();
b.putParcelable("status", status);
intent.putExtras(b);
- if (type == RetrieveFeedsAsyncTask.Type.CONTEXT)
- ((Activity) context).finish();
context.startActivity(intent);
}
});
diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/drawers/PixelfedListAdapter.java b/app/src/main/java/fr/gouv/etalab/mastodon/drawers/PixelfedListAdapter.java
index bbc47750c..4a1d12cec 100644
--- a/app/src/main/java/fr/gouv/etalab/mastodon/drawers/PixelfedListAdapter.java
+++ b/app/src/main/java/fr/gouv/etalab/mastodon/drawers/PixelfedListAdapter.java
@@ -47,8 +47,11 @@ import java.util.List;
import es.dmoral.toasty.Toasty;
import fr.gouv.etalab.mastodon.R;
+import fr.gouv.etalab.mastodon.activities.MainActivity;
import fr.gouv.etalab.mastodon.activities.MediaActivity;
-import fr.gouv.etalab.mastodon.asynctasks.RetrieveFeedsAsyncTask;
+import fr.gouv.etalab.mastodon.activities.ShowAccountActivity;
+import fr.gouv.etalab.mastodon.activities.ShowConversationActivity;
+import fr.gouv.etalab.mastodon.asynctasks.UpdateAccountInfoAsyncTask;
import fr.gouv.etalab.mastodon.client.API;
import fr.gouv.etalab.mastodon.client.APIResponse;
import fr.gouv.etalab.mastodon.client.Entities.Attachment;
@@ -56,7 +59,6 @@ import fr.gouv.etalab.mastodon.client.Entities.Emojis;
import fr.gouv.etalab.mastodon.client.Entities.Error;
import fr.gouv.etalab.mastodon.client.Entities.Notification;
import fr.gouv.etalab.mastodon.client.Entities.Status;
-import fr.gouv.etalab.mastodon.client.Entities.TagTimeline;
import fr.gouv.etalab.mastodon.client.Glide.GlideApp;
import fr.gouv.etalab.mastodon.helper.CrossActions;
import fr.gouv.etalab.mastodon.helper.Helper;
@@ -76,40 +78,20 @@ public class PixelfedListAdapter extends RecyclerView.Adapter implements OnPostA
private Context context;
private List<Status> statuses;
private LayoutInflater layoutInflater;
- private PixelfedListAdapter statusListAdapter;
- private RetrieveFeedsAsyncTask.Type type;
+ private PixelfedListAdapter pixelfedListAdapter;
private final int HIDDEN_STATUS = 0;
private static final int DISPLAYED_STATUS = 1;
private List<String> timedMute;
- private TagTimeline tagTimeline;
- public PixelfedListAdapter(Context context, RetrieveFeedsAsyncTask.Type type, List<Status> statuses){
- super();
- this.context = context;
- this.statuses = statuses;
- layoutInflater = LayoutInflater.from(this.context);
- statusListAdapter = this;
- this.type = type;
- }
-
- public PixelfedListAdapter(Context context, TagTimeline tagTimeline, List<Status> statuses){
+ public PixelfedListAdapter(Context context, List<Status> statuses){
super();
this.context = context;
this.statuses = statuses;
layoutInflater = LayoutInflater.from(this.context);
- statusListAdapter = this;
- this.type = RetrieveFeedsAsyncTask.Type.TAG;
- this.tagTimeline = tagTimeline;
+ pixelfedListAdapter = this;
}
- public PixelfedListAdapter(Context context, List<Status> statuses){
- this.context = context;
- this.statuses = statuses;
- layoutInflater = LayoutInflater.from(this.context);
- statusListAdapter = this;
- this.type = RetrieveFeedsAsyncTask.Type.CONTEXT;
- }
public void updateMuted(List<String> timedMute){
this.timedMute = timedMute;
@@ -184,7 +166,7 @@ public class PixelfedListAdapter extends RecyclerView.Adapter implements OnPostA
@Override
public int getItemViewType(int position) {
- if( type != RetrieveFeedsAsyncTask.Type.REMOTE_INSTANCE && !Helper.filterToots(context, statuses.get(position), timedMute, type))
+ if( !Helper.filterToots(context, statuses.get(position), timedMute, null))
return HIDDEN_STATUS;
else
return DISPLAYED_STATUS;
@@ -193,7 +175,7 @@ public class PixelfedListAdapter extends RecyclerView.Adapter implements OnPostA
@NonNull
@Override
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
- if( type == RetrieveFeedsAsyncTask.Type.ART || (tagTimeline != null && tagTimeline.isART()))
+ if( viewType != DISPLAYED_STATUS)
return new ViewHolderPixelfed(layoutInflater.inflate(R.layout.drawer_pixelfed, parent, false));
else
return new ViewHolderEmpty(layoutInflater.inflate(R.layout.drawer_empty, parent, false));
@@ -263,7 +245,15 @@ public class PixelfedListAdapter extends RecyclerView.Adapter implements OnPostA
holder.art_pp.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
- CrossActions.doCrossProfile(context, status.getAccount());
+ if( MainActivity.social != UpdateAccountInfoAsyncTask.SOCIAL.PIXELFED) {
+ CrossActions.doCrossProfile(context, status.getAccount());
+ }else{
+ Intent intent = new Intent(context, ShowAccountActivity.class);
+ Bundle b = new Bundle();
+ b.putParcelable("account", status.getAccount());
+ intent.putExtras(b);
+ context.startActivity(intent);
+ }
}
});
@@ -286,7 +276,15 @@ public class PixelfedListAdapter extends RecyclerView.Adapter implements OnPostA
holder.art_author.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
- CrossActions.doCrossConversation(context,status);
+ if(MainActivity.social != UpdateAccountInfoAsyncTask.SOCIAL.PIXELFED) {
+ CrossActions.doCrossConversation(context, status);
+ }else {
+ Intent intent = new Intent(context, ShowConversationActivity.class);
+ Bundle b = new Bundle();
+ b.putParcelable("status", status);
+ intent.putExtras(b);
+ context.startActivity(intent);
+ }
}
});
@@ -322,13 +320,13 @@ public class PixelfedListAdapter extends RecyclerView.Adapter implements OnPostA
statusesToRemove.add(status);
}
statuses.removeAll(statusesToRemove);
- statusListAdapter.notifyDataSetChanged();
+ pixelfedListAdapter.notifyDataSetChanged();
}else if( statusAction == API.StatusAction.UNSTATUS ){
int position = 0;
for(Status status: statuses){
if( status.getId().equals(targetedId)) {
statuses.remove(status);
- statusListAdapter.notifyItemRemoved(position);
+ pixelfedListAdapter.notifyItemRemoved(position);
SQLiteDatabase db = Sqlite.getInstance(context, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
//Remove the status from cache also
try {
@@ -347,7 +345,7 @@ public class PixelfedListAdapter extends RecyclerView.Adapter implements OnPostA
status.setPinned(true);
else
status.setPinned(false);
- statusListAdapter.notifyItemChanged(position);
+ pixelfedListAdapter.notifyItemChanged(position);
break;
}
position++;
@@ -358,7 +356,7 @@ public class PixelfedListAdapter extends RecyclerView.Adapter implements OnPostA
for(Status status: statuses){
if( status.getId().equals(targetedId)) {
statuses.remove(status);
- statusListAdapter.notifyItemRemoved(position);
+ pixelfedListAdapter.notifyItemRemoved(position);
break;
}
position++;
@@ -367,11 +365,11 @@ public class PixelfedListAdapter extends RecyclerView.Adapter implements OnPostA
}
public void notifyStatusChanged(Status status){
- for (int i = 0; i < statusListAdapter.getItemCount(); i++) {
+ for (int i = 0; i < pixelfedListAdapter.getItemCount(); i++) {
//noinspection ConstantConditions
- if (statusListAdapter.getItemAt(i) != null && statusListAdapter.getItemAt(i).getId().equals(status.getId())) {
+ if (pixelfedListAdapter.getItemAt(i) != null && pixelfedListAdapter.getItemAt(i).getId().equals(status.getId())) {
try {
- statusListAdapter.notifyItemChanged(i);
+ pixelfedListAdapter.notifyItemChanged(i);
} catch (Exception ignored) {
}
}
@@ -379,9 +377,9 @@ public class PixelfedListAdapter extends RecyclerView.Adapter implements OnPostA
}
public void notifyStatusWithActionChanged(API.StatusAction statusAction, Status status){
- for (int i = 0; i < statusListAdapter.getItemCount(); i++) {
+ for (int i = 0; i < pixelfedListAdapter.getItemCount(); i++) {
//noinspection ConstantConditions
- if (statusListAdapter.getItemAt(i) != null && statusListAdapter.getItemAt(i).getId().equals(status.getId())) {
+ if (pixelfedListAdapter.getItemAt(i) != null && pixelfedListAdapter.getItemAt(i).getId().equals(status.getId())) {
try {
int favCount = statuses.get(i).getFavourites_count();
int boostCount = statuses.get(i).getReblogs_count();
@@ -401,7 +399,7 @@ public class PixelfedListAdapter extends RecyclerView.Adapter implements OnPostA
statuses.get(i).setFavourites_count(favCount);
statuses.get(i).setReblogged(status.isReblogged());
statuses.get(i).setReblogs_count(boostCount);
- statusListAdapter.notifyItemChanged(i);
+ pixelfedListAdapter.notifyItemChanged(i);
} catch (Exception ignored) {
}
}
diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/fragments/DisplayStatusFragment.java b/app/src/main/java/fr/gouv/etalab/mastodon/fragments/DisplayStatusFragment.java
index 1ae2c43f2..4a429be82 100644
--- a/app/src/main/java/fr/gouv/etalab/mastodon/fragments/DisplayStatusFragment.java
+++ b/app/src/main/java/fr/gouv/etalab/mastodon/fragments/DisplayStatusFragment.java
@@ -60,7 +60,9 @@ import fr.gouv.etalab.mastodon.client.Entities.Peertube;
import fr.gouv.etalab.mastodon.client.Entities.RemoteInstance;
import fr.gouv.etalab.mastodon.client.Entities.Status;
import fr.gouv.etalab.mastodon.client.Entities.TagTimeline;
+import fr.gouv.etalab.mastodon.drawers.ArtListAdapter;
import fr.gouv.etalab.mastodon.drawers.PeertubeAdapter;
+import fr.gouv.etalab.mastodon.drawers.PixelfedListAdapter;
import fr.gouv.etalab.mastodon.drawers.StatusListAdapter;
import fr.gouv.etalab.mastodon.helper.Helper;
import fr.gouv.etalab.mastodon.interfaces.OnRetrieveFeedsAfterBookmarkInterface;
@@ -88,6 +90,8 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn
private AsyncTask<Void, Void, Void> asyncTask;
private StatusListAdapter statusListAdapter;
private PeertubeAdapter peertubeAdapater;
+ private ArtListAdapter artListAdapter;
+ private PixelfedListAdapter pixelfedListAdapter;
private String max_id;
private List<Status> statuses;
private List<Peertube> peertubes;
@@ -147,7 +151,7 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn
remoteInstance = bundle.getString("remote_instance", "");
search_peertube = bundle.getString("search_peertube", null);
remote_channel_name = bundle.getString("remote_channel_name", null);
- instanceType = bundle.getString("instanceType", null);
+ instanceType = bundle.getString("instanceType", "MASTODON");
ischannel = bundle.getBoolean("ischannel",false);
}
if( ischannel)
@@ -187,32 +191,39 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn
initialBookMark = sharedpreferences.getString(Helper.BOOKMARK_ID + userId + instance, null);
lastReadToot = sharedpreferences.getString(Helper.LAST_READ_TOOT_ID + userId + instance, null);
}
- if( type == RetrieveFeedsAsyncTask.Type.TAG && tag != null) {
- BaseMainActivity.displayPeertube = null;
- List<TagTimeline> tagTimelines = new SearchDAO(context, db).getTimelineInfo(tag);
- if( tagTimelines != null && tagTimelines.size() > 0) {
- tagTimeline = tagTimelines.get(0);
- statusListAdapter = new StatusListAdapter(context, tagTimeline, targetedId, isOnWifi, this.statuses);
+ if( instanceType.equals("MASTODON") || instanceType.equals("MISSKEY") ){
+ if( type == RetrieveFeedsAsyncTask.Type.TAG && tag != null) {
+ BaseMainActivity.displayPeertube = null;
+ List<TagTimeline> tagTimelines = new SearchDAO(context, db).getTimelineInfo(tag);
+ if( tagTimelines != null && tagTimelines.size() > 0) {
+ tagTimeline = tagTimelines.get(0);
+ statusListAdapter = new StatusListAdapter(context, tagTimeline, targetedId, isOnWifi, this.statuses);
+ lv_status.setAdapter(statusListAdapter);
+ }
+ }else{
+ BaseMainActivity.displayPeertube = null;
+ statusListAdapter = new StatusListAdapter(context, type, targetedId, isOnWifi, this.statuses);
lv_status.setAdapter(statusListAdapter);
}
- }else if( search_peertube == null && (instanceType == null || instanceType.equals("MASTODON") || instanceType.equals("PIXELFED") || instanceType.equals("MISSKEY"))) {
- BaseMainActivity.displayPeertube = null;
- if( instanceType != null && instanceType.equals("PIXELFED"))
- type = RetrieveFeedsAsyncTask.Type.PIXELFED;
- statusListAdapter = new StatusListAdapter(context, type, targetedId, isOnWifi, this.statuses);
- lv_status.setAdapter(statusListAdapter);
- }else {
+ }else if( instanceType.equals("PEERTUBE")){
if( remoteInstance != null && MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.PEERTUBE) //if it's a Peertube account connected
remoteInstance = account.getInstance();
BaseMainActivity.displayPeertube = remoteInstance;
peertubeAdapater = new PeertubeAdapter(context, remoteInstance, ownVideos, this.peertubes);
lv_status.setAdapter(peertubeAdapater);
+ }else if( instanceType.equals("PIXELFED")){
+ pixelfedListAdapter = new PixelfedListAdapter(context, this.statuses);
+ lv_status.setAdapter(pixelfedListAdapter);
+ }else if( instanceType.equals("ART")){
+ artListAdapter = new ArtListAdapter(context, this.statuses);
+ lv_status.setAdapter(artListAdapter);
}
mLayoutManager = new LinearLayoutManager(context);
lv_status.setLayoutManager(mLayoutManager);
- if( MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.MASTODON) {
+ //Manage broadcast receiver for Mastodon timelines
+ if( MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.MASTODON) {
if( receive_action != null)
LocalBroadcastManager.getInstance(context).unregisterReceiver(receive_action);
receive_action = new BroadcastReceiver() {
@@ -258,57 +269,38 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn
((Activity)context).setTitle(remoteInstance + " - " + search_peertube);
if( type == RetrieveFeedsAsyncTask.Type.REMOTE_INSTANCE && remote_channel_name != null)
((Activity)context).setTitle(remote_channel_name + " - " + remoteInstance);
- if( type != RetrieveFeedsAsyncTask.Type.POVERVIEW )
- lv_status.addOnScrollListener(new RecyclerView.OnScrollListener() {
- public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy)
- {
- if (type != RetrieveFeedsAsyncTask.Type.ART && context instanceof BaseMainActivity ) {
- if( dy < 0 && !((BaseMainActivity)context).getFloatingVisibility() )
- ((BaseMainActivity) context).manageFloatingButton(true);
- if( dy > 0 && ((BaseMainActivity)context).getFloatingVisibility() )
- ((BaseMainActivity) context).manageFloatingButton(false);
- }
- int firstVisibleItem = mLayoutManager.findFirstVisibleItemPosition();
- if(dy > 0){
- int visibleItemCount = mLayoutManager.getChildCount();
- int totalItemCount = mLayoutManager.getItemCount();
- if(firstVisibleItem + visibleItemCount == totalItemCount && context != null) {
- if(!flag_loading ) {
- flag_loading = true;
- if( type == RetrieveFeedsAsyncTask.Type.USER)
- asyncTask = new RetrieveFeedsAsyncTask(context, type, targetedId, max_id, showMediaOnly, showPinned, showReply, DisplayStatusFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
- else if( type == RetrieveFeedsAsyncTask.Type.TAG)
- asyncTask = new RetrieveFeedsAsyncTask(context, type, tag, targetedId, max_id, DisplayStatusFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
- else if( type == RetrieveFeedsAsyncTask.Type.REMOTE_INSTANCE || type == RetrieveFeedsAsyncTask.Type.PIXELFED) {
- if( search_peertube == null) {
- if( remote_channel_name == null)
- asyncTask = new RetrieveFeedsAsyncTask(context, type, remoteInstance, max_id, DisplayStatusFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
- else
- asyncTask = new RetrieveFeedsAsyncTask(context, remoteInstance, remote_channel_name, null,DisplayStatusFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
- }
- else
- asyncTask = new RetrievePeertubeSearchAsyncTask(context, remoteInstance, search_peertube, DisplayStatusFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
- }else{
- if( type == RetrieveFeedsAsyncTask.Type.HOME){
- asyncTask = new RetrieveFeedsAsyncTask(context, type, max_id, DisplayStatusFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
- }else {
- asyncTask = new RetrieveFeedsAsyncTask(context, type, max_id, DisplayStatusFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
- }
+ if( type != RetrieveFeedsAsyncTask.Type.POVERVIEW ) //No paginations for Peertube Overviews (it's a fixed size content
+ lv_status.addOnScrollListener(new RecyclerView.OnScrollListener() {
+ public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy)
+ {
+ if (type != RetrieveFeedsAsyncTask.Type.ART && context instanceof BaseMainActivity ) {
+ if( dy < 0 && !((BaseMainActivity)context).getFloatingVisibility() )
+ ((BaseMainActivity) context).manageFloatingButton(true);
+ if( dy > 0 && ((BaseMainActivity)context).getFloatingVisibility() )
+ ((BaseMainActivity) context).manageFloatingButton(false);
+ }
+ int firstVisibleItem = mLayoutManager.findFirstVisibleItemPosition();
+ if(dy > 0){
+ int visibleItemCount = mLayoutManager.getChildCount();
+ int totalItemCount = mLayoutManager.getItemCount();
+ if(firstVisibleItem + visibleItemCount == totalItemCount && context != null) {
+ if(!flag_loading ) {
+ flag_loading = true;
+ manageAsyncTask(true);
+ nextElementLoader.setVisibility(View.VISIBLE);
}
- nextElementLoader.setVisibility(View.VISIBLE);
+ } else {
+ nextElementLoader.setVisibility(View.GONE);
}
- } else {
- nextElementLoader.setVisibility(View.GONE);
+ }
+ if(type == RetrieveFeedsAsyncTask.Type.HOME && statuses != null && statuses.size() > firstVisibleItem && firstVisibleItem >= 0) {
+ Long bookmarkL = Long.parseLong(statuses.get(firstVisibleItem).getId()) + 1;
+ updatedBookMark = String.valueOf(bookmarkL);
+ if( lastReadToot == null || bookmarkL > Long.parseLong(lastReadToot)) //Last read toot, only incremented if the id of the toot is greater than the recorded one
+ lastReadToot = String.valueOf(bookmarkL);
}
}
- if(type == RetrieveFeedsAsyncTask.Type.HOME && statuses != null && statuses.size() > firstVisibleItem && firstVisibleItem >= 0) {
- Long bookmarkL = Long.parseLong(statuses.get(firstVisibleItem).getId()) + 1;
- updatedBookMark = String.valueOf(bookmarkL);
- if( lastReadToot == null || bookmarkL > Long.parseLong(lastReadToot)) //Last read toot, only incremented if the id of the toot is greater than the recorded one
- lastReadToot = String.valueOf(bookmarkL);
- }
- }
- });
+ });
if( instanceType == null || instanceType.equals("MASTODON") || instanceType.equals("PIXELFED"))
@@ -363,62 +355,18 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn
break;
}
if( context != null) {
- if (type == RetrieveFeedsAsyncTask.Type.USER || type == RetrieveFeedsAsyncTask.Type.CHANNEL)
- asyncTask = new RetrieveFeedsAsyncTask(context, type, targetedId, max_id, showMediaOnly, showPinned, showReply,DisplayStatusFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
- else if (type == RetrieveFeedsAsyncTask.Type.TAG)
- asyncTask = new RetrieveFeedsAsyncTask(context, type, tag, targetedId, max_id, DisplayStatusFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
- else if( type == RetrieveFeedsAsyncTask.Type.REMOTE_INSTANCE || type == RetrieveFeedsAsyncTask.Type.PIXELFED) {
- if( search_peertube == null) {
- if( remote_channel_name == null) {
-
- asyncTask = new RetrieveFeedsAsyncTask(context, type, remoteInstance, max_id, DisplayStatusFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
- }
- else
- asyncTask = new RetrieveFeedsAsyncTask(context, remoteInstance, remote_channel_name, null, DisplayStatusFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
- }
- else
- asyncTask = new RetrievePeertubeSearchAsyncTask(context, remoteInstance, search_peertube, DisplayStatusFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
- }else {
- if( type == RetrieveFeedsAsyncTask.Type.HOME ){
- if( context instanceof BaseMainActivity){
- asyncTask = new RetrieveFeedsAsyncTask(context, type, initialBookMark, DisplayStatusFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
- }
- }else {
- asyncTask = new RetrieveFeedsAsyncTask(context, type, null, DisplayStatusFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
- }
- }
+ //Load data depending of the value
+ manageAsyncTask(false);
}else {
new Handler(Looper.getMainLooper()).postDelayed(new Runnable() {
@Override
public void run() {
if( context != null){
- if (type == RetrieveFeedsAsyncTask.Type.USER)
- asyncTask = new RetrieveFeedsAsyncTask(context, type, targetedId, max_id, showMediaOnly, showPinned, showReply,DisplayStatusFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
- else if (type == RetrieveFeedsAsyncTask.Type.TAG)
- asyncTask = new RetrieveFeedsAsyncTask(context, type, tag, targetedId, max_id, Display