Skip to content

Commit

Permalink
Language Page Redesigned.
Browse files Browse the repository at this point in the history
Images provided for each programming language.
  • Loading branch information
amanmehara committed Dec 19, 2015
1 parent 3d4bd68 commit 56b8b48
Show file tree
Hide file tree
Showing 13 changed files with 80 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import org.json.JSONArray;
import org.json.JSONException;

public class LanguageAdapter extends RecyclerView.Adapter<LanguageAdapter.ViewHolder> {

private String language;

private JSONArray mDataset;

private ListClickListener listClickListener;
Expand All @@ -36,10 +39,62 @@ public LanguageAdapter.ViewHolder onCreateViewHolder(ViewGroup viewGroup, int i)
@Override
public void onBindViewHolder(LanguageAdapter.ViewHolder viewHolder, int i) {
try {
viewHolder.mTextView.setText(mDataset.getString(i));
language = mDataset.getString(i);
} catch (JSONException e) {
e.printStackTrace();
}

switch (language) {
case "c":
viewHolder.mImageView.setImageResource(R.drawable.c);
viewHolder.mTextView.setText("C");
break;
case "cpp":
viewHolder.mImageView.setImageResource(R.drawable.cpp);
viewHolder.mTextView.setText("C++");
break;
case "csharp":
viewHolder.mImageView.setImageResource(R.drawable.csharp);
viewHolder.mTextView.setText("C#");
break;
case "fsharp":
viewHolder.mImageView.setImageResource(R.drawable.fsharp);
viewHolder.mTextView.setText("F#");
break;
case "groovy":
viewHolder.mImageView.setImageResource(R.drawable.groovy);
viewHolder.mTextView.setText("Groovy");
break;
case "java":
viewHolder.mImageView.setImageResource(R.drawable.java);
viewHolder.mTextView.setText("Java");
break;
case "javascript":
viewHolder.mImageView.setImageResource(R.drawable.javascript);
viewHolder.mTextView.setText("JavaScript");
break;
case "php":
viewHolder.mImageView.setImageResource(R.drawable.php);
viewHolder.mTextView.setText("PHP");
break;
case "python":
viewHolder.mImageView.setImageResource(R.drawable.python);
viewHolder.mTextView.setText("Python");
break;
case "scala":
viewHolder.mImageView.setImageResource(R.drawable.scala);
viewHolder.mTextView.setText("Scala");
break;
case "sql":
viewHolder.mImageView.setImageResource(R.drawable.sql);
viewHolder.mTextView.setText("SQL");
break;
default:
viewHolder.mImageView.setImageResource(R.drawable.ic_circle_logo);
viewHolder.mTextView.setText(language);
}


}

@Override
Expand All @@ -53,10 +108,12 @@ public interface ListClickListener {

public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
public TextView mTextView;
public ImageView mImageView;

public ViewHolder(View v) {
super(v);
mTextView = (TextView) v.findViewById(R.id.language_name);
mImageView = (ImageView) v.findViewById(R.id.language_image);
v.setOnClickListener(this);
}

Expand Down
Binary file added android/src/main/res/drawable-xhdpi/c.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added android/src/main/res/drawable-xhdpi/cpp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added android/src/main/res/drawable-xhdpi/csharp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added android/src/main/res/drawable-xhdpi/fsharp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added android/src/main/res/drawable-xhdpi/groovy.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added android/src/main/res/drawable-xhdpi/java.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added android/src/main/res/drawable-xhdpi/php.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added android/src/main/res/drawable-xhdpi/python.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added android/src/main/res/drawable-xhdpi/scala.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added android/src/main/res/drawable-xhdpi/sql.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
31 changes: 22 additions & 9 deletions android/src/main/res/layout/language_list.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,33 @@

<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="72dp"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:background="?android:attr/selectableItemBackground"
android:layout_marginTop="8dp"
card_view:cardCornerRadius="4dp">

<TextView
android:id="@+id/language_name"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:background="?android:attr/selectableItemBackground"
android:gravity="center"
android:textSize="20sp"/>
<LinearLayout android:id="@+id/language_info"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="?android:attr/selectableItemBackground"
android:padding="8sp">
<ImageView android:id="@+id/language_image"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.3"
android:layout_gravity="center_vertical|center_horizontal"/>
<TextView
android:id="@+id/language_name"
android:layout_width="0dp"
android:layout_weight="0.7"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:textSize="24sp"
android:paddingLeft="8sp"/>
</LinearLayout>


</android.support.v7.widget.CardView>
</LinearLayout>

0 comments on commit 56b8b48

Please sign in to comment.