예제 #1
0
  public void showDigitalRead(DigitalValue newValue) {
    this.digitalValue = newValue;
    ViewGroup parent = (ViewGroup) view.getParent();
    if (digitalReadView == null) {
      digitalReadView = Ui.findView(parent, R.id.tinker_digital_write_main);
    }

    // If the view does not exist, inflate it
    if (digitalReadView == null) {
      LayoutInflater inflater =
          (LayoutInflater) view.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
      digitalReadView = inflater.inflate(R.layout.tinker_digital_read, parent, false);
      if (pinType == PinType.A) {
        parent.addView(digitalReadView);
      } else if (pinType == PinType.D) {
        parent.addView(digitalReadView, 0);
      }
    }

    digitalReadView.setVisibility(View.VISIBLE);
    final TextView value = Ui.findView(digitalReadView, R.id.tinker_digital_read_value);
    value.setText(newValue.name());
    // fade(value, newValue);
    updatePinColor();
    if (!stopAnimating()) {
      getCancelAnimator().start();
    }
  }
예제 #2
0
  /**
   * Try to find a MenuItemActionBar/MenuItemDefault with the given text set as contentDescription /
   * text.
   *
   * <p>When using legacy menus, make sure the menu has been opened to the appropriate level (i.e.
   * base menu or "More" menu) to ensure the appropriate menu views are in memory. TODO: ^ Maybe we
   * just need to have opened the "More" menu and the current one doesn't matter.
   *
   * <p>This method is dependent on not having two views with equivalent contentDescription / text.
   */
  private View findAppMenuItemView(String text) {
    mSolo.waitForText(text, 1, MAX_WAITTIME_FOR_MENU_UPDATE_IN_MS);

    final List<View> views = mSolo.getViews();

    final List<MenuItemActionBar> menuItemActionBarList =
        RobotiumUtils.filterViews(MenuItemActionBar.class, views);
    for (MenuItemActionBar menuItem : menuItemActionBarList) {
      if (TextUtils.equals(menuItem.getContentDescription(), text)) {
        return menuItem;
      }
    }

    final List<MenuItemDefault> menuItemDefaultList =
        RobotiumUtils.filterViews(MenuItemDefault.class, views);
    for (MenuItemDefault menuItem : menuItemDefaultList) {
      if (TextUtils.equals(menuItem.getText(), text)) {
        return menuItem;
      }
    }

    // On Android 2.3, menu items may be instances of
    // com.android.internal.view.menu.ListMenuItemView, each with a child
    // android.widget.RelativeLayout which in turn has a child
    // TextView with the appropriate text.
    final List<TextView> textViewList = RobotiumUtils.filterViews(TextView.class, views);
    for (TextView textView : textViewList) {
      if (TextUtils.equals(textView.getText(), text)) {
        View relativeLayout = (View) textView.getParent();
        View listMenuItemView = (View) relativeLayout.getParent();
        return listMenuItemView;
      }
    }
    return null;
  }
예제 #3
0
  private void doShowAnalogValue(int newValue) {
    if (analogWriteView != null) {
      analogWriteView.setVisibility(View.GONE);
      analogWriteView = null;
    }

    ViewGroup parent = (ViewGroup) view.getParent();

    if (pinBackgroundAnim != null) {
      pinBackgroundAnim.cancel();
    }

    if (analogReadView == null) {
      analogReadView = Ui.findView(parent, R.id.tinker_analog_read_main);
    }

    // If the view does not exist, inflate it
    if (analogReadView == null) {
      LayoutInflater inflater =
          (LayoutInflater) view.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);

      if (pinType == PinType.A) {
        analogReadView = inflater.inflate(R.layout.tinker_analog_read_left, parent, false);
        parent.addView(analogReadView);
      } else if (pinType == PinType.D) {
        analogReadView = inflater.inflate(R.layout.tinker_analog_read_right, parent, false);
        parent.addView(analogReadView, 0);
      } else if (pinType == PinType.T) {
        analogReadView = inflater.inflate(R.layout.tinker_analog_read_right, parent, false);
        parent.addView(analogReadView, 0);
      }
    }

    analogReadView.setVisibility(View.VISIBLE);
    // Find the existing views and set the values
    ProgressBar barGraph = Ui.findView(analogReadView, R.id.tinker_analog_read_progress);
    TextView readValue = Ui.findView(analogReadView, R.id.tinker_analog_read_value);

    if (PinAction.ANALOG_READ.equals(configuredAction)) {
      barGraph.setProgressDrawable(
          view.getContext().getResources().getDrawable(R.drawable.progress_emerald));
    } else {
      barGraph.setProgressDrawable(
          view.getContext().getResources().getDrawable(R.drawable.progress_sunflower));
    }

    int max = 1;
    if (configuredAction == PinAction.ANALOG_READ) {
      max = ANALOG_READ_MAX;
    } else if (configuredAction == PinAction.ANALOG_WRITE) {
      max = ANALOG_WRITE_MAX;
    }

    barGraph.setMax(max);
    barGraph.setProgress(newValue);
    readValue.setText(String.valueOf(newValue));
  }
