fixed dm conversation crash

This commit is contained in:
Mariotaku Lee 2016-01-04 10:02:23 +08:00
parent 43bc5da927
commit e998e8426c
8 changed files with 35 additions and 6 deletions

View File

@ -109,7 +109,7 @@ dependencies {
compile 'com.makeramen:roundedimageview:2.1.1'
compile 'com.soundcloud.android:android-crop:1.0.1@aar'
compile 'com.hannesdorfmann.parcelableplease:annotation:1.0.1'
compile 'com.github.mariotaku:PickNCrop:6c9d888a9d'
compile 'com.github.mariotaku:PickNCrop:0.9.2'
compile 'com.github.mariotaku.RestFu:library:0.9.8'
compile 'com.github.mariotaku.RestFu:okhttp:0.9.8'
compile 'com.diogobernardino:williamchart:2.1'

View File

@ -21,6 +21,7 @@ package org.mariotaku.twidere.adapter;
import android.content.Context;
import android.support.annotation.NonNull;
import android.support.v4.text.BidiFormatter;
import android.support.v7.widget.RecyclerView;
import org.mariotaku.twidere.util.AsyncTwitterWrapper;
@ -51,6 +52,8 @@ public abstract class BaseRecyclerViewAdapter<VH extends RecyclerView.ViewHolder
protected UserColorNameManager mUserColorNameManager;
@Inject
protected SharedPreferencesWrapper mPreferences;
@Inject
protected BidiFormatter mBidiFormatter;
public BaseRecyclerViewAdapter(Context context) {
mContext = context;
@ -86,4 +89,8 @@ public abstract class BaseRecyclerViewAdapter<VH extends RecyclerView.ViewHolder
public final AsyncTwitterWrapper getTwitterWrapper() {
return mTwitterWrapper;
}
public final BidiFormatter getBidiFormatter() {
return mBidiFormatter;
}
}

View File

@ -31,6 +31,7 @@ import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManagerAccessor;
import android.support.v4.text.BidiFormatter;
import android.support.v4.view.LayoutInflaterCompat;
import android.support.v4.view.LayoutInflaterFactory;
import android.view.LayoutInflater;
@ -77,6 +78,8 @@ public class BaseSupportFragment extends Fragment implements IBaseFragment, Cons
protected SharedPreferencesWrapper mPreferences;
@Inject
protected NotificationManagerWrapper mNotificationManager;
@Inject
protected BidiFormatter mBidiFormatter;
public BaseSupportFragment() {

View File

@ -115,6 +115,8 @@ import java.util.Collections;
import java.util.List;
import java.util.Locale;
import javax.inject.Inject;
import me.uucky.colorpicker.internal.EffectViewHelper;
import static org.mariotaku.twidere.util.Utils.buildDirectMessageConversationUri;
@ -897,10 +899,12 @@ public class MessagesConversationFragment extends BaseSupportFragment implements
public static class SetReadStateTask extends AsyncTask<Object, Object, Cursor> {
private final Context mContext;
ReadStateManager mReadStateManager;
private final ParcelableCredentials mAccount;
private final ParcelableUser mRecipient;
@Inject
ReadStateManager mReadStateManager;
public SetReadStateTask(Context context, ParcelableCredentials account, ParcelableUser recipient) {
GeneralComponentHelper.build(context).inject(this);
mContext = context;

View File

@ -54,6 +54,7 @@ import android.support.v4.content.AsyncTaskLoader;
import android.support.v4.content.Loader;
import android.support.v4.content.res.ResourcesCompat;
import android.support.v4.graphics.ColorUtils;
import android.support.v4.text.BidiFormatter;
import android.support.v4.view.ViewCompat;
import android.support.v4.view.ViewPager;
import android.support.v4.view.ViewPager.OnPageChangeListener;
@ -495,7 +496,7 @@ public class UserFragment extends BaseSupportFragment implements OnClickListener
mProfileImageView.setBorderColor(userColor != 0 ? userColor : Color.WHITE);
mProfileNameContainer.drawEnd(DataStoreUtils.getAccountColor(activity, user.account_id));
final String nick = mUserColorNameManager.getUserNickname(user.id, true);
mNameView.setText(TextUtils.isEmpty(nick) ? user.name : getString(R.string.name_with_nickname, user.name, nick));
mNameView.setText(mBidiFormatter.unicodeWrap(TextUtils.isEmpty(nick) ? user.name : getString(R.string.name_with_nickname, user.name, nick)));
final int typeIconRes = Utils.getUserTypeIconRes(user.is_verified, user.is_protected);
if (typeIconRes != 0) {
mProfileTypeView.setImageResource(typeIconRes);

View File

@ -24,6 +24,7 @@ import android.content.SharedPreferences;
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
import android.graphics.Color;
import android.support.v4.util.LongSparseArray;
import android.text.TextUtils;
import org.apache.commons.lang3.math.NumberUtils;
import org.mariotaku.twidere.TwidereConstants;
@ -153,6 +154,11 @@ public class UserColorNameManager implements TwidereConstants {
return mNicknamePreferences.getAll().entrySet();
}
public String getName(long id, String name) {
final String nick = getUserNickname(id, true);
return TextUtils.isEmpty(nick) ? name : nick;
}
public interface OnUserColorChangedListener {
void onUserColorChanged(long userId, int color);
}

View File

@ -22,6 +22,7 @@ package org.mariotaku.twidere.util.dagger;
import android.content.Context;
import android.os.Looper;
import android.support.annotation.NonNull;
import android.support.v4.text.BidiFormatter;
import com.nostra13.universalimageloader.cache.disc.DiskCache;
import com.nostra13.universalimageloader.cache.disc.impl.ext.LruDiskCache;
@ -198,6 +199,11 @@ public class ApplicationModule implements Constants {
return createDiskCache("files", preferences);
}
@Provides
public BidiFormatter provideBidiFormatter() {
return BidiFormatter.getInstance();
}
private DiskCache createDiskCache(final String dirName, SharedPreferencesWrapper preferences) {
final File cacheDir = Utils.getExternalCacheDir(application, dirName);
final File fallbackCacheDir = getInternalCacheDir(application, dirName);

View File

@ -16,7 +16,8 @@
~ You should have received a copy of the GNU General Public License
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tool="http://schemas.android.com/tools"
android:layout_width="wrap_content"
@ -31,9 +32,10 @@
style="?profileImageStyleLarge"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:minHeight="@dimen/element_size_normal"
app:sivBorder="true"
app:sivBorderWidth="@dimen/line_width_compose_account_profile_image"
app:sivElevation="@dimen/elevation_card" />
app:sivElevation="@dimen/elevation_card"/>
<android.support.v7.widget.CardView
android:layout_width="wrap_content"
@ -53,7 +55,7 @@
android:textAppearance="?android:textAppearanceSmall"
android:textColor="?android:textColorPrimary"
android:textStyle="bold"
tool:text="Name" />
tool:text="Name"/>
</android.support.v7.widget.CardView>
</LinearLayout>