Skip to content

Commit 345af04

Browse files
Fragments to use View Binding
1 parent defa6ca commit 345af04

File tree

6 files changed

+31
-32
lines changed

6 files changed

+31
-32
lines changed

app/build.properties

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#Build Properties
2-
#Sun Mar 08 10:46:31 EDT 2020
2+
#Sun Mar 08 11:21:25 EDT 2020
33
version_minor=1
4-
version_build=22
4+
version_build=23
55
version_patch=1
6-
version_major=2
76
version_store=51
7+
version_major=2

app/src/main/java/com/vrem/wifianalyzer/wifi/channelavailable/ChannelAvailableFragment.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
import android.view.ViewGroup;
2525

2626
import com.vrem.wifianalyzer.MainContext;
27-
import com.vrem.wifianalyzer.R;
27+
import com.vrem.wifianalyzer.databinding.ChannelAvailableContentBinding;
2828
import com.vrem.wifianalyzer.wifi.band.WiFiChannelCountry;
2929

3030
import java.util.ArrayList;
@@ -39,11 +39,11 @@ public class ChannelAvailableFragment extends ListFragment {
3939

4040
@Nullable
4141
@Override
42-
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
43-
View view = inflater.inflate(R.layout.channel_available_content, container, false);
42+
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
43+
ChannelAvailableContentBinding binding = ChannelAvailableContentBinding.inflate(inflater, container, false);
4444
channelAvailableAdapter = new ChannelAvailableAdapter(getActivity(), getChannelAvailable());
4545
setListAdapter(channelAvailableAdapter);
46-
return view;
46+
return binding.getRoot();
4747
}
4848

4949
@Override

app/src/main/java/com/vrem/wifianalyzer/wifi/channelgraph/ChannelGraphFragment.java

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
import com.vrem.util.BuildUtils;
2828
import com.vrem.wifianalyzer.MainContext;
29-
import com.vrem.wifianalyzer.R;
29+
import com.vrem.wifianalyzer.databinding.GraphContentBinding;
3030
import com.vrem.wifianalyzer.wifi.graphutils.GraphViewAdd;
3131

3232
import org.apache.commons.collections4.IterableUtils;
@@ -42,28 +42,27 @@ public class ChannelGraphFragment extends Fragment implements OnRefreshListener
4242

4343
@Override
4444
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
45-
View view = inflater.inflate(R.layout.graph_content, container, false);
45+
GraphContentBinding binding = GraphContentBinding.inflate(inflater, container, false);
4646

47-
swipeRefreshLayout = view.findViewById(R.id.graphRefresh);
47+
swipeRefreshLayout = binding.graphRefresh;
4848
swipeRefreshLayout.setOnRefreshListener(this);
4949
if (BuildUtils.isVersionP()) {
5050
swipeRefreshLayout.setRefreshing(false);
5151
swipeRefreshLayout.setEnabled(false);
5252
}
5353

54-
LinearLayout linearLayout = view.findViewById(R.id.graphNavigation);
54+
LinearLayout linearLayout = binding.graphNavigation;
5555
ChannelGraphNavigation channelGraphNavigation = new ChannelGraphNavigation(linearLayout, getActivity());
5656
channelGraphAdapter = new ChannelGraphAdapter(channelGraphNavigation);
57-
addGraphViews(swipeRefreshLayout, channelGraphAdapter);
57+
addGraphViews(binding, channelGraphAdapter);
5858

5959
MainContext.INSTANCE.getScannerService().register(channelGraphAdapter);
6060

61-
return view;
61+
return binding.getRoot();
6262
}
6363

64-
private void addGraphViews(View view, ChannelGraphAdapter channelGraphAdapter) {
65-
IterableUtils.forEach(channelGraphAdapter.getGraphViews(),
66-
new GraphViewAdd(view.findViewById(R.id.graphFlipper)));
64+
private void addGraphViews(GraphContentBinding binding, ChannelGraphAdapter channelGraphAdapter) {
65+
IterableUtils.forEach(channelGraphAdapter.getGraphViews(), new GraphViewAdd(binding.graphFlipper));
6766
}
6867

6968
@Override

app/src/main/java/com/vrem/wifianalyzer/wifi/channelrating/ChannelRatingFragment.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import com.vrem.util.BuildUtils;
2929
import com.vrem.wifianalyzer.MainContext;
3030
import com.vrem.wifianalyzer.R;
31+
import com.vrem.wifianalyzer.databinding.ChannelRatingContentBinding;
3132

3233
import androidx.annotation.NonNull;
3334
import androidx.fragment.app.Fragment;
@@ -40,25 +41,23 @@ public class ChannelRatingFragment extends Fragment implements OnRefreshListener
4041

4142
@Override
4243
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
44+
ChannelRatingContentBinding binding = ChannelRatingContentBinding.inflate(inflater, container, false);
4345

44-
View view = inflater.inflate(R.layout.channel_rating_content, container, false);
45-
46-
swipeRefreshLayout = view.findViewById(R.id.channelRatingRefresh);
46+
swipeRefreshLayout = binding.channelRatingRefresh;
4747
swipeRefreshLayout.setOnRefreshListener(this);
4848
if (BuildUtils.isVersionP()) {
4949
swipeRefreshLayout.setRefreshing(false);
5050
swipeRefreshLayout.setEnabled(false);
5151
}
5252

53-
TextView bestChannels = view.findViewById(R.id.channelRatingBestChannels);
54-
ListView listView = view.findViewById(R.id.channelRatingView);
55-
53+
TextView bestChannels = binding.channelRatingBest.channelRatingBestChannels;
5654
channelRatingAdapter = new ChannelRatingAdapter(getActivity(), bestChannels);
55+
ListView listView = binding.channelRatingRefresh.findViewById(R.id.channelRatingView);
5756
listView.setAdapter(channelRatingAdapter);
5857

5958
MainContext.INSTANCE.getScannerService().register(channelRatingAdapter);
6059

61-
return view;
60+
return binding.getRoot();
6261
}
6362

6463
@Override

app/src/main/java/com/vrem/wifianalyzer/wifi/timegraph/TimeGraphFragment.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
import com.vrem.util.BuildUtils;
2727
import com.vrem.wifianalyzer.MainContext;
28-
import com.vrem.wifianalyzer.R;
28+
import com.vrem.wifianalyzer.databinding.GraphContentBinding;
2929
import com.vrem.wifianalyzer.wifi.graphutils.GraphViewAdd;
3030

3131
import org.apache.commons.collections4.IterableUtils;
@@ -40,26 +40,25 @@ public class TimeGraphFragment extends Fragment implements SwipeRefreshLayout.On
4040

4141
@Override
4242
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
43-
View view = inflater.inflate(R.layout.graph_content, container, false);
43+
GraphContentBinding binding = GraphContentBinding.inflate(inflater, container, false);
4444

45-
swipeRefreshLayout = view.findViewById(R.id.graphRefresh);
45+
swipeRefreshLayout = binding.graphRefresh;
4646
swipeRefreshLayout.setOnRefreshListener(this);
4747
if (BuildUtils.isVersionP()) {
4848
swipeRefreshLayout.setRefreshing(false);
4949
swipeRefreshLayout.setEnabled(false);
5050
}
5151

5252
timeGraphAdapter = new TimeGraphAdapter();
53-
addGraphViews(swipeRefreshLayout, timeGraphAdapter);
53+
addGraphViews(binding, timeGraphAdapter);
5454

5555
MainContext.INSTANCE.getScannerService().register(timeGraphAdapter);
5656

57-
return view;
57+
return binding.getRoot();
5858
}
5959

60-
private void addGraphViews(View view, TimeGraphAdapter timeGraphAdapter) {
61-
IterableUtils.forEach(timeGraphAdapter.getGraphViews(),
62-
new GraphViewAdd(view.findViewById(R.id.graphFlipper)));
60+
private void addGraphViews(GraphContentBinding binding, TimeGraphAdapter timeGraphAdapter) {
61+
IterableUtils.forEach(timeGraphAdapter.getGraphViews(), new GraphViewAdd(binding.graphFlipper));
6362
}
6463

6564
@Override

app/src/main/res/layout/channel_rating_content.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@
2323
android:layout_height="wrap_content"
2424
android:orientation="vertical">
2525

26-
<include layout="@layout/channel_rating_best"/>
26+
<include
27+
android:id="@+id/channel_rating_best"
28+
layout="@layout/channel_rating_best" />
2729

2830
<include layout="@layout/channel_rating_header"/>
2931

0 commit comments

Comments
 (0)