|
|
@ -30,6 +30,7 @@ import androidx.annotation.NonNull; |
|
|
|
import androidx.annotation.Nullable; |
|
|
|
import androidx.annotation.Nullable; |
|
|
|
import androidx.core.content.ContextCompat; |
|
|
|
import androidx.core.content.ContextCompat; |
|
|
|
import androidx.fragment.app.Fragment; |
|
|
|
import androidx.fragment.app.Fragment; |
|
|
|
|
|
|
|
import androidx.fragment.app.FragmentActivity; |
|
|
|
import androidx.lifecycle.ViewModelProvider; |
|
|
|
import androidx.lifecycle.ViewModelProvider; |
|
|
|
import androidx.recyclerview.widget.GridLayoutManager; |
|
|
|
import androidx.recyclerview.widget.GridLayoutManager; |
|
|
|
import androidx.recyclerview.widget.ItemTouchHelper; |
|
|
|
import androidx.recyclerview.widget.ItemTouchHelper; |
|
|
@ -66,7 +67,6 @@ import com.alphawallet.app.ui.widget.holder.WarningHolder; |
|
|
|
import com.alphawallet.app.util.LocaleUtils; |
|
|
|
import com.alphawallet.app.util.LocaleUtils; |
|
|
|
import com.alphawallet.app.viewmodel.WalletViewModel; |
|
|
|
import com.alphawallet.app.viewmodel.WalletViewModel; |
|
|
|
import com.alphawallet.app.walletconnect.AWWalletConnectClient; |
|
|
|
import com.alphawallet.app.walletconnect.AWWalletConnectClient; |
|
|
|
import com.alphawallet.app.widget.AWalletAlertDialog; |
|
|
|
|
|
|
|
import com.alphawallet.app.widget.BuyEthOptionsView; |
|
|
|
import com.alphawallet.app.widget.BuyEthOptionsView; |
|
|
|
import com.alphawallet.app.widget.LargeTitleView; |
|
|
|
import com.alphawallet.app.widget.LargeTitleView; |
|
|
|
import com.alphawallet.app.widget.NotificationView; |
|
|
|
import com.alphawallet.app.widget.NotificationView; |
|
|
@ -117,6 +117,7 @@ public class WalletFragment extends BaseFragment implements |
|
|
|
private LargeTitleView largeTitleView; |
|
|
|
private LargeTitleView largeTitleView; |
|
|
|
private ActivityResultLauncher<Intent> handleBackupClick; |
|
|
|
private ActivityResultLauncher<Intent> handleBackupClick; |
|
|
|
private ActivityResultLauncher<Intent> tokenManagementLauncher; |
|
|
|
private ActivityResultLauncher<Intent> tokenManagementLauncher; |
|
|
|
|
|
|
|
private boolean completed = false; |
|
|
|
|
|
|
|
|
|
|
|
@Inject |
|
|
|
@Inject |
|
|
|
AWWalletConnectClient awWalletConnectClient; |
|
|
|
AWWalletConnectClient awWalletConnectClient; |
|
|
@ -210,6 +211,34 @@ public class WalletFragment extends BaseFragment implements |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class CompletionLayoutListener extends LinearLayoutManager |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
public CompletionLayoutListener(Context context) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
super(context); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public CompletionLayoutListener(FragmentActivity activity, int orientation, boolean reverseLayout) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
super(activity, orientation, reverseLayout); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void onLayoutCompleted(RecyclerView.State state) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
super.onLayoutCompleted(state); |
|
|
|
|
|
|
|
final int firstVisibleItemPosition = findFirstVisibleItemPosition(); |
|
|
|
|
|
|
|
final int lastVisibleItemPosition = findLastVisibleItemPosition(); |
|
|
|
|
|
|
|
int itemsShown = lastVisibleItemPosition - firstVisibleItemPosition + 1; |
|
|
|
|
|
|
|
if (!completed && itemsShown > 1) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
completed = true; |
|
|
|
|
|
|
|
viewModel.startUpdateListener(); |
|
|
|
|
|
|
|
viewModel.getTokensService().startUpdateCycleIfRequired(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void initList() |
|
|
|
private void initList() |
|
|
|
{ |
|
|
|
{ |
|
|
|
adapter = new TokensAdapter(this, viewModel.getAssetDefinitionService(), viewModel.getTokensService(), |
|
|
|
adapter = new TokensAdapter(this, viewModel.getAssetDefinitionService(), viewModel.getTokensService(), |
|
|
@ -225,7 +254,7 @@ public class WalletFragment extends BaseFragment implements |
|
|
|
|
|
|
|
|
|
|
|
refreshLayout.setOnRefreshListener(this::refreshList); |
|
|
|
refreshLayout.setOnRefreshListener(this::refreshList); |
|
|
|
recyclerView.addRecyclerListener(holder -> adapter.onRViewRecycled(holder)); |
|
|
|
recyclerView.addRecyclerListener(holder -> adapter.onRViewRecycled(holder)); |
|
|
|
recyclerView.setLayoutManager(new LinearLayoutManager(getActivity())); |
|
|
|
recyclerView.setLayoutManager(new CompletionLayoutListener(getActivity(), LinearLayoutManager.VERTICAL, false)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void initViewModel() |
|
|
|
private void initViewModel() |
|
|
@ -373,13 +402,17 @@ public class WalletFragment extends BaseFragment implements |
|
|
|
public void comeIntoFocus() |
|
|
|
public void comeIntoFocus() |
|
|
|
{ |
|
|
|
{ |
|
|
|
isVisible = true; |
|
|
|
isVisible = true; |
|
|
|
viewModel.startUpdateListener(); |
|
|
|
if (completed) |
|
|
|
viewModel.getTokensService().startUpdateCycle(); |
|
|
|
{ |
|
|
|
|
|
|
|
viewModel.startUpdateListener(); |
|
|
|
|
|
|
|
viewModel.getTokensService().startUpdateCycleIfRequired(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void leaveFocus() |
|
|
|
public void leaveFocus() |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
isVisible = false; |
|
|
|
viewModel.stopUpdateListener(); |
|
|
|
viewModel.stopUpdateListener(); |
|
|
|
softKeyboardGone(); |
|
|
|
softKeyboardGone(); |
|
|
|
} |
|
|
|
} |
|
|
@ -388,6 +421,10 @@ public class WalletFragment extends BaseFragment implements |
|
|
|
public void onPause() |
|
|
|
public void onPause() |
|
|
|
{ |
|
|
|
{ |
|
|
|
super.onPause(); |
|
|
|
super.onPause(); |
|
|
|
|
|
|
|
if (isVisible) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
viewModel.stopUpdateListener(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void initTabLayout(View view) |
|
|
|
private void initTabLayout(View view) |
|
|
@ -418,7 +455,7 @@ public class WalletFragment extends BaseFragment implements |
|
|
|
case ASSETS: |
|
|
|
case ASSETS: |
|
|
|
case DEFI: |
|
|
|
case DEFI: |
|
|
|
case GOVERNANCE: |
|
|
|
case GOVERNANCE: |
|
|
|
recyclerView.setLayoutManager(new LinearLayoutManager(getActivity())); |
|
|
|
recyclerView.setLayoutManager(new CompletionLayoutListener(getActivity())); |
|
|
|
viewModel.prepare(); |
|
|
|
viewModel.prepare(); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case COLLECTIBLES: |
|
|
|
case COLLECTIBLES: |
|
|
@ -538,6 +575,12 @@ public class WalletFragment extends BaseFragment implements |
|
|
|
largeTitleView.setVisibility(View.VISIBLE); //show or hide Fiat summary
|
|
|
|
largeTitleView.setVisibility(View.VISIBLE); //show or hide Fiat summary
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (isVisible) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
viewModel.startUpdateListener(); |
|
|
|
|
|
|
|
viewModel.getTokensService().startUpdateCycleIfRequired(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void onTokens(TokenCardMeta[] tokens) |
|
|
|
private void onTokens(TokenCardMeta[] tokens) |
|
|
@ -550,11 +593,6 @@ public class WalletFragment extends BaseFragment implements |
|
|
|
} |
|
|
|
} |
|
|
|
systemView.showProgress(false); |
|
|
|
systemView.showProgress(false); |
|
|
|
|
|
|
|
|
|
|
|
if (isVisible) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
viewModel.startUpdateListener(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (currentTabPos.equals(TokenFilter.ALL)) |
|
|
|
if (currentTabPos.equals(TokenFilter.ALL)) |
|
|
|
{ |
|
|
|
{ |
|
|
|
awWalletConnectClient.updateNotification(); |
|
|
|
awWalletConnectClient.updateNotification(); |
|
|
|