package com.dd7.yahn;

import android.content.Context;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.Toast;
import com.dd7.yahn.service.PreferenceService;

public class SettingsActivity extends AppCompatActivity {

    private Context mContext;
    private PreferenceService mPreferenceService;
    private EditText mEditTextMaxStories;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_settings);
        mContext = getApplicationContext();
        mPreferenceService = new PreferenceService(mContext);

        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);

        mEditTextMaxStories = (EditText) findViewById(R.id.max_story_no);
        mEditTextMaxStories.setText(String.valueOf(mPreferenceService.getMaxStoriesSetting()));


        ImageButton fab = (ImageButton) findViewById(R.id.save_settings);
        fab.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                int val = Integer.parseInt(mEditTextMaxStories.getText().toString());
                mPreferenceService.saveMaxStoriesSetting(val);
                Toast.makeText(mContext, "Saved",Toast.LENGTH_SHORT).show();
            }
        });
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    }
}

@@ -78,114 +78,8 @@
 le;%0A
-import android.support.design.widget.FloatingActionButton;%0Aimport android.support.design.widget.Snackbar;%0A
 impo
@@ -1065,17 +1065,16 @@
 g()));%0A%0A
-%0A
         
@@ -1266,32 +1266,192 @@
 view) %7B%0A        
+        savePreferences();%0A            %7D%0A        %7D);%0A        getSupportActionBar().setDisplayHomeAsUpEnabled(true);%0A    %7D%0A%0A    private void savePreferences() %7B%0A
         int val 
@@ -1520,24 +1520,16 @@
         
-      
-  
 mPrefere
@@ -1567,24 +1567,16 @@
 g(val);%0A
-        
         
@@ -1640,97 +1640,8 @@
 ();%0A
-            %7D%0A        %7D);%0A        getSupportActionBar().setDisplayHomeAsUpEnabled(true);%0A
     

refactor a little bit