Android Open Source - SSPIA Setttings Class






From Project

Back to project page SSPIA.

License

The source code is released under:

MIT License

If you think the Android project SSPIA listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.fiec.sspia.mclass;
// www .  ja  va  2 s.com
import android.R.color;
import android.app.Activity;
import android.app.Dialog;
import android.content.DialogInterface;
import android.content.DialogInterface.OnDismissListener;
import android.content.DialogInterface.OnShowListener;
import android.graphics.drawable.ColorDrawable;
import android.support.v4.app.FragmentActivity;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.Window;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.EditText;
import android.widget.Toast;

import com.fiec.ssapp.R;
import com.fiec.sspia.db.SolarDb;

public class SetttingsClass implements OnCheckedChangeListener, OnDismissListener, OnShowListener{
  
  private Activity act;
  private Dialog dialog;
  private LayoutInflater inflater;
  private View view;
  private EditText min, max;
  private CheckBox cheq;
  private double _MIN = -82, _MAX = -22;
  private SolarDb db;

  public SetttingsClass(FragmentActivity act) {
    this.act = act;
    dialog = new Dialog(act);
    db = new SolarDb(act);
    inflater = (LayoutInflater)act.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
    view = inflater.inflate(R.layout.customdialog, null);
    cheq = (CheckBox)view.findViewById(R.id.notify_checkstatus);
    min = (EditText)view.findViewById(R.id.notify_mintemp);
    max = (EditText)view.findViewById(R.id.notify_maxtemp);
    cheq.setOnCheckedChangeListener(this);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setOnShowListener(this);
    dialog.getWindow().setBackgroundDrawable(new ColorDrawable(color.transparent));
    dialog.setOnShowListener(this);
    dialog.setCanceledOnTouchOutside(true);    
    dialog.setOnDismissListener(this);
  }
  
  public void isNoty(String ischk){    
    
    if(ischk.equals("true")) cheq.setChecked(true);
    else cheq.setChecked(false);
    
    dialog.setContentView(view);
    dialog.show();
  }
  
  public boolean notiStatus(){
    return cheq.isChecked() ? true:false;
  }
  
  public double getMin(){
    if(!min.getText().toString().equals(""))
      this._MIN = getTemp(min.getText().toString());
    return this._MIN;
  }
  public double getMax(){
    if(!max.getText().toString().equals(""))
      this._MAX = getTemp(max.getText().toString());
    return this._MAX;
  }
  
  private double getTemp(String arg){
    try{
      return Double.parseDouble(arg);
    } catch(NumberFormatException ex){Toast.makeText(act, "Number Format Exception, try again",
        Toast.LENGTH_SHORT).show();
    return 0;
    }
  }
  
  public void isAbout(){
    dialog.setContentView(R.layout.about_dialog);
    dialog.show();
  }

  @Override
  public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
    Log.i("gmaTag", "entra0 = "+isChecked);
    db.open();
    db.updateLogIscheck(String.valueOf(isChecked));
    db.close();
  }

  @Override
  public void onDismiss(DialogInterface dialog) {
    getMin(); getMax();
    db.open();
    db.updateLogTemp(String.valueOf(_MIN), String.valueOf(_MAX));
    db.close();
  }

  @Override
  public void onShow(DialogInterface dialog) {
    String[]aux;
    String aux2;
    db.open();
    aux = db.getUserTemp();
    min.setText(aux[0]);
    max.setText(aux[1]);
    aux2 = db.getIsCheck();
    if(aux2.equals("true")) cheq.setChecked(true);
    else cheq.setChecked(false);
    
    
    db.close();
  }

}




Java Source Code List

com.fiec.sspia.buff.DefaultNoti.java
com.fiec.sspia.buff.PlanetClass.java
com.fiec.sspia.buff.PlanetSource.java
com.fiec.sspia.buff.Tag.java
com.fiec.sspia.db.Celestial.java
com.fiec.sspia.db.DBHelper.java
com.fiec.sspia.db.DbAuxClass.java
com.fiec.sspia.db.Planets.java
com.fiec.sspia.db.Satellites.java
com.fiec.sspia.db.SolarDb.java
com.fiec.sspia.main.InformationTab.java
com.fiec.sspia.main.SatellitesClass.java
com.fiec.sspia.main.SolarActivity.java
com.fiec.sspia.main.TabsPlanets.java
com.fiec.sspia.mclass.MainClass.java
com.fiec.sspia.mclass.MainFragment.java
com.fiec.sspia.mclass.SSNotific.java
com.fiec.sspia.mclass.SetttingsClass.java
com.fiec.sspia.mclass.SplashClass.java
com.fiec.sspia.system.BroadcastRec.java
com.fiec.sspia.system.SspiaService.java
com.fiec.sspia.system.StartingNotis.java
com.fiec.sspia.util.AbstrCd.java
com.fiec.sspia.util.CdClass.java
com.fiec.sspia.util.CustomInfoAdapter.java
com.fiec.sspia.util.CustomMenuAdapter.java
com.fiec.sspia.util.FillMenuAdapter.java
com.fiec.sspia.util.JSONParser.java
com.fiec.sspia.util.MainGridAdapterClass.java
com.fiec.sspia.util.MenuSettings.java
com.fiec.sspia.util.SSInterfaceNoti.java
com.fiec.sspia.util.SatelliteGridAdapterClass.java
com.fiec.sspia.util.TempClass.java
com.fiec.sspia.util.TransitionClass.java