예제 #4
0
파일: PVOFragment.java 프로젝트: jankit/pvo
 /** onclick of selected item text view remove from list and add into not selected item list * */
 public void clickOnTextView(TextView tv) {
   counter--;
   LinearLayout parentll = (LinearLayout) tv.getParent();
   parentll.removeView(tv);
   notSelectedItemList.add((String) tv.getText());
   selectedItemList.remove(tv.getText());
   Collections.sort(notSelectedItemList);
   adapter.notifyDataSetChanged();
 }
예제 #5
0
  public void showAnalogWrite(final OnAnalogWriteListener listener) {
    if (analogReadView != null) {
      analogReadView.setVisibility(View.GONE);
      analogReadView = null;
    }

    final ViewGroup parent = (ViewGroup) view.getParent();
    if (analogWriteView == null) {
      analogWriteView = Ui.findView(parent, R.id.tinker_analog_write_main);
    }

    // If the view does not exist, inflate it
    if (analogWriteView == null) {
      LayoutInflater inflater =
          (LayoutInflater) view.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);

      if (pinType == PinType.A) {
        analogWriteView = inflater.inflate(R.layout.tinker_analog_write_left, parent, false);
        parent.addView(analogWriteView);
      } else if (pinType == PinType.D) {
        analogWriteView = inflater.inflate(R.layout.tinker_analog_write_right, parent, false);
        parent.addView(analogWriteView, 0);
      }
    }

    analogWriteView.setVisibility(View.VISIBLE);
    final SeekBar seekBar = Ui.findView(analogWriteView, R.id.tinker_analog_write_seekbar);
    final TextView valueText = Ui.findView(analogWriteView, R.id.tinker_analog_write_value);
    if (pinBackgroundAnim != null) {
      pinBackgroundAnim.cancel();
      pinBackgroundAnim = null;
    }
    parent.setBackgroundColor(0x4C000000);

    seekBar.setOnSeekBarChangeListener(
        new OnSeekBarChangeListener() {

          @Override
          public void onStopTrackingTouch(SeekBar seekBar) {
            int value = seekBar.getProgress();
            parent.setBackgroundColor(0);
            showAnalogWriteValue();
            listener.onAnalogWrite(value);
          }

          @Override
          public void onStartTrackingTouch(SeekBar seekBar) {}

          @Override
          public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            valueText.setText(String.valueOf(progress));
          }
        });
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_view_post_screen);
    android.support.v7.app.ActionBar title_Bar = getSupportActionBar();
    assert getSupportActionBar() != null;
    title_Bar.setTitle("View Post");

    viewing_post = Dynamo_Interface.getSelected_post();
    CheckBox check_details = (CheckBox) findViewById(R.id.ckbDetails);
    final ScrollView detail_view = (ScrollView) findViewById(R.id.scvDetails);
    check_details.setOnCheckedChangeListener(
        new CompoundButton.OnCheckedChangeListener() {

          @Override
          public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            if (buttonView.isChecked()) {
              detail_view.setVisibility(View.VISIBLE);
            } else {
              detail_view.setVisibility(View.INVISIBLE);
            }
          }
        });
    TextView host_name = (TextView) findViewById(R.id.lblHost);
    TextView post_details = (TextView) findViewById(R.id.txvDetails);
    TextView email = (TextView) findViewById(R.id.txtEmail);
    TextView phone = (TextView) findViewById(R.id.txtPhone);
    TextView address = (TextView) findViewById(R.id.txtAddress);
    host_name.setText(viewing_post.getHost());
    email.setText(viewing_post.getEmail());
    phone.setText(Long.toString(viewing_post.getPhone()));
    address.setText(viewing_post.getAddress());
    // handle html
    WebView web_viewer = (WebView) findViewById(R.id.wbvWeb);
    String stripped = viewing_post.getInformation().replaceAll("<(.|\n)*?>", "");
    if (stripped.equals(viewing_post.getInformation())) {
      post_details.setText(viewing_post.getInformation());
      post_details.setMovementMethod(new ScrollingMovementMethod());
      ((ViewGroup) web_viewer.getParent()).removeView(web_viewer);
    } else {
      web_viewer.loadData(viewing_post.getInformation(), "text/html", null);
      ((ViewGroup) post_details.getParent()).removeView(post_details);
    }
  }
