Some cleaning

This commit is contained in:
Thomas 2023-01-25 17:23:49 +01:00
parent 8b26deb064
commit bf8543bc77
14 changed files with 51 additions and 51 deletions

View file

@ -65,8 +65,7 @@ public class AccountActivity extends BaseBarActivity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
binding = ActivityAccountPeertubeBinding.inflate(getLayoutInflater());
View view = binding.getRoot();
setContentView(view);
setContentView(binding.getRoot());
if (getSupportActionBar() != null)
getSupportActionBar().setDisplayHomeAsUpEnabled(true);

View file

@ -518,7 +518,7 @@ public class PeertubeMainActivity extends PeertubeBaseMainActivity {
account.refresh_token = token.getRefresh_token();
account.peertube_account = userMe.getAccount();
account.software = Account.API.PEERTUBE.name();
account.user_id = userMe.getAccount().getUserId();
account.user_id = userMe.getAccount().getId();
account.instance = userMe.getAccount().getHost();
SharedPreferences.Editor editor = sharedpreferences.edit();
editor.putString(PREF_USER_TOKEN, token.getAccess_token());

View file

@ -180,7 +180,7 @@ public class RetrofitPeertubeAPI {
account.api = Account.API.PEERTUBE;
account.software = Account.API.PEERTUBE.name();
account.peertube_account = peertubeAccount;
account.user_id = peertubeAccount.getUserId();
account.user_id = peertubeAccount.getId();
SharedPreferences.Editor editor = sharedpreferences.edit();
editor.putString(PREF_USER_ID, account.user_id);
editor.putString(PREF_USER_INSTANCE, host);

View file

@ -140,6 +140,10 @@ public class ChannelListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHo
private boolean isMyChannel(Channel channel) {
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(context);
if (channel.getOwnerAccount() == null) {
return true;
}
String channeIdOwner = channel.getOwnerAccount().getId();
String channeInstanceOwner = channel.getOwnerAccount().getHost();
String instanceShar = sharedpreferences.getString(PREF_USER_INSTANCE, null);

View file

@ -95,14 +95,11 @@ public class DisplayChannelsFragment extends Fragment implements ChannelListAdap
search_peertube = bundle.getString("search_peertube", null);
}
if (getActivity() != null) {
action_button = getActivity().findViewById(R.id.action_button);
if (action_button != null) {
action_button.setVisibility(View.VISIBLE);
action_button.setOnClickListener(view -> manageAlert(null));
}
action_button = getActivity().findViewById(R.id.action_button);
if (action_button != null) {
action_button.setVisibility(View.VISIBLE);
action_button.setOnClickListener(view -> manageAlert(null));
}
binding.lvElements.addItemDecoration(new DividerItemDecoration(context, DividerItemDecoration.VERTICAL));
channelListAdapter = new ChannelListAdapter(this.channels);
channelListAdapter.allChannelRemoved = this;

View file

@ -65,8 +65,7 @@ public class DisplayOverviewFragment extends Fragment implements PeertubeAdapter
private int page;
private List<VideoData.Video> peertubes;
private boolean firstLoad;
private View rootView;
private RecyclerView lv_status;
private TimelineVM viewModelFeeds;
private Map<String, Boolean> relationship;
private Map<String, List<PlaylistExist>> playlists;
@ -82,7 +81,6 @@ public class DisplayOverviewFragment extends Fragment implements PeertubeAdapter
binding = FragmentOverviewPeertubeBinding.inflate(getLayoutInflater());
peertubes = new ArrayList<>();
lv_status = rootView.findViewById(R.id.lv_status);
page = 1;
flag_loading = true;
firstLoad = true;
@ -95,24 +93,24 @@ public class DisplayOverviewFragment extends Fragment implements PeertubeAdapter
peertubeAdapater.playlistListener = this;
peertubeAdapater.relationShipListener = this;
lv_status.setAdapter(peertubeAdapater);
binding.lvStatus.setAdapter(peertubeAdapater);
if (!Helper.isTablet(requireActivity())) {
mLayoutManager = new LinearLayoutManager(requireActivity());
lv_status.setLayoutManager(mLayoutManager);
binding.lvStatus.setLayoutManager(mLayoutManager);
} else {
gLayoutManager = new GridLayoutManager(requireActivity(), 2);
int spanCount = (int) Helper.convertDpToPixel(2, requireActivity());
int spacing = (int) Helper.convertDpToPixel(5, requireActivity());
lv_status.addItemDecoration(new GridSpacingItemDecoration(spanCount, spacing, true));
lv_status.setLayoutManager(gLayoutManager);
binding.lvStatus.addItemDecoration(new GridSpacingItemDecoration(spanCount, spacing, true));
binding.lvStatus.setLayoutManager(gLayoutManager);
}
viewModelFeeds = new ViewModelProvider(DisplayOverviewFragment.this).get(TimelineVM.class);
binding.swipeContainer.setOnRefreshListener(this::pullToRefresh);
loadTimeline(page);
lv_status.addOnScrollListener(new RecyclerView.OnScrollListener() {
binding.lvStatus.addOnScrollListener(new RecyclerView.OnScrollListener() {
public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
if (mLayoutManager != null) {
int firstVisibleItem = mLayoutManager.findFirstVisibleItemPosition();
@ -149,7 +147,7 @@ public class DisplayOverviewFragment extends Fragment implements PeertubeAdapter
});
return rootView;
return binding.getRoot();
}
@Override
@ -289,7 +287,7 @@ public class DisplayOverviewFragment extends Fragment implements PeertubeAdapter
peertubeAdapater = new PeertubeAdapter(this.peertubes);
peertubeAdapater.playlistListener = DisplayOverviewFragment.this;
peertubeAdapater.relationShipListener = DisplayOverviewFragment.this;
lv_status.setAdapter(peertubeAdapater);
binding.lvStatus.setAdapter(peertubeAdapater);
} else
peertubeAdapater.notifyItemRangeInserted(previousPosition, totalAdded);
//remove handlers
@ -306,14 +304,12 @@ public class DisplayOverviewFragment extends Fragment implements PeertubeAdapter
@Override
public void onDestroyView() {
if (lv_status != null) {
try {
lv_status.setAdapter(null);
} catch (Exception ignored) {
}
try {
binding.lvStatus.setAdapter(null);
} catch (Exception ignored) {
}
super.onDestroyView();
rootView = null;
binding = null;
}
@Override

View file

@ -25,13 +25,13 @@
<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"
app:theme="@style/ThemeOverlay.AppCompat.ActionBar">
android:fitsSystemWindows="true">
<com.google.android.material.appbar.CollapsingToolbarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"
app:expandedTitleGravity="top"
app:expandedTitleMarginEnd="64dp"
app:expandedTitleMarginStart="48dp"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
@ -41,6 +41,10 @@
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
@ -50,6 +54,7 @@
android:id="@+id/profile_picture"
android:layout_width="72dp"
android:layout_height="72dp"
tools:src="@tools:sample/avatars"
android:contentDescription="@string/profile_picture"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
@ -63,7 +68,8 @@
android:ellipsize="end"
android:singleLine="true"
android:textSize="18sp"
app:layout_constraintRight_toLeftOf="@+id/button_container"
app:layout_constraintRight_toLeftOf="@+id/edit_button"
tools:text="@tools:sample/full_names"
app:layout_constraintStart_toEndOf="@+id/profile_picture"
app:layout_constraintTop_toTopOf="@+id/profile_picture" />
@ -76,34 +82,27 @@
android:ellipsize="end"
android:singleLine="true"
android:textSize="14sp"
app:layout_constraintRight_toLeftOf="@+id/edit_button"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintRight_toLeftOf="@+id/button_container"
tools:text="@tools:sample/full_names"
app:layout_constraintStart_toEndOf="@+id/profile_picture"
app:layout_constraintTop_toTopOf="@+id/displayname" />
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/button_container"
<com.google.android.material.button.MaterialButton
android:id="@+id/edit_button"
style="@style/Widget.Material3.Button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="true"
android:text="@string/edit"
android:textAllCaps="false"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent">
app:layout_constraintTop_toTopOf="parent" />
<com.google.android.material.button.MaterialButton
android:id="@+id/edit_button"
style="@style/Widget.Material3.Button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="true"
android:text="@string/edit"
android:textAllCaps="false"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.appcompat.widget.LinearLayoutCompat>
</com.google.android.material.appbar.CollapsingToolbarLayout>
<com.google.android.material.tabs.TabLayout

View file

@ -52,7 +52,7 @@
android:gravity="center"
android:padding="10dp"
android:text="@string/action_playlist_add"
android:textSize="25sp" />
android:textSize="20sp" />
</RelativeLayout>
<!-- Main Loader -->
<RelativeLayout

View file

@ -46,7 +46,7 @@
android:gravity="center"
android:padding="10dp"
android:text="@string/no_instances"
android:textSize="25sp" />
android:textSize="20sp" />
</RelativeLayout>
<!-- Main Loader -->
<RelativeLayout

View file

@ -324,7 +324,7 @@
android:gravity="center"
android:padding="10dp"
android:text="@string/no_comments"
android:textSize="25sp" />
android:textSize="20sp" />
</RelativeLayout>
</LinearLayout>
</androidx.core.widget.NestedScrollView>

View file

@ -58,6 +58,8 @@
android:layout_height="match_parent"
android:layout_gravity="center"
android:gravity="center"
android:padding="10dp"
android:textSize="20sp"
android:text="@string/no_videos" />
</RelativeLayout>
<!-- Main Loader -->

View file

@ -39,6 +39,8 @@
android:layout_height="match_parent"
android:layout_gravity="center"
android:gravity="center"
android:padding="10dp"
android:textSize="20sp"
android:text="@string/action_playlist_add" />
</RelativeLayout>
<!-- Main Loader -->

View file

@ -46,6 +46,7 @@
android:layout_gravity="center"
android:gravity="center"
android:padding="10dp"
android:textSize="20sp"
android:text="@string/no_channels" />
</RelativeLayout>
<!-- Main Loader -->

View file

@ -90,7 +90,7 @@
android:gravity="center"
android:padding="10dp"
android:text="@string/no_videos"
android:textSize="25sp" />
android:textSize="20sp" />
</RelativeLayout>
<!-- Main Loader -->
<RelativeLayout