Prepare backend 3 - improve fragment
This commit is contained in:
parent
4568a4836c
commit
937c16c088
|
@ -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)
|
||||
new InstancesDAO(BaseMainActivity.this, db).insertInstance(instanceName, "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)
|
||||
new InstancesDAO(BaseMainActivity.this, db).insertInstance(instanceName, "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();
|
||||
if(radioGroup.getCheckedRadioButtonId() == R.id.mastodon_instance) {
|
||||
new InstancesDAO(BaseMainActivity.this, db).insertInstance(instanceName, "MASTODON");
|
||||
bundle.putString("instanceType", "MASTODON");
|
||||
}else if( radioGroup.getCheckedRadioButtonId() == R.id.peertube_instance) {
|
||||
new InstancesDAO(BaseMainActivity.this, db).insertInstance(instanceName, "PEERTUBE");
|
||||
bundle.putString("instanceType", "PEERTUBE");
|
||||
} else if( radioGroup.getCheckedRadioButtonId() == R.id.pixelfed_instance) {
|
||||
new InstancesDAO(BaseMainActivity.this, db).insertInstance(instanceName, "PIXELFED");
|
||||
bundle.putString("instanceType", "PIXELFED");
|
||||
} else if( radioGroup.getCheckedRadioButtonId() == R.id.misskey_instance) {
|
||||
new InstancesDAO(BaseMainActivity.this, db).insertInstance(instanceName, "MISSKEY");
|
||||
bundle.putString("instanceType", "MISSKEY");
|
||||
}
|
||||
|
||||
bundle.putSerializable("type", RetrieveFeedsAsyncTask.Type.REMOTE_INSTANCE);
|
||||
bundle.putString("remote_instance", instanceName);
|
||||
statusFragment.setArguments(bundle);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -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,41 +78,21 @@ 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){
|
||||
super();
|
||||
this.context = context;
|
||||
this.statuses = statuses;
|
||||
layoutInflater = LayoutInflater.from(this.context);
|
||||
statusListAdapter = this;
|
||||
this.type = RetrieveFeedsAsyncTask.Type.TAG;
|
||||
this.tagTimeline = tagTimeline;
|
||||
}
|
||||
|
||||
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.CONTEXT;
|
||||
pixelfedListAdapter = this;
|
||||
}
|
||||
|
||||
|
||||
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) {
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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, 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);
|
||||
}
|
||||
}
|
||||
manageAsyncTask(false);
|
||||
}
|
||||
}
|
||||
}, 500);
|
||||
}
|
||||
|
||||
return rootView;
|
||||
}
|
||||
|
||||
|
@ -480,7 +428,7 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn
|
|||
}
|
||||
|
||||
//For remote Peertube remote instances
|
||||
if(( MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.PEERTUBE || instanceType != null && instanceType.equals("PEERTUBE") || (type == RetrieveFeedsAsyncTask.Type.REMOTE_INSTANCE ) && peertubeAdapater != null)){
|
||||
if(instanceType.equals("PEERTUBE")){
|
||||
int previousPosition = this.peertubes.size();
|
||||
if( max_id == null)
|
||||
max_id = "0";
|
||||
|
@ -531,7 +479,7 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn
|
|||
//At this point all statuses are in "List<Status> statuses"
|
||||
|
||||
//Pagination for Pixelfed
|
||||
if(type == RetrieveFeedsAsyncTask.Type.PIXELFED) {
|
||||
if(instanceType.equals("PIXELFED")) {
|
||||
if( max_id == null)
|
||||
max_id = "1";
|
||||
//max_id needs to work like an offset
|
||||
|
@ -976,4 +924,42 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn
|
|||
}
|
||||
}
|
||||
|
||||
private void manageAsyncTask(boolean pagination){
|
||||
//Message for an account
|
||||
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);
|
||||
//Tag timelines
|
||||
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) {
|
||||
//Remote instances
|
||||
if( search_peertube == null) { //Not a Peertube search
|
||||
if( remote_channel_name == null) { //Not a channel
|
||||
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( !pagination) {
|
||||
if (type == RetrieveFeedsAsyncTask.Type.HOME) {
|
||||
if (context instanceof BaseMainActivity) {
|
||||
asyncTask = new RetrieveFeedsAsyncTask(context, type, initialBookMark, DisplayStatusFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
}
|
||||
} else { //Most classical search will be done by this call
|
||||
asyncTask = new RetrieveFeedsAsyncTask(context, type, null, 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 {//Most classical search will be done by this call for pagination
|
||||
asyncTask = new RetrieveFeedsAsyncTask(context, type, max_id, DisplayStatusFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -3089,12 +3089,16 @@ public class Helper {
|
|||
if( status == null)
|
||||
return true;
|
||||
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
if( type == RetrieveFeedsAsyncTask.Type.HOME)
|
||||
filter = sharedpreferences.getString(Helper.SET_FILTER_REGEX_HOME, null);
|
||||
else if( type == RetrieveFeedsAsyncTask.Type.LOCAL)
|
||||
filter = sharedpreferences.getString(Helper.SET_FILTER_REGEX_LOCAL, null);
|
||||
else
|
||||
if( type != null) {
|
||||
if (type == RetrieveFeedsAsyncTask.Type.HOME)
|
||||
filter = sharedpreferences.getString(Helper.SET_FILTER_REGEX_HOME, null);
|
||||
else if (type == RetrieveFeedsAsyncTask.Type.LOCAL)
|
||||
filter = sharedpreferences.getString(Helper.SET_FILTER_REGEX_LOCAL, null);
|
||||
else
|
||||
filter = sharedpreferences.getString(Helper.SET_FILTER_REGEX_PUBLIC, null);
|
||||
}else {
|
||||
filter = sharedpreferences.getString(Helper.SET_FILTER_REGEX_PUBLIC, null);
|
||||
}
|
||||
|
||||
String content = status.getContent();
|
||||
if( status.getSpoiler_text() != null)
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<api name="value"></api>
|
||||
</resources>
|
Loading…
Reference in New Issue