예제 #7
0
    public View getView(int position, View convertView, ViewGroup parent) {
      if (convertView == null) {
        convertView = mInflater.inflate(ITEM_LAYOUT, parent, false);
      }

      TextView title = (TextView) convertView.findViewById(R.id.title);
      RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) title.getLayoutParams();
      params.width = RelativeLayout.LayoutParams.WRAP_CONTENT;
      title.setLayoutParams(params);
      RelativeLayout layout = (RelativeLayout) title.getParent();
      layout.setHorizontalGravity(getLayoutGravity());

      MenuView.ItemView itemView = (MenuView.ItemView) convertView;
      if (mForceShowIcon) {
        ((ListMenuItemView) convertView).setForceShowIcon(true);
      }
      itemView.initialize(getItem(position), 0);
      return convertView;
    }
예제 #8
0
 public void reset() {
   if (analogReadView != null) {
     analogReadView.setVisibility(View.GONE);
     // Reset the values
     ProgressBar barGraph = Ui.findView(analogReadView, R.id.tinker_analog_read_progress);
     TextView readValue = Ui.findView(analogReadView, R.id.tinker_analog_read_value);
     barGraph.setMax(100);
     barGraph.setProgress(0);
     readValue.setText("0");
     analogReadView = null;
   }
   if (analogWriteView != null) {
     // Reset the values
     analogWriteView.setVisibility(View.GONE);
     final SeekBar seekBar = Ui.findView(analogWriteView, R.id.tinker_analog_write_seekbar);
     final TextView value = Ui.findView(analogWriteView, R.id.tinker_analog_write_value);
     seekBar.setProgress(0);
     value.setText("0");
     analogWriteView = null;
   }
   if (digitalWriteView != null) {
     digitalWriteView.setVisibility(View.GONE);
     digitalWriteView = null;
   }
   if (digitalReadView != null) {
     digitalReadView.setVisibility(View.GONE);
     digitalReadView = null;
   }
   if (toggleActivationView != null) {
     toggleActivationView.setVisibility(View.GONE);
     toggleActivationView = null;
   }
   if (!stopAnimating()) {
     ((View) view.getParent()).setBackgroundColor(0);
   }
   muted = false;
   analogValue = 0;
   digitalValue = DigitalValue.NONE;
 }
예제 #9
0
  public void expandOrContractTextView(View view) {
    TextView textView = (TextView) view;

    RelativeLayout relativeLayout = (RelativeLayout) textView.getParent();
    ImageButton expandOrContract = (ImageButton) relativeLayout.getChildAt(1);
    Drawable expandImage = getResources().getDrawable(R.drawable.ic_expand_more_black);
    Drawable contractImage = getResources().getDrawable(R.drawable.ic_expand_less_black);

    // Use Icons to RepresentState
    if (expandOrContract
        .getTag()
        .toString()
        .equals(getResources().getString(R.string.expand))) { // if Expand, then contract
      expandOrContract.setImageDrawable(contractImage);
      expandOrContract.setTag(getResources().getString(R.string.contract));
      if (expandOrContract.getId() == R.id.settings_general_image_button) {
        RelativeLayout layout = (RelativeLayout) findViewById(R.id.settings_general_views_layout);
        layout.setVisibility(View.VISIBLE);
      } else if (expandOrContract.getId() == R.id.settings_synchronisation_image_button) {
        RelativeLayout layout = (RelativeLayout) findViewById(R.id.settings_synchronisation_views);
        layout.setVisibility(View.VISIBLE);
      }

    } else {
      expandOrContract.setImageDrawable(expandImage);
      expandOrContract.setTag(getResources().getString(R.string.expand));

      if (expandOrContract.getId() == R.id.settings_general_image_button) {
        RelativeLayout layout = (RelativeLayout) findViewById(R.id.settings_general_views_layout);

        layout.setVisibility(View.GONE);
      } else if (expandOrContract.getId() == R.id.settings_synchronisation_image_button) {
        RelativeLayout layout = (RelativeLayout) findViewById(R.id.settings_synchronisation_views);

        layout.setVisibility(View.GONE);
      }
    }
  }
