public void onObjectUpdated() {
    Log.i(TAG, "Object " + m_id + " updated");

    View rootView = getView();
    if (rootView != null) {
      ViewSwitcher sw = (ViewSwitcher) getView().findViewById(R.id.switcher);
      if (m_child != null) {
        if (sw.getCurrentView().getId() != R.id.objectDisplayFragment) sw.showNext();

        // Notify the child
        m_child.objectUpdated(m_object);
        return;
      }

      // Construct the child fragment
      ObjectFragment frag = null;
      if (m_object == null) {
        frag = new NullObjectFragment();
      } else if ("person".equals(m_object.optString("objectType"))) {
        frag = new PersonObjectFragment();
      } else {
        frag = new StandardObjectFragment();
      }

      FragmentManager mgr = getChildFragmentManager();
      m_child = ObjectFragment.prepare(frag, m_id, m_intId);

      mgr.beginTransaction().add(R.id.objectDisplayFragment, m_child).commit();

      sw.showNext();
    } else {
      // Nothing to do - our UI hasn't yet been created
      // We will update when we have a child
    }
  }
Esempio n. 2
0
  public static void startLocalActivity(
      final ActivityGroup activityGroup,
      final Intent intent,
      final String identifier,
      final int regionId,
      final int anim) {
    final LocalActivityManager activityManager = activityGroup.getLocalActivityManager();
    final View paneView = activityManager.startActivity(identifier, intent).getDecorView();

    final ViewParent parent = paneView.getParent();
    if ((parent != null) && (parent instanceof ViewGroup)) {
      throw new IllegalStateException("should not happen - currently we don't recycle activities");
    }

    final ViewGroup region = (ViewGroup) activityGroup.findViewById(regionId);
    if ((anim != ANIM_NONE) && (region instanceof ViewSwitcher)) {
      final ViewSwitcher animator = (ViewSwitcher) region;

      if (anim == ANIM_NEXT) {
        animator.setInAnimation(activityGroup, R.anim.sl_next_in);
        animator.setOutAnimation(activityGroup, R.anim.sl_next_out);
      } else {
        animator.setInAnimation(activityGroup, R.anim.sl_previous_in);
        animator.setOutAnimation(activityGroup, R.anim.sl_previous_out);
      }

      final int numChilds = animator.getChildCount();
      if (numChilds == 0) {
        animator.addView(
            paneView,
            0,
            new ViewGroup.LayoutParams(
                ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));
      } else if (numChilds == 1) {
        animator.addView(
            paneView,
            1,
            new ViewGroup.LayoutParams(
                ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));
        animator.showNext();
      } else {
        animator.removeViewAt(0);
        animator.addView(
            paneView,
            1,
            new ViewGroup.LayoutParams(
                ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));
        animator.showNext();
      }
    } else {
      region.removeAllViews();
      region.addView(
          paneView,
          new ViewGroup.LayoutParams(
              ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));
    }
  }
  private void displayResults() {
    if (passwordList.isEmpty()) {
      root.findViewById(R.id.loading_spinner).setVisibility(View.GONE);
      messages.setText(R.string.msg_errnomatches);
    } else {
      final ListView list = (ListView) root.findViewById(R.id.list_keys);
      list.setOnItemClickListener(
          new OnItemClickListener() {
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
              final String key = ((TextView) view).getText().toString();
              Toast.makeText(getActivity(), getString(R.string.msg_copied, key), Toast.LENGTH_SHORT)
                  .show();
              ClipboardManager clipboard =
                  (ClipboardManager) getActivity().getSystemService(Context.CLIPBOARD_SERVICE);

              clipboard.setText(key);
              startActivity(new Intent(Settings.ACTION_WIFI_SETTINGS));
            }
          });
      list.setAdapter(
          new ArrayAdapter<String>(
              getActivity(), android.R.layout.simple_list_item_1, passwordList));
      root.showNext();
    }
  }
Esempio n. 4
0
 void searchModeOn() {
   if (!mTopBarIsSearch) {
     mTopBarIsSearch = true;
     // Focus on EditTextWidget
     mSearchText.requestFocus();
     showKeyboard();
     mTopBarSwitcher.showNext();
   }
 }
Esempio n. 5
0
  // Handle button clicks
  public void onClick(View v) {
    switch (v.getId()) {
      case R.id.SwitchToDate:
        v.setEnabled(false);
        findViewById(R.id.SwitchToTime).setEnabled(true);
        viewSwitcher.showPrevious();
        break;

      case R.id.SwitchToTime:
        v.setEnabled(false);
        findViewById(R.id.SwitchToDate).setEnabled(true);
        viewSwitcher.showNext();
        break;
    }
  }
  /** I did it clicked. */
  private void didIt() {
    if (!mActionComplete) {
      mActionComplete = true;
      mTickSwitcher.showNext();
      Intent completeAction = new Intent(this, CompleteActionService.class);
      completeAction.putExtra(CompleteActionService.ACTION_KEY, mAction.getMappingId());
      startService(completeAction);

      // Finish the activity after one second
      new Handler()
          .postDelayed(
              new Runnable() {
                @Override
                public void run() {
                  finish();
                }
              },
              1000);
    }
  }
