@Override
        public void onPageSelected(int position) {
          // TODO Auto-generated method stub
          mViewPager.setCurrentItem(position);
          selectTab(position);

          if (position == 0) {
            MainActivity mainActivity = (MainActivity) getActivity();
            mainActivity.resetMenuGesture();
          } else {
            MainActivity mainActivity = (MainActivity) getActivity();
            mainActivity.cancelMenuGesture();
          }
        }
Exemplo n.º 2
0
  // OnCreate running
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    MainActivity act = (MainActivity) this.getActivity();
    // toDo = act.getTasks();
    nThumbsIds = act.getTaskList();

    chosen = act.getToAdd();

    View rootView = inflater.inflate(R.layout.start_grid, container, false);

    super.onCreate(savedInstanceState);
    int iconSize = getResources().getDimensionPixelSize(android.R.dimen.app_icon_size);

    GridView gridview = (GridView) rootView.findViewById(R.id.taskgrid);
    gridview.setAdapter(new TaskAdapter(getActivity()));
    gridview.setOnItemClickListener(this);

    return rootView;
  }
Exemplo n.º 3
0
 /**
  * onClick
  *
  * <p>extracts the relai that was clicked, and asks the ipx to open then close the corresponding
  * relai
  */
 @Override
 public void onClick(View view) {
   Ipx800Control ipx = context.getIpx();
   if (view instanceof Button) {
     Button button = (Button) view;
     // Log.d(TAG, "hit the button " + button.getHint()+ "id = "+button.getId());
     try {
       int port2trigger = Integer.parseInt("" + button.getHint());
       // Log.d(TAG, "would trigger ipx out "+port2trigger);
       try {
         ipx.set(port2trigger, true);
         ipx.set(port2trigger, false);
       } catch (Exception e) {
         Toast.makeText(context, "error:" + e, Toast.LENGTH_LONG).show();
       }
     } catch (NumberFormatException e) {
       // ok, we hit a special button....
       if (button.getId() == R.id.servernameValue) context.callSettings();
       else if (button.getHint().equals("fill_me")) context.callSettings();
       // else Log.e(TAG,"unknown button code: "+button.getHint());
     }
   }
 }
Exemplo n.º 4
0
  Runner(final Group group, String router, String routerPrefix, final MainActivity mainActivity) {
    super(group, router, routerPrefix);
    // group, model, colors, audio observer are all set up now.
    this.mainActivity = mainActivity;
    gui = new Gui(mainActivity, group, model);
    String key = "com.tayek.tablet.sharedPreferencesKey";
    sharedPreferences = mainActivity.getSharedPreferences(key, Context.MODE_PRIVATE);
    // sharedPreferences.edit().clear().commit(); // only if we have to
    pl("router: " + router + ", prefix: " + routerPrefix);
    pl("preferences: " + sharedPreferences.getAll());
    ((AndroidPrefs) prefs)
        .setDelegate(
            new AndroidPrefs() {
              @Override
              public String get(String key) {
                return sharedPreferences.getString(key, "");
              }

              @Override
              public void put(String key, String value) {
                sharedPreferences.edit().putString(key, value).commit();
              }

              @Override
              public Map<String, ?> map() {
                return sharedPreferences.getAll();
              }

              @Override
              public String toString() {
                return sharedPreferences.getAll().toString();
              }
            });
    pl("prefs: " + prefs);
    // Exec.exec("settings put global captive_portal_detection_enabled 0 ");
    // loopSleep=10_000;
    // prefs.clear();
    // try clearing the prefs to see if it fixed the problem
    // that conrad found on sunday.
  }
Exemplo n.º 5
0
  @Override
  protected void loop(int n) {
    p("start runner loop " + mainActivity + ", group: " + group);
    if (heartbeatperiod != 0 && n % heartbeatperiod == 0)
      pl("android id: " + mainActivity.androidId + ", loop: " + n);

    super.loop(n);
    if (!isNetworkInterfaceUp) {
      new Thread(
              new Runnable() {
                @Override
                public void run() {
                  mainActivity.networkStuff.checkWifi();
                }
              },
              "checkwifi")
          .start();
    }
    mainActivity.runOnUiThread(
        new Runnable() {
          @Override
          public void run() {
            boolean isServerRunning = tablet != null && tablet.isServerRunning();
            gui.serverStatus.setBackgroundColor(
                Colors.aColor(isServerRunning ? Colors.green : Colors.red));
            gui.wifiStatus.setBackgroundColor(
                Colors.aColor(isNetworkInterfaceUp ? Colors.green : Colors.red));
            gui.routerStatus.setBackgroundColor(
                Colors.aColor(isRouterOk ? Colors.green : Colors.red));
            gui.singleStatus.setBackgroundColor(
                Colors.aColor(
                    isServerRunning && isNetworkInterfaceUp && isRouterOk
                        ? Colors.green
                        : Colors.red));
          }
        });
    p("end runner loop " + mainActivity);
  }
Exemplo n.º 6
0
 @Override
 public void buildGui(MessageReceiver.Model model) {
   pl("building gui.");
   final RelativeLayout relativeLayout = gui.builGui();
   gui.setStatusVisibility(
       gui.status[0].getVisibility() == View.VISIBLE ? View.INVISIBLE : View.VISIBLE);
   mainActivity.runOnUiThread(
       new Runnable() {
         @Override
         public void run() {
           mainActivity.setContentView(relativeLayout);
         }
       });
   hasATablet = gui;
   model.addObserver(gui);
   p("building gui adapter.");
   guiAdapterABC = gui.buildGuiAdapter();
   gui.guiAdapterABC = guiAdapterABC;
   hasATablet.setTablet(null);
   guiAdapterABC.setTablet(null);
   p("gui adapter: " + guiAdapterABC);
   p("gui built.");
 }