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: 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:
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 ViewGroup widgetFrameView = ((ViewGroup) view.findViewById(android.R.id.widg et_frame));
30 if (widgetFrameView == null)
31 return;
32 widgetFrameView.setVisibility(View.VISIBLE);
33 int rightPaddingDip = android.os.Build.VERSION.SDK_INT < 14 ? 8 : 5;
34 float density = getContext().getResources().getDisplayMetrics().density;
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) (density * rightPaddingDip), refreshImage.getPaddingBottom());
42 refreshImage.setOnClickListener(new OnClickListener()
43 {
44 @Override
45 public void onClick(View v)
46 {
47 if (refreshClickListener != null)
48 refreshClickListener.onClick(refreshImage);
49 }
50 });
51 }
52
53 public void setOnRefreshClickListener(OnClickListener l)
54 {
55 refreshClickListener = l;
56 }
57 }
OLDNEW
« no previous file with comments | « src/org/adblockplus/android/Preferences.java ('k') | src/org/adblockplus/android/SummarizedPreferences.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld