问:
Query to filter orders according to posted date?
I have requirement where I have to write a query to get something with date filter monthwise like this.

we have can multiple invoices against an order (Each invoice with new posted date)

I have to get records of such invoices which are posted in very first month and for subsequent month's query with new date filter such records should not be part of resultset.

For Example

Now another invoice for the same order posted in February, 2019.

Now when I run this query for January only record with January posted date should appear and when I run this query for February, then this order should not be part of resultset as we have already decided that it will be part of previous month (January) resultset.

I am using following query to get result but it gives correct result for January but for it is again showing same result for February as well. Kindly help in this regard.

```<code>DECLARE @From DATETIME
DECLARE @To DATETIME

SET @From = '2018-01-01 00:00:00.000'
SET @To = '2018-01-30 23:59:59.997'

SELECT *
FROM (
    SELECT s.OrderNumber
        ,i.InvoiceNumber
        ,i.new_PostedDate
        ,i.new_CanceledDate
        ,s.new_OrderStatus
        ,i.StatusCode
        ,s.ModifiedOn
        ,ROW_NUMBER() OVER (
            PARTITION BY s.OrderNumber ORDER BY i.new_PostedDate ASC
            ) AS RowNumber
    FROM SalesOrders s
    INNER JOIN Invoices i ON s.SalesOrderId = i.SalesOrderId
    LEFT JOIN StatusReasonsLookup sl ON i.StatusCode = sl.Id
        AND (i.new_PostedDate >= @From)
        AND (i.new_PostedDate <= @To)
        --Where sl.StatusCodeName  <> 'Canceled'
    ) tblInvoice
WHERE RowNumber = 1
</code>```

答:
I suspect that you want:

```<code>select *
from (
    select
        s.*,
        min(posted_date) over(partition by order_number) first_posted_date
    from salesorders s
) s
where
    s.posted_date = s.first_posted_date
    s.first_posted_date between @from and @to
</code>```

The inner query uses a window min() to recover the first posted_date of each invoice. Then the outer query filters on the first record per group, whose first posted_date matches the filter.

Body:
I have requirement where I have to write a query to get something with date filter monthwise like this.

we have can multiple invoices against an order (Each invoice with new posted date)

I have to get records of such invoices which are posted in very first month and for subsequent month's query with new date filter such records should not be part of resultset.

For Example

Now another invoice for the same order posted in February, 2019.

Now when I run this query for January only record with January posted date should appear and when I run this query for February, then this order should not be part of resultset as we have already decided that it will be part of previous month (January) resultset.

I am using following query to get result but it gives correct result for January but for it is again showing same result for February as well. Kindly help in this regard.

DECLARE @From DATETIME
DECLARE @To DATETIME

SET @From = '2018-01-01 00:00:00.000'
SET @To = '2018-01-30 23:59:59.997'

SELECT *
FROM (
    SELECT s.OrderNumber
        ,i.InvoiceNumber
        ,i.new_PostedDate
        ,i.new_CanceledDate
        ,s.new_OrderStatus
        ,i.StatusCode
        ,s.ModifiedOn
        ,ROW_NUMBER() OVER (
            PARTITION BY s.OrderNumber ORDER BY i.new_PostedDate ASC
            ) AS RowNumber
    FROM SalesOrders s
    INNER JOIN Invoices i ON s.SalesOrderId = i.SalesOrderId
    LEFT JOIN StatusReasonsLookup sl ON i.StatusCode = sl.Id
        AND (i.new_PostedDate >= @From)
        AND (i.new_PostedDate <= @To)
        --Where sl.StatusCodeName  <> 'Canceled'
    ) tblInvoice
WHERE RowNumber = 1

Body:
I suspect that you want:

select *
from (
    select
        s.*,
        min(posted_date) over(partition by order_number) first_posted_date
    from salesorders s
) s
where
    s.posted_date = s.first_posted_date
    s.first_posted_date between @from and @to

The inner query uses a window min() to recover the first posted_date of each invoice. Then the outer query filters on the first record per group, whose first posted_date matches the filter.


来源: stackexchange

问:
Set x XML node to value in Powershell
I have this PowerShell script in which values for an XML-file will be set by the script. This works perfectly fine when all child nodes are uniquely named. However, I'm adapting the XML-file to one where some nodes are repeated. Now I get an error in Powershell.

My question is, how to set the X'th node in XML to a certain value via PowerShell?

In short, my script works like the following:

```<code>cls

[xml] $xml1 = '<Lvl1>
                    <Lvl2>""</Lvl2>
                    <Lvl2>""</Lvl2>
                </Lvl1>'

$xml1.Lvl1.Lvl2='./'

$xml1.Save("text.xml")
</code>```

There is two times the same node (Lvl2), that's why I get the following error in PowerShell: "Cannot set "Lvl2" because only strings can be used as values to set XmlNode properties."

When I remove one (Lvl2) node, the script works like a charm.

Please advice.

答:
```<code>$xml1 = [xml]@'
    <Lvl1>
        <Lvl2>""</Lvl2>
        <Lvl2>""</Lvl2>
    </Lvl1>
'@

$xml1.GetElementsByTagName('Lvl2') | ForEach-Object { $_.InnerText = './' }

$xml1.Save("text.xml")

Get-Content -Path "text.xml" # debugging output
</code>```

Debugging output: .\SO\60280990.ps1

```<code><Lvl1>
  <Lvl2>./</Lvl2>
  <Lvl2>./</Lvl2>
</Lvl1>
</code>```

Above approach works even for a bit more complicated input data e.g. as follows:

```<code>$xml1 = [xml]@'
<root>
    <Lvl1>
        <Lvl2>"a"</Lvl2>
        <Lvl2>"b"</Lvl2>
    </Lvl1>
    <Lvl0>
        <Lvl1>
            <Lvl2>"c"</Lvl2>
            <Lvl2>"d"</Lvl2>
        </Lvl1>
    </Lvl0>
</root>
'@
</code>```

ContentLicense: CC BY-SA 4.0

Title: Set x XML node to value in Powershell

Body:
I have this PowerShell script in which values for an XML-file will be set by the script. This works perfectly fine when all child nodes are uniquely named. However, I'm adapting the XML-file to one where some nodes are repeated. Now I get an error in Powershell.

My question is, how to set the X'th node in XML to a certain value via PowerShell?

In short, my script works like the following:

cls

[xml] $xml1 = '<Lvl1>
                    <Lvl2>""</Lvl2>
                    <Lvl2>""</Lvl2>
                </Lvl1>'

$xml1.Lvl1.Lvl2='./'

$xml1.Save("text.xml")

There is two times the same node (Lvl2), that's why I get the following error in PowerShell: "Cannot set "Lvl2" because only strings can be used as values to set XmlNode properties."

When I remove one (Lvl2) node, the script works like a charm.

Please advice.

Body:
$xml1 = [xml]@'
    <Lvl1>
        <Lvl2>""</Lvl2>
        <Lvl2>""</Lvl2>
    </Lvl1>
'@

$xml1.GetElementsByTagName('Lvl2') | ForEach-Object { $_.InnerText = './' }

$xml1.Save("text.xml")

Get-Content -Path "text.xml" # debugging output

Debugging output: .\SO\60280990.ps1

<Lvl1>
  <Lvl2>./</Lvl2>
  <Lvl2>./</Lvl2>
</Lvl1>

Above approach works even for a bit more complicated input data e.g. as follows:

$xml1 = [xml]@'
<root>
    <Lvl1>
        <Lvl2>"a"</Lvl2>
        <Lvl2>"b"</Lvl2>
    </Lvl1>
    <Lvl0>
        <Lvl1>
            <Lvl2>"c"</Lvl2>
            <Lvl2>"d"</Lvl2>
        </Lvl1>
    </Lvl0>
</root>
'@


问:
ASP.NET MVC model binding child objects
I'm working on ASP.NET MVC 3 application. I have a Comment class that encapsulates a Post class (each comment is associated with a post in the blog), there is an action method for edit a comment as below,

```<code>    [HttpPost]
    [Authorize(Users = admin)]
    public string EditComment(Comment comment)
    {
        //update the comment by calling NHiberante repository methods
    }
</code>```

From javascript I'm posting only the comment object values like comment id, description to the server, so when binding I see the Post property inside the comment object as null and when I do the ModelState.IsValid i'm getting empty errors. My question is how I can bind the post object to the comment? I can pass the post id to the server along with the other values.

Thanks
Vijaya Anand

答:
Provide additional fields

If you want your post instance to be pre-populated as well, you will have to include its required fields as well.

I suspect you're having a post view where user has a form that displays comment fields so they can post a comment on the post.

suppose you have classes as:

```<code>public class Post
{
    public int Id { get; set; }

    [Required]
    public string Title { get; set; }

    public string Content { get; set; }
}

public class Comment
{
    public int Id { get; set; }

    [Required]
    public string Author { get; set; }

    [Required]
    public string Content { get; set; }

    public Post Post { get; set; }
}
</code>```

Usual browser POST

What you would have to do is to add post fields (of hidden type) to your form. I don't know how you created your form whether you're using strong type views or not... Anyway. Your inputs would have to have names:

Post.Id (for the sake of attaching new comment to a particular post

Post.Title (because I've set it as required, but you could put in here whatever dummy text if all you'll be using is Post.Id; Title just needs to be set so your model validation won't fail)

Author - visible (this is comment author)

Content - visible (this is comment content)

Whether you're creating these fields using Html helpers or manually doesn't really matter. Default model binder will be able to create post object instance and your model validation won't fail.

Ajax POST

If you're posting your comments using Ajax you can do the same as described in the previous example and simply use jQuery's .serialize() function that will serialize form fields when calling $.ajax().

But you could as well programmaticaly collect all fields using Javascript and post that data to server just as well. You could simply create a JSON object:

```<code>var comment = {
    Author: $("#Author").val(),
    Content: $("#Content").val(),
    Post: {
        Id: $("#Post_Id").val(),
        Title: $("#Post_Title").val()
    }
};

$.ajax({
    url: "someURL",
    type: "POST",
    data: $.toDictionary(comment),
    success: function(data) {
        // probably get a partial view with comment you can append it to comments
    },
    error: function(xhr, status, err) {
        // process error
    }
});
</code>```

There are 2 things that are being used here and need some explanation:

Ajax error handling can also consume invalid model state errors (model validation failing) and can be accomplished this way.

Converting a complex (multi-level) JSON object has been done by using a special $.toDictionary() plugin that can be found here and provides the ability to simply consume complex JSON objects that are understood by Asp.net MVC default model binder. It wors with dates and lists as well.

ContentLicense: CC BY-SA 3.0

Title: ASP.NET MVC model binding child objects

Body:
I'm working on ASP.NET MVC 3 application. I have a Comment class that encapsulates a Post class (each comment is associated with a post in the blog), there is an action method for edit a comment as below,

    [HttpPost]
    [Authorize(Users = admin)]
    public string EditComment(Comment comment)
    {
        //update the comment by calling NHiberante repository methods
    }

From javascript I'm posting only the comment object values like comment id, description to the server, so when binding I see the Post property inside the comment object as null and when I do the ModelState.IsValid i'm getting empty errors. My question is how I can bind the post object to the comment? I can pass the post id to the server along with the other values.

Thanks
Vijaya Anand

Body:
Provide additional fields

If you want your post instance to be pre-populated as well, you will have to include its required fields as well.

I suspect you're having a post view where user has a form that displays comment fields so they can post a comment on the post.

suppose you have classes as:

public class Post
{
    public int Id { get; set; }

    [Required]
    public string Title { get; set; }

    public string Content { get; set; }
}

public class Comment
{
    public int Id { get; set; }

    [Required]
    public string Author { get; set; }

    [Required]
    public string Content { get; set; }

    public Post Post { get; set; }
}

Usual browser POST

What you would have to do is to add post fields (of hidden type) to your form. I don't know how you created your form whether you're using strong type views or not... Anyway. Your inputs would have to have names:

Post.Id (for the sake of attaching new comment to a particular post

Post.Title (because I've set it as required, but you could put in here whatever dummy text if all you'll be using is Post.Id; Title just needs to be set so your model validation won't fail)

Author - visible (this is comment author)

Content - visible (this is comment content)

Whether you're creating these fields using Html helpers or manually doesn't really matter. Default model binder will be able to create post object instance and your model validation won't fail.

Ajax POST

If you're posting your comments using Ajax you can do the same as described in the previous example and simply use jQuery's .serialize() function that will serialize form fields when calling $.ajax().

But you could as well programmaticaly collect all fields using Javascript and post that data to server just as well. You could simply create a JSON object:

var comment = {
    Author: $("#Author").val(),
    Content: $("#Content").val(),
    Post: {
        Id: $("#Post_Id").val(),
        Title: $("#Post_Title").val()
    }
};

$.ajax({
    url: "someURL",
    type: "POST",
    data: $.toDictionary(comment),
    success: function(data) {
        // probably get a partial view with comment you can append it to comments
    },
    error: function(xhr, status, err) {
        // process error
    }
});

There are 2 things that are being used here and need some explanation:

Ajax error handling can also consume invalid model state errors (model validation failing) and can be accomplished this way.

Converting a complex (multi-level) JSON object has been done by using a special $.toDictionary() plugin that can be found here and provides the ability to simply consume complex JSON objects that are understood by Asp.net MVC default model binder. It wors with dates and lists as well.


问:
How do I prevent jsp scriptlet from execution?
when i run the program, both statements inside the condition got executed</p>

```<code><script>
    if (true) {
       <%System.out.println("true");%>
    } else {
       <%System.out.println("false");%>
    }
</script>
</code>```

答:
Java and JavaScript are completely different—their similar names notwithstanding.  They have as much in common as the words “pain” and “painting”.

JSP code is executed in the server, before the user ever receives the page.

JavaScript is executed on the end user’s computer, after the server has executed all of its code, assembled the page, and delivered it to the user’s browser.

The server doesn’t process any JSP content other than JSP tags, or known tag libraries like JSTL.  That
```

<p>…because the JavaScript was not processed in any way on the server side.  JavaScript in HTML pages runs in browsers, not on the server.</p>

<p>You probably want something like this:</p>

```<%
    if (true) {
       System.out.println("true");
    } else {
       System.out.println("false");
    }
%>
```

Not that the above does not need to be in a

Body:
Java and JavaScript are completely different—their similar names notwithstanding.  They have as much in common as the words “pain” and “painting”.

JSP code is executed in the server, before the user ever receives the page.

JavaScript is executed on the end user’s computer, after the server has executed all of its code, assembled the page, and delivered it to the user’s browser.

The server doesn’t process any JSP content other than JSP tags, or known tag libraries like JSTL.  That <script> element and its content is simply added to the final page as is, without ever being interpreted or executed.

In other words, if (true) means nothing to the server.  It ignores the JavaScript, and only executes the <%…%> parts.

When the page is finally delivered to the browser, the source will contain this:

<script>
    if (true) {

    } else {

    }
</script>

…because the JavaScript was not processed in any way on the server side.  JavaScript in HTML pages runs in browsers, not on the server.

You probably want something like this:

<%
    if (true) {
       System.out.println("true");
    } else {
       System.out.println("false");
    }
%>

Not that the above does not need to be in a <script> element, and in fact it would not make sense to put it in one—because <script> contains JavaScript and this is server side Java code, not JavaScript.


问:
MFC: How to create options dialog with listbox and multiple pages?
Developing using Visual Studio 2010 C++ and MFC.  I want to create an options (preferences/settings) dialog box that can display several options.  After considering many different options dialog box UIs I think I like the listbox-with-multiple-pages-style similar to visual studio's option dialog box (but I don't need the treeview, a list box is fine).

What's a good way to implement this?  Do I use a CListBox and then handle the selection event to load up the individual pages?  I'm new to MFC, what would the individual pages even be? Something like a panel?  Ideally I would design them in the resource editor and then be able to load them up.

答:
Take a look at http://www.codeproject.com/KB/dialog/embedded_dialog.aspx for one possible way of doing this.

The individual property pages can be designed as dialogs in the resource editor, and then the relevant page can be displayed in your main dialog depending on the selection in the list box, by handling the LVN_ITEMCHANGED message.


问:
Integrate EasyButton, Geoman with ngx-leaflet
I am using raw leaflet.js in my Angular Application which depends on some leaflet plugins like EasyButton, Geoman, Distortable Image. ngx-leaflet looks cool and simple. So I've decided to migrate to ngx-leaflet. But I am sure if it is possible to integrate these plugins with the library. If so provide some guidance.</p>

答:
Answering my own question.
Here are the steps I followed to get geoman working with ngx-leaflet.

Install geoman npm i @geoman-io/leaflet-geoman-free. refer geoman github page

Import geoman css in styles.scss @import '../node_modules/@geoman-io/leaflet-geoman-free/dist/leaflet-geoman.css';

Import geoman in the component import '@geoman-io/leaflet-geoman-free';
Done.

then use it like this

```<code>this.map.pm.addControls({
      position: 'topleft',
      drawCircle: false,
      drawCircleMarker: false,
      drawPolyline: true,
      drawRectangle: false,
      drawPolygon: true,
      editMode: false,
      dragMode: false,
      cutPolygon: false,
      removalMode: false,
      drawMarker: false
    });
</code>```

Body:
Answering my own question.
Here are the steps I followed to get geoman working with ngx-leaflet.

Install geoman npm i @geoman-io/leaflet-geoman-free. refer geoman github page

Import geoman css in styles.scss @import '../node_modules/@geoman-io/leaflet-geoman-free/dist/leaflet-geoman.css';

Import geoman in the component import '@geoman-io/leaflet-geoman-free';
Done.

then use it like this

this.map.pm.addControls({
      position: 'topleft',
      drawCircle: false,
      drawCircleMarker: false,
      drawPolyline: true,
      drawRectangle: false,
      drawPolygon: true,
      editMode: false,
      dragMode: false,
      cutPolygon: false,
      removalMode: false,
      drawMarker: false
    });


问:
How to implement flip animation for ViewPager in Android (GIF Added)
Edited: Adding the XML layout of my view (How to achieve flip animation android (GIF Added))

TopLayout : ivImage
BottomLayout : layoutL

I want to implement Vertical ViewPager as shown in the GIF image below. Implemented Vertical ViewPager but can't implement Flip Animation

Any Code snippet or Library

My Customized VerticalViewPager Class Implemented Vertical ViewPager with normal animation Motionevent in VerticalPageTransformer

```<code>public class VViewPager2 extends ViewPager {

String TAG = "VViewPager";

float x = 0;
float mStartDragX = 0;
private static final float SWIPE_X_MIN_THRESHOLD = 15; // Decide this magical number as per your requirement

private boolean disableSwipe = false;

public VViewPager2(@NonNull Context context) {
    super(context);
    init();
}

public VViewPager2(@NonNull Context context, @Nullable AttributeSet attrs) {
    super(context, attrs);
    init();
    // setPageTransformer(true, new PagerTransformer());
}

private void init() {
    // The majority of the magic happens here
    setPageTransformer(true, new VerticalPageTransformer());
    // The easiest way to get rid of the overscroll drawing that happens on the left and right
    setOverScrollMode(OVER_SCROLL_NEVER);
}

@Override
public boolean onTouchEvent(MotionEvent event) {
    if (getAdapter() != null) {
        if (getCurrentItem() >= 0 || getCurrentItem() < getAdapter().getCount()) {
            swapXY(event);
            final int action = event.getAction();
            switch (action & MotionEventCompat.ACTION_MASK) {
                case MotionEvent.ACTION_MOVE:
                    break;
                case MotionEvent.ACTION_UP:
                    mStartDragX = event.getX();
                    if (x < mStartDragX
                            && (mStartDragX - x > SWIPE_X_MIN_THRESHOLD)
                            && getCurrentItem() > 0) {
                        Log.i(TAG, "down " + x + " : " + mStartDragX + " : " + (mStartDragX - x));
                        setCurrentItem(getCurrentItem() - 1, true);
                        return true;
                    } else if (x > mStartDragX
                            && (x - mStartDragX > SWIPE_X_MIN_THRESHOLD)
                            && getCurrentItem() < getAdapter().getCount() - 1) {
                        Log.i(TAG, "up " + x + " : " + mStartDragX + " : " + (x - mStartDragX));
                        mStartDragX = 0;
                        setCurrentItem(getCurrentItem() + 1, true);
                        return true;
                    }
                    break;
            }
        } else {
            mStartDragX = 0;
        }
        swapXY(event);
        return !disableSwipe && super.onTouchEvent(swapXY(event));
    }
    return false;
}

@Override
public boolean onInterceptTouchEvent(MotionEvent event) {
    boolean intercepted = !disableSwipe && super.onInterceptTouchEvent(swapXY(event));
    if ((event.getAction() & MotionEventCompat.ACTION_MASK) == MotionEvent.ACTION_DOWN) {
        x = event.getX();
    }
    swapXY(event); // return touch coordinates to original reference frame for any child views
    return intercepted;
}

public void disableScroll(Boolean disableSwipe) {
    //When disable = true not work the scroll and when disble = false work the scroll
    this.disableSwipe = disableSwipe;
    Log.d(TAG, "disableSwipe " + disableSwipe);
}

/**
 * Swaps the X and Y coordinates of your touch event.
 */
private MotionEvent swapXY(MotionEvent ev) {
    float width = getWidth();
    float height = getHeight();

    float newX = (ev.getY() / height) * width;
    float newY = (ev.getX() / width) * height;

    ev.setLocation(newX, newY);

    return ev;
}

private class VerticalPageTransformer implements PageTransformer {
    private static final float MIN_SCALE = 0.75f;

    @Override
    public void transformPage(@NonNull View view, float position) {

        if (position < -1) { // [-Infinity,-1)
            // This page is way off-screen to the left.
            view.setAlpha(0);

        } else if (position <= 1) { // [-1,1]
            view.setAlpha(1);

            // Counteract the default slide transition
            view.setTranslationX(-position * view.getWidth());
            // set Y position to swipe in from top
            float yPosition = position * view.getHeight();
            view.setTranslationY(yPosition);

            // Scale the page down (between MIN_SCALE and 1)
            float scaleFactor = MIN_SCALE + (1 - MIN_SCALE) * (1 - Math.abs(position));
            view.setScaleX(scaleFactor);
            view.setScaleY(scaleFactor);

            ScaleAnimation flipDown = new ScaleAnimation(1.0f, 1.0f, -1.0f, 0.0f, 1, 1);
            flipDown.setDuration(500);
            flipDown.setFillAfter(true); // If fillAfter is true, the transformation that this animation performed will persist when it is finished.
            // view.startAnimation(flipDown);

        } else if (position <= 0) { // [-1,0]
            // Use the default slide transition when moving to the left page
            view.setAlpha(1);
            // Counteract the default slide transition
            view.setTranslationX(view.getWidth() * -position);

            //set Y position to swipe in from top
            float yPosition = position * view.getHeight();
            view.setTranslationY(yPosition);
            view.setScaleX(1);
            view.setScaleY(1);

        } else { // (1,+Infinity]
            // This page is way off-screen to the right.
            view.setAlpha(0);
        }
    }
}
</code>```

}

I want to flip the screen between these Layouts From TOP & Bottom

```<code><androidx.cardview.widget.CardView
            app:cardCornerRadius="6dp"
            app:cardPreventCornerOverlap="true"
            app:cardUseCompatPadding="true"
            app:cardBackgroundColor="@color/White"
            android:layout_width="match_parent"
            android:layout_height="match_parent">

            <ImageView
                android:id="@+id/ivImage"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:contentDescription="@string/activity_images"
                android:scaleType="fitXY" />

            <LinearLayout
                android:id="@+id/layoutL"
                android:layout_weight="5.5"
                android:layout_marginStart="10dp"
                android:layout_marginEnd="10dp"
                android:layout_marginTop="8dp"
                android:orientation="vertical"
                android:layout_width="match_parent"
                android:layout_height="0dp">

                <TextView
                    android:id="@+id/tvTTitle"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:gravity="center_vertical"
                    android:padding="4dp"
                    android:textStyle="bold"
                    android:text="@string/Topic_Title"
                    android:textColor="@color/Black"
                    android:textSize="20sp" />

                <TextView
                    android:id="@+id/postDetails"
                    android:textAllCaps="false"
                    android:text="text"
                    android:textSize="12sp"
                    android:layout_marginStart="4dp"
                    android:textStyle="normal"
                    android:textColor="@color/Silver"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"/>

                <TextView
                    android:id="@+id/tvTopicDesc"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:padding="4dp"
                    android:lineSpacingExtra="2dp"
                    android:text="@string/invalid_email_contactno"
                    android:textAllCaps="false"
                    android:textColor="#6D6D6D"
                    android:textSize="15sp" />

            </LinearLayout>

        </androidx.cardview.widget.CardView>
</code>```

I want to create a layout like a given GIF, I tried so many animations but not worked perfectly for me.

答:
Try below solution and set yourSecondView as gone in Xml.

```<code>yourButton.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View view) {
        final ObjectAnimator oa1 = ObjectAnimator.ofFloat(yourFirstView, "scaleY", 1f, 0f);
        final ObjectAnimator oa2 = ObjectAnimator.ofFloat(yourSecondView, "scaleY", 0f, 1f);
        oa1.setInterpolator(new DecelerateInterpolator());
        oa1.setDuration(1000);
        oa2.setInterpolator(new AccelerateDecelerateInterpolator());
        oa2.setDuration(1000);
        oa1.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
                super.onAnimationEnd(animation);
                yourFirstView.setVisibility(View.GONE);
                yourSecondView.setVisibility(View.VISIBLE);
                oa2.start();
            }
        });
        oa1.start();
    }
});
</code>```

Output

I hope this can help you!

Body:
Edited: Adding the XML layout of my view (How to achieve flip animation android (GIF Added))

TopLayout : ivImage
BottomLayout : layoutL

I want to implement Vertical ViewPager as shown in the GIF image below. Implemented Vertical ViewPager but can't implement Flip Animation

Any Code snippet or Library

My Customized VerticalViewPager Class Implemented Vertical ViewPager with normal animation Motionevent in VerticalPageTransformer

public class VViewPager2 extends ViewPager {

String TAG = "VViewPager";

float x = 0;
float mStartDragX = 0;
private static final float SWIPE_X_MIN_THRESHOLD = 15; // Decide this magical number as per your requirement

private boolean disableSwipe = false;

public VViewPager2(@NonNull Context context) {
    super(context);
    init();
}

public VViewPager2(@NonNull Context context, @Nullable AttributeSet attrs) {
    super(context, attrs);
    init();
    // setPageTransformer(true, new PagerTransformer());
}

private void init() {
    // The majority of the magic happens here
    setPageTransformer(true, new VerticalPageTransformer());
    // The easiest way to get rid of the overscroll drawing that happens on the left and right
    setOverScrollMode(OVER_SCROLL_NEVER);
}

@Override
public boolean onTouchEvent(MotionEvent event) {
    if (getAdapter() != null) {
        if (getCurrentItem() >= 0 || getCurrentItem() < getAdapter().getCount()) {
            swapXY(event);
            final int action = event.getAction();
            switch (action & MotionEventCompat.ACTION_MASK) {
                case MotionEvent.ACTION_MOVE:
                    break;
                case MotionEvent.ACTION_UP:
                    mStartDragX = event.getX();
                    if (x < mStartDragX
                            && (mStartDragX - x > SWIPE_X_MIN_THRESHOLD)
                            && getCurrentItem() > 0) {
                        Log.i(TAG, "down " + x + " : " + mStartDragX + " : " + (mStartDragX - x));
                        setCurrentItem(getCurrentItem() - 1, true);
                        return true;
                    } else if (x > mStartDragX
                            && (x - mStartDragX > SWIPE_X_MIN_THRESHOLD)
                            && getCurrentItem() < getAdapter().getCount() - 1) {
                        Log.i(TAG, "up " + x + " : " + mStartDragX + " : " + (x - mStartDragX));
                        mStartDragX = 0;
                        setCurrentItem(getCurrentItem() + 1, true);
                        return true;
                    }
                    break;
            }
        } else {
            mStartDragX = 0;
        }
        swapXY(event);
        return !disableSwipe && super.onTouchEvent(swapXY(event));
    }
    return false;
}

@Override
public boolean onInterceptTouchEvent(MotionEvent event) {
    boolean intercepted = !disableSwipe && super.onInterceptTouchEvent(swapXY(event));
    if ((event.getAction() & MotionEventCompat.ACTION_MASK) == MotionEvent.ACTION_DOWN) {
        x = event.getX();
    }
    swapXY(event); // return touch coordinates to original reference frame for any child views
    return intercepted;
}

public void disableScroll(Boolean disableSwipe) {
    //When disable = true not work the scroll and when disble = false work the scroll
    this.disableSwipe = disableSwipe;
    Log.d(TAG, "disableSwipe " + disableSwipe);
}

/**
 * Swaps the X and Y coordinates of your touch event.
 */
private MotionEvent swapXY(MotionEvent ev) {
    float width = getWidth();
    float height = getHeight();

    float newX = (ev.getY() / height) * width;
    float newY = (ev.getX() / width) * height;

    ev.setLocation(newX, newY);

    return ev;
}

private class VerticalPageTransformer implements PageTransformer {
    private static final float MIN_SCALE = 0.75f;

    @Override
    public void transformPage(@NonNull View view, float position) {

        if (position < -1) { // [-Infinity,-1)
            // This page is way off-screen to the left.
            view.setAlpha(0);

        } else if (position <= 1) { // [-1,1]
            view.setAlpha(1);

            // Counteract the default slide transition
            view.setTranslationX(-position * view.getWidth());
            // set Y position to swipe in from top
            float yPosition = position * view.getHeight();
            view.setTranslationY(yPosition);

            // Scale the page down (between MIN_SCALE and 1)
            float scaleFactor = MIN_SCALE + (1 - MIN_SCALE) * (1 - Math.abs(position));
            view.setScaleX(scaleFactor);
            view.setScaleY(scaleFactor);

            ScaleAnimation flipDown = new ScaleAnimation(1.0f, 1.0f, -1.0f, 0.0f, 1, 1);
            flipDown.setDuration(500);
            flipDown.setFillAfter(true); // If fillAfter is true, the transformation that this animation performed will persist when it is finished.
            // view.startAnimation(flipDown);

        } else if (position <= 0) { // [-1,0]
            // Use the default slide transition when moving to the left page
            view.setAlpha(1);
            // Counteract the default slide transition
            view.setTranslationX(view.getWidth() * -position);

            //set Y position to swipe in from top
            float yPosition = position * view.getHeight();
            view.setTranslationY(yPosition);
            view.setScaleX(1);
            view.setScaleY(1);

        } else { // (1,+Infinity]
            // This page is way off-screen to the right.
            view.setAlpha(0);
        }
    }
}

}

I want to flip the screen between these Layouts From TOP & Bottom

<androidx.cardview.widget.CardView
            app:cardCornerRadius="6dp"
            app:cardPreventCornerOverlap="true"
            app:cardUseCompatPadding="true"
            app:cardBackgroundColor="@color/White"
            android:layout_width="match_parent"
            android:layout_height="match_parent">

            <ImageView
                android:id="@+id/ivImage"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:contentDescription="@string/activity_images"
                android:scaleType="fitXY" />

            <LinearLayout
                android:id="@+id/layoutL"
                android:layout_weight="5.5"
                android:layout_marginStart="10dp"
                android:layout_marginEnd="10dp"
                android:layout_marginTop="8dp"
                android:orientation="vertical"
                android:layout_width="match_parent"
                android:layout_height="0dp">

                <TextView
                    android:id="@+id/tvTTitle"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:gravity="center_vertical"
                    android:padding="4dp"
                    android:textStyle="bold"
                    android:text="@string/Topic_Title"
                    android:textColor="@color/Black"
                    android:textSize="20sp" />

                <TextView
                    android:id="@+id/postDetails"
                    android:textAllCaps="false"
                    android:text="text"
                    android:textSize="12sp"
                    android:layout_marginStart="4dp"
                    android:textStyle="normal"
                    android:textColor="@color/Silver"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"/>

                <TextView
                    android:id="@+id/tvTopicDesc"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:padding="4dp"
                    android:lineSpacingExtra="2dp"
                    android:text="@string/invalid_email_contactno"
                    android:textAllCaps="false"
                    android:textColor="#6D6D6D"
                    android:textSize="15sp" />

            </LinearLayout>

        </androidx.cardview.widget.CardView>

I want to create a layout like a given GIF, I tried so many animations but not worked perfectly for me.

Body:
Try below solution and set yourSecondView as gone in Xml.

yourButton.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View view) {
        final ObjectAnimator oa1 = ObjectAnimator.ofFloat(yourFirstView, "scaleY", 1f, 0f);
        final ObjectAnimator oa2 = ObjectAnimator.ofFloat(yourSecondView, "scaleY", 0f, 1f);
        oa1.setInterpolator(new DecelerateInterpolator());
        oa1.setDuration(1000);
        oa2.setInterpolator(new AccelerateDecelerateInterpolator());
        oa2.setDuration(1000);
        oa1.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
                super.onAnimationEnd(animation);
                yourFirstView.setVisibility(View.GONE);
                yourSecondView.setVisibility(View.VISIBLE);
                oa2.start();
            }
        });
        oa1.start();
    }
});

Output

I hope this can help you!


问:
Using SQL to exclude a word that comes after a phrase
This issue might be a bit too complicated for SQL to handle, but since I have pretty intermediate SQL skills perhaps someone more well-versed in SQL than me will know how to fix the below issue.

I am looking to isolate observations that mention a keyword that occur after a phrase. An example would be like below: For variable FREE_TEXT I want to isolate where the word orange is said AFTER the phrase Excluding This:

FREE_TEXT=
"Including This:

The best fruit is an apple

Excluding This:

The worst fruit is an orange"

Technically I could just do where FREE_TEXT not like '%orange%' but that is not what I am looking for. I am looking to specifically isolate for when a word is said AFTER the phrase Excluding This.

Anyone have ideas?

答:
Is this what you want?</p>

```<code>where free_text like '%Excluding this%orange%'
</code>```

Body:
Is this what you want?

where free_text like '%Excluding this%orange%'


问:
Google Admin SDK in Calendar Audit Activity
I have use google-admin-sdk for calendar activity reports. I've researched some responses and I didn't understand some parameters. https://developers.google.com/admin-sdk/reports/v1/appendix/activity/calendar you can review this document.
According to Google these parameters are the start and end time of the event but I don't know where the 11-digit timestamp is used?

答:
The two parameters are used to indicate the start time and the end time of an event.

The start_time parameter is the number in seconds representing the start time for the event.

The end_time parameter is the number in seconds representing the end time for the event.

In order to obtain the date you can either:

use the following code snippet:

```<code>function findDate() {
  var seconds = "NO_OF_SECONDS";
  var date = new Date(seconds * 1000);
  console.log(date);
}
</code>```

use an online converter which will give you the an approximate date for the number of seconds mentioned;

Body:
The two parameters are used to indicate the start time and the end time of an event.

The start_time parameter is the number in seconds representing the start time for the event.

The end_time parameter is the number in seconds representing the end time for the event.

In order to obtain the date you can either:

use the following code snippet:

function findDate() {
  var seconds = "NO_OF_SECONDS";
  var date = new Date(seconds * 1000);
  console.log(date);
}

use an online converter which will give you the an approximate date for the number of seconds mentioned;


问:
Limit number of results in object.map
I'm importing the spaces object. I only want to render 3 of the Card components which requires attributes from spaces. Imagine a 'featured' section on a website displaying only a few items from a larger list.

With the below code I'm currently rendering all of the results instead of 3, am I using the correct methods? And if so, is the order wrong?

```<code><div className="row">

          {spaces.map(item => {

            for (var i = 0; i < 2; i++) {

              return (

                <div className="col-sm-12 col-md-6 col-lg-4" key={item.id}>

                  <Card
                    town={item.town}
                    name={item.name}
                    net={item.net}
                    day={item.day}
                    night={item.night}
                    dog={item.dog}
                    parking={item.parking}
                    image={item.image}
                  />

                </div>
              )
            }

          })}

</div>
</code>```

答:
spaces.map will iterate over all elements in spaces and produce a new array, with a new value for each existing item.

The loop inside the map callback is useless since you are returning in the first iteration, terminating the loop immediately.

If you only want to get the first 3 spaces, then you can .slice the array:

```<code><div className="row">
          {spaces.slice(0,3).map(item => {
              return (
                <div className="col-sm-12 col-md-6 col-lg-4" key={item.id}>
                  <Card
                    town={item.town}
                    name={item.name}
                    net={item.net}
                    day={item.day}
                    night={item.night}
                    dog={item.dog}
                    parking={item.parking}
                    image={item.image}
                  />
                </div>
              )
          })}
</div>
</code>```

Title: Limit number of results in object.map

Body:
I'm importing the spaces object. I only want to render 3 of the Card components which requires attributes from spaces. Imagine a 'featured' section on a website displaying only a few items from a larger list.

With the below code I'm currently rendering all of the results instead of 3, am I using the correct methods? And if so, is the order wrong?

          {spaces.map(item => {

            for (var i = 0; i < 2; i++) {

              return (

                  <Card
                    town={item.town}
                    name={item.name}
                    net={item.net}
                    day={item.day}
                    night={item.night}
                    dog={item.dog}
                    parking={item.parking}
                    image={item.image}
                  />

              )
            }

          })}

Body:
spaces.map will iterate over all elements in spaces and produce a new array, with a new value for each existing item.

The loop inside the map callback is useless since you are returning in the first iteration, terminating the loop immediately.

If you only want to get the first 3 spaces, then you can .slice the array:

<div className="row">
          {spaces.slice(0,3).map(item => {
              return (
                <div className="col-sm-12 col-md-6 col-lg-4" key={item.id}>
                  <Card
                    town={item.town}
                    name={item.name}
                    net={item.net}
                    day={item.day}
                    night={item.night}
                    dog={item.dog}
                    parking={item.parking}
                    image={item.image}
                  />
                </div>
              )
          })}
</div>


问:
Vertical Axis labels set to middle in Google Visualization Chart
I am using Google's visualization bubble chart. I need to align the labels in the vertical axis to middle. See the image below please. Something like this. These month names needs to be in between the major gridlines.

Here is the options I added for this bubble chart, but it does show next to axis line only.

```<code>var options = {
        sizeAxis: {
            maxSize: 7,
            minSize: 1
        },
        animation: {
            duration: 1500,
            easing: 'in',
            startup: true
        },

        fontSize: 10,
        legend: 'none',
        height: 230,
        chartArea: { left: "20%", right: 0, top: 0, width: "70%", height: "200px" },

        bubble: { stroke: '#ffca18', opacity: 1 },
        colors: ['#ffca18', '#ffca18'],
        tooltip: {
            trigger: 'none'
        },
        hAxis: {
            ticks: [
                { v: 2015, f: '2015' },
                { v: 2016, f: '2016' },
                { v: 2017, f: '2017' },
                { v: 2018, f: '2018' },
                { v: 2019, f: '2019' },
                { v: 2019, f: '2020' }
            ],

            gridlines: { color: '#dedede' },
            minorGridlines: { color: '#f7f7f7', count: 3 },
            textStyle: { color: '#5f5f5f' }
        },
        vAxis: {
            ticks: [
                { v: 1, f: 'May' },
                { v: 2, f: 'April' },
                { v: 3, f: 'March' },
                { v: 4, f: 'February' },
                { v: 5, f: 'January' }
            ],
            gridlines: { color: '#dedede' },
            textStyle: { color: '#5f5f5f' },
            viewWindowMode: 'explicit',
            viewWindow: {
                min: 1,
                max: 7
            }
        }
    };
