示例#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 void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    final Activity activity = getActivity();

    mToast = Toast.makeText(activity, "", Toast.LENGTH_SHORT);
    mToast.setGravity(Gravity.CENTER, 0, 0);

    mRecyclerView = (TwoWayView) view.findViewById(R.id.list);
    mRecyclerView.setHasFixedSize(true);
    mRecyclerView.setLongClickable(true);

    mPositionText = (TextView) view.getRootView().findViewById(R.id.position);
    mCountText = (TextView) view.getRootView().findViewById(R.id.count);

    mStateText = (TextView) view.getRootView().findViewById(R.id.state);
    updateState(SCROLL_STATE_IDLE);

    final ItemClickSupport itemClick = ItemClickSupport.addTo(mRecyclerView);

    itemClick.setOnItemClickListener(
        new OnItemClickListener() {
          @Override
          public void onItemClick(RecyclerView parent, View child, int position, long id) {
            mToast.setText("Item clicked: " + position);
            mToast.show();
          }
        });

    itemClick.setOnItemLongClickListener(
        new OnItemLongClickListener() {
          @Override
          public boolean onItemLongClick(RecyclerView parent, View child, int position, long id) {
            mToast.setText("Item long pressed: " + position);
            mToast.show();
            return true;
          }
        });

    mRecyclerView.setOnScrollListener(
        new RecyclerView.OnScrollListener() {
          @Override
          public void onScrollStateChanged(int scrollState) {
            updateState(scrollState);
          }

          @Override
          public void onScrolled(int i, int i2) {
            mPositionText.setText("First: " + mRecyclerView.getFirstVisiblePosition());
            mCountText.setText("Count: " + mRecyclerView.getChildCount());
          }
        });

    final Drawable divider = getResources().getDrawable(R.drawable.divider);
    mRecyclerView.addItemDecoration(new DividerItemDecoration(divider));

    mRecyclerView.setAdapter(new SimpleAdapter(activity, mRecyclerView, mLayoutId));
  }
示例#3
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;
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    this.requestWindowFeature(Window.FEATURE_NO_TITLE);
    this.getWindow()
        .setFlags(
            WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

    setContentView(R.layout.activity_kairos);

    kairosApps = KairosAppLoader.instance().getKairosApps();

    appDeckAdapter = new AppAdapter(this, kairosApps);

    appDeckGridView = (TwoWayView) findViewById(R.id.appDeckGridView);
    appDeckGridView.setAdapter(appDeckAdapter);
    appDeckGridView.setOnItemClickListener(
        new AdapterView.OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            displayAppInfoFragment((int) id);
          }
        });

    contextImageView = (ImageView) findViewById(R.id.contextImageView);
    contextTextView = (TextView) findViewById(R.id.contextTextView);

    appInfoFrameLayout = (FrameLayout) findViewById(R.id.appInfoFrameLayout);

    navigationFragment = new NavigationFragment();
    getSupportFragmentManager()
        .beginTransaction()
        .add(R.id.navigationFrameLayout, navigationFragment)
        .commit();

    notificationFragment = new NotificationFragment();
    getSupportFragmentManager()
        .beginTransaction()
        .add(R.id.notificationFrameLayout, notificationFragment)
        .commit();

    TouchpadInputProvider.instance().requestInputControls(this);
    CarContextProvider.instance().requestDriverLoad(this);
    CarContextProvider.instance().requestCarStates(this);
  }