admin
2024-07-03 a40e0e51331e5e6f69e8bed5940512b29150c7a9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package com.taoke.autopay.android.ui;
 
import android.graphics.Color;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toast;
 
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatDialogFragment;
 
import com.taoke.autopay.android.App;
import com.taoke.autopay.android.data.local.LocalStore;
import com.taoke.autopay.android.databinding.FragmentPayTimesSettingBinding;
 
public class PayTimesSettingFragment extends AppCompatDialogFragment {
 
    private FragmentPayTimesSettingBinding mViewBinding;
 
    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        mViewBinding = FragmentPayTimesSettingBinding.inflate(inflater, container, false);
        mViewBinding.getRoot().setBackgroundColor(Color.TRANSPARENT);
        return mViewBinding.getRoot();
    }
 
    @Override
    public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
        mViewBinding.etPayTimes.setText(String.valueOf(LocalStore.getInstance().getPayTimes()));
        mViewBinding.button.setOnClickListener(v -> {
            int payTimes = Integer.parseInt(mViewBinding.etPayTimes.getEditableText().toString());
            if (payTimes < 0) {
                Toast.makeText(App.getInstance(), "最小0次", Toast.LENGTH_SHORT).show();
                return;
            }
            if (payTimes > 50) {
                Toast.makeText(App.getInstance(), "最大50次", Toast.LENGTH_SHORT).show();
                return;
            }
            LocalStore.getInstance().putPayTimes(payTimes);
            dismiss();
        });
    }
}