Esempio n. 7
0
  private void updateMainList(List<AppInfo> apps) {

    if (apps != null) {

      if (apps.size() > 0) {
        footer.setVisibility(View.VISIBLE);

        String autosyncSet = Preferences.getAutosyncSet(Main.this, accountname);
        if (autosyncSet == null) {

          // set autosync default value
          AutosyncHandlerFactory.getInstance(Main.this)
              .setAutosyncPeriod(accountname, AutosyncHandler.DEFAULT_PERIOD);

          Preferences.saveAutosyncSet(Main.this, accountname);
        }
      }

      adapter.setAppInfos(apps);
      adapter.notifyDataSetChanged();

      Date lastUpdateDate = null;

      for (int i = 0; i < apps.size(); i++) {
        Date dateObject = apps.get(i).getLastUpdate();
        if (lastUpdateDate == null || lastUpdateDate.before(dateObject)) {
          lastUpdateDate = dateObject;
        }
      }

      if (lastUpdateDate != null) {
        statusText.setText("last update: " + ContentAdapter.formatDate(lastUpdateDate));
      }
    }

    if (!(R.id.main_app_list == mainViewSwitcher.getCurrentView().getId())) {
      mainViewSwitcher.showNext();
    }
  }
Esempio n. 8
0
  @Override
  public View onCreateView(
      LayoutInflater inflater, final ViewGroup container, Bundle savedInstanceState) {
    ViewPager viewPager = (ViewPager) container;

    final ViewSwitcher viewSwitcher = new ViewSwitcher(container.getContext());

    questionView =
        new QuestionView(container.getContext(), stepInfo, viewPager) {

          @Override
          protected void onCorrectAnswer() {
            stepInfo.setRevealed(true);
            viewSwitcher.showNext();
          }

          protected void onIncorrectAnswer() {
            stepInfo.setRevealed(true);
            stepInfo.setMistake(true);
            knotStepView.hideAnswer();
            viewSwitcher.showNext();
          }
        };

    knotStepView = new KnotStepView(container.getContext(), stepInfo, viewPager);

    viewSwitcher.addView(questionView);
    viewSwitcher.addView(knotStepView);

    viewSwitcher.setInAnimation(container.getContext(), android.R.anim.fade_in);
    viewSwitcher.setOutAnimation(container.getContext(), android.R.anim.fade_out);

    if (stepInfo.isRevealed()) {
      viewSwitcher.showNext();
    }

    return viewSwitcher;
  }
Esempio n. 9
0
  public void playHymne(View view) {
    long absTime = 0, duration = 0, msec = 0;
    if (myCountry > 0) {
      mViewSwitcher.showNext();

      if (mSharedPreferences.getBoolean(AUTO_PLAY, false)) {
        mMediaPlayer = MediaPlayer.create(mContext, sounds.getResourceId(myCountry, 0));
        if (mMediaPlayer != null) {
          mMediaPlayer.setLooping(true);
          duration = mMediaPlayer.getDuration();
          if (mSharedPreferences.getBoolean(SYNCHRO, false)) {
            sysTime = System.currentTimeMillis();
            if (ntpDelta != 0) absTime = sysTime + ntpDelta;
            else if (gpsDelta != 0) absTime = sysTime + gpsDelta;
            else absTime = sysTime;
            msec = absTime % duration;
            mMediaPlayer.seekTo((int) msec);
          }
          mMediaPlayer.start();
        }
        Toast.makeText(mContext, R.string.message_flag, Toast.LENGTH_SHORT).show();
      }

      StringBuilder stat = new StringBuilder();
      stat.append(sysTime)
          .append("|")
          .append(gpsTime)
          .append("|")
          .append(gpsDelta)
          .append("|")
          .append(ntpTime)
          .append("|")
          .append(ntpDelta)
          .append("|")
          .append(absTime);
      stat.append("|").append(myCountry).append("|").append(duration).append("|").append(msec);
      stat.append("|")
          .append(System.getProperty("os.name"))
          .append("|")
          .append(System.getProperty("os.version"))
          .append("|")
          .append(System.getProperty("os.arch"))
          .append("|")
          .append(System.getProperty("user.region"))
          .append("|")
          .append(System.getProperty("http.agent"));
      stat.append("|")
          .append(Build.BOARD)
          .append("|")
          .append(Build.BOOTLOADER)
          .append("|")
          .append(Build.BRAND)
          .append("|")
          .append(Build.CPU_ABI)
          .append("|")
          .append(Build.CPU_ABI2)
          .append("|")
          .append(Build.DEVICE)
          .append("|")
          .append(Build.DISPLAY)
          .append("|")
          .append(Build.FINGERPRINT)
          .append("|")
          .append(Build.HARDWARE)
          .append("|")
          .append(Build.HOST)
          .append("|")
          .append(Build.ID)
          .append("|")
          .append(Build.MANUFACTURER)
          .append("|")
          .append(Build.MODEL)
          .append("|")
          .append(Build.PRODUCT)
          .append("|")
          .append(Build.RADIO)
          .append("|")
          .append(Build.SERIAL)
          .append("|")
          .append(Build.TAGS)
          .append("|")
          .append(Build.TIME)
          .append("|")
          .append(Build.TYPE)
          .append("|")
          .append(Build.UNKNOWN)
          .append("|")
          .append(Build.USER);
      try {
        stat.append("|")
            .append(getPackageManager().getPackageInfo(getPackageName(), 0).versionName);
      } catch (NameNotFoundException e) {
        e.printStackTrace();
        stat.append("|NA");
      }

      Log.d(TAG, "stat : " + stat);
      postStat("http://kiof.free.fr/stats.php?", stat.toString());
    }
  }
Esempio n. 10
0
 @OnClick(R.id.login_change_to_register)
 void showRegister() {
   viewSwitcher.showNext();
 }
 @Override
 public void openSearchUI() {
   // Give search view focus, because it needs to handle back key event.
   mViewSwitcher.showNext();
 }
Esempio n. 12
0
  protected void showLoadingIndicator(ViewSwitcher switcher) {
    Animation loadingAnim = AnimationUtils.loadAnimation(this, R.anim.loading);
    loadingAnim.setInterpolator(new LinearInterpolator());

    switcher.showNext();
  }