Beispiel #1
0
  private void applyLayoutParams() {

    FrameLayout.LayoutParams lp =
        new FrameLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);

    switch (badgePosition) {
      case 1:
        lp.gravity = Gravity.LEFT | Gravity.TOP;
        lp.setMargins(badgeMarginH, badgeMarginV, 0, 0);
        break;
      case 2:
        lp.gravity = Gravity.RIGHT | Gravity.TOP;
        lp.setMargins(0, badgeMarginV, badgeMarginH, 0);
        break;
      case 3:
        lp.gravity = Gravity.LEFT | Gravity.BOTTOM;
        lp.setMargins(badgeMarginH, 0, 0, badgeMarginV);
        break;
      case 4:
        lp.gravity = Gravity.RIGHT | Gravity.BOTTOM;
        lp.setMargins(0, 0, badgeMarginH, badgeMarginV);
        break;
      case 5:
        lp.gravity = Gravity.CENTER;
        lp.setMargins(0, 0, 0, 0);
        break;
      default:
        break;
    }

    setLayoutParams(lp);
  }
Beispiel #2
0
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    FrameLayout.LayoutParams params =
        new FrameLayout.LayoutParams(
            FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT);
    FrameLayout fl = new FrameLayout(getActivity());
    fl.setLayoutParams(params);
    DisplayMetrics dm = getResources().getDisplayMetrics();
    final int margin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8, dm);
    TextView v = new TextView(getActivity());

    params.setMargins(margin, margin, margin, margin);
    v.setLayoutParams(params);
    v.setLayoutParams(params);
    v.setGravity(Gravity.CENTER);
    v.setText("PAGE09 ");
    v.setTextSize((int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, 12, dm));
    // WebView webviewtest= new WebView(getActivity());

    // webviewtest.loadUrl("file:///android_asset/1.html");
    // fl.addView(webviewtest);
    fl.addView(v);
    return fl;
  }
    private void updateIndicatorPosition(int position, float positionOffset) {
      // 現在の位置のタブのView
      final View view = mTrack.getChildAt(position);
      // 現在の位置の次のタブのView、現在の位置が最後のタブのときはnull
      final View view2 =
          position == (mTrack.getChildCount() - 1) ? null : mTrack.getChildAt(position + 1);

      // 現在の位置のタブの左端座標取得
      int left = view.getLeft();

      // 現在の位置のタブの横幅
      int width = view.getWidth();
      // 現在の位置の次のタブの横幅
      int width2 = view2 == null ? width : view2.getWidth();

      // インディケータの幅
      // width2 × スライドした割合 + (width × スライドした割合 - 1)
      int indicatorWidth = (int) (width2 * positionOffset + width * (1 - positionOffset));
      // インディケータの左端の位置
      // 今選択中のタブの左端 + width * スライドした割合
      int indicatorLeft = (int) (left + positionOffset * width);

      // インディケータの幅と左端の位置をセット
      final FrameLayout.LayoutParams layoutParams =
          (FrameLayout.LayoutParams) mIndicator.getLayoutParams();
      layoutParams.width = indicatorWidth;
      layoutParams.setMargins(indicatorLeft, 0, 0, 0);
      mIndicator.setLayoutParams(layoutParams);

      // インディケータが画面に入るように、タブの領域をスクロール
      mTrackScroller.scrollTo(indicatorLeft - mIndicatorOffset, 0);

      mIndicator.setBackgroundColor(getResources().getColor(R.color.ferrari_red));
    }