예제 #10
0
  private void hideExtraViews() {
    if (toggleActivationView != null) {
      toggleActivationView.setVisibility(View.GONE);
    }
    if (analogReadView != null) {
      analogReadView.setVisibility(View.GONE);
    }
    if (analogWriteView != null) {
      analogWriteView.setVisibility(View.GONE);
    }
    if (digitalWriteView != null) {
      digitalWriteView.setVisibility(View.GONE);
    }
    if (digitalReadView != null) {
      digitalReadView.setVisibility(View.GONE);
    }

    if (pinBackgroundAnim != null) {
      pinBackgroundAnim.end();
    }
    View parent = (View) view.getParent();
    parent.setBackgroundColor(0);
  }
예제 #11
0
  Animator getCancelAnimator() {
    ObjectAnimator backToTransparent1 =
        (ObjectAnimator)
            AnimatorInflater.loadAnimator(view.getContext(), R.animator.pin_background_end);
    ObjectAnimator goDark =
        (ObjectAnimator)
            AnimatorInflater.loadAnimator(view.getContext(), R.animator.pin_background_go_dark);
    ObjectAnimator backToTransparent2 =
        (ObjectAnimator)
            AnimatorInflater.loadAnimator(view.getContext(), R.animator.pin_background_end);

    ViewGroup parent = (ViewGroup) view.getParent();
    ArgbEvaluator evaluator = new ArgbEvaluator();
    for (ObjectAnimator animator : list(backToTransparent1, goDark, backToTransparent2)) {
      animator.setTarget(parent);
      animator.setEvaluator(evaluator);
    }

    AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.setTarget(parent);
    animatorSet.playSequentially(backToTransparent1, goDark, backToTransparent2);
    return animatorSet;
  }
예제 #12
0
  public void animateYourself() {
    final ViewGroup parent = (ViewGroup) view.getParent();

    if (pinBackgroundAnim != null) {
      pinBackgroundAnim.end();
      pinBackgroundAnim = null;
    }

    pinBackgroundAnim =
        (ObjectAnimator)
            AnimatorInflater.loadAnimator(view.getContext(), R.animator.pin_background_start);

    pinBackgroundAnim.setTarget(parent);
    pinBackgroundAnim.setEvaluator(new ArgbEvaluator());
    pinBackgroundAnim.addListener(
        new AnimatorListener() {

          @Override
          public void onAnimationStart(Animator animation) {
            // NO OP
          }

          @Override
          public void onAnimationRepeat(Animator animation) {}

          @Override
          public void onAnimationEnd(Animator animation) {}

          @Override
          public void onAnimationCancel(Animator animation) {
            endAnimation = getCancelAnimator();
            endAnimation.start();
          }
        });
    pinBackgroundAnim.start();
  }
  private void createListener(final TextView txtView, final TextView txtViewSummary) {

    // Get our relative layout parent view first and set the listener
    View v = (View) txtView.getParent();

    // Show the actual profile;
    v.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {

            final SharedPreferences AeroProfile =
                mContext.getSharedPreferences(txtView.getText().toString(), Context.MODE_PRIVATE);
            TextView profileText = new TextView(mContext);
            String content = "";
            String tmp;

            // Get all our preferences;
            final Map<String, ?> allKeys = AeroProfile.getAll();

            for (Map.Entry<String, ?> entry : allKeys.entrySet()) {

              tmp = entry.getKey();

              // ToDo: For better looking, simplify this!
              if (tmp.contains("/sys/devices/system/cpu/cpufreq/"))
                tmp = tmp.replace("/sys/devices/system/cpu/cpufreq/", "");
              else if (tmp.contains("/proc/sys/vm/")) tmp = tmp.replace("/proc/sys/vm/", "");
              else if (tmp.contains("/sys/module/msm_kgsl_core/parameters/"))
                tmp = tmp.replace("/sys/module/msm_kgsl_core/parameters/", "gpu -> ");
              else if (tmp.contains("/sys/kernel/hotplug_control/"))
                tmp = tmp.replace("/sys/kernel/hotplug_control/", "hotplug_control -> ");
              else if (tmp.contains("/sys/devices/virtual/timed_output/vibrator/"))
                tmp = tmp.replace("/sys/devices/virtual/timed_output/vibrator/", "vibrator -> ");
              else if (tmp.contains("/sys/module/msm_thermal/parameters/"))
                tmp = tmp.replace("/sys/module/msm_thermal/parameters/", "thermal_control -> ");
              else if (tmp.contains("/sys/devices/fdb00000.qcom,kgsl-3d0/kgsl/kgsl-3d0/devfreq/"))
                tmp = tmp.replace("/sys/devices/fdb00000.qcom,kgsl-3d0/kgsl/kgsl-3d0/devfreq/", "");
              else if (tmp.contains("/sys/class/misc/soundcontrol/"))
                tmp = tmp.replace("/sys/class/misc/soundcontrol/", "");
              else if (tmp.contains("/sys/class/misc/mako_hotplug_control/"))
                tmp = tmp.replace("/sys/class/misc/mako_hotplug_control/", "hotplug_control -> ");
              else if (tmp.contains("/sys/module/cpu_boost/parameters"))
                tmp = tmp.replace("/sys/module/cpu_boost/parameters", "cpu_boostl -> ");

              content = tmp + " = " + entry.getValue().toString() + "\n" + content;

              profileText.setText(content);
            }

            profileText.setVerticalScrollBarEnabled(true);
            profileText.setMovementMethod(new ScrollingMovementMethod());
            profileText.setPadding(20, 20, 20, 20);
            profileText.setTypeface(FilePath.kitkatFont);

            AlertDialog dialog =
                new AlertDialog.Builder(mContext)
                    .setTitle(
                        getText(R.string.slider_overview) + ": " + txtView.getText().toString())
                    .setView(profileText)
                    .setIcon(R.drawable.profile)
                    .setPositiveButton(
                        R.string.apply,
                        new DialogInterface.OnClickListener() {
                          @Override
                          public void onClick(DialogInterface dialog, int which) {

                            mPrefs =
                                mContext.getSharedPreferences(
                                    "com.aero.control_preferences", Context.MODE_PRIVATE);
                            deleteProfile("com.aero.control_preferences");
                            SharedPreferences AeroProfile =
                                mContext.getSharedPreferences(
                                    txtView.getText().toString(), Context.MODE_PRIVATE);
                            applyProfile(AeroProfile);
                            settings.setSettings(mContext, null, false);
                          }
                        })
                    .setNeutralButton(
                        R.string.pref_profile_export,
                        new DialogInterface.OnClickListener() {
                          @Override
                          public void onClick(DialogInterface dialogInterface, int i) {

                            String dir = FilePath.EXTERNAL_PATH + "/com.aero.control/profiles";
                            String title = txtView.getText().toString() + ".xml";

                            if (!(AeroActivity.genHelper.doesExist(dir)))
                              if (!(new File(dir).mkdirs()))
                                Log.e(LOG_TAG, "Couldn't create path: " + dir);

                            try {
                              AeroActivity.genHelper.copyFile(
                                  AeroActivity.genHelper.getNewFile(
                                      FilePath.sharedPrefsPath + title),
                                  AeroActivity.genHelper.getNewFile(dir + "/" + title));
                            } catch (IOException e) {
                              Log.e(
                                  LOG_TAG,
                                  "Couldn't copy file: " + FilePath.sharedPrefsPath + title,
                                  e);
                            }

                            if (AeroActivity.genHelper.doesExist(dir + "/" + title))
                              Toast.makeText(mContext, R.string.successful, Toast.LENGTH_SHORT)
                                  .show();
                          }
                        })
                    .create();
            dialog.show();
          }
        });

    // Change the name of the profile;
    v.setOnLongClickListener(
        new View.OnLongClickListener() {
          @Override
          public boolean onLongClick(View view) {

            mCompleteProfiles = AeroActivity.shell.getDirInfo(FilePath.sharedPrefsPath, true);
            final EditText editText = new EditText(mContext);
            final CharSequence oldName = txtView.getText();
            editText.setText(oldName);

            AlertDialog dialog =
                new AlertDialog.Builder(mContext)
                    .setTitle(R.string.pref_profile_change_name)
                    .setMessage(R.string.pref_profile_change_name_sum)
                    .setView(editText)
                    .setPositiveButton(
                        R.string.save,
                        new DialogInterface.OnClickListener() {
                          @Override
                          public void onClick(DialogInterface dialog, int which) {

                            String newName = editText.getText().toString();
                            String allProfiles = Arrays.asList(mCompleteProfiles).toString();

                            if (allProfiles.contains(newName + ".xml")) {
                              Toast.makeText(
                                      mContext,
                                      R.string.pref_profile_name_exists,
                                      Toast.LENGTH_LONG)
                                  .show();
                            } else {
                              txtView.setText(newName);
                              renameProfile(oldName, newName, txtView, txtViewSummary);
                            }
                          }
                        })
                    .create();
            dialog.show();

            return true;
          }
        });
  }
예제 #14
0
 @Override
 public void handle(
     String tag,
     String result,
     String url,
     HashMap<String, Object> params,
     ArrayList<String> files) {
   if (dialog.isShowing()) {
     Button buttonok = dialog.getButton(DialogInterface.BUTTON_POSITIVE);
     buttonok.setText("Submit");
     buttonok.setEnabled(true);
     dialog.getButton(DialogInterface.BUTTON_NEGATIVE).setVisibility(View.VISIBLE);
   }
   if (result == null) {
     Toast.makeText(this, "Unexpected error", Toast.LENGTH_SHORT).show();
     return;
   }
   if (tag.equals("list"))
     try {
       JSONObject json = new JSONObject(result);
       if (json.getInt("success") == 1) {
         list.removeAllViews();
         if (json.isNull("post")) {
           Toast.makeText(this, "No transaction history record found", Toast.LENGTH_SHORT).show();
           return;
         } else {
           JSONObject data = json.getJSONObject("post");
           double balance = data.getDouble("accountBalance");
           tvbalance.setText(String.valueOf(balance));
           JSONArray array = data.getJSONArray("accountHistory");
           Shared.shortdate.setTimeZone(TimeZone.getTimeZone("UTC"));
           for (int i = 0; i < array.length(); i++) {
             TableRow row = (TableRow) getLayoutInflater().inflate(R.layout.accountitem, null);
             row.setBackgroundColor(Color.LTGRAY);
             TextView tvdate = (TextView) row.findViewById(R.id.accountrowdate);
             TextView tvjob = (TextView) row.findViewById(R.id.accountrowjob);
             TextView tvcredit = (TextView) row.findViewById(R.id.accountrowcredit);
             TextView tvdebit = (TextView) row.findViewById(R.id.accountrowdebit);
             int brgt = 255 - (i % 2 == 0 ? 20 : 0);
             int color = Color.rgb(brgt, brgt, brgt);
             tvdate.setBackgroundColor(color);
             tvjob.setBackgroundColor(color);
             ((View) tvjob.getParent()).setBackgroundColor(color);
             tvcredit.setBackgroundColor(color);
             tvdebit.setBackgroundColor(color);
             JSONObject obj = array.getJSONObject(i);
             Date date = Shared.sqltime.parse(obj.getString("created_at"));
             tvdate.setText(Shared.shortdate.format(date));
             Double amount = 0.0;
             if (amount == 0) amount = obj.getDouble("credit_amount");
             if (amount == 0) amount = obj.getDouble("debit_amount") * -1;
             tvjob.setText(obj.isNull("addrfrom") ? "Payment Request" : obj.getString("addrfrom"));
             TextView ctordt = amount > 0 ? tvcredit : tvdebit;
             DecimalFormat cur = new DecimalFormat("'$'0.00");
             ctordt.setText(cur.format(Math.abs(amount)));
             list.addView(row);
           }
         }
       }
     } catch (JSONException ex) {
       Toast.makeText(this, "Unexpected result", Toast.LENGTH_SHORT).show();
     } catch (ParseException ex) {
       Toast.makeText(this, "Unexpected result", Toast.LENGTH_SHORT).show();
     }
   Shared.shortdate.setTimeZone(TimeZone.getDefault());
   if (tag.equals("request"))
     try {
       JSONObject json = new JSONObject(result);
       if (json.getInt("success") == 1) {
         Toast.makeText(
                 this, "Congratulation. Your payment request was succesful", Toast.LENGTH_SHORT)
             .show();
         dialog.dismiss();
       } else {
         String msg = json.getString("message");
         Toast.makeText(this, msg, Toast.LENGTH_SHORT).show();
       }
     } catch (JSONException ex) {
       Toast.makeText(this, "Unexpected result", Toast.LENGTH_SHORT).show();
     }
 }
