Skip to content
Snippets Groups Projects
Commit fc51fe29 authored by Jawnnypoo's avatar Jawnnypoo
Browse files

Selecting accounts gets its own view

parent 3e35f388
No related branches found
No related tags found
No related merge requests found
Pipeline #
Loading
Loading
@@ -81,6 +81,7 @@ dependencies {
compile 'com.github.Commit451:Jounce:1.0.1'
compile 'com.pnikosis:materialish-progress:1.7'
compile 'com.jawnnypoo:physicslayout:1.0.1'
compile 'com.alexgwyn.recyclerviewsquire:recyclerviewsquire:0.0.5'
compile 'com.github.ivbaranov:materiallettericon:0.2.2'
compile 'com.github.johnkil.android-robototextview:robototextview:2.5.0'
compile 'com.github.alorma:diff-textview:1.3.0'
Loading
Loading
package com.commit451.gitlab.widget;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import com.alexgwyn.recyclerviewsquire.TypedViewHolder;
import com.commit451.gitlab.R;
import com.commit451.gitlab.api.GitLabClient;
import com.commit451.gitlab.model.Account;
import com.commit451.gitlab.transformation.CircleTransformation;
import com.commit451.gitlab.util.ImageUtil;
import butterknife.BindView;
import butterknife.ButterKnife;
/**
* A signed in account
*/
public class AccountViewHolder extends TypedViewHolder<Account> {
public static AccountViewHolder inflate(ViewGroup parent) {
View view = LayoutInflater.from(parent.getContext())
.inflate(R.layout.widget_item_account, parent, false);
return new AccountViewHolder(view);
}
@BindView(R.id.account_image) ImageView mImageView;
@BindView(R.id.account_username) TextView mUsernameView;
@BindView(R.id.account_server) TextView mServerView;
public AccountViewHolder(View view) {
super(view);
ButterKnife.bind(this, view);
}
@Override
public void bind(int position, Account item) {
mServerView.setText(item.getServerUrl().toString());
mUsernameView.setText(item.getUser().getUsername());
GitLabClient.getPicasso()
.load(ImageUtil.getAvatarUrl(item.getUser(), itemView.getResources().getDimensionPixelSize(R.dimen.user_list_image_size)))
.transform(new CircleTransformation())
.into(mImageView);
}
}
package com.commit451.gitlab.widget;
import android.view.ViewGroup;
import com.alexgwyn.recyclerviewsquire.ClickableArrayAdapter;
import com.commit451.gitlab.model.Account;
/**
* Adapter to show all the accounts
*/
public class AccountsAdapter extends ClickableArrayAdapter<Account, AccountViewHolder> {
@Override
public AccountViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
return AccountViewHolder.inflate(parent);
}
@Override
public void onBindViewHolder(AccountViewHolder holder, int position) {
super.onBindViewHolder(holder, position);
holder.bind(position, get(position));
}
}
Loading
Loading
@@ -9,9 +9,9 @@ import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.TextView;
 
import com.alexgwyn.recyclerviewsquire.ClickableArrayAdapter;
import com.commit451.gitlab.R;
import com.commit451.gitlab.activity.BaseActivity;
import com.commit451.gitlab.adapter.AccountsAdapter;
import com.commit451.gitlab.data.Prefs;
import com.commit451.gitlab.model.Account;
 
Loading
Loading
@@ -58,20 +58,11 @@ public class FeedWidgetConfigureActivity extends BaseActivity {
 
mToolbar.setTitle(R.string.widget_choose_account);
 
mAccountAdapter = new AccountsAdapter(this, new AccountsAdapter.Listener() {
mAccountAdapter = new AccountsAdapter();
mAccountAdapter.setOnItemClickListener(new ClickableArrayAdapter.OnItemClickListener<Account>() {
@Override
public void onAccountClicked(Account account) {
saveWidgetConfig(account);
}
@Override
public void onAddAccountClicked() {
}
@Override
public void onAccountLogoutClicked(Account account) {
public void onItemClicked(ClickableArrayAdapter<Account, ?> adapter, View view, int position) {
saveWidgetConfig(adapter.get(position));
}
});
mList.setLayoutManager(new LinearLayoutManager(this));
Loading
Loading
@@ -89,7 +80,7 @@ public class FeedWidgetConfigureActivity extends BaseActivity {
mTextMessage.setVisibility(View.VISIBLE);
} else {
mTextMessage.setVisibility(View.GONE);
mAccountAdapter.setAccounts(accounts);
mAccountAdapter.clearAndFill(accounts);
}
}
 
Loading
Loading
Loading
Loading
@@ -22,18 +22,13 @@
android:layout_width="match_parent"
android:layout_height="match_parent">
 
<com.commit451.gitlab.view.LabCoatSwipeRefreshLayout
android:id="@+id/swipe_layout"
android:layout_width="match_parent"
android:layout_height="match_parent" >
 
<android.support.v7.widget.RecyclerView
android:id="@+id/list"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
<android.support.v7.widget.RecyclerView
android:id="@+id/list"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
 
</com.commit451.gitlab.view.LabCoatSwipeRefreshLayout>
 
<TextView
android:id="@+id/message_text"
Loading
Loading
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/list_item"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="8dp"
android:minHeight="?android:attr/listPreferredItemHeight"
android:foreground="?attr/selectableItemBackground">
<ImageView
android:id="@+id/account_image"
android:layout_width="@dimen/image_size"
android:layout_height="@dimen/image_size"
android:layout_marginRight="8dp"
android:layout_gravity="center_vertical"
android:contentDescription="@null"
tools:src="@drawable/ic_assign_24dp"
/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/image_size"
android:layout_marginRight="@dimen/image_size"
android:layout_gravity="center_vertical"
android:paddingLeft="8dp"
android:paddingRight="8dp"
android:orientation="vertical">
<TextView
android:id="@+id/account_username"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="@dimen/text_size_small"
android:maxLines="2"
android:ellipsize="end"
tools:text="Jawnnypoo"/>
<TextView
android:id="@+id/account_server"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="@dimen/text_size_tiny"
tools:text="https://gitlab.com"/>
</LinearLayout>
</FrameLayout>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment