package com.ttstd.dialer.fragment.settings;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.provider.Settings;
import android.util.Log;
import android.view.View;

import com.ttstd.dialer.R;
import com.ttstd.dialer.activity.app.AppListActivity;
import com.ttstd.dialer.base.mvvm.fragment.BaseMvvmFragment;
import com.ttstd.dialer.databinding.FragmentSettingsBinding;

public class SettingsFragment extends BaseMvvmFragment<SettingsViewModel, FragmentSettingsBinding> {
    private static final String TAG = "SettingsFragment";

    private Activity mContext;

    @Override
    protected int getLayoutId() {
        return R.layout.fragment_settings;
    }

    @Override
    protected void initDataBinding() {
        mContext = getActivity();
        mViewModel.setContext(mContext);
        mViewModel.setVDBinding(mViewDataBinding);
        mViewModel.setLifecycle(getLifecycleSubject());
        mViewDataBinding.setClick(new BtnClick());
    }

    @Override
    protected void initView(Bundle bundle) {

    }

    @Override
    protected void initData(Bundle savedInstanceState) {

    }

    @Override
    public void fetchData() {

    }

    public class BtnClick {
        public void openSettings(View view) {
            Intent intent = new Intent(Settings.ACTION_SETTINGS);
            try {
                startActivity(intent);
            } catch (Exception e) {
                Log.e(TAG, "openSettings: " + e.getMessage());
            }
        }

        public void openAppList(View view) {
            startActivity(new Intent(mContext, AppListActivity.class));
        }
    }
}
