Skip to content

Commit

Permalink
Adding Files for First Time
Browse files Browse the repository at this point in the history
  • Loading branch information
mergehez committed Apr 8, 2017
1 parent 4589a32 commit 2ad0e56
Show file tree
Hide file tree
Showing 60 changed files with 1,584 additions and 0 deletions.
1 change: 1 addition & 0 deletions argmusicplayer/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
31 changes: 31 additions & 0 deletions argmusicplayer/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
apply plugin: 'com.android.library'

android {
compileSdkVersion 25
buildToolsVersion "25.0.0"

defaultConfig {
minSdkVersion 11
targetSdkVersion 25
versionCode 1
versionName "1.0"

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.0.1'
testCompile 'junit:junit:4.12'
}
25 changes: 25 additions & 0 deletions argmusicplayer/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in C:\Users\arges\AppData\Local\Android\sdk/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# Add any project specific keep options here:

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.arges.sepan.argmusicplayer;

import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;

import org.junit.Test;
import org.junit.runner.RunWith;

import static org.junit.Assert.*;

/**
* Instrumentation test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() throws Exception {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getTargetContext();

assertEquals("com.arges.sepan.argmusicplayer.test", appContext.getPackageName());
}
}
11 changes: 11 additions & 0 deletions argmusicplayer/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"

package="com.arges.sepan.argmusicplayer">
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<application android:allowBackup="true" android:label="@string/app_name"
android:supportsRtl="true">

</application>

</manifest>
Binary file added argmusicplayer/src/main/assets/zine.mp3
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.arges.sepan.argmusicplayer;

import android.view.View;
import android.view.ViewGroup;


class Arg {
static void disableContent(ViewGroup layout) {
layout.setEnabled(false);
for (int i = 0; i < layout.getChildCount(); i++) {
View child = layout.getChildAt(i);
if (child instanceof ViewGroup) {
Arg.disableContent((ViewGroup) child);
} else {
child.setEnabled(false);
}
}
}
static void enableContent(ViewGroup layout) {
layout.setEnabled(false);
for (int i = 0; i < layout.getChildCount(); i++) {
View child = layout.getChildAt(i);
if (child instanceof ViewGroup) {
Arg.disableContent((ViewGroup) child);
} else {
child.setEnabled(true);
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
package com.arges.sepan.argmusicplayer;

import android.media.audiofx.Equalizer;
import android.support.annotation.NonNull;
import android.support.annotation.RawRes;

public class ArgAudio{
private String title, path;
private boolean isPlaylist = false;
private AudioType type;

public ArgAudio(String title, String path, AudioType type){
this.title = title;
this.path = path;
this.type = type;
}
ArgAudio(String title, String path, AudioType type, boolean isPlaylist){
this.isPlaylist = isPlaylist;
this.title = title;
this.path = path;
this.type = type;
}

public static ArgAudio createFromRaw(@RawRes int rawId){
return new ArgAudio(String.valueOf(rawId), String.valueOf(rawId), AudioType.RAW);
}
public static ArgAudio createFromRaw(String title, @RawRes int rawId){
return new ArgAudio(title, String.valueOf(rawId), AudioType.RAW);
}
public static ArgAudio createFromAssets(String assetName){
return new ArgAudio(assetName, assetName, AudioType.ASSETS);
}
public static ArgAudio createFromAssets(String title, String assetName){
return new ArgAudio(title, assetName, AudioType.ASSETS);
}
public static ArgAudio createFromURL(String url) {
return new ArgAudio(url, url, AudioType.URL);
}
public static ArgAudio createFromURL(String title, String url) {
return new ArgAudio(title, url, AudioType.URL);
}
public static ArgAudio createFromFilePath(String filePath) {
return new ArgAudio(filePath, filePath, AudioType.FILE_PATH);
}
public static ArgAudio createFromFilePath(String title, String filePath) {
return new ArgAudio(title, filePath, AudioType.FILE_PATH);
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getPath() {
return path;
}
public void setPath(String path) {
this.path = path;
}
public AudioType getType() {
return type;
}
public void setType(AudioType type) {
this.type = type;
}
boolean isPlaylist(){return isPlaylist;}
ArgAudio makePlaylist(){ this.isPlaylist=true; return this;}
@Override
public boolean equals(Object obj) {
if(obj == null) return false;
else if (!(obj instanceof ArgAudio)) return false;
else{
ArgAudio a = (ArgAudio)obj;
return this.getTitle().equals(a.getTitle())
&& this.getType() == a.getType()
&& this.getPath().equals(a.getPath());
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
package com.arges.sepan.argmusicplayer;

import android.support.annotation.NonNull;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;

public class ArgAudioList{
ArrayList<ArgAudio> list = new ArrayList<>();
private int currentIndex = -1;
private boolean repeat = false;
public ArgAudioList(){ }

public boolean hasNext(){
if(repeat) return !isEmpty();
return !isEmpty() && size() != currentIndex + 1;
}
protected ArgAudio getNext(){
if(repeat && !isEmpty()) return get(currentIndex = getProperIndex(currentIndex+1));
return (isEmpty() || size()==currentIndex+1) ? null : get(++currentIndex);
}
protected void goToNext(){
if(hasNext()) currentIndex = getProperIndex(currentIndex+1);
}
public boolean hasPrev(){
if(repeat) return !isEmpty();
return !isEmpty() && currentIndex != 0;
}
protected ArgAudio getPrev(){
if(repeat && !isEmpty()) return get(currentIndex = getProperIndex(currentIndex-1));
return (isEmpty() || currentIndex==0) ? null : get(--currentIndex);
}
protected void goToPrev(){
if(hasPrev()) currentIndex = getProperIndex(currentIndex-1);
}
public int getCurrentIndex(){
return currentIndex;
}
public ArgAudio getCurrentAudio(){
return getCurrentIndex() >= 0 ? list.get(getCurrentIndex()) : null;
}
protected void setRepeat(boolean repeat){
this.repeat = repeat;
}
public boolean isRepeat(){
return this.repeat;
}
public void goToStart(){
currentIndex = 0;
}
private int getProperIndex(int index){
return (index % size());
}
public ArgAudioList add(@NonNull ArgAudio audio){
if(currentIndex==-1) currentIndex=0;
list.add(audio.makePlaylist());
return this;
}
public void add(int index, @NonNull ArgAudio element) {
list.add(index, element);
}
public boolean removeAll(Collection<ArgAudio> c) {
return list.removeAll(c);
}
public int size(){
return list.size();
}
public boolean isEmpty() {
return size() == 0;
}
public boolean contains(ArgAudio o) {
return list.contains(o);
}
public int indexOf(ArgAudio o) {
return list.indexOf(o);
}
public ArgAudio remove(int index) {
return list.remove(index);
}
public boolean remove(ArgAudio o) {
return list.remove(o);
}
public boolean addAll(Collection<? extends ArgAudio> c) {
return list.addAll(c);
}
public void clear() {
list.clear();
}
public ArgAudio get(int index) {
return list.get(index);
}
@NonNull
public Iterator<ArgAudio> iterator() {
return list.iterator();
}
public ArgAudio set(int index, ArgAudio element) {
return list.set(index, element);
}
public boolean addAll(int index, Collection<? extends ArgAudio> c) {
return list.addAll(index, c);
}

@Override
public boolean equals(Object obj) {
if(obj == null) return false;
else if (!(obj instanceof ArgAudioList)) return false;
else {
ArgAudioList a = (ArgAudioList) obj;
return !(a.isEmpty() || this.isEmpty()) && this.size() == a.size() && this.get(0).equals(a.get(0));
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package com.arges.sepan.argmusicplayer;

import android.content.Context;
import android.text.Html;
import android.util.AttributeSet;
import android.widget.RelativeLayout;
import android.widget.TextView;

/**
* Created by arges on 4/5/2017.
*/

public class ArgErrorView extends RelativeLayout {
public ArgErrorView(Context context) {
super(context);
inflate(getContext(), R.layout.errorpanel, this);
init();
}

public ArgErrorView(Context context, AttributeSet attrs) {
super(context, attrs);
inflate(getContext(), R.layout.errorpanel, this);
init();
}

public ArgErrorView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
init();
}
private void init(){
inflate(getContext(), R.layout.errorpanel, this);
}
public void show(){
this.setVisibility(VISIBLE);
}
public void hide(){
this.setVisibility(INVISIBLE);
}
public interface OnClickListener{
void onClick();
}
}
Loading

0 comments on commit 2ad0e56

Please sign in to comment.