Skip to content

Commit

Permalink
full cached users.
Browse files Browse the repository at this point in the history
  • Loading branch information
mariotaku committed Dec 15, 2012
1 parent 02416bc commit 1c11057
Show file tree
Hide file tree
Showing 19 changed files with 516 additions and 391 deletions.
2 changes: 1 addition & 1 deletion TODOS
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
2012-12-14 2012-12-14
* option to enable/disable full image preview. * option to enable/disable full image preview.
2012-12-15 2012-12-15
* full user caching (store in cached_users tab) [FINISHED] full user caching (store in cached_users table)
19 changes: 10 additions & 9 deletions res/values-zh-rCN/strings.xml
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -212,10 +212,6 @@
<string name="lists_following_user">关注这个用户的列表</string> <string name="lists_following_user">关注这个用户的列表</string>
<string name="Ntweets_quantity_one">你有一条新推文</string> <string name="Ntweets_quantity_one">你有一条新推文</string>
<string name="Ntweets_quantity_other">你有 <xliff:g id="items">%d</xliff:g> 条新推文</string> <string name="Ntweets_quantity_other">你有 <xliff:g id="items">%d</xliff:g> 条新推文</string>




<string name="item_1_minute">1分钟</string> <string name="item_1_minute">1分钟</string>
<string name="item_3_minutes">3分钟</string> <string name="item_3_minutes">3分钟</string>
<string name="item_5_minutes">5分钟</string> <string name="item_5_minutes">5分钟</string>
Expand All @@ -229,7 +225,7 @@
<string name="solid_color_background">纯色背景</string> <string name="solid_color_background">纯色背景</string>
<string name="solid_color_background_summary">如果你的设备是AMOLED屏幕的话,启用这个会有所帮助</string> <string name="solid_color_background_summary">如果你的设备是AMOLED屏幕的话,启用这个会有所帮助</string>
<string name="following_you">正在关注你</string> <string name="following_you">正在关注你</string>
<string name="user_list">用户列表</string> <string name="user_list">列表</string>
<string name="trends_location">本地趋势的位置</string> <string name="trends_location">本地趋势的位置</string>
<string name="trends_location_summary">设定位置,以显示本地趋势</string> <string name="trends_location_summary">设定位置,以显示本地趋势</string>
<string name="trends">话题</string> <string name="trends">话题</string>
Expand All @@ -241,12 +237,12 @@
<string name="add_member">添加成员</string> <string name="add_member">添加成员</string>
<string name="add_successfully">添加成功</string> <string name="add_successfully">添加成功</string>
<string name="create_successfully">创建成功</string> <string name="create_successfully">创建成功</string>
<string name="new_user_list">新用户列表</string> <string name="new_user_list">新列表</string>
<string name="is_public">公开</string> <string name="is_public">公开</string>
<string name="send_direct_message">发送私信</string> <string name="send_direct_message">发送私信</string>
<string name="extensions">扩展</string> <string name="extensions">扩展</string>
<string name="open_with_extensions">使用扩展打开</string> <string name="open_with_extensions">使用扩展打开</string>
<string name="view_user_list">查看用户列表</string> <string name="view_user_list">查看列表</string>
<string name="uninstall">卸载</string> <string name="uninstall">卸载</string>
<string name="users_retweeted_this">转推了这条推文的用户</string> <string name="users_retweeted_this">转推了这条推文的用户</string>
<string name="saved_searches">已保存的搜索</string> <string name="saved_searches">已保存的搜索</string>
Expand All @@ -263,7 +259,7 @@
<string name="invalid_settings">发现无效设定</string> <string name="invalid_settings">发现无效设定</string>
<string name="icon">图标</string> <string name="icon">图标</string>
<string name="pick_file">选取文件</string> <string name="pick_file">选取文件</string>
<string name="user_timeline">用户时间线</string> <string name="user_timeline">时间线</string>
<string name="notification_ringtone">铃声</string> <string name="notification_ringtone">铃声</string>
<string name="notification_light_color">灯光颜色</string> <string name="notification_light_color">灯光颜色</string>
<string name="share_format">分享格式</string> <string name="share_format">分享格式</string>
Expand Down Expand Up @@ -375,5 +371,10 @@
<string name="pull_to_load_conversation_release_label">释放加载对话…</string> <string name="pull_to_load_conversation_release_label">释放加载对话…</string>
<string name="text_copied">文本已复制到剪贴板</string> <string name="text_copied">文本已复制到剪贴板</string>
<string name="load_from_here">从这里加载</string> <string name="load_from_here">从这里加载</string>
<string name="amount_usd">总额(美元)</string>
<string name="donate">捐助</string>
<string name="hashtag">话题标签</string>
<string name="links">链接</string>
<string name="edit_profile">编辑个人资料</string>


</resources> </resources>
2 changes: 1 addition & 1 deletion src/org/mariotaku/twidere/Constants.java
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public interface Constants extends TwitterConstants {
public static final String PERMISSION_PREFERENCES_NAME = "permissions"; public static final String PERMISSION_PREFERENCES_NAME = "permissions";


public static final String DATABASES_NAME = "twidere.sqlite"; public static final String DATABASES_NAME = "twidere.sqlite";
public static final int DATABASES_VERSION = 33; public static final int DATABASES_VERSION = 34;


// The following 4 constants are not included in source code, you'd better // The following 4 constants are not included in source code, you'd better
// use your own. // use your own.
Expand Down
41 changes: 20 additions & 21 deletions src/org/mariotaku/twidere/activity/ImageViewerActivity.java
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@
import android.support.v4.app.LoaderManager.LoaderCallbacks; import android.support.v4.app.LoaderManager.LoaderCallbacks;
import android.support.v4.content.AsyncTaskLoader; import android.support.v4.content.AsyncTaskLoader;
import android.support.v4.content.Loader; import android.support.v4.content.Loader;
import android.util.Log;
import android.view.View; import android.view.View;
import android.view.View.OnClickListener; import android.view.View.OnClickListener;
import android.widget.ImageButton; import android.widget.ImageButton;
Expand Down Expand Up @@ -316,7 +315,7 @@ private Bitmap decodeFile(final File f) {
if (o.outHeight <= 0) return null; if (o.outHeight <= 0) return null;
final BitmapFactory.Options o1 = new BitmapFactory.Options(); final BitmapFactory.Options o1 = new BitmapFactory.Options();
final double size = Math.max(o.outWidth, o.outHeight); final double size = Math.max(o.outWidth, o.outHeight);
o1.inSampleSize = (size > max_texture_size) ? (int) Math.round(size / max_texture_size) + 1: 1; o1.inSampleSize = size > max_texture_size ? (int) Math.round(size / max_texture_size) + 1 : 1;
Bitmap bitmap = null; Bitmap bitmap = null;
while (bitmap == null) { while (bitmap == null) {
try { try {
Expand All @@ -335,23 +334,36 @@ private Bitmap decodeFile(final File f) {
return null; return null;
} }


private String getURLFilename(final String url) {
if (url == null) return null;
return url.replaceFirst("https?:\\/\\/", "").replaceAll("[^a-zA-Z0-9]", "_");
}

private void init() {
/* Find the dir to save cached images. */
mCacheDir = getBestCacheDir(mContext, CACHE_DIR_NAME);
if (mCacheDir != null && !mCacheDir.exists()) {
mCacheDir.mkdirs();
}
}

public static int getMaximumTextureSize() { public static int getMaximumTextureSize() {
EGL10 egl = (EGL10) EGLContext.getEGL(); final EGL10 egl = (EGL10) EGLContext.getEGL();
EGLDisplay display = egl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY); final EGLDisplay display = egl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY);


// Initialise // Initialise
int[] version = new int[2]; final int[] version = new int[2];
egl.eglInitialize(display, version); egl.eglInitialize(display, version);


// Query total number of configurations // Query total number of configurations
int[] totalConfigurations = new int[1]; final int[] totalConfigurations = new int[1];
egl.eglGetConfigs(display, null, 0, totalConfigurations); egl.eglGetConfigs(display, null, 0, totalConfigurations);


// Query actual list configurations // Query actual list configurations
EGLConfig[] configurationsList = new EGLConfig[totalConfigurations[0]]; final EGLConfig[] configurationsList = new EGLConfig[totalConfigurations[0]];
egl.eglGetConfigs(display, configurationsList, totalConfigurations[0], totalConfigurations); egl.eglGetConfigs(display, configurationsList, totalConfigurations[0], totalConfigurations);


int[] textureSize = new int[1]; final int[] textureSize = new int[1];
int maximumTextureSize = 0; int maximumTextureSize = 0;


// Iterate through all the configurations to located the maximum // Iterate through all the configurations to located the maximum
Expand All @@ -373,19 +385,6 @@ public static int getMaximumTextureSize() {
return maximumTextureSize; return maximumTextureSize;
} }


private String getURLFilename(final String url) {
if (url == null) return null;
return url.replaceFirst("https?:\\/\\/", "").replaceAll("[^a-zA-Z0-9]", "_");
}

private void init() {
/* Find the dir to save cached images. */
mCacheDir = getBestCacheDir(mContext, CACHE_DIR_NAME);
if (mCacheDir != null && !mCacheDir.exists()) {
mCacheDir.mkdirs();
}
}

public static class Result { public static class Result {
public final Bitmap bitmap; public final Bitmap bitmap;
public final File file; public final File file;
Expand Down
4 changes: 3 additions & 1 deletion src/org/mariotaku/twidere/adapter/AutoCompleteAdapter.java
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ public class AutoCompleteAdapter extends SimpleCursorAdapter implements Constant


private static final String[] FROM = new String[0]; private static final String[] FROM = new String[0];
private static final int[] TO = new int[0]; private static final int[] TO = new int[0];
private static final String[] CACHED_USERS_COLUMNS = new String[] { CachedUsers._ID, CachedUsers.NAME,
CachedUsers.SCREEN_NAME, CachedUsers.PROFILE_IMAGE_URL };


private final ContentResolver mResolver; private final ContentResolver mResolver;
private final LazyImageLoader mProfileImageLoader; private final LazyImageLoader mProfileImageLoader;
Expand Down Expand Up @@ -149,7 +151,7 @@ public Cursor runQueryOnBackgroundThread(final CharSequence constraint) {
where.append(CachedUsers.SCREEN_NAME + " LIKE '" + constraint_escaped + "%' ESCAPE '^'"); where.append(CachedUsers.SCREEN_NAME + " LIKE '" + constraint_escaped + "%' ESCAPE '^'");
where.append(" OR "); where.append(" OR ");
where.append(CachedUsers.NAME + " LIKE '" + constraint_escaped + "%' ESCAPE '^'"); where.append(CachedUsers.NAME + " LIKE '" + constraint_escaped + "%' ESCAPE '^'");
return mResolver.query(CachedUsers.CONTENT_URI, CachedUsers.COLUMNS, return mResolver.query(CachedUsers.CONTENT_URI, CACHED_USERS_COLUMNS,
constraint_escaped != null ? where.toString() : null, null, null); constraint_escaped != null ? where.toString() : null, null, null);
} else { } else {
final String where = CachedHashtags.NAME + " LIKE '" + constraint_escaped + "%' ESCAPE '^'"; final String where = CachedHashtags.NAME + " LIKE '" + constraint_escaped + "%' ESCAPE '^'";
Expand Down
2 changes: 1 addition & 1 deletion src/org/mariotaku/twidere/adapter/UsersAdapter.java
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public View getView(final int position, final View convertView, final ViewGroup
holder.description.setText(user.description); holder.description.setText(user.description);
holder.profile_image.setVisibility(mDisplayProfileImage ? View.VISIBLE : View.GONE); holder.profile_image.setVisibility(mDisplayProfileImage ? View.VISIBLE : View.GONE);
if (mDisplayProfileImage) { if (mDisplayProfileImage) {
mProfileImageLoader.displayImage(user.profile_image_url_string, holder.profile_image); mProfileImageLoader.displayImage(user.profile_image_url, holder.profile_image);
} }


return view; return view;
Expand Down
8 changes: 4 additions & 4 deletions src/org/mariotaku/twidere/fragment/StatusFragment.java
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -112,24 +112,25 @@ public class StatusFragment extends ParcelableStatusesListFragment implements On
OnImageClickListener { OnImageClickListener {


private static final int LOADER_ID_STATUS = 1; private static final int LOADER_ID_STATUS = 1;

private static final int LOADER_ID_FOLLOW = 2; private static final int LOADER_ID_FOLLOW = 2;
private static final int LOADER_ID_LOCATION = 3; private static final int LOADER_ID_LOCATION = 3;
private static final int LOADER_ID_CONVERSATION = 4; private static final int LOADER_ID_CONVERSATION = 4;

private long mAccountId, mStatusId; private long mAccountId, mStatusId;
private ParcelableStatus mStatus;


private boolean mLoadMoreAutomatically; private boolean mLoadMoreAutomatically;
private boolean mFollowInfoDisplayed, mLocationInfoDisplayed; private boolean mFollowInfoDisplayed, mLocationInfoDisplayed;
private boolean mStatusLoaderInitialized, mLocationLoaderInitialized, mConversationLoaderInitialized; private boolean mStatusLoaderInitialized, mLocationLoaderInitialized, mConversationLoaderInitialized;
private boolean mFollowInfoLoaderInitialized;; private boolean mFollowInfoLoaderInitialized;;
private boolean mShouldScroll; private boolean mShouldScroll;
private SharedPreferences mPreferences;


private SharedPreferences mPreferences;
private TwitterWrapper mTwitterWrapper; private TwitterWrapper mTwitterWrapper;
private LazyImageLoader mProfileImageLoader; private LazyImageLoader mProfileImageLoader;

private TextView mNameView, mScreenNameView, mTextView, mTimeAndSourceView, mInReplyToView, mLocationView, private TextView mNameView, mScreenNameView, mTextView, mTimeAndSourceView, mInReplyToView, mLocationView,
mRetweetedStatusView; mRetweetedStatusView;

private ImageView mProfileImageView; private ImageView mProfileImageView;
private Button mFollowButton; private Button mFollowButton;
private View mMainContent, mFollowIndicator, mImagePreviewContainer; private View mMainContent, mFollowIndicator, mImagePreviewContainer;
Expand All @@ -141,7 +142,6 @@ public class StatusFragment extends ParcelableStatusesListFragment implements On
private View mLoadImagesIndicator; private View mLoadImagesIndicator;
private ExtendedFrameLayout mStatusContainer; private ExtendedFrameLayout mStatusContainer;
private ListView mListView; private ListView mListView;
private ParcelableStatus mStatus;


private final BroadcastReceiver mStatusReceiver = new BroadcastReceiver() { private final BroadcastReceiver mStatusReceiver = new BroadcastReceiver() {


Expand Down
Loading

0 comments on commit 1c11057

Please sign in to comment.