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

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

Issue 8363097: ABP/Android preferences UI (Closed) Base URL: https://hg.adblockplus.org/adblockplusandroid/
Patch Set: Created Sept. 14, 2012, 8:20 p.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 public class RefreshableListPreference extends ListPreference
13 {
14 private OnClickListener refreshClickListener;
15
16 public RefreshableListPreference(Context context, AttributeSet attrs)
17 {
18 super(context, attrs);
19 }
20
21 @Override
22 protected void onBindView(View view)
23 {
24 super.onBindView(view);
25 final ImageView refreshImage = new ImageView(getContext());
26 final ViewGroup widgetFrameView = ((ViewGroup) view.findViewById (android.R.id.widget_frame));
Felix Dahlke 2012/09/18 15:32:49 Why is widgetFrameView final?
27 if (widgetFrameView == null)
28 return;
29 widgetFrameView.setVisibility(View.VISIBLE);
30 final int rightPaddingDip = android.os.Build.VERSION.SDK_INT < 1 4 ? 8 : 5;
31 final float mDensity = getContext().getResources().getDisplayMet rics().density;
Felix Dahlke 2012/09/18 15:32:49 Why prefix mDensity with an "m"? It's a local vari
32 if (widgetFrameView instanceof LinearLayout)
33 {
34 ((LinearLayout) widgetFrameView).setOrientation(LinearLa yout.HORIZONTAL);
35 }
36 widgetFrameView.addView(refreshImage, 0);
37 refreshImage.setImageResource(R.drawable.ic_menu_refresh);
38 refreshImage.setPadding(refreshImage.getPaddingLeft(), refreshIm age.getPaddingTop(), (int) (mDensity * rightPaddingDip), refreshImage.getPadding Bottom());
39 refreshImage.setOnClickListener(new OnClickListener() {
40 @Override
41 public void onClick(View v)
42 {
43 if (refreshClickListener != null)
44 refreshClickListener.onClick(refreshImag e);
45 }
46 });
47 }
48
49 public void setOnRefreshClickListener(OnClickListener l)
50 {
51 refreshClickListener = l;
52 }
53 }
OLDNEW

Powered by Google App Engine
This is Rietveld