some cleaning
This commit is contained in:
parent
cef711a897
commit
586535840f
|
@ -112,7 +112,6 @@ public class ShowAccountActivity extends AppCompatActivity implements OnPostActi
|
||||||
private TabLayout tabLayout;
|
private TabLayout tabLayout;
|
||||||
private TextView account_note, account_follow_request;
|
private TextView account_note, account_follow_request;
|
||||||
private String userId;
|
private String userId;
|
||||||
private static int instanceValue = 0;
|
|
||||||
private Relationship relationship;
|
private Relationship relationship;
|
||||||
private boolean showMediaOnly, showPinned;
|
private boolean showMediaOnly, showPinned;
|
||||||
private ImageView pp_actionBar;
|
private ImageView pp_actionBar;
|
||||||
|
@ -148,7 +147,6 @@ public class ShowAccountActivity extends AppCompatActivity implements OnPostActi
|
||||||
}
|
}
|
||||||
setContentView(R.layout.activity_show_account);
|
setContentView(R.layout.activity_show_account);
|
||||||
setTitle("");
|
setTitle("");
|
||||||
instanceValue += 1;
|
|
||||||
pins = new ArrayList<>();
|
pins = new ArrayList<>();
|
||||||
Bundle b = getIntent().getExtras();
|
Bundle b = getIntent().getExtras();
|
||||||
account_follow = findViewById(R.id.account_follow);
|
account_follow = findViewById(R.id.account_follow);
|
||||||
|
@ -673,7 +671,6 @@ public class ShowAccountActivity extends AppCompatActivity implements OnPostActi
|
||||||
bundle.putBoolean("hideHeader",true);
|
bundle.putBoolean("hideHeader",true);
|
||||||
bundle.putBoolean("showMediaOnly",showMediaOnly);
|
bundle.putBoolean("showMediaOnly",showMediaOnly);
|
||||||
bundle.putBoolean("showPinned",showPinned);
|
bundle.putBoolean("showPinned",showPinned);
|
||||||
bundle.putString("hideHeaderValue",String.valueOf(instanceValue));
|
|
||||||
displayStatusFragment.setArguments(bundle);
|
displayStatusFragment.setArguments(bundle);
|
||||||
return displayStatusFragment;
|
return displayStatusFragment;
|
||||||
case 1:
|
case 1:
|
||||||
|
@ -681,7 +678,6 @@ public class ShowAccountActivity extends AppCompatActivity implements OnPostActi
|
||||||
bundle.putSerializable("type", RetrieveAccountsAsyncTask.Type.FOLLOWING);
|
bundle.putSerializable("type", RetrieveAccountsAsyncTask.Type.FOLLOWING);
|
||||||
bundle.putString("targetedId", accountId);
|
bundle.putString("targetedId", accountId);
|
||||||
bundle.putBoolean("hideHeader",true);
|
bundle.putBoolean("hideHeader",true);
|
||||||
bundle.putString("hideHeaderValue",String.valueOf(instanceValue));
|
|
||||||
displayAccountsFragment.setArguments(bundle);
|
displayAccountsFragment.setArguments(bundle);
|
||||||
return displayAccountsFragment;
|
return displayAccountsFragment;
|
||||||
case 2:
|
case 2:
|
||||||
|
@ -689,7 +685,6 @@ public class ShowAccountActivity extends AppCompatActivity implements OnPostActi
|
||||||
bundle.putSerializable("type", RetrieveAccountsAsyncTask.Type.FOLLOWERS);
|
bundle.putSerializable("type", RetrieveAccountsAsyncTask.Type.FOLLOWERS);
|
||||||
bundle.putString("targetedId", accountId);
|
bundle.putString("targetedId", accountId);
|
||||||
bundle.putBoolean("hideHeader",true);
|
bundle.putBoolean("hideHeader",true);
|
||||||
bundle.putString("hideHeaderValue",String.valueOf(instanceValue));
|
|
||||||
displayAccountsFragment.setArguments(bundle);
|
displayAccountsFragment.setArguments(bundle);
|
||||||
return displayAccountsFragment;
|
return displayAccountsFragment;
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,14 +14,12 @@ package fr.gouv.etalab.mastodon.fragments;
|
||||||
* You should have received a copy of the GNU General Public License along with Mastalab; if not,
|
* You should have received a copy of the GNU General Public License along with Mastalab; if not,
|
||||||
* see <http://www.gnu.org/licenses>. */
|
* see <http://www.gnu.org/licenses>. */
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Parcelable;
|
import android.os.Parcelable;
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
import android.support.v4.content.LocalBroadcastManager;
|
|
||||||
import android.support.v4.view.ViewCompat;
|
import android.support.v4.view.ViewCompat;
|
||||||
import android.support.v4.widget.SwipeRefreshLayout;
|
import android.support.v4.widget.SwipeRefreshLayout;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
|
@ -66,7 +64,6 @@ public class DisplayAccountsFragment extends Fragment implements OnRetrieveAccou
|
||||||
private String targetedId;
|
private String targetedId;
|
||||||
private boolean swiped;
|
private boolean swiped;
|
||||||
private ListView lv_accounts;
|
private ListView lv_accounts;
|
||||||
private String instanceValue;
|
|
||||||
boolean hideHeader;
|
boolean hideHeader;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -83,7 +80,6 @@ public class DisplayAccountsFragment extends Fragment implements OnRetrieveAccou
|
||||||
type = (RetrieveAccountsAsyncTask.Type) bundle.get("type");
|
type = (RetrieveAccountsAsyncTask.Type) bundle.get("type");
|
||||||
targetedId = bundle.getString("targetedId", null);
|
targetedId = bundle.getString("targetedId", null);
|
||||||
hideHeader = bundle.getBoolean("hideHeader", false);
|
hideHeader = bundle.getBoolean("hideHeader", false);
|
||||||
instanceValue = bundle.getString("hideHeaderValue", null);
|
|
||||||
if( bundle.containsKey("accounts")){
|
if( bundle.containsKey("accounts")){
|
||||||
ArrayList<Parcelable> accountsReceived = bundle.getParcelableArrayList("accounts");
|
ArrayList<Parcelable> accountsReceived = bundle.getParcelableArrayList("accounts");
|
||||||
assert accountsReceived != null;
|
assert accountsReceived != null;
|
||||||
|
@ -98,13 +94,12 @@ public class DisplayAccountsFragment extends Fragment implements OnRetrieveAccou
|
||||||
flag_loading = true;
|
flag_loading = true;
|
||||||
swiped = false;
|
swiped = false;
|
||||||
|
|
||||||
swipeRefreshLayout = (SwipeRefreshLayout) rootView.findViewById(R.id.swipeContainer);
|
swipeRefreshLayout = rootView.findViewById(R.id.swipeContainer);
|
||||||
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
lv_accounts = rootView.findViewById(R.id.lv_accounts);
|
||||||
lv_accounts = (ListView) rootView.findViewById(R.id.lv_accounts);
|
|
||||||
|
|
||||||
mainLoader = (RelativeLayout) rootView.findViewById(R.id.loader);
|
mainLoader = rootView.findViewById(R.id.loader);
|
||||||
nextElementLoader = (RelativeLayout) rootView.findViewById(R.id.loading_next_accounts);
|
nextElementLoader = rootView.findViewById(R.id.loading_next_accounts);
|
||||||
textviewNoAction = (RelativeLayout) rootView.findViewById(R.id.no_action);
|
textviewNoAction = rootView.findViewById(R.id.no_action);
|
||||||
mainLoader.setVisibility(View.VISIBLE);
|
mainLoader.setVisibility(View.VISIBLE);
|
||||||
nextElementLoader.setVisibility(View.GONE);
|
nextElementLoader.setVisibility(View.GONE);
|
||||||
accountsListAdapter = new AccountsListAdapter(context, type, targetedId, this.accounts);
|
accountsListAdapter = new AccountsListAdapter(context, type, targetedId, this.accounts);
|
||||||
|
@ -115,31 +110,11 @@ public class DisplayAccountsFragment extends Fragment implements OnRetrieveAccou
|
||||||
if (hideHeader && Build.VERSION.SDK_INT >= 21)
|
if (hideHeader && Build.VERSION.SDK_INT >= 21)
|
||||||
ViewCompat.setNestedScrollingEnabled(lv_accounts, true);
|
ViewCompat.setNestedScrollingEnabled(lv_accounts, true);
|
||||||
lv_accounts.setOnScrollListener(new AbsListView.OnScrollListener() {
|
lv_accounts.setOnScrollListener(new AbsListView.OnScrollListener() {
|
||||||
int lastFirstVisibleItem = 0;
|
|
||||||
@Override
|
@Override
|
||||||
public void onScrollStateChanged(AbsListView view, int scrollState) {
|
public void onScrollStateChanged(AbsListView view, int scrollState) {
|
||||||
|
|
||||||
}
|
}
|
||||||
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
|
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
|
||||||
if (hideHeader && Build.VERSION.SDK_INT < 21) {
|
|
||||||
if(firstVisibleItem == 0 && Helper.listIsAtTop(lv_accounts)){
|
|
||||||
Intent intent = new Intent(Helper.HEADER_ACCOUNT+instanceValue);
|
|
||||||
intent.putExtra("hide", false);
|
|
||||||
LocalBroadcastManager.getInstance(context).sendBroadcast(intent);
|
|
||||||
}else if (view.getId() == lv_accounts.getId() && totalItemCount > visibleItemCount) {
|
|
||||||
final int currentFirstVisibleItem = lv_accounts.getFirstVisiblePosition();
|
|
||||||
if (currentFirstVisibleItem > lastFirstVisibleItem) {
|
|
||||||
Intent intent = new Intent(Helper.HEADER_ACCOUNT + instanceValue);
|
|
||||||
intent.putExtra("hide", true);
|
|
||||||
LocalBroadcastManager.getInstance(context).sendBroadcast(intent);
|
|
||||||
} else if (currentFirstVisibleItem < lastFirstVisibleItem) {
|
|
||||||
Intent intent = new Intent(Helper.HEADER_ACCOUNT + instanceValue);
|
|
||||||
intent.putExtra("hide", false);
|
|
||||||
LocalBroadcastManager.getInstance(context).sendBroadcast(intent);
|
|
||||||
}
|
|
||||||
lastFirstVisibleItem = currentFirstVisibleItem;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (firstVisibleItem + visibleItemCount == totalItemCount) {
|
if (firstVisibleItem + visibleItemCount == totalItemCount) {
|
||||||
if (!flag_loading) {
|
if (!flag_loading) {
|
||||||
flag_loading = true;
|
flag_loading = true;
|
||||||
|
|
|
@ -74,8 +74,6 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn
|
||||||
private int behaviorWithAttachments;
|
private int behaviorWithAttachments;
|
||||||
private boolean showMediaOnly, showPinned;
|
private boolean showMediaOnly, showPinned;
|
||||||
private int positionSpinnerTrans;
|
private int positionSpinnerTrans;
|
||||||
private boolean hideHeader;
|
|
||||||
private String instanceValue;
|
|
||||||
private String lastReadStatus;
|
private String lastReadStatus;
|
||||||
private Intent streamingFederatedIntent, streamingLocalIntent;
|
private Intent streamingFederatedIntent, streamingLocalIntent;
|
||||||
|
|
||||||
|
@ -86,18 +84,17 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
View rootView = inflater.inflate(R.layout.fragment_status, container, false);
|
View rootView = inflater.inflate(R.layout.fragment_status, container, false);
|
||||||
statuses = new ArrayList<>();
|
statuses = new ArrayList<>();
|
||||||
|
knownId = new ArrayList<>();
|
||||||
context = getContext();
|
context = getContext();
|
||||||
Bundle bundle = this.getArguments();
|
Bundle bundle = this.getArguments();
|
||||||
boolean comesFromSearch = false;
|
boolean comesFromSearch = false;
|
||||||
hideHeader = false;
|
boolean hideHeader = false;
|
||||||
showMediaOnly = false;
|
showMediaOnly = false;
|
||||||
showPinned = false;
|
showPinned = false;
|
||||||
if (bundle != null) {
|
if (bundle != null) {
|
||||||
type = (RetrieveFeedsAsyncTask.Type) bundle.get("type");
|
type = (RetrieveFeedsAsyncTask.Type) bundle.get("type");
|
||||||
targetedId = bundle.getString("targetedId", null);
|
targetedId = bundle.getString("targetedId", null);
|
||||||
tag = bundle.getString("tag", null);
|
tag = bundle.getString("tag", null);
|
||||||
instanceValue = bundle.getString("hideHeaderValue", null);
|
|
||||||
hideHeader = bundle.getBoolean("hideHeader", false);
|
hideHeader = bundle.getBoolean("hideHeader", false);
|
||||||
showMediaOnly = bundle.getBoolean("showMediaOnly",false);
|
showMediaOnly = bundle.getBoolean("showMediaOnly",false);
|
||||||
showPinned = bundle.getBoolean("showPinned",false);
|
showPinned = bundle.getBoolean("showPinned",false);
|
||||||
|
@ -119,15 +116,15 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn
|
||||||
final SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
final SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||||
isOnWifi = Helper.isOnWIFI(context);
|
isOnWifi = Helper.isOnWIFI(context);
|
||||||
positionSpinnerTrans = sharedpreferences.getInt(Helper.SET_TRANSLATOR, Helper.TRANS_YANDEX);
|
positionSpinnerTrans = sharedpreferences.getInt(Helper.SET_TRANSLATOR, Helper.TRANS_YANDEX);
|
||||||
swipeRefreshLayout = (SwipeRefreshLayout) rootView.findViewById(R.id.swipeContainer);
|
swipeRefreshLayout = rootView.findViewById(R.id.swipeContainer);
|
||||||
behaviorWithAttachments = sharedpreferences.getInt(Helper.SET_ATTACHMENT_ACTION, Helper.ATTACHMENT_ALWAYS);
|
behaviorWithAttachments = sharedpreferences.getInt(Helper.SET_ATTACHMENT_ACTION, Helper.ATTACHMENT_ALWAYS);
|
||||||
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||||
if( type == RetrieveFeedsAsyncTask.Type.HOME)
|
if( type == RetrieveFeedsAsyncTask.Type.HOME)
|
||||||
lastReadStatus = sharedpreferences.getString(Helper.LAST_HOMETIMELINE_MAX_ID + userId, null);
|
lastReadStatus = sharedpreferences.getString(Helper.LAST_HOMETIMELINE_MAX_ID + userId, null);
|
||||||
lv_status = (ListView) rootView.findViewById(R.id.lv_status);
|
lv_status = rootView.findViewById(R.id.lv_status);
|
||||||
mainLoader = (RelativeLayout) rootView.findViewById(R.id.loader);
|
mainLoader = rootView.findViewById(R.id.loader);
|
||||||
nextElementLoader = (RelativeLayout) rootView.findViewById(R.id.loading_next_status);
|
nextElementLoader = rootView.findViewById(R.id.loading_next_status);
|
||||||
textviewNoAction = (RelativeLayout) rootView.findViewById(R.id.no_action);
|
textviewNoAction = rootView.findViewById(R.id.no_action);
|
||||||
mainLoader.setVisibility(View.VISIBLE);
|
mainLoader.setVisibility(View.VISIBLE);
|
||||||
nextElementLoader.setVisibility(View.GONE);
|
nextElementLoader.setVisibility(View.GONE);
|
||||||
statusListAdapter = new StatusListAdapter(context, type, targetedId, isOnWifi, behaviorWithAttachments, positionSpinnerTrans, this.statuses);
|
statusListAdapter = new StatusListAdapter(context, type, targetedId, isOnWifi, behaviorWithAttachments, positionSpinnerTrans, this.statuses);
|
||||||
|
@ -135,11 +132,10 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn
|
||||||
if( !comesFromSearch){
|
if( !comesFromSearch){
|
||||||
|
|
||||||
//Hide account header when scrolling for ShowAccountActivity
|
//Hide account header when scrolling for ShowAccountActivity
|
||||||
if (hideHeader )
|
if (hideHeader)
|
||||||
ViewCompat.setNestedScrollingEnabled(lv_status, true);
|
ViewCompat.setNestedScrollingEnabled(lv_status, true);
|
||||||
|
|
||||||
lv_status.setOnScrollListener(new AbsListView.OnScrollListener() {
|
lv_status.setOnScrollListener(new AbsListView.OnScrollListener() {
|
||||||
int lastFirstVisibleItem = 0;
|
|
||||||
@Override
|
@Override
|
||||||
public void onScrollStateChanged(AbsListView view, int scrollState) {
|
public void onScrollStateChanged(AbsListView view, int scrollState) {
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue