Refresh
This commit is contained in:
parent
5bdaf80a24
commit
bcd4ebcefa
|
@ -49,6 +49,7 @@ import android.text.Spanned;
|
|||
import android.text.method.LinkMovementMethod;
|
||||
import android.text.style.ForegroundColorSpan;
|
||||
import android.text.style.UnderlineSpan;
|
||||
import android.util.Log;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
|
@ -250,6 +251,7 @@ public class ShowAccountActivity extends BaseActivity implements OnPostActionInt
|
|||
View fake_actionbar = findViewById(R.id.fake_actionbar);
|
||||
final ImageButton account_menu = findViewById(R.id.account_menu);
|
||||
ImageButton action_more = findViewById(R.id.action_more);
|
||||
ImageButton reload_tabs = findViewById(R.id.reload_tabs);
|
||||
ImageButton action_back = findViewById(R.id.action_back);
|
||||
if(theme == Helper.THEME_LIGHT){
|
||||
fake_actionbar.setBackgroundColor(ContextCompat.getColor(ShowAccountActivity.this, R.color.light_grey));
|
||||
|
@ -272,6 +274,29 @@ public class ShowAccountActivity extends BaseActivity implements OnPostActionInt
|
|||
showMenu(account_menu);
|
||||
}
|
||||
});
|
||||
reload_tabs.setOnClickListener(view -> {
|
||||
|
||||
if( mPager != null && mPager
|
||||
.getAdapter() != null){
|
||||
if(mPager.getCurrentItem() == 0) {
|
||||
if( mPager
|
||||
.getAdapter()
|
||||
.instantiateItem(mPager, mPager.getCurrentItem()) instanceof DisplayStatusFragment){
|
||||
DisplayStatusFragment displayStatusFragment = (DisplayStatusFragment)mPager
|
||||
.getAdapter()
|
||||
.instantiateItem(mPager, mPager.getCurrentItem());
|
||||
displayStatusFragment.pullToRefresh();
|
||||
}else if( mPager
|
||||
.getAdapter()
|
||||
.instantiateItem(mPager, mPager.getCurrentItem()) instanceof DisplayAccountsFragment) {
|
||||
DisplayAccountsFragment displayAccountsFragment = (DisplayAccountsFragment) mPager
|
||||
.getAdapter()
|
||||
.instantiateItem(mPager, mPager.getCurrentItem());
|
||||
displayAccountsFragment.pullToRefresh();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
action_back.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
@ -345,9 +370,9 @@ public class ShowAccountActivity extends BaseActivity implements OnPostActionInt
|
|||
}
|
||||
|
||||
//Peertube account watched by a Mastodon account
|
||||
if( peertubeAccount && (MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.MASTODON || MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA)) {
|
||||
/*if( peertubeAccount && (MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.MASTODON || MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA)) {
|
||||
account_type.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}*/
|
||||
//Bot account
|
||||
if( account.isBot()){
|
||||
account_bot.setVisibility(View.VISIBLE);
|
||||
|
|
|
@ -18,6 +18,7 @@ import android.content.Context;
|
|||
import android.content.SharedPreferences;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
@ -25,6 +26,7 @@ import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
|||
import androidx.recyclerview.widget.DividerItemDecoration;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
@ -106,8 +108,7 @@ public class DisplayAccountsFragment extends Fragment implements OnRetrieveAccou
|
|||
mLayoutManager = new LinearLayoutManager(context);
|
||||
lv_accounts.setLayoutManager(mLayoutManager);
|
||||
lv_accounts.addOnScrollListener(new RecyclerView.OnScrollListener() {
|
||||
public void onScrolled(RecyclerView recyclerView, int dx, int dy)
|
||||
{
|
||||
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
|
||||
if (dy > 0) {
|
||||
int visibleItemCount = mLayoutManager.getChildCount();
|
||||
int totalItemCount = mLayoutManager.getItemCount();
|
||||
|
@ -179,13 +180,11 @@ public class DisplayAccountsFragment extends Fragment implements OnRetrieveAccou
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle saveInstance)
|
||||
{
|
||||
public void onCreate(Bundle saveInstance) {
|
||||
super.onCreate(saveInstance);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void onAttach(Context context) {
|
||||
super.onAttach(context);
|
||||
|
@ -284,4 +283,19 @@ public class DisplayAccountsFragment extends Fragment implements OnRetrieveAccou
|
|||
accountsListAdapter.notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public void pullToRefresh(){
|
||||
max_id = null;
|
||||
accounts = new ArrayList<>();
|
||||
firstLoad = true;
|
||||
flag_loading = true;
|
||||
swiped = true;
|
||||
swipeRefreshLayout.setRefreshing(true);
|
||||
if (type == RetrieveAccountsAsyncTask.Type.SEARCH || type == RetrieveAccountsAsyncTask.Type.FOLLOWERS || type == RetrieveAccountsAsyncTask.Type.FOLLOWING || type == RetrieveAccountsAsyncTask.Type.REBLOGGED || type == RetrieveAccountsAsyncTask.Type.FAVOURITED)
|
||||
asyncTask = new RetrieveAccountsAsyncTask(context, type, targetedId, max_id, DisplayAccountsFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
else if (type == RetrieveAccountsAsyncTask.Type.CHANNELS)
|
||||
asyncTask = new RetrieveAccountsAsyncTask(context, instance, name, DisplayAccountsFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
else
|
||||
asyncTask = new RetrieveAccountsAsyncTask(context, type, max_id, DisplayAccountsFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1113,4 +1113,39 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn
|
|||
firstLoad = false;
|
||||
}
|
||||
}
|
||||
|
||||
public void pullToRefresh() {
|
||||
if(swipeRefreshLayout != null){
|
||||
swipeRefreshLayout.setRefreshing(true);
|
||||
}else {
|
||||
return;
|
||||
}
|
||||
if (instanceType == null || !instanceType.equals("PEERTUBE")){
|
||||
if( type == RetrieveFeedsAsyncTask.Type.HOME)
|
||||
MainActivity.countNewStatus = 0;
|
||||
isSwipped = true;
|
||||
if( type != RetrieveFeedsAsyncTask.Type.CONVERSATION)
|
||||
retrieveMissingToots(null);
|
||||
else{
|
||||
if( statuses.size() > 0)
|
||||
retrieveMissingToots(statuses.get(0).getId());
|
||||
else
|
||||
retrieveMissingToots(null);
|
||||
}
|
||||
}else if( peertubes != null){
|
||||
if (peertubes.size() > 0) {
|
||||
int size = peertubes.size();
|
||||
isSwipped = true;
|
||||
peertubes.clear();
|
||||
peertubes = new ArrayList<>();
|
||||
max_id = "0";
|
||||
peertubeAdapater.notifyItemRangeRemoved(0, size);
|
||||
if (search_peertube == null) { //Not a Peertube search
|
||||
asyncTask = new RetrieveFeedsAsyncTask(context, type, remoteInstance, "0", DisplayStatusFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
} else {
|
||||
asyncTask = new RetrievePeertubeSearchAsyncTask(context, remoteInstance, search_peertube, DisplayStatusFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -472,6 +472,16 @@
|
|||
android:textSize="14sp"
|
||||
android:textColor="?attr/actionBarTextColor"
|
||||
/>
|
||||
<ImageButton
|
||||
android:background="?attr/selectableItemBackgroundBorderless"
|
||||
android:id="@+id/reload_tabs"
|
||||
android:layout_width="30dp"
|
||||
android:layout_height="30dp"
|
||||
android:layout_gravity="center"
|
||||
android:src="@drawable/ic_refresh"
|
||||
android:layout_marginEnd="10dp"
|
||||
android:gravity="center"
|
||||
android:contentDescription="@string/refresh" />
|
||||
<ImageButton
|
||||
android:background="?attr/selectableItemBackgroundBorderless"
|
||||
android:id="@+id/action_more"
|
||||
|
|
|
@ -476,6 +476,16 @@
|
|||
android:textSize="14sp"
|
||||
android:textColor="?attr/actionBarTextColor"
|
||||
/>
|
||||
<ImageButton
|
||||
android:background="?attr/selectableItemBackgroundBorderless"
|
||||
android:id="@+id/reload_tabs"
|
||||
android:layout_width="30dp"
|
||||
android:layout_height="30dp"
|
||||
android:layout_gravity="center"
|
||||
android:src="@drawable/ic_refresh"
|
||||
android:layout_marginEnd="10dp"
|
||||
android:gravity="center"
|
||||
android:contentDescription="@string/refresh" />
|
||||
<ImageButton
|
||||
android:background="?attr/selectableItemBackgroundBorderless"
|
||||
android:id="@+id/action_more"
|
||||
|
|
Loading…
Reference in New Issue