Skip to content

Commit

Permalink
addons: viewbinding in myMeetups (fixes #2563) (#2567)
Browse files Browse the repository at this point in the history
Co-authored-by: dogi <[email protected]>
  • Loading branch information
Okuro3499 and dogi authored Oct 11, 2023
1 parent cf6d2ba commit eecf593
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 33 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ android {
applicationId "org.ole.planet.myplanet"
minSdkVersion 21
targetSdkVersion 34
versionCode 1089
versionName "0.10.89"
versionCode 1090
versionName "0.10.90"
ndkVersion '21.3.6528147'
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
package org.ole.planet.myplanet.ui.mymeetup;

import android.os.Bundle;

import androidx.fragment.app.Fragment;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import org.ole.planet.myplanet.R;
import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;

import org.ole.planet.myplanet.databinding.FragmentMyMeetUpsBinding;

public class MyMeetUpsFragment extends Fragment {
private FragmentMyMeetUpsBinding fragmentMyMeetUpsBinding;
public MyMeetUpsFragment() {
// Required empty public constructor
}

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
return inflater.inflate(R.layout.fragment_my_meet_ups, container, false);
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
fragmentMyMeetUpsBinding = FragmentMyMeetUpsBinding.inflate(inflater, container, false);
return fragmentMyMeetUpsBinding.getRoot();
}
}
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
package org.ole.planet.myplanet.ui.mymeetup;

import android.os.Bundle;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;

import org.ole.planet.myplanet.R;
import org.ole.planet.myplanet.databinding.FragmentMyMeetupDetailBinding;
import org.ole.planet.myplanet.datamanager.DatabaseService;
import org.ole.planet.myplanet.model.RealmMeetup;
import org.ole.planet.myplanet.model.RealmUserModel;
Expand All @@ -29,13 +27,11 @@
import io.realm.RealmResults;

public class MyMeetupDetailFragment extends Fragment implements View.OnClickListener {
LinearLayout llContent;
private FragmentMyMeetupDetailBinding fragmentMyMeetupDetailBinding;
RealmMeetup meetups;
Realm mRealm;
String meetUpId;
TextView title;
Button btnLeave;
Button btnInvite;

UserProfileDbHandler profileDbHandler;
RealmUserModel user;
ListView listUsers;
Expand All @@ -56,20 +52,17 @@ public void onCreate(@Nullable Bundle savedInstanceState) {

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.fragment_my_meetup_detail, container, false);
listDesc = v.findViewById(R.id.list_desc);
listUsers = v.findViewById(R.id.list_users);
tvJoined = v.findViewById(R.id.tv_joined);
btnInvite = v.findViewById(R.id.btn_invite);
btnInvite.setVisibility(Constants.showBetaFeature(Constants.KEY_MEETUPS, getActivity()) ? View.VISIBLE : View.GONE);
btnLeave = v.findViewById(R.id.btn_leave);
btnLeave.setVisibility(Constants.showBetaFeature(Constants.KEY_MEETUPS, getActivity()) ? View.VISIBLE : View.GONE);
btnLeave.setOnClickListener(this);
title = v.findViewById(R.id.meetup_title);
fragmentMyMeetupDetailBinding = FragmentMyMeetupDetailBinding.inflate(inflater, container, false);
listDesc = fragmentMyMeetupDetailBinding.getRoot().findViewById(R.id.list_desc);
listUsers = fragmentMyMeetupDetailBinding.getRoot().findViewById(R.id.list_users);
tvJoined = fragmentMyMeetupDetailBinding.getRoot().findViewById(R.id.tv_joined);
fragmentMyMeetupDetailBinding.btnInvite.setVisibility(Constants.showBetaFeature(Constants.KEY_MEETUPS, getActivity()) ? View.VISIBLE : View.GONE);
fragmentMyMeetupDetailBinding.btnLeave.setVisibility(Constants.showBetaFeature(Constants.KEY_MEETUPS, getActivity()) ? View.VISIBLE : View.GONE);
fragmentMyMeetupDetailBinding.btnLeave.setOnClickListener(this);
mRealm = new DatabaseService(getActivity()).getRealmInstance();
profileDbHandler = new UserProfileDbHandler(getActivity());
user = mRealm.copyFromRealm(profileDbHandler.getUserModel());
return v;
return fragmentMyMeetupDetailBinding.getRoot();
}

@Override
Expand All @@ -88,7 +81,7 @@ private void setUserList() {
}

private void setUpData() {
title.setText(meetups.getTitle());
fragmentMyMeetupDetailBinding.meetupTitle.setText(meetups.getTitle());
final HashMap<String, String> map = RealmMeetup.getHashMap(meetups);
final ArrayList<String> keys = new ArrayList<>(map.keySet());
listDesc.setAdapter(new ArrayAdapter<String>(getActivity(), R.layout.row_description, keys) {
Expand Down Expand Up @@ -116,11 +109,12 @@ private void leaveJoinMeetUp() {
mRealm.executeTransaction(realm -> {
if (meetups.getUserId().isEmpty()) {
meetups.setUserId(user.getId());
btnLeave.setText(R.string.leave);
fragmentMyMeetupDetailBinding.btnLeave.setText(R.string.leave);
} else {
meetups.setUserId("");
btnLeave.setText(R.string.join);
fragmentMyMeetupDetailBinding.btnLeave.setText(R.string.join);
}
});
}
}

0 comments on commit eecf593

Please sign in to comment.