Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Delta Between Two Patch Sets: src/org/adblockplus/android/RefreshableListPreference.java

Issue 8493083: ABP/Android UI (Closed)
Left Patch Set: Created Oct. 5, 2012, 9:42 a.m.
Right Patch Set: ABP/Android UI Created Oct. 12, 2012, 1:24 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « src/org/adblockplus/android/Preferences.java ('k') | src/org/adblockplus/android/SummarizedPreferences.java » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 package org.adblockplus.android; 1 package org.adblockplus.android;
2 2
3 import android.content.Context; 3 import android.content.Context;
4 import android.preference.ListPreference; 4 import android.preference.ListPreference;
5 import android.util.AttributeSet; 5 import android.util.AttributeSet;
6 import android.view.View; 6 import android.view.View;
7 import android.view.View.OnClickListener; 7 import android.view.View.OnClickListener;
8 import android.view.ViewGroup; 8 import android.view.ViewGroup;
9 import android.widget.ImageView; 9 import android.widget.ImageView;
10 import android.widget.LinearLayout; 10 import android.widget.LinearLayout;
11 11
12 /** 12 /**
13 * ListPreference UI with refresh button. 13 * ListPreference UI with refresh button.
14 */ 14 */
15 public class RefreshableListPreference extends ListPreference 15 public class RefreshableListPreference extends ListPreference
16 { 16 {
17 private OnClickListener refreshClickListener; 17 private OnClickListener refreshClickListener;
18 18
19 public RefreshableListPreference(Context context, AttributeSet attrs) 19 public RefreshableListPreference(Context context, AttributeSet attrs)
20 { 20 {
21 super(context, attrs); 21 super(context, attrs);
22 } 22 }
23 23
24 @Override 24 @Override
25 protected void onBindView(View view) 25 protected void onBindView(View view)
26 { 26 {
27 super.onBindView(view); 27 super.onBindView(view);
28 final ImageView refreshImage = new ImageView(getContext()); 28 final ImageView refreshImage = new ImageView(getContext());
29 final ViewGroup widgetFrameView = ((ViewGroup) view.findViewById(android.R.i d.widget_frame)); 29 ViewGroup widgetFrameView = ((ViewGroup) view.findViewById(android.R.id.widg et_frame));
Felix Dahlke 2012/10/09 14:27:29 Why is widgetFrameView final?
Andrey Novikov 2012/10/12 13:19:14 Done.
30 if (widgetFrameView == null) 30 if (widgetFrameView == null)
31 return; 31 return;
32 widgetFrameView.setVisibility(View.VISIBLE); 32 widgetFrameView.setVisibility(View.VISIBLE);
33 final int rightPaddingDip = android.os.Build.VERSION.SDK_INT < 14 ? 8 : 5; 33 int rightPaddingDip = android.os.Build.VERSION.SDK_INT < 14 ? 8 : 5;
34 final float mDensity = getContext().getResources().getDisplayMetrics().densi ty; 34 float density = getContext().getResources().getDisplayMetrics().density;
Felix Dahlke 2012/10/09 14:27:29 Why prefix this variable with "m"? It's local.
Andrey Novikov 2012/10/12 13:19:14 Copy/paste problems.
35 if (widgetFrameView instanceof LinearLayout) 35 if (widgetFrameView instanceof LinearLayout)
36 { 36 {
37 ((LinearLayout) widgetFrameView).setOrientation(LinearLayout.HORIZONTAL); 37 ((LinearLayout) widgetFrameView).setOrientation(LinearLayout.HORIZONTAL);
38 } 38 }
39 widgetFrameView.addView(refreshImage, 0); 39 widgetFrameView.addView(refreshImage, 0);
40 refreshImage.setImageResource(R.drawable.ic_menu_refresh); 40 refreshImage.setImageResource(R.drawable.ic_menu_refresh);
41 refreshImage.setPadding(refreshImage.getPaddingLeft(), refreshImage.getPaddi ngTop(), (int) (mDensity * rightPaddingDip), refreshImage.getPaddingBottom()); 41 refreshImage.setPadding(refreshImage.getPaddingLeft(), refreshImage.getPaddi ngTop(), (int) (density * rightPaddingDip), refreshImage.getPaddingBottom());
42 refreshImage.setOnClickListener(new OnClickListener() { 42 refreshImage.setOnClickListener(new OnClickListener()
43 {
43 @Override 44 @Override
44 public void onClick(View v) 45 public void onClick(View v)
45 { 46 {
46 if (refreshClickListener != null) 47 if (refreshClickListener != null)
47 refreshClickListener.onClick(refreshImage); 48 refreshClickListener.onClick(refreshImage);
48 } 49 }
49 }); 50 });
50 } 51 }
51 52
52 public void setOnRefreshClickListener(OnClickListener l) 53 public void setOnRefreshClickListener(OnClickListener l)
53 { 54 {
54 refreshClickListener = l; 55 refreshClickListener = l;
55 } 56 }
56 } 57 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld