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

Side by Side Diff: src/org/adblockplus/android/RefreshableListPreference.java

Issue 8493083: ABP/Android UI (Closed)
Patch Set: Created Oct. 5, 2012, 9:42 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 package org.adblockplus.android;
2
3 import android.content.Context;
4 import android.preference.ListPreference;
5 import android.util.AttributeSet;
6 import android.view.View;
7 import android.view.View.OnClickListener;
8 import android.view.ViewGroup;
9 import android.widget.ImageView;
10 import android.widget.LinearLayout;
11
12 /**
13 * ListPreference UI with refresh button.
14 */
15 public class RefreshableListPreference extends ListPreference
16 {
17 private OnClickListener refreshClickListener;
18
19 public RefreshableListPreference(Context context, AttributeSet attrs)
20 {
21 super(context, attrs);
22 }
23
24 @Override
25 protected void onBindView(View view)
26 {
27 super.onBindView(view);
28 final ImageView refreshImage = new ImageView(getContext());
29 final ViewGroup widgetFrameView = ((ViewGroup) view.findViewById(android.R.i d.widget_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)
31 return;
32 widgetFrameView.setVisibility(View.VISIBLE);
33 final int rightPaddingDip = android.os.Build.VERSION.SDK_INT < 14 ? 8 : 5;
34 final float mDensity = getContext().getResources().getDisplayMetrics().densi ty;
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)
36 {
37 ((LinearLayout) widgetFrameView).setOrientation(LinearLayout.HORIZONTAL);
38 }
39 widgetFrameView.addView(refreshImage, 0);
40 refreshImage.setImageResource(R.drawable.ic_menu_refresh);
41 refreshImage.setPadding(refreshImage.getPaddingLeft(), refreshImage.getPaddi ngTop(), (int) (mDensity * rightPaddingDip), refreshImage.getPaddingBottom());
42 refreshImage.setOnClickListener(new OnClickListener() {
43 @Override
44 public void onClick(View v)
45 {
46 if (refreshClickListener != null)
47 refreshClickListener.onClick(refreshImage);
48 }
49 });
50 }
51
52 public void setOnRefreshClickListener(OnClickListener l)
53 {
54 refreshClickListener = l;
55 }
56 }
OLDNEW

Powered by Google App Engine
This is Rietveld