fixed crashes

This commit is contained in:
Mariotaku Lee 2016-04-19 18:46:13 +08:00
parent 0e69222fb8
commit 2a78139e94
7 changed files with 17 additions and 10 deletions

View File

@ -324,7 +324,6 @@ public final class DummyItemAdapter implements IStatusesAdapter<Object>,
return false;
}
@Override
public RequestClickListener getRequestClickListener() {
return requestClickListener;

View File

@ -210,6 +210,7 @@ public abstract class ParcelableStatusesAdapter extends LoadMoreSupportAdapter<R
return mData.get(dataPosition).account_key;
}
@Override
public boolean setData(List<ParcelableStatus> data) {
mData = data;
if (data instanceof ObjectCursor || data == null || data.isEmpty()) {

View File

@ -67,13 +67,13 @@ public class ParcelableUsersAdapter extends LoadMoreSupportAdapter<RecyclerView.
mShowAbsoluteTime = mPreferences.getBoolean(KEY_SHOW_ABSOLUTE_TIME);
}
@Nullable
public List<ParcelableUser> getData() {
return mData;
}
@Override
public boolean setData(List<ParcelableUser> data) {
public boolean setData(@Nullable List<ParcelableUser> data) {
mData = data;
notifyDataSetChanged();
return true;

View File

@ -144,6 +144,10 @@ public class TwidereApplication extends Application implements Constants,
if (BuildConfig.DEBUG) {
StrictModeUtils.detectAllVmPolicy();
}
final SharedPreferences preferences = getSharedPreferences();
resetTheme(preferences);
super.onCreate();
mProfileImageViewViewProcessor = new ProfileImageViewViewProcessor();
mFontFamilyTagProcessor = new FontFamilyTagProcessor();
@ -166,7 +170,6 @@ public class TwidereApplication extends Application implements Constants,
ATE.registerTagProcessor(IconActionButtonTagProcessor.PREFIX_COLOR_DISABLED,
new IconActionButtonTagProcessor(IconActionButtonTagProcessor.PREFIX_COLOR_DISABLED));
ATE.registerTagProcessor(ThemedMultiValueSwitch.PREFIX_TINT, new ThemedMultiValueSwitch.TintTagProcessor());
final SharedPreferences preferences = getSharedPreferences();
mProfileImageViewViewProcessor.setStyle(Utils.getProfileImageStyle(preferences));
@ -198,8 +201,6 @@ public class TwidereApplication extends Application implements Constants,
.coloredStatusBar(false)
.commit();
}
resetTheme(preferences);
super.onCreate();
initializeAsyncTask();
initDebugMode();
initBugReport();

View File

@ -47,8 +47,6 @@ import java.util.List;
public class UserListMembersFragment extends CursorSupportUsersListFragment {
private ParcelableUserList mUserList;
@Override
public CursorSupportUsersLoader onCreateUsersLoader(final Context context,
@NonNull final Bundle args, boolean fromUser) {
@ -154,6 +152,7 @@ public class UserListMembersFragment extends CursorSupportUsersListFragment {
final ParcelableUsersAdapter adapter = getAdapter();
final List<ParcelableUser> newUsers = Arrays.asList(event.getUsers());
final List<ParcelableUser> users = adapter.getData();
if (users == null) return;
users.removeAll(newUsers);
users.addAll(0, newUsers);
for (int i = 0, j = users.size(); i < j; i++) {
@ -166,6 +165,7 @@ public class UserListMembersFragment extends CursorSupportUsersListFragment {
final ParcelableUsersAdapter adapter = getAdapter();
final List<ParcelableUser> removedUsers = Arrays.asList(event.getUsers());
final List<ParcelableUser> users = adapter.getData();
if (users == null) return;
users.removeAll(removedUsers);
for (int i = 0, j = users.size(); i < j; i++) {
users.get(i).position = i;

View File

@ -37,7 +37,7 @@ public class StatusLinkClickHandler extends OnLinkClickHandler {
final String link, final int start, final int end) {
final ParcelableStatus status = mStatus;
final ParcelableMedia current = findByLink(status.media, link);
if (current.open_browser) {
if (current == null || current.open_browser) {
openLink(link);
} else {
IntentUtils.openMedia(context, status, current, null,

View File

@ -53,6 +53,7 @@ import android.net.Uri;
import android.nfc.NfcAdapter;
import android.nfc.NfcAdapter.CreateNdefMessageCallback;
import android.os.AsyncTask;
import android.os.BadParcelableException;
import android.os.BatteryManager;
import android.os.Build;
import android.os.Bundle;
@ -453,7 +454,12 @@ public final class Utils implements Constants {
if (uri == null) return null;
final Bundle args = new Bundle();
if (extras != null) {
args.putAll(extras);
try {
args.putAll(extras);
} catch (BadParcelableException e) {
// When called by external app with wrong params
return null;
}
}
boolean isAccountIdRequired = true;
switch (linkId) {