Skip to content

Commit

Permalink
FragmentAddMistake0 bug fixed
Browse files Browse the repository at this point in the history
Signed-off-by: xavieryao <[email protected]>
  • Loading branch information
xavieryao committed Oct 5, 2013
1 parent 83a58ae commit 6461769
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 44 deletions.
7 changes: 4 additions & 3 deletions res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@
<string-array name="drawer_items">
<item>首页</item>
<item>全部题目</item>
<item>Sample Page 0</item>
<item>Sample Page 1</item>
<item>Sample Page 2</item>
<item>自我评测</item>
<item>牛X的功能</item>
<item>牛X的功能</item>
<item>关于</item>
</string-array>
<!-- 版权信息 -->
<string name="copy_right">哪错了?\n版本:Rolling Stone pre-ɑ\n2013 PaperAirplane Dev Team</string>
Expand Down
8 changes: 7 additions & 1 deletion src/org/papdt/miscol/ui/ActivityMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import org.papdt.miscol.R;
import org.papdt.miscol.ui.adapter.DrawerAdapter;
import org.papdt.miscol.ui.adapter.DrawerAdapter.IDrawerNames;
import org.papdt.miscol.ui.fragment.FragmentAbout;
import org.papdt.miscol.ui.fragment.FragmentConstruction;
import org.papdt.miscol.ui.fragment.FragmentMain;
import org.papdt.miscol.ui.fragment.FragmentCategories;