</code>```

答:
we can move the labels manually, on the chart's 'ready' event,

or in this case, the 'animationfinish' event, or both.

the chart has a method for getChartLayoutInterface()

this returns an object we can use to get the placement of various chart elements.

we can get the placement of the gridlines,

and move the labels in between.

```<code>function moveYAxisLabels() {
  var chartLayout = chart.getChartLayoutInterface();
  var labels = chart.getContainer().getElementsByTagName('text');
  var labelIndex = -1;
  Array.prototype.forEach.call(labels, function(label) {
    if (label.getAttribute('text-anchor') === 'end') {
      labelIndex++;
      labelHeight = chartLayout.getBoundingBox('vAxis#0#label#' + labelIndex).height;
      labelBottom = chartLayout.getBoundingBox('vAxis#0#gridline#' + labelIndex).top;
      labelTop = chartLayout.getBoundingBox('vAxis#0#gridline#' + (labelIndex + 1)).top;
      label.setAttribute('y', labelBottom - ((labelBottom - labelTop) / 2) + Math.floor(labelHeight / 2));
    }
  });
}
</code>```

see following working snippet...

google.charts.load('current', {
  packages: ['corechart']
}).then(function () {
  var data = new google.visualization.DataTable({
    "cols": [
      {"label": "id", "type": "string"},
      {"label": "x", "type": "number"},
      {"label": "y", "type": "number"}
    ],
    "rows": [
      {"c":[{"v": ""}, {"v": 2015}, {"v": 1}]},
      {"c":[{"v": ""}, {"v": 2016}, {"v": 2}]},
      {"c":[{"v": ""}, {"v": 2017}, {"v": 3}]},
      {"c":[{"v": ""}, {"v": 2018}, {"v": 4}]},
      {"c":[{"v": ""}, {"v": 2019}, {"v": 5}]},
      {"c":[{"v": ""}, {"v": 2020}, {"v": 6}]}
    ]
  });

  var chart = new google.visualization.BubbleChart(document.getElementById('chart_div'));

  google.visualization.events.addListener(chart, 'ready', moveYAxisLabels);
  google.visualization.events.addListener(chart, 'animationfinish', moveYAxisLabels);

  function moveYAxisLabels() {
    var chartLayout = chart.getChartLayoutInterface();
    var labels = chart.getContainer().getElementsByTagName('text');
    var labelIndex = -1;
    Array.prototype.forEach.call(labels, function(label) {
      if (label.getAttribute('text-anchor') === 'end') {
        labelIndex++;
        labelHeight = chartLayout.getBoundingBox('vAxis#0#label#' + labelIndex).height;
        labelBottom = chartLayout.getBoundingBox('vAxis#0#gridline#' + labelIndex).top;
        labelTop = chartLayout.getBoundingBox('vAxis#0#gridline#' + (labelIndex + 1)).top;
        label.setAttribute('y', labelBottom - ((labelBottom - labelTop) / 2) + Math.floor(labelHeight / 2));
      }
    });
  }

  var options = {
    sizeAxis: {
      maxSize: 7,
      minSize: 1
    },
    animation: {
      duration: 1500,
      easing: 'in',
      startup: true
    },
    fontSize: 10,
    legend: 'none',
    height: 230,
    chartArea: {
      bottom: 48,
      left: 200,
      right: 18,
      top: 18,
      width: '100%',
      height: '100%'
    },
    bubble: { stroke: '#ffca18', opacity: 1 },
    colors: ['#ffca18', '#ffca18'],
    tooltip: {
      trigger: 'none'
    },
    hAxis: {
      ticks: [
        { v: 2015, f: '2015' },
        { v: 2016, f: '2016' },
        { v: 2017, f: '2017' },
        { v: 2018, f: '2018' },
        { v: 2019, f: '2019' },
        { v: 2020, f: '2020' }
      ],
      gridlines: { color: '#dedede' },
      minorGridlines: { color: '#f7f7f7', count: 3 },
      textStyle: { color: '#5f5f5f' }
    },
    vAxis: {
      ticks: [
        { v: 1, f: 'JUNE' },
        { v: 2, f: 'MAY' },
        { v: 3, f: 'APRIL' },
        { v: 4, f: 'MARCH' },
        { v: 5, f: 'FEBRUARY' },
        { v: 6, f: 'JANUARY' },
        { v: 7, f: '' }
      ],
      gridlines: { color: '#dedede' },
      textStyle: { color: '#5f5f5f' },
      viewWindowMode: 'explicit',
      viewWindow: {
        min: 1,
        max: 7
      }
    }
  };

  chart.draw(data, options);
});```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://www.gstatic.com/charts/loader.js"></script>
<div id="chart_div"></div></code>```

the only issue here is the animation,

the chart will move the labels on 'ready',

then we move them back on 'animationfinish',

so they appear to jump.

you may re-think using animation...

Body:
I am using Google's visualization bubble chart. I need to align the labels in the vertical axis to middle. See the image below please. Something like this. These month names needs to be in between the major gridlines.

Here is the options I added for this bubble chart, but it does show next to axis line only.

var options = {
        sizeAxis: {
            maxSize: 7,
            minSize: 1
        },
        animation: {
            duration: 1500,
            easing: 'in',
            startup: true
        },

        fontSize: 10,
        legend: 'none',
        height: 230,
        chartArea: { left: "20%", right: 0, top: 0, width: "70%", height: "200px" },

        bubble: { stroke: '#ffca18', opacity: 1 },
        colors: ['#ffca18', '#ffca18'],
        tooltip: {
            trigger: 'none'
        },
        hAxis: {
            ticks: [
                { v: 2015, f: '2015' },
                { v: 2016, f: '2016' },
                { v: 2017, f: '2017' },
                { v: 2018, f: '2018' },
                { v: 2019, f: '2019' },
                { v: 2019, f: '2020' }
            ],

            gridlines: { color: '#dedede' },
            minorGridlines: { color: '#f7f7f7', count: 3 },
            textStyle: { color: '#5f5f5f' }
        },
        vAxis: {
            ticks: [
                { v: 1, f: 'May' },
                { v: 2, f: 'April' },
                { v: 3, f: 'March' },
                { v: 4, f: 'February' },
                { v: 5, f: 'January' }
            ],
            gridlines: { color: '#dedede' },
            textStyle: { color: '#5f5f5f' },
            viewWindowMode: 'explicit',
            viewWindow: {
                min: 1,
                max: 7
            }
        }
    };

Body:
we can move the labels manually, on the chart's 'ready' event,

or in this case, the 'animationfinish' event, or both.

the chart has a method for getChartLayoutInterface()

this returns an object we can use to get the placement of various chart elements.

we can get the placement of the gridlines,

and move the labels in between.

function moveYAxisLabels() {
  var chartLayout = chart.getChartLayoutInterface();
  var labels = chart.getContainer().getElementsByTagName('text');
  var labelIndex = -1;
  Array.prototype.forEach.call(labels, function(label) {
    if (label.getAttribute('text-anchor') === 'end') {
      labelIndex++;
      labelHeight = chartLayout.getBoundingBox('vAxis#0#label#' + labelIndex).height;
      labelBottom = chartLayout.getBoundingBox('vAxis#0#gridline#' + labelIndex).top;
      labelTop = chartLayout.getBoundingBox('vAxis#0#gridline#' + (labelIndex + 1)).top;
      label.setAttribute('y', labelBottom - ((labelBottom - labelTop) / 2) + Math.floor(labelHeight / 2));
    }
  });
}

see following working snippet...

google.charts.load('current', {
  packages: ['corechart']
}).then(function () {
  var data = new google.visualization.DataTable({
    "cols": [
      {"label": "id", "type": "string"},
      {"label": "x", "type": "number"},
      {"label": "y", "type": "number"}
    ],
    "rows": [
      {"c":[{"v": ""}, {"v": 2015}, {"v": 1}]},
      {"c":[{"v": ""}, {"v": 2016}, {"v": 2}]},
      {"c":[{"v": ""}, {"v": 2017}, {"v": 3}]},
      {"c":[{"v": ""}, {"v": 2018}, {"v": 4}]},
      {"c":[{"v": ""}, {"v": 2019}, {"v": 5}]},
      {"c":[{"v": ""}, {"v": 2020}, {"v": 6}]}
    ]
  });

  var chart = new google.visualization.BubbleChart(document.getElementById('chart_div'));

  google.visualization.events.addListener(chart, 'ready', moveYAxisLabels);
  google.visualization.events.addListener(chart, 'animationfinish', moveYAxisLabels);

  function moveYAxisLabels() {
    var chartLayout = chart.getChartLayoutInterface();
    var labels = chart.getContainer().getElementsByTagName('text');
    var labelIndex = -1;
    Array.prototype.forEach.call(labels, function(label) {
      if (label.getAttribute('text-anchor') === 'end') {
        labelIndex++;
        labelHeight = chartLayout.getBoundingBox('vAxis#0#label#' + labelIndex).height;
        labelBottom = chartLayout.getBoundingBox('vAxis#0#gridline#' + labelIndex).top;
        labelTop = chartLayout.getBoundingBox('vAxis#0#gridline#' + (labelIndex + 1)).top;
        label.setAttribute('y', labelBottom - ((labelBottom - labelTop) / 2) + Math.floor(labelHeight / 2));
      }
    });
  }

  var options = {
    sizeAxis: {
      maxSize: 7,
      minSize: 1
    },
    animation: {
      duration: 1500,
      easing: 'in',
      startup: true
    },
    fontSize: 10,
    legend: 'none',
    height: 230,
    chartArea: {
      bottom: 48,
      left: 200,
      right: 18,
      top: 18,
      width: '100%',
      height: '100%'
    },
    bubble: { stroke: '#ffca18', opacity: 1 },
    colors: ['#ffca18', '#ffca18'],
    tooltip: {
      trigger: 'none'
    },
    hAxis: {
      ticks: [
        { v: 2015, f: '2015' },
        { v: 2016, f: '2016' },
        { v: 2017, f: '2017' },
        { v: 2018, f: '2018' },
        { v: 2019, f: '2019' },
        { v: 2020, f: '2020' }
      ],
      gridlines: { color: '#dedede' },
      minorGridlines: { color: '#f7f7f7', count: 3 },
      textStyle: { color: '#5f5f5f' }
    },
    vAxis: {
      ticks: [
        { v: 1, f: 'JUNE' },
        { v: 2, f: 'MAY' },
        { v: 3, f: 'APRIL' },
        { v: 4, f: 'MARCH' },
        { v: 5, f: 'FEBRUARY' },
        { v: 6, f: 'JANUARY' },
        { v: 7, f: '' }
      ],
      gridlines: { color: '#dedede' },
      textStyle: { color: '#5f5f5f' },
      viewWindowMode: 'explicit',
      viewWindow: {
        min: 1,
        max: 7
      }
    }
  };

  chart.draw(data, options);
});

<script src="https://www.gstatic.com/charts/loader.js"></script>
<div id="chart_div"></div>

the only issue here is the animation,

the chart will move the labels on 'ready',

then we move them back on 'animationfinish',

so they appear to jump.

you may re-think using animation...


问:
Redirection problem from Springboot to Angular
Our team make a web application with Angular frontend and Springboot backend. The procurer asked Google Authentication in case of user login. On the login component there is an anchor tag, after a click the google page jump up and we can choose our profile. After that the Google send the user data to Springboot, where it validates that and then it creates a token.

My problem is in Angular we use HashLocationStrategy, there is an auth component with this url:
http://localhost:4200/#/auth, where the token in route parameters is waited. In normal way it would look like "http://localhost:4200/#/auth?token=25jlsjflsfdlslfj....".
In Springboot there is also a variable: public static final String ALTERNATIVE_REDIRECT_URI = "http://localhost:4200/#/auth";
But it can't work with #, because with these settings the Spring sends back the token to the basic route, for a moment the ?token=..... is shown on the url and after the page is rerendered. Without the HashLocationStrategy it works well (http://localhost:4200/auth). Could you recommend a solution? How do I need to declare the Url in Springboot?

答:
Answer

Angular runs its code in a patched zone where addEventListener(), setTimeout(), and other async APIs are patched to notify Angular when async action has happened to rerun change detection. This makes change detection quite efficient. When code is called that somehow circuments Angulars zone, Angulars change detection doesn't kick in. If a method (even one from an Angular component or similar) is called from code that was invoked outside Angulars zone, everything runs outside the zone until this event is fully processed. With zone.run(...) you force execution back into Angulars zone.

visit here


问:
compareTo() function in Java
I have written the code below

```<code>import java.util.*;
class compare{
    public static void main(String []args){
        String s1="java";
        String s2="javaProgramming";
        System.out.println(s1.compareTo(s2));
    }
}
</code>```

The output for this code is -11. Since there is no character for termination of string in java, which character in "java" is being compared with 'P' in "javaProgramming"?

答:
The 'P' character is not compared to anything in the first String.

It only compares the first 4 characters of the 2 Strings, which are equal to each other.

Then it returns the length of the first String minus the length of the second String.

```<code>public int compareTo(String anotherString) {
    int len1 = value.length;
    int len2 = anotherString.value.length;
    int lim = Math.min(len1, len2);
    char v1[] = value;
    char v2[] = anotherString.value;

    int k = 0;
    while (k < lim) {
        char c1 = v1[k];
        char c2 = v2[k];
        if (c1 != c2) {
            return c1 - c2;
        }
        k++;
    }
    return len1 - len2;
}
</code>```

Since the second String is longer, and the first String is contained in the second, returning any negative value will do, since the shorter String should come first in lexicographical order.

Title: compareTo() function in Java

Body:
I have written the code below

import java.util.*;
class compare{
    public static void main(String []args){
        String s1="java";
        String s2="javaProgramming";
        System.out.println(s1.compareTo(s2));
    }
}

The output for this code is -11. Since there is no character for termination of string in java, which character in "java" is being compared with 'P' in "javaProgramming"?

Body:
The 'P' character is not compared to anything in the first String.

It only compares the first 4 characters of the 2 Strings, which are equal to each other.

Then it returns the length of the first String minus the length of the second String.

public int compareTo(String anotherString) {
    int len1 = value.length;
    int len2 = anotherString.value.length;
    int lim = Math.min(len1, len2);
    char v1[] = value;
    char v2[] = anotherString.value;

    int k = 0;
    while (k < lim) {
        char c1 = v1[k];
        char c2 = v2[k];
        if (c1 != c2) {
            return c1 - c2;
        }
        k++;
    }
    return len1 - len2;
}

Since the second String is longer, and the first String is contained in the second, returning any negative value will do, since the shorter String should come first in lexicographical order.


问:
ReactJS setState with object and array
I want to have a data structure in terms of array
e.g.

```<code>data[0]
  title:"ABC"
  photo: "./123.jpg"
  summ: "text text test"