예제 #15
0
  /**
   * Called when the activity is first created. Sets up the view.
   *
   * @param savedInstanceState Um I don't even know. Read the Android documentation.
   */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    String TAG = StaticBlob.TAG();
    if (android.os.Build.VERSION.SDK_INT >= 11) setTheme(R.style.Default_New);
    // General create stuff
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
    Log.v(TAG, "Launching Activity");
    mainListView = new ListView(this);
    Callisto.build_layout(this, mainListView);

    // Get the settings for this show
    currentShow = getIntent().getExtras().getString("current_show");
    currentShowAudio = getIntent().getExtras().getString("current_show_audio");
    currentShowVideo = getIntent().getExtras().getString("current_show_video");
    showSettings = getSharedPreferences(currentShow, 0);
    filter = showSettings.getBoolean("filter", false);
    loading = (TextView) findViewById(android.R.id.empty);
    // If it has been checked before but there are no episodes, show that it is empty, not just
    // loading.
    if (StaticBlob.databaseConnector.getShow(currentShow, filter).getCount() == 0)
      loading.setText(this.getResources().getString(R.string.list_empty));
    else loading.setText(this.getResources().getString(R.string.loading));
    loading.setGravity(Gravity.CENTER_HORIZONTAL);
    // If it has never been checked before add a refresh button
    if (showSettings.getString("last_checked", null) == null) {
      refresh = new Button(this);
      refresh.setText(this.getResources().getString(R.string.refresh));
      refresh.setTextColor(this.getResources().getColor(R.color.txtClr));
      LinearLayout.LayoutParams p =
          new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);
      p.setMargins(20, 10, 20, 10);
      refresh.setLayoutParams(p);
      ((LinearLayout) loading.getParent()).setGravity(Gravity.CENTER_HORIZONTAL);
      refresh.setPadding(100, 10, 100, 10);
      refresh.setOnClickListener(
          new OnClickListener() {
            @Override
            public void onClick(View v) {
              reload();
            }
          });
      ((LinearLayout) mainListView.getParent()).addView(refresh, 1);
      ((LinearLayout) mainListView.getParent())
          .setBackgroundColor(this.getResources().getColor(R.color.backClr));
      mainListView.setEmptyView(refresh);
      loading.setVisibility(View.INVISIBLE);
    } else {
      mainListView.setEmptyView(loading);
    }
    // Finish setting up the listview
    mainListView.setOnItemClickListener(selectEpisode);
    mainListView.setBackgroundColor(getResources().getColor(R.color.backClr));
    mainListView.setCacheColorHint(getResources().getColor(R.color.backClr));
    setTitle(currentShow);
    // Get the shows from the SQL; make it async because of reasons
    new GetShowTask().execute((Object[]) null);
    Cursor r = StaticBlob.databaseConnector.getShow(currentShow, filter);
    showAdapter = new ShowListCursorAdapter(ShowList.this, R.layout.row, r);
    mainListView.setAdapter(showAdapter);
    return;
  }
 private void hideSkipText() {
   if (_skipTextView != null && _skipTextView.getParent() != null) {
     disableSkippingFromSkipText();
     _skipTextView.setVisibility(INVISIBLE);
   }
 }