Expand Down Expand Up @@ -113,8 +115,11 @@ private void selectItem(int position) {
case MISTAKES:
mFragments[position] = FragmentCategories.getInstance();
break;
case ABOUT:
mFragments[position] = new FragmentAbout();
break;
default:
mFragments[position] = new Fragment();
mFragments[position] = new FragmentConstruction();
// TODO 初始化各Fragment
break;
}
Expand Down Expand Up @@ -240,6 +245,7 @@ private void initializeTabs() {
mTabListener = new MistakesTabListener(
(FragmentCategories) mFragments[MISTAKES]);
}
//FIXME 横屏模式下ActionBar Tab颜色问题
actionBar.removeAllTabs();
Tab tagTab = actionBar.newTab().setText(R.string.tag)
.setTag(MistakesTabListener.TAGS).setTabListener(mTabListener);
Expand Down
2 changes: 1 addition & 1 deletion src/org/papdt/miscol/ui/MistakeCard.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class MistakeCard extends Card {

public MistakeCard(Mistake m) {
mMistake = m;
setmBindedObject(mMistake);
this.setmBindedObject(mMistake);
}

@Override
Expand Down
6 changes: 4 additions & 2 deletions src/org/papdt/miscol/ui/adapter/DrawerAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@ public class DrawerAdapter extends BaseAdapter {
public interface IDrawerNames {
int MAIN = 0; // 要不以后这么样,常量不要那么多,用接口
int MISTAKES = 1; // fython : 嗯!
int THIRD = 2;
int TEST = 2;
int FORTH = 3;
int FIFTH = 4;
String[] TAGS = { "Welcome", "Mistakes", "Third", "Forth", "Fifth" };
int ABOUT = 5;
String[] TAGS = { "Welcome", "Mistakes", "Test", "Forth", "Fifth",
"About" };
}

public DrawerAdapter(String[] datas, Context ctx) {
Expand Down
44 changes: 22 additions & 22 deletions src/org/papdt/miscol/ui/fragment/FragmentAddMistake0.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,14 @@
import android.widget.Toast;

public class FragmentAddMistake0 extends AbsFragmentAddMistake implements
OnItemSelectedListener,CategoryInfo.TYPE {
OnItemSelectedListener, CategoryInfo.TYPE {

private LinearLayout mLayout;
private EditText mEtTitle;
private Spinner mSpinnerGrade, mSpinnerSubject, mSpinnerType;
private TextView mTvTags;
private Mistake mMistake;
private DatabaseHelper mDbHelper;
private boolean mInitialized;
private ArrayAdapter<String> mGradeAdapter, mSubjectAdapter;
public HashSet<String> mTags = new HashSet<String>();
public HashSet<String> mAllTags = new HashSet<String>();
Expand Down Expand Up @@ -76,19 +75,23 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
mTvTags = (TextView) mLayout.findViewById(R.id.tv_tags);
mSpinnerGrade = (Spinner) mLayout.findViewById(R.id.spinner_grade);
mSpinnerSubject = (Spinner) mLayout.findViewById(R.id.spinner_subject);
mSpinnerType = (Spinner)mLayout.findViewById(R.id.spinner_type);
mSpinnerType = (Spinner) mLayout.findViewById(R.id.spinner_type);

mSpinnerGrade.setAdapter(mGradeAdapter);
mSpinnerSubject.setAdapter(mSubjectAdapter);
mSpinnerType.setAdapter(new ArrayAdapter<String>(getActivity(),android.R.layout.simple_spinner_item,getResources().getStringArray(R.array.types)));
((ArrayAdapter<?>)mSpinnerType.getAdapter()).setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);

mSpinnerType.setAdapter(new ArrayAdapter<String>(getActivity(),
android.R.layout.simple_spinner_item, getResources()
.getStringArray(R.array.types)));
((ArrayAdapter<?>) mSpinnerType.getAdapter())
.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);

mSpinnerGrade.setOnItemSelectedListener(this);
mSpinnerSubject.setOnItemSelectedListener(this);
fillDatas();
assert (mSpinnerGrade.getOnItemSelectedListener() == this);
return mLayout;
}

@Override
public void onPrepareOptionsMenu(Menu menu) {
menu.clear();
Expand Down Expand Up @@ -170,8 +173,7 @@ private void fillDatas() {
}
mAllTags.addAll(mTags);
CategoryInfo[] gradeInfo = mDbHelper.getCategoryInfo(GRADES);
CategoryInfo[] subjectInfo = mDbHelper
.getCategoryInfo(SUBJECTS);
CategoryInfo[] subjectInfo = mDbHelper.getCategoryInfo(SUBJECTS);
addCategoryInfoToAdapter(gradeInfo, mGradeAdapter);
addCategoryInfoToAdapter(subjectInfo, mSubjectAdapter);
String addCat = getString(R.string.add_category);
Expand All @@ -194,12 +196,11 @@ private void fillDatas() {
mSpinnerSubject.setSelection(subjectIndex);
}
}
mInitialized = true;
}

private void addCategoryInfoToAdapter(CategoryInfo[] info,
ArrayAdapter<String> adapter) {
if (info != null) {
if (info.length > 0) {
for (CategoryInfo ci : info) {
adapter.add(ci.getName());
}
Expand Down Expand Up @@ -364,22 +365,23 @@ private void addGrade(String name) {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position,
long id) {
Log.d(TAG, "onItemSelected position: " + position);
// FIXME 根本不工作
Log.d(TAG, "onItemSelected");
try {
switch (parent.getId()) {
case R.id.spinner_grade:
Log.d(TAG, "mSpinnerGrade onItemSelected position: " + position);
Log.d(TAG, mGradeAdapter.getItem(position));
if (mGradeAdapter.getItem(position).equals(
getString(R.string.add_category))&&mInitialized) {
Log.d(TAG, "addGrade");
getString(R.string.add_category)))
openAddGradeDialog();
}
break;
case R.id.spinner_subject:
Log.d(TAG, "mSpinnerSubject onItemSelected position: "
+ position);
if (mSubjectAdapter.getItem(position).equals(
getString(R.string.add_category))&&mInitialized) {
Log.d(TAG, "addSubject");
getString(R.string.add_category)))
openAddSubjectDialog();
}
break;
}
} catch (NullPointerException e) {
Expand All @@ -389,9 +391,7 @@ public void onItemSelected(AdapterView<?> parent, View view, int position,

@Override
public void onNothingSelected(AdapterView<?> arg0) {

Log.d(TAG, "onNothingSelected.");
}

}


17 changes: 5 additions & 12 deletions src/org/papdt/miscol/ui/fragment/FragmentCategories.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
* 用于显示 [标签]、[年级/科目] 的全部分类的Fragment
*
*/
public class FragmentCategories extends AbsFragmentCategories implements CategoryInfo.TYPE {
public class FragmentCategories extends AbsFragmentCategories implements
CategoryInfo.TYPE {

private final int NULL = -1;

Expand Down Expand Up @@ -67,15 +68,6 @@ public void onClick(View arg0) {
}

});
return v;
}

/**
* 刷新
*/
@Override
public void onResume() {
super.onResume();
if (mCurrentTab != NULL) {
switch (mCurrentTab) {
case TAGS:
Expand All @@ -86,7 +78,9 @@ public void onResume() {
break;
}
}
getActivity().getActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
getActivity().getActionBar().setNavigationMode(
ActionBar.NAVIGATION_MODE_TABS);
return v;
}

@Override
Expand Down Expand Up @@ -138,7 +132,6 @@ public FragmentCategories() {
Log.d(TAG, TAG + "被初始化");
}


private CategoryCard[] queryCategoryCards(int category) {
CategoryInfo[] info = mDbHelper.getCategoryInfo(category);
return processCategoryCard(info);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

public class FragmentMistakeDetail extends Fragment implements OnClickListener{
public final static String TAG = "FragmentMistakeDetail";
private final static String KEY = "Mistake";
public final static String KEY = "Mistake";

private Mistake mMistake;
private Answer mAnswer;
Expand Down
4 changes: 2 additions & 2 deletions src/org/papdt/miscol/ui/fragment/FragmentMistakes.java
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,11 @@ public void onClick(DialogInterface view, int button) {
public void onClick(View v) {
Mistake m = (Mistake) v.getTag();
Bundle args = new Bundle();
args.putParcelable(KEY, m);
args.putParcelable(FragmentMistakeDetail.KEY, m);
Fragment fragment = new FragmentMistakeDetail();
fragment.setArguments(args);
getFragmentManager().beginTransaction().addToBackStack(TAG)
.replace(R.id.fl_content, fragment).commit();
.replace(R.id.fl_content, fragment).commit();
}

}

0 comments on commit 6461769

Please sign in to comment.