Beispiel #4
0
 public Loading(Context ctx) {
   super(ctx);
   //
   Window window = this.getWindow();
   window.requestFeature(Window.FEATURE_NO_TITLE);
   window.setBackgroundDrawableResource(R.color.transparent);
   this.setContentView(R.layout.dialog_loading);
   FrameLayout.LayoutParams rlp =
       new FrameLayout.LayoutParams(
           ((QAppSp) ctx.getApplicationContext()).getQWindow().getWidth() - 20,
           RelativeLayout.LayoutParams.WRAP_CONTENT);
   rlp.setMargins(10, 0, 10, 0);
   this.findViewById(R.id.dialog_loading_layout).setLayoutParams(rlp);
   //
   ivOut = this.findViewById(R.id.dialog_loading_out);
   ivIn = this.findViewById(R.id.dialog_loading_in);
   //
   LinearInterpolator li = new LinearInterpolator(); // 线性效果
   animOut.setDuration(500);
   animOut.setRepeatCount(Animation.INFINITE);
   animOut.setInterpolator(li);
   animIn.setDuration(500);
   animIn.setRepeatCount(Animation.INFINITE);
   animIn.setInterpolator(li);
 }
  public void showTags() {
    clearTags();

    if (!mShowTags) return;
    if (videoTags == null) return;

    for (int i = 0; i < videoTags.size(); i++) {
      VideoTag videoTag = videoTags.get(i);

      TextView textView;
      if (i < tagViews.size()) {
        textView = (TextView) tagViews.get(i);
      } else {
        textView = new TextView(getContext());
        textView.setOnTouchListener(listener);
        textView.setTag(VIDEO_TAG_VIEW_TAG);
        tagViews.add(textView);
      }
      textView.setText(videoTag.getText());
      // position
      int left = (int) (videoTag.getX() * getSize());
      int top = (int) (videoTag.getY() * getSize());

      FrameLayout.LayoutParams params =
          new FrameLayout.LayoutParams(
              ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
      params.setMargins(left, top, 0, 0);
      textView.setLayoutParams(params);
      addView(textView);
    }
  }
Beispiel #6
0
  private void initActionButton() {
    actionButton = new ImageView(mapActivity);
    int btnSize = (int) mapActivity.getResources().getDimension(R.dimen.map_button_size);
    int topPad = (int) mapActivity.getResources().getDimension(R.dimen.dashboard_map_top_padding);
    FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(btnSize, btnSize);
    int marginRight = btnSize / 4;
    params.setMargins(
        0, landscape ? 0 : topPad - 2 * btnSize, marginRight, landscape ? marginRight : 0);
    params.gravity = landscape ? Gravity.BOTTOM | Gravity.RIGHT : Gravity.TOP | Gravity.RIGHT;
    actionButton.setLayoutParams(params);
    actionButton.setScaleType(ScaleType.CENTER);
    actionButton.setImageDrawable(
        mapActivity.getResources().getDrawable(R.drawable.map_my_location));

    actionButton.setBackgroundDrawable(
        mapActivity.getResources().getDrawable(R.drawable.btn_circle_blue));
    hideActionButton();
    actionButton.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            if (getMyApplication().accessibilityEnabled()) {
              mapActivity.getMapActions().whereAmIDialog();
            } else {
              mapActivity.getMapViewTrackingUtilities().backToLocationImpl();
            }
            hideDashboard();
          }
        });
  }
 @Override
 public void setMargins(int left, int top, int right, int bottom) {
   super.setMargins(left, top, right, bottom);
   if (mPercentLayoutInfo != null) {
     mPercentLayoutInfo.setMargins(left, top, right, bottom);
   }
 }
 public void show(boolean animate) {
   menuSize = dpToPx(250, act);
   content = ((LinearLayout) act.findViewById(android.R.id.content).getParent());
   FrameLayout.LayoutParams parm = (FrameLayout.LayoutParams) content.getLayoutParams();
   parm.gravity = Gravity.TOP;
   statusHeight = 0;
   parm.setMargins(menuSize, 0, -menuSize, 0);
   content.setLayoutParams(parm);
   // animation for smooth slide-out
   TranslateAnimation ta = new TranslateAnimation(-menuSize, 0, 0, 0);
   ta.setDuration(500);
   if (animate) content.startAnimation(ta);
   parent = (FrameLayout) content.getParent();
   LayoutInflater inflater =
       (LayoutInflater) act.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
   menu = inflater.inflate(R.layout.menu, null);
   FrameLayout.LayoutParams lays = new FrameLayout.LayoutParams(-1, -1, 3);
   lays.setMargins(0, statusHeight, 0, 0);
   menu.setLayoutParams(lays);
   parent.addView(menu);
   ListView list = (ListView) act.findViewById(R.id.menu_listview);
   list.setBackgroundResource(R.drawable.shadow);
   list.setOnItemClickListener(
       new OnItemClickListener() {
         @Override
         public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
           // handle your menu-click
         }
       });
   if (animate) menu.startAnimation(ta);
   menu.findViewById(R.id.overlay)
       .setOnClickListener(
           new OnClickListener() {
             @Override
             public void onClick(View v) {
               NewsgroupListMenu.this.hide();
             }
           });
   enableDisableViewGroup(
       (LinearLayout) parent.findViewById(android.R.id.content).getParent(), false);
   // ((ExtendedViewPager) act.findViewById(R.id.viewpager)).setPagingEnabled(false);
   // ((ExtendedPagerTabStrip) act.findViewById(R.id.viewpager_tabs)).setNavEnabled(false);
   menuShown = true;
   this.fill();
 }
