-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix #27: add the step graphic in Parent Category Spinner under Add Ne…
…w Category
- Loading branch information
Showing
3 changed files
with
101 additions
and
23 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
|
||
<LinearLayout | ||
xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:layout_width="match_parent" | ||
android:layout_height="@dimen/category_row_height" | ||
android:orientation="horizontal" | ||
android:id="@+id/categoryRow" android:clickable="false"> | ||
<ImageView android:layout_width="@dimen/category_row_height" | ||
android:layout_height="@dimen/category_row_height" | ||
android:src="@drawable/ic_level_indicator" | ||
android:id="@+id/categoryRowLevelIndicator" android:scaleType="fitEnd"/> | ||
<TextView | ||
android:orientation="vertical" | ||
android:layout_width="fill_parent" | ||
android:layout_height="fill_parent" | ||
android:textAppearance="?android:attr/textAppearanceLarge" | ||
android:gravity="center_vertical" | ||
android:textColor="#464646" | ||
android:paddingLeft="6dip" | ||
android:paddingRight="6dip" | ||
android:checkMark="?android:attr/listChoiceIndicatorMultiple" | ||
android:id="@+id/categoryRowText"/> | ||
</LinearLayout> |
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
70 changes: 70 additions & 0 deletions
70
src/org/wordpress/android/ui/posts/ParentCategorySpinnerAdapter.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,70 @@ | ||
package org.wordpress.android.ui.posts; | ||
|
||
import android.content.Context; | ||
import android.text.Html; | ||
import android.view.LayoutInflater; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
import android.widget.BaseAdapter; | ||
import android.widget.ImageView; | ||
import android.widget.SpinnerAdapter; | ||
import android.widget.TextView; | ||
import org.wordpress.android.R; | ||
import org.wordpress.android.models.CategoryNode; | ||
|
||
import java.util.List; | ||
|
||
|
||
public class ParentCategorySpinnerAdapter extends BaseAdapter implements SpinnerAdapter { | ||
int mResourceId; | ||
List<CategoryNode> mObjects; | ||
Context mContext; | ||
|
||
public int getCount() { | ||
return mObjects.size(); | ||
} | ||
|
||
public CategoryNode getItem(int position) { | ||
return mObjects.get(position); | ||
} | ||
|
||
public long getItemId(int position) { | ||
return position; | ||
} | ||
|
||
public ParentCategorySpinnerAdapter(Context context, int resource, List<CategoryNode> objects) { | ||
super(); | ||
mContext = context; | ||
mObjects = objects; | ||
mResourceId = resource; | ||
} | ||
|
||
@Override | ||
public View getDropDownView(int position, View convertView, ViewGroup parent) { | ||
LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE); | ||
View rowView = inflater.inflate(mResourceId, parent, false); | ||
TextView textView = (TextView) rowView.findViewById(R.id.categoryRowText); | ||
ImageView levelIndicatorView = (ImageView) rowView.findViewById(R.id.categoryRowLevelIndicator); | ||
textView.setText(Html.fromHtml(getItem(position).getName())); | ||
int level = getItem(position).getLevel(); | ||
if (level == 1) { // hide ImageView | ||
levelIndicatorView.setVisibility(View.GONE); | ||
} else { | ||
ViewGroup.LayoutParams params = levelIndicatorView.getLayoutParams(); | ||
params.width = (params.width / 2) * level; | ||
levelIndicatorView.setLayoutParams(params); | ||
} | ||
return rowView; | ||
} | ||
|
||
@Override | ||
public View getView(int position, View convertView, ViewGroup parent) { | ||
LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE); | ||
View rowView = inflater.inflate(mResourceId, parent, false); | ||
TextView textView = (TextView) rowView.findViewById(R.id.categoryRowText); | ||
ImageView levelIndicatorView = (ImageView) rowView.findViewById(R.id.categoryRowLevelIndicator); | ||
textView.setText(Html.fromHtml(getItem(position).getName())); | ||
levelIndicatorView.setVisibility(View.GONE); | ||
return rowView; | ||
} | ||
} |