|
| 1 | +package io.agora.api.example.examples.advanced; |
| 2 | + |
| 3 | +import static io.agora.api.example.common.model.Examples.ADVANCED; |
| 4 | + |
| 5 | +import android.os.Bundle; |
| 6 | +import android.text.TextUtils; |
| 7 | +import android.view.LayoutInflater; |
| 8 | +import android.view.View; |
| 9 | +import android.view.ViewGroup; |
| 10 | +import android.widget.EditText; |
| 11 | +import android.widget.Spinner; |
| 12 | +import android.widget.Toast; |
| 13 | + |
| 14 | +import androidx.annotation.NonNull; |
| 15 | +import androidx.annotation.Nullable; |
| 16 | +import androidx.navigation.Navigation; |
| 17 | + |
| 18 | +import io.agora.api.example.R; |
| 19 | +import io.agora.api.example.annotation.Example; |
| 20 | +import io.agora.api.example.common.BaseFragment; |
| 21 | + |
| 22 | +@Example( |
| 23 | + index = 24, |
| 24 | + group = ADVANCED, |
| 25 | + name = R.string.item_third_party_beauty, |
| 26 | + actionId = R.id.action_mainFragment_to_third_party_beauty, |
| 27 | + tipsId = R.string.third_party_beauty |
| 28 | +) |
| 29 | +public class ThirdPartyBeauty extends BaseFragment { |
| 30 | + |
| 31 | + private EditText etChannel; |
| 32 | + private Spinner snBeautyType; |
| 33 | + private int[] beautyActionIds; |
| 34 | + |
| 35 | + @Nullable |
| 36 | + @Override |
| 37 | + public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { |
| 38 | + return inflater.inflate(R.layout.fragment_third_party_beauty, container, false); |
| 39 | + } |
| 40 | + |
| 41 | + @Override |
| 42 | + public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { |
| 43 | + super.onViewCreated(view, savedInstanceState); |
| 44 | + etChannel = view.findViewById(R.id.et_channel); |
| 45 | + snBeautyType = view.findViewById(R.id.sn_beauty_type); |
| 46 | + beautyActionIds = new int[]{ |
| 47 | + R.id.action_third_party_beauty_to_scene_time |
| 48 | + }; |
| 49 | + |
| 50 | + view.findViewById(R.id.btn_join).setOnClickListener(v -> { |
| 51 | + int index = snBeautyType.getSelectedItemPosition(); |
| 52 | + if (index >= beautyActionIds.length) { |
| 53 | + return; |
| 54 | + } |
| 55 | + String channelName = etChannel.getText().toString(); |
| 56 | + if (TextUtils.isEmpty(channelName)) { |
| 57 | + Toast.makeText(getContext(), "The channel name is empty!", Toast.LENGTH_SHORT).show(); |
| 58 | + return; |
| 59 | + } |
| 60 | + Bundle args = new Bundle(); |
| 61 | + args.putString(getString(R.string.key_channel_name), channelName); |
| 62 | + Navigation.findNavController(view) |
| 63 | + .navigate(beautyActionIds[index], args); |
| 64 | + }); |
| 65 | + } |
| 66 | +} |
0 commit comments