fix crash in ViewThreadFragment

main
Conny Duck 6 years ago
parent e2b66e76e4
commit e473d914f1
  1. 15
      app/src/main/java/com/keylesspalace/tusky/ViewThreadActivity.java
  2. 1
      app/src/main/java/com/keylesspalace/tusky/fragment/ViewThreadFragment.java

@ -26,7 +26,6 @@ import android.support.v7.widget.Toolbar;
import android.view.Menu; import android.view.Menu;
import android.view.MenuItem; import android.view.MenuItem;
import com.keylesspalace.tusky.entity.Status;
import com.keylesspalace.tusky.fragment.ViewThreadFragment; import com.keylesspalace.tusky.fragment.ViewThreadFragment;
import com.keylesspalace.tusky.util.LinkHelper; import com.keylesspalace.tusky.util.LinkHelper;
@ -49,12 +48,9 @@ public class ViewThreadActivity extends BottomSheetActivity implements HasSuppor
return intent; return intent;
} }
public static Intent startIntentFromStatus(Context context, Status status) {
return startIntent(context, status.getActionableId(), status.getActionableStatus().getUrl());
}
private static final String ID_EXTRA = "id"; private static final String ID_EXTRA = "id";
private static final String URL_EXTRA = "url"; private static final String URL_EXTRA = "url";
private static final String FRAGMENT_TAG = "ViewThreadFragment_";
private int revealButtonState = REVEAL_BUTTON_HIDDEN; private int revealButtonState = REVEAL_BUTTON_HIDDEN;
@ -78,9 +74,14 @@ public class ViewThreadActivity extends BottomSheetActivity implements HasSuppor
} }
String id = getIntent().getStringExtra(ID_EXTRA); String id = getIntent().getStringExtra(ID_EXTRA);
fragment = (ViewThreadFragment)getSupportFragmentManager().findFragmentByTag(FRAGMENT_TAG + id);
if(fragment == null) {
fragment = ViewThreadFragment.newInstance(id);
}
FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction(); FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
fragment = ViewThreadFragment.newInstance(id); fragmentTransaction.replace(R.id.fragment_container, fragment, FRAGMENT_TAG + id);
fragmentTransaction.replace(R.id.fragment_container, fragment);
fragmentTransaction.commit(); fragmentTransaction.commit();
} }

@ -144,7 +144,6 @@ public final class ViewThreadFragment extends SFragment implements
}); });
} }
@Nullable
@Override @Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
@Nullable Bundle savedInstanceState) { @Nullable Bundle savedInstanceState) {

Loading…
Cancel
Save