parent
d56cda1b37
commit
d529226329
|
@ -31,6 +31,7 @@ import android.database.sqlite.SQLiteOpenHelper;
|
|||
import android.os.AsyncTask;
|
||||
import android.os.Handler;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.multidex.MultiDexApplication;
|
||||
|
||||
import com.nostra13.universalimageloader.cache.disc.DiskCache;
|
||||
|
@ -202,6 +203,7 @@ public class TwidereApplication extends MultiDexApplication implements Constants
|
|||
return mMediaLoaderWrapper = new MediaLoaderWrapper(getImageLoader(), getVideoLoader());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Bus getMessageBus() {
|
||||
return mMessageBus;
|
||||
}
|
||||
|
|
|
@ -39,6 +39,7 @@ import android.support.annotation.Nullable;
|
|||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.app.FragmentActivity;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
import android.support.v4.app.FragmentManagerTrojan;
|
||||
import android.support.v4.app.FragmentTransaction;
|
||||
import android.support.v4.app.LoaderManager.LoaderCallbacks;
|
||||
import android.support.v4.content.Loader;
|
||||
|
@ -809,8 +810,8 @@ public class StatusFragment extends BaseSupportFragment implements LoaderCallbac
|
|||
twitterCard.setCardSize(0, 0);
|
||||
}
|
||||
final Fragment cardFragment = TwitterCardUtils.createCardFragment(status.card);
|
||||
if (cardFragment != null) {
|
||||
final FragmentManager fm = fragment.getChildFragmentManager();
|
||||
final FragmentManager fm = fragment.getChildFragmentManager();
|
||||
if (cardFragment != null && !FragmentManagerTrojan.isStateSaved(fm)) {
|
||||
final FragmentTransaction ft = fm.beginTransaction();
|
||||
ft.replace(R.id.twitter_card, cardFragment);
|
||||
ft.commit();
|
||||
|
|
|
@ -23,6 +23,7 @@ import android.content.Context;
|
|||
import android.content.SharedPreferences;
|
||||
import android.media.RingtoneManager;
|
||||
import android.net.Uri;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import org.mariotaku.twidere.Constants;
|
||||
|
@ -142,6 +143,7 @@ public class AccountPreferences implements Constants {
|
|||
return enabledIds;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static AccountPreferences[] getNotificationEnabledPreferences(final Context context, final long[] accountIds) {
|
||||
if (context == null || accountIds == null) return null;
|
||||
final AccountPreferences[] temp = new AccountPreferences[accountIds.length];
|
||||
|
|
|
@ -751,12 +751,14 @@ public final class TwidereDataProvider extends ContentProvider implements Consta
|
|||
private void notifyUnreadCountChanged(final int position) {
|
||||
final Context context = getContext();
|
||||
final Bus bus = TwidereApplication.getInstance(context).getMessageBus();
|
||||
mHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
bus.post(new UnreadCountUpdatedEvent(position));
|
||||
}
|
||||
});
|
||||
if (bus != null) {
|
||||
mHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
bus.post(new UnreadCountUpdatedEvent(position));
|
||||
}
|
||||
});
|
||||
}
|
||||
notifyContentObserver(UnreadCounts.CONTENT_URI);
|
||||
}
|
||||
|
||||
|
@ -779,13 +781,16 @@ public final class TwidereDataProvider extends ContentProvider implements Consta
|
|||
}
|
||||
|
||||
private void onNewItemsInserted(final Uri uri, final int tableId, final ContentValues[] valuesArray, final long[] newIds) {
|
||||
if (uri == null || valuesArray == null || valuesArray.length == 0) return;
|
||||
final Context context = getContext();
|
||||
if (uri == null || valuesArray == null || valuesArray.length == 0 || context == null)
|
||||
return;
|
||||
preloadImages(valuesArray);
|
||||
if (!uri.getBooleanQueryParameter(QUERY_PARAM_NOTIFY, true)) return;
|
||||
switch (tableId) {
|
||||
case TABLE_ID_STATUSES: {
|
||||
final AccountPreferences[] prefs = AccountPreferences.getNotificationEnabledPreferences(getContext(),
|
||||
getAccountIds(getContext()));
|
||||
final AccountPreferences[] prefs = AccountPreferences.getNotificationEnabledPreferences(context,
|
||||
getAccountIds(context));
|
||||
assert prefs != null;
|
||||
for (final AccountPreferences pref : prefs) {
|
||||
if (!pref.isHomeTimelineNotificationEnabled()) continue;
|
||||
showTimelineNotification(pref, getPositionTag(TAB_TYPE_HOME_TIMELINE, pref.getAccountId()));
|
||||
|
@ -794,8 +799,9 @@ public final class TwidereDataProvider extends ContentProvider implements Consta
|
|||
break;
|
||||
}
|
||||
case TABLE_ID_MENTIONS: {
|
||||
final AccountPreferences[] prefs = AccountPreferences.getNotificationEnabledPreferences(getContext(),
|
||||
getAccountIds(getContext()));
|
||||
final AccountPreferences[] prefs = AccountPreferences.getNotificationEnabledPreferences(context,
|
||||
getAccountIds(context));
|
||||
assert prefs != null;
|
||||
for (final AccountPreferences pref : prefs) {
|
||||
if (!pref.isMentionsNotificationEnabled()) continue;
|
||||
showMentionsNotification(pref, getPositionTag(TAB_TYPE_MENTIONS_TIMELINE, pref.getAccountId()));
|
||||
|
@ -804,8 +810,9 @@ public final class TwidereDataProvider extends ContentProvider implements Consta
|
|||
break;
|
||||
}
|
||||
case TABLE_ID_DIRECT_MESSAGES_INBOX: {
|
||||
final AccountPreferences[] prefs = AccountPreferences.getNotificationEnabledPreferences(getContext(),
|
||||
getAccountIds(getContext()));
|
||||
final AccountPreferences[] prefs = AccountPreferences.getNotificationEnabledPreferences(context,
|
||||
getAccountIds(context));
|
||||
assert prefs != null;
|
||||
for (final AccountPreferences pref : prefs) {
|
||||
if (!pref.isDirectMessagesNotificationEnabled()) continue;
|
||||
final StringLongPair[] pairs = mReadStateManager.getPositionPairs(TAB_TYPE_DIRECT_MESSAGES);
|
||||
|
|
|
@ -1309,6 +1309,7 @@ public final class Utils implements Constants, TwitterConstants {
|
|||
}
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public static long[] getAccountIds(final Context context) {
|
||||
if (context == null) return new long[0];
|
||||
final Cursor cur = ContentResolverUtils.query(context.getContentResolver(), Accounts.CONTENT_URI,
|
||||
|
|
|
@ -64,7 +64,7 @@
|
|||
android:id="@+id/label_auth_type"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/authType"
|
||||
android:text="@string/auth_type"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall" />
|
||||
|
||||
<HorizontalScrollView
|
||||
|
|
Loading…
Reference in New Issue