Beispiel #9
0
 public void setStyle(Style style) {
   this.style = style;
   android.widget.FrameLayout.LayoutParams layoutParams =
       (android.widget.FrameLayout.LayoutParams) content.getLayoutParams();
   if (style == Style.Floating) {
     layoutParams.width = ViewGroup.LayoutParams.WRAP_CONTENT;
     layoutParams.height = ViewGroup.LayoutParams.WRAP_CONTENT;
     int margin = (int) getResources().getDimension(R.dimen.carbon_padding);
     layoutParams.setMargins(margin, 0, margin, margin);
     layoutParams.gravity = Gravity.LEFT | Gravity.BOTTOM;
   } else {
     layoutParams.width = ViewGroup.LayoutParams.MATCH_PARENT;
     layoutParams.height = ViewGroup.LayoutParams.WRAP_CONTENT;
     layoutParams.setMargins(0, 0, 0, 0);
     layoutParams.gravity = Gravity.BOTTOM;
   }
   content.setLayoutParams(layoutParams);
   requestLayout();
 }
  private void display(Context cx) {
    ArrayList<Block> blocks = new ArrayList<Block>();

    counter = coorX = coorY = 0;
    calculateAllCells(cx);
    pattern = getDisplayPattern();

    for (int i = 0; i < pattern.size(); i++) {

      ArrayList<Cell> boxCells = new ArrayList<Cell>();

      for (int j = 0; j < pattern.get(i).size(); j++) {
        Cell c = cells.get(pattern.get(i).get(j));
        boxCells.add(c);
      }

      Block block = mBlockPattern.getBlock(boxCells);
      block.cells = boxCells;

      blocks.add(block);
    }

    double maxHeightsLocal[] = {0, 0, 0, 0};

    for (int i = 0; i < blocks.size(); i++) {

      CellView cv = new CellView(cx);
      View view = mAdapter.getView(postion, null, frameLayout);
      cv.addView(view);

      FrameLayout.LayoutParams params =
          new FrameLayout.LayoutParams((int) blocks.get(i).width, (int) blocks.get(i).height);
      params.setMargins(
          (int) blocks.get(i).x1,
          (int) blocks.get(i).y1 + (int) blocks.get(i).getHeightShift(maxHeights),
          0,
          0);

      frameLayout.addView(cv, params);
      cells.get(i).setCellView(cv);
      postion++;
      view.setTag(postion);
      setViewListeners(view);

      if (postion >= mAdapter.getCount()) return;

      // Get the max height that the cells of the box occupy
      for (int j = 0; j < blocks.get(i).cells.size(); j++) {
        maxHeightsLocal[blocks.get(i).cells.get(j).coorX] += blocks.get(i).cells.get(j).getHeight();
      }
    }
    for (int i = 0; i < 4; i++) maxHeights[i] += maxHeightsLocal[i];

    cells.clear();
  }
  /**
   * Sets the margins of the button from the edge of the screen in dp
   *
   * @param left the left margin in dp
   * @param top the top margin in dp
   * @param right the bottom margin in dp
   * @param bottom the right margin in dp
   */
  public void setMargins(int left, int top, int right, int bottom) {
    // Set the margins in dp
    buttonLayoutParams.setMargins(
        dpToPixel(left), dpToPixel(top), dpToPixel(right), dpToPixel(bottom));

    // Set the layout margin
    buttonLayoutMargins = new int[4];
    buttonLayoutMargins[0] = left;
    buttonLayoutMargins[1] = top;
    buttonLayoutMargins[2] = right;
    buttonLayoutMargins[3] = bottom;
  }
