mirror of
https://github.com/freeedcom/ai-codereviewer.git
synced 2025-06-30 21:04:16 +00:00
add project adins
This commit is contained in:
parent
ad06ac5505
commit
f8f85d679d
5299 changed files with 625430 additions and 0 deletions
|
@ -0,0 +1,4 @@
|
|||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:state_enabled="false" android:color="@color/gradient_end" />
|
||||
<item android:state_enabled="true" android:color="@color/fontColor" />
|
||||
</selector>
|
|
@ -0,0 +1,84 @@
|
|||
package com.adins.mss.base.util;
|
||||
|
||||
import android.os.AsyncTask;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
* Generic implementation of AsyncTask which enable usage of AsyncTask without the hassle of creating a new class for each
|
||||
* implementation. It is done by creating an instance of GenericAsyncTask and pass the delegate (or callback) on constructor
|
||||
* <br>
|
||||
* The delegate is responsible of implementing onPreExecute(), doInBackground(), and onPostExecute(). Think of GenericTaskInterface
|
||||
* to AsyncTask is like Runnable to Thread
|
||||
* <p>
|
||||
* Same as AsyncTask, onPreExecute() and onPostExecute() runs on main thread, while doInBackground() runs on new thread. While in AsyncTask
|
||||
* we can customize the type of the parameters, GenericAsyncTask only communicate in String
|
||||
*
|
||||
* @author glen.iglesias
|
||||
*/
|
||||
public class GenericAsyncTask extends AsyncTask<String, String, String> {
|
||||
protected String errMessage = null;
|
||||
/**
|
||||
* A way to supply GenericAsyncTask with specific additional object
|
||||
*/
|
||||
private Map<String, Object> additionalObject;
|
||||
private GenericTaskInterface delegate;
|
||||
|
||||
public GenericAsyncTask(GenericTaskInterface delegate) {
|
||||
super();
|
||||
this.delegate = delegate;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPreExecute() {
|
||||
if (delegate != null) {
|
||||
delegate.onPreExecute(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String doInBackground(String... args) {
|
||||
String result = "";
|
||||
if (delegate != null) {
|
||||
result = delegate.doInBackground(this, args);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(String result) {
|
||||
if (delegate != null) {
|
||||
delegate.onPostExecute(this, result, errMessage);
|
||||
}
|
||||
}
|
||||
|
||||
public GenericTaskInterface getDelegate() {
|
||||
return delegate;
|
||||
}
|
||||
|
||||
public void setDelegate(GenericTaskInterface delegate) {
|
||||
this.delegate = delegate;
|
||||
}
|
||||
|
||||
public Map<String, Object> getAdditionalObject() {
|
||||
return additionalObject;
|
||||
}
|
||||
|
||||
public void setAdditionalObject(Map<String, Object> additionalObject) {
|
||||
this.additionalObject = additionalObject;
|
||||
}
|
||||
|
||||
public interface GenericTaskInterface {
|
||||
/**
|
||||
* Implementation of AsyncTask in GenericAsyncTask
|
||||
*
|
||||
* @param task
|
||||
*/
|
||||
void onPreExecute(GenericAsyncTask task);
|
||||
|
||||
String doInBackground(GenericAsyncTask task, String... args);
|
||||
|
||||
void onPostExecute(GenericAsyncTask task, String result, String errMsg);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,74 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/bgColor" >
|
||||
|
||||
<ScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
<androidx.cardview.widget.CardView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:cardCornerRadius="10dp"
|
||||
app:contentPadding="7dp"
|
||||
app:cardElevation="5dp"
|
||||
android:layout_marginTop="3dp"
|
||||
android:layout_marginLeft="3dp"
|
||||
android:layout_marginRight="3dp"
|
||||
android:layout_marginBottom="60dp"
|
||||
app:cardBackgroundColor="@color/fontColorWhite">
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
<TextView
|
||||
android:id="@+id/txtName"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingBottom="5dp"
|
||||
android:paddingTop="5dp"
|
||||
android:text="Name"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:drawableLeft="@drawable/ic_person_color"
|
||||
android:drawablePadding="5dp" />
|
||||
<TextView
|
||||
android:id="@+id/txtAddress"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingBottom="5dp"
|
||||
android:text="Address"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:drawableLeft="@drawable/ic_location_color"
|
||||
android:drawablePadding="5dp" />
|
||||
<TextView
|
||||
android:id="@+id/txtPhone1"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingBottom="5dp"
|
||||
android:text="Phone"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:drawableLeft="@drawable/ic_phone_color"
|
||||
android:drawablePadding="5dp" />
|
||||
<TextView
|
||||
android:id="@+id/txtPhone2"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingBottom="5dp"
|
||||
android:text="Phone"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:drawableLeft="@drawable/ic_phone_color"
|
||||
android:drawablePadding="5dp" />
|
||||
<ImageView
|
||||
android:id="@+id/accImage"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="150dp"
|
||||
android:layout_margin="10dp"
|
||||
android:scaleType="centerCrop"
|
||||
android:src="@drawable/img_notavailable" />
|
||||
</LinearLayout>
|
||||
</androidx.cardview.widget.CardView>
|
||||
</ScrollView>
|
||||
</RelativeLayout>
|
|
@ -0,0 +1,5 @@
|
|||
<vector android:height="50dp" android:tint="#B0003A"
|
||||
android:viewportHeight="24.0" android:viewportWidth="24.0"
|
||||
android:width="50dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<path android:fillColor="#FF000000" android:pathData="M9,16h6v-6h4l-7,-7 -7,7h4zM5,18h14v2L5,20z"/>
|
||||
</vector>
|
|
@ -0,0 +1,13 @@
|
|||
package com.soundcloud.android.crop.util;
|
||||
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
@Documented
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
@Target({ElementType.CONSTRUCTOR, ElementType.FIELD, ElementType.METHOD, ElementType.TYPE})
|
||||
public @interface VisibleForTesting {
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<set xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<scale
|
||||
android:fromXScale="1.0" android:toXScale="0.3"
|
||||
android:fromYScale="1.0" android:toYScale="0.3"
|
||||
android:pivotX="0%" android:pivotY="0%"
|
||||
android:duration="@android:integer/config_shortAnimTime"
|
||||
/>
|
||||
<alpha
|
||||
android:interpolator="@android:anim/accelerate_interpolator"
|
||||
android:fromAlpha="1.0" android:toAlpha="0.0"
|
||||
android:duration="@android:integer/config_shortAnimTime"
|
||||
/>
|
||||
</set>
|
Binary file not shown.
After Width: | Height: | Size: 4.4 KiB |
|
@ -0,0 +1,106 @@
|
|||
/*
|
||||
* Copyright (C) 2011 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.adins.libs.nineoldandroids.util;
|
||||
|
||||
|
||||
/**
|
||||
* A property is an abstraction that can be used to represent a <emb>mutable</em> value that is held
|
||||
* in a <em>host</em> object. The Property's {@link #set(Object, Object)} or {@link #get(Object)}
|
||||
* methods can be implemented in terms of the private fields of the host object, or via "setter" and
|
||||
* "getter" methods or by some other mechanism, as appropriate.
|
||||
*
|
||||
* @param <T> The class on which the property is declared.
|
||||
* @param <V> The type that this property represents.
|
||||
*/
|
||||
public abstract class Property<T, V> {
|
||||
|
||||
private final String mName;
|
||||
private final Class<V> mType;
|
||||
|
||||
/**
|
||||
* A constructor that takes an identifying name and {@link #getType() type} for the property.
|
||||
*/
|
||||
public Property(Class<V> type, String name) {
|
||||
mName = name;
|
||||
mType = type;
|
||||
}
|
||||
|
||||
/**
|
||||
* This factory method creates and returns a Property given the <code>class</code> and
|
||||
* <code>name</code> parameters, where the <code>"name"</code> parameter represents either:
|
||||
* <ul>
|
||||
* <li>a public <code>getName()</code> method on the class which takes no arguments, plus an
|
||||
* optional public <code>setName()</code> method which takes a value of the same type
|
||||
* returned by <code>getName()</code>
|
||||
* <li>a public <code>isName()</code> method on the class which takes no arguments, plus an
|
||||
* optional public <code>setName()</code> method which takes a value of the same type
|
||||
* returned by <code>isName()</code>
|
||||
* <li>a public <code>name</code> field on the class
|
||||
* </ul>
|
||||
* <p>
|
||||
* <p>If either of the get/is method alternatives is found on the class, but an appropriate
|
||||
* <code>setName()</code> method is not found, the <code>Property</code> will be
|
||||
* {@link #isReadOnly() readOnly}. Calling the {@link #set(Object, Object)} method on such
|
||||
* a property is allowed, but will have no effect.</p>
|
||||
* <p>
|
||||
* <p>If neither the methods nor the field are found on the class a
|
||||
* {@link NoSuchPropertyException} exception will be thrown.</p>
|
||||
*/
|
||||
public static <T, V> Property<T, V> of(Class<T> hostType, Class<V> valueType, String name) {
|
||||
return new ReflectiveProperty<T, V>(hostType, valueType, name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the {@link #set(Object, Object)} method does not set the value on the target
|
||||
* object (in which case the {@link #set(Object, Object) set()} method should throw a {@link
|
||||
* NoSuchPropertyException} exception). This may happen if the Property wraps functionality that
|
||||
* allows querying the underlying value but not setting it. For example, the {@link #of(Class,
|
||||
* Class, String)} factory method may return a Property with name "foo" for an object that has
|
||||
* only a <code>getFoo()</code> or <code>isFoo()</code> method, but no matching
|
||||
* <code>setFoo()</code> method.
|
||||
*/
|
||||
public boolean isReadOnly() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value on <code>object</code> which this property represents. If the method is unable
|
||||
* to set the value on the target object it will throw an {@link UnsupportedOperationException}
|
||||
* exception.
|
||||
*/
|
||||
public void set(T object, V value) {
|
||||
throw new UnsupportedOperationException("Property " + getName() + " is read-only");
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current value that this property represents on the given <code>object</code>.
|
||||
*/
|
||||
public abstract V get(T object);
|
||||
|
||||
/**
|
||||
* Returns the name for this property.
|
||||
*/
|
||||
public String getName() {
|
||||
return mName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the type for this property.
|
||||
*/
|
||||
public Class<V> getType() {
|
||||
return mType;
|
||||
}
|
||||
}
|
Binary file not shown.
|
@ -0,0 +1,240 @@
|
|||
package com.adins.mss.base.dynamicform;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
import android.widget.ToggleButton;
|
||||
|
||||
import com.adins.mss.base.GlobalData;
|
||||
import com.adins.mss.base.R;
|
||||
import com.adins.mss.base.crashlytics.FireCrash;
|
||||
import com.adins.mss.base.util.LocaleHelper;
|
||||
import com.adins.mss.constant.Global;
|
||||
import com.adins.mss.foundation.audio.AudioRecord;
|
||||
import com.adins.mss.foundation.db.dataaccess.TaskHDataAccess;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
public class VoiceNotePage extends Activity {
|
||||
public SurveyHeaderBean header;
|
||||
public int SURVEY_MODE;
|
||||
public boolean flag_timer = false;
|
||||
ToggleButton btnVoiceNotes;
|
||||
ImageButton btnPlay;
|
||||
ImageButton btnStop;
|
||||
Button btnSave;
|
||||
LinearLayout playerLayout;
|
||||
View view = null;
|
||||
private AudioRecord record;
|
||||
private Bundle mArguments;
|
||||
private Handler handler;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.voice_note_layout);
|
||||
overridePendingTransition(R.anim.activity_open_translate, R.anim.activity_close_scale);
|
||||
mArguments = getIntent().getExtras();
|
||||
int mMode = getIntent().getIntExtra(Global.BUND_KEY_MODE_SURVEY, 0);
|
||||
this.SURVEY_MODE = mMode;
|
||||
try {
|
||||
header = (SurveyHeaderBean) CustomerFragment.getHeader().clone();
|
||||
} catch (CloneNotSupportedException e) {
|
||||
header = CustomerFragment.getHeader();
|
||||
}
|
||||
if (header != null)
|
||||
initialize();
|
||||
else {
|
||||
Toast.makeText(getApplicationContext(), getString(R.string.customer_header_error), Toast.LENGTH_SHORT).show();
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void attachBaseContext(Context newBase) {
|
||||
Context context = newBase;
|
||||
Locale locale;
|
||||
try{
|
||||
locale = new Locale(GlobalData.getSharedGlobalData().getLocale());
|
||||
context = LocaleHelper.wrap(newBase, locale);
|
||||
} catch (Exception e) {
|
||||
locale = new Locale(LocaleHelper.ENGLSIH);
|
||||
context = LocaleHelper.wrap(newBase, locale);
|
||||
} finally {
|
||||
super.attachBaseContext(context);
|
||||
}
|
||||
}
|
||||
|
||||
private void initialize() {
|
||||
playerLayout = (LinearLayout) findViewById(R.id.recorderLayout);
|
||||
btnVoiceNotes = (ToggleButton) findViewById(R.id.btnVoiceNotes);
|
||||
TextView noVoiceNote = (TextView) findViewById(R.id.txtNoVoiceNote);
|
||||
btnPlay = (ImageButton) findViewById(R.id.btnPlay);
|
||||
btnStop = (ImageButton) findViewById(R.id.btnStop);
|
||||
btnSave = (Button) findViewById(R.id.buttonSave);
|
||||
btnSave.setVisibility(View.GONE);
|
||||
|
||||
record = new AudioRecord(this);
|
||||
|
||||
|
||||
if (SURVEY_MODE == Global.MODE_SURVEY_TASK ||
|
||||
SURVEY_MODE == Global.MODE_VIEW_SENT_SURVEY) {
|
||||
|
||||
if (!(TaskHDataAccess.STATUS_SEND_INIT.equals(header.getIs_prepocessed()) &&
|
||||
TaskHDataAccess.STATUS_SEND_SAVEDRAFT.equals(header.getStatus()))) {
|
||||
btnVoiceNotes.setEnabled(false);
|
||||
btnVoiceNotes.setClickable(false);
|
||||
btnVoiceNotes.setTextOff(getString(R.string.recording_not_allowed));
|
||||
if (header.getVoice_note() != null) {
|
||||
btnVoiceNotes.setVisibility(View.GONE);
|
||||
playerLayout.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
btnVoiceNotes.setVisibility(View.GONE);
|
||||
noVoiceNote.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
if (TaskHDataAccess.STATUS_SEND_SAVEDRAFT.equals(header.getStatus()) ||
|
||||
TaskHDataAccess.STATUS_SEND_DOWNLOAD.equals(header.getStatus()) ||
|
||||
TaskHDataAccess.STATUS_SEND_INIT.equals(header.getStatus())) {
|
||||
if (header.getVoice_note() != null) {
|
||||
btnVoiceNotes.setVisibility(View.VISIBLE);
|
||||
playerLayout.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
if (header.getPriority() == null)
|
||||
btnVoiceNotes.setVisibility(View.VISIBLE);
|
||||
playerLayout.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (header.getVoice_note() != null) {
|
||||
btnVoiceNotes.setVisibility(View.VISIBLE);
|
||||
playerLayout.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
btnVoiceNotes.setVisibility(View.VISIBLE);
|
||||
playerLayout.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
final Runnable runnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (!flag_timer) {
|
||||
btnVoiceNotes.setChecked(false);
|
||||
record.stop(view);
|
||||
header.setVoice_note(null);
|
||||
playerLayout.setVisibility(View.VISIBLE);
|
||||
btnSave.setVisibility(View.VISIBLE);
|
||||
btnVoiceNotes.setClickable(true);
|
||||
|
||||
Toast.makeText(getApplicationContext(), getString(R.string.recording_done),
|
||||
Toast.LENGTH_SHORT).show();
|
||||
handler.removeCallbacks(this);
|
||||
} else {
|
||||
handler.removeCallbacks(this);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
btnVoiceNotes.setOnClickListener(new View.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
view = v;
|
||||
stopPlayer(v);
|
||||
if (btnVoiceNotes.isChecked()) {
|
||||
//start record
|
||||
flag_timer = false;
|
||||
record.startRecording(v);
|
||||
playerLayout.setVisibility(View.GONE);
|
||||
btnSave.setVisibility(View.GONE);
|
||||
handler = new Handler();
|
||||
handler.postDelayed(runnable, 30000);
|
||||
|
||||
} else {
|
||||
//stop record
|
||||
flag_timer = true;
|
||||
record.stop(view);
|
||||
header.setVoice_note(null);
|
||||
playerLayout.setVisibility(View.VISIBLE);
|
||||
btnSave.setVisibility(View.VISIBLE);
|
||||
if (handler != null)
|
||||
handler.removeCallbacks(runnable);
|
||||
}
|
||||
}
|
||||
});
|
||||
btnSave.setOnClickListener(new View.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
byte[] voiceNotes = null;
|
||||
try {
|
||||
voiceNotes = record.saveAudioToByte();
|
||||
header.setVoice_note(voiceNotes);
|
||||
} catch (Exception e) {
|
||||
FireCrash.log(e);
|
||||
}
|
||||
Intent intent = new Intent();
|
||||
intent.putExtra(Global.BUND_KEY_DETAIL_DATA, voiceNotes);
|
||||
setResult(Activity.RESULT_OK, intent);
|
||||
finish();
|
||||
}
|
||||
});
|
||||
btnPlay.setOnClickListener(new View.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
playPlayer(v);
|
||||
btnSave.setVisibility(View.GONE);
|
||||
}
|
||||
});
|
||||
btnStop.setOnClickListener(new View.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
btnSave.setVisibility(View.VISIBLE);
|
||||
stopPlayer(v);
|
||||
try {
|
||||
if (DynamicFormActivity.getIsVerified() || DynamicFormActivity.getIsApproval()) {
|
||||
btnSave.setVisibility(View.GONE);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
FireCrash.log(e);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void playPlayer(View v) {
|
||||
if (SURVEY_MODE == Global.MODE_SURVEY_TASK ||
|
||||
SURVEY_MODE == Global.MODE_VIEW_SENT_SURVEY) {//
|
||||
if (header.getVoice_note() != null) {
|
||||
AudioRecord.playAudio(getApplicationContext(), header.getVoice_note());
|
||||
} else {
|
||||
record.play(v);
|
||||
}
|
||||
} else {
|
||||
if (header.getVoice_note() != null) {
|
||||
AudioRecord.playAudio(getApplicationContext(), header.getVoice_note());
|
||||
} else {
|
||||
record.play(v);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void stopPlayer(View v) {
|
||||
try {
|
||||
AudioRecord.stopPlay(v);
|
||||
} catch (Exception e) {
|
||||
FireCrash.log(e);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,95 @@
|
|||
package com.adins.mss.base.todolist.form.todaysplan;
|
||||
|
||||
import android.content.Context;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.core.graphics.drawable.DrawableCompat;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.adins.mss.base.R;
|
||||
import com.adins.mss.base.todolist.form.todaysplan.dummytaskplan.DummyPlan;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class TodayPlanDummyAdapter extends RecyclerView.Adapter<TodayPlanDummyAdapter.TodayPlanDummyViewHolder>{
|
||||
|
||||
private Context mContext;
|
||||
private List<DummyPlan> dummyDataset;
|
||||
|
||||
public TodayPlanDummyAdapter(Context context,List<DummyPlan> dummyDataset){
|
||||
mContext = context;
|
||||
this.dummyDataset = dummyDataset;
|
||||
}
|
||||
|
||||
public void setDummyDataset(List<DummyPlan> dummyDataset) {
|
||||
this.dummyDataset = dummyDataset;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public static List<DummyPlan> createDefaultDummyDataset(int count,boolean showDeleteBtn) {
|
||||
List<DummyPlan> dummyPlans = new ArrayList<>();
|
||||
for(int i=0; i<count; i++){
|
||||
DummyPlan dummyPlan = new DummyPlan(showDeleteBtn,"Sample Customer "+(i+1),"Sample Address "+(i+1),"Sample Phone "+(i+1));
|
||||
dummyPlans.add(dummyPlan);
|
||||
}
|
||||
return dummyPlans;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public TodayPlanDummyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int i) {
|
||||
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.fragment_dummy_today_plan_item, parent, false);
|
||||
return new TodayPlanDummyViewHolder(view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull TodayPlanDummyViewHolder todayPlanDummyViewHolder, int i) {
|
||||
DummyPlan data = dummyDataset.get(i);
|
||||
todayPlanDummyViewHolder.bind(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return dummyDataset.size();
|
||||
}
|
||||
|
||||
public class TodayPlanDummyViewHolder extends RecyclerView.ViewHolder{
|
||||
private ImageView deletePlanBtn;
|
||||
private TextView customerNameTxt;
|
||||
private TextView addressTxt;
|
||||
private TextView phoneTxt;
|
||||
|
||||
public TodayPlanDummyViewHolder(View view){
|
||||
super(view);
|
||||
deletePlanBtn = view.findViewById(R.id.dummyDeletePlanBtn);
|
||||
DrawableCompat.setTint(
|
||||
DrawableCompat.wrap(deletePlanBtn.getDrawable()),
|
||||
ContextCompat.getColor(mContext, R.color.gradient_end)
|
||||
);
|
||||
|
||||
|
||||
customerNameTxt = view.findViewById(R.id.dummyTaskName);
|
||||
addressTxt = view.findViewById(R.id.dummyTaskAddress);
|
||||
phoneTxt = view.findViewById(R.id.dummyTaskPhone);
|
||||
}
|
||||
|
||||
//called when notify data change or bind view holder event
|
||||
public void bind(DummyPlan dummyData){
|
||||
customerNameTxt.setText(dummyData.getCustomer());
|
||||
addressTxt.setText(dummyData.getAddress());
|
||||
phoneTxt.setText(dummyData.getPhone());
|
||||
if(dummyData.isShowDeleteBtn()){
|
||||
deletePlanBtn.setVisibility(View.VISIBLE);
|
||||
}
|
||||
else {
|
||||
deletePlanBtn.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,133 @@
|
|||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:padding="5dp"
|
||||
android:paddingTop="@dimen/activity_vertical_margin"
|
||||
android:background="@drawable/bg_grayscale">
|
||||
|
||||
<!-- <com.fima.cardsui.views.CardUI -->
|
||||
<!-- android:layout_below="@+id/export" -->
|
||||
<!-- android:id="@+id/cardsview" -->
|
||||
<!-- android:layout_width="match_parent" -->
|
||||
<!-- android:layout_height="match_parent"/> -->
|
||||
|
||||
|
||||
<!--<ImageView-->
|
||||
<!--android:id="@+id/app_logo"-->
|
||||
<!--android:layout_width="64dp"-->
|
||||
<!--android:layout_height="64dp"-->
|
||||
<!--android:layout_alignParentTop="true"-->
|
||||
<!--android:layout_centerHorizontal="true"-->
|
||||
<!--android:src="@drawable/icon_mss" />-->
|
||||
|
||||
<!--<TextView-->
|
||||
<!--android:id="@+id/txt_appName"-->
|
||||
<!--android:layout_width="wrap_content"-->
|
||||
<!--android:layout_height="wrap_content"-->
|
||||
<!--android:layout_below="@+id/btnCheckUpdate"-->
|
||||
<!--android:layout_centerHorizontal="true"-->
|
||||
<!--android:text="@string/app_name_order"-->
|
||||
<!--android:fontFamily="sans-serif-condensed"-->
|
||||
<!--android:layout_marginBottom="5dp"-->
|
||||
<!--android:textAppearance="?android:attr/textAppearanceSmall"-->
|
||||
<!--android:paddingLeft="@dimen/activity_horizontal_margin"-->
|
||||
<!--android:paddingRight="@dimen/activity_horizontal_margin" />-->
|
||||
|
||||
<!--<TextView-->
|
||||
<!--android:id="@+id/appDescription"-->
|
||||
<!--android:layout_width="match_parent"-->
|
||||
<!--android:layout_height="wrap_content"-->
|
||||
<!--android:layout_below="@+id/iconDivider"-->
|
||||
<!--android:ems="10"-->
|
||||
<!--android:gravity="center_horizontal"-->
|
||||
<!--android:layout_marginTop="8dp"-->
|
||||
<!--android:text="@string/app_desc_order"-->
|
||||
<!--android:textSize="@dimen/textSizeSmall_openSource"-->
|
||||
<!--android:paddingLeft="@dimen/activity_horizontal_margin"-->
|
||||
<!--android:paddingRight="@dimen/activity_horizontal_margin" />-->
|
||||
|
||||
<TextView
|
||||
android:id="@+id/txtAppVer"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/iconDivider"
|
||||
android:ems="10"
|
||||
android:gravity="center_horizontal"
|
||||
android:layout_marginTop="8dp"
|
||||
android:text="txtAppVer"
|
||||
android:textSize="@dimen/textSizeSmall_openSource"
|
||||
android:paddingLeft="@dimen/activity_horizontal_margin"
|
||||
android:paddingRight="@dimen/activity_horizontal_margin" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/txtOsVer"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/txtAppVer"
|
||||
android:ems="10"
|
||||
android:gravity="center_horizontal"
|
||||
android:layout_marginTop="8dp"
|
||||
android:text="txtOsVer"
|
||||
android:textSize="@dimen/textSizeSmall_openSource"
|
||||
android:paddingLeft="@dimen/activity_horizontal_margin"
|
||||
android:paddingRight="@dimen/activity_horizontal_margin" />
|
||||
<TextView
|
||||
android:id="@+id/txtBattery"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/txtOsVer"
|
||||
android:ems="10"
|
||||
android:gravity="center_horizontal"
|
||||
android:layout_marginTop="8dp"
|
||||
android:text="txtBattery"
|
||||
android:textSize="@dimen/textSizeSmall_openSource"
|
||||
android:paddingLeft="@dimen/activity_horizontal_margin"
|
||||
android:paddingRight="@dimen/activity_horizontal_margin" />
|
||||
<TextView
|
||||
android:id="@+id/txtDataUsage"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/txtBattery"
|
||||
android:ems="10"
|
||||
android:gravity="center_horizontal"
|
||||
android:layout_marginTop="8dp"
|
||||
android:text="txtDataUsage"
|
||||
android:textSize="@dimen/textSizeSmall_openSource"
|
||||
android:paddingLeft="@dimen/activity_horizontal_margin"
|
||||
android:paddingRight="@dimen/activity_horizontal_margin" />
|
||||
<TextView
|
||||
android:id="@+id/txtMemoryAvailable"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/txtDataUsage"
|
||||
android:ems="10"
|
||||
android:gravity="center_horizontal"
|
||||
android:layout_marginTop="8dp"
|
||||
android:text="txtMemoryAvailable"
|
||||
android:textSize="@dimen/textSizeSmall_openSource"
|
||||
android:paddingLeft="@dimen/activity_horizontal_margin"
|
||||
android:paddingRight="@dimen/activity_horizontal_margin" />
|
||||
|
||||
<View
|
||||
android:id="@+id/iconDivider"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="3dp"
|
||||
android:background="@android:color/darker_gray"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_centerHorizontal="true" />
|
||||
|
||||
|
||||
<!--<Button-->
|
||||
<!--android:id="@+id/btnCheckUpdate"-->
|
||||
<!--android:background="@drawable/button_background"-->
|
||||
<!--android:textColor="@color/tv_white"-->
|
||||
<!--android:layout_width="wrap_content"-->
|
||||
<!--android:layout_height="wrap_content"-->
|
||||
<!--android:layout_below="@+id/app_logo"-->
|
||||
<!--android:layout_centerHorizontal="true"-->
|
||||
<!--android:onClick="checkForUpdate"-->
|
||||
<!--android:text="@string/checkUpdate" />-->
|
||||
|
||||
</RelativeLayout>
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue