Search in sources :

Example 1 with Permissions

use of com.a5corp.weather.permissions.Permissions in project Weather by Sparker0i.

the class WeatherFragment method onOptionsItemSelected.

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch(item.getItemId()) {
        case R.id.location:
            permission = new Permissions(getContext());
            requestPermissions(new String[] { android.Manifest.permission.ACCESS_COARSE_LOCATION }, Constants.READ_COARSE_LOCATION);
            break;
        case R.id.search:
            showMenuInputDialog();
            break;
    }
    return true;
}
Also used : Permissions(com.a5corp.weather.permissions.Permissions)

Example 2 with Permissions

use of com.a5corp.weather.permissions.Permissions in project Weather by Sparker0i.

the class FirstLaunchFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    rootView = inflater.inflate(R.layout.fragment_first_launch, container, false);
    preferences = new Prefs(getContext());
    cityInput = (EditText) rootView.findViewById(R.id.city_input);
    textField = (MaterialTextField) rootView.findViewById(R.id.materialTextField);
    ImageView img = (ImageView) textField.findViewById(R.id.mtf_image);
    img.setImageAlpha(R.drawable.logo);
    img.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            permission = new Permissions(getContext());
            requestPermissions(new String[] { android.Manifest.permission.ACCESS_COARSE_LOCATION }, Constants.READ_COARSE_LOCATION);
        }
    });
    message = (TextView) rootView.findViewById(R.id.intro_text);
    if (GlobalActivity.i == 0) {
        message.setText(getString(R.string.pick_city));
    } else {
        message.setText(getString(R.string.uh_oh));
    }
    Button goButton = (Button) rootView.findViewById(R.id.go_button);
    goButton.setText(getString(R.string.first_go_text));
    goButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (!new CheckConnection(getContext()).isNetworkAvailable()) {
                Snackbar.make(rootView, getString(R.string.check_internet), Snackbar.LENGTH_SHORT).show();
            } else if (cityInput.getText().length() > 0) {
                launchActivity(0);
            } else {
                Snackbar.make(rootView, getString(R.string.enter_city_first), Snackbar.LENGTH_SHORT).show();
            }
        }
    });
    cityInput.setOnEditorActionListener(new EditText.OnEditorActionListener() {

        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (event != null && event.getKeyCode() == KeyEvent.KEYCODE_ENTER) {
                launchActivity(0);
                return true;
            }
            return false;
        }
    });
    return rootView;
}
Also used : EditText(android.widget.EditText) Prefs(com.a5corp.weather.preferences.Prefs) ImageView(android.widget.ImageView) TextView(android.widget.TextView) View(android.view.View) KeyEvent(android.view.KeyEvent) Button(android.widget.Button) Permissions(com.a5corp.weather.permissions.Permissions) TextView(android.widget.TextView) ImageView(android.widget.ImageView) CheckConnection(com.a5corp.weather.internet.CheckConnection)

Aggregations

Permissions (com.a5corp.weather.permissions.Permissions)2 KeyEvent (android.view.KeyEvent)1 View (android.view.View)1 Button (android.widget.Button)1 EditText (android.widget.EditText)1 ImageView (android.widget.ImageView)1 TextView (android.widget.TextView)1 CheckConnection (com.a5corp.weather.internet.CheckConnection)1 Prefs (com.a5corp.weather.preferences.Prefs)1