Beispiel #12
0
  /////////////////  Transparency bar /////////////////////////
  private void initTransparencyBar(final OsmandMapTileView view, FrameLayout parent) {
    int minimumHeight = view.getResources().getDrawable(R.drawable.map_zoom_in).getMinimumHeight();
    android.widget.FrameLayout.LayoutParams params =
        new FrameLayout.LayoutParams(
            LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, Gravity.BOTTOM | Gravity.CENTER);
    params.setMargins(0, 0, 0, minimumHeight + 3);
    transparencyBarLayout = new LinearLayout(view.getContext());
    transparencyBarLayout.setVisibility(settingsToTransparency != null ? View.VISIBLE : View.GONE);
    parent.addView(transparencyBarLayout, params);

    transparencyBar = new SeekBar(view.getContext());
    transparencyBar.setMax(255);
    if (settingsToTransparency != null) {
      transparencyBar.setProgress(settingsToTransparency.get());
    }
    transparencyBar.setOnSeekBarChangeListener(
        new SeekBar.OnSeekBarChangeListener() {

          @Override
          public void onStopTrackingTouch(SeekBar seekBar) {}

          @Override
          public void onStartTrackingTouch(SeekBar seekBar) {}

          @Override
          public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            if (settingsToTransparency != null) {
              settingsToTransparency.set(progress);
              mapActivity.getMapView().refreshMap();
            }
          }
        });
    android.widget.LinearLayout.LayoutParams prms =
        new LinearLayout.LayoutParams((int) (scaleCoefficient * 100), LayoutParams.WRAP_CONTENT);
    transparencyBarLayout.addView(transparencyBar, prms);
    ImageButton imageButton = new ImageButton(view.getContext());
    prms = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    prms.setMargins((int) (2 * scaleCoefficient), (int) (2 * scaleCoefficient), 0, 0);
    imageButton.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            transparencyBarLayout.setVisibility(View.GONE);
            hideTransparencyBar(settingsToTransparency);
          }
        });
    imageButton.setContentDescription(view.getContext().getString(R.string.close));
    imageButton.setBackgroundResource(R.drawable.headliner_close);
    transparencyBarLayout.addView(imageButton, prms);
  }
  // The return value is sent elsewhere. TODO in java, in SendMessage in C++.
  public void inputBox(String title, String defaultText, String defaultAction) {
    final FrameLayout fl = new FrameLayout(this);
    final EditText input = new EditText(this);
    input.setGravity(Gravity.CENTER);

    FrameLayout.LayoutParams editBoxLayout =
        new FrameLayout.LayoutParams(
            FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.WRAP_CONTENT);
    editBoxLayout.setMargins(2, 20, 2, 20);
    fl.addView(input, editBoxLayout);

    input.setInputType(InputType.TYPE_CLASS_TEXT);
    input.setText(defaultText);
    input.selectAll();

    // Lovely!
    AlertDialog.Builder bld = null;
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) bld = new AlertDialog.Builder(this);
    else if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH)
      bld = createDialogBuilderWithTheme();
    else if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M)
      bld = createDialogBuilderWithDeviceTheme();
    else bld = createDialogBuilderNew();

    AlertDialog dlg =
        bld.setView(fl)
            .setTitle(title)
            .setPositiveButton(
                defaultAction,
                new DialogInterface.OnClickListener() {
                  @Override
                  public void onClick(DialogInterface d, int which) {
                    NativeApp.sendMessage("inputbox_completed", input.getText().toString());
                    d.dismiss();
                  }
                })
            .setNegativeButton(
                "Cancel",
                new DialogInterface.OnClickListener() {
                  @Override
                  public void onClick(DialogInterface d, int which) {
                    NativeApp.sendMessage("inputbox_failed", "");
                    d.cancel();
                  }
                })
            .create();

    dlg.setCancelable(true);
    dlg.show();
  }
 @Override
 public void onSizeChanged(int width, int height) {
   // this is called whenever size of the BlinkIDView changes
   // we will use this callback in this example to adjust the margins of buttons
   int horizontalMargin = (int) (width * 0.07);
   int verticalMargin = (int) (height * 0.07);
   // set margins for back button
   FrameLayout.LayoutParams backButtonParams =
       (FrameLayout.LayoutParams) mBackButton.getLayoutParams();
   if (backButtonParams.leftMargin != horizontalMargin
       && backButtonParams.topMargin != verticalMargin) {
     backButtonParams.setMargins(
         horizontalMargin, verticalMargin, horizontalMargin, verticalMargin);
     mBackButton.setLayoutParams(backButtonParams);
   }
   // set margins for torch button
   FrameLayout.LayoutParams torchButtonParams =
       (FrameLayout.LayoutParams) mTorchButton.getLayoutParams();
   if (torchButtonParams.leftMargin != horizontalMargin
       && torchButtonParams.topMargin != verticalMargin) {
     torchButtonParams.setMargins(
         horizontalMargin, verticalMargin, horizontalMargin, verticalMargin);
     mTorchButton.setLayoutParams(torchButtonParams);
   }
   // set margins for text view
   FrameLayout.LayoutParams statusViewParams =
       (FrameLayout.LayoutParams) mStatusTextView.getLayoutParams();
   if (statusViewParams.bottomMargin != verticalMargin) {
     if (android.os.Build.VERSION.SDK_INT <= 7) {
       statusViewParams.setMargins(0, verticalMargin, 0, verticalMargin);
     } else {
       statusViewParams.setMargins(
           horizontalMargin, verticalMargin, horizontalMargin, verticalMargin);
     }
     mStatusTextView.setLayoutParams(statusViewParams);
   }
 }
  /** 计算结果 */
  private void compuleResult() {
    mView.getLocationInWindow(location);
    viewWidth = mView.getWidth();
    viewHeight = mView.getHeight();

    int menuWidth = windowWidth - widthOffset * 2;
    int menuHeight = windowHeight - getStatusBarHeight() - heightOffset * 2;

    int viewPonitX = location[0] + viewWidth / 2;
    int viewPonitY = location[1] + viewHeight / 2;
    int windowPonitX = windowWidth / 2;
    int windowPonitY = (windowHeight) / 2;

    paramsBig = new FrameLayout.LayoutParams(menuWidth, menuHeight);
    paramsBig.setMargins(widthOffset, heightOffset - actionBarHeight, menuWidth, menuHeight);

    paramsSmall = new FrameLayout.LayoutParams(viewWidth, viewHeight);
    paramsSmall.setMargins(
        location[0],
        location[1] - getStatusBarHeight() - actionBarHeight,
        location[0] + viewWidth,
        location[1] - getStatusBarHeight() - actionBarHeight + viewHeight);

    viewMoveX = windowPonitX - viewPonitX;
    viewMoveY = windowPonitY - viewPonitY;

    toValueX = ((((windowWidth - viewWidth) / 2) - widthOffset) * 1.0f) / (viewWidth / 2);
    toValueY =
        ((((windowHeight - getStatusBarHeight() - viewHeight) / 2) - heightOffset) * 1.0f)
            / (viewHeight / 2);

    //		toMenuValueX = (viewWidth*1.0f)/menuWidth;
    //		toMenuValueY = (viewHeight*1.0f)/menuHeight;
    //		menuToViewX = widthOffset - location[0];
    //		menuToViewY = heightOffset - location[1];
  }
 public void createProgressItem() {
   flProgress = new FrameLayout(getSherlockActivity());
   ProgressBar pb = new ProgressBar(getSherlockActivity());
   pb.setIndeterminateDrawable(getResources().getDrawable(R.drawable.progress));
   FrameLayout.LayoutParams lp =
       new FrameLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
   int px =
       (int)
           TypedValue.applyDimension(
               TypedValue.COMPLEX_UNIT_DIP, 8, getResources().getDisplayMetrics());
   lp.setMargins(px / 2, px, px / 2, px);
   pb.setLayoutParams(lp);
   flProgress.addView(pb);
   flProgress.setClickable(true);
   flProgress.setBackgroundResource(R.drawable.abs__item_background_holo_light);
 }
  public CustVideoView(final Context context, Video video) {
    super(context);
    this.context = context;
    this.setVideo(video);
    String frame = video.getFrame();
    String closesOnEnd = video.getClosesOnEnd();
    if (closesOnEnd != null && closesOnEnd.equalsIgnoreCase("true")) {
      autoClose = true;
    }
    fullscreen = video.getFullscreen();
    FrameLayout.LayoutParams params;
    int[] frames = FrameUtil.frame2int(frame);
    frames = FrameUtil.autoAdjust(frames, context);
    // 全屏模式
    if (fullscreen.equalsIgnoreCase("true")) {
      act = (Activity) context;
      Display display = act.getWindowManager().getDefaultDisplay();
      int width = display.getWidth();
      int height = display.getHeight();
      params = new FrameLayout.LayoutParams(width, height);
      params.topMargin = 0;
      params.leftMargin = 0;
      setMeasuredDimension(width, height);
    } else {
      params = new FrameLayout.LayoutParams(frames[2], frames[3]);
      params.setMargins(frames[0], frames[1], 0, 0);
    }
    setLayoutParams(params);
    String path = AppConfigUtil.getAppResource(AppConfigUtil.MAGAZINE_ID) + video.getResource();
    setVideoPath(path);
    setVisibility(View.VISIBLE);
    setOnCompletionListener(
        new OnCompletionListener() {

          @Override
          public void onCompletion(MediaPlayer mp) {
            MagazineActivity act = (MagazineActivity) context;
            act.getvControllers().remove(this);
            if (autoClose) {
              setVisibility(View.INVISIBLE);
              showLayers();
            }
          }
        });
    setOnClickListener(this);
  }
  public void hide() {
    TranslateAnimation ta = new TranslateAnimation(0, -menuSize, 0, 0);
    ta.setDuration(500);
    menu.startAnimation(ta);
    parent.removeView(menu);

    TranslateAnimation tra = new TranslateAnimation(menuSize, 0, 0, 0);
    tra.setDuration(500);
    content.startAnimation(tra);
    FrameLayout.LayoutParams parm = (FrameLayout.LayoutParams) content.getLayoutParams();
    parm.setMargins(0, 0, 0, 0);
    content.setLayoutParams(parm);
    enableDisableViewGroup(
        (LinearLayout) parent.findViewById(android.R.id.content).getParent(), true);
    // ((ExtendedViewPager) act.findViewById(R.id.viewpager)).setPagingEnabled(true);
    // ((ExtendedPagerTabStrip) act.findViewById(R.id.viewpager_tabs)).setNavEnabled(true);
    menuShown = false;
  }
Beispiel #19
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    mCoordinator = (CoordinatorLayout) findViewById(R.id.coordinator);

    // Setting the Navigation Drawer
    final DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    ActionBarDrawerToggle toggle =
        new ActionBarDrawerToggle(
            this, drawer, null, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
    drawer.setDrawerListener(toggle);
    toggle.syncState();
    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);
    FloatingActionButton btnNav = (FloatingActionButton) findViewById(R.id.btn_nav);
    btnNav.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            if (drawer.isDrawerOpen(GravityCompat.START)) {
              drawer.closeDrawer(GravityCompat.START);
            } else {
              drawer.openDrawer(GravityCompat.START);
            }
          }
        });

    // Set main content to margin fit system window with transparent status bar
    if (Build.VERSION.SDK_INT == Build.VERSION_CODES.LOLLIPOP) {
      FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) drawer.getLayoutParams();
      layoutParams.setMargins(0, -getStatusBarHeight(), 0, 0);
      navigationView.setPadding(0, getStatusBarHeight(), 0, 0);
    }

    // Obtain the SupportMapFragment and get notified when the map is ready to be used.
    SupportMapFragment mapFragment =
        (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
    mapFragment.getMapAsync(this);

    // Get user location data
    buildGoogleApiClient();
  }
    @Override
    public void resetTranslations() {
      parentFragment.toolbar.setBackgroundColor(Color.TRANSPARENT);
      parentFragment.viewContainerBackground.setBackgroundColor(Color.TRANSPARENT);
      parentFragment.descriptionText.setVisibility(View.GONE);

      int orientation = Utils.getScreenOrientation(getActivity());
      float density = getResources().getDisplayMetrics().density;

      float tabsPadding = orientation == Configuration.ORIENTATION_PORTRAIT ? 0 : density * 48;
      FrameLayout.LayoutParams layoutParams =
          (FrameLayout.LayoutParams) parentFragment.mTabs.getLayoutParams();
      layoutParams.setMargins((int) tabsPadding, 0, (int) tabsPadding, 0);
      parentFragment.mTabs.requestLayout();

      setPaddingRecyclerview(orientation, density);
      if (onScrollListener != null) onScrollListener.reset();
      layoutManager.scrollToPositionWithOffset(0, 0);
    }
