mirror of
https://github.com/KokaKiwi/BarInsta
synced 2024-11-22 22:57:29 +00:00
Use null checked context for Toast. Fixes https://github.com/austinhuang0131/barinsta/issues/802
This commit is contained in:
parent
b5cd213e84
commit
50fd282ab2
@ -156,6 +156,7 @@ public class StoryViewerFragment extends Fragment {
|
|||||||
public void onCreate(@Nullable final Bundle savedInstanceState) {
|
public void onCreate(@Nullable final Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
final String csrfToken = CookieUtils.getCsrfTokenFromCookie(cookie);
|
final String csrfToken = CookieUtils.getCsrfTokenFromCookie(cookie);
|
||||||
|
if (csrfToken == null) return;
|
||||||
final long userIdFromCookie = CookieUtils.getUserIdFromCookie(cookie);
|
final long userIdFromCookie = CookieUtils.getUserIdFromCookie(cookie);
|
||||||
final String deviceId = settingsHelper.getString(Constants.DEVICE_UUID);
|
final String deviceId = settingsHelper.getString(Constants.DEVICE_UUID);
|
||||||
fragmentActivity = (AppCompatActivity) requireActivity();
|
fragmentActivity = (AppCompatActivity) requireActivity();
|
||||||
@ -241,8 +242,7 @@ public class StoryViewerFragment extends Fragment {
|
|||||||
try {
|
try {
|
||||||
Toast.makeText(context, R.string.downloader_unknown_error, Toast.LENGTH_SHORT).show();
|
Toast.makeText(context, R.string.downloader_unknown_error, Toast.LENGTH_SHORT).show();
|
||||||
Log.e(TAG, "onFailure: ", t);
|
Log.e(TAG, "onFailure: ", t);
|
||||||
}
|
} catch (Throwable ignored) {}
|
||||||
catch(Throwable e) {}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} catch (UnsupportedEncodingException e) {
|
} catch (UnsupportedEncodingException e) {
|
||||||
@ -488,8 +488,7 @@ public class StoryViewerFragment extends Fragment {
|
|||||||
try {
|
try {
|
||||||
poll.setMyChoice(w);
|
poll.setMyChoice(w);
|
||||||
Toast.makeText(context, R.string.votef_story_poll, Toast.LENGTH_SHORT).show();
|
Toast.makeText(context, R.string.votef_story_poll, Toast.LENGTH_SHORT).show();
|
||||||
}
|
} catch (Exception ignored) {}
|
||||||
catch (Exception ignored) {}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -498,8 +497,7 @@ public class StoryViewerFragment extends Fragment {
|
|||||||
Log.e(TAG, "Error responding", t);
|
Log.e(TAG, "Error responding", t);
|
||||||
try {
|
try {
|
||||||
Toast.makeText(context, R.string.downloader_unknown_error, Toast.LENGTH_SHORT).show();
|
Toast.makeText(context, R.string.downloader_unknown_error, Toast.LENGTH_SHORT).show();
|
||||||
}
|
} catch (Exception ignored) {}
|
||||||
catch (Exception ignored) {}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
@ -525,8 +523,7 @@ public class StoryViewerFragment extends Fragment {
|
|||||||
sticking = false;
|
sticking = false;
|
||||||
try {
|
try {
|
||||||
Toast.makeText(context, R.string.answered_story, Toast.LENGTH_SHORT).show();
|
Toast.makeText(context, R.string.answered_story, Toast.LENGTH_SHORT).show();
|
||||||
}
|
} catch (Exception ignored) {}
|
||||||
catch (Exception ignored) {}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -535,8 +532,7 @@ public class StoryViewerFragment extends Fragment {
|
|||||||
Log.e(TAG, "Error responding", t);
|
Log.e(TAG, "Error responding", t);
|
||||||
try {
|
try {
|
||||||
Toast.makeText(context, R.string.downloader_unknown_error, Toast.LENGTH_SHORT).show();
|
Toast.makeText(context, R.string.downloader_unknown_error, Toast.LENGTH_SHORT).show();
|
||||||
}
|
} catch (Exception ignored) {}
|
||||||
catch (Exception ignored) {}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
@ -570,9 +566,8 @@ public class StoryViewerFragment extends Fragment {
|
|||||||
try {
|
try {
|
||||||
quiz.setMyChoice(w);
|
quiz.setMyChoice(w);
|
||||||
Toast.makeText(context, R.string.answered_story, Toast.LENGTH_SHORT).show();
|
Toast.makeText(context, R.string.answered_story, Toast.LENGTH_SHORT).show();
|
||||||
}
|
} catch (Exception ignored) {}
|
||||||
catch (Exception ignored) {}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(final Throwable t) {
|
public void onFailure(final Throwable t) {
|
||||||
@ -580,8 +575,7 @@ public class StoryViewerFragment extends Fragment {
|
|||||||
Log.e(TAG, "Error responding", t);
|
Log.e(TAG, "Error responding", t);
|
||||||
try {
|
try {
|
||||||
Toast.makeText(context, R.string.downloader_unknown_error, Toast.LENGTH_SHORT).show();
|
Toast.makeText(context, R.string.downloader_unknown_error, Toast.LENGTH_SHORT).show();
|
||||||
}
|
} catch (Exception ignored) {}
|
||||||
catch (Exception ignored) {}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -640,8 +634,7 @@ public class StoryViewerFragment extends Fragment {
|
|||||||
try {
|
try {
|
||||||
slider.setMyChoice(sliderValue);
|
slider.setMyChoice(sliderValue);
|
||||||
Toast.makeText(context, R.string.answered_story, Toast.LENGTH_SHORT).show();
|
Toast.makeText(context, R.string.answered_story, Toast.LENGTH_SHORT).show();
|
||||||
}
|
} catch (Exception ignored) {}
|
||||||
catch (Exception ignored) {}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -650,8 +643,7 @@ public class StoryViewerFragment extends Fragment {
|
|||||||
Log.e(TAG, "Error responding", t);
|
Log.e(TAG, "Error responding", t);
|
||||||
try {
|
try {
|
||||||
Toast.makeText(context, R.string.downloader_unknown_error, Toast.LENGTH_SHORT).show();
|
Toast.makeText(context, R.string.downloader_unknown_error, Toast.LENGTH_SHORT).show();
|
||||||
}
|
} catch (Exception ignored) {}
|
||||||
catch (Exception ignored) {}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
@ -681,6 +673,7 @@ public class StoryViewerFragment extends Fragment {
|
|||||||
|
|
||||||
private void resetView() {
|
private void resetView() {
|
||||||
final Context context = getContext();
|
final Context context = getContext();
|
||||||
|
if (context == null) return;
|
||||||
StoryModel live = null;
|
StoryModel live = null;
|
||||||
slidePos = 0;
|
slidePos = 0;
|
||||||
lastSlidePos = 0;
|
lastSlidePos = 0;
|
||||||
@ -759,7 +752,6 @@ public class StoryViewerFragment extends Fragment {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(final Throwable t) {
|
public void onFailure(final Throwable t) {
|
||||||
final Context context = getContext();
|
|
||||||
Toast.makeText(context, t.getMessage(), Toast.LENGTH_SHORT).show();
|
Toast.makeText(context, t.getMessage(), Toast.LENGTH_SHORT).show();
|
||||||
Log.e(TAG, "Error", t);
|
Log.e(TAG, "Error", t);
|
||||||
}
|
}
|
||||||
@ -789,7 +781,6 @@ public class StoryViewerFragment extends Fragment {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(final Throwable t) {
|
public void onFailure(final Throwable t) {
|
||||||
final Context context = getContext();
|
|
||||||
Toast.makeText(context, t.getMessage(), Toast.LENGTH_SHORT).show();
|
Toast.makeText(context, t.getMessage(), Toast.LENGTH_SHORT).show();
|
||||||
Log.e(TAG, "Error", t);
|
Log.e(TAG, "Error", t);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user