fix channel list adapters
This commit is contained in:
parent
d1faaa9362
commit
7cf97feb9e
4 changed files with 25 additions and 9 deletions
|
@ -1598,6 +1598,8 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener
|
||||||
|
|
||||||
private void startup() {
|
private void startup() {
|
||||||
final Context context = this;
|
final Context context = this;
|
||||||
|
Lbry.startupInit();
|
||||||
|
|
||||||
// perform some tasks before launching
|
// perform some tasks before launching
|
||||||
(new AsyncTask<Void, Void, Boolean>() {
|
(new AsyncTask<Void, Void, Boolean>() {
|
||||||
protected void onPreExecute() {
|
protected void onPreExecute() {
|
||||||
|
@ -1638,7 +1640,6 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener
|
||||||
throw new Exception("Did not retrieve authenticated user.");
|
throw new Exception("Did not retrieve authenticated user.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Lbryio.newInstall(context);
|
Lbryio.newInstall(context);
|
||||||
|
|
||||||
// (light) fetch subscriptions
|
// (light) fetch subscriptions
|
||||||
|
|
|
@ -194,13 +194,15 @@ public class RepostClaimDialogFragment extends BottomSheetDialogFragment impleme
|
||||||
if (channelSpinnerAdapter == null) {
|
if (channelSpinnerAdapter == null) {
|
||||||
Context context = getContext();
|
Context context = getContext();
|
||||||
channelSpinnerAdapter = new InlineChannelSpinnerAdapter(context, R.layout.spinner_item_channel, channels);
|
channelSpinnerAdapter = new InlineChannelSpinnerAdapter(context, R.layout.spinner_item_channel, channels);
|
||||||
channelSpinner.setAdapter(channelSpinnerAdapter);
|
|
||||||
channelSpinnerAdapter.notifyDataSetChanged();
|
channelSpinnerAdapter.notifyDataSetChanged();
|
||||||
} else {
|
} else {
|
||||||
channelSpinnerAdapter.clear();
|
channelSpinnerAdapter.clear();
|
||||||
channelSpinnerAdapter.addAll(channels);
|
channelSpinnerAdapter.addAll(channels);
|
||||||
channelSpinnerAdapter.notifyDataSetChanged();
|
channelSpinnerAdapter.notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
|
if (channelSpinner != null) {
|
||||||
|
channelSpinner.setAdapter(channelSpinnerAdapter);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -198,10 +198,6 @@ public class InvitesFragment extends BaseFragment implements SdkStatusListener,
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (Lbry.ownChannels != null) {
|
|
||||||
updateChannelList(Lbry.ownChannels);
|
|
||||||
}
|
|
||||||
|
|
||||||
channelSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
channelSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onItemSelected(AdapterView<?> adapterView, View view, int position, long l) {
|
public void onItemSelected(AdapterView<?> adapterView, View view, int position, long l) {
|
||||||
|
@ -268,9 +264,8 @@ public class InvitesFragment extends BaseFragment implements SdkStatusListener,
|
||||||
private void updateChannelList(List<Claim> channels) {
|
private void updateChannelList(List<Claim> channels) {
|
||||||
if (channelSpinnerAdapter == null) {
|
if (channelSpinnerAdapter == null) {
|
||||||
Context context = getContext();
|
Context context = getContext();
|
||||||
channelSpinnerAdapter = new InlineChannelSpinnerAdapter(context, R.layout.spinner_item_channel, channels);
|
channelSpinnerAdapter = new InlineChannelSpinnerAdapter(context, R.layout.spinner_item_channel, new ArrayList<>(channels));
|
||||||
channelSpinnerAdapter.addPlaceholder(false);
|
channelSpinnerAdapter.addPlaceholder(false);
|
||||||
channelSpinner.setAdapter(channelSpinnerAdapter);
|
|
||||||
channelSpinnerAdapter.notifyDataSetChanged();
|
channelSpinnerAdapter.notifyDataSetChanged();
|
||||||
} else {
|
} else {
|
||||||
channelSpinnerAdapter.clear();
|
channelSpinnerAdapter.clear();
|
||||||
|
@ -279,6 +274,10 @@ public class InvitesFragment extends BaseFragment implements SdkStatusListener,
|
||||||
channelSpinnerAdapter.notifyDataSetChanged();
|
channelSpinnerAdapter.notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (channelSpinner != null) {
|
||||||
|
channelSpinner.setAdapter(channelSpinnerAdapter);
|
||||||
|
}
|
||||||
|
|
||||||
if (channelSpinnerAdapter.getCount() > 1) {
|
if (channelSpinnerAdapter.getCount() > 1) {
|
||||||
channelSpinner.setSelection(1);
|
channelSpinner.setSelection(1);
|
||||||
}
|
}
|
||||||
|
@ -382,6 +381,11 @@ public class InvitesFragment extends BaseFragment implements SdkStatusListener,
|
||||||
}
|
}
|
||||||
|
|
||||||
private void fetchChannels() {
|
private void fetchChannels() {
|
||||||
|
if (Lbry.ownChannels != null && Lbry.ownChannels.size() > 0) {
|
||||||
|
updateChannelList(Lbry.ownChannels);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
fetchingChannels = true;
|
fetchingChannels = true;
|
||||||
disableChannelSpinner();
|
disableChannelSpinner();
|
||||||
ClaimListTask task = new ClaimListTask(Claim.TYPE_CHANNEL, progressLoadingChannels, new ClaimListResultHandler() {
|
ClaimListTask task = new ClaimListTask(Claim.TYPE_CHANNEL, progressLoadingChannels, new ClaimListResultHandler() {
|
||||||
|
@ -413,10 +417,12 @@ public class InvitesFragment extends BaseFragment implements SdkStatusListener,
|
||||||
if (inviteHistoryAdapter == null) {
|
if (inviteHistoryAdapter == null) {
|
||||||
inviteHistoryAdapter = new InviteeListAdapter(invitees, getContext());
|
inviteHistoryAdapter = new InviteeListAdapter(invitees, getContext());
|
||||||
inviteHistoryAdapter.addHeader();
|
inviteHistoryAdapter.addHeader();
|
||||||
inviteHistoryList.setAdapter(inviteHistoryAdapter);
|
|
||||||
} else {
|
} else {
|
||||||
inviteHistoryAdapter.addInvitees(invitees);
|
inviteHistoryAdapter.addInvitees(invitees);
|
||||||
}
|
}
|
||||||
|
if (inviteHistoryList != null) {
|
||||||
|
inviteHistoryList.setAdapter(inviteHistoryAdapter);
|
||||||
|
}
|
||||||
Helper.setViewVisibility(inviteHistoryList,
|
Helper.setViewVisibility(inviteHistoryList,
|
||||||
inviteHistoryAdapter == null || inviteHistoryAdapter.getItemCount() < 2 ? View.GONE : View.VISIBLE
|
inviteHistoryAdapter == null || inviteHistoryAdapter.getItemCount() < 2 ? View.GONE : View.VISIBLE
|
||||||
);
|
);
|
||||||
|
|
|
@ -92,6 +92,13 @@ public final class Lbry {
|
||||||
public static KeyStore KEYSTORE;
|
public static KeyStore KEYSTORE;
|
||||||
public static boolean SDK_READY = false;
|
public static boolean SDK_READY = false;
|
||||||
|
|
||||||
|
public static void startupInit() {
|
||||||
|
ownChannels = new ArrayList<>();
|
||||||
|
ownClaims = new ArrayList<>();
|
||||||
|
knownTags = new ArrayList<>();
|
||||||
|
followedTags = new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
public static void parseStatus(String response) {
|
public static void parseStatus(String response) {
|
||||||
try {
|
try {
|
||||||
JSONObject json = parseSdkResponse(response);
|
JSONObject json = parseSdkResponse(response);
|
||||||
|
|
Loading…
Reference in a new issue