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

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

Issue 5697499218051072: Usage of new API, cleanups (reduced) (Closed)
Patch Set: Addressed new review issues Created April 28, 2014, 8:34 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
1 /* 1 /*
2 * This file is part of Adblock Plus <http://adblockplus.org/>, 2 * This file is part of Adblock Plus <http://adblockplus.org/>,
3 * Copyright (C) 2006-2014 Eyeo GmbH 3 * Copyright (C) 2006-2014 Eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 15 matching lines...) Expand all
26 import android.widget.ImageView; 26 import android.widget.ImageView;
27 import android.widget.LinearLayout; 27 import android.widget.LinearLayout;
28 28
29 /** 29 /**
30 * ListPreference UI with refresh button. 30 * ListPreference UI with refresh button.
31 */ 31 */
32 public class RefreshableListPreference extends ListPreference 32 public class RefreshableListPreference extends ListPreference
33 { 33 {
34 private OnClickListener refreshClickListener; 34 private OnClickListener refreshClickListener;
35 35
36 public RefreshableListPreference(Context context, AttributeSet attrs) 36 public RefreshableListPreference(final Context context, final AttributeSet att rs)
37 { 37 {
38 super(context, attrs); 38 super(context, attrs);
39 } 39 }
40 40
41 @Override 41 @Override
42 protected void onBindView(View view) 42 protected void onBindView(final View view)
43 { 43 {
44 super.onBindView(view); 44 super.onBindView(view);
45 final ImageView refreshImage = new ImageView(getContext()); 45 final ImageView refreshImage = new ImageView(getContext());
46 ViewGroup widgetFrameView = ((ViewGroup) view.findViewById(android.R.id.widg et_frame)); 46 final ViewGroup widgetFrameView = ((ViewGroup) view.findViewById(android.R.i d.widget_frame));
47 if (widgetFrameView == null) 47 if (widgetFrameView == null)
48 return; 48 return;
49 widgetFrameView.setVisibility(View.VISIBLE); 49 widgetFrameView.setVisibility(View.VISIBLE);
50 int rightPaddingDip = android.os.Build.VERSION.SDK_INT < 14 ? 8 : 5; 50 final int rightPaddingDip = android.os.Build.VERSION.SDK_INT < 14 ? 8 : 5;
51 float density = getContext().getResources().getDisplayMetrics().density; 51 final float density = getContext().getResources().getDisplayMetrics().densit y;
52 if (widgetFrameView instanceof LinearLayout) 52 if (widgetFrameView instanceof LinearLayout)
53 { 53 {
54 ((LinearLayout) widgetFrameView).setOrientation(LinearLayout.HORIZONTAL); 54 ((LinearLayout) widgetFrameView).setOrientation(LinearLayout.HORIZONTAL);
55 } 55 }
56 widgetFrameView.addView(refreshImage, 0); 56 widgetFrameView.addView(refreshImage, 0);
57 refreshImage.setImageResource(R.drawable.ic_menu_refresh); 57 refreshImage.setImageResource(R.drawable.ic_menu_refresh);
58 refreshImage.setPadding(refreshImage.getPaddingLeft(), refreshImage.getPaddi ngTop(), (int) (density * rightPaddingDip), refreshImage.getPaddingBottom()); 58 refreshImage.setPadding(refreshImage.getPaddingLeft(), refreshImage.getPaddi ngTop(), (int) (density * rightPaddingDip), refreshImage.getPaddingBottom());
59 refreshImage.setOnClickListener(new OnClickListener() 59 refreshImage.setOnClickListener(new OnClickListener()
60 { 60 {
61 @Override 61 @Override
62 public void onClick(View v) 62 public void onClick(final View v)
63 { 63 {
64 if (refreshClickListener != null) 64 if (refreshClickListener != null)
65 refreshClickListener.onClick(refreshImage); 65 refreshClickListener.onClick(refreshImage);
66 } 66 }
67 }); 67 });
68 } 68 }
69 69
70 public void setOnRefreshClickListener(OnClickListener l) 70 public void setOnRefreshClickListener(final OnClickListener l)
71 { 71 {
72 refreshClickListener = l; 72 refreshClickListener = l;
73 } 73 }
74 } 74 }
OLDNEW
« no previous file with comments | « src/org/adblockplus/android/ProxySettings.java ('k') | src/org/adblockplus/android/Starter.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld