Code cleanup, renamed serverlist to search server
This commit is contained in:
parent
0e3756f399
commit
b01807d2a9
@ -49,7 +49,7 @@
|
|||||||
android:label="@string/title_activity_settings"
|
android:label="@string/title_activity_settings"
|
||||||
android:theme="@style/AppTheme.NoActionBar" /> <!-- Server Selection -->
|
android:theme="@style/AppTheme.NoActionBar" /> <!-- Server Selection -->
|
||||||
<activity
|
<activity
|
||||||
android:name=".activity.SelectServerActivity"
|
android:name=".activity.SearchServerActivity"
|
||||||
android:label="@string/title_activity_select_server"
|
android:label="@string/title_activity_select_server"
|
||||||
android:theme="@style/AppTheme.NoActionBar" /> <!-- Me -->
|
android:theme="@style/AppTheme.NoActionBar" /> <!-- Me -->
|
||||||
<activity
|
<activity
|
||||||
|
@ -33,7 +33,7 @@ import android.widget.TextView;
|
|||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import net.schueller.peertube.R;
|
import net.schueller.peertube.R;
|
||||||
import net.schueller.peertube.adapter.ServerAdapter;
|
import net.schueller.peertube.adapter.ServerSearchAdapter;
|
||||||
import net.schueller.peertube.helper.APIUrlHelper;
|
import net.schueller.peertube.helper.APIUrlHelper;
|
||||||
import net.schueller.peertube.model.ServerList;
|
import net.schueller.peertube.model.ServerList;
|
||||||
import net.schueller.peertube.network.GetServerListDataService;
|
import net.schueller.peertube.network.GetServerListDataService;
|
||||||
@ -42,9 +42,9 @@ import net.schueller.peertube.network.RetrofitInstance;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
public class SelectServerActivity extends CommonActivity {
|
public class SearchServerActivity extends CommonActivity {
|
||||||
|
|
||||||
private ServerAdapter serverAdapter;
|
private ServerSearchAdapter serverAdapter;
|
||||||
private SwipeRefreshLayout swipeRefreshLayout;
|
private SwipeRefreshLayout swipeRefreshLayout;
|
||||||
|
|
||||||
private int currentStart = 0;
|
private int currentStart = 0;
|
||||||
@ -64,7 +64,7 @@ public class SelectServerActivity extends CommonActivity {
|
|||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_server_selection);
|
setContentView(R.layout.activity_search_server);
|
||||||
|
|
||||||
// Attaching the layout to the toolbar object
|
// Attaching the layout to the toolbar object
|
||||||
Toolbar toolbar = findViewById(R.id.tool_bar_server_selection);
|
Toolbar toolbar = findViewById(R.id.tool_bar_server_selection);
|
||||||
@ -85,10 +85,10 @@ public class SelectServerActivity extends CommonActivity {
|
|||||||
|
|
||||||
emptyView = findViewById(R.id.empty_server_selection_view);
|
emptyView = findViewById(R.id.empty_server_selection_view);
|
||||||
|
|
||||||
RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(SelectServerActivity.this);
|
RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(SearchServerActivity.this);
|
||||||
recyclerView.setLayoutManager(layoutManager);
|
recyclerView.setLayoutManager(layoutManager);
|
||||||
|
|
||||||
serverAdapter = new ServerAdapter(new ArrayList<>(), this);
|
serverAdapter = new ServerSearchAdapter(new ArrayList<>(), this);
|
||||||
recyclerView.setAdapter(serverAdapter);
|
recyclerView.setAdapter(serverAdapter);
|
||||||
|
|
||||||
loadServers(currentStart, count);
|
loadServers(currentStart, count);
|
||||||
@ -132,7 +132,7 @@ public class SelectServerActivity extends CommonActivity {
|
|||||||
isLoading = true;
|
isLoading = true;
|
||||||
|
|
||||||
GetServerListDataService service = RetrofitInstance.getRetrofitInstance(
|
GetServerListDataService service = RetrofitInstance.getRetrofitInstance(
|
||||||
APIUrlHelper.getServerIndexUrl(SelectServerActivity.this)
|
APIUrlHelper.getServerIndexUrl(SearchServerActivity.this)
|
||||||
).create(GetServerListDataService.class);
|
).create(GetServerListDataService.class);
|
||||||
|
|
||||||
|
|
||||||
@ -171,7 +171,7 @@ public class SelectServerActivity extends CommonActivity {
|
|||||||
@Override
|
@Override
|
||||||
public void onFailure(@NonNull Call<ServerList> call, @NonNull Throwable t) {
|
public void onFailure(@NonNull Call<ServerList> call, @NonNull Throwable t) {
|
||||||
Log.wtf("err", t.fillInStackTrace());
|
Log.wtf("err", t.fillInStackTrace());
|
||||||
Toast.makeText(SelectServerActivity.this, getString(R.string.api_error), Toast.LENGTH_SHORT).show();
|
Toast.makeText(SearchServerActivity.this, getString(R.string.api_error), Toast.LENGTH_SHORT).show();
|
||||||
isLoading = false;
|
isLoading = false;
|
||||||
swipeRefreshLayout.setRefreshing(false);
|
swipeRefreshLayout.setRefreshing(false);
|
||||||
}
|
}
|
@ -18,15 +18,11 @@
|
|||||||
package net.schueller.peertube.adapter;
|
package net.schueller.peertube.adapter;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.AlertDialog;
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
import android.provider.SearchRecentSuggestions;
|
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
@ -39,12 +35,8 @@ import androidx.recyclerview.widget.RecyclerView;
|
|||||||
|
|
||||||
import net.schueller.peertube.R;
|
import net.schueller.peertube.R;
|
||||||
|
|
||||||
import net.schueller.peertube.activity.SelectServerActivity;
|
|
||||||
import net.schueller.peertube.activity.ServerAddressBookActivity;
|
|
||||||
import net.schueller.peertube.activity.VideoListActivity;
|
|
||||||
import net.schueller.peertube.database.Server;
|
import net.schueller.peertube.database.Server;
|
||||||
import net.schueller.peertube.helper.APIUrlHelper;
|
import net.schueller.peertube.helper.APIUrlHelper;
|
||||||
import net.schueller.peertube.provider.SearchSuggestionsProvider;
|
|
||||||
import net.schueller.peertube.service.LoginService;
|
import net.schueller.peertube.service.LoginService;
|
||||||
|
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ import android.widget.Toast;
|
|||||||
|
|
||||||
|
|
||||||
import net.schueller.peertube.R;
|
import net.schueller.peertube.R;
|
||||||
import net.schueller.peertube.activity.SelectServerActivity;
|
import net.schueller.peertube.activity.SearchServerActivity;
|
||||||
import net.schueller.peertube.helper.APIUrlHelper;
|
import net.schueller.peertube.helper.APIUrlHelper;
|
||||||
import net.schueller.peertube.model.Server;
|
import net.schueller.peertube.model.Server;
|
||||||
|
|
||||||
@ -41,14 +41,14 @@ import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
|
|||||||
import static android.app.Activity.RESULT_OK;
|
import static android.app.Activity.RESULT_OK;
|
||||||
|
|
||||||
|
|
||||||
public class ServerAdapter extends RecyclerView.Adapter<ServerAdapter.AccountViewHolder> {
|
public class ServerSearchAdapter extends RecyclerView.Adapter<ServerSearchAdapter.AccountViewHolder> {
|
||||||
|
|
||||||
|
|
||||||
private ArrayList<Server> serverList;
|
private ArrayList<Server> serverList;
|
||||||
private SelectServerActivity activity;
|
private SearchServerActivity activity;
|
||||||
private String baseUrl;
|
private String baseUrl;
|
||||||
|
|
||||||
public ServerAdapter(ArrayList<Server> serverList, SelectServerActivity activity) {
|
public ServerSearchAdapter(ArrayList<Server> serverList, SearchServerActivity activity) {
|
||||||
this.serverList = serverList;
|
this.serverList = serverList;
|
||||||
this.activity = activity;
|
this.activity = activity;
|
||||||
}
|
}
|
@ -38,7 +38,7 @@ import android.widget.EditText;
|
|||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import net.schueller.peertube.R;
|
import net.schueller.peertube.R;
|
||||||
import net.schueller.peertube.activity.SelectServerActivity;
|
import net.schueller.peertube.activity.SearchServerActivity;
|
||||||
import net.schueller.peertube.activity.ServerAddressBookActivity;
|
import net.schueller.peertube.activity.ServerAddressBookActivity;
|
||||||
import net.schueller.peertube.helper.APIUrlHelper;
|
import net.schueller.peertube.helper.APIUrlHelper;
|
||||||
|
|
||||||
@ -128,7 +128,7 @@ public class AddServerFragment extends Fragment {
|
|||||||
|
|
||||||
Button pickServerUrl = mView.findViewById(R.id.pickServerUrl);
|
Button pickServerUrl = mView.findViewById(R.id.pickServerUrl);
|
||||||
pickServerUrl.setOnClickListener(view -> {
|
pickServerUrl.setOnClickListener(view -> {
|
||||||
Intent intentServer = new Intent(getActivity(), SelectServerActivity.class);
|
Intent intentServer = new Intent(getActivity(), SearchServerActivity.class);
|
||||||
this.startActivityForResult(intentServer, PICK_SERVER);
|
this.startActivityForResult(intentServer, PICK_SERVER);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
tools:context=".activity.SelectServerActivity">
|
tools:context=".activity.SearchServerActivity">
|
||||||
|
|
||||||
<com.google.android.material.appbar.AppBarLayout
|
<com.google.android.material.appbar.AppBarLayout
|
||||||
android:id="@+id/appbar_server_selection"
|
android:id="@+id/appbar_server_selection"
|
@ -344,7 +344,7 @@
|
|||||||
<string name="server_book_del_alert_title">Remove Server</string>
|
<string name="server_book_del_alert_title">Remove Server</string>
|
||||||
<string name="server_book_del_alert_msg">Are you sure you want to remove this server from the address book?</string>
|
<string name="server_book_del_alert_msg">Are you sure you want to remove this server from the address book?</string>
|
||||||
|
|
||||||
<string name="title_activity_select_server">Select Server</string>
|
<string name="title_activity_select_server">Search Server</string>
|
||||||
<string name="title_activity_me">Account</string>
|
<string name="title_activity_me">Account</string>
|
||||||
<string name="title_activity_settings2">SettingsActivity2</string>
|
<string name="title_activity_settings2">SettingsActivity2</string>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user