Beispiel #21
0
  @Override
  protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);
    // mOverlay.setTranslationY(800);

    Log.d("mPaintSeekInfo", "draw with mPaintSeekInfo => " + mPaintSeekInfo);

    if (isInEditMode()) {
      return;
    }

    if (mPaintSeekInfo) {
      Log.d("PlayerSeekbar", "Draw seekinfo");
      if (params.height == 0) {
        mOverlay.setVisibility(INVISIBLE);
        params.height = mOverlay.getHeight();
        params.width = mOverlay.getWidth();
        mOverlay.bringToFront();
      }

      mBackwards.setText(mBackwardsText);
      mCurrent.setText(mCurrentText);
      mForwards.setText(mForwardText);

      this.getLocationOnScreen(loc);
      int offset =
          loc[1] - (int) UIUtils.convertDpToPixel(200, getContext()); // FIXME this.getHeight()*4;
      int translationY = (int) ((View) this.getParent()).getTranslationY();
      Log.d("PlayerSeekbar", "trans => " + translationY);
      Log.d("PlayerSeekbar", "loc0 => " + loc[0] + " loc0 => " + loc[1]);
      params.setMargins(mSideMargin, offset, mSideMargin, 0);

      if (mOverlay != null) {
        mOverlay.setLayoutParams(params);
        mOverlay.setVisibility(VISIBLE);
      }
    } else {
      Log.d("PlayerSeekbar", "Remove seekinfo");
      if (mOverlay != null) {
        mOverlay.setVisibility(GONE);
      }
    }
  }
    private void addTileFromEntry(ContactEntry entry, int childIndex, boolean isLastRow) {
      final ContactTileView contactTile;

      if (getChildCount() <= childIndex) {
        contactTile = (ContactTileView) inflate(mContext, mLayoutResId, null);
        // Note: the layoutparam set here is only actually used for FREQUENT.
        // We override onMeasure() for STARRED and we don't care the layout param there.
        Resources resources = mContext.getResources();
        FrameLayout.LayoutParams params =
            new FrameLayout.LayoutParams(
                ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        params.setMargins(
            resources.getDimensionPixelSize(R.dimen.detail_item_side_margin),
            0,
            resources.getDimensionPixelSize(R.dimen.detail_item_side_margin),
            0);
        contactTile.setLayoutParams(params);
        contactTile.setPhotoManager(mPhotoManager);
        contactTile.setListener(mContactTileListener);
        addView(contactTile);
      } else {
        contactTile = (ContactTileView) getChildAt(childIndex);
      }
      contactTile.loadFromContact(entry);

      switch (mItemViewType) {
        case ViewTypes.STARRED_WITH_SECONDARY_ACTION:
        case ViewTypes.STARRED:
          // Setting divider visibilities
          contactTile.setPadding(
              0,
              0,
              childIndex >= mColumnCount - 1 ? 0 : mPaddingInPixels,
              isLastRow ? 0 : mPaddingInPixels);
          break;
        case ViewTypes.FREQUENT:
          contactTile.setHorizontalDividerVisibility(isLastRow ? View.GONE : View.VISIBLE);
          break;
        default:
          break;
      }
    }
  private void createCardLayout() {

    float width, height, left_right_margins = 0, top_bottom_margins = 0;
    int screen_width = 0, screen_height = 0;
    final float HORIZONTAL_PERCENTAGE = (float) (5.0 / 100);
    final float VERTICAL_PERCENTAGE = (float) (85.0 / 100);
    FrameLayout.LayoutParams params =
        new FrameLayout.LayoutParams(
            FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT);
    mFrontCardLayout = (RelativeLayout) findViewById(R.id.layout_front_card);
    mBackCardLayout = (RelativeLayout) findViewById(R.id.layout_back_card);
    Display display = getWindowManager().getDefaultDisplay();
    int version = android.os.Build.VERSION.SDK_INT;
    if (version >= 13) {
      Point size = new Point();
      display.getSize(size);
      screen_height = size.y;
      screen_width = size.x;
      left_right_margins = (float) (HORIZONTAL_PERCENTAGE * screen_width);
      width = (float) (screen_width - left_right_margins); // width of the flash card
      height = (float) (VERTICAL_PERCENTAGE * width); // height of the flash card
      top_bottom_margins = (float) ((screen_height - height) / 2.0);
    } else {
      screen_height = display.getHeight();
      screen_width = display.getWidth();
      left_right_margins = (float) (HORIZONTAL_PERCENTAGE * screen_width);
      width = (float) (screen_width - left_right_margins); // width of the flash card
      height = (float) (VERTICAL_PERCENTAGE * width); // height of the flash card
      top_bottom_margins = (float) ((screen_height - height) / 2.0);
      params.gravity = Gravity.TOP;
    }

    params.setMargins(
        (int) left_right_margins,
        (int) top_bottom_margins,
        (int) left_right_margins,
        (int) top_bottom_margins);
    mFrontCardLayout.setLayoutParams(params);
    mBackCardLayout.setLayoutParams(params);
  }
  public void initPathAnimation() {
    int viewSize = getResources().getDimensionPixelSize(R.dimen.fourthSampleViewSize);
    FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(viewSize, viewSize);

    params.setMargins(0, 0, 0, 50);
    FillableLoaderBuilder loaderBuilder = new FillableLoaderBuilder();
    mPathLogo =
        loaderBuilder
            .parentView(mFl)
            .layoutParams(params)
            .svgPath(mConfigSplash.getPathSplash())
            .originalDimensions(mConfigSplash.getOriginalWidth(), mConfigSplash.getOriginalHeight())
            .strokeWidth(mConfigSplash.getPathSplashStrokeSize())
            .strokeColor(
                Color.parseColor(
                    String.format(
                        "#%06X",
                        (0xFFFFFF
                            & getResources().getColor(mConfigSplash.getPathSplashStrokeColor())))))
            .fillColor(
                Color.parseColor(
                    String.format(
                        "#%06X",
                        (0xFFFFFF
                            & getResources().getColor(mConfigSplash.getPathSplashFillColor())))))
            .strokeDrawingDuration(mConfigSplash.getAnimPathStrokeDrawingDuration())
            .fillDuration(mConfigSplash.getAnimPathFillingDuration())
            .clippingTransform(new PlainClippingTransform())
            .build();
    mPathLogo.setOnStateChangeListener(
        new OnStateChangeListener() {
          @Override
          public void onStateChange(int i) {
            if (i == State.FINISHED) {
              startTextAnimation();
            }
          }
        });
  }
 public void show(String media, int spot, int interval, int x, int y, int w, int h) {
   this.hide();
   Activity activity = this.getActivity();
   if (activity != null && adstir == null) {
     float density = activity.getResources().getDisplayMetrics().density;
     adstir =
         new com.ad_stir.webview.AdstirMraidView(
             this.getActivity(),
             media,
             spot,
             new com.ad_stir.webview.AdstirMraidView.AdSize(w, h),
             interval);
     android.widget.FrameLayout topVIew =
         (android.widget.FrameLayout) this.getActivity().findViewById(android.R.id.content);
     android.widget.FrameLayout.LayoutParams param =
         new android.widget.FrameLayout.LayoutParams(
             android.widget.FrameLayout.LayoutParams.WRAP_CONTENT,
             android.widget.FrameLayout.LayoutParams.WRAP_CONTENT);
     param.setMargins((int) (density * x), (int) (density * y), 0, 0);
     param.gravity = android.view.Gravity.NO_GRAVITY;
     topVIew.addView(adstir, param);
   }
 }
 @Override
 public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
   if (loadedImage != null) {
     ImageView imageView = (ImageView) view;
     int h = dp2px.dip2px(98);
     int w = h * loadedImage.getWidth() / loadedImage.getHeight();
     FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(w, h);
     // imageView.setLayoutParams(lp);
     imageView.setScaleType(ScaleType.CENTER_CROP);
     boolean firstDisplay = !displayedImages.contains(imageUri);
     if (firstDisplay) {
       FadeInBitmapDisplayer.animate(imageView, 500);
       displayedImages.add(imageUri);
     }
   } else {
     ImageView imageView = (ImageView) view;
     int h = imageView.getHeight();
     FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(h, h);
     lp.setMargins(dp2px.dip2px(10), dp2px.dip2px(10), 0, dp2px.dip2px(10));
     imageView.setLayoutParams(lp);
     imageView.setImageResource(R.drawable.img_default);
   }
 }
Beispiel #27
0
  @Override
  public void setContentView(int layoutResID) {
    super.setContentView(R.layout.base_layout);

    mDensity = getResources().getDisplayMetrics().density;
    mInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);

    mRootView = (FrameLayout) findViewById(android.R.id.content);

    if (!mHideTitle) {
      final int resId = -1 == mTitleResId ? R.layout.base_title_layout : mTitleResId;
      mInflater.inflate(resId, mRootView);
    }

    FrameLayout.LayoutParams layoutParams =
        new FrameLayout.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT,
            Gravity.BOTTOM);
    final int marginTop = mHideTitle ? 0 : (int) (mDensity * 48 + .5f);
    layoutParams.setMargins(0, marginTop, 0, 0);
    View contentView = mInflater.inflate(layoutResID, null);
    mRootView.addView(contentView, layoutParams);
  }
    private void addTileFromEntry(ContactEntry entry, int childIndex, boolean isLastRow) {
      final ContactTileView contactTile;

      if (getChildCount() <= childIndex) {
        contactTile = (ContactTileView) inflate(mContext, mLayoutResId, null);
        // Note: the layoutparam set here is only actually used for FREQUENT.
        // We override onMeasure() for STARRED and we don't care the layout param there.
        Resources resources = mContext.getResources();
        FrameLayout.LayoutParams params =
            new FrameLayout.LayoutParams(
                ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        params.setMargins(mWhitespaceStartEnd, 0, mWhitespaceStartEnd, 0);
        contactTile.setLayoutParams(params);
        contactTile.setPhotoManager(mPhotoManager);
        contactTile.setListener(mListener);
        addView(contactTile);
      } else {
        contactTile = (ContactTileView) getChildAt(childIndex);
      }
      contactTile.loadFromContact(entry);

      switch (mItemViewType) {
        case ViewTypes.STARRED:
          // Set padding between tiles. Divide mPaddingInPixels between left and right
          // tiles as evenly as possible.
          contactTile.setPaddingRelative(
              (mPaddingInPixels + 1) / 2, 0,
              mPaddingInPixels / 2, 0);
          break;
        case ViewTypes.FREQUENT:
          contactTile.setHorizontalDividerVisibility(isLastRow ? View.GONE : View.VISIBLE);
          break;
        default:
          break;
      }
    }
Beispiel #29
0
  private void initZoomButtons(final OsmandMapTileView view, FrameLayout parent) {
    int minimumWidth = view.getResources().getDrawable(R.drawable.map_zoom_in).getMinimumWidth();

    Context ctx = view.getContext();
    ImageView bottomShadow = new ImageView(ctx);
    bottomShadow.setBackgroundResource(R.drawable.bottom_shadow);
    android.widget.FrameLayout.LayoutParams params =
        new FrameLayout.LayoutParams(
            LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT, Gravity.BOTTOM);
    params.setMargins(0, 0, 0, 0);
    parent.addView(bottomShadow, params);

    zoomTextPaint = new TextPaint();
    zoomTextPaint.setTextSize(18 * scaleCoefficient);
    zoomTextPaint.setAntiAlias(true);
    zoomTextPaint.setFakeBoldText(true);

    zoomShadow = view.getResources().getDrawable(R.drawable.zoom_background);

    zoomInButton = new Button(ctx);
    zoomInButton.setBackgroundResource(R.drawable.map_zoom_in);
    params =
        new FrameLayout.LayoutParams(
            LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, Gravity.BOTTOM | Gravity.RIGHT);
    params.setMargins(0, 0, 0, 0);
    zoomInButton.setContentDescription(ctx.getString(R.string.zoomIn));
    parent.addView(zoomInButton, params);

    zoomOutButton = new Button(ctx);
    zoomOutButton.setBackgroundResource(R.drawable.map_zoom_out);
    params =
        new FrameLayout.LayoutParams(
            LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, Gravity.BOTTOM | Gravity.RIGHT);

    params.setMargins(0, 0, minimumWidth, 0);
    zoomOutButton.setContentDescription(ctx.getString(R.string.zoomOut));
    parent.addView(zoomOutButton, params);

    activity.accessibleContent.add(zoomInButton);
    activity.accessibleContent.add(zoomOutButton);

    zoomInButton.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            if (view.isZooming()) {
              activity.changeZoom(view.getZoom() + 2);
              //					activity.changeZoom(view.getFloatZoom() + 2 * OsmandMapTileView.ZOOM_DELTA_1 );
            } else {
              activity.changeZoom(view.getZoom() + 1);
              //					activity.changeZoom(view.getFloatZoom() + 1 * OsmandMapTileView.ZOOM_DELTA_1 );
            }
          }
        });

    zoomOutButton.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            activity.changeZoom(view.getZoom() - 1);
            //				activity.changeZoom(view.getFloatZoom() - 1 * OsmandMapTileView.ZOOM_DELTA_1 );
          }
        });
  }
Beispiel #30
0
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    bgLayout = (FrameLayout) inflater.inflate(R.layout.popover_layout, container, false);

    containerLayout = (FrameLayout) bgLayout.findViewById(R.id.popover_container);
    bgView = bgLayout.findViewById(R.id.popover_background);

    bgView.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            loader.cancelSubViews();
          }
        });

    FrameLayout.LayoutParams frameLayoutParams =
        new FrameLayout.LayoutParams(
            FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT);
    frameLayoutParams.gravity = Gravity.TOP | Gravity.RIGHT;
    float density = getResources().getDisplayMetrics().density;
    frameLayoutParams.width = (int) (width * density);
    frameLayoutParams.height = (int) (height * density);

    /*// set size
    LayoutParams params = containerLayout.getLayoutParams();
    float density = getResources().getDisplayMetrics().density;
    params.width = (int)(width * density);
    params.height = (int)(height * density);*/

    containerLayout.setLayoutParams(frameLayoutParams);

    /*
    webView = new SmartWebView(this);

    containerLayout.addView(webView, new FrameLayout.LayoutParams(
    		FrameLayout.LayoutParams.MATCH_PARENT,
    		FrameLayout.LayoutParams.MATCH_PARENT));
    webView.loadUrl(url);*/

    FrameLayout.LayoutParams webViewLayoutParams =
        new FrameLayout.LayoutParams(
            FrameLayout.LayoutParams.MATCH_PARENT,
            FrameLayout.LayoutParams
                .MATCH_PARENT); // (android.widget.RelativeLayout.LayoutParams)
                                // containerLayout.getLayoutParams();
    int margin = (int) (10 * density);
    webViewLayoutParams.setMargins(margin, margin, margin, margin);
    // webView.setLayoutParams(webViewLayoutParams);
    webView = new SmartWebViewClassic(this);
    containerLayout.addView(webView, webViewLayoutParams);
    webView.loadUrl(url);

    /*RoundRectShape rs = new RoundRectShape(new float[] { 10, 10, 10, 10, 10, 10, 10, 10 }, null, null);
    ShapeDrawable sd = new CustomShapeDrawable(rs, Color.RED, Color.WHITE, 20);
    webView.setBackground(sd);*/

    return bgLayout;
  }