Same issue and solution as #884

This commit is contained in:
Martin Fietz 2016-02-14 07:47:12 +01:00
parent bd3152b737
commit 8d60c3b4e9
1 changed files with 19 additions and 6 deletions

View File

@ -7,6 +7,7 @@ import android.support.v4.content.ContextCompat;
import android.support.v4.view.MotionEventCompat;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.helper.ItemTouchHelper;
import android.text.TextUtils;
import android.util.Log;
import android.view.ContextMenu;
import android.view.LayoutInflater;
@ -28,8 +29,6 @@ import com.bumptech.glide.request.target.GlideDrawableImageViewTarget;
import com.joanzapata.iconify.Iconify;
import com.nineoldandroids.view.ViewHelper;
import org.apache.commons.lang3.StringUtils;
import java.lang.ref.WeakReference;
import de.danoeh.antennapod.R;
@ -214,13 +213,13 @@ public class QueueRecyclerAdapter extends RecyclerView.Adapter<QueueRecyclerAdap
title.setText(item.getTitle());
String pubDateStr = DateUtils.formatAbbrev(mainActivity.get(), item.getPubDate());
int index = 0;
if(StringUtils.countMatches(pubDateStr, ' ') == 1 || StringUtils.countMatches(pubDateStr, ' ') == 2) {
if(countMatches(pubDateStr, ' ') == 1 || countMatches(pubDateStr, ' ') == 2) {
index = pubDateStr.lastIndexOf(' ');
} else if(StringUtils.countMatches(pubDateStr, '.') == 2) {
} else if(countMatches(pubDateStr, '.') == 2) {
index = pubDateStr.lastIndexOf('.');
} else if(StringUtils.countMatches(pubDateStr, '-') == 2) {
} else if(countMatches(pubDateStr, '-') == 2) {
index = pubDateStr.lastIndexOf('-');
} else if(StringUtils.countMatches(pubDateStr, '/') == 2) {
} else if(countMatches(pubDateStr, '/') == 2) {
index = pubDateStr.lastIndexOf('/');
}
if(index > 0) {
@ -376,4 +375,18 @@ public class QueueRecyclerAdapter extends RecyclerView.Adapter<QueueRecyclerAdap
*/
void onItemClear();
}
// Oh Xiaomi, I hate you so much. How did you manage to fuck this up?
private static int countMatches(final CharSequence str, final char ch) {
if (TextUtils.isEmpty(str)) {
return 0;
}
int count = 0;
for (int i = 0; i < str.length(); i++) {
if (ch == str.charAt(i)) {
count++;
}
}
return count;
}
}