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

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

Issue 5697499218051072: Usage of new API, cleanups (reduced) (Closed)
Left Patch Set: Created April 11, 2014, 1:31 p.m.
Right Patch Set: Even more review issues fixed. Created April 28, 2014, 10:18 a.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/ProxySettings.java ('k') | src/org/adblockplus/android/Starter.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 /* 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 24 matching lines...) Expand all
35 35
36 public RefreshableListPreference(final Context context, final AttributeSet att rs) 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(final 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(this.getContext()); 45 final ImageView refreshImage = new ImageView(getContext());
46 final ViewGroup widgetFrameView = ((ViewGroup)view.findViewById(android.R.id .widget_frame)); 46 final ViewGroup widgetFrameView = ((ViewGroup) view.findViewById(android.R.i d.widget_frame));
47 if (widgetFrameView == null) 47 if (widgetFrameView == null)
48 {
49 return; 48 return;
50 }
51 widgetFrameView.setVisibility(View.VISIBLE); 49 widgetFrameView.setVisibility(View.VISIBLE);
52 final int rightPaddingDip = android.os.Build.VERSION.SDK_INT < 14 ? 8 : 5; 50 final int rightPaddingDip = android.os.Build.VERSION.SDK_INT < 14 ? 8 : 5;
53 final float density = this.getContext().getResources().getDisplayMetrics().d ensity; 51 final float density = getContext().getResources().getDisplayMetrics().densit y;
54 if (widgetFrameView instanceof LinearLayout) 52 if (widgetFrameView instanceof LinearLayout)
55 { 53 {
56 ((LinearLayout)widgetFrameView).setOrientation(LinearLayout.HORIZONTAL); 54 ((LinearLayout) widgetFrameView).setOrientation(LinearLayout.HORIZONTAL);
57 } 55 }
58 widgetFrameView.addView(refreshImage, 0); 56 widgetFrameView.addView(refreshImage, 0);
59 refreshImage.setImageResource(R.drawable.ic_menu_refresh); 57 refreshImage.setImageResource(R.drawable.ic_menu_refresh);
60 refreshImage.setPadding(refreshImage.getPaddingLeft(), refreshImage.getPaddi ngTop(), (int)(density * rightPaddingDip), 58 refreshImage.setPadding(refreshImage.getPaddingLeft(), refreshImage.getPaddi ngTop(), (int) (density * rightPaddingDip), refreshImage.getPaddingBottom());
61 refreshImage.getPaddingBottom());
62 refreshImage.setOnClickListener(new OnClickListener() 59 refreshImage.setOnClickListener(new OnClickListener()
63 { 60 {
64 @Override 61 @Override
65 public void onClick(final View v) 62 public void onClick(final View v)
66 { 63 {
67 if (RefreshableListPreference.this.refreshClickListener != null) 64 if (refreshClickListener != null)
68 { 65 refreshClickListener.onClick(refreshImage);
69 RefreshableListPreference.this.refreshClickListener.onClick(refreshIma ge);
70 }
71 } 66 }
72 }); 67 });
73 } 68 }
74 69
75 public void setOnRefreshClickListener(final OnClickListener l) 70 public void setOnRefreshClickListener(final OnClickListener l)
76 { 71 {
77 this.refreshClickListener = l; 72 refreshClickListener = l;
78 } 73 }
79 } 74 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld