From 3998cb8e646625b4c9370b0eb4f55ff3ec128cb0 Mon Sep 17 00:00:00 2001 From: Mariotaku Lee Date: Sun, 14 Feb 2016 22:22:21 +0800 Subject: [PATCH] improved card preview preference --- twidere/src/main/AndroidManifest.xml | 2 +- .../main/java/okhttp3/RealCallAccessor.java | 20 ------------------- .../support/BrowserSignInActivity.java | 5 +---- .../twidere/adapter/AbsUsersAdapter.java | 17 ++++------------ .../adapter/ParcelableUsersAdapter.java | 4 ++-- .../fragment/support/AbsUsersFragment.java | 11 +++++----- .../support/ParcelableUsersFragment.java | 5 +++-- .../preference/CardPreviewPreference.java | 4 ++-- .../layout_preferences_card_preview.xml | 9 +++++++++ ...ayout_preferences_card_preview_compact.xml | 9 +++++++++ 10 files changed, 37 insertions(+), 49 deletions(-) delete mode 100644 twidere/src/main/java/okhttp3/RealCallAccessor.java create mode 100644 twidere/src/main/res/layout/layout_preferences_card_preview.xml create mode 100644 twidere/src/main/res/layout/layout_preferences_card_preview_compact.xml diff --git a/twidere/src/main/AndroidManifest.xml b/twidere/src/main/AndroidManifest.xml index 042d5a7e9..aef42bfef 100644 --- a/twidere/src/main/AndroidManifest.xml +++ b/twidere/src/main/AndroidManifest.xml @@ -215,7 +215,7 @@ diff --git a/twidere/src/main/java/okhttp3/RealCallAccessor.java b/twidere/src/main/java/okhttp3/RealCallAccessor.java deleted file mode 100644 index d9eeb431c..000000000 --- a/twidere/src/main/java/okhttp3/RealCallAccessor.java +++ /dev/null @@ -1,20 +0,0 @@ -package okhttp3; - -import android.support.annotation.Nullable; - -import okhttp3.internal.http.HttpEngine; - -/** - * Created by mariotaku on 16/2/13. - */ -public class RealCallAccessor { - - @Nullable - public static HttpEngine getHttpEngine(Call call) { - if (call instanceof RealCall) { - return ((RealCall) call).engine; - } - return null; - } - -} diff --git a/twidere/src/main/java/org/mariotaku/twidere/activity/support/BrowserSignInActivity.java b/twidere/src/main/java/org/mariotaku/twidere/activity/support/BrowserSignInActivity.java index b70955dc0..dc31a941d 100644 --- a/twidere/src/main/java/org/mariotaku/twidere/activity/support/BrowserSignInActivity.java +++ b/twidere/src/main/java/org/mariotaku/twidere/activity/support/BrowserSignInActivity.java @@ -58,12 +58,10 @@ import static android.text.TextUtils.isEmpty; import static org.mariotaku.twidere.util.Utils.getNonEmptyString; @SuppressLint("SetJavaScriptEnabled") -public class BrowserSignInActivity extends BaseSupportDialogActivity { +public class BrowserSignInActivity extends BaseAppCompatActivity { private static final String INJECT_CONTENT = "javascript:window.injector.processHTML(''+document.getElementsByTagName('html')[0].innerHTML+'');"; - private SharedPreferences mPreferences; - private WebView mWebView; private View mProgressContainer; @@ -102,7 +100,6 @@ public class BrowserSignInActivity extends BaseSupportDialogActivity { protected void onCreate(final Bundle savedInstanceState) { requestWindowFeature(Window.FEATURE_NO_TITLE); super.onCreate(savedInstanceState); - mPreferences = getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE); setContentView(R.layout.activity_browser_sign_in); mWebView.setWebViewClient(new AuthorizationWebViewClient(this)); mWebView.setVerticalScrollBarEnabled(false); diff --git a/twidere/src/main/java/org/mariotaku/twidere/adapter/AbsUsersAdapter.java b/twidere/src/main/java/org/mariotaku/twidere/adapter/AbsUsersAdapter.java index b7c564534..2a8663f62 100644 --- a/twidere/src/main/java/org/mariotaku/twidere/adapter/AbsUsersAdapter.java +++ b/twidere/src/main/java/org/mariotaku/twidere/adapter/AbsUsersAdapter.java @@ -20,7 +20,6 @@ package org.mariotaku.twidere.adapter; import android.content.Context; -import android.support.v7.widget.CardView; import android.support.v7.widget.RecyclerView.ViewHolder; import android.view.LayoutInflater; import android.view.View; @@ -42,13 +41,12 @@ public abstract class AbsUsersAdapter extends LoadMoreSupportAdapter extends LoadMoreSupportAdapter extends LoadMoreSupportAdapter private List mData; - public ParcelableUsersAdapter(Context context, boolean compact) { - super(context, compact); + public ParcelableUsersAdapter(Context context) { + super(context); } @Override diff --git a/twidere/src/main/java/org/mariotaku/twidere/fragment/support/AbsUsersFragment.java b/twidere/src/main/java/org/mariotaku/twidere/fragment/support/AbsUsersFragment.java index 860ba8819..cb930db56 100644 --- a/twidere/src/main/java/org/mariotaku/twidere/fragment/support/AbsUsersFragment.java +++ b/twidere/src/main/java/org/mariotaku/twidere/fragment/support/AbsUsersFragment.java @@ -122,15 +122,16 @@ abstract class AbsUsersFragment extends AbsContentListRecyclerViewFragment return true; } - protected ParcelableUser getSelectedUser() { - //TODO return selected - return null; - } - protected abstract boolean hasMoreData(Data data); protected abstract Loader onCreateUsersLoader(final Context context, @NonNull final Bundle args, final boolean fromUser); + + @Override + protected void setupRecyclerView(Context context, boolean compact) { + + } + } diff --git a/twidere/src/main/java/org/mariotaku/twidere/fragment/support/ParcelableUsersFragment.java b/twidere/src/main/java/org/mariotaku/twidere/fragment/support/ParcelableUsersFragment.java index 6be2ae29a..4a271c7c4 100644 --- a/twidere/src/main/java/org/mariotaku/twidere/fragment/support/ParcelableUsersFragment.java +++ b/twidere/src/main/java/org/mariotaku/twidere/fragment/support/ParcelableUsersFragment.java @@ -25,6 +25,7 @@ import android.support.annotation.NonNull; import android.support.v4.app.LoaderManager; import android.support.v4.content.Loader; +import org.mariotaku.twidere.adapter.AbsUsersAdapter; import org.mariotaku.twidere.adapter.ParcelableUsersAdapter; import org.mariotaku.twidere.adapter.iface.ILoadMoreSupportAdapter.IndicatorPosition; import org.mariotaku.twidere.model.ParcelableUser; @@ -41,8 +42,8 @@ public abstract class ParcelableUsersFragment extends AbsUsersFragment> onCreateAdapter(Context context, boolean compact) { + return new ParcelableUsersAdapter(context); } protected long getAccountId() { diff --git a/twidere/src/main/java/org/mariotaku/twidere/preference/CardPreviewPreference.java b/twidere/src/main/java/org/mariotaku/twidere/preference/CardPreviewPreference.java index e076d372b..0ed83b878 100644 --- a/twidere/src/main/java/org/mariotaku/twidere/preference/CardPreviewPreference.java +++ b/twidere/src/main/java/org/mariotaku/twidere/preference/CardPreviewPreference.java @@ -74,9 +74,9 @@ public class CardPreviewPreference extends Preference implements Constants, OnSh protected void setLayoutResources(SharedPreferences preferences) { if (preferences.getBoolean(KEY_COMPACT_CARDS, false)) { - setLayoutResource(R.layout.card_item_status_compact); + setLayoutResource(R.layout.layout_preferences_card_preview_compact); } else { - setLayoutResource(R.layout.card_item_status); + setLayoutResource(R.layout.layout_preferences_card_preview); } } diff --git a/twidere/src/main/res/layout/layout_preferences_card_preview.xml b/twidere/src/main/res/layout/layout_preferences_card_preview.xml new file mode 100644 index 000000000..842078d56 --- /dev/null +++ b/twidere/src/main/res/layout/layout_preferences_card_preview.xml @@ -0,0 +1,9 @@ + + + + + + \ No newline at end of file diff --git a/twidere/src/main/res/layout/layout_preferences_card_preview_compact.xml b/twidere/src/main/res/layout/layout_preferences_card_preview_compact.xml new file mode 100644 index 000000000..04aa304e8 --- /dev/null +++ b/twidere/src/main/res/layout/layout_preferences_card_preview_compact.xml @@ -0,0 +1,9 @@ + + + + + + \ No newline at end of file