Android Open Source - markj Jw Preference






From Project

Back to project page markj.

License

The source code is released under:

GNU Lesser General Public License

If you think the Android project markj 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.markjmind.mobile.api.android.util;
//from www.j  a  va  2 s  . c  o m
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;

import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;

import com.markjmind.mobile.api.hub.JDhub;
import com.markjmind.mobile.api.hub.Store;
import com.markjmind.mobile.api.hub.StoreList;

public class JwPreference {
  Context context;
  String preference;
  SharedPreferences sp;
  JDhub jd = new JDhub();
  Editor editor;
  
  public JwPreference(Context context,String preference_name){
    this.context = context;
    this.preference = preference_name;
    sp = context.getSharedPreferences(preference, context.MODE_WORLD_READABLE|context.MODE_WORLD_WRITEABLE);
    editor = sp.edit();
    
  }
  
  public synchronized void setStore(String key, Store store){
    
    String msg = jd.sendString(store);
    editor.putString(key, msg);
    editor.commit();
  }
  
  public Store getStore(String key){
    String msg=sp.getString(key, "");
    if(msg==null){
      return null;
    }
    Store result = jd.receiveStore(msg);
    return result;
  }    
  
  public int size(){
    Map map = sp.getAll();
    return map.size();
  }
  
  public String[] getKeys(){
    Map map = sp.getAll();
    if(map.size()==0){
      return null;
    }
    Set set = map.keySet();
    Iterator iter = set.iterator();
    String[] keys = new String[set.size()];
    int index = 0;
    while(iter.hasNext()){
      keys[index]=(String)iter.next();
      index++;
    }
    return keys;
  }
  
  public StoreList getStoreList(){
    StoreList list = new StoreList();
    String[] keys = this.getKeys();
    for(int i=0;i<keys.length;i++){
      list.add(this.getStore(keys[i]));
    }
    return list;
  }
  
  // ????? storelist? ????.
  public StoreList getStoreList(String sortKey){
    StoreList sl = this.getStoreList();
    sl.sort(sortKey);
    return sl;
  }
  
  // ????? storelist? ????.
    public StoreList getStoreList(String sortKey,boolean ASC){
      StoreList sl = this.getStoreList();
      sl.sort(sortKey, ASC);
      return sl;
    }
    
  public StoreList search(String storeKey, String value){
//    ArrayList result = new ArrayList();
//    String[] keys = this.getKeys();
//    for(int i=0;i<keys.length;i++){
//      Store temp = this.getStore(keys[i]);
//      if(temp.containsKey(storeKey)){
//        if(value.equals(temp.getString(storeKey))){
//          result.add(keys[i]);
//        }
//      }
//    }
//    if(result.size()==0){
//      return null;
//    }else{
//      return result;
//    }
    StoreList list = getStoreList();
    return list.search(storeKey, value);
  }

  public void updateAll(String storeKey, String value){
    String[] keys = this.getKeys();
    for(int i=0;i<keys.length;i++){
      Store temp = this.getStore(keys[i]);
      if(temp.containsKey(storeKey)){
        temp.add(storeKey, value);
      }
    }
  }
  
  public void update(String key, String storeKey, String value){
    Store temp = this.getStore(key);
    if(temp.containsKey(storeKey)){
      temp.add(storeKey, value);
    }
  }
  
  public void remove(String key){
    editor.remove(key);
    editor.commit();
  }
  
  public void remove(String key,String storeKey){
    this.getStore(key).remove(key);
  }

}




Java Source Code List