data[1]
  title:"ABCD"
  photo: "./1234.jpg"
  summ: "text texwt test"
</code>```

I have attempted to setState like this, but it won't work.
Please guide me ;(

```<code>
             this.setState({
               data:{
                title: [ ...this.state.data.title, title ],
                photo: [ ...this.state.data.photo, photo ],
                summ: [ ...this.state.data.summ, summ ]

                    }

                  });
</code>```

Uncaught (in promise) TypeError: _this.state.data.concat is not a function

/////
Mistake on not initialize my state

```<code>// this is incorrect
this.state={
data:{
title:null,
photo:null,
summ:null,
}
//The correct version is
this.state={
data:[],

</code>```

答:
The reason your solution doesn't work is that you are trying to assign an object to an array.

I am not sure if you are trying to add an item to array or change single item from an array. If you are trying to add, you can do it like this:

```<code>this.setState({
...this.state.data, {title, photo, summ}
})
</code>```

However if you are trying to change an item from the array. You should store in a temporary variable and then assign it like this.

```<code>const tempArray = this.state.data;
this.setState({
    data: tempArray.filter(//some change function)
})
</code>```

If you are trying to initialize your data into state, you can do it like this:

```<code>import JsonData from "./myJsonData"
constructor(props) {
super(props);
this.searchBarRef = React.createRef();
this.state = {
  data: JsonData
};
</code>```

}

Hope this solves your issue. If I couldn't explain clearly please say, so I can try to give a better answer to your problem.

Title: ReactJS setState with object and array

Body:
I want to have a data structure in terms of array
e.g.

data[0]
  title:"ABC"
  photo: "./123.jpg"
  summ: "text text test"
data[1]
  title:"ABCD"
  photo: "./1234.jpg"
  summ: "text texwt test"

I have attempted to setState like this, but it won't work.
Please guide me ;(

             this.setState({
               data:{
                title: [ ...this.state.data.title, title ],
                photo: [ ...this.state.data.photo, photo ],
                summ: [ ...this.state.data.summ, summ ]

                    }

                  });

Uncaught (in promise) TypeError: _this.state.data.concat is not a function

/////
Mistake on not initialize my state

// this is incorrect
this.state={
data:{
title:null,
photo:null,
summ:null,
}
//The correct version is
this.state={
data:[],

Body:
The reason your solution doesn't work is that you are trying to assign an object to an array.

I am not sure if you are trying to add an item to array or change single item from an array. If you are trying to add, you can do it like this:

this.setState({
...this.state.data, {title, photo, summ}
})

However if you are trying to change an item from the array. You should store in a temporary variable and then assign it like this.

const tempArray = this.state.data;
this.setState({
    data: tempArray.filter(//some change function)
})

If you are trying to initialize your data into state, you can do it like this:

import JsonData from "./myJsonData"
constructor(props) {
super(props);
this.searchBarRef = React.createRef();
this.state = {
  data: JsonData
};

}

Hope this solves your issue. If I couldn't explain clearly please say, so I can try to give a better answer to your problem.


问:
MYSQL - Update row number for each group
I am trying to update the column sip_count so that it counts the number of rows with the same sip_id as shown below. None of the things that I have tried are worth posting. How do I do this?

Table

```<code>sip_id | sip   | sip_count
---------------------------
 1      |  1    | 2
 1      |  1    | 2
 2      |  1    | 3
 2      |  1    | 3
 2      |  1    | 3
 4      |  1    | 2
 4      |  1    | 2
 3      |  1    | 3
 3      |  1    | 3
 3      |  1    | 3
</code>```

Desired result

```<code> sip_id | sip   | sip_count
---------------------------
 1      |  1    | 1
 1      |  1    | 2
 2      |  1    | 1
 2      |  1    | 2
 2      |  1    | 3
 4      |  1    | 1
 4      |  1    | 2
 3      |  1    | 1
 3      |  1    | 2
 3      |  1    | 3
</code>```

答:
I tried the below query and it gave me the result you are looking for.

```<code>UPDATE SipDetails
SET sip_count = (SELECT (MAX(sp2.sip_count) + 1)
                FROM SipDetails sp2
                WHERE sp2.sip_id = SipDetails.sip_id);
</code>```

Please note:
[SipDetails] should be replaced with your relevant table name.

Below mentioned is the result of running the above query.
I initially set the "sip_count" column value to 0 (zero), before the update.

Body:
I am trying to update the column sip_count so that it counts the number of rows with the same sip_id as shown below. None of the things that I have tried are worth posting. How do I do this?

Table

sip_id | sip   | sip_count
---------------------------
 1      |  1    | 2
 1      |  1    | 2
 2      |  1    | 3
 2      |  1    | 3
 2      |  1    | 3
 4      |  1    | 2
 4      |  1    | 2
 3      |  1    | 3
 3      |  1    | 3
 3      |  1    | 3

Desired result

 sip_id | sip   | sip_count
---------------------------
 1      |  1    | 1
 1      |  1    | 2
 2      |  1    | 1
 2      |  1    | 2
 2      |  1    | 3
 4      |  1    | 1
 4      |  1    | 2
 3      |  1    | 1
 3      |  1    | 2
 3      |  1    | 3

Body:
I tried the below query and it gave me the result you are looking for.

UPDATE SipDetails
SET sip_count = (SELECT (MAX(sp2.sip_count) + 1)
                FROM SipDetails sp2
                WHERE sp2.sip_id = SipDetails.sip_id);

Please note:
[SipDetails] should be replaced with your relevant table name.

Below mentioned is the result of running the above query.
I initially set the "sip_count" column value to 0 (zero), before the update.


问:
How do I create a private Maven repository on S3 from jar not .java file?
I want to create a private Maven repository using AWS S3 from jar, because I must control a jar which is not registered Maven Central.

I searched the way to do that by google, but I could only search the way to create from a .java file by using Maven or Gradle like this(https://medium.com/@JacobASeverson/s3-maven-repositories-and-gradle-911c25cebeeb).

How do I create a private Maven repository on S3 from jar?

答:
You will need an artifactory with a private repository, the quickest way to do this is with jfrog-artifactory-amazon-ec2

You can then add your private artifacts in a private repository (see creating a repository)

Then you can create a virtual repository which will combine maven from the internet and your private repository.

Use this virtual repository in you settings.xml, it will see both private and public artifacts.


问:
How do I rotate text in css?
How do I rotate text in CSS to get following output:

The problem I am facing is that when we rotate the text then it breaks the alignment and positions. So what is causing that, and how can I manage them?

HTML:

```<code><div class="mainWrapper">
    <div class="rotateObj">
        <div class="title active">First Text Title</div>
        <div class="content">
            Here goes my bla bla bla text and more stuffs...
            Here goes my bla bla bla text and more stuffs...
            Here goes my bla bla bla text and more stuffs...
            Here goes my bla bla bla text and more stuffs...
            Here goes my bla bla bla text and more stuffs...
            Here goes my bla bla bla text and more stuffs...
            Here goes my bla bla bla text and more stuffs...
            Here goes my bla bla bla text and more stuffs...
            Here goes my bla bla bla text and more stuffs...
            Here goes my bla bla bla text and more stuffs...
            Here goes my bla bla bla text and more stuffs...
            Here goes my bla bla bla text and more stuffs...
        </div>
        <div class="title">First Text Title</div>
        <div class="content hide">
            Here goes my bla bla bla text and more stuffs...
            Here goes my bla bla bla text and more stuffs...
            Here goes my bla bla bla text and more stuffs...
            Here goes my bla bla bla text and more stuffs...
            Here goes my bla bla bla text and more stuffs...
            Here goes my bla bla bla text and more stuffs...
            Here goes my bla bla bla text and more stuffs...
            Here goes my bla bla bla text and more stuffs...
            Here goes my bla bla bla text and more stuffs...
            Here goes my bla bla bla text and more stuffs...
            Here goes my bla bla bla text and more stuffs...
            Here goes my bla bla bla text and more stuffs...
        </div>
        <div class="title">First Text Title</div>
        <div class="content hide">
            Here goes my bla bla bla text and more stuffs...
            Here goes my bla bla bla text and more stuffs...
            Here goes my bla bla bla text and more stuffs...
            Here goes my bla bla bla text and more stuffs...
            Here goes my bla bla bla text and more stuffs...
            Here goes my bla bla bla text and more stuffs...
            Here goes my bla bla bla text and more stuffs...
            Here goes my bla bla bla text and more stuffs...
            Here goes my bla bla bla text and more stuffs...
            Here goes my bla bla bla text and more stuffs...
            Here goes my bla bla bla text and more stuffs...
            Here goes my bla bla bla text and more stuffs...
        </div>
        <div class="title">First Text Title</div>
        <div class="content hide">
            Here goes my bla bla bla text and more stuffs...
            Here goes my bla bla bla text and more stuffs...
            Here goes my bla bla bla text and more stuffs...
            Here goes my bla bla bla text and more stuffs...
            Here goes my bla bla bla text and more stuffs...
            Here goes my bla bla bla text and more stuffs...
            Here goes my bla bla bla text and more stuffs...
            Here goes my bla bla bla text and more stuffs...
            Here goes my bla bla bla text and more stuffs...
            Here goes my bla bla bla text and more stuffs...
            Here goes my bla bla bla text and more stuffs...
            Here goes my bla bla bla text and more stuffs...
        </div>
        <div class="title">First Text Title</div>
        <div class="content hide">
            Here goes my bla bla bla text and more stuffs...
            Here goes my bla bla bla text and more stuffs...
            Here goes my bla bla bla text and more stuffs...
            Here goes my bla bla bla text and more stuffs...
            Here goes my bla bla bla text and more stuffs...
            Here goes my bla bla bla text and more stuffs...
            Here goes my bla bla bla text and more stuffs...
            Here goes my bla bla bla text and more stuffs...
            Here goes my bla bla bla text and more stuffs...
            Here goes my bla bla bla text and more stuffs...
            Here goes my bla bla bla text and more stuffs...
            Here goes my bla bla bla text and more stuffs...
        </div>
    </div>
</div>
</code>```

CSS:

```<code>    .mainWrapper{margin:0 auto; width:960px; background:#EFEFEF;}
    .rotateObj{position:relative; height:400px;}
    .rotateObj .title{
        float:left;
        background:gray;
        width:50px;
        height:100%;

        /** Rounded Border */
        border-radius:5px;-moz-border-radius:5px;

        /** Rotation */
        -webkit-transform: rotate(-90deg);
        -moz-transform: rotate(-90deg);
        transform:rotate(-90deg);
        filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=3);
    }
    .rotateObj .active{background:green;}
    .rotateObj .content{float:left;width:600px;height:100%;padding:20px;}
    .hide{display:none;}
</code>```

http://jsfiddle.net/koolkabin/yawYM/

答:
You can use like this...

```<code><div id="rot">hello</div>

#rot
{
   -webkit-transform: rotate(-90deg);
   -moz-transform: rotate(-90deg);
    width:100px;
}
</code>```

Have a look at this fiddle:http://jsfiddle.net/anish/MAN4g/

Title: How do I rotate text in css?

Body:
How do I rotate text in CSS to get following output:

The problem I am facing is that when we rotate the text then it breaks the alignment and positions. So what is causing that, and how can I manage them?

HTML:

First Text Title

            Here goes my bla bla bla text and more stuffs...
            Here goes my bla bla bla text and more stuffs...
            Here goes my bla bla bla text and more stuffs...
            Here goes my bla bla bla text and more stuffs...
            Here goes my bla bla bla text and more stuffs...
            Here goes my bla bla bla text and more stuffs...
            Here goes my bla bla bla text and more stuffs...
            Here goes my bla bla bla text and more stuffs...
            Here goes my bla bla bla text and more stuffs...
            Here goes my bla bla bla text and more stuffs...
            Here goes my bla bla bla text and more stuffs...
            Here goes my bla bla bla text and more stuffs...

First Text Title

            Here goes my bla bla bla text and more stuffs...
            Here goes my bla bla bla text and more stuffs...
            Here goes my bla bla bla text and more stuffs...
            Here goes my bla bla bla text and more stuffs...
            Here goes my bla bla bla text and more stuffs...
            Here goes my bla bla bla text and more stuffs...
            Here goes my bla bla bla text and more stuffs...
            Here goes my bla bla bla text and more stuffs...
            Here goes my bla bla bla text and more stuffs...
            Here goes my bla bla bla text and more stuffs...
            Here goes my bla bla bla text and more stuffs...
            Here goes my bla bla bla text and more stuffs...

First Text Title

            Here goes my bla bla bla text and more stuffs...
            Here goes my bla bla bla text and more stuffs...
            Here goes my bla bla bla text and more stuffs...
            Here goes my bla bla bla text and more stuffs...
            Here goes my bla bla bla text and more stuffs...
            Here goes my bla bla bla text and more stuffs...
            Here goes my bla bla bla text and more stuffs...
            Here goes my bla bla bla text and more stuffs...
            Here goes my bla bla bla text and more stuffs...
            Here goes my bla bla bla text and more stuffs...
            Here goes my bla bla bla text and more stuffs...
            Here goes my bla bla bla text and more stuffs...

First Text Title

            Here goes my bla bla bla text and more stuffs...
            Here goes my bla bla bla text and more stuffs...
            Here goes my bla bla bla text and more stuffs...
            Here goes my bla bla bla text and more stuffs...
            Here goes my bla bla bla text and more stuffs...
            Here goes my bla bla bla text and more stuffs...
            Here goes my bla bla bla text and more stuffs...
            Here goes my bla bla bla text and more stuffs...
            Here goes my bla bla bla text and more stuffs...
            Here goes my bla bla bla text and more stuffs...
            Here goes my bla bla bla text and more stuffs...
            Here goes my bla bla bla text and more stuffs...

First Text Title

            Here goes my bla bla bla text and more stuffs...
            Here goes my bla bla bla text and more stuffs...
            Here goes my bla bla bla text and more stuffs...
            Here goes my bla bla bla text and more stuffs...
            Here goes my bla bla bla text and more stuffs...
            Here goes my bla bla bla text and more stuffs...
            Here goes my bla bla bla text and more stuffs...
            Here goes my bla bla bla text and more stuffs...
            Here goes my bla bla bla text and more stuffs...
            Here goes my bla bla bla text and more stuffs...
            Here goes my bla bla bla text and more stuffs...
            Here goes my bla bla bla text and more stuffs...

CSS:

    .mainWrapper{margin:0 auto; width:960px; background:#EFEFEF;}
    .rotateObj{position:relative; height:400px;}
    .rotateObj .title{
        float:left;
        background:gray;
        width:50px;
        height:100%;

        /** Rounded Border */
        border-radius:5px;-moz-border-radius:5px;

        /** Rotation */
        -webkit-transform: rotate(-90deg);
        -moz-transform: rotate(-90deg);
        transform:rotate(-90deg);
        filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=3);
    }
    .rotateObj .active{background:green;}
    .rotateObj .content{float:left;width:600px;height:100%;padding:20px;}
    .hide{display:none;}

http://jsfiddle.net/koolkabin/yawYM/

Body:
You can use like this...

<div id="rot">hello</div>

#rot
{
   -webkit-transform: rotate(-90deg);
   -moz-transform: rotate(-90deg);
    width:100px;
}

Have a look at this fiddle:http://jsfiddle.net/anish/MAN4g/


问:
First Time show fetch data on recyclerview but the second time open recycleview not show data
I am developing app to face some problems my problem is  if first time open recycleview to fetch data show full correct means first time not problem correct show data but the app is  close again reopen recyclerview to not show data. I am using mysql database on working retrofit library.</p>

```<code>    RecyclerView recyclerView;
    EditText searchcard;
    Superdent_Invi_fetct.Adapter adapter;
    FloatingActionButton rotationbtn;
    List<Supert_Invigilator_Model> data;
    String supert_id, hall_id;
    LinearLayoutManager layoutManager;

    SharedPreferences sharedPreferences;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_superdent__invi_fetct);

        supert_id = getIntent().getStringExtra("id");
        hall_id = getIntent().getStringExtra("hall_id");

        rotationbtn = findViewById(R.id.rotat_float_btn);
        searchcard = (EditText) findViewById(R.id.searchcard);
        recyclerView = (RecyclerView) findViewById(R.id.std_report_list);
        recyclerView.setHasFixedSize(true);
        recyclerView.setLayoutManager(new LinearLayoutManager(this));

        searchcard.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {

            }

            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {
                Log.e("onTextChanged: ", s.toString());

                if (adapter != null) {
                    if (!s.toString().isEmpty()) {
                        Filter filter = adapter.getFilter();
                        filter.filter(s.toString());
                        adapter.notifyDataSetChanged();
                    }
                } else {
                    searchcard.setError("List is Empty");
                }

            }

            @Override
            public void afterTextChanged(Editable s) {
                Filter filter = adapter.getFilter();
                filter.filter(s.toString());
            }
        });

        rotationbtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                screenscape();
            }
        });
        ShowReport();
    }

    @Override
    public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
        switch (requestCode) {
            case 555:
                if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
                    // Permission Granted
//                    createShopingPdf();

                } else {
                    // Permission Denied
                    Toast.makeText(this, "WRITE_EXTERNAL Permission Denied", Toast.LENGTH_SHORT)
                            .show();
                }
                break;
            default:
                super.onRequestPermissionsResult(requestCode, permissions, grantResults);
        }
    }

    public void ShowReport() {
        HashMap<String, String> map = new HashMap<>();
        map.put("id", supert_id);
        map.put("hall_id", hall_id);
        Invi_std_Api apiInterface = ApiClient.getClient().create(Invi_std_Api.class);
        Call<List<Supert_Invigilator_Model>> call = apiInterface.getsuperdentinvigilator(map);
        call.enqueue(new Callback<List<Supert_Invigilator_Model>>() {
            @Override
            public void onResponse(Call<List<Supert_Invigilator_Model>> call, Response<List<Supert_Invigilator_Model>> response) {
                data = response.body();
                Log.e("size", "onResponse: " + data.size());

                adapter = new Superdent_Invi_fetct.Adapter(Superdent_Invi_fetct.this, data);
                recyclerView.setAdapter(adapter);

            }

            @Override
            public void onFailure(Call<List<Supert_Invigilator_Model>> call, Throwable t) {
                Log.e("Exception", "onFailure: " + t.getMessage());

            }
        });
    }

    public void screenscape() {

        int orientation = getResources().getConfiguration().orientation;
        switch (orientation) {
            case Configuration.ORIENTATION_LANDSCAPE:
                runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
                    }
                });

                break;

            case Configuration.ORIENTATION_PORTRAIT:
                runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
                    }
                });

                break;
        }
    }

    public class Adapter extends RecyclerView.Adapter<Superdent_Invi_fetct.Adapter.MyViewHolder> implements Filterable {
        Context context;
        List<Supert_Invigilator_Model> data;
        List<Supert_Invigilator_Model> copyList;

        public Adapter(Context context, List<Supert_Invigilator_Model> data) {
            this.context = context;
            this.data = data;
            this.copyList = data;
        }

        @NonNull
        @Override
        public Superdent_Invi_fetct.Adapter.MyViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
            View view = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.invigilator_record_spt, viewGroup, false);

            return new Superdent_Invi_fetct.Adapter.MyViewHolder(view);
        }

        @Override
        public void onBindViewHolder(@NonNull Superdent_Invi_fetct.Adapter.MyViewHolder holder, int i) {

            final Supert_Invigilator_Model model = data.get(i);
            //  holder.tvid.setText(copyList.get(i).getInvigId());
            holder.tvinvname.setText(copyList.get(i).getName());
            holder.tvhall.setText(copyList.get(i).getTitle());
            holder.tvroleid.setText(copyList.get(i).getRoleId());
            holder.tvhallid.setText(copyList.get(i).getHallId());

        }

        @Override
        public int getItemCount() {
            return copyList.size();
        }

        @Override
        public Filter getFilter() {

            Filter filter = new Filter() {

                @SuppressWarnings("unchecked")
                @Override
                protected void publishResults(CharSequence constraint, FilterResults results) {

                    copyList = (List<Supert_Invigilator_Model>) results.values;
                    notifyDataSetChanged();
                }

                @Override
                protected FilterResults performFiltering(CharSequence constraint) {
                    FilterResults results = new FilterResults();
                    List<Supert_Invigilator_Model> FilteredArrList = new ArrayList<>();

                    if (data == null) {
                        data = new ArrayList<>();
                    }

                    if (constraint == null || constraint.length() == 0) {
                        results.count = data.size();
                        results.values = data;
                    } else {
                        constraint = constraint.toString().toLowerCase();
                        for (int i = 0; i < data.size(); i++) {
                            String item = data.get(i).getName();

                            if (item.toLowerCase().contains(constraint.toString())) {
                                FilteredArrList.add(new Supert_Invigilator_Model(
                                        data.get(i).getCnic(),
                                        data.get(i).getDeptId(),
                                        data.get(i).getFName(),
                                        data.get(i).getHallId(),
                                        data.get(i).getId(),
                                        data.get(i).getInvigId(),
                                        data.get(i).getName(),
                                        data.get(i).getPassword(),
                                        data.get(i).getRoleId(),
                                        data.get(i).getRoll(),
                                        data.get(i).getSupertId(),
                                        data.get(i).getTitle(),
                                        data.get(i).getUserId()));
                            }
                        }
                        results.count = FilteredArrList.size();
                        results.values = FilteredArrList;
                    }
                    return results;
                }
            };
            return filter;
        }

        public class MyViewHolder extends RecyclerView.ViewHolder {
            TextView tvid, tvinvname, tvhall, tvroleid, tvhallid;

            public MyViewHolder(@NonNull View itemView) {
                super(itemView);
                //    tvid = itemView.findViewById(R.id.tID);
                tvinvname = itemView.findViewById(R.id.tIviglatorName);
                tvhall = itemView.findViewById(R.id.tHallName);
                tvroleid = itemView.findViewById(R.id.troleid);
                tvhallid = itemView.findViewById(R.id.thallid);

            }

            public List<Supert_Invigilator_Model> getList() {
                Log.e("getList: ", "" + copyList);
                return copyList;

            }
        }
    }
}
</code>```

答:
Try calling adapter.notifyDataSetChanged(); in your ShowReport method after setting the adapter.

Also, don't try to set your adapter in your ShowReport method. Try to set it in onCreate using another list and just add the response in that list in your ShowReport method.

And also, please try to debug the code so that you can know why it's not showing the data in the second run.

Body:
I am developing app to face some problems my problem is  if first time open recycleview to fetch data show full correct means first time not problem correct show data but the app is  close again reopen recyclerview to not show data. I am using mysql database on working retrofit library.

    RecyclerView recyclerView;
    EditText searchcard;
    Superdent_Invi_fetct.Adapter adapter;
    FloatingActionButton rotationbtn;
    List<Supert_Invigilator_Model> data;
    String supert_id, hall_id;
    LinearLayoutManager layoutManager;

    SharedPreferences sharedPreferences;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_superdent__invi_fetct);

        supert_id = getIntent().getStringExtra("id");
        hall_id = getIntent().getStringExtra("hall_id");

        rotationbtn = findViewById(R.id.rotat_float_btn);
        searchcard = (EditText) findViewById(R.id.searchcard);
        recyclerView = (RecyclerView) findViewById(R.id.std_report_list);
        recyclerView.setHasFixedSize(true);
        recyclerView.setLayoutManager(new LinearLayoutManager(this));

        searchcard.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {

            }

            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {
                Log.e("onTextChanged: ", s.toString());

                if (adapter != null) {
                    if (!s.toString().isEmpty()) {
                        Filter filter = adapter.getFilter();
                        filter.filter(s.toString());
                        adapter.notifyDataSetChanged();
                    }
                } else {
                    searchcard.setError("List is Empty");
                }

            }

            @Override
            public void afterTextChanged(Editable s) {
                Filter filter = adapter.getFilter();
                filter.filter(s.toString());
            }
        });

        rotationbtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                screenscape();
            }
        });
        ShowReport();
    }

    @Override
    public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
        switch (requestCode) {
            case 555:
                if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
                    // Permission Granted
//                    createShopingPdf();

                } else {
                    // Permission Denied
                    Toast.makeText(this, "WRITE_EXTERNAL Permission Denied", Toast.LENGTH_SHORT)
                            .show();
                }
                break;
            default:
                super.onRequestPermissionsResult(requestCode, permissions, grantResults);
        }
    }

    public void ShowReport() {
        HashMap<String, String> map = new HashMap<>();
        map.put("id", supert_id);
        map.put("hall_id", hall_id);
        Invi_std_Api apiInterface = ApiClient.getClient().create(Invi_std_Api.class);
        Call<List<Supert_Invigilator_Model>> call = apiInterface.getsuperdentinvigilator(map);
        call.enqueue(new Callback<List<Supert_Invigilator_Model>>() {
            @Override
            public void onResponse(Call<List<Supert_Invigilator_Model>> call, Response<List<Supert_Invigilator_Model>> response) {
                data = response.body();
                Log.e("size", "onResponse: " + data.size());

                adapter = new Superdent_Invi_fetct.Adapter(Superdent_Invi_fetct.this, data);
                recyclerView.setAdapter(adapter);

            }

            @Override
            public void onFailure(Call<List<Supert_Invigilator_Model>> call, Throwable t) {
                Log.e("Exception", "onFailure: " + t.getMessage());

            }
        });
    }

    public void screenscape() {

        int orientation = getResources().getConfiguration().orientation;
        switch (orientation) {
            case Configuration.ORIENTATION_LANDSCAPE:
                runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
                    }
                });

                break;

            case Configuration.ORIENTATION_PORTRAIT:
                runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
                    }
                });

                break;
        }
    }

    public class Adapter extends RecyclerView.Adapter<Superdent_Invi_fetct.Adapter.MyViewHolder> implements Filterable {
        Context context;
        List<Supert_Invigilator_Model> data;
        List<Supert_Invigilator_Model> copyList;

        public Adapter(Context context, List<Supert_Invigilator_Model> data) {
            this.context = context;
            this.data = data;
            this.copyList = data;
        }

        @NonNull
        @Override
        public Superdent_Invi_fetct.Adapter.MyViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
            View view = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.invigilator_record_spt, viewGroup, false);

            return new Superdent_Invi_fetct.Adapter.MyViewHolder(view);
        }

        @Override
        public void onBindViewHolder(@NonNull Superdent_Invi_fetct.Adapter.MyViewHolder holder, int i) {

            final Supert_Invigilator_Model model = data.get(i);
            //  holder.tvid.setText(copyList.get(i).getInvigId());
            holder.tvinvname.setText(copyList.get(i).getName());
            holder.tvhall.setText(copyList.get(i).getTitle());
            holder.tvroleid.setText(copyList.get(i).getRoleId());
            holder.tvhallid.setText(copyList.get(i).getHallId());

        }

        @Override
        public int getItemCount() {
            return copyList.size();
        }

        @Override
        public Filter getFilter() {

            Filter filter = new Filter() {

                @SuppressWarnings("unchecked")
                @Override
                protected void publishResults(CharSequence constraint, FilterResults results) {

                    copyList = (List<Supert_Invigilator_Model>) results.values;
                    notifyDataSetChanged();
                }

                @Override
                protected FilterResults performFiltering(CharSequence constraint) {
                    FilterResults results = new FilterResults();
                    List<Supert_Invigilator_Model> FilteredArrList = new ArrayList<>();

                    if (data == null) {
                        data = new ArrayList<>();
                    }

                    if (constraint == null || constraint.length() == 0) {
                        results.count = data.size();
                        results.values = data;
                    } else {
                        constraint = constraint.toString().toLowerCase();
                        for (int i = 0; i < data.size(); i++) {
                            String item = data.get(i).getName();

                            if (item.toLowerCase().contains(constraint.toString())) {
                                FilteredArrList.add(new Supert_Invigilator_Model(
                                        data.get(i).getCnic(),
                                        data.get(i).getDeptId(),
                                        data.get(i).getFName(),
                                        data.get(i).getHallId(),
                                        data.get(i).getId(),
                                        data.get(i).getInvigId(),
                                        data.get(i).getName(),
                                        data.get(i).getPassword(),
                                        data.get(i).getRoleId(),
                                        data.get(i).getRoll(),
                                        data.get(i).getSupertId(),
                                        data.get(i).getTitle(),
                                        data.get(i).getUserId()));
                            }
                        }
                        results.count = FilteredArrList.size();
                        results.values = FilteredArrList;
                    }
                    return results;
                }
            };
            return filter;
        }

        public class MyViewHolder extends RecyclerView.ViewHolder {
            TextView tvid, tvinvname, tvhall, tvroleid, tvhallid;

            public MyViewHolder(@NonNull View itemView) {
                super(itemView);
                //    tvid = itemView.findViewById(R.id.tID);
                tvinvname = itemView.findViewById(R.id.tIviglatorName);
                tvhall = itemView.findViewById(R.id.tHallName);
                tvroleid = itemView.findViewById(R.id.troleid);
                tvhallid = itemView.findViewById(R.id.thallid);

            }

            public List<Supert_Invigilator_Model> getList() {
                Log.e("getList: ", "" + copyList);
                return copyList;

            }
        }
    }
}


答:
As Felix Kling said in commentary, you want an Array of Object so you need to have a structure like that :

this.setState({
  data: [
    ...this.state.data,
    { title, photo, summ }
  ];
});
```

Title: ReactJS setState with object and array