Java Code Examples for android.view.View#setHasTransientState()

The following examples show how to use android.view.View#setHasTransientState() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: android_9.0.0_r45   File: Transition.java    License: Apache License 2.0 5 votes vote down vote up
static void addViewValues(TransitionValuesMaps transitionValuesMaps,
        View view, TransitionValues transitionValues) {
    transitionValuesMaps.viewValues.put(view, transitionValues);
    int id = view.getId();
    if (id >= 0) {
        if (transitionValuesMaps.idValues.indexOfKey(id) >= 0) {
            // Duplicate IDs cannot match by ID.
            transitionValuesMaps.idValues.put(id, null);
        } else {
            transitionValuesMaps.idValues.put(id, view);
        }
    }
    String name = view.getTransitionName();
    if (name != null) {
        if (transitionValuesMaps.nameValues.containsKey(name)) {
            // Duplicate transitionNames: cannot match by transitionName.
            transitionValuesMaps.nameValues.put(name, null);
        } else {
            transitionValuesMaps.nameValues.put(name, view);
        }
    }
    if (view.getParent() instanceof ListView) {
        ListView listview = (ListView) view.getParent();
        if (listview.getAdapter().hasStableIds()) {
            int position = listview.getPositionForView(view);
            long itemId = listview.getItemIdAtPosition(position);
            if (transitionValuesMaps.itemIdValues.indexOfKey(itemId) >= 0) {
                // Duplicate item IDs: cannot match by item ID.
                View alreadyMatched = transitionValuesMaps.itemIdValues.get(itemId);
                if (alreadyMatched != null) {
                    alreadyMatched.setHasTransientState(false);
                    transitionValuesMaps.itemIdValues.put(itemId, null);
                }
            } else {
                view.setHasTransientState(true);
                transitionValuesMaps.itemIdValues.put(itemId, view);
            }
        }
    }
}
 
Example 2
Source Project: litho   File: VisibilityEventsTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void
    visibilityOutputs_setTransientStateFalse_parentInTransientState_processVisibilityOutputs() {
  final TestComponent content = create(mContext).build();
  final EventHandler<VisibleEvent> visibleEventHandler = new EventHandler<>(content, 2);
  final Component root =
      Column.create(mContext)
          .child(
              Wrapper.create(mContext)
                  .delegate(content)
                  .visibleHandler(visibleEventHandler)
                  .widthPx(10)
                  .heightPx(10))
          .build();

  final View view = (View) mLithoView.getParent();
  view.setHasTransientState(true);

  mLithoViewRule
      .useComponentTree(ComponentTree.create(mContext).build())
      .setRoot(root)
      .attachToWindow()
      .setSizeSpecs(makeSizeSpec(100, EXACTLY), makeSizeSpec(100, EXACTLY))
      .measure()
      .layout();

  mLithoView.notifyVisibleBoundsChanged(new Rect(0, -10, 10, -5), true);
  content.getDispatchedEventHandlers().clear();

  mLithoView.setHasTransientState(true);
  assertThat(content.getDispatchedEventHandlers()).doesNotContain(visibleEventHandler);

  mLithoView.setMountStateDirty();
  mLithoView.notifyVisibleBoundsChanged(new Rect(0, -10, 10, -5), true);
  assertThat(content.getDispatchedEventHandlers()).doesNotContain(visibleEventHandler);

  mLithoView.setHasTransientState(false);
  assertThat(content.getDispatchedEventHandlers()).contains(visibleEventHandler);
  view.setHasTransientState(false);
}
 
Example 3
Source Project: Noyze   File: CircleVolumePanel.java    License: Apache License 2.0 5 votes vote down vote up
protected Animator shuffle(View target) {
    LOGI(TAG, "shuffle()");
    final int duration = Resources.getSystem().getInteger(android.R.integer.config_mediumAnimTime);
    ObjectAnimator rotation = ObjectAnimator.ofFloat(target, View.TRANSLATION_X, 5, 0, -5, 0, 5, 0, -5, 0, 5, 0, -5, 0, 5, 0);
    rotation.setDuration(duration);
    rotation.setStartDelay(duration / 4);
    target.setHasTransientState(true);
    return rotation;
}
 
Example 4
Source Project: Noyze   File: CircleVolumePanel.java    License: Apache License 2.0 5 votes vote down vote up
protected Animator wiggle(View target) {
    LOGI(TAG, "wiggle()");
    final int duration = Resources.getSystem().getInteger(android.R.integer.config_mediumAnimTime);
    ObjectAnimator rotation = ObjectAnimator.ofFloat(target, View.ROTATION, 5, 0, -5, 0, 5, 0, -5, 0, 5, 0, -5, 0, 5, 0);
    rotation.setDuration(duration);
    rotation.setStartDelay(duration / 4);
    target.setHasTransientState(true);
    return rotation;
}
 
Example 5
Source Project: Pimp_my_Z1   File: Card.java    License: GNU General Public License v2.0 5 votes vote down vote up
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
@Override
public View getView(Context context, boolean swipable) {

    View view = LayoutInflater.from(context).inflate(getCardLayout(), null);

    mCardLayout = view;

    try {
        if (view != null) ((FrameLayout) view.findViewById(R.id.cardContent))
                .addView(getCardContent(context));
    } catch (NullPointerException e) {
        e.printStackTrace();
    }

    // ((TextView) view.findViewById(R.id.title)).setText(this.title);

    LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.MATCH_PARENT,
            LinearLayout.LayoutParams.WRAP_CONTENT);
    int bottom = Utils.convertDpToPixelInt(context, 12);
    lp.setMargins(0, 0, 0, bottom);

    if (view != null) {
        view.setLayoutParams(lp);
        view.setHasTransientState(true);
    }

    return view;
}
 
Example 6
Source Project: Pimp_my_Z1   File: Card.java    License: GNU General Public License v2.0 5 votes vote down vote up
@SuppressLint("NewApi")
@Override
public View getView(Context context) {

    View view = LayoutInflater.from(context).inflate(getCardLayout(), null);

    mCardLayout = view;

    try {
        if (view != null) ((FrameLayout) view.findViewById(R.id.cardContent))
                .addView(getCardContent(context));
    } catch (NullPointerException e) {
        e.printStackTrace();
    }

    // ((TextView) view.findViewById(R.id.title)).setText(this.title);

    LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.MATCH_PARENT,
            LinearLayout.LayoutParams.WRAP_CONTENT);
    int bottom = Utils.convertDpToPixelInt(context, 12);
    lp.setMargins(0, 0, 0, bottom);

    if (view != null) {
        view.setLayoutParams(lp);
        view.setHasTransientState(true);
    }

    return view;
}
 
Example 7
Source Project: Pimp_my_Z1   File: Card.java    License: GNU General Public License v2.0 5 votes vote down vote up
@SuppressLint("NewApi")
public View getViewLast(Context context) {

    View view = LayoutInflater.from(context).inflate(getLastCardLayout(),
            null);

    mCardLayout = view;

    try {
        if (view != null) ((FrameLayout) view.findViewById(R.id.cardContent))
                .addView(getCardContent(context));
    } catch (NullPointerException e) {
        e.printStackTrace();
    }

    // ((TextView) view.findViewById(R.id.title)).setText(this.title);

    LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.MATCH_PARENT,
            LinearLayout.LayoutParams.WRAP_CONTENT);
    int bottom = Utils.convertDpToPixelInt(context, 12);
    lp.setMargins(0, 0, 0, bottom);

    if (view != null) {
        view.setLayoutParams(lp);
        view.setHasTransientState(true);
    }
    return view;
}
 
Example 8
Source Project: Pimp_my_Z1   File: Card.java    License: GNU General Public License v2.0 5 votes vote down vote up
@SuppressLint("NewApi")
public View getViewFirst(Context context) {

    View view = LayoutInflater.from(context).inflate(getFirstCardLayout(),
            null);

    mCardLayout = view;

    try {
        if (view != null) ((FrameLayout) view.findViewById(R.id.cardContent))
                .addView(getCardContent(context));
    } catch (NullPointerException e) {
        e.printStackTrace();
    }

    // ((TextView) view.findViewById(R.id.title)).setText(this.title);

    LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.MATCH_PARENT,
            LinearLayout.LayoutParams.WRAP_CONTENT);
    int bottom = Utils.convertDpToPixelInt(context, 12);
    lp.setMargins(0, 0, 0, bottom);

    if (view != null) {
        view.setLayoutParams(lp);
        view.setHasTransientState(true);
    }

    return view;
}
 
Example 9
Source Project: Noyze   File: CircleVolumePanel.java    License: Apache License 2.0 5 votes vote down vote up
protected Animator shuffle(View target) {
    LOGI(TAG, "shuffle()");
    final int duration = Resources.getSystem().getInteger(android.R.integer.config_mediumAnimTime);
    ObjectAnimator rotation = ObjectAnimator.ofFloat(target, View.TRANSLATION_X, 5, 0, -5, 0, 5, 0, -5, 0, 5, 0, -5, 0, 5, 0);
    rotation.setDuration(duration);
    rotation.setStartDelay(duration / 4);
    target.setHasTransientState(true);
    return rotation;
}
 
Example 10
Source Project: Noyze   File: CircleVolumePanel.java    License: Apache License 2.0 5 votes vote down vote up
protected Animator wiggle(View target) {
    LOGI(TAG, "wiggle()");
    final int duration = Resources.getSystem().getInteger(android.R.integer.config_mediumAnimTime);
    ObjectAnimator rotation = ObjectAnimator.ofFloat(target, View.ROTATION, 5, 0, -5, 0, 5, 0, -5, 0, 5, 0, -5, 0, 5, 0);
    rotation.setDuration(duration);
    rotation.setStartDelay(duration / 4);
    target.setHasTransientState(true);
    return rotation;
}
 
Example 11
private void beforeDataSetChanged() {
  Adapter adapter = adapterView.getAdapter();
  final int firstVisiblePosition = adapterView.getFirstVisiblePosition();
  for (int i = 0, childCount = adapterView.getChildCount(); i < childCount; i++) {
    final int position = firstVisiblePosition + i;
    final long id = adapter.getItemId(position);
    final View child = adapterView.getChildAt(i);
    Rect r = new Rect(child.getLeft(), child.getTop(), child.getRight(), child.getBottom());
    child.setHasTransientState(true);
    viewBounds.put(id, r);
    idToViewMap.put(id, child);
  }
}
 
Example 12
Source Project: letv   File: ViewCompatJB.java    License: Apache License 2.0 4 votes vote down vote up
public static void setHasTransientState(View view, boolean hasTransientState) {
    view.setHasTransientState(hasTransientState);
}
 
Example 13
public static void setTransientState(List<View> views, boolean hasState) {
    for (View view : views)
        view.setHasTransientState(hasState);
}
 
Example 14
Source Project: MiBandDecompiled   File: am.java    License: Apache License 2.0 4 votes vote down vote up
public static void a(View view, boolean flag)
{
    view.setHasTransientState(flag);
}
 
Example 15
public static void setHasTransientState(View view, boolean hasTransientState) {
    view.setHasTransientState(hasTransientState);
}
 
Example 16
public static void setHasTransientState(View view, boolean hasTransientState) {
    view.setHasTransientState(hasTransientState);
}
 
Example 17
public static void setTransientState(List<View> views, boolean hasState) {
    for (View view : views)
        view.setHasTransientState(hasState);
}
 
Example 18
Source Project: V.FlyoutTest   File: ViewCompatJB.java    License: MIT License 4 votes vote down vote up
public static void setHasTransientState(View view, boolean hasTransientState) {
    view.setHasTransientState(hasTransientState);
}
 
Example 19
Source Project: guideshow   File: ViewCompatJB.java    License: MIT License 4 votes vote down vote up
public static void setHasTransientState(View view, boolean hasTransientState) {
    view.setHasTransientState(hasTransientState);
}
 
Example 20
@Override
public void setHasTransientState(@NonNull View view, boolean hasTransientState) {
    view.setHasTransientState(hasTransientState);
}