예제 #17
0
  @Override
  public void onCreate(Bundle saved) {
    super.onCreate(saved);
    setContentView(R.layout.layout_person_info);
    searcher = new TmdbQuery(getBaseContext());

    picture = (ImageView) findViewById(R.id.image_person_info);
    name = (TextView) findViewById(R.id.text_person_name);
    birth = (TextView) findViewById(R.id.text_person_birth);
    death = (TextView) findViewById(R.id.text_person_death);
    bio = (TextView) findViewById(R.id.text_person_bio);
    appearsIn = (ListView) findViewById(R.id.listview_credits);

    Bundle extras = getIntent().getExtras();
    personId = extras.getInt("id");
    person = searcher.getPersonById(personId);
    picture.setTag(person.getIdTag());
    ImageGetter imgGetter = new ImageGetter(getBaseContext());
    try {
      String url =
          getString(R.string.baseurl_images)
              + person.getMediumImage(getResources())
              + person.getImagePath();
      imgGetter.DisplayImage(url, picture, 1.2f);
    } catch (RejectedExecutionException e) {
      Log.d(tag, "async task queue full at the moment, imgGet rejected");
    }

    name.setText(person.getName());
    birth.setText(
        Html.fromHtml(
            "born: " + person.getBirthday() + "<br><i>in</i>: " + person.getBirthPlace()));
    String deathString = person.getDeathday();
    if (deathString.equals("")) ((ViewManager) death.getParent()).removeView(death);
    else {
      death.setText("died: " + deathString);
    }
    bio.setText(person.getBiography());

    TabHost creditTabHost = (TabHost) findViewById(R.id.tabhost_credits);
    creditTabHost.setup();

    TabHost.TabSpec appearsSpec = creditTabHost.newTabSpec(APPEARS_TAB);
    appearsSpec.setContent(appearsIn.getId());
    appearsSpec.setIndicator("appears in");

    TabHost.TabSpec directedSpec = creditTabHost.newTabSpec(DIRECTED_TAB);
    directedSpec.setContent(appearsIn.getId());
    directedSpec.setIndicator("directed");

    TabHost.TabSpec wroteSpec = creditTabHost.newTabSpec(WROTE_TAB);
    wroteSpec.setContent(appearsIn.getId());
    wroteSpec.setIndicator("wrote");

    TabHost.TabSpec producedSpec = creditTabHost.newTabSpec(PRODUCED_TAB);
    producedSpec.setContent(appearsIn.getId());
    producedSpec.setIndicator("produced");

    List<CastCredit> castCredits = searcher.getCastCreditsByPersonId(personId);
    appearsIn.setAdapter(
        new ResultListAdapter(
            getBaseContext(), R.layout.list_item_movie_with_picture, castCredits));

    creditTabHost.addTab(appearsSpec);
    creditTabHost.addTab(directedSpec);
    creditTabHost.addTab(wroteSpec);
    creditTabHost.addTab(producedSpec);

    //        List<CrewCredit> crewCredits = searcher.getCrewCreditsByPersonId(personId);
    //
    //        List<CrewCredit> directed = new ArrayList<CrewCredit>();
    //        List<CrewCredit> wrote = new ArrayList<CrewCredit>();
    //        List<CrewCredit> produced = new ArrayList<CrewCredit>();
    //        for (CrewCredit credit : crewCredits) {
    //            if (credit.getDepartment().equals("Directing"))
    //                directed.add(credit);
    //            else if (credit.getDepartment().equals("Writing"))
    //                wrote.add(credit);
    //            else if (credit.getDepartment().equals("Production"))
    //                produced.add(credit);
    //        }
    appearsIn.setOnItemClickListener(
        new AdapterView.OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
            Intent infoActivity = new Intent(getBaseContext(), MovieInfoActivity.class);
            infoActivity.putExtra("id", (Integer) view.getTag());
            infoActivity.putExtra("listItemId", R.layout.list_item_movie_with_picture);
            infoActivity.putExtra("infoClass", MovieInfoActivity.class);
            startActivity(infoActivity);
          }
        });
    creditTabHost.setOnTabChangedListener(
        new TabHost.OnTabChangeListener() {
          @Override
          public void onTabChanged(String s) {
            if (s.equals(APPEARS_TAB)) {
              List<CastCredit> castCredits = searcher.getCastCreditsByPersonId(personId);
              appearsIn.setAdapter(
                  new ResultListAdapter(
                      getBaseContext(), R.layout.list_item_movie_with_picture, castCredits));
            } else if (s.equals(DIRECTED_TAB)) {
              List<CrewCredit> crewCredits = searcher.getCrewCreditsByPersonId(personId);

              List<CrewCredit> directed = new ArrayList<CrewCredit>();
              for (CrewCredit credit : crewCredits) {
                if (credit.getDepartment().equals("Directing")) directed.add(credit);
              }
              appearsIn.setAdapter(
                  new ResultListAdapter(
                      getBaseContext(), R.layout.list_item_movie_with_picture, directed));
            } else if (s.equals(WROTE_TAB)) {
              List<CrewCredit> crewCredits = searcher.getCrewCreditsByPersonId(personId);

              List<CrewCredit> wrote = new ArrayList<CrewCredit>();
              for (CrewCredit credit : crewCredits) {
                if (credit.getDepartment().equals("Writing")) wrote.add(credit);
              }
              appearsIn.setAdapter(
                  new ResultListAdapter(
                      getBaseContext(), R.layout.list_item_movie_with_picture, wrote));
            } else if (s.equals(PRODUCED_TAB)) {
              List<CrewCredit> crewCredits = searcher.getCrewCreditsByPersonId(personId);

              List<CrewCredit> produced = new ArrayList<CrewCredit>();
              for (CrewCredit credit : crewCredits) {
                if (credit.getDepartment().equals("Production")) produced.add(credit);
              }
              appearsIn.setAdapter(
                  new ResultListAdapter(
                      getBaseContext(), R.layout.list_item_movie_with_picture, produced));
            }
          }
        });
    creditTabHost.setCurrentTab(0);
  }
예제 #18
0
 public void zoneInvisible() {
   LinearLayout parent = (LinearLayout) textViewNom.getParent();
   parent.setVisibility(ViewGroup.INVISIBLE);
 }