com.markjmind.mobile.api.android.controller.JwAsyncTask.java
com.markjmind.mobile.api.android.controller.JwMapperException.java
com.markjmind.mobile.api.android.controller.JwMemberMapper.java
com.markjmind.mobile.api.android.controller.JwStringID.java
com.markjmind.mobile.api.android.controller.JwViewController.java
com.markjmind.mobile.api.android.controller.JwViewerCache.java
com.markjmind.mobile.api.android.controller.JwViewer.java
com.markjmind.mobile.api.android.controller.Jwc.java
com.markjmind.mobile.api.android.controller.OnClickListenerReceiver.java
com.markjmind.mobile.api.android.controller.ViewerXmlMapper.java
com.markjmind.mobile.api.android.exception.JwErrorCode.java
com.markjmind.mobile.api.android.exception.JwException.java
com.markjmind.mobile.api.android.json.JSONMsgString.java
com.markjmind.mobile.api.android.json.JwJOSNTreeArray.java
com.markjmind.mobile.api.android.json.JwJSONReader.java
com.markjmind.mobile.api.android.ui.JwAnimation.java
com.markjmind.mobile.api.android.ui.JwGroup.java
com.markjmind.mobile.api.android.ui.JwMenu.java
com.markjmind.mobile.api.android.ui.JwOnGroupSelect.java
com.markjmind.mobile.api.android.ui.JwTabGroup.java
com.markjmind.mobile.api.android.ui.JwTouchGroupListener.java
com.markjmind.mobile.api.android.ui.JwTouchGroup.java
com.markjmind.mobile.api.android.ui.JwTouchMotionGroupLisener.java
com.markjmind.mobile.api.android.ui.JwTouchMotionGroup.java
com.markjmind.mobile.api.android.ui.drawgraph.GraphBoard.java
com.markjmind.mobile.api.android.ui.drawgraph.GraphSkin.java
com.markjmind.mobile.api.android.ui.drawgraph.HBackLineSkin.java
com.markjmind.mobile.api.android.ui.drawgraph.LineGraphSkin.java
com.markjmind.mobile.api.android.ui.drawgraph.PieGraph.java
com.markjmind.mobile.api.android.ui.drawgraph.RectGraphSkin.java
com.markjmind.mobile.api.android.ui.drawgraph.SimpleStyle.java
com.markjmind.mobile.api.android.ui.drawgraph.TextArraySkin.java
com.markjmind.mobile.api.android.ui.drawgraph.VBackLineSkin.java
com.markjmind.mobile.api.android.ui.graph.Arc.java
com.markjmind.mobile.api.android.ui.graph.BarElement.java
com.markjmind.mobile.api.android.ui.graph.BarLayout.java
com.markjmind.mobile.api.android.ui.graph.Bar.java
com.markjmind.mobile.api.android.ui.graph.IPieSkin.java
com.markjmind.mobile.api.android.ui.graph.LineLayout.java
com.markjmind.mobile.api.android.ui.graph.MeasureLayout.java
com.markjmind.mobile.api.android.ui.graph.PieArcRoundSkin.java
com.markjmind.mobile.api.android.ui.graph.PieLayout.java
com.markjmind.mobile.api.android.ui.graph.PiePercentSkin.java
com.markjmind.mobile.api.android.ui.view.JwBaseDropDown.java
com.markjmind.mobile.api.android.ui.view.JwDropDown.java
com.markjmind.mobile.api.android.ui.view.JwSlidingLayout.java
com.markjmind.mobile.api.android.ui.view.JwWheelView.java
com.markjmind.mobile.api.android.ui.view.StickerListener.java
com.markjmind.mobile.api.android.ui.view.StickerView.java
com.markjmind.mobile.api.android.ui.view.textview.JwTextViewAutoScale.java
com.markjmind.mobile.api.android.ui.view.textview.JwTextViewFonts.java
com.markjmind.mobile.api.android.ui.view.textview.JwTextViewWrapScale.java
com.markjmind.mobile.api.android.ui.wrapper.JwAlertDialog.java
com.markjmind.mobile.api.android.ui.wrapper.JwToast.java
com.markjmind.mobile.api.android.util.JwFile.java
com.markjmind.mobile.api.android.util.JwPreferenceList.java
com.markjmind.mobile.api.android.util.JwPreference.java
com.markjmind.mobile.api.android.util.JwSound.java
com.markjmind.mobile.api.android.util.JwTextUtils.java
com.markjmind.mobile.api.android.util.PhoneInfo.java
com.markjmind.mobile.api.android.util.WebConnection.java
com.markjmind.mobile.api.android.xml.JwDomHandler.java
com.markjmind.mobile.api.android.xml.JwDomLoader.java
com.markjmind.mobile.api.android.xml.JwEditElementHandler.java
com.markjmind.mobile.api.android.xml.JwXmlLoader.java
com.markjmind.mobile.api.android.xml.JwXmlResoure.java
com.markjmind.mobile.api.hub.ArrayJDhub.java
com.markjmind.mobile.api.hub.DBhub.java
com.markjmind.mobile.api.hub.JDhub.java
com.markjmind.mobile.api.hub.Loader.java
com.markjmind.mobile.api.hub.StoreList.java
com.markjmind.mobile.api.hub.Store.java