示例#1
0
  @Override
  public void onResume() {
    if (activity != null) {

      Boolean a = s.getBoolean(IS_TIME_TABLE_CHANGED, true);
      timetable = s.getString(GET_TIME_TABLE, null);
      adapter2 = new CustomList_calendar(activity, days, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9);
      lvTest.setAdapter(adapter2);
      lvTest.setItemMargin(10);

      if (a || timetable == null) {
        if (Utils.isNetworkAvailable(activity)) new DownloadWebPageTask2().execute();
        else {
          if (activity != null)
            SnackbarManager.show(
                Snackbar.with(activity.getApplicationContext())
                    .text("Check Your Internet Connection")
                    .duration(Snackbar.SnackbarDuration.LENGTH_SHORT),
                activity);
        }
      } else {
        load();
      }
    }
    super.onResume();
  }
示例#2
0
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_calender, container, false);
    lvTest = (TwoWayView) rootView.findViewById(R.id.lvItems);
    if (activity == null) return rootView;

    s = PreferenceManager.getDefaultSharedPreferences(activity);
    e = s.edit();
    Boolean b = s.getBoolean(IS_CLASS_SET, false);
    if (!b) {
      Intent i = new Intent(activity, ChooseClass.class);
      startActivity(i);
    }

    Boolean a = s.getBoolean(IS_TIME_TABLE_CHANGED, true);
    timetable = s.getString(GET_TIME_TABLE, null);

    adapter2 = new CustomList_calendar(activity, days, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9);
    lvTest.setAdapter(adapter2);
    lvTest.setItemMargin(10);

    if (a == true || timetable == null) {
      if (Utils.isNetworkAvailable(activity)) new DownloadWebPageTask2().execute();
      else {
        SnackbarManager.show(
            Snackbar.with(activity.getApplicationContext())
                .text("Check Your Internet Connection")
                .duration(Snackbar.SnackbarDuration.LENGTH_SHORT),
            activity);
      }
    } else {
      load();
    }

    lvTest.setOnScrollListener(
        new TwoWayView.OnScrollListener() {
          @Override
          public void onScrollStateChanged(TwoWayView view, int scrollState) {}

          @Override
          public void onScroll(
              TwoWayView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
            int lastInScreen = firstVisibleItem + visibleItemCount;
            if ((lastInScreen == totalItemCount) && !(loadingMore)) {
              load();
            }
            adapter2.notifyDataSetChanged();
          }
        });
    return rootView;
  }