Skip to content

Commit 7d7c506

Browse files
committed
Pair finder bug fixed & show display name in pair finder
1 parent 70e0b1a commit 7d7c506

File tree

5 files changed

+235
-198
lines changed

5 files changed

+235
-198
lines changed

app/app.iml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,6 @@
6464
<sourceFolder url="file://$MODULE_DIR$/src/main/jni" isTestSource="false" />
6565
<sourceFolder url="file://$MODULE_DIR$/src/main/rs" isTestSource="false" />
6666
<sourceFolder url="file://$MODULE_DIR$/src/main/shaders" isTestSource="false" />
67-
<sourceFolder url="file://$MODULE_DIR$/src/test/res" type="java-test-resource" />
68-
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
69-
<sourceFolder url="file://$MODULE_DIR$/src/test/assets" type="java-test-resource" />
70-
<sourceFolder url="file://$MODULE_DIR$/src/test/aidl" isTestSource="true" />
71-
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
72-
<sourceFolder url="file://$MODULE_DIR$/src/test/jni" isTestSource="true" />
73-
<sourceFolder url="file://$MODULE_DIR$/src/test/rs" isTestSource="true" />
74-
<sourceFolder url="file://$MODULE_DIR$/src/test/shaders" isTestSource="true" />
7567
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" />
7668
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" />
7769
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" />
@@ -80,6 +72,14 @@
8072
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" />
8173
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
8274
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/shaders" isTestSource="true" />
75+
<sourceFolder url="file://$MODULE_DIR$/src/test/res" type="java-test-resource" />
76+
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
77+
<sourceFolder url="file://$MODULE_DIR$/src/test/assets" type="java-test-resource" />
78+
<sourceFolder url="file://$MODULE_DIR$/src/test/aidl" isTestSource="true" />
79+
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
80+
<sourceFolder url="file://$MODULE_DIR$/src/test/jni" isTestSource="true" />
81+
<sourceFolder url="file://$MODULE_DIR$/src/test/rs" isTestSource="true" />
82+
<sourceFolder url="file://$MODULE_DIR$/src/test/shaders" isTestSource="true" />
8383
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" />
8484
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/blame" />
8585
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/builds" />

