Fix crash bug for anonymous repost claim results. Better handle channel repost navigation.

This commit is contained in:
Akinwale Ariwodola 2021-01-12 09:07:33 +01:00
parent 28212808f8
commit e1d51c881a
4 changed files with 17 additions and 8 deletions

View file

@ -3402,6 +3402,11 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener
return String.format("%s-%d", fragmentClass.getName(), navItemId);
}
public void popFragment(Class fragmentClass, int navItemId, Map<String, Object> params) {
String key = buildNavFragmentKey(fragmentClass, navItemId, params);
openNavFragments.remove(key);
}
public void openFragment(Class fragmentClass, boolean allowNavigateBack, int navItemId, Map<String, Object> params) {
try {
String key = buildNavFragmentKey(fragmentClass, navItemId, params);

View file

@ -404,7 +404,7 @@ public class ClaimListAdapter extends RecyclerView.Adapter<ClaimListAdapter.View
vh.publishTimeView.setVisibility(!isPending ? View.VISIBLE : View.GONE);
vh.pendingTextView.setVisibility(isPending && !item.isLoadingPlaceholder() ? View.VISIBLE : View.GONE);
vh.repostInfoView.setVisibility(isRepost && type != VIEW_TYPE_FEATURED ? View.VISIBLE : View.GONE);
vh.repostChannelView.setText(isRepost ? original.getSigningChannel().getName() : null);
vh.repostChannelView.setText(isRepost && original.getSigningChannel() != null ? original.getSigningChannel().getName() : null);
vh.repostChannelView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {

View file

@ -12,6 +12,7 @@ import android.graphics.Color;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Handler;
import android.text.Editable;
import android.text.TextWatcher;
import android.text.format.DateUtils;
@ -310,8 +311,7 @@ public class FileViewFragment extends BaseFragment implements
String mediaSourceUrl = getStreamingUrl();
long duration = MainActivity.appPlayer.getDuration();
long position = MainActivity.appPlayer.getCurrentPosition();
// TODO: Determine a hash for the userId
String userIdHash = Helper.SHA256(Lbryio.currentUser != null ? String.valueOf(Lbryio.currentUser.getId()) : "0");
String userIdHash = Lbryio.currentUser != null ? String.valueOf(Lbryio.currentUser.getId()) : "0";
if (mediaSourceUrl.startsWith(CDN_PREFIX)) {
BufferEventTask bufferEvent = new BufferEventTask(claim.getPermanentUrl(), duration, position, 1, userIdHash);
bufferEvent.executeOnExecutor(AsyncTask.SERIAL_EXECUTOR);
@ -429,8 +429,11 @@ public class FileViewFragment extends BaseFragment implements
renderNothingAtLocation();
} else if (claim.getName().startsWith("@")) {
// this is a reposted channel, so launch the channel url
if (context instanceof MainActivity) {
((MainActivity) context).openChannelUrl(!Helper.isNullOrEmpty(claim.getShortUrl()) ? claim.getShortUrl() : claim.getPermanentUrl());
if (context instanceof MainActivity) {
MainActivity activity = (MainActivity) context;
//activity.onBackPressed(); // remove the reposted url page from the back stack
activity.getSupportFragmentManager().popBackStack();
activity.openChannelUrl(!Helper.isNullOrEmpty(claim.getShortUrl()) ? claim.getShortUrl() : claim.getPermanentUrl());
}
return;
}
@ -899,7 +902,9 @@ public class FileViewFragment extends BaseFragment implements
// this is a reposted channel, so finish this activity and launch the channel url
Context context = getContext();
if (context instanceof MainActivity) {
((MainActivity) context).openChannelUrl(!Helper.isNullOrEmpty(claim.getShortUrl()) ? claim.getShortUrl() : claim.getPermanentUrl());
MainActivity activity = (MainActivity) context;
activity.getSupportFragmentManager().popBackStack();
activity.openChannelUrl(!Helper.isNullOrEmpty(claim.getShortUrl()) ? claim.getShortUrl() : claim.getPermanentUrl());
}
return;
}

View file

@ -131,8 +131,7 @@ public class ShuffleFragment extends BaseFragment {
String mediaSourceUrl = getStreamingUrl();
long duration = MainActivity.appPlayer.getDuration();
long position = MainActivity.appPlayer.getCurrentPosition();
// TODO: Determine a hash for the userId
String userIdHash = Helper.SHA256(Lbryio.currentUser != null ? String.valueOf(Lbryio.currentUser.getId()) : "0");
String userIdHash = Lbryio.currentUser != null ? String.valueOf(Lbryio.currentUser.getId()) : "0";
if (mediaSourceUrl.startsWith(FileViewFragment.CDN_PREFIX)) {
BufferEventTask bufferEvent = new BufferEventTask(current.getPermanentUrl(), duration, position, 1, userIdHash);
bufferEvent.executeOnExecutor(AsyncTask.SERIAL_EXECUTOR);