示例#1
0
 @Override
 public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
   Header header = (Header) parent.getItemAtPosition(position);
   String lessonNo = Integer.toString(header.getNo());
   VolleyHelper.createInstance(HeaderActivity.this)
       .requestLesson(
           lessonNo,
           new LessonCallback() {
             @Override
             public void execute(byte[] data) {
               Intent intent = MainActivity.createIntent(HeaderActivity.this, data);
               startActivityForResult(intent, RC_HEADER);
             }
           });
 }
示例#2
0
 private void reloadLesson(Header header) {
   String lessonNo = Integer.toString(header.getNo());
   VolleyHelper.createInstance(HeaderActivity.this)
       .requestLesson(
           lessonNo,
           new LessonCallback() {
             @Override
             public void execute(byte[] data) {
               HeaderAdapter adapter = (HeaderAdapter) mHeaderList.getAdapter();
               adapter.notifyDataSetChanged();
             }
           });
 }
示例#3
0
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
    ViewHolder holder;
    if (convertView == null) {
      LayoutInflater inflater =
          (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
      convertView = inflater.inflate(R.layout.header_item, null);
      holder = new ViewHolder();
      holder.noText = (TextView) convertView.findViewById(R.id.no_text);
      holder.titleText = (TextView) convertView.findViewById(R.id.title_text);
      holder.unloadText = (TextView) convertView.findViewById(R.id.unload_text);
      convertView.setTag(holder);
    } else {
      holder = (ViewHolder) convertView.getTag();
    }

    Header header = getItem(position);
    holder.noText.setText(getContext().getString(R.string.lesson_no, header.getNo()));
    holder.titleText.setText(header.getTitle());
    SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getContext());
    boolean isUnloaded = !preferences.contains(Integer.toString(header.getNo()));
    holder.unloadText.setVisibility(isUnloaded ? View.VISIBLE : View.GONE);
    return convertView;
  }