mirror of
https://github.com/stan220/Zte-F660-Control.git
synced 2026-09-08 16:28:41 +00:00
Added refresh button and control disabling.
This commit is contained in:
@@ -61,15 +61,25 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void onSwitchClick(View view) {
|
public void onSwitchClick(View view) {
|
||||||
System.out.println("### click: " + view);
|
System.out.println("### switch clicked: " + view);
|
||||||
new DownloadFilesTask(this).execute((SwitchMaterial) view);
|
new DownloadFilesTask(this).execute((SwitchMaterial) view);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void onRefreshButtonClick(View view) {
|
||||||
|
System.out.println("### refresh clicked: " + view);
|
||||||
|
new DownloadFilesTask(this).execute();
|
||||||
|
}
|
||||||
|
|
||||||
private static class DownloadFilesTask extends AsyncTask<SwitchMaterial, Void, List<String>> {
|
private static class DownloadFilesTask extends AsyncTask<SwitchMaterial, Void, List<String>> {
|
||||||
|
|
||||||
private MainActivity context;
|
private MainActivity context;
|
||||||
|
|
||||||
public DownloadFilesTask(MainActivity context) {
|
public DownloadFilesTask(MainActivity context) {
|
||||||
|
context.findViewById(R.id.switchTab).setEnabled(false);
|
||||||
|
context.findViewById(R.id.switchTv).setEnabled(false);
|
||||||
|
context.findViewById(R.id.switchAlisa).setEnabled(false);
|
||||||
|
context.findViewById(R.id.button_refresh).setEnabled(false);
|
||||||
|
|
||||||
this.context = context;
|
this.context = context;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -77,7 +87,7 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
protected List<String> doInBackground(SwitchMaterial... switches) {
|
protected List<String> doInBackground(SwitchMaterial... switches) {
|
||||||
List<String> result = new ArrayList<>();
|
List<String> result = new ArrayList<>();
|
||||||
|
|
||||||
Socket s = null;
|
Socket s;
|
||||||
try {
|
try {
|
||||||
s = new Socket(InetAddress.getByName("192.168.100.1"), 23);
|
s = new Socket(InetAddress.getByName("192.168.100.1"), 23);
|
||||||
|
|
||||||
@@ -175,6 +185,11 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
switchAlisa.setChecked(false);
|
switchAlisa.setChecked(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
context.findViewById(R.id.switchTab).setEnabled(true);
|
||||||
|
context.findViewById(R.id.switchTv).setEnabled(true);
|
||||||
|
context.findViewById(R.id.switchAlisa).setEnabled(true);
|
||||||
|
context.findViewById(R.id.button_refresh).setEnabled(true);
|
||||||
|
|
||||||
Toast.makeText(context, "Статус обновлён!", Toast.LENGTH_LONG).show();
|
Toast.makeText(context, "Статус обновлён!", Toast.LENGTH_LONG).show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,10 +9,19 @@
|
|||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:padding="20dp">
|
android:padding="20dp">
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/button_refresh"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:enabled="false"
|
||||||
|
android:onClick="onRefreshButtonClick"
|
||||||
|
android:text="Обновить" />
|
||||||
|
|
||||||
<com.google.android.material.switchmaterial.SwitchMaterial
|
<com.google.android.material.switchmaterial.SwitchMaterial
|
||||||
android:id="@+id/switchTab"
|
android:id="@+id/switchTab"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:enabled="false"
|
||||||
android:onClick="onSwitchClick"
|
android:onClick="onSwitchClick"
|
||||||
android:text="Tab"
|
android:text="Tab"
|
||||||
app:useMaterialThemeColors="true" />
|
app:useMaterialThemeColors="true" />
|
||||||
@@ -21,6 +30,7 @@
|
|||||||
android:id="@+id/switchTv"
|
android:id="@+id/switchTv"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:enabled="false"
|
||||||
android:onClick="onSwitchClick"
|
android:onClick="onSwitchClick"
|
||||||
android:text="TV"
|
android:text="TV"
|
||||||
app:useMaterialThemeColors="true" />
|
app:useMaterialThemeColors="true" />
|
||||||
@@ -29,6 +39,7 @@
|
|||||||
android:id="@+id/switchAlisa"
|
android:id="@+id/switchAlisa"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:enabled="false"
|
||||||
android:onClick="onSwitchClick"
|
android:onClick="onSwitchClick"
|
||||||
android:text="Alisa"
|
android:text="Alisa"
|
||||||
app:useMaterialThemeColors="true" />
|
app:useMaterialThemeColors="true" />
|
||||||
|
|||||||
Reference in New Issue
Block a user