-
Notifications
You must be signed in to change notification settings - Fork 428
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Kunal
committed
Jan 20, 2020
1 parent
8fe143b
commit 3ea1fb6
Showing
11 changed files
with
311 additions
and
18 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
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
139 changes: 139 additions & 0 deletions
139
app/src/main/java/io/neurolab/activities/FAQActivity.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,139 @@ | ||
package io.neurolab.activities; | ||
|
||
import android.support.v7.app.AppCompatActivity; | ||
import android.os.Bundle; | ||
import android.text.Html; | ||
import android.text.method.LinkMovementMethod; | ||
import android.view.LayoutInflater; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
import android.widget.BaseExpandableListAdapter; | ||
import android.widget.ExpandableListAdapter; | ||
import android.widget.ExpandableListView; | ||
import android.widget.TextView; | ||
|
||
import io.neurolab.R; | ||
|
||
public class FAQActivity extends AppCompatActivity { | ||
|
||
private String[] questions; | ||
private String[][] answers; | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_faq); | ||
|
||
questions = getResources().getStringArray(R.array.faq_questions); | ||
|
||
String[] ans = getResources().getStringArray(R.array.faq_answers); | ||
answers = new String[ans.length][]; | ||
for (int i = 0; i < ans.length; i++) { | ||
answers[i] = new String[]{ans[i]}; | ||
} | ||
|
||
ExpandableListView listView; | ||
|
||
listView = findViewById(R.id.expListView); | ||
listView.setAdapter(new ExpandableListAdapter(questions, answers)); | ||
listView.setGroupIndicator(null); | ||
} | ||
|
||
public class ExpandableListAdapter extends BaseExpandableListAdapter { | ||
|
||
private final LayoutInflater inf; | ||
private String[] questions; | ||
private String[][] answers; | ||
|
||
public ExpandableListAdapter(String[] questions, String[][] answers) { | ||
this.questions = questions; | ||
this.answers = answers; | ||
inf = LayoutInflater.from(getApplication()); | ||
} | ||
|
||
@Override | ||
public int getGroupCount() { | ||
return questions.length; | ||
} | ||
|
||
@Override | ||
public int getChildrenCount(int questionPosition) { | ||
return answers[questionPosition].length; | ||
} | ||
|
||
@Override | ||
public Object getGroup(int questionPosition) { | ||
return questions[questionPosition]; | ||
} | ||
|
||
@Override | ||
public Object getChild(int questionPosition, int answerPosition) { | ||
return answers[questionPosition][answerPosition]; | ||
} | ||
|
||
@Override | ||
public long getGroupId(int questionPosition) { | ||
return questionPosition; | ||
} | ||
|
||
@Override | ||
public long getChildId(int questionPosition, int answerPosition) { | ||
return answerPosition; | ||
} | ||
|
||
@Override | ||
public boolean hasStableIds() { | ||
return true; | ||
} | ||
|
||
@Override | ||
public View getChildView(int questionPosition, final int childPosition, boolean isLastChild, View convertView, ViewGroup parent) { | ||
|
||
ViewHolder holder; | ||
View v = convertView; | ||
if (v == null) { | ||
v = inf.inflate(R.layout.list_item, parent, false); | ||
holder = new ViewHolder(); | ||
|
||
holder.text = (TextView) v.findViewById(R.id.lblListItem); | ||
v.setTag(holder); | ||
} else { | ||
holder = (ViewHolder) v.getTag(); | ||
} | ||
|
||
holder.text.setClickable(true); | ||
holder.text.setMovementMethod(LinkMovementMethod.getInstance()); | ||
holder.text.setText(Html.fromHtml(getChild(questionPosition, childPosition).toString())); | ||
|
||
return v; | ||
} | ||
|
||
@Override | ||
public View getGroupView(int questionPosition, boolean isExpanded, View convertView, ViewGroup parent) { | ||
ViewHolder holder; | ||
View v = convertView; | ||
if (v == null) { | ||
v = inf.inflate(R.layout.list_group, parent, false); | ||
|
||
holder = new ViewHolder(); | ||
holder.text = (TextView) v.findViewById(R.id.lblListHeader); | ||
v.setTag(holder); | ||
} else { | ||
holder = (ViewHolder) v.getTag(); | ||
} | ||
|
||
holder.text.setText(getGroup(questionPosition).toString()); | ||
|
||
return v; | ||
} | ||
|
||
@Override | ||
public boolean isChildSelectable(int questionPosition, int answerPosition) { | ||
return true; | ||
} | ||
|
||
private class ViewHolder { | ||
private TextView text; | ||
} | ||
} | ||
} |
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
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,9 @@ | ||
<vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:width="24dp" | ||
android:height="24dp" | ||
android:viewportWidth="24.0" | ||
android:viewportHeight="24.0"> | ||
<path | ||
android:fillColor="#FF000000" | ||
android:pathData="M20,2L4,2c-1.1,0 -1.99,0.9 -1.99,2L2,22l4,-4h14c1.1,0 2,-0.9 2,-2L22,4c0,-1.1 -0.9,-2 -2,-2zM13,14h-2v-2h2v2zM13,10h-2L11,6h2v4z"/> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:id="@+id/faq" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:background="#ffffff" | ||
android:orientation="vertical"> | ||
|
||
<ExpandableListView | ||
android:id="@+id/expListView" | ||
android:layout_margin="@dimen/faq_answer_margin_start" | ||
android:layout_width="match_parent" | ||
android:layout_height="@dimen/dimen_zero_dp" | ||
android:layout_weight="0.14" | ||
android:childDivider="@android:color/transparent"> | ||
</ExpandableListView> | ||
|
||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:layout_width="fill_parent" | ||
android:layout_height="wrap_content" | ||
android:background="#ffffff" | ||
android:orientation="horizontal"> | ||
|
||
<LinearLayout | ||
android:layout_width="@dimen/list_group_layout_width" | ||
android:layout_height="@dimen/list_group_layout_height" | ||
android:orientation="vertical"> | ||
|
||
<TextView | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:layout_marginTop="@dimen/faq_question_margin_top" | ||
android:text="@string/question" | ||
android:textAlignment="center" | ||
android:textColor="@color/colorPrimary" | ||
android:textSize="@dimen/faq_question_text_size" /> | ||
|
||
</LinearLayout> | ||
|
||
<LinearLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:orientation="vertical"> | ||
|
||
<TextView | ||
android:id="@+id/lblListHeader" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:gravity="center_vertical" | ||
android:justificationMode="inter_word" | ||
android:paddingBottom="@dimen/text_padding_top" | ||
android:paddingLeft="@dimen/text_padding_top" | ||
android:paddingTop="@dimen/text_padding_top" | ||
android:textColor="@color/colorPrimaryDark" | ||
android:textSize="@dimen/text_size" | ||
tools:ignore="SpUsage" /> | ||
|
||
</LinearLayout> | ||
|
||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?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="wrap_content" | ||
android:background="#ffffff" | ||
android:orientation="vertical"> | ||
|
||
<LinearLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content"> | ||
|
||
<TextView | ||
android:layout_width="wrap_content" | ||
android:layout_height="match_parent" | ||
android:layout_marginLeft="@dimen/faq_answer_margin_start" | ||
android:layout_marginTop="@dimen/faq_question_margin_top" | ||
android:text="@string/answer" | ||
android:textAlignment="center" | ||
android:textColor="#000000" | ||
android:textSize="@dimen/faq_question_text_size" /> | ||
|
||
<TextView | ||
android:id="@+id/lblListItem" | ||
android:layout_width="fill_parent" | ||
android:layout_height="match_parent" | ||
android:layout_marginLeft="@dimen/faq_answer_margin" | ||
android:paddingBottom="@dimen/list_item_padding" | ||
android:paddingLeft="@dimen/text_padding_top" | ||
android:paddingRight="@dimen/text_padding_top" | ||
android:paddingTop="@dimen/list_item_padding" | ||
android:textSize="@dimen/text_size_wavegen" /> | ||
|
||
</LinearLayout> | ||
|
||
</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
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
Oops, something went wrong.