Skip to content

Commit

Permalink
Update MultiSelectPreference.
Browse files Browse the repository at this point in the history
  • Loading branch information
XhinLiang committed Mar 12, 2016
1 parent 237a80b commit 95ce533
Show file tree
Hide file tree
Showing 6 changed files with 86 additions and 4 deletions.
5 changes: 3 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".SettingsActivity">
<activity android:name=".SettingsActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

<activity android:name=".OriginalActivity" />
</application>

</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package xhinliang.github.io.mdpreference;


import android.app.Fragment;

/**
* Created by xhinliang on 16-3-11.
* original
*/
public class OriginalActivity extends SingleFragmentActivity {


@Override
protected Fragment createFragment() {
return new OriginalFragment();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package xhinliang.github.io.mdpreference;

import android.os.Bundle;
import android.preference.PreferenceFragment;

/**
* Created by xhinliang on 16-3-11.
* original
*/
public class OriginalFragment extends PreferenceFragment {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getPreferenceManager().setSharedPreferencesName(getString(R.string.app_name));
addPreferencesFromResource(R.xml.preference_original);
}
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,26 @@
package xhinliang.github.io.mdpreference;

import android.app.Fragment;
import android.content.SharedPreferences;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

import java.util.Set;

import io.github.xhinliang.mdpreference.MultiSelectListPreference;

public class SettingsActivity extends SingleFragmentActivity {

@Override
protected Fragment createFragment() {
return new SettingsFragment();
}

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
SharedPreferences preferences = getSharedPreferences(getString(R.string.app_name), MODE_PRIVATE);
preferences.getString("key_fff", "");

}
}
34 changes: 34 additions & 0 deletions app/src/main/res/xml/preference_original.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceCategory android:title="Alert Settings">
<CheckBoxPreference
android:key="preference_key_remind_the_same_day11"
android:summary="Alert in the birthday"
android:title="Alert first" />
<SwitchPreference
android:key="preference_key_remind_the_same_day31"
android:summary="Alert in three day before birthday"
android:title="Alert second" />
<EditTextPreference
android:key="preference_key_remind_the_same_daywwwd21"
android:summary="Alert in a week before the birthday"
android:title="Alert third" />
<SwitchPreference
android:key="preference_key_remind_the_same_day341"
android:summary="Alert in two weeks before the birthday"
android:title="Alert fourth" />
<ListPreference
android:entries="@array/alert_time_entry"
android:entryValues="@array/alert_time_value"
android:key="preference_key_alert_timess1"
android:summary="Select alert time"
android:title="Alert time"/>
<MultiSelectListPreference
android:entries="@array/alert_time_entry"
android:entryValues="@array/alert_time_value"
android:key="preference_key_alert_timeddwexss1"
android:summary="Select alert time"
android:title="Alert time" />
</PreferenceCategory>

</PreferenceScreen>
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ private int getBit(int[] indexes) {
return selected;
}

private Set<Integer> getSet(int bit) {
private static Set<Integer> getSet(int bit) {
Set<Integer> set = new HashSet<>();
int temp = 1;
for (int i = 0; i < 32; ++i) {
Expand All @@ -123,7 +123,7 @@ private Set<Integer> getSet(int bit) {
return set;
}

public Set<Integer> getSetByBit(int bit) {
public static Set<Integer> getSetByBit(int bit) {
return getSet(bit);
}

Expand Down

0 comments on commit 95ce533

Please sign in to comment.