prevent NPEs in linked id creation
This commit is contained in:
@@ -49,7 +49,6 @@ public class LinkedIdCreateHttpsStep2Fragment extends LinkedIdCreateFinalFragmen
|
|||||||
EditText mEditUri;
|
EditText mEditUri;
|
||||||
|
|
||||||
URI mResourceUri;
|
URI mResourceUri;
|
||||||
String mResourceString;
|
|
||||||
|
|
||||||
public static LinkedIdCreateHttpsStep2Fragment newInstance(String uri) {
|
public static LinkedIdCreateHttpsStep2Fragment newInstance(String uri) {
|
||||||
|
|
||||||
@@ -77,8 +76,6 @@ public class LinkedIdCreateHttpsStep2Fragment extends LinkedIdCreateFinalFragmen
|
|||||||
Timber.e(e);
|
Timber.e(e);
|
||||||
requireActivity().finish();
|
requireActivity().finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
mResourceString = GenericHttpsResource.generateText(requireActivity(), fingerprint);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -100,10 +97,14 @@ public class LinkedIdCreateHttpsStep2Fragment extends LinkedIdCreateFinalFragmen
|
|||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String getResourceString() {
|
||||||
|
return GenericHttpsResource.generateText(requireActivity(), fingerprint);
|
||||||
|
}
|
||||||
|
|
||||||
private void proofSend() {
|
private void proofSend() {
|
||||||
Intent sendIntent = new Intent();
|
Intent sendIntent = new Intent();
|
||||||
sendIntent.setAction(Intent.ACTION_SEND);
|
sendIntent.setAction(Intent.ACTION_SEND);
|
||||||
sendIntent.putExtra(Intent.EXTRA_TEXT, mResourceString);
|
sendIntent.putExtra(Intent.EXTRA_TEXT, getResourceString());
|
||||||
sendIntent.setType("text/plain");
|
sendIntent.setType("text/plain");
|
||||||
startActivity(sendIntent);
|
startActivity(sendIntent);
|
||||||
}
|
}
|
||||||
@@ -124,7 +125,7 @@ public class LinkedIdCreateHttpsStep2Fragment extends LinkedIdCreateFinalFragmen
|
|||||||
private void saveFile(Uri uri) {
|
private void saveFile(Uri uri) {
|
||||||
try {
|
try {
|
||||||
PrintWriter out = new PrintWriter(requireActivity().getContentResolver().openOutputStream(uri));
|
PrintWriter out = new PrintWriter(requireActivity().getContentResolver().openOutputStream(uri));
|
||||||
out.print(mResourceString);
|
out.print(getResourceString());
|
||||||
if (out.checkError()) {
|
if (out.checkError()) {
|
||||||
Notify.create(getActivity(), "Error writing file!", Style.ERROR).show();
|
Notify.create(getActivity(), "Error writing file!", Style.ERROR).show();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,7 +40,6 @@ public class LinkedIdCreateTwitterStep2Fragment extends LinkedIdCreateFinalFragm
|
|||||||
public static final String ARG_HANDLE = "handle";
|
public static final String ARG_HANDLE = "handle";
|
||||||
|
|
||||||
String mResourceHandle;
|
String mResourceHandle;
|
||||||
String mResourceString;
|
|
||||||
|
|
||||||
public static LinkedIdCreateTwitterStep2Fragment newInstance(String handle) {
|
public static LinkedIdCreateTwitterStep2Fragment newInstance(String handle) {
|
||||||
LinkedIdCreateTwitterStep2Fragment frag = new LinkedIdCreateTwitterStep2Fragment();
|
LinkedIdCreateTwitterStep2Fragment frag = new LinkedIdCreateTwitterStep2Fragment();
|
||||||
@@ -56,10 +55,13 @@ public class LinkedIdCreateTwitterStep2Fragment extends LinkedIdCreateFinalFragm
|
|||||||
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
|
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
|
||||||
super.onActivityCreated(savedInstanceState);
|
super.onActivityCreated(savedInstanceState);
|
||||||
|
|
||||||
mResourceString = TwitterResource.generate(fingerprint);
|
|
||||||
mResourceHandle = getArguments().getString(ARG_HANDLE);
|
mResourceHandle = getArguments().getString(ARG_HANDLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String getResourceString() {
|
||||||
|
return TwitterResource.generate(fingerprint);
|
||||||
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
@@ -76,8 +78,7 @@ public class LinkedIdCreateTwitterStep2Fragment extends LinkedIdCreateFinalFragm
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
LinkedTokenResource getResource(OperationLog log) {
|
LinkedTokenResource getResource(OperationLog log) {
|
||||||
return TwitterResource.searchInTwitterStream(getActivity(),
|
return TwitterResource.searchInTwitterStream(getActivity(), mResourceHandle, getResourceString(), log);
|
||||||
mResourceHandle, mResourceString, log);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -88,14 +89,14 @@ public class LinkedIdCreateTwitterStep2Fragment extends LinkedIdCreateFinalFragm
|
|||||||
private void proofShare() {
|
private void proofShare() {
|
||||||
Intent sendIntent = new Intent();
|
Intent sendIntent = new Intent();
|
||||||
sendIntent.setAction(Intent.ACTION_SEND);
|
sendIntent.setAction(Intent.ACTION_SEND);
|
||||||
sendIntent.putExtra(Intent.EXTRA_TEXT, mResourceString);
|
sendIntent.putExtra(Intent.EXTRA_TEXT, getResourceString());
|
||||||
sendIntent.setType("text/plain");
|
sendIntent.setType("text/plain");
|
||||||
startActivity(sendIntent);
|
startActivity(sendIntent);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void proofSend() {
|
private void proofSend() {
|
||||||
Uri.Builder builder = Uri.parse("https://twitter.com/intent/tweet").buildUpon();
|
Uri.Builder builder = Uri.parse("https://twitter.com/intent/tweet").buildUpon();
|
||||||
builder.appendQueryParameter("text", mResourceString);
|
builder.appendQueryParameter("text", getResourceString());
|
||||||
Uri uri = builder.build();
|
Uri uri = builder.build();
|
||||||
|
|
||||||
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
|
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
|
||||||
|
|||||||
Reference in New Issue
Block a user