-
Notifications
You must be signed in to change notification settings - Fork 319
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Summary: Pull Request resolved: #2282 Reviewed By: larryliu0820 Differential Revision: D54607005
- Loading branch information
1 parent
0570294
commit 5916639
Showing
9 changed files
with
189 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
...les/demo-apps/android/LlamaDemo/app/src/main/java/com/example/executorchdemo/Message.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
package com.example.executorchllamademo; | ||
|
||
public class Message { | ||
private String text; | ||
private boolean isSent; | ||
|
||
public Message(String text, boolean isSent) { | ||
this.text = text; | ||
this.isSent = isSent; | ||
} | ||
|
||
public String getText() { | ||
return text; | ||
} | ||
|
||
public void appendText(String text) { | ||
this.text += text; | ||
} | ||
|
||
public boolean getIsSent() { | ||
return isSent; | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
...o-apps/android/LlamaDemo/app/src/main/java/com/example/executorchdemo/MessageAdapter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
package com.example.executorchllamademo; | ||
|
||
import android.view.LayoutInflater; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
import android.widget.ArrayAdapter; | ||
import android.widget.TextView; | ||
|
||
public class MessageAdapter extends ArrayAdapter<Message> { | ||
public MessageAdapter(android.content.Context context, int resource) { | ||
super(context, resource); | ||
} | ||
|
||
@Override | ||
public View getView(int position, View convertView, ViewGroup parent) { | ||
Message currentMessage = getItem(position); | ||
int layoutIdForListItem = | ||
currentMessage.getIsSent() ? R.layout.sent_message : R.layout.received_message; | ||
View listItemView = | ||
LayoutInflater.from(getContext()).inflate(layoutIdForListItem, parent, false); | ||
TextView messageTextView = listItemView.findViewById(R.id.message_text); | ||
messageTextView.setText(currentMessage.getText()); | ||
return listItemView; | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
examples/demo-apps/android/LlamaDemo/app/src/main/res/drawable/received_message.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<shape xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:shape="rectangle"> | ||
<solid android:color="#fff" /> | ||
<corners android:radius="10dp" /> | ||
</shape> |
6 changes: 6 additions & 0 deletions
6
examples/demo-apps/android/LlamaDemo/app/src/main/res/drawable/sent_message.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<shape xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:shape="rectangle"> | ||
<solid android:color="@color/colorPrimary" /> | ||
<corners android:radius="10dp" /> | ||
</shape> |
5 changes: 5 additions & 0 deletions
5
examples/demo-apps/android/LlamaDemo/app/src/main/res/drawable/three_dots.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<vector android:height="24dp" android:tint="#000000" | ||
android:viewportHeight="24" android:viewportWidth="24" | ||
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<path android:fillColor="@android:color/white" android:pathData="M6,10c-1.1,0 -2,0.9 -2,2s0.9,2 2,2 2,-0.9 2,-2 -0.9,-2 -2,-2zM18,10c-1.1,0 -2,0.9 -2,2s0.9,2 2,2 2,-0.9 2,-2 -0.9,-2 -2,-2zM12,10c-1.1,0 -2,0.9 -2,2s0.9,2 2,2 2,-0.9 2,-2 -0.9,-2 -2,-2z"/> | ||
</vector> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
examples/demo-apps/android/LlamaDemo/app/src/main/res/layout/received_message.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:paddingVertical="10dp" | ||
android:paddingLeft="15dp" | ||
android:paddingRight="60dp" | ||
android:clipToPadding="false"> | ||
|
||
<TextView | ||
android:id="@+id/name" | ||
android:layout_marginLeft="15dp" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:paddingBottom="4dp" | ||
android:text="LLaMA"/> | ||
|
||
<TextView | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:id="@+id/message_text" | ||
android:layout_below="@+id/name" | ||
android:layout_alignLeft="@+id/name" | ||
android:background="@drawable/received_message" | ||
android:paddingVertical="12dp" | ||
android:paddingHorizontal="16dp" | ||
android:elevation="2dp" | ||
android:textSize="18dp" | ||
android:text="Generated text" | ||
/> | ||
</RelativeLayout> |
34 changes: 34 additions & 0 deletions
34
examples/demo-apps/android/LlamaDemo/app/src/main/res/layout/sent_message.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:paddingVertical="10dp" | ||
android:paddingRight="15dp" | ||
android:paddingLeft="60dp" | ||
android:clipToPadding="false"> | ||
|
||
<TextView | ||
android:id="@+id/name" | ||
android:layout_marginRight="15dp" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:paddingBottom="4dp" | ||
android:layout_alignParentRight="true" | ||
android:text="Prompt"/> | ||
|
||
<TextView | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:id="@+id/message_text" | ||
android:layout_below="@+id/name" | ||
android:layout_alignRight="@+id/name" | ||
android:background="@drawable/sent_message" | ||
android:textColor="#fff" | ||
android:padding="10dp" | ||
android:elevation="2dp" | ||
android:textSize="18dp" | ||
android:layout_alignParentRight="true" | ||
android:text="My prompt" | ||
/> | ||
|
||
</RelativeLayout> |