updateGallery関係を修正,あとログイン画面も
1 parent 92f0ade commit ce5a22bf53df98e4dc5d09258d8c02a8915bbf9e
d-matsuura authored on 2 Nov 2021
Showing 17 changed files
View
35
.idea/misc.xml
<project version="4">
<component name="DesignSurface">
<option name="filePathToZoomLevelMap">
<map>
<entry key="..\:/Users/DAISUKE/AndroidStudioProjects/org.ntlab.acanthus_client/app/src/main/res/drawable-v24/ic_launcher_foreground.xml" value="0.16354166666666667" />
<entry key="..\:/Users/DAISUKE/AndroidStudioProjects/org.ntlab.acanthus_client/app/src/main/res/drawable/flame_home_list.xml" value="0.38333333333333336" />
<entry key="..\:/Users/DAISUKE/AndroidStudioProjects/org.ntlab.acanthus_client/app/src/main/res/drawable/flame_underline.xml" value="0.37222222222222223" />
<entry key="..\:/Users/DAISUKE/AndroidStudioProjects/org.ntlab.acanthus_client/app/src/main/res/drawable/ic_baseline_cancel_24.xml" value="0.38333333333333336" />
<entry key="..\:/Users/DAISUKE/AndroidStudioProjects/org.ntlab.acanthus_client/app/src/main/res/drawable/ic_baseline_free_breakfast.xml" value="0.38333333333333336" />
<entry key="..\:/Users/DAISUKE/AndroidStudioProjects/org.ntlab.acanthus_client/app/src/main/res/drawable/ic_launcher_background.xml" value="0.29583333333333334" />
<entry key="..\:/Users/DAISUKE/AndroidStudioProjects/org.ntlab.acanthus_client/app/src/main/res/drawable/shape_style.xml" value="0.38333333333333336" />
<entry key="..\:/Users/DAISUKE/AndroidStudioProjects/org.ntlab.acanthus_client/app/src/main/res/layout/activity_app_information.xml" value="0.22327898550724637" />
<entry key="..\:/Users/DAISUKE/AndroidStudioProjects/org.ntlab.acanthus_client/app/src/main/res/layout/activity_how_to_use.xml" value="0.353125" />
<entry key="..\:/Users/DAISUKE/AndroidStudioProjects/org.ntlab.acanthus_client/app/src/main/res/layout/activity_logout.xml" value="0.22327898550724637" />
<entry key="..\:/Users/DAISUKE/AndroidStudioProjects/org.ntlab.acanthus_client/app/src/main/res/layout/activity_main.xml" value="0.165" />
<entry key="..\:/Users/DAISUKE/AndroidStudioProjects/org.ntlab.acanthus_client/app/src/main/res/layout/activity_paint.xml" value="0.13601823708206687" />
<entry key="..\:/Users/DAISUKE/AndroidStudioProjects/org.ntlab.acanthus_client/app/src/main/res/layout/activity_privacy_policy.xml" value="0.27475538160469665" />
<entry key="..\:/Users/DAISUKE/AndroidStudioProjects/org.ntlab.acanthus_client/app/src/main/res/layout/activity_sign_up.xml" value="0.23369565217391305" />
<entry key="..\:/Users/DAISUKE/AndroidStudioProjects/org.ntlab.acanthus_client/app/src/main/res/layout/activity_terms_of_service.xml" value="0.22327898550724637" />
<entry key="..\:/Users/DAISUKE/AndroidStudioProjects/org.ntlab.acanthus_client/app/src/main/res/layout/activity_userpage.xml" value="0.13601823708206687" />
<entry key="..\:/Users/DAISUKE/AndroidStudioProjects/org.ntlab.acanthus_client/app/src/main/res/layout/animation_home_header.xml" value="0.23369565217391305" />
<entry key="..\:/Users/DAISUKE/AndroidStudioProjects/org.ntlab.acanthus_client/app/src/main/res/layout/fragment_create.xml" value="0.22327898550724637" />
<entry key="..\:/Users/DAISUKE/AndroidStudioProjects/org.ntlab.acanthus_client/app/src/main/res/layout/fragment_edit.xml" value="0.1762917933130699" />
<entry key="..\:/Users/DAISUKE/AndroidStudioProjects/org.ntlab.acanthus_client/app/src/main/res/layout/fragment_edit_header.xml" value="0.3671875" />
<entry key="..\:/Users/DAISUKE/AndroidStudioProjects/org.ntlab.acanthus_client/app/src/main/res/layout/fragment_home.xml" value="0.14739583333333334" />
<entry key="..\:/Users/DAISUKE/AndroidStudioProjects/org.ntlab.acanthus_client/app/src/main/res/layout/fragment_mypage.xml" value="0.1762917933130699" />
<entry key="..\:/Users/DAISUKE/AndroidStudioProjects/org.ntlab.acanthus_client/app/src/main/res/layout/fragment_pen_detail.xml" value="0.165" />
<entry key="..\:/Users/DAISUKE/AndroidStudioProjects/org.ntlab.acanthus_client/app/src/main/res/layout/fragment_search.xml" value="0.20697463768115942" />
<entry key="..\:/Users/DAISUKE/AndroidStudioProjects/org.ntlab.acanthus_client/app/src/main/res/menu/bottom_nav_menu.xml" value="0.26944444444444443" />
<entry key="..\:/Users/DAISUKE/AndroidStudioProjects/org.ntlab.acanthus_client/app/src/main/res/menu/bottom_nav_paint.xml" value="0.26944444444444443" />
<entry key="..\:/Users/DAISUKE/AndroidStudioProjects/org.ntlab.acanthus_client/app/src/main/res/menu/bottom_nav_top.xml" value="0.14739583333333334" />
<entry key="..\:/Users/DAISUKE/AndroidStudioProjects/org.ntlab.acanthus_client/app/src/main/res/menu/botton_nav_top.xml" value="0.14739583333333334" />
<entry key="..\:/Users/DAISUKE/AndroidStudioProjects/org.ntlab.acanthus_client/app/src/main/res/menu/top_nav_main.xml" value="0.3671875" />
<entry key="..\:/Users/DAISUKE/AndroidStudioProjects/org.ntlab.acanthus_client/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml" value="0.29583333333333334" />
<entry key="..\:/Users/DAISUKE/AndroidStudioProjects/org.ntlab.acanthus_client/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml" value="0.29583333333333334" />
<entry key="..\:/Users/Student/StudioProjects/org.ntlab.acanthus_client/app/src/main/res/layout/fragment_home.xml" value="0.1" />
<entry key="..\:/Users/student/StudioProjects/org.ntlab.acanthus_client/app/src/main/res/drawable/flame_edit_list.xml" value="0.4574358974358974" />
<entry key="..\:/Users/student/StudioProjects/org.ntlab.acanthus_client/app/src/main/res/drawable/flame_home_list.xml" value="0.4574358974358974" />
<entry key="..\:/Users/student/StudioProjects/org.ntlab.acanthus_client/app/src/main/res/drawable/flame_style.xml" value="0.3907407407407407" />
<entry key="..\:/Users/student/StudioProjects/org.ntlab.acanthus_client/app/src/main/res/layout/fragment_pen_detail.xml" value="0.31929347826086957" />
<entry key="..\:/Users/student/StudioProjects/org.ntlab.acanthus_client/app/src/main/res/layout/fragment_search.xml" value="0.37318840579710144" />
<entry key="..\:/Users/student/StudioProjects/org.ntlab.acanthus_client/app/src/main/res/layout/fragment_test.xml" value="0.32382246376811596" />
<entry key="..\:/Users/student/StudioProjects/org.ntlab.acanthus_client/app/src/main/res/layout/frame_textview.xml" value="0.32382246376811596" />
<entry key="..\:/Users/student/StudioProjects/org.ntlab.acanthus_client/app/src/main/res/layout/invites_list.xml" value="0.3134057971014493" />
<entry key="..\:/Users/student/StudioProjects/org.ntlab.acanthus_client/app/src/main/res/layout/list.xml" value="0.360054347826087" />
<entry key="..\:/Users/student/StudioProjects/org.ntlab.acanthus_client/app/src/main/res/layout/low.xml" value="0.32382246376811596" />
<entry key="..\:/Users/student/StudioProjects/org.ntlab.acanthus_client/app/src/main/res/layout/my_text_view.xml" value="0.32382246376811596" />
<entry key="..\:/Users/student/StudioProjects/org.ntlab.acanthus_client/app/src/main/res/layout/row.xml" value="0.26063829787234044" />
<entry key="..\:/Users/student/StudioProjects/org.ntlab.acanthus_client/app/src/main/res/menu/bottom_nav_menu.xml" value="0.328125" />
<entry key="..\:/Users/student/StudioProjects/org.ntlab.acanthus_client/app/src/main/res/menu/bottom_nav_paint.xml" value="0.328125" />
<entry key="..\:/Users/student/StudioProjects/org.ntlab.acanthus_client/app/src/main/res/menu/botton_nav_icon.xml" value="0.45" />
<entry key="..\:/Users/student/StudioProjects/org.ntlab.acanthus_client/app/src/main/res/menu/botton_nav_top.xml" value="0.55" />
<entry key="..\:/Users/user/StudioProjects/org.ntlab.acanthus_client/app/src/main/res/drawable/shape_style.xml" value="0.15260416666666668" />
<entry key="..\:/Users/user/StudioProjects/org.ntlab.acanthus_client/app/src/main/res/layout/activity_paint.xml" value="0.1" />
<entry key="..\:/Users/user/StudioProjects/org.ntlab.acanthus_client/app/src/main/res/layout/fragment_pen_detail.xml" value="0.18" />
</map>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="true" project-jdk-name="11" project-jdk-type="JavaSDK">
View
4
app/src/main/AndroidManifest.xml
<activity android:name=".views.paint.InviteActivity" />
<activity android:name=".views.paint.PaintActivity" />
<activity android:name=".views.paint.page.PageActivity" />
<activity android:name=".views.login.LoginScreenActivity" />
<activity android:name=".views.userpage.UserPageActivity"></activity>
<activity android:name=".views.userpage.followList.FollowListActivity"></activity>
<activity android:name=".views.userpage.followerList.FollowerListActivity"></activity>
<activity android:name=".views.userpage.workList.WorkListActivity"></activity>
<activity
android:name=".views.MainActivity"
android:label="@string/title_activity_main"
android:screenOrientation="portrait"
View
11
app/src/main/java/org/ntlab/acanthus_client/entities/EditorJson.java
package org.ntlab.acanthus_client.entities;
 
import java.util.ArrayList;
import java.util.Collection;
 
//-----------------------------------------------------------------
// 作品編集者の一覧
public class EditorJson {
private ArrayList<Integer> uidList = new ArrayList<>();
private ArrayList<Integer> uid = new ArrayList<>();
 
//-----------------------------------------------------------------
public EditorJson() {
}
 
//-----------------------------------------------------------------
// getter
public ArrayList<Integer> getUidList() {
return uidList;
public Collection<Integer> getUid() {
return uid;
}
 
//-----------------------------------------------------------------
// setter
public void addUid(Integer uid) {
this.uidList.add(uid);
public void setAid(ArrayList<Integer> uid) {
this.uid = uid;
}
}
View
5
app/src/main/java/org/ntlab/acanthus_client/resources/gallery/InvitesRest.java
package org.ntlab.acanthus_client.resources.gallery;
 
import org.ntlab.acanthus_client.entities.Account;
import org.ntlab.acanthus_client.entities.InvitesJson;
 
import java.util.Collection;
 
import retrofit2.Call;
 
//-----------------------------------------------------------------
 
@GET("gallery/{aid}/invites")
Call<Collection<Account>> isGalleryInvites(
Call<InvitesJson> isGalleryInvites(
@Path("aid") Integer aid,
@Query("invited") String invitedUid,
@Query("invitedUserToken") String invitedUserToken,
@Query("ownerToken") String ownerToken
//-----------------------------------------------------------------
 
@FormUrlEncoded
@PUT("gallery/{aid}/invites")
Call<String> addInvite(
Call<Boolean> addInvite(
@Path("aid") Integer aid,
@Field("ownerUid") String ownerUid,
@Field("invitedUid") String invitedUid,
@Field("ownerToken") String ownerToken
View
24
app/src/main/java/org/ntlab/acanthus_client/views/animation/AnimationActivity.java
private int msec = 500;
 
//ボタン系
private boolean buttonView = true;
private boolean player = true;
private Button buttonPlayback;
private Button buttonReset;
private Button buttonClose;
private Button buttonDetail;
//アニメーションの再生停止
buttonPlayback = findViewById(R.id.button_playback);
buttonPlayback.setOnClickListener(new View.OnClickListener(){
public void onClick(View v) {
if(onClickPlayback()){
buttonPlayback.setBackgroundDrawable(getResources().getDrawable(R.drawable.ic_baseline_play_arrow));
}
else {
buttonPlayback.setBackgroundDrawable(getResources().getDrawable(R.drawable.ic_baseline_pause));
}
onClickPlayback();
}
});
 
//最初に戻す
//詳細画面へ移動
buttonDetail = findViewById(R.id.button_detail);
buttonDetail.setOnClickListener(new View.OnClickListener(){
public void onClick(View v) {
if(player) onClickPlayback();
Intent intent = new Intent(AnimationActivity.this, AnimationDetailActivity.class);
intent.putExtra("AnimationJsonData", animationJson);
startActivity(intent);
}
webView.loadUrl(pages.get(pageNo+1));
}
 
//アニメーションの再生停止
public boolean onClickPlayback(){
public void onClickPlayback(){
if(timer != null){
//timerの終了
timer.cancel();
timer = null;
return true;
buttonPlayback.setBackgroundDrawable(getResources().getDrawable(R.drawable.ic_baseline_play_arrow));
player = false;
}
else{
//timerの生成
this.timer = new Timer();
this.timerTask = new CountUpTimerTask();
this.timer.schedule(timerTask,0, this.msec);//スケジュールを100ms毎に設定する。
return false;
buttonPlayback.setBackgroundDrawable(getResources().getDrawable(R.drawable.ic_baseline_pause));
player = true;
}
}
 
//ページを進める(ループ)
View
2
■■■
app/src/main/java/org/ntlab/acanthus_client/views/animation/AnimationConnectionModel.java
public void getPage(MutableLiveData<HashMap<Integer, String>> pages) {
final StrokesRest strokesRest = retrofit.create(StrokesRest.class);
 
// 筆跡追加API
Call<HashMap<Integer, String>> call = strokesRest.getPageUrls(1111);
Call<HashMap<Integer, String>> call = strokesRest.getPageUrls(acanthus.getAid());
call.enqueue(new Callback<HashMap<Integer, String>>() {
@Override
public void onResponse(Call<HashMap<Integer, String>> call, Response<HashMap<Integer, String>> response) {
if (response.isSuccessful()){
View
1
■■■■
app/src/main/java/org/ntlab/acanthus_client/views/login/LoginScreenActivity.java
//
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setTheme(R.style.AppTheme_NoTitleBar);//タイトルバーを消す
init();
}
 
//-----------------------------------------------------------------
View
4
app/src/main/java/org/ntlab/acanthus_client/views/main_menu_ui/create/CreateFragment.java
public class CreateFragment extends Fragment {
private CreateViewModel createViewModel;
private FragmentCreateBinding binding;
private HomeViewModel homeViewModel;
private Acanthus acanthus;
 
public View onCreateView(@NonNull LayoutInflater inflater,
ViewGroup container, Bundle savedInstanceState) {
createViewModel =
//ダミーユーザー
Integer uid = 1;
String token = "abc0";
 
Acanthus acanthus = (Acanthus) getActivity().getApplication();
acanthus = (Acanthus) getActivity().getApplication();
appButton.setOnClickListener(v -> {
//Integer uid = acanthus.getPreferenceUid();
String name = ((EditText)view.findViewById(R.id.AnimationNameCreate)).getText().toString();
//String token = acanthus.getPreferenceToken();
// 画面遷移
private void transitionPaintActivity() {
Acanthus acanthus = (Acanthus) getActivity().getApplication();
Intent intent = new Intent(acanthus, PaintActivity.class);
homeViewModel.updateGallery(acanthus); // ギャラリーをアップデート
startActivity(intent);
}
}
View
34
app/src/main/java/org/ntlab/acanthus_client/views/main_menu_ui/edit/EditFragment.java
public class EditFragment extends Fragment implements SwipeRefreshLayout.OnRefreshListener {
 
private EditViewModel editViewModel;
private FragmentEditBinding binding;
private ArrayList<Integer> aidList;
private ArrayList<Integer> userAidList;
private ArrayList<Integer> aidList = new ArrayList<>();
private ArrayList<AnimationJson> AnimationJsonList;
private ArrayList<String> nameList;
private ArrayList<String> lastUpDateList;
private HashMap<Integer, String> nameHashMap;
acanthus = (Acanthus) getActivity().getApplication();
Integer uid = 1;
String token = "abc0";
editViewModel.getWorkList(uid, token);
aidList = new ArrayList<>();
userAidList = new ArrayList<>();
nameList = new ArrayList<>();
lastUpDateList = new ArrayList<>();
AnimationJsonList = new ArrayList<>();
Map<Integer, String> nameHashMap = new HashMap<Integer, String>();
 
ListView listView = (ListView) getActivity().findViewById(R.id.list_view);
listView.addHeaderView(header);
 
homeViewModel.updateGallery(acanthus); // ギャラリーをアップデート
 
// SwipeRefreshLayoutを作成
createSwipeRefreshLayout();
 
editViewModel.getWorkJson().observe(getViewLifecycleOwner(), new Observer<WorkJson>() {
 
//listViewの表示をしている
@Override
public void onChanged(@Nullable WorkJson workJson) {
aidList = (ArrayList<Integer>) editViewModel.getWorkJson().getValue().getAid();
userAidList = (ArrayList<Integer>) editViewModel.getWorkJson().getValue().getAid();
AnimationJsonList = (ArrayList<AnimationJson>) acanthus.getAnimationJsonList();
ArrayList<AnimationJson> workList = new ArrayList<>();
HashMap<Integer, AnimationJson> workList = new HashMap<>();
 
if(AnimationJsonList != null){
for(int i=0; i<AnimationJsonList.size(); i++){
for(AnimationJson animationJson : AnimationJsonList){
//acanthusのAnimationJsonListにとってきたaidが該当するかを探索する
if(aidList.contains(AnimationJsonList.get(i).getAid())){
AnimationName = AnimationJsonList.get(i).getAnimationName();
AnimationLastUpDate = AnimationJsonList.get(i).getLastUpdate();
AnimationAid = AnimationJsonList.get(i).getAid();
if(userAidList.contains(animationJson.getAid())){
AnimationName = animationJson.getAnimationName();
AnimationLastUpDate = animationJson.getLastUpdate();
AnimationAid = animationJson.getAid();
nameHashMap.put(AnimationAid, AnimationName);
lastUpDateHashMap.put(AnimationAid, AnimationLastUpDate);
 
// nameList.add(AnimationName);
// lastUpDateList.add(AnimationLastUpDate);
workList.add(AnimationJsonList.get(i));
}
}
}
 
});
for(Entry<Integer, String> entry : list_entries) {
lastUpDateList.add(entry.getValue());
nameList.add(nameHashMap.get(entry.getKey()));
aidList.add(entry.getKey());
}
//--------------------------------------------------------------------------------------------------------------------
 
 
 
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) {
transitionPaintActivity(workList.get(position-1));
transitionPaintActivity(aidList.get(position-1));
}
});
}
 
 
//-----------------------------------------------------------------
// 画面遷移
private void transitionPaintActivity() {
acanthus = (Acanthus) getActivity().getApplication();
Acanthus acanthus = (Acanthus) getActivity().getApplication();
Intent intent = new Intent(acanthus, PaintActivity.class);
startActivity(intent);
}
 
//各作品毎の画面遷移
private void transitionPaintActivity(AnimationJson animationJson) {
acanthus = (Acanthus) getActivity().getApplication();
private void transitionPaintActivity(Integer aid) {
Acanthus acanthus = (Acanthus) getActivity().getApplication();
Intent intent = new Intent(acanthus, PaintActivity.class);
acanthus.setAid(animationJson.getAid());
acanthus.setAid(aid);
startActivity(intent);
}
 
// 引っ張って更新するSwipeRefreshLayoutを作成
View
6
app/src/main/java/org/ntlab/acanthus_client/views/main_menu_ui/home/HomeFragment.java
binding = FragmentHomeBinding.inflate(inflater, container, false);
View root = binding.getRoot();
 
ListView listView = binding.animationView;
 
// homeViewModel.updateGallery();
//
// final TextView textView = binding.textHome;
// homeViewModel.getText().observe(getViewLifecycleOwner(), new Observer<String>() {
// @Override
 
// SwipeRefreshLayoutを作成
createSwipeRefreshLayout();
 
homeViewModel.updateGallery(acanthus);
updateGallery();
 
homeViewModel.getAnimationJson().observe(getViewLifecycleOwner(), new Observer<Collection<AnimationJson>>() {
@Override
public void onChanged(Collection<AnimationJson> animationJsons) {
 
// ひっぱり更新の処理
@Override
public void onRefresh() {
homeViewModel.updateGallery(acanthus);
updateGallery();
mSwipeRefreshLayout.setRefreshing(false);
}
}
View
189
app/src/main/java/org/ntlab/acanthus_client/views/paint/InviteActivity.java
import android.widget.BaseAdapter;
import android.widget.ListView;
 
import androidx.appcompat.app.AppCompatActivity;
import androidx.lifecycle.Observer;
import androidx.lifecycle.ViewModelProvider;
 
import org.ntlab.acanthus_client.Acanthus;
import org.ntlab.acanthus_client.R;
import org.ntlab.acanthus_client.entities.Account;
import org.ntlab.acanthus_client.entities.AccountJson;
import org.ntlab.acanthus_client.entities.EditorJson;
import org.ntlab.acanthus_client.entities.FollowerJson;
import org.ntlab.acanthus_client.entities.InvitesJson;
import org.ntlab.acanthus_client.entities.WorkJson;
import org.ntlab.acanthus_client.views.main_menu_ui.edit.EditViewModel;
 
public class InviteActivity extends AppCompatActivity implements AdapterView.OnItemClickListener {
import java.util.ArrayList;
import java.util.Collection;
 
public class InviteActivity extends AppCompatActivity {
private InviteViewModel inviteViewModel;
private static final String[] scenes = {
"UserName",
};
private Integer aid;
private Integer uid;
private Integer invitedUid;
private String ownerToken;
private Acanthus acanthus;
private ArrayList<Integer> followersUidList = new ArrayList<>();
private ArrayList<String> followersNameList = new ArrayList<>();
private ArrayList<Integer> collectionAccountUid = new ArrayList<>();
private EditorJson editorJson;
private InvitesJson invitedUidList;
private Integer followersNameIndex;
 
//-----------------------------------------------------------------
@Override
protected void onCreate(Bundle savedInstanceState) {
init();
setContentView((R.layout.activity_invite));
// ListViewのインスタンスを生成
ListView listView = findViewById(R.id.list_view);
Acanthus acanthus = (Acanthus) getApplication();
inviteViewModel = new ViewModelProvider(this).get(InviteViewModel.class);
aid = acanthus.getAid();
uid = 1;
ownerToken = acanthus.getPreferenceToken();
 
// BaseAdapter を継承したadapterのインスタンスを生成
// レイアウトファイル list.xml を activity_main.xml に
// inflate するためにadapterに引数として渡す
BaseAdapter adapter = new ListViewAdapter(this.getApplicationContext(), R.layout.list, scenes);
 
// ListViewにadapterをセット
listView.setAdapter(adapter);
//フォロワー情報を取得する
inviteViewModel.startFollowersUidJson(uid, aid, ownerToken);
inviteViewModel.getFollowerUidJson().observe(this, new Observer<FollowerJson>() {
@Override
public void onChanged(FollowerJson followerUidJson) {
followersUidList = inviteViewModel.getFollowerUidJson().getValue().getFollowerUids();
followersNameList = inviteViewModel.getFollowerUidJson().getValue().getFollowerNames();
inviteViewModel.startGalleryInvites(aid, ownerToken);
}
});
 
// クリックリスナーをセット
listView.setOnItemClickListener(this);
//すべての招待情報を取得する
inviteViewModel.getInvitesJson().observe(this, new Observer<InvitesJson>() {
@Override
public void onChanged(InvitesJson collectionAccount) {
invitedUidList = inviteViewModel.getInvitesJson().getValue();
 
inviteViewModel.startGalleryEditors(aid);
}
});
 
inviteViewModel.getEditorJson().observe(this, new Observer<EditorJson>() {
@Override
public void onChanged(EditorJson collectionAccount) {
editorJson = inviteViewModel.getEditorJson().getValue();
 
if(editorJson != null){
for(Integer editorUid : editorJson.getUid()){
followersNameIndex = followersUidList.indexOf(editorUid);
followersUidList.remove(editorUid);
followersNameList.remove(followersNameIndex);
}
}
 
if(invitedUidList != null){
for(Integer invitedUid : invitedUidList.getInvites()){
followersNameList.remove(followersUidList.indexOf(invitedUid));
followersUidList.remove(invitedUid);
}
}
 
// BaseAdapter を継承したadapterのインスタンスを生成
// レイアウトファイル list.xml を activity_main.xml に
// inflate するためにadapterに引数として渡す
BaseAdapter adapter = new ListViewAdapter(getApplication(), R.layout.invites_list, followersNameList);
 
// ListViewにadapterをセット
listView.setAdapter(adapter);
 
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) {
invitedUid = followersUidList.get(position);
inviteViewModel.addInvite(aid, uid.toString(), invitedUid.toString(), ownerToken);
}
});
}
});
 
inviteViewModel.getMessage().observe(this, new Observer<Boolean>() {
@Override
public void onChanged(Boolean message) {
finish();
}
});
}
 
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Intent intent = new Intent(
this.getApplicationContext(), PaintActivity.class);
 
// clickされたpositionのtextとphotoのID
String selectedText = scenes[position];
// インテントにセット
intent.putExtra("Text", selectedText);
 
// SubActivityへ遷移
startActivity(intent);
}
 
//-----------------------------------------------------------------
// init
private void init() {
Acanthus acanthus = (Acanthus) getApplication();
inviteViewModel = new ViewModelProvider(this).get(InviteViewModel.class);
}
}
View
160
app/src/main/java/org/ntlab/acanthus_client/views/paint/InviteViewModel.java
package org.ntlab.acanthus_client.views.paint;
 
import android.util.Log;
 
import androidx.lifecycle.LiveData;
import androidx.lifecycle.MutableLiveData;
import androidx.lifecycle.ViewModel;
 
import org.ntlab.acanthus_client.Acanthus;
import org.ntlab.acanthus_client.entities.Account;
import org.ntlab.acanthus_client.entities.AccountJson;
import org.ntlab.acanthus_client.entities.AidJson;
import org.ntlab.acanthus_client.entities.Animation;
import org.ntlab.acanthus_client.entities.AnimationJson;
import org.ntlab.acanthus_client.entities.EditorJson;
import org.ntlab.acanthus_client.entities.FollowerJson;
import org.ntlab.acanthus_client.entities.InvitesJson;
import org.ntlab.acanthus_client.resources.accounts.AccountsRest;
import org.ntlab.acanthus_client.resources.accounts.FollowersRest;
import org.ntlab.acanthus_client.resources.gallery.EditorsRest;
import org.ntlab.acanthus_client.resources.gallery.GalleryRest;
import org.ntlab.acanthus_client.resources.gallery.InvitesRest;
 
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
 
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
import retrofit2.Retrofit;
import retrofit2.converter.jackson.JacksonConverterFactory;
 
public class InviteViewModel extends ViewModel {
 
private MutableLiveData<FollowerJson> followersUidJsonMutableLiveData;
private MutableLiveData<Collection<AccountJson>> collectionAccountJsonMutableLiveData;
private MutableLiveData<InvitesJson> collectionInvitesJsonMutableLiveData;
private MutableLiveData<Boolean> messageMutableLiveData;
private MutableLiveData<EditorJson> editorJsonMutableLiveData;
 
 
public InviteViewModel() {
this.followersUidJsonMutableLiveData = new MutableLiveData<>();
this.collectionAccountJsonMutableLiveData = new MutableLiveData<>();
this.collectionInvitesJsonMutableLiveData = new MutableLiveData<>();
this.messageMutableLiveData = new MutableLiveData<>();
this.editorJsonMutableLiveData = new MutableLiveData<>();
}
 
public LiveData<FollowerJson> getFollowerUidJson() {
return this.followersUidJsonMutableLiveData;
}
 
public LiveData<Collection<AccountJson>> getCollectionAccountJson() {
return this.collectionAccountJsonMutableLiveData;
}
 
public LiveData<InvitesJson> getInvitesJson() {
return this.collectionInvitesJsonMutableLiveData;
}
 
public LiveData<Boolean> getMessage() {
return this.messageMutableLiveData;
}
 
public LiveData<EditorJson> getEditorJson() {
return this.editorJsonMutableLiveData;
}
 
public void startFollowersUidJson(Integer uid, Integer aid, String ownerToken){
Retrofit retrofit = new Retrofit.Builder()
.baseUrl("http://nitta-lab-www.is.konan-u.ac.jp/acanthus/")
.addConverterFactory(JacksonConverterFactory.create())
.build();
final FollowersRest followersRest = retrofit.create(FollowersRest.class);
Call<FollowerJson> call = followersRest.getFollowers(uid);
call.enqueue(new Callback<FollowerJson>() {
@Override
public void onResponse(Call<FollowerJson> call, Response<FollowerJson> response) {
if(response.isSuccessful()){
if (response.body() != null) {
followersUidJsonMutableLiveData.setValue(response.body());
}
}
}
 
@Override
public void onFailure(Call<FollowerJson> call, Throwable t) {
startGalleryInvites(aid, ownerToken);
}
});
}
 
public void startGalleryInvites(Integer aid, String ownerToken){
Retrofit retrofit = new Retrofit.Builder()
.baseUrl("http://nitta-lab-www.is.konan-u.ac.jp/acanthus/")
.addConverterFactory(JacksonConverterFactory.create())
.build();
final InvitesRest invitesRest = retrofit.create(InvitesRest.class);
Call<InvitesJson> call = invitesRest.isGalleryInvites(aid, null, null, ownerToken);
call.enqueue(new Callback<InvitesJson>() {
@Override
public void onResponse(Call<InvitesJson> call, Response<InvitesJson> response) {
if(response.isSuccessful()){
if (response.body() != null) {
collectionInvitesJsonMutableLiveData.setValue(response.body());
}
}
}
 
@Override
public void onFailure(Call<InvitesJson> call, Throwable t) {
startGalleryEditors(aid);
}
});
}
 
public void startGalleryEditors(Integer aid){
Retrofit retrofit = new Retrofit.Builder()
.baseUrl("http://nitta-lab-www.is.konan-u.ac.jp/acanthus/")
.addConverterFactory(JacksonConverterFactory.create())
.build();
final EditorsRest invitesRest = retrofit.create(EditorsRest.class);
Call<EditorJson> call = invitesRest.getEditors(aid);
call.enqueue(new Callback<EditorJson>() {
@Override
public void onResponse(Call<EditorJson> call, Response<EditorJson> response) {
if(response.isSuccessful()){
if (response.body() != null) {
editorJsonMutableLiveData.setValue(response.body());
}
}
}
 
@Override
public void onFailure(Call<EditorJson> call, Throwable t) {
editorJsonMutableLiveData.setValue(null);
}
});
}
 
 
public void addInvite(Integer aid, String ownerUid, String invitedUid, String ownerToken){
Retrofit retrofit = new Retrofit.Builder()
.baseUrl("http://nitta-lab-www.is.konan-u.ac.jp/acanthus/")
.addConverterFactory(JacksonConverterFactory.create())
.build();
final InvitesRest invitesRest = retrofit.create(InvitesRest.class);
Call<Boolean> call = invitesRest.addInvite(aid, ownerUid, invitedUid, ownerToken);
call.enqueue(new Callback<Boolean>() {
@Override
public void onResponse(Call<Boolean> call, Response<Boolean> response) {
if(response.isSuccessful()){
if (response.body() != null) {
messageMutableLiveData.setValue(response.body());
}
}
}
 
@Override
public void onFailure(Call<Boolean> call, Throwable t) {
}
});
}
}
View
16
app/src/main/java/org/ntlab/acanthus_client/views/paint/ListViewAdapter.java
import android.widget.TextView;
 
import org.ntlab.acanthus_client.R;
 
import java.util.ArrayList;
import java.util.Collection;
 
public class ListViewAdapter extends BaseAdapter {
 
static class ViewHolder {
TextView textView;
}
 
private LayoutInflater inflater;
private int itemLayoutId;
private String[] titles;
private ArrayList<String> titles = new ArrayList<>();
private int[] ids;
 
ListViewAdapter(Context context, int itemLayoutId,
String[] scenes) {
ArrayList<String> collectionAccountName) {
super();
this.inflater = (LayoutInflater)
context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
this.itemLayoutId = itemLayoutId;
this.titles = scenes;
this.titles = collectionAccountName;
}
 
@Override
public View getView(int position, View convertView, ViewGroup parent) {
// activity_main.xml に list.xml を inflate して convertView とする
convertView = inflater.inflate(itemLayoutId, parent, false);
// ViewHolder を生成
holder = new ViewHolder();
holder.textView = convertView.findViewById(R.id.textView);
holder.textView = convertView.findViewById(R.id.textViewInvitesName);
convertView.setTag(holder);
}
// holder を使って再利用
else {
holder = (ViewHolder) convertView.getTag();
}
 
// 現在の position にあるファイル名リストを holder の textView にセット
holder.textView.setText(titles[position]);
holder.textView.setText(titles.get(position));
 
return convertView;
}
 
@Override
public int getCount() {
// texts 配列の要素数
return titles.length;
return titles.size();
}
 
@Override
public Object getItem(int position) {
public long getItemId(int position) {
return 0;
}
}
View
8
app/src/main/java/org/ntlab/acanthus_client/views/paint/models/InvitesConnectionModel.java
Integer owner = 1;
String token = "abc0";
int dummyAid = 1111;
 
Call<String> call = invitesRest.addInvite(dummyAid, owner.toString(), invitedUid.toString(), token);
call.enqueue(new Callback<String>() {
Call<Boolean> call = invitesRest.addInvite(dummyAid, owner.toString(), invitedUid.toString(), token);
call.enqueue(new Callback<Boolean>() {
@Override
public void onResponse(Call<String> call, Response<String> response) {
public void onResponse(Call<Boolean> call, Response<Boolean> response) {
if (response.isSuccessful()) ;
}
 
@Override
public void onFailure(Call<String> call, Throwable t) {
public void onFailure(Call<Boolean> call, Throwable t) {
 
}
});
}
View
app/src/main/java/org/ntlab/acanthus_client/views/sign_up/SignUpActivity.java
View
app/src/main/res/layout/activity_login_screen.xml
View
app/src/main/res/layout/activity_sign_up.xml