app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ android {
88
applicationId "com.genonbeta.CoolSocket.test"
99
minSdkVersion 14
1010
targetSdkVersion 21
11-
versionCode 6
12-
versionName "1.0.5"
11+
versionCode 7
12+
versionName "1.0.6"
1313
}
1414
buildTypes {
1515
release {
Lines changed: 125 additions & 121 deletions
Original file line numberDiff line numberDiff line change
@@ -1,121 +1,125 @@
1-
package com.genonbeta.CoolSocket.test.adapter;
2-
3-
import android.content.Context;
4-
import android.support.v4.util.ArrayMap;
5-
import android.view.LayoutInflater;
6-
import android.view.View;
7-
import android.view.ViewGroup;
8-
import android.view.animation.AnimationSet;
9-
import android.widget.BaseAdapter;
10-
import android.widget.TextView;
11-
import android.widget.Toast;
12-
13-
import com.genonbeta.CoolSocket.test.R;
14-
import com.genonbeta.CoolSocket.test.helper.GAnimater;
15-
import com.genonbeta.CoolSocket.test.helper.PairListHelper;
16-
import com.genonbeta.CoolSocket.test.helper.PairListHelper.DeviceInfo;
17-
import com.genonbeta.CoolSocket.test.helper.PairListHelper.ResultHandler;
18-
import com.genonbeta.core.content.Intent;
19-
20-
import java.net.InetAddress;
21-
22-
public class PairListAdapter extends BaseAdapter
23-
{
24-
private Context mContext;
25-
private ResultHandler mHandler = new ResultHandler()
26-
{
27-
@Override
28-
public void onDeviceFound(InetAddress inetAddress)
29-
{
30-
super.onDeviceFound(inetAddress);
31-
mContext.sendBroadcast(Intent.getNotifyIntent());
32-
}
33-
};
34-
private ArrayMap<String, DeviceInfo> mIndex = new ArrayMap<>();
35-
36-
public PairListAdapter(Context context)
37-
{
38-
39-
this.mContext = context;
40-
}
41-
42-
public void requestUpdate()
43-
{
44-
Toast.makeText(this.mContext, PairListHelper.update(this.mHandler) ? "Scan started" : "Still scanning. When it ends, list will be refreshed", Toast.LENGTH_SHORT).show();
45-
}
46-
47-
@Override
48-
public void notifyDataSetChanged()
49-
{
50-
this.mIndex.clear();
51-
52-
for (String str : PairListHelper.getList().keySet())
53-
{
54-
mIndex.put(str, PairListHelper.getList().get(str));
55-
}
56-
57-
super.notifyDataSetChanged();
58-
}
59-
60-
@Override
61-
public int getCount()
62-
{
63-
return this.mIndex.size();
64-
}
65-
66-
@Override
67-
public Object getItem(int i)
68-
{
69-
return this.mIndex.keyAt(i);
70-
}
71-
72-
@Override
73-
public long getItemId(int i)
74-
{
75-
return (long) 0;
76-
}
77-
78-
@Override
79-
public View getView(int i, View view, ViewGroup viewGroup)
80-
{
81-
if (view == null)
82-
view = LayoutInflater.from(this.mContext).inflate(R.layout.list_pair, viewGroup, false);
83-
84-
return getViewAt(view, i);
85-
}
86-
87-
public View getViewAt(View view, int i)
88-
{
89-
String str = (String) getItem(i);
90-
DeviceInfo deviceInfo = this.mIndex.get(str);
91-
92-
TextView textView = (TextView) view.findViewById(R.id.list_text2);
93-
((TextView) view.findViewById(R.id.list_text)).setText(str);
94-
95-
StringBuilder stringBuilder = new StringBuilder();
96-
97-
if (!deviceInfo.deviceName.equals(textView.getText().toString()))
98-
{
99-
AnimationSet set = GAnimater.getAnimation(GAnimater.APPEAR);
100-
view.setAnimation(set);
101-
}
102-
103-
if (deviceInfo.trebleShot || deviceInfo.coolSocket || deviceInfo.deviceController)
104-
{
105-
textView.setVisibility(View.VISIBLE);
106-
107-
if (deviceInfo.trebleShot)
108-
stringBuilder = stringBuilder.append("TShot ");
109-
110-
if (deviceInfo.coolSocket)
111-
stringBuilder = stringBuilder.append("CSocket ");
112-
113-
if (deviceInfo.deviceController)
114-
stringBuilder = stringBuilder.append("DContrllr ");
115-
}
116-
117-
textView.setText(stringBuilder);
118-
119-
return view;
120-
}
121-
}
1+
package com.genonbeta.CoolSocket.test.adapter;
2+
3+
import android.content.Context;
4+
import android.support.v4.util.ArrayMap;
5+
import android.util.Log;
6+
import android.view.LayoutInflater;
7+
import android.view.View;
8+
import android.view.ViewGroup;
9+
import android.view.animation.AnimationSet;
10+
import android.widget.BaseAdapter;
11+
import android.widget.TextView;
12+
import android.widget.Toast;
13+
14+
import com.genonbeta.CoolSocket.test.R;
15+
import com.genonbeta.CoolSocket.test.helper.GAnimater;
16+
import com.genonbeta.CoolSocket.test.helper.PairListHelper;
17+
import com.genonbeta.CoolSocket.test.helper.PairListHelper.DeviceInfo;
18+
import com.genonbeta.CoolSocket.test.helper.PairListHelper.ResultHandler;
19+
import com.genonbeta.core.content.Intent;
20+
21+
import java.net.InetAddress;
22+
23+
public class PairListAdapter extends BaseAdapter
24+
{
25+
private Context mContext;
26+
private ResultHandler mHandler = new ResultHandler()
27+
{
28+
@Override
29+
public void onDeviceFound(InetAddress inetAddress)
30+
{
31+
super.onDeviceFound(inetAddress);
32+
mContext.sendBroadcast(Intent.getNotifyIntent());
33+
}
34+
};
35+
private ArrayMap<String, DeviceInfo> mIndex = new ArrayMap<>();
36+
37+
public PairListAdapter(Context context)
38+
{
39+
this.mContext = context;
40+
}
41+
42+
public void requestUpdate()
43+
{
44+
Toast.makeText(this.mContext, PairListHelper.update(this.mHandler) ? "Scan started" : "Still scanning. When it ends, list will be refreshed", Toast.LENGTH_SHORT).show();
45+
}
46+
47+
@Override
48+
public void notifyDataSetChanged()
49+
{
50+
this.mIndex.clear();
51+
52+
for (String str : PairListHelper.getList().keySet())
53+
{
54+
mIndex.put(str, PairListHelper.getList().get(str));
55+
}
56+
57+
super.notifyDataSetChanged();
58+
}
59+
60+
@Override
61+
public int getCount()
62+
{
63+
return this.mIndex.size();
64+
}
65+
66+
@Override
67+
public Object getItem(int i)
68+
{
69+
return this.mIndex.keyAt(i);
70+
}
71+
72+
@Override
73+
public long getItemId(int i)
74+
{
75+
return (long) 0;
76+
}
77+
78+
@Override
79+
public View getView(int i, View view, ViewGroup viewGroup)
80+
{
81+
if (view == null)
82+
view = LayoutInflater.from(this.mContext).inflate(R.layout.list_pair, viewGroup, false);
83+
84+
return getViewAt(view, i);
85+
}
86+
87+
public View getViewAt(View view, int i)
88+
{
89+
String str = (String) getItem(i);
90+
DeviceInfo deviceInfo = this.mIndex.get(str);
91+
92+
93+
((TextView) view.findViewById(R.id.list_text)).setText(str);
94+
TextView textView2 = (TextView) view.findViewById(R.id.list_text2);
95+
TextView textView3 = (TextView) view.findViewById(R.id.list_text3);
96+
97+
StringBuilder stringBuilder = new StringBuilder();
98+
99+
if (!str.equals(textView2.getText().toString()))
100+
{
101+
AnimationSet set = GAnimater.getAnimation(GAnimater.APPEAR);
102+
view.setAnimation(set);
103+
}
104+
105+
if (deviceInfo.trebleShot || deviceInfo.coolSocket || deviceInfo.deviceController)
106+
{
107+
textView2.setVisibility(View.VISIBLE);
108+
109+
if (deviceInfo.trebleShot)
110+
stringBuilder = stringBuilder.append("TShot ");
111+
112+
if (deviceInfo.coolSocket)
113+
stringBuilder = stringBuilder.append("CSocket ");
114+
115+
if (deviceInfo.deviceController)
116+
stringBuilder = stringBuilder.append("DContrllr ");
117+
}
118+
119+
textView2.setText(stringBuilder);
120+
textView3.setVisibility((deviceInfo.deviceName != null) ? View.VISIBLE : View.GONE);
121+
textView3.setText(deviceInfo.deviceName);
122+
123+
return view;
124+
}
125+
}
Lines changed: 51 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,51 @@
1-
<?xml version="1.0" encoding="utf-8"?>
2-
<RelativeLayout
3-
xmlns:android="http://schemas.android.com/apk/res/android"
4-
android:orientation="vertical"
5-
android:background="@drawable/checkable_item_background"
6-
android:padding="12dp"
7-
android:layout_width="match_parent"
8-
android:layout_height="match_parent">
9-
10-
<TextView
11-
android:textSize="16sp"
12-
android:textStyle="bold"
13-
android:ellipsize="end"
14-
android:id="@+id/list_text"
15-
android:layout_width="wrap_content"
16-
android:layout_height="wrap_content"
17-
android:singleLine="true"
18-
style="@style/primaryText"
19-
/>
20-
21-
<TextView
22-
android:textSize="14sp"
23-
android:id="@+id/list_text2"
24-
android:visibility="gone"
25-
android:layout_width="wrap_content"
26-
android:layout_height="wrap_content"
27-
android:singleLine="true"
28-
android:layout_below="@+id/list_text"
29-
style="@style/secondaryText"
30-
/>
31-
</RelativeLayout>
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<LinearLayout
3+
xmlns:android="http://schemas.android.com/apk/res/android"
4+
android:layout_width="match_parent"
5+
android:layout_height="match_parent"
6+
android:background="@drawable/checkable_item_background"
7+
android:orientation="vertical"
8+
android:padding="15dp">
9+
10+
<RelativeLayout
11+
android:layout_width="wrap_content"
12+
android:layout_height="wrap_content">
13+
14+
<TextView
15+
android:id="@+id/list_text3"
16+
style="@style/secondaryText"
17+
android:layout_width="wrap_content"
18+
android:layout_height="wrap_content"
19+
android:layout_alignParentRight="true"
20+
android:ellipsize="end"
21+
android:singleLine="true"
22+
android:textSize="15sp"
23+
android:textStyle="italic"
24+
/>
25+
26+
<TextView
27+
android:id="@+id/list_text"
28+
style="@style/primaryText"
29+
android:layout_width="wrap_content"
30+
android:layout_height="wrap_content"
31+
android:layout_alignParentLeft="true"
32+
android:layout_toLeftOf="@+id/list_text2"
33+
android:ellipsize="end"
34+
android:singleLine="true"
35+
android:textSize="16sp"
36+
android:textStyle="bold"
37+
/>
38+
39+
</RelativeLayout>
40+
41+
<TextView
42+
android:id="@+id/list_text2"
43+
style="@style/secondaryText"
44+
android:layout_width="wrap_content"
45+
android:layout_height="wrap_content"
46+
android:singleLine="true"
47+
android:textSize="14sp"
48+
android:visibility="gone"
49+
/>
50+
51+
</LinearLayout>

0 commit comments

Comments
 (0)