Code cleanup, renamed serverlist to search server

This commit is contained in:
Stefan Schueller 2020-07-05 14:25:28 +02:00
parent 0e3756f399
commit b01807d2a9
7 changed files with 17 additions and 25 deletions

View File

@ -49,7 +49,7 @@
android:label="@string/title_activity_settings"
android:theme="@style/AppTheme.NoActionBar" /> <!-- Server Selection -->
<activity
android:name=".activity.SelectServerActivity"
android:name=".activity.SearchServerActivity"
android:label="@string/title_activity_select_server"
android:theme="@style/AppTheme.NoActionBar" /> <!-- Me -->
<activity

View File

@ -33,7 +33,7 @@ import android.widget.TextView;
import android.widget.Toast;
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.model.ServerList;
import net.schueller.peertube.network.GetServerListDataService;
@ -42,9 +42,9 @@ import net.schueller.peertube.network.RetrofitInstance;
import java.util.ArrayList;
import java.util.Objects;
public class SelectServerActivity extends CommonActivity {
public class SearchServerActivity extends CommonActivity {
private ServerAdapter serverAdapter;
private ServerSearchAdapter serverAdapter;
private SwipeRefreshLayout swipeRefreshLayout;
private int currentStart = 0;
@ -64,7 +64,7 @@ public class SelectServerActivity extends CommonActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_server_selection);
setContentView(R.layout.activity_search_server);
// Attaching the layout to the toolbar object
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);
RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(SelectServerActivity.this);
RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(SearchServerActivity.this);
recyclerView.setLayoutManager(layoutManager);
serverAdapter = new ServerAdapter(new ArrayList<>(), this);
serverAdapter = new ServerSearchAdapter(new ArrayList<>(), this);
recyclerView.setAdapter(serverAdapter);
loadServers(currentStart, count);
@ -132,7 +132,7 @@ public class SelectServerActivity extends CommonActivity {
isLoading = true;
GetServerListDataService service = RetrofitInstance.getRetrofitInstance(
APIUrlHelper.getServerIndexUrl(SelectServerActivity.this)
APIUrlHelper.getServerIndexUrl(SearchServerActivity.this)
).create(GetServerListDataService.class);
@ -171,7 +171,7 @@ public class SelectServerActivity extends CommonActivity {
@Override
public void onFailure(@NonNull Call<ServerList> call, @NonNull Throwable t) {
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;
swipeRefreshLayout.setRefreshing(false);
}

View File

@ -18,15 +18,11 @@
package net.schueller.peertube.adapter;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import android.provider.SearchRecentSuggestions;
import android.text.TextUtils;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@ -39,12 +35,8 @@ import androidx.recyclerview.widget.RecyclerView;
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.helper.APIUrlHelper;
import net.schueller.peertube.provider.SearchSuggestionsProvider;
import net.schueller.peertube.service.LoginService;

View File

@ -27,7 +27,7 @@ import android.widget.Toast;
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.model.Server;
@ -41,14 +41,14 @@ import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
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 SelectServerActivity activity;
private SearchServerActivity activity;
private String baseUrl;
public ServerAdapter(ArrayList<Server> serverList, SelectServerActivity activity) {
public ServerSearchAdapter(ArrayList<Server> serverList, SearchServerActivity activity) {
this.serverList = serverList;
this.activity = activity;
}

View File

@ -38,7 +38,7 @@ import android.widget.EditText;
import android.widget.Toast;
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.helper.APIUrlHelper;
@ -128,7 +128,7 @@ public class AddServerFragment extends Fragment {
Button pickServerUrl = mView.findViewById(R.id.pickServerUrl);
pickServerUrl.setOnClickListener(view -> {
Intent intentServer = new Intent(getActivity(), SelectServerActivity.class);
Intent intentServer = new Intent(getActivity(), SearchServerActivity.class);
this.startActivityForResult(intentServer, PICK_SERVER);
});

View File

@ -4,7 +4,7 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".activity.SelectServerActivity">
tools:context=".activity.SearchServerActivity">
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/appbar_server_selection"

View File

@ -344,7 +344,7 @@
<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="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_settings2">SettingsActivity2</string>